-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmake-stackage-dist-precompiled.sh
More file actions
executable file
·124 lines (106 loc) · 2.32 KB
/
make-stackage-dist-precompiled.sh
File metadata and controls
executable file
·124 lines (106 loc) · 2.32 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/bin/bash
set -u
RESOLVER=lts-5.0
t=${BASH_SOURCE[0]}
t=$(dirname ${t})
t=$(realpath ${t})
syntax() {
echo "build-srpm -t [type] -o [output directory] -n"
}
outdir=""
nocleanup=0
pkgtype=
maintainer=
distros=
bootlevel=1
while getopts "o:nt:m:d:b:" o; do
case "${o}" in
o)
outdir=${OPTARG}
;;
t)
pkgtype=${OPTARG}
;;
m)
maintainer=${OPTARG}
;;
n)
nocleanup=1
;;
b)
bootlevel=${OPTARG}
;;
d)
distros=${OPTARG}
;;
*)
syntax
exit 1
;;
esac
done
if [ -z "$outdir" ] ; then
echo error: no output directory specified
echo
syntax
exit 1
fi
case $pkgtype in
rpm)
;;
deb)
if [[ "$maintainer" == "" ]] ; then
echo "Maintainer needs to be given for type 'deb'"
exit -1
fi
if [[ "$distros" == "" ]] ; then
echo error: no output directory specified
echo
syntax
exit 1
fi
;;
*)
echo "Need to specify proper package type"
exit -1
esac
make_srpm() {
cleanups () {
rm -rf ${RPM_TARGET_DIR}
}
RPM_TARGET_DIR=`mktemp --tmpdir -d XXXXXXrpm-packaging`
mkdir -p ${RPM_TARGET_DIR}/{SPECS,SOURCES}
BATCH_NR=${bootlevel}
PKG_BASE_NAME=stackage-dist-${RESOLVER}
PKG_NAME=${PKG_BASE_NAME}-precompiled-boot${BATCH_NR}
SPEC_FILE=${RPM_TARGET_DIR}/SPECS/${PKG_NAME}.spec
PKG_VERSION=1
PKG_RELEASE=1
cp ${t}/fix-bins.py ${RPM_TARGET_DIR}/SOURCES/fix-bins.py
cp ${t}/install-ghc.py ${RPM_TARGET_DIR}/SOURCES/install-ghc.py
cp ${t}/helpers.sh ${RPM_TARGET_DIR}/SOURCES/helpers.sh
cp ${t}/project.tar.gz ${RPM_TARGET_DIR}/SOURCES/project.tar.gz
cat ${t}/stackage-dist-precompiled.rpm.spec \
| sed s/@@RESOLVER@@/${RESOLVER}/g \
| sed s/@@BATCH_NR@@/${BATCH_NR}/g \
| sed s/@@PKG_VERSION@@/${PKG_VERSION}/g \
| sed s/@@PKG_BASE_NAME@@/${PKG_BASE_NAME}/g \
| sed s/@@PKG_NAME@@/${PKG_NAME}/g \
| sed s/@@PKG_RELEASE@@/${PKG_RELEASE}/g > ${SPEC_FILE}
(rpmbuild -bs \
--define "_topdir ${RPM_TARGET_DIR}" \
${SPEC_FILE} \
|| (cleanups ; exit 1)) || return -1
mkdir -p ${outdir}
cp -v ${RPM_TARGET_DIR}/SRPMS/* ${outdir}
cleanups
return 0
}
make_sdeb() {
echo "Not yet supported"
exit -1
}
make_s$pkgtype
X=$?
echo Done
exit $?