diff options
| author | Greg MacLellan <github@list.mtechsolutions.ca> | 2016-10-05 04:32:03 -0400 |
|---|---|---|
| committer | XECDesign <XECDesign@users.noreply.github.com> | 2016-10-05 09:32:03 +0100 |
| commit | 7f0c59d5c1291c087eccc4fc70014190de6a439f (patch) | |
| tree | 00e655391517d8cec2e5cdc359fb74261870b2ce | |
| parent | 62406bad92ed23728f46711b3539c04c37dfb62c (diff) | |
Add MAX_STAGE and RUN_STAGE variables (#21)
* Add MAX_STAGES variable
If set, only runs up to that stage
* Show "Skipping stageX" message for all skipped stages
* Add RUN_STAGE variable to run a single stage
* Document RUN_STAGE and MAX_STAGE
* Removed SKIP file support for main stage
| -rw-r--r-- | README.md | 3 | ||||
| -rwxr-xr-x | build.sh | 43 |
2 files changed, 28 insertions, 18 deletions
@@ -1,6 +1,5 @@ #TODO -1. Simplify running a single stage 1. Documentation #Dependencies @@ -17,6 +16,8 @@ The following environment variables are supported: * `IMG_NAME`, the name of the distribution to build (required) * `APT_PROXY`, proxy/cache URL to be included in the build + * `MAX_STAGE`, to only run up to this stage. (default `4`, eg: `MAX_STAGE=2`) + * `RUN_STAGE`, to only run a single stage (eg: `RUN_STAGE=1`) A simple example for building Raspbian: @@ -88,24 +88,22 @@ run_stage(){ if [ -f ${STAGE_DIR}/EXPORT_IMAGE ]; then EXPORT_DIRS="${EXPORT_DIRS} ${STAGE_DIR}" fi - if [ ! -f SKIP ]; then - if [ "${CLEAN}" = "1" ]; then - if [ -d ${ROOTFS_DIR} ]; then - rm -rf ${ROOTFS_DIR} - fi - fi - if [ -x prerun.sh ]; then - log "Begin ${STAGE_DIR}/prerun.sh" - ./prerun.sh - log "End ${STAGE_DIR}/prerun.sh" + if [ "${CLEAN}" = "1" ]; then + if [ -d ${ROOTFS_DIR} ]; then + rm -rf ${ROOTFS_DIR} fi - for SUB_STAGE_DIR in ${STAGE_DIR}/*; do - if [ -d ${SUB_STAGE_DIR} ] && - [ ! -f ${SUB_STAGE_DIR}/SKIP ]; then - run_sub_stage - fi - done fi + if [ -x prerun.sh ]; then + log "Begin ${STAGE_DIR}/prerun.sh" + ./prerun.sh + log "End ${STAGE_DIR}/prerun.sh" + fi + for SUB_STAGE_DIR in ${STAGE_DIR}/*; do + if [ -d ${SUB_STAGE_DIR} ] && + [ ! -f ${SUB_STAGE_DIR}/SKIP ]; then + run_sub_stage + fi + done unmount ${WORK_DIR}/${STAGE} PREV_STAGE=${STAGE} PREV_STAGE_DIR=${STAGE_DIR} @@ -128,6 +126,12 @@ if [ -z "${IMG_NAME}" ]; then exit 1 fi +if [ -n "${RUN_STAGE}" ]; then + echo "Running ONLY stage${RUN_STAGE}" +elif [ -n "${MAX_STAGE}" ]; then + echo "Running stage${MAX_STAGE} build" +fi + export IMG_DATE=${IMG_DATE:-"$(date -u +%Y-%m-%d)"} export BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" @@ -166,7 +170,12 @@ mkdir -p ${WORK_DIR} log "Begin ${BASE_DIR}" for STAGE_DIR in ${BASE_DIR}/stage*; do - run_stage + STAGE_DIR_NUM=$(echo $STAGE_DIR | grep -o -E "[0-9]+$") + if [[ (-z $RUN_STAGE || $STAGE_DIR_NUM -eq $RUN_STAGE) && (-z $MAX_STAGE || $STAGE_DIR_NUM -le $MAX_STAGE) ]]; then + run_stage + else + echo "Skipping ${STAGE_DIR}" + fi done CLEAN=1 |
