From 0dcb4ddd2e1dd53ce03a3216c71b17554732e6ab Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 12 Nov 2013 15:30:56 +0100 Subject: ship build: #@include a file only once --- ship/build | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 2 deletions(-) (limited to 'ship') diff --git a/ship/build b/ship/build index 7755253d..62be4e8f 100755 --- a/ship/build +++ b/ship/build @@ -20,14 +20,24 @@ build() { esac } +### +### macros +### + ## usage: #@include \([0-9A-Za-z]\+\) -> build_include \1 \2 -build_include() { cat< build_info \1 @@ -39,6 +49,10 @@ $1a\\ EOF } +### +### main subroutines +### + ## usage: build_compile SRCFILE DSTFILE build_compile() { @@ -57,12 +71,16 @@ t;s:^ *\\([0-9]\\+\\) .*:echo \\1p: SRCFILE="$1" setf src '$(cat "$%s")' SRCFILE + buildcache_initialize "$2" + while echo "$src" | grep -q "$unexpanded_macros_pattern"; do setf sedgen '$(echo "$%s" | nl -b a -s \ | sed "$%s")' src input_parser setf sedscript '$(eval "$%s")' sedgen setf src '$(echo "$%s" | sed -n "$%s")' src sedscript done + buildcache_finalize + echo "$src" > "$2" chmod +x "$2" } @@ -85,6 +103,10 @@ build_deps() { done | sort | uniq } +### +### misc utilities +### + ## usage: build_resolve LIBNAME build_resolve() { echo "$BUILD_PATH" | tr : \\n | @@ -121,5 +143,37 @@ setf() { fi >&2 } -## main +### +### buildcache utilities +### + +## usage: buildcache_initialize DESTFILE +buildcache_initialize() { + buildcache="$1.buildcache" + cat /dev/null > "$buildcache" +} + +## usage: buildcache_finalize +buildcache_finalize() { + if test "${debug-false}" != true; then + rm "$buildcache" + fi +} + +## usage: buildcache_has BRE +# Check if buildcache contains a line matching BRE. +buildcache_has() { + grep -q "^$1" "$buildcache" +} + +## usage: buildcache_add LINE +# Add LINE to buildcache. +buildcache_add() { + echo "$1" >> "$buildcache" +} + +### +### main invocation +### + build "$@" -- cgit v1.2.3 From a6012ff33c05593f4c73b7de55ce09915b6327f9 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 12 Nov 2013 15:33:15 +0100 Subject: ship build: add is_debug_mode --- ship/build | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'ship') diff --git a/ship/build b/ship/build index 62be4e8f..5dc55801 100755 --- a/ship/build +++ b/ship/build @@ -137,12 +137,17 @@ setf() { eval "$1=$value_script" - if test "${debug-false}" = true; then + if is_debug_mode; then eval 'echo "$1=\"$value_script\""' eval 'echo "'"\$$1"'"' | nl -b a fi >&2 } +## usage: is_debug_mode +is_debug_mode() { + test "${debug-false}" = true +} + ### ### buildcache utilities ### @@ -155,7 +160,7 @@ buildcache_initialize() { ## usage: buildcache_finalize buildcache_finalize() { - if test "${debug-false}" != true; then + if is_debug_mode; then rm "$buildcache" fi } -- cgit v1.2.3 From 5af5558ea3d0499a2c17da6358cc6beca9a7c01b Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 12 Nov 2013 15:40:06 +0100 Subject: ship buildcache: check whole line, not just prefix --- ship/build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ship') diff --git a/ship/build b/ship/build index 5dc55801..61d79ee4 100755 --- a/ship/build +++ b/ship/build @@ -168,7 +168,7 @@ buildcache_finalize() { ## usage: buildcache_has BRE # Check if buildcache contains a line matching BRE. buildcache_has() { - grep -q "^$1" "$buildcache" + grep -q "^$1\$" "$buildcache" } ## usage: buildcache_add LINE -- cgit v1.2.3 From 0be9d62c78c27ea73691cb0a58779c319d5f9355 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 12 Nov 2013 15:45:37 +0100 Subject: ship: split _punani_db off lib/punani --- ship/build | 2 +- ship/lib/_punani_db | 40 ++++++++++++++++++++++++++++++++++++++++ ship/lib/punani | 45 +-------------------------------------------- 3 files changed, 42 insertions(+), 45 deletions(-) create mode 100644 ship/lib/_punani_db (limited to 'ship') diff --git a/ship/build b/ship/build index 61d79ee4..bd26482d 100755 --- a/ship/build +++ b/ship/build @@ -24,7 +24,7 @@ build() { ### macros ### -## usage: #@include \([0-9A-Za-z]\+\) -> build_include \1 \2 +## usage: #@include \([0-9A-Za-z_]\+\) -> build_include \1 \2 build_include() { if buildcache_has "#@include:$2"; then printf '%da\\\n##include %s: already done\n' $1 $2 diff --git a/ship/lib/_punani_db b/ship/lib/_punani_db new file mode 100644 index 00000000..9812aff7 --- /dev/null +++ b/ship/lib/_punani_db @@ -0,0 +1,40 @@ +_punanidb_pacman_= +_punanidb_yum_= +_punanidb_aptget_= + +_punanidb_pacman_git=git +_punanidb_yum_git=git +_punanidb_aptget_git=git-core + +_punanidb_pacman_python2=python2 +_punanidb_yum_python2=python +_punanidb_aptget_python2=python + +_punanidb_pacman_python3=python +_punanidb_aptget_python3=python3 + +_punanidb_pacman_hostname=inetutils +_punanidb_aptget_hostname=hostname + +_punanidb_pacman_hostname=inetutils +_punanidb_aptget_hostname=hostname + +_punanidb_pacman_make=make +_punanidb_yum_make=make +_punanidb_aptget_make=make + +_punanidb_pacman_tinc=tinc +_punanidb_yum_tinc=tinc +_punanidb_aptget_tinc=tinc + +_punanidb_pacman_tor=tor +_punanidb_yum_tor=tor +_punanidb_aptget_tor=tor + +_punanidb_pacman_nano=nano +_punanidb_yum_nano=nano +_punanidb_aptget_nano=nano + +_punanidb_pacman_vim=vim +_punanidb_yum_vim=vim-enhanced +_punanidb_aptget_vim=vim diff --git a/ship/lib/punani b/ship/lib/punani index c4f7f013..c07763a4 100644 --- a/ship/lib/punani +++ b/ship/lib/punani @@ -1,48 +1,5 @@ #@include core - -## begin punani DB -_punanidb_pacman_= -_punanidb_yum_= -_punanidb_aptget_= - -_punanidb_pacman_git=git -_punanidb_yum_git=git -_punanidb_aptget_git=git-core - -_punanidb_pacman_python2=python2 -_punanidb_yum_python2=python -_punanidb_aptget_python2=python - -_punanidb_pacman_python3=python -_punanidb_aptget_python3=python3 - -_punanidb_pacman_hostname=inetutils -_punanidb_aptget_hostname=hostname - -_punanidb_pacman_hostname=inetutils -_punanidb_aptget_hostname=hostname - -_punanidb_pacman_make=make -_punanidb_yum_make=make -_punanidb_aptget_make=make - -_punanidb_pacman_tinc=tinc -_punanidb_yum_tinc=tinc -_punanidb_aptget_tinc=tinc - -_punanidb_pacman_tor=tor -_punanidb_yum_tor=tor -_punanidb_aptget_tor=tor - -_punanidb_pacman_nano=nano -_punanidb_yum_nano=nano -_punanidb_aptget_nano=nano - -_punanidb_pacman_vim=vim -_punanidb_yum_vim=vim-enhanced -_punanidb_aptget_vim=vim - -## end punani DB +#@include _punani_db _punani_resolve_package(){ : ${PACKER?PACKER is not set,bailing out} -- cgit v1.2.3