forked from nkaul/cldemo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·142 lines (122 loc) · 3.41 KB
/
build.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
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/usr/bin/env bash
#--------------------------------------------------------------------------
#
# Copyright 2014 Cumulus Networks, inc all rights reserved
#
#--------------------------------------------------------------------------
SIGNRELEASE=1
while getopts ":n" opt; do
case $opt in
n)
SIGNRELEASE=0
;;
\?)
echo "Invalid option"
exit 1
;;
esac
done
# check pre-reqs
TOOLMISSING=0
tools=(apt-ftparchive dpkg-deb dpkg-scanpackages gpg)
for TOOL in ${tools[@]}; do
if ! hash $TOOL 2>/dev/null; then
echo "** ERROR ** $TOOL not installed"
TOOLMISSING=$[$TOOLMISSING +1]
fi
done
if [[ $TOOLMISSING -gt 0 ]]
then
echo "$TOOLMISSING tools/cmds missing"
exit 1
fi
# GPG location depends varies; Jenkins slaves keep them in /var/repo
if [ -e /var/repo/cldemo ]; then
KEYPATH=/var/repo/cldemo
else
KEYPATH=/mnt/repo/keyrings/cldemo
fi
# clean up
if [ ! -e repo-build ]; then
mkdir repo-build
else
rm -rf repo-build/*
fi
# sync git submodules
/usr/bin/git submodule init
/usr/bin/git submodule update
/usr/bin/git submodule foreach git pull origin master
if [ $? -ne 0 ]
then
echo "git submodules failed to update; build will be incomplete"
exit 1
fi
architectures=(amd64 i386 powerpc)
# loop through repos
for R in `find pkgs/* -maxdepth 0 -type d`
do
REPO=$(echo $R | sed -e "s/pkgs\///")
echo ""
echo "$REPO repo..."
echo ""
# create empty repos
for ARCH in ${architectures[@]}; do
mkdir -p repo-build/$REPO/binary-$ARCH
done
# loop through packages
for P in `find pkgs/$REPO/* -maxdepth 0 -type d`
do
PKG=$(echo $P | sed -e "s/pkgs\/$REPO\///")
if [ ! -e pkgs/$REPO/$PKG/debian/DEBIAN/control ]; then
echo "** WARNING ** skipping $REPO/$PKG no control file"
else
if ! fakeroot dpkg-deb --build pkgs/$REPO/$PKG/debian repo-build/$REPO/binary-amd64/${PKG}_amd64.deb
then
echo "** ERROR ** while building $REPO/$PKG"
exit 1
fi
fi
done
# generate package lists
for ARCH in ${architectures[@]}; do
if ! dpkg-scanpackages -a $ARCH repo-build/$REPO/binary-$ARCH /dev/null | sed -e 's/Filename: repo-build\//Filename: dists\/cldemo\//' > repo-build/$REPO/binary-$ARCH/Packages
then
echo "** ERROR ** while generating repo for $REPO $ARCH"
exit 1
fi
done
done
# create dependencies graph
mkdir -p output/
DEPENDFILES="dependencies_`date +%Y%m%d_%H%M`"
DEPENDPNG="output/$DEPENDFILES.png"
DEPENDDOT="output/$DEPENDFILES.dot"
./depends.py -p pkgs/workbench -t png -o $DEPENDPNG -d $DEPENDDOT
cp -f $DEPENDPNG output/dependencies_latest.png
cp -f $DEPENDDOT output/dependencies_latest.dot
# create Release file
echo ""
if ! apt-ftparchive -c ftparchive.conf release repo-build/ | sed -e 's/dists\/cldemo\///g' > repo-build/Release
then
echo "** ERROR *** problem creating Release file"
exit 1
else
echo "Created Release file"
fi
if [ $SIGNRELEASE -eq 1 ]; then
# signing Release
echo ""
if ! gpg -a --yes --homedir $KEYPATH --default-key 9804E228 --output repo-build/Release.gpg --detach-sig repo-build/Release
then
echo "** ERROR *** problem signing Release file"
exit 1
else
echo "Signed Release file"
fi
fi
# copy static content
cp -R repo-static/* repo-build/
echo ""
echo "Done"
echo ""
exit 0