diff options
author | Renato Botelho <renato@netgate.com> | 2015-11-25 09:39:23 -0200 |
---|---|---|
committer | Renato Botelho <renato@netgate.com> | 2015-11-25 09:39:23 -0200 |
commit | 919c84863cbf711b9335cf265771ad8a5fe750e6 (patch) | |
tree | 5ea190b32d133aa49b85c12a6d3256c0088946ed /tools | |
parent | 9447077e3f9e3e90d5afd5aa223348e71cd1350a (diff) | |
download | pfsense-919c84863cbf711b9335cf265771ad8a5fe750e6.zip pfsense-919c84863cbf711b9335cf265771ad8a5fe750e6.tar.gz |
Teach build_snapshots to deal with poudriere builds
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/build_snapshots.sh | 50 | ||||
-rw-r--r-- | tools/builder_common.sh | 22 | ||||
-rw-r--r-- | tools/builder_defaults.sh | 11 |
3 files changed, 62 insertions, 21 deletions
diff --git a/tools/build_snapshots.sh b/tools/build_snapshots.sh index e1e5fab..b9b07fd 100755 --- a/tools/build_snapshots.sh +++ b/tools/build_snapshots.sh @@ -31,8 +31,9 @@ # usage() { - echo "Usage: $(basename $0) [-l] [-r] [-u]" + echo "Usage: $(basename $0) [-l] [-r] [-u] [-p]" echo " -l: Build looped operations" + echo " -p: Update poudriere repo" echo " -r: Do not reset local changes" echo " -u: Do not upload snapshots" } @@ -43,15 +44,17 @@ export BUILDER_ROOT=$(realpath "${BUILDER_TOOLS}/..") NO_RESET="" NO_UPLOAD="" LOOPED_SNAPSHOTS="" -export minsleepvalue=${minsleepvalue:-"28800"} -export maxsleepvalue=${maxsleepvalue:-"86400"} +POUDRIERE_SNAPSHOTS="" # Handle command line arguments -while getopts lur opt; do +while getopts lpru opt; do case ${opt} in l) LOOPED_SNAPSHOTS=1 ;; + p) + POUDRIERE_SNAPSHOTS=--poudriere-snapshots + ;; r) NO_RESET=1 ;; @@ -65,6 +68,13 @@ while getopts lur opt; do esac done +if [ -n "${POUDRIERE_SNAPSHOTS}" ]; then + export minsleepvalue=${minsleepvalue:-"1800"} +else + export minsleepvalue=${minsleepvalue:-"28800"} +fi +export maxsleepvalue=${maxsleepvalue:-"86400"} + # Keeps track of how many time builder has looped export BUILDCOUNTER=0 export COUNTER=0 @@ -73,7 +83,8 @@ export COUNTER=0 export _sleeping=0 snapshot_update_status() { - ${BUILDER_ROOT}/build.sh ${NO_UPLOAD} --snapshot-update-status "${1}" + ${BUILDER_ROOT}/build.sh ${NO_UPLOAD} ${POUDRIERE_SNAPSHOTS} \ + --snapshot-update-status "${1}" } git_last_commit() { @@ -154,14 +165,27 @@ while [ /bin/true ]; do git_last_commit - (${BUILDER_ROOT}/build.sh --clean-builder 2>&1) | while read -r LINE; do - snapshot_update_status "${LINE}" - done - - (${BUILDER_ROOT}/build.sh ${NO_UPLOAD} --flash-size '1g 2g 4g' \ - --snapshots 2>&1) | while read -r LINE; do - snapshot_update_status "${LINE}" - done + if [ -n "${POUDRIERE_SNAPSHOTS}" ]; then + (${BUILDER_ROOT}/build.sh --update-poudriere-ports 2>&1) \ + | while read -r LINE; do + snapshot_update_status "${LINE}" + done + + (${BUILDER_ROOT}/build.sh ${NO_UPLOAD} --update-pkg-repo 2>&1) \ + | while read -r LINE; do + snapshot_update_status "${LINE}" + done + else + (${BUILDER_ROOT}/build.sh --clean-builder 2>&1) \ + | while read -r LINE; do + snapshot_update_status "${LINE}" + done + + (${BUILDER_ROOT}/build.sh ${NO_UPLOAD} --flash-size '1g 2g 4g' \ + --snapshots 2>&1) | while read -r LINE; do + snapshot_update_status "${LINE}" + done + fi if [ -z "${LOOPED_SNAPSHOTS}" ]; then # only one build required, exiting diff --git a/tools/builder_common.sh b/tools/builder_common.sh index c87010d..077cf7f 100644 --- a/tools/builder_common.sh +++ b/tools/builder_common.sh @@ -2048,18 +2048,23 @@ poudriere_bulk() { # and we scp the log file to the builder host if # needed for the real time logging functions. snapshots_update_status() { - if [ -z "${SNAPSHOTS}" -o -z "$1" ]; then + if [ -z "$1" ]; then + return + fi + if [ -z "${SNAPSHOTS}" -a -z "${POUDRIERE_SNAPSHOTS}" ]; then return fi echo $1 echo "`date` -|- $1" >> $SNAPSHOTSLOGFILE - if [ -z "${DO_NOT_UPLOAD}" -a -n "${RSYNCIP}" ]; then - LU=`cat $SNAPSHOTSLASTUPDATE` - CT=`date "+%H%M%S"` + if [ -z "${DO_NOT_UPLOAD}" -a -n "${SNAPSHOTS_RSYNCIP}" ]; then + LU=$(cat $SNAPSHOTSLASTUPDATE 2>/dev/null) + CT=$(date "+%H%M%S") # Only update every minute if [ "$LU" != "$CT" ]; then - ssh ${RSYNCUSER}@${RSYNCIP} "mkdir -p ${RSYNCLOGS}" - scp -q $SNAPSHOTSLOGFILE ${RSYNCUSER}@${RSYNCIP}:${RSYNCLOGS}/build.log + ssh ${SNAPSHOTS_RSYNCUSER}@${SNAPSHOTS_RSYNCIP} \ + "mkdir -p ${SNAPSHOTS_RSYNCLOGS}" + scp -q $SNAPSHOTSLOGFILE \ + ${SNAPSHOTS_RSYNCUSER}@${SNAPSHOTS_RSYNCIP}:${SNAPSHOTS_RSYNCLOGS}/build.log date "+%H%M%S" > $SNAPSHOTSLASTUPDATE fi fi @@ -2068,8 +2073,9 @@ snapshots_update_status() { # Copy the current log file to $filename.old on # the snapshot www server (real time logs) snapshots_rotate_logfile() { - if [ -z "${DO_NOT_UPLOAD}" -a -n "${RSYNCIP}" ]; then - scp -q $SNAPSHOTSLOGFILE ${RSYNCUSER}@${RSYNCIP}:${RSYNCLOGS}/build.log.old + if [ -z "${DO_NOT_UPLOAD}" -a -n "${SNAPSHOTS_RSYNCIP}" ]; then + scp -q $SNAPSHOTSLOGFILE \ + ${SNAPSHOTS_RSYNCUSER}@${SNAPSHOTS_RSYNCIP}:${SNAPSHOTS_RSYNCLOGS}/build.log.old fi # Cleanup log file diff --git a/tools/builder_defaults.sh b/tools/builder_defaults.sh index 438e300..4d1b448 100644 --- a/tools/builder_defaults.sh +++ b/tools/builder_defaults.sh @@ -273,6 +273,7 @@ export POUDRIERE_PORTS_GIT_BRANCH=${POUDRIERE_PORTS_GIT_BRANCH:-"devel"} export PKG_RSYNC_USERNAME=${PKG_RSYNC_USERNAME:-"wwwsync"} export PKG_RSYNC_SSH_PORT=${PKG_RSYNC_SSH_PORT:-"22"} export PKG_RSYNC_DESTDIR=${PKG_RSYNC_DESTDIR:-"/usr/local/www/beta/packages"} +export PKG_RSYNC_LOGS=${PKG_RSYNC_LOGS:-"/usr/local/www/beta"} export PKG_REPO_SERVER=${PKG_REPO_SERVER:-"pkg+http://beta.pfsense.org/packages"} export PKG_REPO_CONF_BRANCH=${PKG_REPO_CONF_BRANCH:-"${GIT_REPO_BRANCH_OR_TAG}"} @@ -344,3 +345,13 @@ mkdir -p ${STAGINGAREA} export SNAPSHOTSLOGFILE=${SNAPSHOTSLOGFILE:-"${SCRATCHDIR}/snapshots-build.log"} export SNAPSHOTSLASTUPDATE=${SNAPSHOTSLASTUPDATE:-"${SCRATCHDIR}/snapshots-lastupdate.log"} + +if [ -n "${POUDRIERE_SNAPSHOTS}" ]; then + export SNAPSHOTS_RSYNCIP=${PKG_RSYNC_HOSTNAME} + export SNAPSHOTS_RSYNCUSER=${PKG_RSYNC_USERNAME} + export SNAPSHOTS_RSYNCLOGS=${PKG_RSYNC_LOGS} +else + export SNAPSHOTS_RSYNCIP=${RSYNCIP} + export SNAPSHOTS_RSYNCUSER=${RSYNCUSER} + export SNAPSHOTS_RSYNCLOGS=${RSYNCLOGS} +fi |