-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
These two tools (author: thomas) are currently installed in /usr/local/package/bin. Import them into this repository and install into /usr/bin/ in analogy to prun. The copies in /usr/local/package/bin can then be replaced by symbolic links to the /usr/bin/ variants.
- Loading branch information
Showing
3 changed files
with
167 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 "$@" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|