diff options
author | Lucía Andrea Illanes Albornoz <lucia@luciaillanes.de> | 2023-03-29 14:26:52 +0200 |
---|---|---|
committer | Lucía Andrea Illanes Albornoz <lucia@luciaillanes.de> | 2023-03-29 14:26:52 +0200 |
commit | b570fd50f9b60626a5327aac06e8103c3cb0348d (patch) | |
tree | 0adbad9dcb225a3fa5e57e230f57b3c15b03287c | |
parent | 107752e42c617f329648dca864d4058ca7f6d250 (diff) | |
download | midipix_build-b570fd50f9b60626a5327aac06e8103c3cb0348d.tar.bz2 midipix_build-b570fd50f9b60626a5327aac06e8103c3cb0348d.tar.xz |
Implements ./pkgtool.sh -e: edit package group file w/ ${EDITOR}.
-rw-r--r-- | etc/README.md | 1 | ||||
-rw-r--r-- | etc/pkgtool.usage | 1 | ||||
-rwxr-xr-x | pkgtool.sh | 50 |
3 files changed, 50 insertions, 2 deletions
diff --git a/etc/README.md b/etc/README.md index 16d779fd..24f90451 100644 --- a/etc/README.md +++ b/etc/README.md @@ -926,6 +926,7 @@ usage: ./pkgtool.sh [-a nt32|nt64] [-b debug|release] [-i|-m <dname> -M <dname>| -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.
+ -e Edit package group file of single named package with ${EDITOR}.
-i List package variables and dependencies of named package(s).
-m <dname> Setup package archives mirror in <dname> and/or
-M <dname> Setup Git repositories mirror in <dname>
diff --git a/etc/pkgtool.usage b/etc/pkgtool.usage index b998bab7..898e3e0e 100644 --- a/etc/pkgtool.usage +++ b/etc/pkgtool.usage @@ -4,6 +4,7 @@ [33m-[93ma nt32[90m|[93mnt64[0m [96mSelects 32-bit or 64-bit architecture; defaults to [93mnt64[96m.[0m [33m-[93mb debug[90m|[93mrelease[0m [96mSelects debug or release build kind; defaults to [93mdebug[96m.[0m + [33m-[93me [96mEdit package group file of single named package with ${EDITOR}.[0m [33m-[93mi [96mList package variables and dependencies of named package(s).[0m [33m-[93mm [90m<[93mdname[90m> [96mSetup package archives mirror in [90m<[93mdname[90m>[96m and/or[0m [33m-[93mM [90m<[93mdname[90m> [96mSetup Git repositories mirror in [90m<[93mdname[90m>[0m @@ -7,7 +7,7 @@ pkgtoolp_init() { local _pi_rstatus="${1#\$}" \ _pi_args_long="" \ _pi_name_base="pkgtool" \ - _pi_optstring="a:b:him:M:p:rRtv" \ + _pi_optstring="a:b:ehim:M:p:rRtv" \ _pi_prereqs=" awk bzip2 cat chmod cp date find grep hostname mkdir mktemp mv paste printf readlink rm sed sort tar test @@ -51,6 +51,7 @@ pkgtoolp_init_args() { _ppia_rc=0; if [ "$((${ARG_INFO:-0} + + ${ARG_EDIT:-0} + ${ARG_MIRROR:-0} + ${ARG_PROFILE:-0} + ${ARG_RDEPENDS:-0} @@ -61,6 +62,7 @@ pkgtoolp_init_args() { _ppia_rc=1; rtl_setrstatus "${_ppia_rstatus}" 'only one of -i, -m and/or -M, -p, -r, -R, -s, or -t must be specified.'; elif [ "$((${ARG_INFO:-0} + + ${ARG_EDIT:-0} + ${ARG_MIRROR:-0} + ${ARG_PROFILE:-0} + ${ARG_RDEPENDS:-0} @@ -89,7 +91,7 @@ pkgtoolp_init_getopts_fn() { : ${ARCH:="nt64"}; : ${BUILD_KIND:="debug"}; - ARG_INFO=0; ARG_MIRROR=0; ARG_RDEPENDS=0; + ARG_INFO=0; ARG_EDIT=0; ARG_MIRROR=0; ARG_RDEPENDS=0; ARG_RDEPENDS_FULL=0; ARG_TARBALL=0; ARG_VERBOSE=0; ;; @@ -119,6 +121,7 @@ pkgtoolp_init_getopts_fn() { a) ARCH="${OPTARG}"; _ppigf_shiftfl=2; ;; b) BUILD_KIND="${OPTARG}"; _ppigf_shiftfl=2; ;; h) cat etc/pkgtool.usage; exit 0; ;; + e) ARG_EDIT=1; _ppigf_shiftfl=1; ;; i) ARG_INFO=1; _ppigf_shiftfl=1; ;; m) ARG_MIRROR=1; if [ "${OPTARG:+1}" = 1 ]; then @@ -207,6 +210,48 @@ pkgtoolp_init_getopts_fn() { }; # }}} +# {{{ pkgtoolp_edit($_rstatus, $_pkg_name) +pkgtoolp_edit() { + local _ppe_rstatus="${1}" _ppe_pkg_name="${2}" \ + _ppe_fname="" _ppe_group_fname="" _ppe_group_name="" _ppe_patch_idx=0 _ppe_pkg_disabled="" \ + _ppe_pkg_finished="" _ppe_pkg_name_uc="" _ppe_pkg_names="" _ppe_pkg_vars="" _ppe_rc=0; + rtl_toupper2 \$_ppe_pkg_name \$_ppe_pkg_name_uc; + + if ! ex_pkg_load_groups \$_ppe_groups \$_ppe_groups_noauto; then + _ppi_rc=1; + rtl_setrstatus "${_ppi_rstatus}" 'Error: failed to load build groups.'; + elif ! ex_pkg_find_package \$_ppe_group_name "${_ppe_groups}" "${_ppe_pkg_name}"; then + _ppe_rc=1; + rtl_setrstatus "${_ppe_rstatus}" 'Error: unknown package \`'"${_ppe_pkg_name}'"'.'; + elif ! ex_pkg_get_packages \$_ppe_pkg_names "${_ppe_group_name}"; then + _ppe_rc=1; + rtl_setrstatus "${_ppe_rstatus}" 'Error: failed to expand package list of build group \`'"${_ppe_group_name}'"'.'; + elif ! ex_pkg_env "${DEFAULT_BUILD_STEPS}" "${DEFAULT_BUILD_VARS}"\ + "${_ppe_group_name}" "${_ppe_pkg_name}" "" "${BUILD_WORKDIR}"; then + _ppe_rc=1; + rtl_setrstatus "${_ppe_rstatus}" 'Error: failed to set package environment for \`'"${_ppe_pkg_name}'"'.'; + else + rtl_get_var_unsafe \$_ppe_group_fname -u "PKG_${_ppe_pkg_name}_GROUP_FNAME"; + + case "${EDITOR}" in + "") + rtl_setrstatus "${_ppe_rstatus}" 'Error: \${EDITOR} unset.'; + ;; + + vi|vim|nvi|nvim) + "${EDITOR}" "${_ppe_group_fname}" "+/PKG_${_ppe_pkg_name_uc}_/"; + _ppe_rc="${?}"; + ;; + *) + "${EDITOR}" "${_ppe_group_fname}"; + _ppe_rc="${?}"; + ;; + esac; + fi; + + return "${_ppe_rc}"; +}; +# }}} # {{{ pkgtoolp_info($_rstatus, $_pkg_name) pkgtoolp_info() { local _ppi_rstatus="${1}" _ppi_pkg_name_list="${2}" \ @@ -644,6 +689,7 @@ pkgtool() { _status="Error: ${_status}"; else case "1" in + "${ARG_EDIT:-0}") pkgtoolp_edit \$_status "${PKGTOOL_PKG_NAME}"; ;; "${ARG_INFO:-0}") pkgtoolp_info \$_status "${PKGTOOL_PKG_NAME}"; ;; "${ARG_MIRROR:-0}") pkgtoolp_mirror \$_status "${ARG_MIRROR_DNAME}" "${ARG_MIRROR_DNAME_GIT}"; ;; "${ARG_PROFILE:-0}") pkgtoolp_profile \$_status "${ARG_PROFILE_LOG_FNAME}"; ;; |