From bc7491121757ab553ff8c953e2ac24a070972bb3 Mon Sep 17 00:00:00 2001 From: Pieter Lexis Date: Tue, 24 Sep 2019 22:40:38 +0200 Subject: [PATCH 1/6] Categorize and sort options --- build.sh | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/build.sh b/build.sh index 129d74f..b3e53ba 100755 --- a/build.sh +++ b/build.sh @@ -66,20 +66,24 @@ usage() { echo "USAGE: $0 " echo echo "Options:" + echo " -q - Be more quiet. Build error details are still printed on build error." + echo " -v - Always show full docker build output (default: only steps and build error details)" + echo " -S - Force running of install tests, even if this is not a full build" + echo " -s - Skip install tests" + echo "" + echo " docker build options:" echo " -B ARG=VAL - Add extra build arguments, can be passed more than once" + echo " -b VALUE - Docker cache buster, set to 'always', 'daily', 'weekly' or a literal value." echo " -C - Run docker build with --no-cache" + echo " -P - Run docker build with --pull" + echo "" + echo " Package options:" echo " -c - Enable builder package cache" - echo " -V VERSION - Override version (default: run gen-version)" - echo " -R RELEASE - Override release tag (default: '1pdns', do not include %{dist} here)" - echo " -m MODULES - Build only specific components (comma separated; warning: this disables install tests)" echo " -e EPOCH - Set a specific Epoch for packages" - echo " -P - Run docker build with --pull" + echo " -m MODULES - Build only specific components (comma separated; warning: this disables install tests)" echo " -p PACKAGENAME - Build only spec files that have this string in their name (warning: this disables install tests)" - echo " -s - Skip install tests" - echo " -S - Force running of install tests, even if this is not a full build" - echo " -v - Always show full docker build output (default: only steps and build error details)" - echo " -q - Be more quiet. Build error details are still printed on build error." - echo " -b VALUE - Docker cache buster, set to 'always', 'daily', 'weekly' or a literal value." + echo " -R RELEASE - Override release tag (default: '1pdns', do not include %{dist} here)" + echo " -V VERSION - Override version (default: run gen-version)" echo echo "Targets: $targets" echo From 133615b7f508079c553f54eb485598de6b033f1a Mon Sep 17 00:00:00 2001 From: Pieter Lexis Date: Tue, 24 Sep 2019 22:41:31 +0200 Subject: [PATCH 2/6] Add to usage --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index b3e53ba..e9ddfd4 100755 --- a/build.sh +++ b/build.sh @@ -63,7 +63,7 @@ usage() { targets=$(ls $BUILDER_SUPPORT_ROOT/dockerfiles/Dockerfile.target.* | sed 's/.*Dockerfile.target.//' | tr '\n' ' ') echo "Builds packages in Docker for a target distribution, or sdist for generic source packages." echo - echo "USAGE: $0 " + echo "USAGE: $0 [options] " echo echo "Options:" echo " -q - Be more quiet. Build error details are still printed on build error." From 9bec23d322067bf611ece9d33dc736c690567f51 Mon Sep 17 00:00:00 2001 From: Pieter Lexis Date: Tue, 24 Sep 2019 22:51:16 +0200 Subject: [PATCH 3/6] Use $BUILDER_VERSION when tagging images Instead of 'latest' --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index e9ddfd4..0798627 100755 --- a/build.sh +++ b/build.sh @@ -239,7 +239,7 @@ cd - > /dev/null # iprefix="builder-${repo_safe_name}-${target}" -image="$iprefix:latest" # TODO: maybe use version instead of latest? +image="$iprefix:${BUILDER_VERSION}" echo -e "${color_white}Building docker image: ${image}${color_reset}" buildcmd=(docker build --build-arg BUILDER_VERSION="$BUILDER_VERSION" From 618315af3f55c17fae1d7a8f2aa5caffcad2bf1a Mon Sep 17 00:00:00 2001 From: Pieter Lexis Date: Tue, 24 Sep 2019 22:58:50 +0200 Subject: [PATCH 4/6] Allow the use of custom tags --- build.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index 0798627..edc322b 100755 --- a/build.sh +++ b/build.sh @@ -70,6 +70,7 @@ usage() { echo " -v - Always show full docker build output (default: only steps and build error details)" echo " -S - Force running of install tests, even if this is not a full build" echo " -s - Skip install tests" + echo " -t TAG - Use TAG instead of builder-\$REPO_NAME-\$TARGET:\$VERSION. Without ':' in TAG, tag as TAG:\$VERSION" echo "" echo " docker build options:" echo " -B ARG=VAL - Add extra build arguments, can be passed more than once" @@ -117,7 +118,7 @@ BUILDER_MODULES='' package_match="" cache_buster="" -while getopts ":CcV:R:svqm:Pp:b:e:B:" opt; do +while getopts ":CcV:R:svqm:Pp:b:e:B:t:" opt; do case $opt in C) dockeropts+=('--no-cache') ;; @@ -155,6 +156,8 @@ while getopts ":CcV:R:svqm:Pp:b:e:B:" opt; do export skiptests=1 echo -e "${color_red}WARNING: Skipping install tests, because not all packages are being built${color_reset}" ;; + t) iprefix="$OPTARG" + ;; b) cache_buster="$OPTARG" ;; B) buildargs+=("--build-arg ${OPTARG}") @@ -238,8 +241,12 @@ cd - > /dev/null # Build docker images with artifacts inside # -iprefix="builder-${repo_safe_name}-${target}" +iprefix="${iprefix:-builder-${repo_safe_name}-${target}}" image="$iprefix:${BUILDER_VERSION}" +if [[ "$iprefix" =~ ":" ]]; then + image="$iprefix" +fi + echo -e "${color_white}Building docker image: ${image}${color_reset}" buildcmd=(docker build --build-arg BUILDER_VERSION="$BUILDER_VERSION" From f42a6a7f4af76c3c6d2fb463f580be7d43955b5b Mon Sep 17 00:00:00 2001 From: Pieter Lexis Date: Tue, 24 Sep 2019 23:03:47 +0200 Subject: [PATCH 5/6] getopts: sort options --- build.sh | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/build.sh b/build.sh index edc322b..c84ed73 100755 --- a/build.sh +++ b/build.sh @@ -118,28 +118,18 @@ BUILDER_MODULES='' package_match="" cache_buster="" -while getopts ":CcV:R:svqm:Pp:b:e:B:t:" opt; do +while getopts ":B:b:Cce:m:Pp:qR:Sst:V:v" opt; do case $opt in - C) dockeropts+=('--no-cache') + B) buildargs+=("--build-arg ${OPTARG}") ;; - c) export BUILDER_CACHE=1 + b) cache_buster="$OPTARG" ;; - V) _version="$OPTARG" + C) dockeropts+=('--no-cache') ;; - R) export BUILDER_RELEASE="$OPTARG" + c) export BUILDER_CACHE=1 ;; e) export BUILDER_EPOCH="$OPTARG" ;; - s) export skiptests=1 - echo "NOTE: Skipping install tests, as requested with -s" - ;; - S) export forcetests=1 - ;; - v) verbose=1 - ;; - q) quiet=1 - dockeroutdev=/dev/null - ;; m) export M_all= export skiptests=1 echo -e "${color_red}WARNING: Skipping install tests, because not all components are being built${color_reset}" @@ -156,11 +146,21 @@ while getopts ":CcV:R:svqm:Pp:b:e:B:t:" opt; do export skiptests=1 echo -e "${color_red}WARNING: Skipping install tests, because not all packages are being built${color_reset}" ;; + q) quiet=1 + dockeroutdev=/dev/null + ;; + R) export BUILDER_RELEASE="$OPTARG" + ;; + S) export forcetests=1 + ;; + s) export skiptests=1 + echo "NOTE: Skipping install tests, as requested with -s" + ;; t) iprefix="$OPTARG" ;; - b) cache_buster="$OPTARG" + V) _version="$OPTARG" ;; - B) buildargs+=("--build-arg ${OPTARG}") + v) verbose=1 ;; \?) echo "Invalid option: -$OPTARG" >&2 usage From caa5bc0a78c945dbece0052487308a7fe258fd53 Mon Sep 17 00:00:00 2001 From: Pieter Lexis Date: Wed, 25 Sep 2019 09:52:50 +0200 Subject: [PATCH 6/6] Switch back to latest for tag, add option --- build.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/build.sh b/build.sh index c84ed73..c20a125 100755 --- a/build.sh +++ b/build.sh @@ -70,7 +70,8 @@ usage() { echo " -v - Always show full docker build output (default: only steps and build error details)" echo " -S - Force running of install tests, even if this is not a full build" echo " -s - Skip install tests" - echo " -t TAG - Use TAG instead of builder-\$REPO_NAME-\$TARGET:\$VERSION. Without ':' in TAG, tag as TAG:\$VERSION" + echo " -t TAG - Use TAG instead of 'builder-\$REPO_NAME-\$TARGET' for the tagged image." + echo " -T TAG_VERSION - Use TAG_VERSION as the version of the image. 'latest' by default. set to 'version' to use the value from -V" echo "" echo " docker build options:" echo " -B ARG=VAL - Add extra build arguments, can be passed more than once" @@ -117,8 +118,9 @@ BUILDER_MODULES='' package_match="" cache_buster="" +iversion="latest" -while getopts ":B:b:Cce:m:Pp:qR:Sst:V:v" opt; do +while getopts ":B:b:Cce:m:Pp:qR:SsT:t:V:v" opt; do case $opt in B) buildargs+=("--build-arg ${OPTARG}") ;; @@ -156,6 +158,8 @@ while getopts ":B:b:Cce:m:Pp:qR:Sst:V:v" opt; do s) export skiptests=1 echo "NOTE: Skipping install tests, as requested with -s" ;; + T) iversion="$OPTARG" + ;; t) iprefix="$OPTARG" ;; V) _version="$OPTARG" @@ -242,9 +246,9 @@ cd - > /dev/null # iprefix="${iprefix:-builder-${repo_safe_name}-${target}}" -image="$iprefix:${BUILDER_VERSION}" -if [[ "$iprefix" =~ ":" ]]; then - image="$iprefix" +image="$iprefix:$iversion" +if [ "$iversion" = "version" ]; then + image="$iprefix:${BUILDER_VERSION}" fi echo -e "${color_white}Building docker image: ${image}${color_reset}"