-
Notifications
You must be signed in to change notification settings - Fork 55
/
rpmsquirt.sh
executable file
·54 lines (41 loc) · 1.04 KB
/
rpmsquirt.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
50
51
52
53
54
#!/bin/sh
RPMSQUIRT=/rpmsquirt.dat
RPMBASE=/root/rpmbuild
createpkg() {
PKGNAME=$1
PKGVERS=$2
if [ -f ${RPMBASE}/SPECS/${PKGNAME}.spec ]; then
rm -f ${RPMBASE}/SPECS/${PKGNAME}.spec
fi
cd /
mkdir -p ${RPMBASE}/{BUILD,RPMS,SOURCES,SPECS,SRPMS,tmp}
cd ${RPMBASE}/SPECS
rpmdev-newspec -t dummy ${PKGNAME}.spec
mv ${PKGNAME}.spec ${PKGNAME}.spec.pre
cat ${PKGNAME}.spec.pre | \
sed -e 's|1%{?dist}|0|g' | \
sed -e "s|1.0|${PKGVERS}|g" > \
${PKGNAME}.spec
cd ${RPMBASE}/SOURCES
touch ${PKGNAME}
tar zcf ${PKGNAME}-${PKGVERS}.tar.gz ${PKGNAME}
cd ${RPMBASE}
rpmbuild -ba SPECS/${PKGNAME}.spec
}
installpkg() {
PKGNAME=$1
PKGVERS=$2
rpm -ivh ${RPMBASE}/RPMS/x86_64/${PKGNAME}-${PKGVERS}-0.x86_64.rpm
}
if [ ! -f /rpmsquirt.dat ]; then
echo Error: /rpmsquirt.dat not found
exit 1
fi
while read -r line
do
_pkgname=`echo $line | awk -F ' ' '{print $1}'`
_pkgvers=`echo $line | awk -F ' ' '{print $2}'`
createpkg ${_pkgname} ${_pkgvers}
installpkg ${_pkgname} ${_pkgvers}
done < "${RPMSQUIRT}"
rm -rf /root/rpmbuild /rpmbuild/