Browse Source

update build script

Karsten Böddeker 7 years ago
parent
commit
f6af19d6cb
3 changed files with 41 additions and 48 deletions
  1. 1 2
      ReadMe.md
  2. 39 44
      build.sh
  3. 1 2
      docker-build.sh

+ 1 - 2
ReadMe.md

@@ -54,11 +54,10 @@ optional:
 * **BROKEN** falls "1", erzeuge zusätzlich Firmware-Images für ungetestete Plattformen (default: "0")
 * **BUILD_TS** setzt den Zeitstempel für den Build-Prozess (format: %Y-%m-%d %H:%M:%S)
 * **CLEAN** falls "dirclean", wird `make dirclean` ausgeführt, falls "clean" wird `make clean` ausgeführt, ansonsten keins von beidem (BRANCH=stable/testing default: "dirclean", BRANCH=experimental default: "clean")
-* **FAKETIME_LIB** gibt den Pfad zu libfaketime.so.1 an (default: "/usr/lib/${MACHTYPE}-${OSTYPE}/faketime/libfaketime.so.1")
 * **KEY_DIR** gibt das Verzeichnis für gluon-opkg-key an (default: ./opkg-keys)
 * **MAKEJOBS** spezifiziert die Anzahl der parallel laufenden Compiler-Prozesse (default: ein Prozess pro CPU/Kern)
-* **NO_FAKETIME** falls "1", wird ohne Faketime gebaut (default: "0")
 * **PRIORITY** spezifiziert die maximale Anzahl an Tagen, die ein Knoten das Einspielen des Updates verzögern darf (default: $(DEFAULT_GLUON_PRIORITY))
+* **PUBLISH** falls "1", veröffentliche die Firmware nach dem bauen
 * **SITE_ID** gibt die Commit-ID des Site-Repos an (default: HEAD)
 * **SITE_REPO_FETCH_METHOD** wählt die Methode zum Klonen des Site-Repos ('git' oder 'http', default: 'http')
 * **TARGETS** ein Liste durch Leerzeichen separierter Hardware-Zielplattformen (default: alle bekannten Plattformen)

+ 39 - 44
build.sh

@@ -12,12 +12,11 @@
 # AUTOUPDATER = force Autoupdater Branch (stable/testing/experimental/off)
 # BROKEN      = 0 (default) or 1, build the untested hardware model firmwares, too
 # BUILD_TS    = build timestamp (format: %Y-%m-%d %H:%M:%S)
-# CLEAN       = DIRCLEAN perform "make dirclean" before build (BRANCH==stable/testing) or CLEAN perform "make clean" (BRANCH==experimental) or NONE
-# FAKETIME_LIB = path to libfaketime.so.1 if it is not in the standard location
+# CLEAN       = DIRCLEAN perform "make dirclean" before build (BRANCH==stable/testing) or CLEAN perform "make clean" or NONE (BRANCH==experimental)
 # KEY_DIR     = specify directory for gluon-opkg-key
 # MAKEJOBS    = number of compiler processes running in parallel (default: number of CPUs/Cores)
-# NO_FAKETIME = 0 (default) or 1, disables the use of Faketime
 # PRIORITY    = determines the number of day a rollout phase should last at most
+# PUBLISH     = 0 (default) or 1, publish firmware at the end
 # SITE_ID     = specific site repository commit-id (leave blank to use HEAD)
 # SITE_REPO_FETCH_METHOD = http, everything except "git" will use the HTTP method for fetchting site repo
 # TARGETS     = a space separated list of target platforms (if unset, all platforms will be build)
@@ -39,7 +38,11 @@ PATCH_DIR="${SITE_DIR}/patches"
 OUTPUT_DIR="${MY_DIR}/output"
 IMAGE_DIR="${CODE_DIR}/output/images"
 MODULE_DIR="${CODE_DIR}/output/modules"
+MANIFEST_DIR="${CODE_DIR}/output/images/sysupgrade"
 VERSIONS_INFO_DIR="${MY_DIR}/versions"
+SRV_URL="firmware.in.ffho.net"
+SRV_USER="firmware"
+SRV_PATH="/srv/firmware"
 
 BUILD_INFO_FILENAME="build-info.txt"
 SITE_REPO_URL="git.c3pb.de/freifunk-pb/site-ffho.git"
@@ -67,7 +70,7 @@ fi
 
 if [ -z "${CLEAN}" ]; then
 	if [ "${BRANCH}" == "experimental" ]; then
