From afd0865cfdd383b4952b6bbab725638292fe7c78 Mon Sep 17 00:00:00 2001 From: LucĂ­a Andrea Illanes Albornoz Date: Mar 13 2023 06:26:01 +0000 Subject: pkgtool.sh: optionally source ${HOME}/pkgtool.vars to provide defaults for -a, -b, -m, -M. etc/pkgtool.usage: updated. etc/README.md: updated. --- diff --git a/etc/README.md b/etc/README.md index 63411a6..95ad13e 100644 --- a/etc/README.md +++ b/etc/README.md @@ -909,6 +909,8 @@ usage: ./pkgtool.sh [-a nt32|nt64] [-b debug|release] [-i|-m -M | -i List package variables and dependencies of single named package. -m Setup package archives mirror in and/or -M Setup Git repositories mirror in + Specify "" or '' as to default to the defaults in + ${HOME}/pkgtool.vars, if present. -r List reverse dependencies of single named package. -R List full reverse dependencies of single named package. -t Produce tarball of package build root directory and build log @@ -921,7 +923,12 @@ usage: ./pkgtool.sh [-a nt32|nt64] [-b debug|release] [-i|-m -M | > N.B. When using ``pkgtool.sh`` on a build w/ build variables (see section [4.2](#42-build-variables)) overriden on the command line or via the environment, ensure that they are included in the -``pkgtool.sh`` command line, preceding the package name, or exported, respectively. +``pkgtool.sh`` command line, preceding the package name, or exported, respectively. + +> N.B. ``pkgtool.sh`` will source the ``${HOME}/pkgtool.vars`` file, if present, on startup where the +following option arguments may be set: ``-a nt32|nt64`` by setting ``ARCH=...``, ``-b debug|release`` +by setting ``BUILD_KIND=...``, ``-m `` by setting ``ARG_MIRROR_DNAME=...``, and ``-M `` +by setting ``ARG_MIRROR_DNAME_GIT=...``. [Back to top](#table-of-contents) diff --git a/etc/pkgtool.usage b/etc/pkgtool.usage index 6c86e86..446ac3a 100644 --- a/etc/pkgtool.usage +++ b/etc/pkgtool.usage @@ -6,6 +6,8 @@ -i List package variables and dependencies of single named package. -m <dname> Setup package archives mirror in <dname> and/or -M <dname> Setup Git repositories mirror in <dname> + Specify "" or '' as to default to the defaults in + ${HOME}/pkgtool.vars, if present. -r List reverse dependencies of single named package. -R List recursive reverse dependencies of single named package. -t Produce tarball of package build root directory and build log diff --git a/pkgtool.sh b/pkgtool.sh index 24f0233..03efe32 100755 --- a/pkgtool.sh +++ b/pkgtool.sh @@ -15,6 +15,10 @@ pkgtoolp_init() { _pi_fname="" _pi_rc=0; shift; + if [ -e "${HOME}/pkgtool.vars" ]; then + . "${HOME}/pkgtool.vars" || exit 1; + fi; + if ! . "${0%/*}/subr.ex/ex_init.subr"; then _pi_rc=1; _pi_status='failed to source \`'"${0%/*}/subr/ex_init.subr"\'; @@ -80,8 +84,8 @@ pkgtoolp_init_getopts_fn() { : ${ARCH:="nt64"}; : ${BUILD_KIND:="debug"}; - ARG_INFO=0; ARG_MIRROR=0; ARG_MIRROR_DNAME=""; ARG_MIRROR_DNAME_GIT=""; - ARG_RDEPENDS=0; ARG_RDEPENDS_FULL=0; ARG_TARBALL=0; ARG_VERBOSE=0; + ARG_INFO=0; ARG_MIRROR=0; ARG_RDEPENDS=0; + ARG_RDEPENDS_FULL=0; ARG_TARBALL=0; ARG_VERBOSE=0; ;; longopt) @@ -98,8 +102,20 @@ pkgtoolp_init_getopts_fn() { b) BUILD_KIND="${OPTARG}"; _ppigf_shiftfl=2; ;; h) cat etc/pkgtool.usage; exit 0; ;; i) ARG_INFO=1; _ppigf_shiftfl=1; ;; - m) ARG_MIRROR=1; ARG_MIRROR_DNAME="${OPTARG}"; _ppigf_shiftfl=2; ;; - M) ARG_MIRROR=1; ARG_MIRROR_DNAME_GIT="${OPTARG}"; _ppigf_shiftfl=2; ;; + m) ARG_MIRROR=1; + if [ "${OPTARG:+1}" = 1 ]; then + ARG_MIRROR_DNAME="${OPTARG}"; + elif [ "${ARG_MIRROR_DNAME:+1}" != 1 ]; then + rtl_setrstatus "${_ppigf_rstatus}" 'missing -m argument and no default present.'; + fi; + _ppigf_shiftfl=2; ;; + M) ARG_MIRROR=1; + if [ "${OPTARG:+1}" = 1 ]; then + ARG_MIRROR_DNAME_GIT="${OPTARG}"; + elif [ "${ARG_MIRROR_DNAME_GIT:+1}" != 1 ]; then + rtl_setrstatus "${_ppigf_rstatus}" 'missing -M argument and no default present.'; + fi; + _ppigf_shiftfl=2; ;; r) ARG_RDEPENDS=1; _ppigf_shiftfl=1; ;; R) ARG_RDEPENDS_FULL=1; _ppigf_shiftfl=1; ;; t) ARG_TARBALL=1; _ppigf_shiftfl=1; ;;