summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLucio Andrés Illanes Albornoz <lucio@lucioillanes.de>2021-08-25 18:16:46 +0200
committerLucio Andrés Illanes Albornoz <lucio@lucioillanes.de>2021-08-25 18:16:46 +0200
commit30cdf7382b1816ee6544a9527d426f2e09008dc0 (patch)
treecb1fb0d32c48fbd82aa832cefb568cb43a01ca82
parent1c1a6d41c1ef151cb1f2332e19b10e50c6ef2191 (diff)
downloadmidipix_build-30cdf7382b1816ee6544a9527d426f2e09008dc0.tar.bz2
midipix_build-30cdf7382b1816ee6544a9527d426f2e09008dc0.tar.xz
Implements ./build.sh -V {notice,verbose,build,fileops,install,xtrace}.
-rwxr-xr-xbuild.sh4
-rw-r--r--dist/dist_minipix.dist4
-rw-r--r--etc/README.md19
-rw-r--r--etc/build.usage20
-rw-r--r--etc/build.usage.short13
-rw-r--r--subr/build_init.subr35
-rw-r--r--subr/pkg_install_files.subr4
7 files changed, 71 insertions, 28 deletions
diff --git a/build.sh b/build.sh
index dc9554da..950bb199 100755
--- a/build.sh
+++ b/build.sh
@@ -73,7 +73,7 @@ buildp_dispatch_pkg_state() {
step_pkg) rtl_log_msg verbose "Finished build step %s of package \`%s'." "${4}" "${_pkg_name}"; ;;
finish_pkg)
: $((BUILD_NFINI+=1));
- if [ "${ARG_VERBOSE:-0}" -ge 2 ]; then
+ if rtl_lmatch "${ARG_VERBOSE_LEVELS}" "build" ","; then
cat "${BUILD_WORKDIR}/${_pkg_name}_stderrout.log";
fi;
rtl_log_msg info_end "[%3d%%/%3d%%] [%03d/%03d] Finished \`%s' build." "${7}" "${6}" "${4}" "${5}" "${_pkg_name}"; ;;
@@ -81,7 +81,7 @@ buildp_dispatch_pkg_state() {
if [ "${PKG_NO_LOG_VARS:-0}" -eq 0 ]; then
rtl_log_env_vars "build" $(rtl_get_vars_fast "^PKG_");
fi;
- if [ "${ARG_XTRACE:-0}" -ge 1 ]; then
+ if rtl_lmatch "${ARG_VERBOSE_LEVELS}" "xtrace" ","; then
set -o xtrace;
fi; ;;
esac;
diff --git a/dist/dist_minipix.dist b/dist/dist_minipix.dist
index d34298ef..f5ea59be 100644
--- a/dist/dist_minipix.dist
+++ b/dist/dist_minipix.dist
@@ -72,7 +72,9 @@
pkg_dist_minipix_all() {
local _vflag="";
- [ "${ARG_VERBOSE:-0}" -ge 3 ] && _vflag="-v";
+ if rtl_lmatch "${ARG_VERBOSE_LEVELS}" "install" ","; then
+ _vflag="-v";
+ fi;
if rtl_lmatch "${ARG_DIST}" "minipix" "," \
&& ! rtl_install_v2 \
-p "_minipix=${PREFIX_MINIPIX##*/}" \
diff --git a/etc/README.md b/etc/README.md
index abdf2597..56a5a81f 100644
--- a/etc/README.md
+++ b/etc/README.md
@@ -494,8 +494,9 @@ env ARCH=nt64 BUILD_KIND=release PREFIX_ROOT="${HOME}/midipix_tmp" ./build.sh -D
```
usage: ./build.sh [-a nt32|nt64] [-b debug|release] [-C dir[,..]] [-D kind[,..]]
- [-F ipv4|ipv6|offline] [-h|--help] [-p jobs] [-P] [-r ALL|LAST]
- [-r [*[*[*]]]name[,..][:[^|<|<=|>|>=]step,..]] [-R] [-v[v[v]]] [-x]
+ [-F ipv4|ipv6|offline] [-h|--help] [-p jobs|-P] [-r ALL|LAST]
+ [-r [*[*[*]]]name[,..][:[^|<|<=|>|>=]step,..]]
+ [-R] [-v[v]] [-V level[,..]] [-x]
[--as-needed] [--debug-minipix] [--dump-on-abort] [--reset-state]
[--roar] [[=]<group>|<variable name>=<variable override>[ ..]]
@@ -512,8 +513,8 @@ usage: ./build.sh [-a nt32|nt64] [-b debug|release] [-C dir[,..]] [-D kind[
archives and/or Git repositories or don't download either at all
(offline.)
-h|--help Show short/full help screen, respectively.
- -p jobs Enables parallelisation at group-level, whenever applicable.
- -P The maximum count of jobs defaults to the number of logical
+ -p jobs|-P Enables parallelisation at group-level, whenever applicable.
+ The maximum count of jobs defaults to the number of logical
processors on the host system divided by two (2.)
If -R is not specified and at least one (1) package fails to
@@ -549,7 +550,15 @@ usage: ./build.sh [-a nt32|nt64] [-b debug|release] [-C dir[,..]] [-D kind[
-R Ignore build failures, skip printing package logs, and continue
building (relaxed mode.)
- -v[v[v]] Be verbose; -vv: always print package logs; -vvv: logs fileops.
+
+ -v[v] -v: log at notice, -vv: log at verbose level.
+ -V level[,..] Be verbose concerning any of:
+ notice...: log at notice level (-v,)
+ verbose..: log at verbose level (-vv,)
+ build....: always print package build logs,
+ fileops..: log RTL file operations,
+ install..: log RTL installation DSL operations,
+ xtrace...: set xtrace during package builds (-x.)
-x Set xtrace during package builds.
--as-needed Don't build unless the midipix_build repository has received
diff --git a/etc/build.usage b/etc/build.usage
index 9d0ccbf5..7440dc15 100644
--- a/etc/build.usage
+++ b/etc/build.usage
@@ -1,6 +1,8 @@
usage: ./build.sh [-a nt32|nt64] [-b debug|release] [-C dir[,..]] [-D kind[,..]]
- [-F ipv4|ipv6|offline] [-h|--help] [-p jobs] [-P] [-r ALL|LAST]
- [-r [*[*[*]]]name[,..][:[^|<|<=|>|>=]step,..]] [-R] [-v[v[v]]] [-x]
+ [-F ipv4|ipv6|offline] [-h|--help] [-p jobs|-P] [-r ALL|LAST]
+ [-r [*[*[*]]]name[,..][:[^|<|<=|>|>=]step,..]]
+ [-R] [-v[v]] [-V level[,..]] [-x]
+
[--as-needed] [--debug-minipix] [--dump-on-abort] [--reset-state]
[--roar] [[=]<group>|<variable name>=<variable override>[ ..]]
@@ -17,8 +19,8 @@ usage: ./build.sh [-a nt32|nt64] [-b debug|release] [-C dir[,..]] [-D kind[
archives and/or Git repositories or don't download either at all
(offline.)
-h|--help Show short/full help screen, respectively.
- -p jobs Enables parallelisation at group-level, whenever applicable.
- -P The maximum count of jobs defaults to the number of logical
+ -p jobs|-P Enables parallelisation at group-level, whenever applicable.
+ The maximum count of jobs defaults to the number of logical
processors on the host system divided by two (2.)
If -R is not specified and at least one (1) package fails to
@@ -54,7 +56,15 @@ usage: ./build.sh [-a nt32|nt64] [-b debug|release] [-C dir[,..]] [-D kind[
-R Ignore build failures, skip printing package logs, and continue
building (relaxed mode.)
- -v[v[v]] Be verbose; -vv: always print package logs; -vvv: logs fileops.
+
+ -v[v] -v: log at notice, -vv: log at verbose level.
+ -V level[,..] Be verbose concerning any of:
+ notice...: log at notice level (-v,)
+ verbose..: log at verbose level (-vv,)
+ build....: always print package build logs,
+ fileops..: log RTL file operations,
+ install..: log RTL installation DSL operations,
+ xtrace...: set xtrace during package builds (-x.)
-x Set xtrace during package builds.
--as-needed Don't build unless the midipix_build repository has received
diff --git a/etc/build.usage.short b/etc/build.usage.short
index 24778221..bbcc046d 100644
--- a/etc/build.usage.short
+++ b/etc/build.usage.short
@@ -1,11 +1,18 @@
usage: ./build.sh [-a nt32|nt64] [-b debug|release] [-C dir[,..]] [-D kind[,..]]
- [-F ipv4|ipv6|offline] [-h|--help] [-p jobs] [-P] [-r ALL|LAST]
- [-r [*[*[*]]]name[,..][:[^|<|<=|>|>=]step,..]] [-R] [-v[v[v]]] [-x]
+ [-F ipv4|ipv6|offline] [-h|--help] [-p jobs|-P] [-r ALL|LAST]
+ [-r [*[*[*]]]name[,..][:[^|<|<=|>|>=]step,..]]
+ [-R] [-v[v]] [-V level[,..]] [-x]
+
[--as-needed] [--debug-minipix] [--dump-on-abort] [--reset-state]
[--roar] [[=]<group>|<variable name>=<variable override>[ ..]]
+ -a nt32|nt64 Selects 32-bit or 64-bit architecture; defaults to nt64.
+ -b debug|release Selects debug or release build kind; defaults to debug.
-h|--help Show short/full help screen, respectively.
- -v[v[v]] Be verbose; -vv: always print package logs; -vvv: logs fileops.
+ -p jobs|-P Enables parallelisation at group-level, whenever applicable.
+ -r ALL|LAST Restart all/the last failed/the specified comma-separated package(s).
+ -r [*[*[*]]]name[,..][:ALL|LAST|[^|<|<=|>|>=]step,..]
+ -v[v] -v: log at notice, -vv: log at verbose level.
-x Set xtrace during package builds.
<group>[ ..] One of: dev_packages, dist, host_deps, host_deps_rpm,
diff --git a/subr/build_init.subr b/subr/build_init.subr
index 205afc0d..8933fff1 100644
--- a/subr/build_init.subr
+++ b/subr/build_init.subr
@@ -124,11 +124,13 @@ buildp_init_files() {
};
buildp_init_getopts() {
- local _arg="" _opt="" _rc=0 _shiftfl=0 OPTIND=0; _status="";
+ local _arg="" _level="" _opt="" _rc=0 _shiftfl=0 _verbose=0 OPTIND=0; _status="";
+
: ${ARCH:="nt64"}; : ${BUILD_KIND:="debug"};
ARG_AS_NEEDED=0; ARG_CLEAN_BUILDS=""; ARG_DEBUG_MINIPIX=0; ARG_DIST=""; ARG_DUMP_IN="";
ARG_DUMP_ON_ABORT=0; ARG_FETCH_FORCE=""; ARG_PARALLEL=1; ARG_RELAXED=0; ARG_RESET_PKG=0;
- ARG_RESTART=""; ARG_RESTART_AT=""; ARG_RESTART_RECURSIVE=""; ARG_VERBOSE=0; ARG_XTRACE=0;
+ ARG_RESTART=""; ARG_RESTART_AT=""; ARG_RESTART_RECURSIVE=""; ARG_VERBOSE_LEVELS="";
+
while [ "${#}" -gt 0 ]; do
case "${1}" in
--as-needed) ARG_AS_NEEDED=1; _shiftfl=1; ;;
@@ -143,7 +145,7 @@ buildp_init_getopts() {
--help) cat etc/build.usage; exit 0; ;;
--reset-state) ARG_RESET_PKG=1; _shiftfl=1; ;;
-v*) _opt="${1#-}"; while [ -n "${_opt}" ]; do
- : $((ARG_VERBOSE+=1)); _opt="${_opt#?}";
+ : $((_verbose+=1)); _opt="${_opt#?}";
done; _shiftfl=1; ;;
# {{{ --roar
--roar) printf "%s\n" '
@@ -166,7 +168,7 @@ buildp_init_getopts() {
break;
elif [ "${_shiftfl}" -gt 0 ]; then
shift "${_shiftfl}"; continue;
- elif getopts a:b:C:D:F:hp:Pr:Rx _opt; then
+ elif getopts a:b:C:D:F:hp:Pr:RxV: _opt; then
case "${_opt}" in
a) ARCH="${OPTARG}"; ;;
b) BUILD_KIND="${OPTARG}"; ;;
@@ -182,7 +184,8 @@ buildp_init_getopts() {
fi; ;;
r) ARG_RESTART="${OPTARG}"; ;;
R) ARG_RELAXED=1; ;;
- x) ARG_XTRACE=1; ;;
+ x) ARG_VERBOSE_LEVELS="${ARG_VERBOSE_LEVELS:+${ARG_VERBOSE_LEVELS},}xtrace"; ;;
+ V) ARG_VERBOSE_LEVELS="${OPTARG}"; ;;
*) cat etc/build.usage.short; exit 1; ;;
esac; shift $((${OPTIND}-1)); OPTIND=1;
else if rtl_match "${1}" "=*"; then
@@ -212,13 +215,23 @@ buildp_init_getopts() {
esac;
if [ "${_rc:-0}" -eq 0 ]; then
DEFAULT_BUILD_CPUS="${ARG_PARALLEL}";
- case "${ARG_VERBOSE:-0}" in
- 0) rtl_fileop_set_log 0; rtl_log_set_lvl 0; ;;
- 1) rtl_fileop_set_log 0; rtl_log_set_lvl 2; ;;
- 2) rtl_fileop_set_log 0; rtl_log_set_lvl 2; ;;
- 3) rtl_fileop_set_log 1; rtl_log_set_lvl 3; ;;
- *) _rc=1; _status="Error: invalid verbosity level (max. -vvv)"; ;;
+ case "${_verbose:-0}" in
+ 0) ;;
+ 1) ARG_VERBOSE_LEVELS="${ARG_VERBOSE_LEVELS:+${ARG_VERBOSE_LEVELS},}notice"; ;;
+ 2) ARG_VERBOSE_LEVELS="${ARG_VERBOSE_LEVELS:+${ARG_VERBOSE_LEVELS},}verbose"; ;;
+ *) _rc=1; _status="Error: invalid verbosity level (max. -vv)"; ;;
esac;
+ rtl_log_set_lvl 0;
+ for _level in $(rtl_llift "${ARG_VERBOSE_LEVELS}" "," " "); do
+ case "${_level}" in
+ notice) rtl_log_set_lvl 1; ;;
+ verbose) rtl_log_set_lvl 2; ;;
+ build|install|xtrace)
+ ;;
+ fileops) rtl_fileop_set_log 1; ;;
+ *) _rc=1; _status="Error: invalid verbosity level \`${_level}'"; ;;
+ esac;
+ done;
fi;
fi;
return "${_rc}";
diff --git a/subr/pkg_install_files.subr b/subr/pkg_install_files.subr
index 8dc71753..3280e74d 100644
--- a/subr/pkg_install_files.subr
+++ b/subr/pkg_install_files.subr
@@ -14,7 +14,9 @@ pkgp_install_files_v2() {
local _vflag=""; _status="";
if [ -n "${PKG_INSTALL_FILES_V2:-}" ]; then
- [ "${ARG_VERBOSE:-0}" -ge 3 ] && _vflag="-v";
+ if rtl_lmatch "${ARG_VERBOSE_LEVELS}" "install" ","; then
+ _vflag="-v";
+ fi;
if ! rtl_install_v2 \
-p "_builddir=${PKG_BUILD_DIR}" \
-p "_destdir=${PKG_BASE_DIR}/${PKG_DESTDIR}" \