-
Notifications
You must be signed in to change notification settings - Fork 1
/
make.sh
75 lines (61 loc) · 1.69 KB
/
make.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
#!/bin/bash
ARCHS=("fedora-25-i386" "fedora-25-x86_64" "fedora-26-i386" "fedora-26-x86_64" "fedora-rawhide-i386" "fedora-rawhide-x86_64")
# "fedora-24-i386 fedora-24-x86_64 fedora-25-i386 fedora-25-x86_64 fedora-rawhide-i386 fedora-rawhide-x86_64"
PACKAGE=$1
RESULT_DIR=/tmp/build_$(date +%Y%m%d_%H%M%S)
# COPR specific config
COPR_PROJECT=deepin
MOCK=0
if [ "$2" ]; then
ARCHS=($2)
fi
if [ "$3" == "mock" ]; then
MOCK=1
fi
if [ "$4" ]; then
COPR_PROJECT="${4}"
fi
function buildPackage()
{
local package=$1
# Download source for given package
spectool -g -C ./SOURCES ${package}
if [ $? == 0 ]; then
for arch in ${ARCHS[@]}; do
rm -rf ${RESULT_DIR}
mkdir -p ${RESULT_DIR}
#echo mock -r ${arch} --spec=SPECS/${package}.spec --sources=SOURCES/ --buildsrpm --resultdir=${RESULT_DIR}
mock -r ${arch} --spec=${package} --sources=SOURCES/ --buildsrpm --resultdir=${RESULT_DIR}
###
rpmfile=$(grep 'src.rpm' ${RESULT_DIR}/build.log | head -n 1 | sed -e 's#^.*/##g')
if [ ${MOCK} -eq 1 ]; then
mockBuild "${arch}" "${RESULT_DIR}/${rpmfile}"
else
upload2Copr "${arch}" "${RESULT_DIR}/${rpmfile}"
fi
done
else
echo "An error occured. Exiting..."
exit 1
fi
}
function upload2Copr()
{
local arch=$1
local package=$2
#echo copr-cli build -r ${arch} --nowait ${COPR_PROJECT} ${package}
copr-cli build --nowait ${COPR_PROJECT} ${package}
}
function mockBuild()
{
local arch=$1
local package=$2
mock -r ${arch} ${package} --resultdir=${RESULT_DIR}
}
buildPackage $PACKAGE
echo "RESULT IN: ${RESULT_DIR}"
#
# Notes
#
# Run script as mock builder
# $ bash make.sh ./SPECS/file.spec fedora-25-x86_64 "mock" deepin-test