From 19ab706dac37932341aa743c982dd4cca9df4636 Mon Sep 17 00:00:00 2001 From: Lucio Andrés Illanes Albornoz (arab, vxp) Date: Dec 10 2017 18:40:13 +0000 Subject: etc/build.usage, subr/build_args.subr: adds -C build[,dest[,src]] (clean subdirs) and -p (create package tarballs). subr/pkg_clean.subr: given -C, clean build, dest, and/or src. subr/pkg_install.subr: given -p, create gzip(1)-compressed package tarball at ${PKG_BASE_DIR}/${PKG_NAME}.tgz. vars/env.vars:${DEFAULT_BUILD_STEPS}: adds `clean' post-install. --- diff --git a/etc/build.usage b/etc/build.usage index 3267d2a..97aeb23 100644 --- a/etc/build.usage +++ b/etc/build.usage @@ -1,13 +1,17 @@ -usage: ./build.sh [-4|6] [-a nt32|nt64] [-b debug|release] - [-c] [-h] [-N] [-P [jobs]] [-r ALL[:step,..]] - [-r name[,..][:step,..]] [-R] [-t[.gz|.bz2|.xz] - [-v[v[v]]] [-x] [[ ..]] +usage: ./build.sh [-4|6] [-a nt32|nt64] [-b debug|release] + [-c] [-C dir[,..]] [-h] [-N] [-P [jobs]] + [-r ALL[:step,..]] [-r name[,..][:step,..]] + [-R] [-t[.gz|.bz2|.xz] [-v[v[v]]] [-x] [[ ..]] -4|-6 Force IPv[46] when downloading files. -a nt32|nt64 Selects 32-bit or 64-bit architecture; defaults to nt64. -b debug|release Selects debug or release build; defaults to debug. -c Clean ${PREFIX} before processing build scripts. + -C dir[,..] Clean build directory (build,) source directory (src,) and/or + destination directory (dest) after successful package builds; + excludes -t, but may be passed alongside -p. -h Show this screen. -N Offline mode: no {wget,git-{clone,pull}}(1) calls. + -p Create package tarballs; excludes -t. -P [jobs] Enables parallelisation at target-level, whenever applicable. The maximum count of jobs defaults to the number of logical processors on the host system. diff --git a/subr/build_args.subr b/subr/build_args.subr index 8bf668a..3487504 100644 --- a/subr/build_args.subr +++ b/subr/build_args.subr @@ -8,8 +8,10 @@ BUILD_ARGS_SPEC=" ARCH:arg:-a: BUILD:arg:-b: ARG_CLEAN:-c: + ARG_CLEAN_BUILDS:arg:-C: ARG_DEBUG_MINIPIX:--debug-minipix: ARG_OFFLINE:-N: + ARG_PACKAGE:-p: ARG_PARALLEL:optarg:-P:auto ARG_RELAXED:-R: ARG_RESTART:arg:-r: @@ -57,7 +59,14 @@ build_args() { shift; fi; done; - if [ -n "${ARG_TARBALL}" ]; then + if [ -n "${ARG_CLEAN_BUILDS}" ]; then + ARG_CLEAN_BUILDS="$(echo "${ARG_CLEAN_BUILDS}" | sed "s/,/ /g")"; + fi; + if [ -n "${ARG_CLEAN_BUILDS}" ]\ + || [ "${ARG_PACKAGE:-0}" -eq 1 ]\ + && [ -n "${ARG_TARBALL}" ]; then + unset ARG_TARBALL; + elif [ -n "${ARG_TARBALL}" ]; then if [ "${ARG_TARBALL#-t.}" != "${ARG_TARBALL}" ]; then TARBALL_SUFFIX="${ARG_TARBALL#-t.}"; else @@ -78,7 +87,7 @@ build_args() { else ARG_RESTART_AT=ALL; fi; - ARG_RESTART="$(echo ${ARG_RESTART} | sed "s/,/ /g")"; + ARG_RESTART="$(echo "${ARG_RESTART}" | sed "s/,/ /g")"; fi; while [ ${#} -gt 0 ]; do case "${1}" in diff --git a/subr/pkg_clean.subr b/subr/pkg_clean.subr new file mode 100644 index 0000000..d18adc1 --- /dev/null +++ b/subr/pkg_clean.subr @@ -0,0 +1,17 @@ +# +# set -o errexit -o noglob are assumed. +# + +pkg_clean() { + local _dir; + for _dir in ${ARG_CLEAN_BUILDS}; do + case "${_dir}" in + build) ex_rtl_fileop rm "${PKG_BUILD_DIR}"; ;; + src) ex_rtl_fileop rm "${PKG_SUBDIR}"; ;; + dest) ex_rtl_fileop rm "${PKG_DESTDIR}"; ;; + *) return 1; ;; + esac; + done; +}; + +# vim:filetype=sh diff --git a/subr/pkg_install.subr b/subr/pkg_install.subr index 84eda48..81c67d2 100644 --- a/subr/pkg_install.subr +++ b/subr/pkg_install.subr @@ -4,8 +4,12 @@ pkg_install() { ex_rtl_fileop mkdir "${PKG_PREFIX}"; - tar -C "${PKG_DESTDIR}" -cpf - . |\ + tar -C "${PKG_DESTDIR}" -cpf - . |\ tar -C "${PKG_PREFIX}" --overwrite -xpf -; + if [ "${ARG_PACKAGE:-0}" -eq 1 ]; then + tar -C "${PKG_DESTDIR}" -cpf - . |\ + gzip -c -9 - > "${PKG_BASE_DIR}/${PKG_NAME}.tgz" + fi; }; # vim:filetype=sh diff --git a/vars/env.vars b/vars/env.vars index 265931c..dd2dca0 100644 --- a/vars/env.vars +++ b/vars/env.vars @@ -3,7 +3,7 @@ DEFAULT_BUILD_STEPS=" configure_patch_pre configure_autotools configure_patch configure \ build \ install_subdirs install_make install_files install_libs \ - install_pkgconfig install_purge_la install_strip install"; + install_pkgconfig install_purge_la install_strip install clean"; DEFAULT_BUILD_VARS=" AR BASE_DIR BUILD_DIR BUILD_STEPS_DISABLE BUILD_TYPE CC \ CFLAGS_BUILD_EXTRA CFLAGS_CONFIGURE CFLAGS_CONFIGURE_EXTRA \