Pārlūkot izejas kodu

Merge branch 'new'

Karsten Böddeker 8 gadi atpakaļ
vecāks
revīzija
565db04148
8 mainītis faili ar 247 papildinājumiem un 190 dzēšanām
  1. 2 0
      .gitignore
  2. 1 1
      LICENSE
  3. 15 0
      Makefile
  4. 3 3
      ReadMe.md
  5. 26 27
      build-version.sh
  6. 179 143
      build.sh
  7. 20 15
      docker-build.sh
  8. 1 1
      functions.sh

+ 2 - 0
.gitignore

@@ -1,3 +1,5 @@
 /.*
 output
 src
+opkg-keys
+versions/*exp*

+ 1 - 1
LICENSE

@@ -1,7 +1,7 @@
 The code of Project Gluon may be distributed under the following terms, unless
 noted otherwise in indiviual files or subtrees.
 
-Copyright (c) 2014-2015, Freifunk Paderborn
+Copyright (c) 2014-2016, Freifunk Hochstift
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without

+ 15 - 0
Makefile

@@ -0,0 +1,15 @@
+all:
+
+LC_ALL:=C
+LANG:=C
+
+GLUONDIR:=${CURDIR}/src
+
+include $(GLUONDIR)/include/gluon.mk
+include $(GLUONDIR)/targets/targets.mk
+
+list-targets:
+	@echo '$(GLUON_TARGETS)'
+
+default-release:
+	@echo '$(DEFAULT_GLUON_RELEASE)'

+ 3 - 3
ReadMe.md

@@ -1,4 +1,4 @@
-# Firmware von Freifunk Paderborn
+# Firmware von Freifunk Hochstift
 
 Dieses Repository beherbergt die Skripte, um die Firmware von Freifunk Paderborn zu bauen.
 Die Inhalte dieses Repositories werden unter einer "2-clause BSD" Lizenz veröffentlicht, Details sind der Datei [LICENSE](https://git.c3pb.de/freifunk-pb/firmware/blob/master/LICENSE) zu entnehmen.
@@ -6,7 +6,7 @@ Die Inhalte dieses Repositories werden unter einer "2-clause BSD" Lizenz veröff
 Beim Bauen der Firmware werden weitere Git-Repositories heruntergeladen und benutzt:
 
 * Basis: [Gluon](https://github.com/freifunk-gluon/gluon)
-* Site-Repository: [FFPB](https://git.c3pb.de/freifunk-pb/site-ffpb)
+* Site-Repository: [FFHO](https://git.c3pb.de/freifunk-pb/site-ffho)
 
 ## Vorbereitung / Umgebung
 
@@ -87,4 +87,4 @@ Die Nutzung von Docker zur Überprüfung von Builds wird dringend empfohlen, da
 ```bash
 ./build_version.sh 0.6.1_stable # baut Version '0.6.1_stable' erneut
 NO_DOCKER=1 ./build_version.sh 0.6.1_stable # ohne Docker-Umgebung erneut bauen
-```
+```

+ 26 - 27
build-version.sh

@@ -1,50 +1,49 @@
 #!/bin/bash
-# (c) 2014-2015 Freifunk Paderborn <maschinenraum@paderborn.freifunk.net>
+# (c) 2014-2016 Freifunk Hochstift <kontakt@hochstift.freifunk.net>
 #
 # calls build.sh with information found in given version
 
 MY_DIR=$(dirname $0)
-MY_DIR=$(readlink -f "$MY_DIR")
-pushd $MY_DIR > /dev/null
+MY_DIR=$(readlink -f "${MY_DIR}")
+pushd ${MY_DIR} > /dev/null
 
 . functions.sh
 
 version=$1
 versionfile="${MY_DIR}/versions/${version}"
-[ -r $versionfile ] || abort "Failed to find the version '$version'."
+[ -r ${versionfile} ] || abort "Failed to find the version '${version}'."
 
 [ -n "${BROKEN}" ] || BROKEN=0
-base=`awk 'BEGIN { FS="=" } /^GLUON=([a-f0-9]+)(\s*#.+)?$/ { print $2; }' $versionfile | awk 'BEGIN { FS="#" } { print $1; }'`
-branch=`awk 'BEGIN { FS="=" } /^BRANCH=([a-z]+)$/ { print $2; }' $versionfile`
-version=`awk 'BEGIN { FS="=" } /^VERSION=([0-9\.\-+~a-z]+)$/ { print $2; }' $versionfile`
-site_repo=`awk 'BEGIN { FS="=" } /^SITE_REPO=([a-z]+)$/ { print $2; }' $versionfile`
-site=`awk 'BEGIN { FS="=" } /^SITE=([a-f0-9]+)(\s*#.+)?$/ { print $2; }' $versionfile | awk 'BEGIN { FS="#" } { print $1; }'`
-targets=`awk 'BEGIN { FS="=" } /^TARGETS=.+$/ { print $2; }' $versionfile`
-ts=`awk 'BEGIN { FS="=" } /^TS=.+$/ { print $2; }' $versionfile`
-
-[ -z "$base" ] && abort "Failed to parse Gluon base commit-id from version file."
-[ -z "$branch" ] && abort "Failed to parse branch name from version file."
-[ -z "$version" ] && abort "Failed to parse version from version file."
-[ -z "$site_repo" ] && site_repo="ffpb"
-[ -z "$site" ] && abort "Failed to parse site repo commit-id from version file."
-[ -z "$ts" ] && abort "Failed to parse timestamp from version file."
+base=`awk 'BEGIN { FS="=" } /^GLUON=([a-f0-9]+)(\s*#.+)?$/ { print $2; }' ${versionfile} | awk 'BEGIN { FS="#" } { print $1; }'`
+branch=`awk 'BEGIN { FS="=" } /^BRANCH=([a-z]+)$/ { print $2; }' ${versionfile}`
+version=`awk 'BEGIN { FS="=" } /^VERSION=([0-9\.\-+~a-z]+)$/ { print $2; }' ${versionfile}`
+site=`awk 'BEGIN { FS="=" } /^SITE=([a-f0-9]+)(\s*#.+)?$/ { print $2; }' ${versionfile} | awk 'BEGIN { FS="#" } { print $1; }'`
+targets=`awk 'BEGIN { FS="=" } /^TARGETS=.+$/ { print $2; }' ${versionfile}`
+ts=`awk 'BEGIN { FS="=" } /^TS=.+$/ { print $2; }' ${versionfile}`
+
+[ -n "${base}" ] || abort "Failed to parse Gluon base commit-id from version file."
+[ -n "${branch}" ] || abort "Failed to parse branch name from version file."
+[ -n "${version}" ] || abort "Failed to parse version from version file."
+[ -n "${site}" ] || abort "Failed to parse site repo commit-id from version file."
+[ -n "${targets}" ] || abort "Failed to parse targets from version file"
+[ -n "${ts}" ] || abort "Failed to parse timestamp from version file."
 
 # remove all spaces from git-commit-ids
 base="${base// /}"
 site="${site// /}"
 
-info "Building $branch version '$version' again ..."
-echo " * Gluon base = $base"
-echo " * Site repo  = $site_repo"
-echo " * Site commit= $site"
-echo " * Timestamp  = $ts"
-echo " * Targets    = $targets"
+info "Building ${branch} version '${version}' again ..."
+echo " * Gluon base = ${base}"
+echo " * Site commit= ${site}"
+echo " * Timestamp  = ${ts}"
+echo " * Targets    = ${targets}"
 echo
 
 # invoke build script
-if [ "$NO_DOCKER" == "1" ]; then
-	BASE="$base" BRANCH="$branch" SITE="$site_repo" SITE_ID="$site" VERSION="$version" BUILD_TS="$ts" TARGETS="$targets" BROKEN="$BROKEN" ./build.sh
+if [ "${NO_DOCKER}" -eq "1" ]; then
+	BASE="${base}" BRANCH="${branch}" SITE_ID="${site}" VERSION="${version}" BUILD_TS="${ts}" TARGETS="${targets}" BROKEN="${BROKEN}" ./build.sh
 else
-	BASE="$base" BRANCH="$branch" SITE="$site_repo" SITE_ID="$site" VERSION="$version" BUILD_TS="$ts" TARGETS="$targets" BROKEN="$BROKEN" ./docker-build.sh
+	BASE="${base}" BRANCH="${branch}" SITE="${site_repo}" SITE_ID="${site}" VERSION="${version}" BUILD_TS="${ts}" TARGETS="${targets}" BROKEN="${BROKEN}" ./docker-build.sh
 fi
 
+popd > /dev/null #${MY_DIR}

+ 179 - 143
build.sh

@@ -1,158 +1,162 @@
 #!/bin/bash
-# (c) 2014-2015 Freifunk Paderborn <maschinenraum@paderborn.freifunk.net>
+# (c) 2014-2016 Freifunk Hochstift <kontakt@hochstift.freifunk.net>
 #
 # This script builds the firmware by the environment variables given, the
 # first two being mandatory:
 #
-# BASE      = Gluon Version (tag or commit, i.e. v2014.4)
-# BRANCH    = Firmware Branch (stable/testing/experimental)
-# SITE      = site repository to use
-# SITE_ID   = specific site repository commit-id (leave blank to use HEAD)
-# VERSION   = the version tag (can only be empty if BRANCH=experimental)
-# BUILD_TS  = build timestamp (format: %Y-%m-%d %H:%M:%S)
-# BROKEN    = 0 (default) or 1, build the untested hardware model firmwares, too
-# MAKEJOBS  = number of compiler processes running in parallel (default: number of CPUs/Cores)
-# TARGETS   = a space separated list of target platforms (if unset, all platforms will be build)
-# PRIORITY  = determines the number of day a rollout phase should last at most
-# VERBOSE   = 0 (default) or 1, call the make commands with 'V=s' to see actual errors better
+# BASE        = Gluon Version (tag or commit, i.e. v2014.4)
+# BRANCH      = Firmware Branch (stable/testing/experimental)
+# VERSION     = the version tag (can only be empty if BRANCH=experimental)
+#
+# optional:
+# 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)
+# DIRCLEAN    = 1 perform "make dirclean" before build (BRANCH==stable/testing) or 0 perform "make clean" (BRANCH==experimental)
+# FAKETIME_LIB = path to libfaketime.so.1 if it is not in the standard location
+# 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
+# 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)
+# VERBOSE     = 0 (default) or 1, call the make commands with 'V=s' to see actual errors better
 #
 
-function get_all_supported_platforms()
-{
-	local buffer;
-	for val in $(ls ${1}) ; do
-		[ -d "./${1}/${val}" ] || continue
-	buffer="${buffer} ${val}"
-	done
-	echo ${buffer}
-}
 
+### includes
+. functions.sh
 
-if [ "_$BRANCH" == "_" ]; then
-	echo "Please specify BRANCH environment variable." >&2
-	exit 1
-fi
+### static variables
+MY_DIR=$(dirname $0)
+MY_DIR=$(readlink -f "${MY_DIR}")
+DEFAULT_KEY_DIR="${MY_DIR}/opkg-keys"
+CODE_DIR="${MY_DIR}/src"
+GLUON_BUILD_DIR="${CODE_DIR}/build"
+SITE_DIR="${CODE_DIR}/site"
+PATCH_DIR="${SITE_DIR}/patches"
+OUTPUT_DIR="${MY_DIR}/output"
+IMAGE_DIR="${CODE_DIR}/output/images"
+MODULE_DIR="${CODE_DIR}/output/modules"
+VERSIONS_INFO_DIR="${MY_DIR}/versions"
 
-if [ "_$BASE" == "_" ]; then
-	echo "Please specify BASE environment variable (Gluon, i.e. 'v2014.3' or commit-id)." >&2
-	exit 1
-fi
+BUILD_INFO_FILENAME="build-info.txt"
+SITE_REPO_URL="git.c3pb.de/freifunk-pb/site-ffho.git"
+LANG=C
 
-if [ "${BRANCH}" != "experimental" -a "${BASE}" == "HEAD" ] ; then
-	echo "HEAD is not an allowed BASE-identifier for non-experimental builds." >&2
-	echo "Either use a tagged commit or the commit-SHA itself." >&2
-	exit 1
+pushd ${MY_DIR} > /dev/null
+
+### ERROR handling
+[ -n "${BASE}" ] || abort "Please specify BASE environment variable (Gluon, i.e. 'v2014.3' or commit-id)."
+[ -n "${BRANCH}" ] || abort "Please specify BRANCH environment variable."
+[ "${BRANCH}" == "experimental" -o "${BASE}" != "HEAD" ] || abort "HEAD is not an allowed BASE-identifier for non-experimental builds. Either use a tagged commit or the commit-SHA itself."
+[ -n "${VERSION}" -o "${BRANCH}" == "experimental" ] || abort "Please specify VERSION environment variable (not necessary for experimental branch)."
+[ "${BRANCH}" == "experimental" -o ! -r "${VERSIONS_INFO_DIR}/${VERSION}" ] || abort "There exists a version file for '${VERSION}' ... you are trying to do something really stupid, aren't you?"
+
+### set reasonable defaults for unset environment variables
+[ -n "${AUTOUPDATER}" ] || AUTOUPDATER=${BRANCH}
+# TODO: [ "${BASE}" == "master" ] && BASE="origin/master"
+if [ -n "${BROKEN}" ]; then
+	if [ "${BROKEN}" -eq "1" ]; then
+		export BROKEN
+	else
+		unset BROKEN
+	fi
 fi
+[ -n "${BUILD_TS}" ] || BUILD_TS=$(date +"%Y-%m-%d %H:%M:%S")
 
-if [ "_$VERSION" == "_" -a "$BRANCH" != "experimental" ]; then
-	echo "Please specify VERSION environment variable (not necessary for experimental branch)." >&2
-	exit 1
+if [ -z "${DIRCLEAN}" ]; then
+	if [ "${BRANCH}" == "experimental" ]; then
+		DIRCLEAN=0
+	else
+		DIRCLEAN=1
+	fi
 fi
 
-MY_DIR=$(dirname $0)
-MY_DIR=$(readlink -f "$MY_DIR")
-CODE_DIR="src"
-PATCH_DIR="site/patches"
-OUTPUT_DIR="${MY_DIR}/output"
-BUILD_INFO_FILENAME="build-info.txt"
-VERSIONS_INFO_DIR="versions"
-LANG=C
+if [ -n "${KEY_DIR}" ]; then
+	KEY_DIR=$(readlink -f "${KEY_DIR}")
+else
+	KEY_DIR="${DEFAULT_KEY_DIR}"
+fi
+[ -e "${KEY_DIR}" ] || mkdir -p ${KEY_DIR}
+[ "$?" -eq "0" ] || abort "Unable to create output directory: ${KEY_DIR}"
 
-pushd $MY_DIR > /dev/null
-[ "_$BUILD_TS" == "_" ] && export BUILD_TS=$(date +"%Y-%m-%d %H:%M:%S")
+[ -n "${MAKEJOBS}" ] || MAKEJOBS=$(grep -c "^processor" /proc/cpuinfo)
+[ -n "${NO_FAKETIME}" ] || NO_FAKETIME=0
+[ -n "${PRIORITY}" ] || PRIORITY=0
+[ -n "${SITE_REPO_FETCH_METHOD}" ] || SITE_REPO_FETCH_METHOD="http"
+[ -n "${VERBOSE}" ] || VERBOSE=0
 
-. functions.sh
+if [ "${SITE_REPO_FETCH_METHOD}" != "git" ]; then
+	SITE_REPO_URL="https://${SITE_REPO_URL}"
+else
+	SITE_REPO_URL="git@${SITE_REPO_URL}"
+fi
 
-### CHECK THAT VERSION DOES NOT YET EXISTS
-[ -n "$VERSION" -a -x "${VERSIONS_INFO_DIR}/${VERSION}" ] && abort "There exists a version file for '$VERSION' ... you are trying to do something really stupid, aren't you?"
+MAKE_PARAM=""
+[ "${VERBOSE}" -eq "1" ] && MAKE_PARAM="${MAKE_PARAM} V=s"
 
 ### INIT /src IF NECESSARY
-if [ ! -d "$CODE_DIR" ]; then
+if [ ! -d "${CODE_DIR}" ]; then
 	info "Code directory does not exist yet - fetching Gluon ..."
-	git clone https://github.com/freifunk-gluon/gluon.git "$CODE_DIR"
-fi
-
-if [ "_${SITE_REPO_FETCH_METHOD}" != "_git" ]; then
-	SITE_REPO_URL="https://git.c3pb.de/freifunk-pb/site-${SITE}.git"
-else
-	SITE_REPO_URL="git@git.c3pb.de:freifunk-pb/site-${SITE}.git"
+	git clone https://github.com/freifunk-gluon/gluon.git "${CODE_DIR}"
+	[ "$?" -eq "0" ] || abort "Failed to fetch Gluon repository."
 fi
 
 ### INIT /src/site IF NECESSARY
-if [ -d "$CODE_DIR/site" ]; then
-	# verify the site-repo is the correct one ($SITE), otherwise delete the repo
-	pushd "$CODE_DIR/site"
-	url=$(git remote show origin | awk '/Fetch URL/ { print $3; }')
-	if [ "$SITE_REPO_URL" != "$url" ]; then
-		info "The site repository is not the correct one."
-		if ! git diff-index --quiet HEAD --; then
-			popd > /dev/null
-			abort "The site repo is the wrong one but has local modifications, please fix this manually."
-		fi
-		# check on the actual branch, not the target one given as parameter
-		local_branch=$(git branch --list --no-color | awk '/^*/ { print $2; }')
-		commits=$(git log origin/${local_branch}..HEAD)
-		if [ -n "$commits" ]; then
-			popd > /dev/null
-			abort "The site repo is the wrong one but has unpushed commits, please fix this manually."
-		fi
-
-		# remove the directory without asking further questions
-		popd > /dev/null
-		rm -Rf "$CODE_DIR/site" || abort "Failed to remove wrong site-repository."
-		success "Removed old site directory in order to be able to clone the correct one."
-	else
-		popd > /dev/null
-	fi
-fi
-
-if [ ! -d "$CODE_DIR/site" ]; then
+if [ ! -d "${SITE_DIR}" ]; then
 	info "Site repository does not exist, fetching it ..."
