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
This commit is contained in:
parent
62406bad92
commit
7f0c59d5c1
2 changed files with 28 additions and 18 deletions
|
@ -1,6 +1,5 @@
|
||||||
#TODO
|
#TODO
|
||||||
|
|
||||||
1. Simplify running a single stage
|
|
||||||
1. Documentation
|
1. Documentation
|
||||||
|
|
||||||
#Dependencies
|
#Dependencies
|
||||||
|
@ -17,6 +16,8 @@ The following environment variables are supported:
|
||||||
|
|
||||||
* `IMG_NAME`, the name of the distribution to build (required)
|
* `IMG_NAME`, the name of the distribution to build (required)
|
||||||
* `APT_PROXY`, proxy/cache URL to be included in the build
|
* `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:
|
A simple example for building Raspbian:
|
||||||
|
|
||||||
|
|
13
build.sh
13
build.sh
|
@ -88,7 +88,6 @@ run_stage(){
|
||||||
if [ -f ${STAGE_DIR}/EXPORT_IMAGE ]; then
|
if [ -f ${STAGE_DIR}/EXPORT_IMAGE ]; then
|
||||||
EXPORT_DIRS="${EXPORT_DIRS} ${STAGE_DIR}"
|
EXPORT_DIRS="${EXPORT_DIRS} ${STAGE_DIR}"
|
||||||
fi
|
fi
|
||||||
if [ ! -f SKIP ]; then
|
|
||||||
if [ "${CLEAN}" = "1" ]; then
|
if [ "${CLEAN}" = "1" ]; then
|
||||||
if [ -d ${ROOTFS_DIR} ]; then
|
if [ -d ${ROOTFS_DIR} ]; then
|
||||||
rm -rf ${ROOTFS_DIR}
|
rm -rf ${ROOTFS_DIR}
|
||||||
|
@ -105,7 +104,6 @@ run_stage(){
|
||||||
run_sub_stage
|
run_sub_stage
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
|
||||||
unmount ${WORK_DIR}/${STAGE}
|
unmount ${WORK_DIR}/${STAGE}
|
||||||
PREV_STAGE=${STAGE}
|
PREV_STAGE=${STAGE}
|
||||||
PREV_STAGE_DIR=${STAGE_DIR}
|
PREV_STAGE_DIR=${STAGE_DIR}
|
||||||
|
@ -128,6 +126,12 @@ if [ -z "${IMG_NAME}" ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
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 IMG_DATE=${IMG_DATE:-"$(date -u +%Y-%m-%d)"}
|
||||||
|
|
||||||
export BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
export BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
@ -166,7 +170,12 @@ mkdir -p ${WORK_DIR}
|
||||||
log "Begin ${BASE_DIR}"
|
log "Begin ${BASE_DIR}"
|
||||||
|
|
||||||
for STAGE_DIR in ${BASE_DIR}/stage*; do
|
for STAGE_DIR in ${BASE_DIR}/stage*; do
|
||||||
|
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
|
run_stage
|
||||||
|
else
|
||||||
|
echo "Skipping ${STAGE_DIR}"
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
CLEAN=1
|
CLEAN=1
|
||||||
|
|
Loading…
Reference in a new issue