diff --git a/install.sh b/install.sh index 9cdb2a1d..dead3e32 100755 --- a/install.sh +++ b/install.sh @@ -87,6 +87,8 @@ install_data nvidiactl/nvidia.service "$DESTDIR$systemdunitdir/nvidi install_exec pdist/pdist "$DESTDIR$usrlocal_bindir/pdist" install_exec pmirror/pmirror "$DESTDIR$usrlocal_bindir/pmirror" install_exec prun/prun "$DESTDIR$usr_bindir/prun" +install_exec prun/ptype "$DESTDIR$usr_bindir/ptype" +install_exec prun/pman "$DESTDIR$usr_bindir/pman" install_exec put_websafe/put_websafe "$DESTDIR$usrlocal_bindir/put_websafe" install_exec switch-passwd/switch-passwd "$DESTDIR$root_sbindir/switch-passwd" install_data switch-passwd/switch-passwd.service "$DESTDIR$systemdunitdir/switch-passwd.service" diff --git a/prun/pman b/prun/pman new file mode 100755 index 00000000..14a7cfaf --- /dev/null +++ b/prun/pman @@ -0,0 +1,79 @@ +#! /bin/bash + +# pman: a package aware variant of the 'man' command + +function nop() { :; } # does nothing + +function exec_help() { +cat <<__HELP + + usage: + + pman [man options...] name + + The given NAME is tested if it relates to a 'pwrap' binary, + if so, the path is set and 'man NAME' is tried. + + environment honored: + + PMAN_VERBOSE + +__HELP + exit +} + + +PMAN_DEBUG=${PMAN_DEBUG:-''} +PMAN_VERBOSE=${PMAN_VERBOSE:-''} +ROOT="$PMAN_DEBUG/usr/local/package" +CFG="$ROOT/admin/config" + +if [ -z "$1" ] ; then + exec_help +fi + +SHOW=nop + +if [ -n "$PMAN_VERBOSE" ] ; then + SHOW=echo +fi + +# last arg +QUERY=${@: -1} + +PWRAPBIN=`type -p $QUERY` + +# expect wrappers only in /usr/local/package/bin +if [[ -n "$PWRAPBIN" && $PWRAPBIN =~ ^${ROOT}/bin ]] ; then + + # extract 'FooBar' out of '. /usr/local/package/lib/FooBar.profile' + PACKAGE=`sed -n -e '/^\.\s*\/usr/ s,^.*lib/\(.*\).profile$,\1,p' $PWRAPBIN` + + $SHOW "# package: '$PACKAGE'" + + if [ -n "$PACKAGE" ] ; then + + if [ -f "${ROOT}/lib/${PACKAGE}.profile" ] ; then + BN=`basename $PWRAPBIN` + source "${ROOT}/lib/${PACKAGE}.profile" + + # wrappers might still exist, but not the packagedirs + PATH_ADD=`echo $PATH | cut -f1 -d:` + $SHOW "# path: '$PATH'" + [ -n "$PATH_ADD" -a -d $PATH_ADD ] || echo "# Note: directory '$PATH_ADD' is missing." + + # ANSWER=`type -p $BN` + # echo "$QUERY is $ANSWER (${ROOT}/lib/${PACKAGE}.profile)"; + exec man "$@" + else + echo "# Error: Profile missing: ${ROOT}/lib/${PACKAGE}.profile" + fi + else + # take former output + echo "$QUERY is $PWRAPBIN (no package wrapper found)" + fi +fi + +# try it anyway +man "$@" + diff --git a/prun/ptype b/prun/ptype new file mode 100755 index 00000000..881a2022 --- /dev/null +++ b/prun/ptype @@ -0,0 +1,86 @@ +#! /bin/bash + +# ptype: a package aware variant of the 'type' command + +function nop() { :; } # does nothing + +function exec_help() { +cat <<__HELP + + usage: + + ptype name [name ...] + + Each NAME is tested if it is a 'pwrap' binary, + if so, the real binary is shown, otherwise you + get the regular type output. + + environment honored: + + PTYPE_VERBOSE + +__HELP + exit +} + + +PTYPE_DEBUG=${PTYPE_DEBUG:-''} # || '/dev/shm/makebintest'; +PTYPE_VERBOSE=${PTYPE_VERBOSE:-''} +ROOT="$PTYPE_DEBUG/usr/local/package" +CFG="$ROOT/admin/config" + +if [ -z "$1" ] ; then + exec_help +fi + +SHOW=nop + +if [ -n "$PTYPE_VERBOSE" ] ; then + SHOW=echo +fi + +while [ -n "$1" ] ; do + QUERY=$1; shift + + PWRAPBIN=`type -p $QUERY` + # PWRAPBIN=`which $QUERY` # alternative ? + + # expect wrappers only in /usr/local/package/bin + if [ -n "$PWRAPBIN" ] ; then + if [[ $PWRAPBIN =~ ^${ROOT}/bin ]] ; then + + # extract 'FooBar' out of '. /usr/local/package/lib/FooBar.profile' + PACKAGE=`sed -n -e '/^\.\s*\/usr/ s,^.*lib/\(.*\).profile$,\1,p' $PWRAPBIN` + + $SHOW "# package: '$PACKAGE'" + + if [ -n "$PACKAGE" ] ; then + + if [ -f "${ROOT}/lib/${PACKAGE}.profile" ] ; then + ( + BN=`basename $PWRAPBIN` + source "${ROOT}/lib/${PACKAGE}.profile" + + # wrappers might still exist, but not the packagedirs + PATH_ADD=`echo $PATH | cut -f1 -d:` + $SHOW "# path: '$PATH'" + [ -n "$PATH_ADD" -a -d $PATH_ADD ] || echo "# Note: directory '$PATH_ADD' is missing." + + ANSWER=`type -p $BN` + echo "$QUERY is $ANSWER (${ROOT}/lib/${PACKAGE}.profile)"; + ) + else + echo "# Error: Profile missing: ${ROOT}/lib/${PACKAGE}.profile" + fi + else + # take former output + echo "$QUERY is $PWRAPBIN (no package wrapper found)" + fi + else + echo "$QUERY is $PWRAPBIN (not in package path)" + fi + else + echo "ptype: $QUERY: not found"; + fi +done +