-		CLEAN="clean"
+		CLEAN="none"
 	else
 		CLEAN="dirclean"
 	fi
@@ -79,11 +82,11 @@ else
 	KEY_DIR="${DEFAULT_KEY_DIR}"
 fi
 [ -e "${KEY_DIR}" ] || mkdir -p ${KEY_DIR}
-[ "$?" -eq "0" ] || abort "Unable to create output directory: ${KEY_DIR}"
+[ "$?" -eq "0" ] || abort "Unable to create key directory: ${KEY_DIR}"
 
 [ -n "${MAKEJOBS}" ] || MAKEJOBS=$(grep -c "^processor" /proc/cpuinfo)
-[ -n "${NO_FAKETIME}" ] || NO_FAKETIME=0
 [ -n "${PRIORITY}" ] || PRIORITY=0
+[ -n "${PUBLISH}" ] || PUBLISH=0
 [ -n "${SITE_REPO_FETCH_METHOD}" ] || SITE_REPO_FETCH_METHOD="http"
 [ -n "${VERBOSE}" ] || VERBOSE=0
 
@@ -166,7 +169,6 @@ if [ -d "${PATCH_DIR}" -a "$(echo ${PATCH_DIR}/*.patch)" ]; then
 fi
 git branch -M patched
 
-
 ### DIRCLEAN
 if [ -d "${GLUON_BUILD_DIR}/" -a "${CLEAN}" == "dirclean" ]; then
 	progress "Cleaning your build environment (make dirclean) ..."
@@ -190,7 +192,7 @@ if [ "${BRANCH}" == "experimental" -a -z "${VERSION}" ] ; then
 fi
 
 # we are now ready to produce the firmware images, so let's "save" our state
-build_info_path="${OUTPUT_DIR}/${BRANCH}/${BUILD_INFO_FILENAME}"
+build_info_path="${VERSIONS_INFO_DIR}/${VERSION}"
 progress "Saving build information to: ${build_info_path}"
 [ -n "${build_info_path}" -a -f "${build_info_path}" ] && rm -f ${build_info_path}
 mkdir -p $(dirname ${build_info_path})
@@ -204,13 +206,6 @@ echo "SITE=${SITE_COMMIT} # ${VERSION}" >> ${build_info_path}
 echo "TARGETS=${TARGETS}" >> ${build_info_path}
 echo "TS=${BUILD_TS}" >> ${build_info_path}
 
-### SETUP FAKETIME (consistent build)
-if [ "${NO_FAKETIME}" -eq "0" ]; then
-	[ -z "${FAKETIME_LIB}" ] && FAKETIME_LIB="/usr/lib/${MACHTYPE}-${OSTYPE}/faketime/libfaketime.so.1"
-	export LD_PRELOAD="${FAKETIME_LIB}"
-	export FAKETIME="${BUILD_TS}"
-fi
-
 ### restore gluon-opkg-key, if already exists
 if [ -e "${KEY_DIR}/gluon-opkg-key" -a -e "${KEY_DIR}/gluon-opkg-key.pub" ]; then
 	info "gluon-opkg-key already exists, restoring it."
@@ -261,45 +256,45 @@ for target in ${TARGETS} ; do
 	[ "$?" -eq "0" ] || abort "${target}: Unable to build modules."
 done
 
+# generate manifest
+progress "Generating manifest ..."
+GLUON_PRIORITY=${PRIORITY} GLUON_BRANCH=${BRANCH} make manifest
+[ "$?" -eq "0" ] || abort "Failed to generate the manifest."
+
 popd > /dev/null #${CODE_DIR}
 
