forked from tcler/bkr-client-improved
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_rpm.sh
executable file
·49 lines (41 loc) · 1.44 KB
/
build_rpm.sh
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
#!/bin/sh
# to build the bkr-client-improved rpm and update.
# autor: [email protected]
OPWD=$PWD
cd $(dirname ${0})
pkgName="bkr-client-improved"
configToCompatRhel5() {
local ni=i p=
[ $# -gt 0 ] && { ni=n; p=p; }
sed -r -$ni -e '/#+%_(source|binary)_payload/{s/#+//g;'$p'}' /usr/lib/rpm/macros
sed -r -$ni -e '/^%_(source|binary)_.*_algorithm/{s/^/#/;'$p'}' -e '/^%_binary_payload/{s/^/#/g;'$p'}' /usr/lib/rpm/redhat/macros
}
unconfigToCompatRhel5() {
local ni=i p=
[ $# -gt 0 ] && { ni=n; p=p; }
sed -r -$ni -e '/^%_(source|binary)_payload/{s/^/#/g;'$p'}' /usr/lib/rpm/macros
sed -r -$ni -e '/#+%_(source|binary)_.*_algorithm/{s/#+//g;'$p'}' -e '/#+%_binary_payload/{s/#+//g;'$p'}' /usr/lib/rpm/redhat/macros
}
rpmBild() {
local ftar=${1%%,*}
local dirList=${1#*,}
configToCompatRhel5
pushd sysroot >/dev/null
tar zcf $ftar ${dirList//,/ }
chmod +x ./usr/local/bin/tgz2rpm.sh
echo -e "#========> Delete old version rpm <========#\n"
echo -e "#========> Begin build new rpm <========#"
rm -f ~/rpmbuild/RPMS/*/${ftar%-*}-*.rpm
./usr/local/bin/tgz2rpm.sh $ftar
mv $ftar ../.; cd ..
popd >/dev/null
unconfigToCompatRhel5
}
mkdir -p sysroot/usr/local/{src,lib,bin} sysroot/etc
cp -arf lib/* sysroot/usr/local/lib/.
cp -af bkr/* utils/* cron_task/* sysroot/usr/local/bin/.
cp -af conf/* sysroot/etc/.
rpmBild ${pkgName}-0.12.129.tar.gz,usr,etc,var,opt
rm -rf sysroot
cp ~/rpmbuild/RPMS/*/${pkgName}*.rpm $OPWD/.
rm ${pkgName}*.tar.gz