forked from freifunk-westpfalz/site-ffwp
-
Notifications
You must be signed in to change notification settings - Fork 1
/
make-release.sh
executable file
·146 lines (121 loc) · 5.75 KB
/
make-release.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
143
144
145
146
#!/bin/bash
######################################################################################
## Thanks to FFSAAR for the base of this script
## see also: https://github.com/freifunk-saar/gluon-site/blob/master/make-release.sh
######################################################################################
## This script will compile Gluon for all architectures, create the
## manifest and sign it. For that, you must have clone gluon and have a
## valid site config. Additionally, the signing key must be present in
## $PATH_FFWP/fw/autobuilder.secret
## Call from site directory with the version and branch variables
## properly configured in this script.
# if version is unset, will use the default nightly version from site.mk
#VERSION=0.5.0
# branch must be set to either nightly, beta or stable
BRANCH=nightly
#debug switch: DEBUG=V\=s
#DEBUG=V\=s
DEBUG=
PATH_GLUON=/home/freifunk/gluon
PATH_FFWP=/home/freifunk/.ffwp
PATH_LOG=$PATH_FFWP/fw/log
FILE_SECRET=$PATH_FFWP/fw/autobuilder.secret
CPU_CNT=`cat /proc/cpuinfo|grep ^processor|wc -l`
CPU_CNT=$(($CPU_CNT-1))
cd ..
VERSION=`make show-release`
if [ ! -d "site" ]; then
echo "This script must be called from within the site directory"
exit 1
fi
LOGFILE=$PATH_LOG/build.log
RESULT=0
rm $LOGFILE
date | tee -a $LOGFILE
rm -r $PATH_GLUON/output/images
echo -e "\n\n\nmake dirclean" >> $LOGFILE
make dirclean | tee -a $LOGFILE
echo -e "\n\n\n" >> $LOGFILE
#for TARGET in ar71xx-tiny
for TARGET in ar71xx-generic ar71xx-tiny ar71xx-nand brcm2708-bcm2708 brcm2708-bcm2709 mpc85xx-generic ramips-mt7621 x86-generic x86-geode x86-64
do
date | tee -a $LOGFILE
if [ -z "$VERSION" ]
then
echo "Starting work on target $TARGET (1)" | tee -a $LOGFILE
echo -e "\n\n\nmake GLUON_TARGET=$TARGET GLUON_BRANCH=stable update" >> $LOGFILE
make GLUON_TARGET=$TARGET GLUON_BRANCH=stable update >> $LOGFILE 2>&1
echo -e "\n\n\nmake GLUON_TARGET=$TARGET GLUON_BRANCH=stable clean" >> $LOGFILE
make GLUON_TARGET=$TARGET GLUON_BRANCH=stable clean >> $LOGFILE 2>&1
echo -e "\n\n\nmake $DEBUG GLUON_TARGET=$TARGET GLUON_BRANCH=stable -j$CPU_CNT" >> $LOGFILE
make $DEBUG GLUON_TARGET=$TARGET GLUON_BRANCH=stable -j$CPU_CNT >> $LOGFILE 2>&1
if [ $? -ne 0 ]; then
RESULT=$(($RESULT + 1))
fi
else
echo "Starting work on target $TARGET (2)" | tee -a $LOGFILE
echo -e "\n\n\nmake GLUON_TARGET=$TARGET GLUON_BRANCH=stable GLUON_RELEASE=$VERSION update" >> $LOGFILE
make GLUON_TARGET=$TARGET GLUON_BRANCH=stable GLUON_RELEASE=$VERSION update >> $LOGFILE 2>&1
echo -e "\n\n\nmake GLUON_TARGET=$TARGET GLUON_BRANCH=stable GLUON_RELEASE=$VERSION clean" >> $LOGFILE
make GLUON_TARGET=$TARGET GLUON_BRANCH=stable GLUON_RELEASE=$VERSION clean >> $LOGFILE 2>&1
echo -e "\n\n\nmake $DEBUG GLUON_TARGET=$TARGET GLUON_BRANCH=stable GLUON_RELEASE=$VERSION -j$CPU_CNT" >> $LOGFILE
make $DEBUG GLUON_TARGET=$TARGET GLUON_BRANCH=stable GLUON_RELEASE=$VERSION -j$CPU_CNT >> $LOGFILE 2>&1
if [ $? -ne 0 ]; then
RESULT=$(($RESULT + 1))
fi
fi
echo " Overall error/s: $RESULT" | tee -a $LOGFILE
echo -e "\n\n\n============================================================\n\n" >> $LOGFILE
done
if [ $RESULT -ne 0 ]; then
echo "Compilation FAILED, see build.log $RESULT error/s" | tee -a $LOGFILE
cd $PATH_GLUON/site
exit 1
else
echo "Compilation complete, creating manifest(s)" | tee -a $LOGFILE
echo $VERSION > $PATH_GLUON/output/images/sysupgrade/.version.txt
echo -e "make GLUON_BRANCH=nightly GLUON_RELEASE=$VERSION manifest" >> $LOGFILE
make GLUON_BRANCH=nightly GLUON_RELEASE=$VERSION manifest >> $LOGFILE 2>&1
cp $PATH_GLUON/output/images/sysupgrade/nightly.manifest $PATH_GLUON/output/images/sysupgrade/.template.manifest
echo -e "\n\n\n============================================================\n\n" >> $LOGFILE
if [[ "$BRANCH" == "beta" ]] || [[ "$BRANCH" == "stable" ]]
then
echo -e "make GLUON_BRANCH=beta GLUON_RELEASE=$VERSION manifest" >> $LOGFILE
make GLUON_BRANCH=beta GLUON_RELEASE=$VERSION manifest >> $LOGFILE 2>&1
cp $PATH_GLUON/output/images/sysupgrade/beta.manifest $PATH_GLUON/output/images/sysupgrade/.template.manifest
echo -e "\n\n\n============================================================\n\n" >> $LOGFILE
fi
if [[ "$BRANCH" == "stable" ]]
then
echo -e "make GLUON_BRANCH=stable GLUON_RELEASE=$VERSION manifest" >> $LOGFILE
make GLUON_BRANCH=stable GLUON_RELEASE=$VERSION manifest >> $LOGFILE 2>&1
echo -e "\n\n\n============================================================\n\n" >> $LOGFILE
fi
echo "Manifest creation complete, signing manifest" | tee -a $LOGFILE
echo -e "$PATH_GLUON/contrib/sign.sh $FILE_SECRET $PATH_GLUON/output/images/sysupgrade/nightly.manifest" >> $LOGFILE
$PATH_GLUON/contrib/sign.sh $FILE_SECRET $PATH_GLUON/output/images/sysupgrade/nightly.manifest >> $LOGFILE 2>&1
if [[ "$BRANCH" == "beta" ]] || [[ "$BRANCH" == "stable" ]]
then
echo -e "$PATH_GLUON/contrib/sign.sh $FILE_SECRET $PATH_GLUON/output/images/sysupgrade/beta.manifest" >> $LOGFILE
$PATH_GLUON/contrib/sign.sh $FILE_SECRET $PATH_GLUON/output/images/sysupgrade/beta.manifest >> $LOGFILE 2>&1
fi
if [[ "$BRANCH" == "stable" ]]
then
echo -e "$PATH_GLUON/contrib/sign.sh $FILE_SECRET $PATH_GLUON/output/images/sysupgrade/stable.manifest" >> $LOGFILE
$PATH_GLUON/contrib/sign.sh $FILE_SECRET $PATH_GLUON/output/images/sysupgrade/stable.manifest >> $LOGFILE 2>&1
fi
echo -e "--- md5 erzeugen ---" >> $LOGFILE
cd $PATH_GLUON/output/images/factory
md5sum gluon* > md5.txt
cd $PATH_GLUON/output/images/sysupgrade
md5sum gluon* > md5.txt
#back to gluon path
cd $PATH_GLUON
date >> $LOGFILE
echo "Done :) $RESULT error/s"| tee -a $LOGFILE
#copying log files to output
cp $LOGFILE $PATH_GLUON/output/images/.build.txt
cp $PATH_LOG/pull.log $PATH_GLUON/output/images/.pull.txt
fi
cd $PATH_GLUON/site
exit 0