-# compress all binaries into 7z archive
-if [ -d "${IMAGE_DIR}" ]; then
-	progress "Assembling images.7z ..."
-	pushd ${IMAGE_DIR} > /dev/null
-	[ -e "${OUTPUT_DIR}/${BRANCH}/images.7z" ] && rm "${OUTPUT_DIR}/${BRANCH}/images.7z"
-	7z a -mmt=on -xr!*.manifest "${OUTPUT_DIR}/${BRANCH}/images.7z" ./sysupgrade/* ./factory/*
-	[ "$?" -eq "0" ] || abort "Failed to assemble images (did you install p7zip-full?)."
-	popd > /dev/null #${IMAGE_DIR}
-fi
+if [ "${PUBLISH}" -eq "1" ]; then
+	# copying firmware to the server
+	if [ -d "${IMAGE_DIR}" ]; then
+		progress "Copying the firmware ..."
+		rsync -rlutzc --exclude=*manifest -e ssh ${IMAGE_DIR}/ ${SRV_USER}@${SRV_URL}:${SRV_PATH}/${VERSION}
+		[ "$?" -eq "0" ] || abort "Failed to copy the firmware."
+	fi
 
-# compress modules into 7z archive
-if [ -d "${MODULE_DIR}" ]; then
-	progress "Assembling modules.7z ..."
-	pushd ${MODULE_DIR} > /dev/null
-	[ -e "${OUTPUT_DIR}/${BRANCH}/modules.7z" ] && rm "${OUTPUT_DIR}/${BRANCH}/modules.7z"
-	7z a -mmt=on "${OUTPUT_DIR}/${BRANCH}/modules.7z" ./* > /dev/null
-	[ "$?" -eq "0" ] || abort "Failed to assemble modules."
-	popd > /dev/null #${MODULE_DIR}
-fi
+	# copying modules to the server
+	if [ -d "${MODULE_DIR}" ]; then
+		progress "Copying the modules ..."
+		rsync -rlutzc -e ssh ${MODULE_DIR}/gluon-ffho-${VERSION}/ ${SRV_USER}@${SRV_URL}:${SRV_PATH}/${VERSION}/modules
+		[ "$?" -eq "0" ] || abort "Failed to copy the modules."
+	fi
 
-# generate and copy manifests
-progress "Generating and copying manifest ..."
-pushd ${CODE_DIR} > /dev/null
-GLUON_PRIORITY=${PRIORITY} GLUON_BRANCH=${BRANCH} make manifest
-[ "$?" -eq "0" ] || abort "Failed to generate the manifest, try running 'make manifest' in '$CODE_DIR' directory manually."
-cp "${CODE_DIR}/output/images/sysupgrade/${BRANCH}.manifest" "${OUTPUT_DIR}/${BRANCH}/"
-popd > /dev/null #${CODE_DIR}
+	# copy manifest and the build info file
+	progress "Copying manifest and build info file ..."
+	cp "${MANIFEST_DIR}/${BRANCH}.manifest" "${OUTPUT_DIR}/${VERSION}/"
+	cp -p "${build_info_path}" "${OUTPUT_DIR}/${VERSION}/${BUILD_INFO_FILENAME}"
 
-# Saving a copy of the build info file as reference
-progress "Building a greater and brighter firmware finished successfully. Saving build information at: ${VERSIONS_INFO_DIR}/${VERSION}"
-cp -p "${build_info_path}" "${VERSIONS_INFO_DIR}/${VERSION}"
+	# Update symlinks
+	progress "Update symlink for ${BRANCH}"
+	pushd ${OUTPUT_DIR} > /dev/null
+	ln -fsn ${VERSION} ${BRANCH}
+	popd > /dev/null #${OUTPUT_DIR}
+fi
 
 # Saving a copy of gluon-opkg-key
 [ -e "${KEY_DIR}/gluon-opkg-key" -a -e "${KEY_DIR}/gluon-opkg-key.pub" ] || cp ${GLUON_BUILD_DIR}/gluon-opkg-key* ${KEY_DIR}/
 [ "$?" -eq "0" ] || abort "Failed to save gluon-opkg-key, try to execute 'cp ${GLUON_BUILD_DIR}/gluon-opkg-key* ${KEY_DIR}/' manually"
 
 # The end. Finally.
-success "We're done, go and enjoy your new firmware (${VERSION}) in ${OUTPUT_DIR}/${BRANCH}!"
+success "We're done, go and enjoy your new firmware (${VERSION})!"
 popd > /dev/null #${MY_DIR}
 

+ 1 - 2
docker-build.sh

@@ -31,11 +31,10 @@ docker run -ti -h ffho-build -v "${MYDIR}:/code" \
     --env BROKEN="${BROKEN}" \
     --env BUILD_TS="${BUILD_TS}" \
     --env CLEAN="${CLEAN}" \
-    --env FAKETIME_LIB="/usr/lib/x86_64-linux-gnu/faketime/libfaketime.so.1" \
     --env KEY_DIR="${KEY_DIR}" \
     --env MAKEJOBS="${MAKEJOBS}" \
-    --env NO_FAKETIME="${NO_FAKETIME}" \
     --env PRIORITY="${PRIORITY}" \
+    --env PUBLISH="0" \
     --env SITE_ID="${SITE_ID}" \
     --env TARGETS="${TARGETS}" \
     --env VERBOSE="${VERBOSE}" \