From 5d0da8bd98bdaa38880c9ceded785e028e1cd83f Mon Sep 17 00:00:00 2001 From: Richard Mortier Date: Fri, 26 Apr 2019 19:43:02 +0100 Subject: abuild: rename to avoid clash on alpine systems --- Makefile | 6 +++--- README.md | 10 +++++----- abuild.in | 60 ------------------------------------------------------------ dabuild.in | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 68 insertions(+), 68 deletions(-) delete mode 100755 abuild.in create mode 100755 dabuild.in diff --git a/Makefile b/Makefile index d77ed51..b2cf4c4 100644 --- a/Makefile +++ b/Makefile @@ -15,8 +15,8 @@ TAGS = 2.6 2.7 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 edge .PHONY: build build: $(patsubst %, build-%, $(TAGS)) - sed 's!%%ABUILD_VOLUMES%%!$(VOLS)!;s!%%ABUILD_IMAGE%%!$(IMG)!' abuild.in >| abuild - chmod +x abuild + sed 's!%%ABUILD_VOLUMES%%!$(VOLS)!;s!%%ABUILD_IMAGE%%!$(IMG)!' dabuild.in >| dabuild + chmod +x dabuild .PHONY: build-% build-%: @@ -32,7 +32,7 @@ push: .PHONY: clean clean: docker rmi -f $$(docker images -q $(IMG)) || true - $(RM) Dockerfile abuild + $(RM) Dockerfile dabuild .PHONY: distclean distclean: clean diff --git a/README.md b/README.md index 5170ec8..c1bb50d 100644 --- a/README.md +++ b/README.md @@ -4,24 +4,24 @@ A Docker-ised `abuild` for invocation from within an `aports/` tree. Attempts to ## Configuration -The `abuild` script is generated from `abuild.in` on `make build`. This ensures synchronisation of volume names. By default, the `abuild` script then uses the Docker image `mor1/abuild`; set the `IMG` variable in the `Makefile` and `make build` to use a different image. +The `dabuild` script is generated from `dabuild.in` on `make build`. This ensures synchronisation of volume names. By default, the `dabuild` script then uses the Docker image `mor1/abuild`. To use a different image, set the `IMG` variable in the `Makefile` and then `make build`. -On invocation from within an `aports/` tree, the script will determine the root of the tree (`.../aports/`) and bind mount it into the container at `/home/builder/aports`. It also bind mounts `$HOME/.abuild` for configuration. +On invocation from within an `aports/` tree, the script will determine the root of the tree (`.../aports/`) and bind mount it into the container at `/home/builder/aports`. It also bind mounts `$HOME/.abuild` for configuration and `.../aports/../packages` for `abuild` output packages. ## Building without fetching -Per normal usage, if you use the `-K` switch, then the build, source, etc directories will be left alone on completion. If you then invoke as `abuild build`, then the source will not be re-fetched -- useful when you wish to edit the source to debug a package build. +Per normal usage, if you use the `-K` switch, then the build, source, etc directories will be left alone on completion. If you then invoke as `dabuild build`, then the source will not be re-fetched -- useful when you wish to edit the source to debug a package build. ## Caching The script attempts to support caching via named volumes. To turn on caching, invoke as ``` shell -DOCKER_ABUILD_CACHE=true abuild [options] +DABUILD_CACHE=true abuild [options] ``` To clean the cache before continuing, invoke as ``` shell -DOCKER_ABUILD_CACHE=true DOCKER_ABUILD_CLEAN=true abuild [options] +DABUILD_CACHE=true DABUILD_CLEAN=true abuild [options] ``` diff --git a/abuild.in b/abuild.in deleted file mode 100755 index 49defe8..0000000 --- a/abuild.in +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/sh - -# Copyright (C) 2019 Richard Mortier -# Licensed under the MIT License, https://opensource.org/licenses/MIT - -set -e - -## debug -if [ "$DOCKER_ABUILD_DEBUG" = "true" ]; then - set -x - PS4='$LINENO: ' -fi - -## check running from within an `aports` tree -if [ "${PWD%*/aports*}" = "$PWD" ]; then - echo "Error: expecting to be run from within an aports tree!" - echo "Could not find '/aports' in the current path ($PWD)" - exit 1 -fi - -## use branch to figure out most appropriate alpine version -if [ "$DOCKER_ABUILD_VERSION" ]; then - ABUILD_VERSION=$DOCKER_ABUILD_VERSION -else - APORTS_BRANCH=$(git status | head -1) - APORTS_BRANCH="${APORTS_BRANCH##*[ /]}" - case $APORTS_BRANCH in - [[:digit:]].[[:digit:]]-stable ) - ABUILD_VERSION=${APORTS_BRANCH%-stable} - ;; - - * ) - ABUILD_VERSION=edge - ;; - esac -fi - -## setup volumes; use named volumes as cache if desired -ABUILD_VOLUMES=" - -v ${HOME}/.abuild:/home/builder/.abuild - -v ${PWD%/aports*}/aports:/home/builder/aports - -v ${PWD%/aports*}/packages:/home/builder/packages -" -if [ "$DOCKER_ABUILD_CACHE" = "true" ]; then - for v in %%ABUILD_VOLUMES%% ; do - vol=abuild-$ABUILD_VERSION-${v//\//_} - if [ "$DOCKER_ABUILD_CLEAN" = "true" ]; then - ## clean the cache if requested - docker rm -f $(docker ps -qaf "volume=$vol") >/dev/null 2>/dev/null || true - docker volume rm $vol >/dev/null - docker volume create $vol >/dev/null - fi - ABUILD_VOLUMES="$ABUILD_VOLUMES -v $vol:/$v" - done -fi - -## go! -ABUILD_WORKDIR=/home/builder/aports${PWD#*/aports} -DOCKER="docker run -ti $ABUILD_VOLUMES -e DOCKER_ABUILD_DEBUG $DOCKER_ABUILD_ARGS" -$DOCKER --workdir $ABUILD_WORKDIR %%ABUILD_IMAGE%%:$ABUILD_VERSION "$@" diff --git a/dabuild.in b/dabuild.in new file mode 100755 index 0000000..91b2c50 --- /dev/null +++ b/dabuild.in @@ -0,0 +1,60 @@ +#!/bin/sh + +# Copyright (C) 2019 Richard Mortier +# Licensed under the MIT License, https://opensource.org/licenses/MIT + +set -e + +## debug +if [ "$DABUILD_DEBUG" = "true" ]; then + set -x + PS4='$LINENO: ' +fi + +## check running from within an `aports` tree +if [ "${PWD%*/aports*}" = "$PWD" ]; then + echo "Error: expecting to be run from within an aports tree!" + echo "Could not find '/aports' in the current path ($PWD)" + exit 1 +fi + +## use branch to figure out most appropriate alpine version +if [ "$DABUILD_VERSION" ]; then + ABUILD_VERSION=$DABUILD_VERSION +else + APORTS_BRANCH=$(git status | head -1) + APORTS_BRANCH="${APORTS_BRANCH##*[ /]}" + case $APORTS_BRANCH in + [[:digit:]].[[:digit:]]-stable ) + ABUILD_VERSION=${APORTS_BRANCH%-stable} + ;; + + * ) + ABUILD_VERSION=edge + ;; + esac +fi + +## setup volumes; use named volumes as cache if desired +ABUILD_VOLUMES=" + -v ${HOME}/.abuild:/home/builder/.abuild + -v ${PWD%/aports*}/aports:/home/builder/aports + -v ${PWD%/aports*}/packages:/home/builder/packages +" +if [ "$DABUILD_CACHE" = "true" ]; then + for v in %%ABUILD_VOLUMES%% ; do + vol=abuild-$ABUILD_VERSION-${v//\//_} + if [ "$DABUILD_CLEAN" = "true" ]; then + ## clean the cache if requested + docker rm -f $(docker ps -qaf "volume=$vol") >/dev/null 2>/dev/null || true + docker volume rm $vol >/dev/null + docker volume create $vol >/dev/null + fi + ABUILD_VOLUMES="$ABUILD_VOLUMES -v $vol:/$v" + done +fi + +## go! +ABUILD_WORKDIR=/home/builder/aports${PWD#*/aports} +DOCKER="docker run -ti $ABUILD_VOLUMES -e DABUILD_DEBUG $DABUILD_ARGS" +$DOCKER --workdir $ABUILD_WORKDIR %%ABUILD_IMAGE%%:$ABUILD_VERSION "$@" -- cgit v1.2.3