From cf3dc88155a00c2f5a2dea91bca8cc505de457eb Mon Sep 17 00:00:00 2001 From: Jacen Date: Tue, 12 Sep 2017 22:11:07 +0200 Subject: [PATCH] Selection for the last stage to build --- README.md | 24 ++++++------------------ build.sh | 13 +++++++++++-- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 3a02095..4915d80 100755 --- a/README.md +++ b/README.md @@ -66,6 +66,10 @@ The following environment variables are supported: Output directory for target system images and NOOBS bundles. + * `LAST_STAGE` (Default: `"5"`) + + If you wish to build up to a specified stage (such as building up to stage 2 for a lite system) + A simple example for building Raspbian: @@ -155,21 +159,5 @@ maintenance and allows for more easy customization. ### Stage specification -If you wish to build up to a specified stage (such as building up to stage 2 -for a lite system), place an empty file named `SKIP` in each of the `./stage` -directories you wish not to include. - -Then remove the `EXPORT*` files from `./stage4` (if building up to stage 2) or -from `./stage2` (if building a minimal system). - -```bash -# Example for building a lite system -echo "IMG_NAME='Raspbian'" > config -touch ./stage3/SKIP ./stage4/SKIP ./stage5/SKIP -rm stage4/EXPORT* stage5/EXPORT* -sudo ./build.sh # or ./build-docker.sh -``` - -If you wish to build further configurations upon (for example) the lite -system, you can also delete the contents of `./stage3` and `./stage4` and -replace with your own contents in the same format. +If you wish to skip some steps you can add an empty file `SKIP` in the directory. +It works in `./stage*` or in `./stage*/**-whatever`. diff --git a/build.sh b/build.sh index 06d9abc..492fa16 100755 --- a/build.sh +++ b/build.sh @@ -128,6 +128,7 @@ if [ -z "${IMG_NAME}" ]; then exit 1 fi +export LAST_STAGE=${LAST_STAGE:-5} export IMG_DATE=${IMG_DATE:-"$(date +%Y-%m-%d)"} export BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" @@ -160,14 +161,22 @@ export QUILT_REFRESH_ARGS="-p ab" source ${SCRIPT_DIR}/common source ${SCRIPT_DIR}/dependencies_check +mkdir -p ${WORK_DIR} +# LAST_STAGE validation +if [[ "${LAST_STAGE,,}" =~ ^(2|4|5)$ ]]; then + log "Valid LAST_STAGE: $LAST_STAGE" +else + log "ERROR INVALID LAST_STAGE: $LAST_STAGE, try 2, 4 or 5" + exit 2 +fi dependencies_check ${BASE_DIR}/depends -mkdir -p ${WORK_DIR} log "Begin ${BASE_DIR}" -for STAGE_DIR in ${BASE_DIR}/stage*; do +for i in $( seq 0 $LAST_STAGE); do + STAGE_DIR=${BASE_DIR}/stage$i run_stage done