forked from charlessimpson/dist-rpm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
quickbuild
executable file
·69 lines (59 loc) · 1.22 KB
/
quickbuild
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
#!/bin/bash
usage() { echo "Usage: $0 [-k] [-v] [-d DST] [-t TOPDIR] [-o OPT...] SPEC SOURCE..."; }
keep=0
dstdir=$(pwd)
verbosity="--quiet"
opts=""
while getopts "hkvo:t:" opt; do
case "${opt}" in
h)
usage
exit 0
;;
k)
keep=1
;;
v)
verbosity="-v"
;;
d)
dstdir=${OPTARG}
;;
t)
topdir=$(readlink -m ${OPTARG})
keep=1
;;
o)
opts+=" ${OPTARG}"
;;
*)
usage
exit 1
esac
done
if [ ${OPTIND} -gt $# ]; then
echo "$0: missing spec"
usage
exit 1
fi
shift $((OPTIND-1))
specname=$1
shift
if [ $# -lt 1 ]; then
echo "$0: missing source"
usage
exit 1
fi
if [ -z ${topdir} ]; then
topdir=$(mktemp -d)
fi
mkdir -p $topdir/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
cp "$specname" $topdir/SPECS
cp $* $topdir/SOURCES
rpmbuild $verbosity $opts --define="_topdir $topdir" -bb $topdir/SPECS/$(basename "$specname")
find $topdir/RPMS -name "*.rpm" -exec cp {} $dstdir \;
if [ "x"$keep == "x0" ]; then
rm -rf $topdir
else
echo "Keeping build directory: $topdir"
fi