summaryrefslogtreecommitdiff
path: root/pkgtools/pkg_alternatives
diff options
context:
space:
mode:
authorjperkin <jperkin@pkgsrc.org>2012-06-13 15:35:32 +0000
committerjperkin <jperkin@pkgsrc.org>2012-06-13 15:35:32 +0000
commit58716964eae626096b3ca488d9b55fe8df6dea7a (patch)
tree927378a0e079ee0848fcec237b89d88675519390 /pkgtools/pkg_alternatives
parent141ce8e1d4a73548d30b006b64c7d4831113d8d9 (diff)
downloadpkgsrc-58716964eae626096b3ca488d9b55fe8df6dea7a.tar.gz
Update to 1.6, changes:
- Use the correct id(1) program. Fixes PR pkg/40691 - Avoid unprintable characters, some implementations of tr(1) have issues with them. Instead go for what hopefully will be a unique string, as well as making use of shell parameter substitution. Fixes PR pkg/42197 These changes combined make pkg_alternatives work correctly on Solaris.
Diffstat (limited to 'pkgtools/pkg_alternatives')
-rw-r--r--pkgtools/pkg_alternatives/Makefile5
-rw-r--r--pkgtools/pkg_alternatives/files/pkg_alternatives.sh45
-rw-r--r--pkgtools/pkg_alternatives/files/wrapper.sh10
3 files changed, 31 insertions, 29 deletions
diff --git a/pkgtools/pkg_alternatives/Makefile b/pkgtools/pkg_alternatives/Makefile
index 485c288ed49..1410b2eb1ee 100644
--- a/pkgtools/pkg_alternatives/Makefile
+++ b/pkgtools/pkg_alternatives/Makefile
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.17 2012/06/13 15:28:23 jperkin Exp $
+# $NetBSD: Makefile,v 1.18 2012/06/13 15:35:32 jperkin Exp $
#
-DISTNAME= pkg_alternatives-1.5
+DISTNAME= pkg_alternatives-1.6
CATEGORIES= pkgtools
MASTER_SITES= # empty
DISTFILES= # empty
@@ -38,6 +38,7 @@ SUBST_SED.vars+= -e 's|@PKGMANDIR@|${PKGMANDIR}|g'
SUBST_SED.vars+= -e 's|@PKG_DBDIR@|${PKG_DBDIR}|g'
SUBST_SED.vars+= -e 's|@PREFIX@|${PREFIX}|g'
SUBST_SED.vars+= -e 's|@ROOT_USER@|${REAL_ROOT_USER}|g'
+SUBST_SED.vars+= -e 's|@ID@|${ID}|g'
SUBST_SED.vars+= -e 's|@SH@|${SH}|g'
INSTALLATION_DIRS= ${PKGMANDIR}/man8 sbin
diff --git a/pkgtools/pkg_alternatives/files/pkg_alternatives.sh b/pkgtools/pkg_alternatives/files/pkg_alternatives.sh
index 6ef7126a6b6..56a19b10524 100644
--- a/pkgtools/pkg_alternatives/files/pkg_alternatives.sh
+++ b/pkgtools/pkg_alternatives/files/pkg_alternatives.sh
@@ -1,6 +1,6 @@
#!@SH@
#
-# $NetBSD: pkg_alternatives.sh,v 1.6 2007/01/15 02:50:06 rillig Exp $
+# $NetBSD: pkg_alternatives.sh,v 1.7 2012/06/13 15:35:32 jperkin Exp $
#
# pkg_alternatives - Generic wrappers for programs with similar interfaces
# Copyright (c) 2005 Julio M. Merino Vidal <jmmv@NetBSD.org>
@@ -56,9 +56,9 @@ action_auto_package() {
validate_package ${1}
pkg=${PKG_DBDIR}/${1}*/+ALTERNATIVES
- set -- $(cat ${pkg} | tr ' ' '¬')
+ set -- $(cat ${pkg} | sed -e 's# #__dE/lImIt/Er__#g')
while [ ${#} -gt 0 ]; do
- action_auto_wrapper $(echo ${1} | cut -d '¬' -f 1)
+ action_auto_wrapper ${1%%__dE/lImIt/Er__*}
shift
done
}
@@ -161,9 +161,9 @@ action_manual_package() {
validate_package ${1}
pkg=${PKG_DBDIR}/${1}*/+ALTERNATIVES
- set -- $(cat ${pkg} | tr ' ' '¬')
+ set -- $(cat ${pkg} | sed -e 's# #__dE/lImIt/Er__#g')
while [ ${#} -gt 0 ]; do
- action_manual_wrapper $(echo ${1} | tr '¬' ' ')
+ action_manual_wrapper $(echo ${1} | sed -e 's#__dE/lImIt/Er__# #g')
shift
done
}
@@ -231,9 +231,9 @@ action_rebuild_wrapper() {
action_register_package() {
validate_args register ${#} -eq 1
- set -- $(cat ${1} | tr ' ' '¬')
+ set -- $(cat ${1} | sed -e 's# #__dE/lImIt/Er__#g')
while [ ${#} -gt 0 ]; do
- action_register_wrapper $(echo ${1} | tr '¬' ' ')
+ action_register_wrapper $(echo ${1} | sed -e 's#__dE/lImIt/Er__# #g')
shift
done
}
@@ -276,7 +276,8 @@ action_register_wrapper() {
if [ ! -f ${wabs} ]; then
info "creating wrapper \`${wbase}'"
mkdir_p ${wabs%/*}
- sed -e "s|__SH__|@SH@|g" \
+ sed -e "s|__ID__|@ID@|g" \
+ -e "s|__SH__|@SH@|g" \
-e "s|__CONF_FILE__|${sysconf}|g" \
-e "s|__CREATOR__|${Prog_Name}|g" \
-e "s|__DB_FILE__|${dbconf}|g" \
@@ -308,9 +309,9 @@ action_status_package() {
validate_package ${1}
pkg=${PKG_DBDIR}/${1}*/+ALTERNATIVES
- set -- $(cat ${pkg} | tr ' ' '¬')
+ set -- $(cat ${pkg} | sed -e 's# #__dE/lImIt/Er__#g')
while [ ${#} -gt 0 ]; do
- action_status_wrapper $(echo ${1} | cut -d '¬' -f 1)
+ action_status_wrapper ${1%%__dE/lImIt/Er__*}
shift
done
}
@@ -330,15 +331,15 @@ action_status_wrapper() {
sysconf=${Conf_Dir}/${wbase}
userconf=~/.pkg_alternatives${Prefix}/${wbase}
- [ $(id -un) = @ROOT_USER@ ] && userconf=
+ [ $(@ID@ -un) = @ROOT_USER@ ] && userconf=
alts=$(cat ${userconf} ${sysconf} ${dbconf} 2>/dev/null | grep -v '^#' | \
- tr ' ' '¬')
+ sed -e 's# #__dE/lImIt/Er__#g')
found=
for a in ${alts}; do
- prog=$(echo ${a} | cut -d '¬' -f 1)
+ prog=${a%%__dE/lImIt/Er__*}
if [ -x ${prog} ]; then
- found=$(echo ${a} | tr '¬' ' ')
+ found=$(echo ${a} | sed -e 's#__dE/lImIt/Er__# #g')
break
fi
done
@@ -348,7 +349,7 @@ action_status_wrapper() {
echo "\`${wbase}' points to \`${found}'"
for a in $(echo ${alts} | tr ' ' '\n' | sort | uniq); do
- echo " candidate: $(echo ${a} | tr '¬' ' ')"
+ echo " candidate: $(echo ${a} | sed -e 's#__dE/lImIt/Er__# #g')"
done
}
@@ -362,9 +363,9 @@ action_status_wrapper() {
action_unregister_package() {
validate_args unregister ${#} -eq 1
- set -- $(cat ${1} | tr ' ' '¬')
+ set -- $(cat ${1} | sed -e 's# #__dE/lImIt/Er__#g')
while [ ${#} -gt 0 ]; do
- action_unregister_wrapper $(echo ${1} | tr '¬' ' ')
+ action_unregister_wrapper $(echo ${1} | sed -e 's#__dE/lImIt/Er__# #g')
shift
done
}
@@ -431,24 +432,24 @@ filter() {
[ ! -f @CONFDIR@/filter.conf ] && return 0
if [ ${Filter_Read} = no ]; then
- Filter=$(cat @CONFDIR@/filter.conf | grep -v '^#' | tr ' ' '¬')
+ Filter=$(cat @CONFDIR@/filter.conf | grep -v '^#' | sed -e 's# #__dE/lImIt/Er__#g')
Filter_Read=yes
fi
[ -z "${Filter}" ] && return 0
for f in ${Filter}; do
- what=$(echo ${f} | cut -d '¬' -f 1)
+ what=${f%%__dE/lImIt/Er__*}
case ${what} in
accept)
- name=$(echo ${f} | cut -d '¬' -f 2- | tr '¬' ' ')
+ name=$(echo ${f#*__dE/lImIt/Er__} | sed -e 's#__dE/lImIt/Er__# #g')
if echo ${1} | grep "${name}" >/dev/null; then
info "filter accepts \`${1}'"
return 0
fi
;;
ignore)
- name=$(echo ${f} | cut -d '¬' -f 2- | tr '¬' ' ')
+ name=$(echo ${f#*__dE/lImIt/Er__} | sed -e 's#__dE/lImIt/Er__# #g')
if echo ${1} | grep "${name}" >/dev/null; then
info "filter ignores \`${1}'"
return 1
@@ -472,7 +473,7 @@ filter() {
# personal directory.
#
get_my_config() {
- if [ $(id -un) = @ROOT_USER@ ]; then
+ if [ $(@ID@ -un) = @ROOT_USER@ ]; then
echo ${Conf_Dir}
else
echo ~/.pkg_alternatives${Prefix}
diff --git a/pkgtools/pkg_alternatives/files/wrapper.sh b/pkgtools/pkg_alternatives/files/wrapper.sh
index e4a757a2801..97b750dcd39 100644
--- a/pkgtools/pkg_alternatives/files/wrapper.sh
+++ b/pkgtools/pkg_alternatives/files/wrapper.sh
@@ -1,6 +1,6 @@
#!__SH__
#
-# $NetBSD: wrapper.sh,v 1.1.1.1 2005/01/25 13:00:46 jmmv Exp $
+# $NetBSD: wrapper.sh,v 1.2 2012/06/13 15:35:32 jperkin Exp $
#
# pkg_alternatives - Generic wrappers for programs with similar interfaces
# Copyright (c) 2005 Julio M. Merino Vidal <jmmv@NetBSD.org>
@@ -39,19 +39,19 @@ if [ ! -f __DB_FILE__ ]; then
exit 1
fi
-if [ $(id -un) = __ROOT_USER__ ]; then
+if [ $(__ID__ -un) = __ROOT_USER__ ]; then
userfile=
else
userfile=~/.pkg_alternatives/${wrapper}
fi
alternatives=$(cat ${userfile} __CONF_FILE__ __DB_FILE__ 2>/dev/null | \
- grep -v "^#" | tr ' ' '¬')
+ grep -v "^#" | sed -e 's# #__dE/lImIt/Er__#g')
found=
for a in ${alternatives}; do
- prog=$(echo ${a} | cut -d '¬' -f 1)
+ prog=${a%%__dE/lImIt/Er__*}
if [ -x ${prog} ]; then
- found=$(echo ${a} | tr '¬' ' ')
+ found=$(echo ${a} | sed -e 's#__dE/lImIt/Er__# #g')
break
fi
done