-
Notifications
You must be signed in to change notification settings - Fork 1
/
make-rpm.sh
executable file
·94 lines (78 loc) · 1.9 KB
/
make-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
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/bash
set -e
RPMNAME=fuse-dkms
MODNAME=fuse
PACKAGE_VERSION=1.0
WHAT="fuse kernel module with feature backports"
DESCRIPTION="fuse kernel module with feature backports"
CHROOT=''
BUILD_PATH=$(pwd)/buildroot
run_cmd()
{
echo "Running: $@"
eval $@
}
BUILD_RELEASE=0000
if [ -n "${BUILD_ID}" ]; then
BUILD_RELEASE=${BUILD_ID}
fi
DATE="`date '+%Y%m%d'`"
GITID=""
if [ -z "$GITID" ]; then
GITID="`git rev-parse --short HEAD`"
if [ -z "$GITID" ]; then
echo "Failed to get the git commit-id, aborting."
echo
print_help
fi
fi
SUBRELEASE="${DATE}.${GITID}"
print_help()
{
prog=`basename $0`
echo
echo "Usage: $prog [options]"
echo " -b build path (rpm root)"
echo " -c chroot to start building rpms on"
echo " -h This help text"
echo " -r build release."
exit 1
}
while getopts "b:c:hr:" opt; do
case $opt in
b)
BUILD_PATH="$OPTARG"
;;
c)
CHROOT="schroot -c $OPTARG --"
;;
h)
print_help "$@"
;;
r)
BUILD_RELEASE="$OPTARG"
;;
*)
echo "Invalid option: -$OPTARG" >&2
print_help "$@"
;;
esac
done
#module purge
run_cmd rm -rf ${BUILD_PATH} || exit 1
run_cmd mkdir -p ${BUILD_PATH}/{BUILD,RPMS,SRPMS,SPECS,SOURCES} || exit 1
run_cmd 'sed -e "s/%description$/&\n$DESCRIPTION/" ${RPMNAME}.spec.in >${RPMNAME}.spec' || exit 1
${CHROOT} rpmbuild -bb ${RPMNAME}.spec \
--define "%RPMNAME ${RPMNAME}" \
--define "%MODNAME ${MODNAME}" \
--define "%WHAT ${WHAT}" \
--define "%RELEASE ${BUILD_RELEASE}" \
--define "%PACKAGE_VERSION ${PACKAGE_VERSION}" \
--define "%SUBRELEASE ${SUBRELEASE}" \
--define "_topdir ${BUILD_PATH}" \
|| exit 1
rm -f *.rpm && mv ${BUILD_PATH}/RPMS/noarch/* . || exit 1
rm -r ${BUILD_PATH} || exit 1
rm -f *.dat && md5sum *.rpm >md5sum.dat || exit
echo "finished building"
ls *.rpm