-	git clone "$SITE_REPO_URL" "$CODE_DIR/site" || abort "Failed to fetch SITE repository."
+	git clone "${SITE_REPO_URL}" "${SITE_DIR}"
+	[ "$?" -eq "0" ] || abort "Failed to fetch SITE repository."
 fi
 
+pushd ${CODE_DIR} > /dev/null
+
 ### CHECKOUT GLUON
-progress "Checking out GLUON '$BASE' ..."
-cd $CODE_DIR
+progress "Checking out GLUON '${BASE}' ..."
 # TODO: check if gluon got modified and bail out if necessary
 git fetch
-if [ "$BASE" = "master" ]; then
-	git checkout -q origin/master
-else
-	git checkout -q $BASE
-fi
-[ "$?" -eq "0" ] || abort "Failed to checkout '$BASE' gluon base version, mimimi." >&2
+git checkout -q ${BASE}
+[ "$?" -eq "0" ] || abort "Failed to checkout '${BASE}' gluon base version, mimimi." >&2
 GLUON_COMMIT=$(git rev-list --max-count=1 HEAD)
 
+
 ### CHECKOUT SITE REPO
 progress "Checking out SITE REPO ..."
-cd site
+pushd ${SITE_DIR} > /dev/null
 # TODO: check if site got modified locally and bail out if necessary
