1 |
2d44934d
|
Scott Ullrich
|
#!/bin/sh
|
2 |
|
|
#
|
3 |
c2573cbb
|
Scott Ullrich
|
# ${PRODUCT_NAME} snapshot building system
|
4 |
77fc19fb
|
Scott Ullrich
|
# (C)2007, 2008, 2009 Scott Ullrich
|
5 |
2d44934d
|
Scott Ullrich
|
# All rights reserved
|
6 |
|
|
#
|
7 |
426c3237
|
Scott Ullrich
|
# Redistribution and use in source and binary forms, with or without
|
8 |
|
|
# modification, are permitted provided that the following conditions
|
9 |
|
|
# are met:
|
10 |
2d44934d
|
Scott Ullrich
|
#
|
11 |
426c3237
|
Scott Ullrich
|
# 1. Redistributions of source code must retain the above copyright
|
12 |
|
|
# notice, this list of conditions and the following disclaimer.
|
13 |
|
|
#
|
14 |
|
|
# 2. Redistributions in binary form must reproduce the above copyright
|
15 |
|
|
# notice, this list of conditions and the following disclaimer in the
|
16 |
|
|
# documentation and/or other materials provided with the distribution.
|
17 |
2d44934d
|
Scott Ullrich
|
#
|
18 |
417ee3c1
|
Scott Ullrich
|
#
|
19 |
20ab9ac3
|
Scott Ullrich
|
# This script glues together the various FreeSBIE style pieces of the
|
20 |
c2573cbb
|
Scott Ullrich
|
# ${PRODUCT_NAME} builder system and will build each style image: ISO, NanoBSD,
|
21 |
417ee3c1
|
Scott Ullrich
|
# DevISO, full update and NanoBSD updates and then copy the results of
|
22 |
|
|
# all the builds to the public facing WWW server. This script will
|
23 |
|
|
# invoke the scripts directly such as build_iso.sh and build_nano.sh,
|
24 |
|
|
# etc.
|
25 |
|
|
#
|
26 |
|
|
# Crank up error reporting, debugging.
|
27 |
|
|
# set -e
|
28 |
|
|
# set -x
|
29 |
20ab9ac3
|
Scott Ullrich
|
|
30 |
81aa6462
|
Scott Ullrich
|
if [ ! -f ./pfsense-build.conf ]; then
|
31 |
|
|
echo "You must first run ./set_version.sh !"
|
32 |
|
|
exit 1
|
33 |
|
|
fi
|
34 |
|
|
|
35 |
63205757
|
Ermal
|
NO_UPLOAD=""
|
36 |
|
|
LOOPED_SNAPSHOTS=""
|
37 |
|
|
|
38 |
|
|
# Handle command line arguments
|
39 |
|
|
while test "$1" != "" ; do
|
40 |
|
|
case $1 in
|
41 |
|
|
--no-ports|--noports|-n)
|
42 |
|
|
NO_PORTS=yo
|
43 |
|
|
;;
|
44 |
|
|
--noupload|-u)
|
45 |
|
|
NO_UPLOAD="-u"
|
46 |
|
|
;;
|
47 |
|
|
--looped)
|
48 |
|
|
LOOPED_SNAPSHOTS="true"
|
49 |
|
|
esac
|
50 |
|
|
shift
|
51 |
74b24b85
|
Ermal
|
done
|
52 |
|
|
|
53 |
63d7c187
|
Ermal
|
# Source ${PRODUCT_NAME} / FreeSBIE variables
|
54 |
|
|
# *** DO NOT SOURCE BUILDER_COMMON.SH!
|
55 |
|
|
# *** IT WILL BREAK EVERYTHING FOR
|
56 |
|
|
# *** SOME UNKNOWN LAYERING REASON.
|
57 |
|
|
# *** 04/07/2008, 11/04/2009
|
58 |
|
|
echo ">>> Execing pfsense-build.conf"
|
59 |
8326a7c1
|
Ermal
|
. ./builder_defaults.sh
|
60 |
63d7c187
|
Ermal
|
|
61 |
63205757
|
Ermal
|
# Unset do not build ports flag
|
62 |
|
|
rm -f $SCRATCHDIR/pfSense_do_not_build_pfPorts
|
63 |
|
|
|
64 |
|
|
# Keeps track of how many time builder has looped
|
65 |
|
|
BUILDCOUNTER=0
|
66 |
|
|
|
67 |
2d44934d
|
Scott Ullrich
|
# Local variables that are used by builder scripts
|
68 |
|
|
STAGINGAREA=/tmp/staging
|
69 |
b594cf1b
|
jim-p
|
RSYNCIP="snapshots.pfsense.org"
|
70 |
25c48847
|
Chris Buechler
|
RSYNCKBYTELIMIT="248000"
|
71 |
661593d2
|
Scott Ullrich
|
PINGTIME="999"
|
72 |
|
|
PINGMAX="40"
|
73 |
b594cf1b
|
jim-p
|
PINGIP="snapshots.pfsense.org"
|
74 |
2d44934d
|
Scott Ullrich
|
|
75 |
63205757
|
Ermal
|
export SNAPSHOTSLOGFILE=${SNAPSHOTSLOGFILE:-"$SCRATCHDIR/snapshots-build.log"}
|
76 |
|
|
export SNAPSHOTSLASTUPDATE=${SNAPSHOTSLASTUPDATE:-"$SCRATCHDIR/snapshots-lastupdate.log"}
|
77 |
|
|
export MASTER_BUILDER_SSH_LOG_DEST=${MASTER_BUILDER_SSH_LOG_DEST:-snapshots@${RSYNCIP}:/usr/local/www/snapshots/logs/pfSense_${PFSENSETAG}__FreeBSD_${FREEBSD_VERSION}/${TARGET}/build.log}
|
78 |
|
|
|
79 |
2d44934d
|
Scott Ullrich
|
# Ensure directories exist
|
80 |
|
|
mkdir -p $STAGINGAREA
|
81 |
|
|
|
82 |
b5b7f3ef
|
Ermal
|
if [ -f $SCRATCHDIR/pfPorts_forced_build_required ]; then
|
83 |
|
|
rm $SCRATCHDIR/pfPorts_forced_build_required
|
84 |
29b9c908
|
Scott Ullrich
|
fi
|
85 |
|
|
|
86 |
63205757
|
Ermal
|
echo "" > $SNAPSHOTSLOGFILE
|
87 |
|
|
echo "" > $SNAPSHOTSLASTUPDATE
|
88 |
|
|
|
89 |
|
|
git_last_commit() {
|
90 |
|
|
if [ -d "${1}" ]; then
|
91 |
f0bb83ab
|
Ermal
|
(cd ${1} && git fetch && git reset ${2})>/dev/null
|
92 |
63205757
|
Ermal
|
CURRENT_COMMIT=$(cd "${1}" && git log | head -n1 | cut -d' ' -f2)
|
93 |
|
|
echo ">>> CURRENT_COMMIT: ${CURRENT_COMMIT} on ${1}"
|
94 |
|
|
return $CURRENT_COMMIT
|
95 |
|
|
else
|
96 |
|
|
update_status ">>> WARNING: pfSenseGITREPO variable not set! Previous commit functions disabled."
|
97 |
|
|
fi
|
98 |
|
|
}
|
99 |
|
|
|
100 |
|
|
# This routine is called in between runs. We
|
101 |
|
|
# will sleep for a bit and check for new commits
|
102 |
|
|
# in between sleeping for short durations.
|
103 |
|
|
sleep_between_runs() {
|
104 |
|
|
COUNTER=0
|
105 |
|
|
while [ $COUNTER -lt $maxsleepvalue ]; do
|
106 |
|
|
sleep 60
|
107 |
d6411f2f
|
Ermal
|
PFSENSE_CURRENT_COMMIT=$(git_last_commit "${GIT_REPO_DIR}/pfSenseGITREPO" origin/${PFSENSETAG})
|
108 |
63205757
|
Ermal
|
if [ "$PFSENSE_LAST_COMMIT" != "$PFSENSE_CURRENT_COMMIT" ]; then
|
109 |
|
|
update_status ">>> New commit: $CURRENT_AUTHOR - $CURRENT_COMMIT .. No longer sleepy."
|
110 |
|
|
COUNTER="`expr $maxsleepvalue + 60`"
|
111 |
|
|
export PFSENSE_LAST_COMMIT="${PFSENSE_CURRENT_COMMIT}"
|
112 |
|
|
return
|
113 |
|
|
fi
|
114 |
584e0eb1
|
Ermal
|
TOOLS_CURRENT_COMMIT=$(git_last_commit "${BUILDER_SCRIPTS}" origin)
|
115 |
63205757
|
Ermal
|
if [ "$TOOLS_LAST_COMMIT" != "$TOOLS_CURRENT_COMMIT" ]; then
|
116 |
|
|
update_status ">>> New commit: $CURRENT_AUTHOR - $CURRENT_COMMIT .. No longer sleepy."
|
117 |
|
|
COUNTER="`expr $maxsleepvalue + 60`"
|
118 |
|
|
export TOOLS_LAST_COMMIT="${TOOLS_CURRENT_COMMIT}"
|
119 |
|
|
return
|
120 |
|
|
fi
|
121 |
|
|
COUNTER="`expr $COUNTER + 60`"
|
122 |
|
|
done
|
123 |
|
|
if [ $COUNTER -ge $maxsleepvalue ]; then
|
124 |
|
|
update_status ">>> Sleep timer expired. Restarting build."
|
125 |
|
|
maxsleepvalue=0
|
126 |
|
|
COUNTER=0
|
127 |
|
|
fi
|
128 |
|
|
}
|
129 |
|
|
|
130 |
|
|
# This routine is called to write out to stdout
|
131 |
|
|
# a string. The string is appeneded to $SNAPSHOTSLOGFILE
|
132 |
|
|
# and we scp the log file to the builder host if
|
133 |
|
|
# needed for the real time logging functions.
|
134 |
|
|
update_status() {
|
135 |
|
|
if [ "$1" = "" ]; then
|
136 |
|
|
return
|
137 |
|
|
fi
|
138 |
|
|
echo $1
|
139 |
|
|
echo "`date` -|- $1" >> $SNAPSHOTSLOGFILE
|
140 |
|
|
if [ -n "$MASTER_BUILDER_SSH_LOG_DEST" -a -z "${NO_UPLOAD}" ]; then
|
141 |
|
|
LU=`cat $SNAPSHOTSLASTUPDATE`
|
142 |
|
|
CT=`date "+%H%M%S"`
|
143 |
|
|
# Only update every minute
|
144 |
|
|
if [ "$LU" != "$CT" ]; then
|
145 |
|
|
scp -q $SNAPSHOTSLOGFILE $MASTER_BUILDER_SSH_LOG_DEST
|
146 |
|
|
date "+%H%M%S" > $SNAPSHOTSLASTUPDATE
|
147 |
|
|
fi
|
148 |
|
|
fi
|
149 |
|
|
}
|
150 |
|
|
|
151 |
|
|
# Copy the current log file to $filename.old on
|
152 |
|
|
# the snapshot www server (real time logs)
|
153 |
|
|
rotate_logfile() {
|
154 |
|
|
if [ -n "$MASTER_BUILDER_SSH_LOG_DEST" -a -z "${NO_UPLOAD}" ]; then
|
155 |
|
|
scp -q $SNAPSHOTSLOGFILE $MASTER_BUILDER_SSH_LOG_DEST.old
|
156 |
|
|
fi
|
157 |
|
|
|
158 |
|
|
# Cleanup log file
|
159 |
|
|
echo "" > $SNAPSHOTSLOGFILE
|
160 |
|
|
}
|
161 |
|
|
|
162 |
4d84fa36
|
Scott Ullrich
|
post_tweet() {
|
163 |
68d79e27
|
Scott Ullrich
|
TWEET_MESSAGE="$1"
|
164 |
a89236b9
|
Scott Ullrich
|
if [ "$TWITTER_USERNAME" = "" ]; then
|
165 |
63205757
|
Ermal
|
update_status ">>> ERROR: Could not find TWITTER_USERNAME -- tweet cancelled."
|
166 |
4d84fa36
|
Scott Ullrich
|
return
|
167 |
|
|
fi
|
168 |
68d79e27
|
Scott Ullrich
|
if [ "$TWITTER_PASSWORD" = "" ]; then
|
169 |
63205757
|
Ermal
|
update_status ">>> ERROR: Could not find TWITTER_PASSWORD -- tweet cancelled."
|
170 |
4d84fa36
|
Scott Ullrich
|
return
|
171 |
|
|
fi
|
172 |
|
|
if [ ! -f "/usr/local/bin/curl" ]; then
|
173 |
63205757
|
Ermal
|
update_status ">>> ERROR: Could not find /usr/local/bin/curl -- tweet cancelled."
|
174 |
4d84fa36
|
Scott Ullrich
|
return
|
175 |
|
|
fi
|
176 |
63205757
|
Ermal
|
update_status ">>> Tweet:"
|
177 |
|
|
update_status ">>> ${TWEET_MESSAGE}"
|
178 |
a89236b9
|
Scott Ullrich
|
echo -n ">>> Posting tweet..."
|
179 |
b5b7f3ef
|
Ermal
|
`/usr/local/bin/curl --silent --basic --user "$TWITTER_USERNAME:$TWITTER_PASSWORD" --data status="$TWEET_MESSAGE" http://twitter.com/statuses/update.xml` > $SCRATCHDIR/tweet_diag.txt 2>&1
|
180 |
63205757
|
Ermal
|
update_status "Done!"
|
181 |
4d84fa36
|
Scott Ullrich
|
}
|
182 |
|
|
|
183 |
4eea41f8
|
Scott Ullrich
|
dobuilds() {
|
184 |
69ba7f52
|
Ermal
|
# Set a common DATESTRING for the build if not set from builder_defaults.sh.
|
185 |
|
|
if [ -z "${DATESTRING}" ]; then
|
186 |
|
|
export DATESTRING=`date "+%Y%m%d-%H%M"`
|
187 |
|
|
fi
|
188 |
|
|
if [ -z "${BUILTDATESTRING}" ]; then
|
189 |
|
|
export BUILTDATESTRING=`date "+%a %b %d %T %Z %Y"`
|
190 |
|
|
fi
|
191 |
43dbeb30
|
Ermal
|
# NOTE: This is needed to have autoupdate detect a new version.
|
192 |
|
|
# There is max a second difference here with DATESTRING which should not be a problem
|
193 |
69ba7f52
|
Ermal
|
echo "$BUILTDATESTRING" > $BUILTDATESTRINGFILE
|
194 |
|
|
echo "$DATESTRING" > $DATESTRINGFILE
|
195 |
97090d70
|
Ermal
|
|
196 |
63d7c187
|
Ermal
|
cd $BUILDER_SCRIPTS
|
197 |
adbddb0e
|
Ermal
|
# Build images
|
198 |
aef1b261
|
Ermal
|
./build.sh --flash-size '1g 2g 4g' "iso memstick memstickserial fullupdate nanobsd nanobsd-vga"
|
199 |
59d33514
|
Ermal
|
# Copy files
|
200 |
4eea41f8
|
Scott Ullrich
|
copy_to_staging_iso_updates
|
201 |
aef1b261
|
Ermal
|
copy_to_staging_nanobsd '1g 2g 4g'
|
202 |
|
|
|
203 |
|
|
unset DATESTRING
|
204 |
ea4c21c8
|
Ermal
|
rm $DATESTRINGFILE
|
205 |
69ba7f52
|
Ermal
|
unset BUILTDATESTRING
|
206 |
ea4c21c8
|
Ermal
|
rm $BUILTDATESTRINGFILE
|
207 |
a2990ef3
|
Scott Ullrich
|
}
|
208 |
|
|
|
209 |
e64d3e3a
|
Scott Ullrich
|
copy_to_staging_nanobsd() {
|
210 |
63d7c187
|
Ermal
|
cd $BUILDER_SCRIPTS
|
211 |
9a552840
|
jim-p
|
|
212 |
aef1b261
|
Ermal
|
for NANOTYPE in nanobsd nanobsd-vga; do
|
213 |
|
|
for FILESIZE in ${1}; do
|
214 |
|
|
FILENAMEFULL="${PRODUCT_NAME}-${PFSENSE_VERSION}-${FILESIZE}-${TARGET}-${NANOTYPE}-${DATESTRING}.img.gz"
|
215 |
|
|
FILENAMEUPGRADE="${PRODUCT_NAME}-${PFSENSE_VERSION}-${FILESIZE}-${TARGET}-${NANOTYPE}-upgrade-${DATESTRING}.img.gz"
|
216 |
|
|
mkdir -p $STAGINGAREA/nanobsd
|
217 |
|
|
mkdir -p $STAGINGAREA/nanobsdupdates
|
218 |
|
|
|
219 |
|
|
cp $MAKEOBJDIRPREFIXFINAL/$FILENAMEFULL $STAGINGAREA/nanobsd/ 2>/dev/null
|
220 |
|
|
cp $MAKEOBJDIRPREFIXFINAL/$FILENAMEUPGRADE $STAGINGAREA/nanobsdupdates 2>/dev/null
|
221 |
|
|
|
222 |
|
|
if [ -f $STAGINGAREA/nanobsd/$FILENAMEFULL ]; then
|
223 |
|
|
md5 $STAGINGAREA/nanobsd/$FILENAMEFULL > $STAGINGAREA/nanobsd/$FILENAMEFULL.md5 2>/dev/null
|
224 |
|
|
sha256 $STAGINGAREA/nanobsd/$FILENAMEFULL > $STAGINGAREA/nanobsd/$FILENAMEFULL.sha256 2>/dev/null
|
225 |
|
|
fi
|
226 |
|
|
if [ -f $STAGINGAREA/nanobsdupdates/$FILENAMEUPGRADE ]; then
|
227 |
|
|
md5 $STAGINGAREA/nanobsdupdates/$FILENAMEUPGRADE > $STAGINGAREA/nanobsdupdates/$FILENAMEUPGRADE.md5 2>/dev/null
|
228 |
|
|
sha256 $STAGINGAREA/nanobsdupdates/$FILENAMEUPGRADE > $STAGINGAREA/nanobsdupdates/$FILENAMEUPGRADE.sha256 2>/dev/null
|
229 |
|
|
fi
|
230 |
|
|
|
231 |
|
|
# Copy NanoBSD auto update:
|
232 |
|
|
if [ -f $STAGINGAREA/nanobsdupdates/$FILENAMEUPGRADE ]; then
|
233 |
|
|
cp $STAGINGAREA/nanobsdupdates/$FILENAMEUPGRADE $STAGINGAREA/latest-${NANOTYPE}-$FILESIZE.img.gz 2>/dev/null
|
234 |
|
|
sha256 $STAGINGAREA/latest-${NANOTYPE}-$FILESIZE.img.gz > $STAGINGAREA/latest-${NANOTYPE}-$FILESIZE.img.gz.sha256 2>/dev/null
|
235 |
43dbeb30
|
Ermal
|
# NOTE: Updates need a file with output similar to date output
|
236 |
|
|
# Use the file generated at start of dobuilds() to be consistent on times
|
237 |
bfbcf6bf
|
Ermal
|
cp $BUILTDATESTRINGFILE $STAGINGAREA/version-${NANOTYPE}-$FILESIZE
|
238 |
43dbeb30
|
Ermal
|
fi
|
239 |
aef1b261
|
Ermal
|
done
|
240 |
adbddb0e
|
Ermal
|
done
|
241 |
e64d3e3a
|
Scott Ullrich
|
}
|
242 |
|
|
|
243 |
2d44934d
|
Scott Ullrich
|
copy_to_staging_iso_updates() {
|
244 |
63d7c187
|
Ermal
|
cd $BUILDER_SCRIPTS
|
245 |
adbddb0e
|
Ermal
|
|
246 |
e0038a75
|
Scott Ullrich
|
# Copy ISOs
|
247 |
adbddb0e
|
Ermal
|
md5 ${ISOPATH}.gz > ${ISOPATH}.md5
|
248 |
|
|
sha256 ${ISOPATH}.gz > ${ISOPATH}.sha256
|
249 |
72d65d89
|
Ermal
|
cp ${ISOPATH}* $STAGINGAREA/ 2>/dev/null
|
250 |
adbddb0e
|
Ermal
|
|
251 |
c2bf724a
|
Scott Ullrich
|
# Copy memstick items
|
252 |
adbddb0e
|
Ermal
|
md5 ${MEMSTICKPATH}.gz > ${MEMSTICKPATH}.md5
|
253 |
|
|
sha256 ${MEMSTICKPATH}.gz > ${MEMSTICKPATH}.sha256
|
254 |
72d65d89
|
Ermal
|
cp ${MEMSTICKPATH}* $STAGINGAREA/ 2>/dev/null
|
255 |
adbddb0e
|
Ermal
|
|
256 |
|
|
md5 ${MEMSTICKSERIALPATH}.gz > ${MEMSTICKSERIALPATH}.md5
|
257 |
|
|
sha256 ${MEMSTICKSERIALPATH}.gz > ${MEMSTICKSERIALPATH}.sha256
|
258 |
72d65d89
|
Ermal
|
cp ${MEMSTICKSERIALPATH}* $STAGINGAREA/ 2>/dev/null
|
259 |
adbddb0e
|
Ermal
|
|
260 |
25c6d9ec
|
Ermal
|
md5 ${UPDATES_TARBALL_FILENAME} > ${UPDATES_TARBALL_FILENAME}.md5
|
261 |
|
|
sha256 ${UPDATES_TARBALL_FILENAME} > ${UPDATES_TARBALL_FILENAME}.sha256
|
262 |
adbddb0e
|
Ermal
|
cp ${UPDATES_TARBALL_FILENAME}* $STAGINGAREA/ 2>/dev/null
|
263 |
43dbeb30
|
Ermal
|
# NOTE: Updates need a file with output similar to date output
|
264 |
|
|
# Use the file generated at start of dobuilds() to be consistent on times
|
265 |
bfbcf6bf
|
Ermal
|
cp $BUILTDATESTRINGFILE $STAGINGAREA/version 2>/dev/null
|
266 |
2d44934d
|
Scott Ullrich
|
}
|
267 |
|
|
|
268 |
82412a82
|
Scott Ullrich
|
check_for_congestion() {
|
269 |
63d7c187
|
Ermal
|
# cd $BUILDER_SCRIPTS
|
270 |
e73988eb
|
jim-p
|
# echo -n ">>> Waiting for Internet congestion to die down before rsync operations: $PINGTIME "
|
271 |
|
|
# while [ "$PINGTIME" -gt "$PINGMAX" ]; do
|
272 |
|
|
# PINGTIME=`ping -c1 $PINGIP | grep time | cut -d"=" -f4 | cut -d" " -f1 | cut -d"." -f1`
|
273 |
|
|
# echo -n " $PINGTIME"
|
274 |
|
|
# sleep 10
|
275 |
|
|
# done
|
276 |
|
|
# echo ""
|
277 |
82412a82
|
Scott Ullrich
|
}
|
278 |
|
|
|
279 |
|
|
scp_files() {
|
280 |
63d7c187
|
Ermal
|
cd $BUILDER_SCRIPTS
|
281 |
e75e449e
|
Scott Ullrich
|
if [ -z "${RSYNC_COPY_ARGUMENTS:-}" ]; then
|
282 |
d9f4e6ac
|
jim-p
|
RSYNC_COPY_ARGUMENTS="-ave ssh --timeout=60 --bwlimit=${RSYNCKBYTELIMIT}" #--bwlimit=50
|
283 |
e75e449e
|
Scott Ullrich
|
fi
|
284 |
63205757
|
Ermal
|
update_status ">>> Copying files to snapshots.pfsense.org"
|
285 |
8a7c2cf7
|
Scott Ullrich
|
if [ ! -f /usr/local/bin/rsync ]; then
|
286 |
63205757
|
Ermal
|
update_status ">>> Could not find rsync, installing from ports..."
|
287 |
8a7c2cf7
|
Scott Ullrich
|
(cd /usr/ports/net/rsync && make install clean)
|
288 |
|
|
fi
|
289 |
b5b7f3ef
|
Ermal
|
rm -f $SCRATCHDIR/ssh-snapshots*
|
290 |
7203485d
|
Ermal
|
|
291 |
438133f3
|
Scott Ullrich
|
# Ensure directory(s) are available
|
292 |
9f2a340a
|
Ermal
|
ssh snapshots@${RSYNCIP} "mkdir -p /usr/local/www/snapshots/FreeBSD_${FREEBSD_BRANCH}/${TARGET}/${PRODUCT_NAME}_${PFSENSETAG}/livecd_installer"
|
293 |
|
|
ssh snapshots@${RSYNCIP} "mkdir -p /usr/local/www/snapshots/FreeBSD_${FREEBSD_BRANCH}/${TARGET}/${PRODUCT_NAME}_${PFSENSETAG}/updates"
|
294 |
|
|
ssh snapshots@${RSYNCIP} "mkdir -p /usr/local/www/snapshots/FreeBSD_${FREEBSD_BRANCH}/${TARGET}/${PRODUCT_NAME}_${PFSENSETAG}/nanobsd"
|
295 |
5a9909a6
|
Ermal
|
if [ -d $STAGINGAREA/virtualization ]; then
|
296 |
|
|
ssh snapshots@${RSYNCIP} "mkdir -p /usr/local/www/snapshots/FreeBSD_${FREEBSD_BRANCH}/${TARGET}/${PRODUCT_NAME}_${PFSENSETAG}/virtualization"
|
297 |
|
|
fi
|
298 |
9f2a340a
|
Ermal
|
ssh snapshots@${RSYNCIP} "mkdir -p /usr/local/www/snapshots/FreeBSD_${FREEBSD_BRANCH}/${TARGET}/${PRODUCT_NAME}_${PFSENSETAG}/.updaters"
|
299 |
d451db3b
|
Scott Ullrich
|
# ensure permissions are correct for r+w
|
300 |
9f2a340a
|
Ermal
|
ssh snapshots@${RSYNCIP} "chmod -R ug+rw /usr/local/www/snapshots/FreeBSD_${FREEBSD_BRANCH}/${TARGET}/."
|
301 |
|
|
ssh snapshots@${RSYNCIP} "chmod -R ug+rw /usr/local/www/snapshots/FreeBSD_${FREEBSD_BRANCH}/${TARGET}/${PRODUCT_NAME}_${PFSENSETAG}/."
|
302 |
|
|
ssh snapshots@${RSYNCIP} "chmod -R ug+rw /usr/local/www/snapshots/FreeBSD_${FREEBSD_BRANCH}/${TARGET}/${PRODUCT_NAME}_${PFSENSETAG}/*/."
|
303 |
a2990ef3
|
Scott Ullrich
|
check_for_congestion
|
304 |
c2573cbb
|
Scott Ullrich
|
rsync $RSYNC_COPY_ARGUMENTS $STAGINGAREA/${PRODUCT_NAME}-*iso* \
|
305 |
9f2a340a
|
Ermal
|
snapshots@${RSYNCIP}:/usr/local/www/snapshots/FreeBSD_${FREEBSD_BRANCH}/${TARGET}/${PRODUCT_NAME}_${PFSENSETAG}/livecd_installer/
|
306 |
82412a82
|
Scott Ullrich
|
check_for_congestion
|
307 |
c2573cbb
|
Scott Ullrich
|
rsync $RSYNC_COPY_ARGUMENTS $STAGINGAREA/${PRODUCT_NAME}-memstick* \
|
308 |
9f2a340a
|
Ermal
|
snapshots@${RSYNCIP}:/usr/local/www/snapshots/FreeBSD_${FREEBSD_BRANCH}/${TARGET}/${PRODUCT_NAME}_${PFSENSETAG}/livecd_installer/
|
309 |
82412a82
|
Scott Ullrich
|
check_for_congestion
|
310 |
c2573cbb
|
Scott Ullrich
|
rsync $RSYNC_COPY_ARGUMENTS $STAGINGAREA/${PRODUCT_NAME}-*Update* \
|
311 |
9f2a340a
|
Ermal
|
snapshots@${RSYNCIP}:/usr/local/www/snapshots/FreeBSD_${FREEBSD_BRANCH}/${TARGET}/${PRODUCT_NAME}_${PFSENSETAG}/updates/
|
312 |
c2bf724a
|
Scott Ullrich
|
check_for_congestion
|
313 |
a2990ef3
|
Scott Ullrich
|
rsync $RSYNC_COPY_ARGUMENTS $STAGINGAREA/nanobsd/* \
|
314 |
9f2a340a
|
Ermal
|
snapshots@${RSYNCIP}:/usr/local/www/snapshots/FreeBSD_${FREEBSD_BRANCH}/${TARGET}/${PRODUCT_NAME}_${PFSENSETAG}/nanobsd/
|
315 |
f8c4378b
|
Scott Ullrich
|
check_for_congestion
|
316 |
a2990ef3
|
Scott Ullrich
|
rsync $RSYNC_COPY_ARGUMENTS $STAGINGAREA/nanobsdupdates/* \
|
317 |
9f2a340a
|
Ermal
|
snapshots@${RSYNCIP}:/usr/local/www/snapshots/FreeBSD_${FREEBSD_BRANCH}/${TARGET}/${PRODUCT_NAME}_${PFSENSETAG}/updates/
|
318 |
61d3cd9d
|
Scott Ullrich
|
check_for_congestion
|
319 |
5a9909a6
|
Ermal
|
if [ -d $STAGINGAREA/virtualization ]; then
|
320 |
|
|
rsync $RSYNC_COPY_ARGUMENTS $STAGINGAREA/virtualization/* \
|
321 |
|
|
snapshots@${RSYNCIP}:/usr/local/www/snapshots/FreeBSD_${FREEBSD_BRANCH}/${TARGET}/${PRODUCT_NAME}_${PFSENSETAG}/virtualization/
|
322 |
|
|
check_for_congestion
|
323 |
|
|
fi
|
324 |
8aff9872
|
jim-p
|
|
325 |
|
|
# Rather than copy these twice, use ln to link to the latest one.
|
326 |
|
|
|
327 |
9f2a340a
|
Ermal
|
ssh snapshots@${RSYNCIP} "rm -f /usr/local/www/snapshots/FreeBSD_${FREEBSD_BRANCH}/${TARGET}/${PRODUCT_NAME}_${PFSENSETAG}/.updaters/latest.tgz"
|
328 |
|
|
ssh snapshots@${RSYNCIP} "rm -f /usr/local/www/snapshots/FreeBSD_${FREEBSD_BRANCH}/${TARGET}/${PRODUCT_NAME}_${PFSENSETAG}/.updaters/latest.tgz.sha256"
|
329 |
8aff9872
|
jim-p
|
|
330 |
63d7c187
|
Ermal
|
LATESTFILENAME="`ls $UPDATESDIR/*.tgz | grep Full | grep -v md5 | grep -v sha256 | tail -n1`"
|
331 |
a59cef1b
|
jim-p
|
LATESTFILENAME=`basename ${LATESTFILENAME}`
|
332 |
9f2a340a
|
Ermal
|
ssh snapshots@${RSYNCIP} "ln -s /usr/local/www/snapshots/FreeBSD_${FREEBSD_BRANCH}/${TARGET}/${PRODUCT_NAME}_${PFSENSETAG}/updates/${LATESTFILENAME} \
|
333 |
|
|
/usr/local/www/snapshots/FreeBSD_${FREEBSD_BRANCH}/${TARGET}/${PRODUCT_NAME}_${PFSENSETAG}/.updaters/latest.tgz"
|
334 |
|
|
ssh snapshots@${RSYNCIP} "ln -s /usr/local/www/snapshots/FreeBSD_${FREEBSD_BRANCH}/${TARGET}/${PRODUCT_NAME}_${PFSENSETAG}/updates/${LATESTFILENAME}.sha256 \
|
335 |
|
|
/usr/local/www/snapshots/FreeBSD_${FREEBSD_BRANCH}/${TARGET}/${PRODUCT_NAME}_${PFSENSETAG}/.updaters/latest.tgz.sha256"
|
336 |
8aff9872
|
jim-p
|
|
337 |
aef1b261
|
Ermal
|
for i in 1g 2g 4g
|
338 |
8aff9872
|
jim-p
|
do
|
339 |
9f2a340a
|
Ermal
|
ssh snapshots@${RSYNCIP} "rm -f /usr/local/www/snapshots/FreeBSD_${FREEBSD_BRANCH}/${TARGET}/${PRODUCT_NAME}_${PFSENSETAG}/.updaters/latest-nanobsd-${i}.img.gz"
|
340 |
|
|
ssh snapshots@${RSYNCIP} "rm -f /usr/local/www/snapshots/FreeBSD_${FREEBSD_BRANCH}/${TARGET}/${PRODUCT_NAME}_${PFSENSETAG}/.updaters/latest-nanobsd-${i}.img.gz.sha256"
|
341 |
|
|
ssh snapshots@${RSYNCIP} "rm -f /usr/local/www/snapshots/FreeBSD_${FREEBSD_BRANCH}/${TARGET}/${PRODUCT_NAME}_${PFSENSETAG}/.updaters/latest-nanobsd-vga-${i}.img.gz"
|
342 |
|
|
ssh snapshots@${RSYNCIP} "rm -f /usr/local/www/snapshots/FreeBSD_${FREEBSD_BRANCH}/${TARGET}/${PRODUCT_NAME}_${PFSENSETAG}/.updaters/latest-nanobsd-vga-${i}.img.gz.sha256"
|
343 |
|
|
|
344 |
|
|
FILENAMEUPGRADE="${PRODUCT_NAME}-${PFSENSE_VERSION}-${i}-${TARGET}-nanobsd-upgrade-${DATESTRING}.img.gz"
|
345 |
|
|
ssh snapshots@${RSYNCIP} "ln -s /usr/local/www/snapshots/FreeBSD_${FREEBSD_BRANCH}/${TARGET}/${PRODUCT_NAME}_${PFSENSETAG}/updates/${FILENAMEUPGRADE} \
|
346 |
|
|
/usr/local/www/snapshots/FreeBSD_${FREEBSD_BRANCH}/${TARGET}/${PRODUCT_NAME}_${PFSENSETAG}/.updaters/latest-nanobsd-${i}.img.gz"
|
347 |
|
|
ssh snapshots@${RSYNCIP} "ln -s /usr/local/www/snapshots/FreeBSD_${FREEBSD_BRANCH}/${TARGET}/${PRODUCT_NAME}_${PFSENSETAG}/updates/${FILENAMEUPGRADE}.sha256 \
|
348 |
|
|
/usr/local/www/snapshots/FreeBSD_${FREEBSD_BRANCH}/${TARGET}/${PRODUCT_NAME}_${PFSENSETAG}/.updaters/latest-nanobsd-${i}.img.gz.sha256"
|
349 |
|
|
|
350 |
9c5f8a31
|
Ermal
|
FILENAMEUPGRADE="${PRODUCT_NAME}-${PFSENSE_VERSION}-${i}-${TARGET}-nanobsd-vga-upgrade-${DATESTRING}.img.gz"
|
351 |
9f2a340a
|
Ermal
|
ssh snapshots@${RSYNCIP} "ln -s /usr/local/www/snapshots/FreeBSD_${FREEBSD_BRANCH}/${TARGET}/${PRODUCT_NAME}_${PFSENSETAG}/updates/${FILENAMEUPGRADE} \
|
352 |
|
|
/usr/local/www/snapshots/FreeBSD_${FREEBSD_BRANCH}/${TARGET}/${PRODUCT_NAME}_${PFSENSETAG}/.updaters/latest-nanobsd-vga-${i}.img.gz"
|
353 |
|
|
ssh snapshots@${RSYNCIP} "ln -s /usr/local/www/snapshots/FreeBSD_${FREEBSD_BRANCH}/${TARGET}/${PRODUCT_NAME}_${PFSENSETAG}/updates/${FILENAMEUPGRADE}.sha256 \
|
354 |
|
|
/usr/local/www/snapshots/FreeBSD_${FREEBSD_BRANCH}/${TARGET}/${PRODUCT_NAME}_${PFSENSETAG}/.updaters/latest-nanobsd-vga-${i}.img.gz.sha256"
|
355 |
8aff9872
|
jim-p
|
done
|
356 |
|
|
|
357 |
|
|
check_for_congestion
|
358 |
|
|
rsync $RSYNC_COPY_ARGUMENTS $STAGINGAREA/version* \
|
359 |
9f2a340a
|
Ermal
|
snapshots@${RSYNCIP}:/usr/local/www/snapshots/FreeBSD_${FREEBSD_BRANCH}/${TARGET}/${PRODUCT_NAME}_${PFSENSETAG}/.updaters
|
360 |
63205757
|
Ermal
|
update_status ">>> Finished copying files."
|
361 |
2d44934d
|
Scott Ullrich
|
}
|
362 |
|
|
|
363 |
|
|
cleanup_builds() {
|
364 |
63d7c187
|
Ermal
|
cd $BUILDER_SCRIPTS
|
365 |
2d44934d
|
Scott Ullrich
|
# Remove prior builds
|
366 |
63205757
|
Ermal
|
update_status ">>> Cleaning up after prior builds..."
|
367 |
9c9ce96e
|
Scott Ullrich
|
rm -rf $STAGINGAREA/*
|
368 |
63d7c187
|
Ermal
|
rm -f $UPDATESDIR/* # Keep updates dir slimmed down
|
369 |
3c5584ba
|
Scott Ullrich
|
rm -rf $MAKEOBJDIRPREFIXFINAL/*
|
370 |
8326a7c1
|
Ermal
|
./build.sh --clean-builder
|
371 |
2d44934d
|
Scott Ullrich
|
}
|
372 |
|
|
|
373 |
|
|
build_loop_operations() {
|
374 |
63d7c187
|
Ermal
|
cd $BUILDER_SCRIPTS
|
375 |
63205757
|
Ermal
|
update_status ">>> Starting build loop operations"
|
376 |
2d44934d
|
Scott Ullrich
|
# --- Items we need to run for a complete build run ---
|
377 |
|
|
# Cleanup prior builds
|
378 |
|
|
cleanup_builds
|
379 |
|
|
# Do the builds
|
380 |
|
|
dobuilds
|
381 |
79d4108d
|
Scott Ullrich
|
# SCP files to snapshot web hosting area
|
382 |
74b24b85
|
Ermal
|
if [ -z "${NO_UPLOAD}" ]; then
|
383 |
|
|
scp_files
|
384 |
|
|
fi
|
385 |
b27a7e35
|
Scott Ullrich
|
# Alert the world that we have some snapshots ready.
|
386 |
63205757
|
Ermal
|
update_status ">>> Builder run is complete."
|
387 |
9f2a340a
|
Ermal
|
post_tweet "Snapshots for FreeBSD_${FREEBSD_BRANCH}/${TARGET}/${PRODUCT_NAME}-${PFSENSETAG} have been copied http://snapshots.pfsense.org/FreeBSD_${FREEBSD_BRANCH}/${TARGET}/${PRODUCT_NAME}_${PFSENSETAG}/"
|
388 |
2d44934d
|
Scott Ullrich
|
}
|
389 |
|
|
|
390 |
63205757
|
Ermal
|
if [ -z "${LOOPED_SNAPSHOTS}" ]; then
|
391 |
|
|
build_loop_operations
|
392 |
|
|
else
|
393 |
|
|
# Main builder loop
|
394 |
|
|
while [ /bin/true ]; do
|
395 |
|
|
BUILDCOUNTER=`expr $BUILDCOUNTER + 1`
|
396 |
|
|
update_status ">>> Starting builder run #${BUILDCOUNTER}..."
|
397 |
|
|
# We can disable ports builds
|
398 |
|
|
if [ "$NO_PORTS" = "yo" ]; then
|
399 |
|
|
update_status ">>> Not building pfPorts at all during this snapshot builder looped run..."
|
400 |
|
|
touch $SCRATCHDIR/pfSense_do_not_build_pfPorts
|
401 |
|
|
else
|
402 |
|
|
if [ "$BUILDCOUNTER" -gt 1 ]; then
|
403 |
|
|
update_status ">>> Previous snapshot runs deteceted, not building pfPorts again..."
|
404 |
|
|
touch $SCRATCHDIR/pfSense_do_not_build_pfPorts
|
405 |
|
|
else
|
406 |
|
|
update_status ">>> Building pfPorts on this snapshot run..."
|
407 |
|
|
rm -f $SCRATCHDIR/pfSense_do_not_build_pfPorts
|
408 |
|
|
fi
|
409 |
|
|
fi
|
410 |
|
|
|
411 |
|
|
# Launch the snapshots builder script and pipe its
|
412 |
|
|
# contents to the while loop so we can record the
|
413 |
|
|
# script progress in real time to the public facing
|
414 |
|
|
# snapshot server (snapshots.pfsense.org).
|
415 |
80e2721b
|
Ermal
|
( build_loop_operations ) | while read LINE
|
416 |
|
|
do
|
417 |
|
|
update_status "$LINE"
|
418 |
|
|
done
|
419 |
63205757
|
Ermal
|
|
420 |
|
|
export minsleepvalue=28800
|
421 |
|
|
export maxsleepvalue=86400
|
422 |
|
|
update_status ">>> Sleeping for at least $minsleepvalue, at most $maxsleepvalue in between snapshot builder runs. Last known commit ${PFSENSE_LAST_COMMIT}/${TOOLS_LAST_COMMIT}"
|
423 |
|
|
update_status ">>> Freezing build process at `date`."
|
424 |
|
|
sleep $minsleepvalue
|
425 |
|
|
update_status ">>> Thawing build process and resuming checks for pending commits at `date`."
|
426 |
|
|
|
427 |
|
|
# Count some sheep or wait until a new commit turns up
|
428 |
|
|
# for one days time. We will wake up if a new commit
|
429 |
|
|
# is deteceted during sleepy time.
|
430 |
|
|
sleep_between_runs $maxsleepvalue
|
431 |
|
|
|
432 |
|
|
# If REBOOT_AFTER_SNAPSHOT_RUN is defined reboot
|
433 |
|
|
# the box after the run.
|
434 |
|
|
if [ ! -z "${REBOOT_AFTER_SNAPSHOT_RUN:-}" ]; then
|
435 |
|
|
update_status ">>> Rebooting `hostname` due to \$REBOOT_AFTER_SNAPSHOT_RUN"
|
436 |
|
|
shutdown -r now
|
437 |
|
|
kill $$
|
438 |
|
|
fi
|
439 |
|
|
# Rotate log file (.old)
|
440 |
|
|
rotate_logfile
|
441 |
|
|
done
|
442 |
|
|
fi
|