Browse Source

it is better to store gluon-opkg-key for future builds

if ./opkg-keys/gluon-opkg-key(.pub) exists, copy it to build directory

if there is no key in ./opkg-keys/, then copy the one from build directory after buildprocess
Karsten Böddeker 8 years ago
parent
commit
bbb91a1e33
3 changed files with 28 additions and 3 deletions
  1. 1 0
      .gitignore
  2. 26 3
      build.sh
  3. 1 0
      docker-build.sh

+ 1 - 0
.gitignore

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

+ 26 - 3
build.sh

@@ -13,16 +13,16 @@
 # 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
 #
-# expert/special usecase only (optional):
-# FAKETIME_LIB = path to libfaketime.so.1 if it is not in the standard location
-# NO_FAKETIME  = 0 (default) or 1, disables the use of Faketime
 
 
 ### includes
@@ -31,7 +31,9 @@
 ### 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"
@@ -72,6 +74,14 @@ if [ -z "${DIRCLEAN}" ]; then
 	fi
 fi
 
+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}"
+
 [ -n "${MAKEJOBS}" ] || MAKEJOBS=$(grep -c "^processor" /proc/cpuinfo)
 [ -n "${NO_FAKETIME}" ] || NO_FAKETIME=0
 [ -n "${PRIORITY}" ] || PRIORITY=0
@@ -189,6 +199,15 @@ if [ "${NO_FAKETIME}" -eq "0" ]; then
 	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
@@ -258,6 +277,10 @@ popd > /dev/null #${CODE_DIR}
 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 #${MY_DIR}

+ 1 - 0
docker-build.sh

@@ -32,6 +32,7 @@ docker run -ti -h ffho-build -v "${MYDIR}:/code" \
     --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}" \