From 480bd92a682ce0ff3d8057be939c052caab01cc9 Mon Sep 17 00:00:00 2001 From: Malte Janduda Date: Sat, 17 Jun 2023 14:52:53 +0200 Subject: [PATCH 1/2] using default values. get_repo, get_timestamp, get_commit, get_version files become optional --- build | 12 ++++++++---- builder/Makefile | 18 +++++++++++------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/build b/build index 0803c59..3531b45 100755 --- a/build +++ b/build @@ -63,10 +63,14 @@ if [ "$container_image" = localhost/builder ]; then "$container_engine" build -t "$container_image" "$dir" fi -repo="$(./get_repo)" -commit="$(./get_commit)" -timestamp="$(./get_timestamp)" -default_version="$(./get_version)" +repo="" +commit="" +timestamp="" +default_version="" +[ -e get_repo ] && repo="$(./get_repo)" +[ -e get_commit ] && commit="$(./get_commit)" +[ -e get_timestamp ] && timestamp="$(./get_timestamp)" +[ -e get_version ] && default_version="$(./get_version)" [ -d $target_dir ] || mkdir $target_dir diff --git a/builder/Makefile b/builder/Makefile index e921759..1fea85f 100644 --- a/builder/Makefile +++ b/builder/Makefile @@ -15,14 +15,18 @@ prelastword = $(word $(words $1),_ $1) cname_version = $(call lastword,$(subst -, ,$1)) cname_arch = $(call prelastword,$(subst -, ,$1)) -define require_var = -ifndef $1 -$$(error '$1 undefined') +ifeq ($(REPO),) + override REPO := http://deb.debian.org/debian +endif +ifeq ($(COMMIT),) + override COMMIT := $(shell [ -z "$$(git status --porcelain 2> /dev/null)" ] && git rev-parse HEAD 2> /dev/null || echo local) +endif +ifeq ($(TIMESTAMP),) + override TIMESTAMP := 0 +endif +ifeq ($(DEFAULT_VERSION),) + override DEFAULT_VERSION := bookworm endif -endef - -required_vars := REPO COMMIT TIMESTAMP DEFAULT_VERSION -$(foreach var,$(required_vars),$(eval $(call require_var,$(var)))) SHORT_COMMIT := $(shell head -c 8 <<< '$(COMMIT)') From 329530531c9d98e32b90ae3deb2d30cd4a0a0d07 Mon Sep 17 00:00:00 2001 From: Malte Janduda Date: Mon, 19 Jun 2023 08:05:13 +0000 Subject: [PATCH 2/2] adding default values to build --- build | 24 ++++++++++++++++-------- builder/Makefile | 18 +++++++----------- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/build b/build index 3531b45..2e9cb70 100755 --- a/build +++ b/build @@ -63,14 +63,22 @@ if [ "$container_image" = localhost/builder ]; then "$container_engine" build -t "$container_image" "$dir" fi -repo="" -commit="" -timestamp="" -default_version="" -[ -e get_repo ] && repo="$(./get_repo)" -[ -e get_commit ] && commit="$(./get_commit)" -[ -e get_timestamp ] && timestamp="$(./get_timestamp)" -[ -e get_version ] && default_version="$(./get_version)" +[ -e get_repo ] && repo="$(./get_repo)" || repo="http://deb.debian.org/debian" +if [ -e get_commit ] +then + commit="$(./get_commit)" +else + pushd $(dirname "${BASH_SOURCE[0]}") + if [ -z "$(git status --porcelain 2> /dev/null)" ] + then + commit=$(git rev-parse HEAD 2> /dev/null) + else + commit="local" + fi + popd +fi +[ -e get_timestamp ] && timestamp="$(./get_timestamp)" || timestamp="0" +[ -e get_version ] && default_version="$(./get_version)" || default_version="bookworm" [ -d $target_dir ] || mkdir $target_dir diff --git a/builder/Makefile b/builder/Makefile index 1fea85f..e921759 100644 --- a/builder/Makefile +++ b/builder/Makefile @@ -15,18 +15,14 @@ prelastword = $(word $(words $1),_ $1) cname_version = $(call lastword,$(subst -, ,$1)) cname_arch = $(call prelastword,$(subst -, ,$1)) -ifeq ($(REPO),) - override REPO := http://deb.debian.org/debian -endif -ifeq ($(COMMIT),) - override COMMIT := $(shell [ -z "$$(git status --porcelain 2> /dev/null)" ] && git rev-parse HEAD 2> /dev/null || echo local) -endif -ifeq ($(TIMESTAMP),) - override TIMESTAMP := 0 -endif -ifeq ($(DEFAULT_VERSION),) - override DEFAULT_VERSION := bookworm +define require_var = +ifndef $1 +$$(error '$1 undefined') endif +endef + +required_vars := REPO COMMIT TIMESTAMP DEFAULT_VERSION +$(foreach var,$(required_vars),$(eval $(call require_var,$(var)))) SHORT_COMMIT := $(shell head -c 8 <<< '$(COMMIT)')