-if [ "_${SITE_ID}" == "_" ]; then
+if [ -z "${SITE_ID}" ]; then
 	# no specific site given - get the most current one
-	git checkout -q $BRANCH ; git pull
-	[ "$?" -eq "0" ] || abort "Failed to get newest '$BRANCH' in site repository, mimimi."
+	git checkout -q ${BRANCH} ; git pull
+	[ "$?" -eq "0" ] || abort "Failed to get newest '${BRANCH}' in site repository, mimimi."
 else
 	# fetch site repo updates
 	git fetch || true
 	# commit given - use this one
-	git checkout -q ${SITE_ID} || abort "Failed to checkout requested site commit, mimimi."
+	git checkout -q ${SITE_ID}
+	[ "$?" -eq "0" ] || abort "Failed to checkout requested site commit '${SITE_ID}', mimimi."
 fi
 SITE_COMMIT=$(git rev-list --max-count=1 HEAD)
-
-cd ..
+popd > /dev/null #${SITE_DIR}
 
 ### APPLY PATCHES TO GLUON
-if [ -d "$PATCH_DIR" ]; then
-	progress "Applying Patches ..."
-	git am $PATCH_DIR/*.patch
+progress "Applying Patches ..."
+git checkout -B patching "${BASE}"
+if [ "$(echo "${PATCH_DIR}"/*.patch)" ]; then
+	git am ${PATCH_DIR}/*.patch || (
+		git am --abort
+		git checkout patched
+		git branch -D patching
+		false
+	)
 	[ "$?" -eq "0" ] || abort "Failed to apply patches, mimimi."
 fi
+git branch -M patched
 
 
-### CLEAN
-if [ -d "./build/" -a "$BRANCH" != "experimental" ]; then
+### DIRCLEAN
+if [ -d "./build/" -a "${DIRCLEAN}" -eq "1" ]; then
 	progress "Cleaning your build environment ..."
 	make dirclean
 fi
@@ -161,24 +165,19 @@ fi
 progress "Preparing the build environment (make update) ..."
 make update
 [ "$?" -eq "0" ] || abort "Failed to update the build environment, mimimi."
+popd > /dev/null #${CODE_DIR}
 
-# determine VERSION for BRANCH=experimental if it is not set
+### set reasonable defaults for ${TARGETS} and ${BRANCH} if unset
+if [ -z "${TARGETS}" ]; then
+        TARGETS=$(make list-targets | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
+        info "building all tagets: '${TARGETS}'"
+fi
 if [ "${BRANCH}" == "experimental" -a -z "${VERSION}" ] ; then
-	default_release_pattern=$( awk -F" := " '/^DEFAULT_GLUON_RELEASE/ { gsub("shell ", "", $2); print $2; }' ./site/site.mk )
-	VERSION=$(eval echo ${default_release_pattern})
-
-	info "EXPERIMENTAL FIRMWARE: using version tag '$VERSION'"
+        VERSION=$(make default-release)
+        info "EXPERIMENTAL FIRMWARE: using version tag '${VERSION}'"
 fi
 
-# set reasonable defaults for unset environment variables
-[ -n "${BROKEN}" ] || BROKEN=0
-[ -n "${MAKEJOBS}" ] || MAKEJOBS=$(grep -c "^processor" /proc/cpuinfo)
-[ -n "${TARGETS}" ] || TARGETS=$(get_all_supported_platforms "./targets")
-[ -n "${PRIORITY}" ] || PRIORITY=0
-MAKE_PARAM=""
-[ "_$VERBOSE" = "_1" ] && MAKE_PARAM="${MAKE_PARAM} V=s"
-
-# we are now ready to produke the firmware images, so let's "save" our state
+# we are now ready to produce the firmware images, so let's "save" our state
 build_info_path="${OUTPUT_DIR}/${BRANCH}/${BUILD_INFO_FILENAME}"
 progress "Saving build information to: ${build_info_path}"
 [ -n "${build_info_path}" -a -f "${build_info_path}" ] && rm -f ${build_info_path}
@@ -189,63 +188,100 @@ touch $(dirname ${build_info_path})
 echo "VERSION=${VERSION}" >> ${build_info_path}
 echo "GLUON=${GLUON_COMMIT} # ${BASE}" >> ${build_info_path}
 echo "BRANCH=${BRANCH}" >> ${build_info_path}
-echo "SITE_REPO=${SITE}" >> ${build_info_path}
 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."
+	mkdir -p ${GLUON_BUILD_DIR}/
+	[ "$?" -eq "0" ] || abort "Unable to create directory: ${GLUON_BUILD_DIR}/"
+	cp -f ${KEY_DIR}/gluon-opkg-key* ${GLUON_BUILD_DIR}/
+	[ "$?" -eq "0" ] || abort "Unable to copy gluon-opkg-key."
+fi
+
 ### BUILD FIRMWARE
 progress "Building the firmware - please stand by!"
+pushd ${CODE_DIR} > /dev/null
 
 for target in ${TARGETS} ; do
 	# configure build environment for our current target
 	export GLUON_TARGET="${target}"
-	gluon_build_env_vars="GLUON_TARGET=\"${target}\" GLUON_BRANCH=\"${BRANCH}\" GLUON_RELEASE=\"${VERSION}\" BROKEN=\"${BROKEN}\""
+	export GLUON_RELEASE="${VERSION}"
+	[ "${AUTOUPDATER}" != "off" ] && export GLUON_BRANCH="${AUTOUPDATER}"
 
 	# prepare build environment for our current target
 	progress "Preparing build environment for target ${target}."
-	[ "${BRANCH}" == "experimental" ] || make clean
-	make -j ${MAKEJOBS} prepare-target${MAKE_PARAM}
+	[ "${DIRCLEAN}" -eq "0" ] && make clean
+	[ "$?" -eq "0" ] || abort "Unable to clean environment for target-platform ${target}."
+
+	make -j ${MAKEJOBS} prepare-target ${MAKE_PARAM}
+	[ "$?" -eq "0" ] || abort "Unable to build environment for target-platform ${target}."
 
 	# need to have a toolchain for the particular target 
 	progress "Building toolchain for target ${target}."
-	make -j ${MAKEJOBS} toolchain/install${MAKE_PARAM}
-	[ "$?" -eq "0" ] || abort "Unable to build toolchain for target. Aborting."
+	make -j ${MAKEJOBS} toolchain/install ${MAKE_PARAM}
+	[ "$?" -eq "0" ] || abort "Unable to build toolchain for target-platform ${target}."
 
 	# now we can start building the images for the target platform
-	progress "Building FFPB-flavoured Gluon firmware for target ${target}. You'd better go and fetch some c0ffee!"
-	make_targets="prepare"
-	eval "${gluon_build_env_vars} faketime \"$BUILD_TS\" make -j ${MAKEJOBS} ${make_targets}${MAKE_PARAM}"
+	progress "Building FFHO-flavoured Gluon firmware for target ${target}. You'd better go and fetch some c0ffee!"
+	make -j ${MAKEJOBS} prepare ${MAKE_PARAM}
 	[ "$?" -eq "0" ] || abort "Failed to build firmware for target-platform ${target}."
 
 	# finally compile the firmware binaries
 	progress "Compiling binary firmware images."
-	faketime "$BUILD_TS" make images${MAKE_PARAM}
+	make -j ${MAKEJOBS} images ${MAKE_PARAM}
 	[ "$?" -eq "0" ] || abort "Failed to assemble images for target-platform ${target}."
+
+	# compile the modules
+	progress "Compiling modules."
+	make -j ${MAKEJOBS} modules ${MAKE_PARAM}
+	[ "$?" -eq "0" ] || abort "Failed to build modules for target-platform ${target}."
 done
 
-cd ..
+popd > /dev/null #${CODE_DIR}
 
 # compress all binaries into 7z archive
 progress "Assembling images.7z ..."
+pushd ${IMAGE_DIR} > /dev/null
 [ -e "${OUTPUT_DIR}/${BRANCH}/images.7z" ] && rm "${OUTPUT_DIR}/${BRANCH}/images.7z"
-if [ ${BRANCH} == "experimental" ]; then
-        7z a -xr!*.manifest "${OUTPUT_DIR}/${BRANCH}/images.7z" ${CODE_DIR}/output/images/sysupgrade/* ${CODE_DIR}/output/images/factory/* || abort "Failed to assemble images (did you install p7zip-full?)."
-else
-        7z a -xr!*.manifest "${OUTPUT_DIR}/${BRANCH}/images.7z" ${CODE_DIR}/images/sysupgrade/* ${CODE_DIR}/images/factory/* || abort "Failed to assemble images (did you install p7zip-full?)."
-fi
-
-# generate, franken-merge, and copy manifests
+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}
+
+# compress modules into 7z archive
+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}
+
+# generate and copy manifests
 progress "Generating and copying manifest ..."
-pushd $CODE_DIR
-GLUON_TARGET="ar71xx-generic" GLUON_BRANCH=$BRANCH make manifest || abort "Failed to generate the manifest, try running 'make manifest' in '$CODE_DIR' directory manually."
-popd
-cp "${CODE_DIR}/images/sysupgrade/${BRANCH}.manifest" "${OUTPUT_DIR}/${BRANCH}/"
+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}
 
 # 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}"
 
+# 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 in ${OUTPUT_DIR}/${BRANCH}!"
-popd > /dev/null
+popd > /dev/null #${MY_DIR}
+

+ 20 - 15
docker-build.sh

@@ -1,5 +1,5 @@
 #!/bin/bash
-# (c) 2014-2015 Freifunk Hochstift <maschinenraum@hochstift.freifunk.net>
+# (c) 2014-2016 Freifunk Hochstift <kontakt@hochstift.freifunk.net>
 
 # check if we're in the container
 running_in_docker() {
@@ -19,21 +19,26 @@ if [ running_in_docker -a "$(id -un)" == "build" ]; then
 fi
 
 MYDIR="$(dirname $0)"
-MYDIR="$(readlink -f $MYDIR)"
-pushd "$MYDIR" > /dev/null
+MYDIR="$(readlink -f ${MYDIR})"
+pushd "${MYDIR}" > /dev/null
 
 # run the container with fixed hostname and mapped /code directory
-docker run -ti -h ffho-build -v "$MYDIR:/code" \
-    --env BUILD_TS="$BUILD_TS" \
-    --env BASE="$BASE" \
-    --env BRANCH="$BRANCH" \
-    --env BROKEN="$BROKEN" \
-    --env MAKEJOBS="$MAKEJOBS" \
-    --env VERBOSE="$VERBOSE" \
-    --env VERSION="$VERSION" \
-    --env TARGETS="$TARGETS" \
-    --env SITE="$SITE" \
-    --env SITE_ID="$SITE_ID" \
+docker run -ti -h ffho-build -v "${MYDIR}:/code" \
+    --env BASE="${BASE}" \
+    --env BRANCH="${BRANCH}" \
+    --env VERSION="${VERSION}" \
+    --env AUTOUPDATER="${AUTOUPDATER}" \
+    --env BROKEN="${BROKEN}" \
+    --env BUILD_TS="${BUILD_TS}" \
+    --env DIRCLEAN="${DIRCLEAN}" \
+    --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 SITE_ID="${SITE_ID}" \
+    --env TARGETS="${TARGETS}" \
+    --env VERBOSE="${VERBOSE}" \
     ffpb/build
 
-popd > /dev/null
+popd > /dev/null #${MYDIR}

+ 1 - 1
functions.sh

@@ -1,5 +1,5 @@
 #!/bin/bash
-# (c) 2014-2015 Freifunk Paderborn <maschinenraum@paderborn.freifunk.net>
+# (c) 2014-2016 Freifunk Hochstift <kontakt@hochstift.freifunk.net>
 #
 # Helper functions for 'fancy' output