From baa17218216eff0fd83827cb202cf2ac1bb90e8e Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Fri, 25 Dec 2015 15:24:18 +0100 Subject: [PATCH 247/257] reproduce.sh: Add -p option to change the prefix for the source and object directories This could be useful when building ElectroBSD as port. Obtained from: ElectroBSD --- reproduce.sh | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/reproduce.sh b/reproduce.sh index d7b4fa941817..31be55b7ba04 100755 --- a/reproduce.sh +++ b/reproduce.sh @@ -33,8 +33,14 @@ EPOCH=__EPOCH__ # This is just a suggestion, feel free to overwrite it with the -j option. MAX_MAKE_JOBS="${MAX_MAKE_JOBS-4}" -# Currently hardcoded. -SRC_DIR=/usr/src +# Prefix to use for SRC_DIR and MAKEOBJDIRPREFIX +DIRECTORY_PREFIX="${DIRECTORY_PREFIX-/}" + +# Currently somewhat hardcoded. +SRC_DIR="${DIRECTORY_PREFIX}usr/src" +MAKEOBJDIRPREFIX="${DIRECTORY_PREFIX}usr/obj" + +# Config file location when -f isn't specified OPTIONAL_CONFIG_FILE="${SRC_DIR}/reproduce.conf" # Make sure we respawn with the same script, even if it is located @@ -62,6 +68,8 @@ reproduce_all_the_things() { export KERNFAST=1 export NO_CLEAN=1 fi + export MAKEOBJDIRPREFIX + announce_status "MAKEOBJDIRPREFIX is set to ${MAKEOBJDIRPREFIX}" announce_status "Starting to build the kernel" make buildkernel || return 1 @@ -70,7 +78,7 @@ reproduce_all_the_things() { make -j${MAX_MAKE_JOBS} buildworld || return 1 # Make sure obj files aren't dumped in ${SRC_DIR} - mkdir -p "/usr/obj${SRC_DIR}/release" || return 1 + mkdir -p "${MAKEOBJDIRPREFIX}${SRC_DIR}/release" || return 1 if ! "${RESUME_BUILD}"; then announce_status "Starting to clean the release dir" @@ -105,6 +113,7 @@ respawn_with_clean_environment() { exec env -i PATH="/sbin:/bin:/usr/sbin:/usr/bin" HOME="/root" \ LC_COLLATE=C SHELL=/bin/sh ALREADY_RESPAWNED=1 \ MAX_MAKE_JOBS="${MAX_MAKE_JOBS}" RESUME_BUILD="${RESUME_BUILD}" \ + DIRECTORY_PREFIX="${DIRECTORY_PREFIX}" \ REPRO_SEED="${REPRO_SEED}" SRCCONF=/dev/null /bin/sh "${REPRODUCE_SH}" } @@ -118,7 +127,7 @@ main() { dry_run=false config_file="${OPTIONAL_CONFIG_FILE}" - args=$(getopt af:j:nr $*) + args=$(getopt af:j:npr $*) if [ $? -ne 0 ]; then echo 'You are doing it wrong: Invalid flag specified' exit 2 @@ -148,6 +157,17 @@ main() { dry_run=true shift ;; + -p) + shift + DIRECTORY_PREFIX="${1}" + shift; + if [ ! -d "${DIRECTORY_PREFIX}" ]; then + echo "Directory ${DIRECTORY_PREFIX} specified with -p does not exist" + exit 2 + fi + # This is only needed for the cd below + SRC_DIR="${DIRECTORY_PREFIX}${SRC_DIR}" + ;; -r) shift RESUME_BUILD=true -- 2.11.0