-
Notifications
You must be signed in to change notification settings - Fork 136
Expand file tree
/
Copy pathob_build
More file actions
76 lines (66 loc) · 1.96 KB
/
ob_build
File metadata and controls
76 lines (66 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
set -x
set -e
if [ $# -lt 4 ]; then
echo "no enough parameters. Please provide project_name, version and release."
exit 1
fi
# Get system release
os_release=$(grep -Po '(?<=^ID=")[^"]*' /etc/os-release || true)
if [ -z "$os_release" ]; then
os_release=$(grep -Po '^ID=\K[^ ]+' /etc/os-release)
fi
set +e
source /etc/profile
set -e
project_dir=$1
project_name=$2
version=$3
release=$4
rpm_work_dir=${5:-rpm}
ob_build_script=${project_name}-build.sh
ob_build_spec=${project_name}.spec
ob_build_deps=${project_name}.deps
cur_dir=`pwd`
echo "cur dir: $cur_dir"
# check rpm work dir
if [ ! -d "${cur_dir}/${rpm_work_dir}" ]; then
echo "rpm work dir (${rpm_work_dir}) missing! Please create ${rpm_work_dir} in source code dir and place the packaging related files in the ${rpm_work_dir} dir."
exit 1
fi
# trigger building
echo "trigger building, current dir: "
pwd
cd $rpm_work_dir
ABS_PATH=`pwd`
if [[ x"$os_release" == x"alios" && x"$AONE_COMPATIBLE_AUTO_DEP_CREATE" == x"on" ]]; then
if [ -e "$ob_build_deps" ]; then
echo "execute dep_create for alios"
dep_create $ob_build_deps
echo "execute sw for alios"
sw
fi
fi
if [ -e "$ob_build_script" ]; then
bash $ob_build_script $project_dir $project_name $version $release
elif [ -e "$ob_build_spec" ]; then
if [[ x"$os_release" == x"alios" ]]; then
rpm_create $ob_build_spec -v $version -r $release
else
TOP_DIR=".rpm_create"
RPM_MACROS=$HOME/.rpmmacros
if [ -e $RPM_MACROS ]; then
mv -f $RPM_MACROS $RPM_MACROS.bak
fi
# prepare rpm build dirs
mkdir -p $TOP_DIR/BUILD
mkdir -p $TOP_DIR/RPMS
mkdir -p $TOP_DIR/SRPMS
echo "%_topdir $ABS_PATH/$TOP_DIR" > $RPM_MACROS
rpmbuild -bb $ob_build_spec
find $TOP_DIR/ -name "*.rpm" -exec mv {} . 2>/dev/null \;
fi
else
echo "packaging files missing! Please provide $ob_build_script or $ob_build_spec"
exit 1
fi