Wed Jun 13 15:35:32 2012 UTC ()
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.


(jperkin)
diff -r1.17 -r1.18 pkgsrc/pkgtools/pkg_alternatives/Makefile
diff -r1.6 -r1.7 pkgsrc/pkgtools/pkg_alternatives/files/pkg_alternatives.sh
diff -r1.1.1.1 -r1.2 pkgsrc/pkgtools/pkg_alternatives/files/wrapper.sh

cvs diff -r1.17 -r1.18 pkgsrc/pkgtools/pkg_alternatives/Makefile (expand / switch to unified diff)

--- pkgsrc/pkgtools/pkg_alternatives/Makefile 2012/06/13 15:28:23 1.17
+++ pkgsrc/pkgtools/pkg_alternatives/Makefile 2012/06/13 15:35:32 1.18
@@ -1,17 +1,17 @@ @@ -1,17 +1,17 @@
1# $NetBSD: Makefile,v 1.17 2012/06/13 15:28:23 jperkin Exp $ 1# $NetBSD: Makefile,v 1.18 2012/06/13 15:35:32 jperkin Exp $
2# 2#
3 3
4DISTNAME= pkg_alternatives-1.5 4DISTNAME= pkg_alternatives-1.6
5CATEGORIES= pkgtools 5CATEGORIES= pkgtools
6MASTER_SITES= # empty 6MASTER_SITES= # empty
7DISTFILES= # empty 7DISTFILES= # empty
8 8
9MAINTAINER= jmmv@NetBSD.org 9MAINTAINER= jmmv@NetBSD.org
10COMMENT= Generic wrappers for programs with similar interfaces 10COMMENT= Generic wrappers for programs with similar interfaces
11 11
12PKG_INSTALLATION_TYPES= overwrite pkgviews 12PKG_INSTALLATION_TYPES= overwrite pkgviews
13PKG_DESTDIR_SUPPORT= user-destdir 13PKG_DESTDIR_SUPPORT= user-destdir
14 14
15NO_BUILD= YES 15NO_BUILD= YES
16WRKSRC= ${WRKDIR} 16WRKSRC= ${WRKDIR}
17 17
@@ -28,26 +28,27 @@ PKG_SYSCONFSUBDIR= pkg_alternatives @@ -28,26 +28,27 @@ PKG_SYSCONFSUBDIR= pkg_alternatives
28CONF_FILES= ${EGDIR}/filter.conf ${PKG_SYSCONFDIR}/filter.conf 28CONF_FILES= ${EGDIR}/filter.conf ${PKG_SYSCONFDIR}/filter.conf
29 29
30SUBST_CLASSES+= vars 30SUBST_CLASSES+= vars
31SUBST_STAGE.vars= do-configure 31SUBST_STAGE.vars= do-configure
32SUBST_MESSAGE.vars= Configuring sources. 32SUBST_MESSAGE.vars= Configuring sources.
33SUBST_FILES.vars= pkg_alternatives.8 pkg_alternatives.sh 33SUBST_FILES.vars= pkg_alternatives.8 pkg_alternatives.sh
34SUBST_SED.vars= -e 's|@CONFDIR@|${PKG_SYSCONFDIR}|g' 34SUBST_SED.vars= -e 's|@CONFDIR@|${PKG_SYSCONFDIR}|g'
35SUBST_SED.vars+= -e 's|@DATADIR@|${DATADIR}|g' 35SUBST_SED.vars+= -e 's|@DATADIR@|${DATADIR}|g'
36SUBST_SED.vars+= -e 's|@DBDIR@|${DBDIR}|g' 36SUBST_SED.vars+= -e 's|@DBDIR@|${DBDIR}|g'
37SUBST_SED.vars+= -e 's|@PKGMANDIR@|${PKGMANDIR}|g' 37SUBST_SED.vars+= -e 's|@PKGMANDIR@|${PKGMANDIR}|g'
38SUBST_SED.vars+= -e 's|@PKG_DBDIR@|${PKG_DBDIR}|g' 38SUBST_SED.vars+= -e 's|@PKG_DBDIR@|${PKG_DBDIR}|g'
39SUBST_SED.vars+= -e 's|@PREFIX@|${PREFIX}|g' 39SUBST_SED.vars+= -e 's|@PREFIX@|${PREFIX}|g'
40SUBST_SED.vars+= -e 's|@ROOT_USER@|${REAL_ROOT_USER}|g' 40SUBST_SED.vars+= -e 's|@ROOT_USER@|${REAL_ROOT_USER}|g'
 41SUBST_SED.vars+= -e 's|@ID@|${ID}|g'
41SUBST_SED.vars+= -e 's|@SH@|${SH}|g' 42SUBST_SED.vars+= -e 's|@SH@|${SH}|g'
42 43
43INSTALLATION_DIRS= ${PKGMANDIR}/man8 sbin 44INSTALLATION_DIRS= ${PKGMANDIR}/man8 sbin
44 45
45CHECK_INTERPRETER_SKIP= ${DATADIR}/wrapper.sh 46CHECK_INTERPRETER_SKIP= ${DATADIR}/wrapper.sh
46 47
47do-extract: 48do-extract:
48 ${CP} ${FILESDIR}/pkg_alternatives.sh ${WRKSRC} 49 ${CP} ${FILESDIR}/pkg_alternatives.sh ${WRKSRC}
49 ${CP} ${FILESDIR}/pkg_alternatives.8 ${WRKSRC} 50 ${CP} ${FILESDIR}/pkg_alternatives.8 ${WRKSRC}
50 ${CP} ${FILESDIR}/wrapper.sh ${WRKSRC} 51 ${CP} ${FILESDIR}/wrapper.sh ${WRKSRC}
51 ${CP} ${FILESDIR}/wrapper.man ${WRKSRC} 52 ${CP} ${FILESDIR}/wrapper.man ${WRKSRC}
52 ${CP} ${FILESDIR}/filter.conf ${WRKSRC} 53 ${CP} ${FILESDIR}/filter.conf ${WRKSRC}
53 54

cvs diff -r1.6 -r1.7 pkgsrc/pkgtools/pkg_alternatives/files/pkg_alternatives.sh (expand / switch to unified diff)

--- pkgsrc/pkgtools/pkg_alternatives/files/pkg_alternatives.sh 2007/01/15 02:50:06 1.6
+++ pkgsrc/pkgtools/pkg_alternatives/files/pkg_alternatives.sh 2012/06/13 15:35:32 1.7
@@ -1,16 +1,16 @@ @@ -1,16 +1,16 @@
1#!@SH@ 1#!@SH@
2# 2#
3# $NetBSD: pkg_alternatives.sh,v 1.6 2007/01/15 02:50:06 rillig Exp $ 3# $NetBSD: pkg_alternatives.sh,v 1.7 2012/06/13 15:35:32 jperkin Exp $
4# 4#
5# pkg_alternatives - Generic wrappers for programs with similar interfaces 5# pkg_alternatives - Generic wrappers for programs with similar interfaces
6# Copyright (c) 2005 Julio M. Merino Vidal <jmmv@NetBSD.org> 6# Copyright (c) 2005 Julio M. Merino Vidal <jmmv@NetBSD.org>
7# 7#
8# Redistribution and use in source and binary forms, with or without 8# Redistribution and use in source and binary forms, with or without
9# modification, are permitted provided that the following conditions 9# modification, are permitted provided that the following conditions
10# are met: 10# are met:
11# 1. Redistributions of source code must retain the above copyright 11# 1. Redistributions of source code must retain the above copyright
12# notice, this list of conditions and the following disclaimer. 12# notice, this list of conditions and the following disclaimer.
13# 2. Redistributions in binary form must reproduce the above copyright 13# 2. Redistributions in binary form must reproduce the above copyright
14# notice, this list of conditions and the following disclaimer in 14# notice, this list of conditions and the following disclaimer in
15# the documentation and/or other materials provided with the 15# the documentation and/or other materials provided with the
16# distribution. 16# distribution.
@@ -46,29 +46,29 @@ Verbose=yes @@ -46,29 +46,29 @@ Verbose=yes
46# ------------------------------------------------------------------------- 46# -------------------------------------------------------------------------
47 47
48# action_auto_package package 48# action_auto_package package
49# 49#
50# Configures the given package to be in automatic mode. I.e., it removes 50# Configures the given package to be in automatic mode. I.e., it removes
51# local customizations for all related wrappers, so that only the files in 51# local customizations for all related wrappers, so that only the files in
52# the database are taken into account. 52# the database are taken into account.
53# 53#
54action_auto_package() { 54action_auto_package() {
55 validate_args auto ${#} -eq 1 55 validate_args auto ${#} -eq 1
56 validate_package ${1} 56 validate_package ${1}
57 pkg=${PKG_DBDIR}/${1}*/+ALTERNATIVES 57 pkg=${PKG_DBDIR}/${1}*/+ALTERNATIVES
58 58
59 set -- $(cat ${pkg} | tr ' ' '¬') 59 set -- $(cat ${pkg} | sed -e 's# #__dE/lImIt/Er__#g')
60 while [ ${#} -gt 0 ]; do 60 while [ ${#} -gt 0 ]; do
61 action_auto_wrapper $(echo ${1} | cut -d '¬' -f 1) 61 action_auto_wrapper ${1%%__dE/lImIt/Er__*}
62 shift 62 shift
63 done 63 done
64} 64}
65 65
66# ------------------------------------------------------------------------- 66# -------------------------------------------------------------------------
67 67
68# action_auto_wrapper wrapper 68# action_auto_wrapper wrapper
69# 69#
70# Configures the given wrapper to be in automatic mode. I.e., it removes 70# Configures the given wrapper to be in automatic mode. I.e., it removes
71# local customizations so that only the files in the database are taken 71# local customizations so that only the files in the database are taken
72# into account. 72# into account.
73# 73#
74# wrapper is a path relative to prefix. 74# wrapper is a path relative to prefix.
@@ -151,29 +151,29 @@ action_list_wrapper() { @@ -151,29 +151,29 @@ action_list_wrapper() {
151 151
152# ------------------------------------------------------------------------- 152# -------------------------------------------------------------------------
153 153
154# action_manual_package package 154# action_manual_package package
155# 155#
156# Configures the given package to be the preferred alternative for all the 156# Configures the given package to be the preferred alternative for all the
157# wrappers associated to it. 157# wrappers associated to it.
158# 158#
159action_manual_package() { 159action_manual_package() {
160 validate_args manual ${#} -eq 1 160 validate_args manual ${#} -eq 1
161 validate_package ${1} 161 validate_package ${1}
162 pkg=${PKG_DBDIR}/${1}*/+ALTERNATIVES 162 pkg=${PKG_DBDIR}/${1}*/+ALTERNATIVES
163 163
164 set -- $(cat ${pkg} | tr ' ' '¬') 164 set -- $(cat ${pkg} | sed -e 's# #__dE/lImIt/Er__#g')
165 while [ ${#} -gt 0 ]; do 165 while [ ${#} -gt 0 ]; do
166 action_manual_wrapper $(echo ${1} | tr '¬' ' ') 166 action_manual_wrapper $(echo ${1} | sed -e 's#__dE/lImIt/Er__# #g')
167 shift 167 shift
168 done 168 done
169} 169}
170 170
171# ------------------------------------------------------------------------- 171# -------------------------------------------------------------------------
172 172
173# action_manual_wrapper wrapper alternative arguments 173# action_manual_wrapper wrapper alternative arguments
174# 174#
175# Configures the given wrapper to use the specified alternative. 175# Configures the given wrapper to use the specified alternative.
176# If running as the administrator, the system-wide settings are changed; 176# If running as the administrator, the system-wide settings are changed;
177# otherwise, the user-specific settings are affected. 177# otherwise, the user-specific settings are affected.
178# 178#
179# wrapper is a path relative to prefix. 179# wrapper is a path relative to prefix.
@@ -221,29 +221,29 @@ action_rebuild_wrapper() { @@ -221,29 +221,29 @@ action_rebuild_wrapper() {
221} 221}
222 222
223# ------------------------------------------------------------------------- 223# -------------------------------------------------------------------------
224 224
225# action_register_package file 225# action_register_package file
226# 226#
227# Registers all wrapper/alternative pairs listed in the file. This is 227# Registers all wrapper/alternative pairs listed in the file. This is
228# supposed to be an +ALTERNATIVES file found inside a package in PKG_DBDIR. 228# supposed to be an +ALTERNATIVES file found inside a package in PKG_DBDIR.
229# Each line should follow the semantics expected by action_register_wrapper. 229# Each line should follow the semantics expected by action_register_wrapper.
230# 230#
231action_register_package() { 231action_register_package() {
232 validate_args register ${#} -eq 1 232 validate_args register ${#} -eq 1
233 233
234 set -- $(cat ${1} | tr ' ' '¬') 234 set -- $(cat ${1} | sed -e 's# #__dE/lImIt/Er__#g')
235 while [ ${#} -gt 0 ]; do 235 while [ ${#} -gt 0 ]; do
236 action_register_wrapper $(echo ${1} | tr '¬' ' ') 236 action_register_wrapper $(echo ${1} | sed -e 's#__dE/lImIt/Er__# #g')
237 shift 237 shift
238 done 238 done
239} 239}
240 240
241# ------------------------------------------------------------------------- 241# -------------------------------------------------------------------------
242 242
243# action_register_wrapper wrapper alternative arguments 243# action_register_wrapper wrapper alternative arguments
244# 244#
245# Registers a new alternative for the given wrapper in the database. 245# Registers a new alternative for the given wrapper in the database.
246# The wrapper and its manual page are created if they do not exist. 246# The wrapper and its manual page are created if they do not exist.
247# 247#
248action_register_wrapper() { 248action_register_wrapper() {
249 validate_args register ${#} -ge 2 249 validate_args register ${#} -ge 2
@@ -266,27 +266,28 @@ action_register_wrapper() { @@ -266,27 +266,28 @@ action_register_wrapper() {
266 mkdir_p ${dbconf%/*} 266 mkdir_p ${dbconf%/*}
267 touch ${dbconf%/*} 267 touch ${dbconf%/*}
268 fi 268 fi
269 info "registering alternative \`${alt}' for wrapper \`${wbase}'" 269 info "registering alternative \`${alt}' for wrapper \`${wbase}'"
270 if [ -n "${args}" ]; then 270 if [ -n "${args}" ]; then
271 echo "${alt} ${args}" >>${dbconf} 271 echo "${alt} ${args}" >>${dbconf}
272 else 272 else
273 echo "${alt}" >>${dbconf} 273 echo "${alt}" >>${dbconf}
274 fi 274 fi
275 275
276 if [ ! -f ${wabs} ]; then 276 if [ ! -f ${wabs} ]; then
277 info "creating wrapper \`${wbase}'" 277 info "creating wrapper \`${wbase}'"
278 mkdir_p ${wabs%/*} 278 mkdir_p ${wabs%/*}
279 sed -e "s|__SH__|@SH@|g" \ 279 sed -e "s|__ID__|@ID@|g" \
 280 -e "s|__SH__|@SH@|g" \
280 -e "s|__CONF_FILE__|${sysconf}|g" \ 281 -e "s|__CONF_FILE__|${sysconf}|g" \
281 -e "s|__CREATOR__|${Prog_Name}|g" \ 282 -e "s|__CREATOR__|${Prog_Name}|g" \
282 -e "s|__DB_FILE__|${dbconf}|g" \ 283 -e "s|__DB_FILE__|${dbconf}|g" \
283 -e "s|__ROOT_USER__|@ROOT_USER@|g" \ 284 -e "s|__ROOT_USER__|@ROOT_USER@|g" \
284 -e "s|__WRAPPER__|${wabs}|g" \ 285 -e "s|__WRAPPER__|${wabs}|g" \
285 <${Data_Dir}/wrapper.sh >${wabs} 286 <${Data_Dir}/wrapper.sh >${wabs}
286 chmod +x ${wabs} 287 chmod +x ${wabs}
287 mkdir_p ${manpage%/*} 288 mkdir_p ${manpage%/*}
288 sed -e "s|__CONF_FILE__|${sysconf}|g" \ 289 sed -e "s|__CONF_FILE__|${sysconf}|g" \
289 -e "s|__CREATOR__|${Prog_Name}|g" \ 290 -e "s|__CREATOR__|${Prog_Name}|g" \
290 -e "s|__DB_FILE__|${dbconf}|g" \ 291 -e "s|__DB_FILE__|${dbconf}|g" \
291 -e "s|__PREFIX__|${Prefix}|g" \ 292 -e "s|__PREFIX__|${Prefix}|g" \
292 -e "s|__SECTION__|$(get_manpage_sect ${wbase})|g" \ 293 -e "s|__SECTION__|$(get_manpage_sect ${wbase})|g" \
@@ -298,83 +299,83 @@ action_register_wrapper() { @@ -298,83 +299,83 @@ action_register_wrapper() {
298} 299}
299 300
300# ------------------------------------------------------------------------- 301# -------------------------------------------------------------------------
301 302
302# action_status_package package 303# action_status_package package
303# 304#
304# Shows the status of each wrapper associated to the given package. 305# Shows the status of each wrapper associated to the given package.
305# 306#
306action_status_package() { 307action_status_package() {
307 validate_args status ${#} -eq 1 308 validate_args status ${#} -eq 1
308 validate_package ${1} 309 validate_package ${1}
309 pkg=${PKG_DBDIR}/${1}*/+ALTERNATIVES 310 pkg=${PKG_DBDIR}/${1}*/+ALTERNATIVES
310 311
311 set -- $(cat ${pkg} | tr ' ' '¬') 312 set -- $(cat ${pkg} | sed -e 's# #__dE/lImIt/Er__#g')
312 while [ ${#} -gt 0 ]; do 313 while [ ${#} -gt 0 ]; do
313 action_status_wrapper $(echo ${1} | cut -d '¬' -f 1) 314 action_status_wrapper ${1%%__dE/lImIt/Er__*}
314 shift 315 shift
315 done 316 done
316} 317}
317 318
318# ------------------------------------------------------------------------- 319# -------------------------------------------------------------------------
319 320
320# action_status_wrapper wrapper 321# action_status_wrapper wrapper
321# 322#
322# Shows the current status for the given wrapper. 323# Shows the current status for the given wrapper.
323# 324#
324action_status_wrapper() { 325action_status_wrapper() {
325 validate_args status ${#} -eq 1 326 validate_args status ${#} -eq 1
326 validate_wrapper ${1} yes 327 validate_wrapper ${1} yes
327 328
328 wbase=${1} 329 wbase=${1}
329 dbconf=${Db_Dir}/${wbase} 330 dbconf=${Db_Dir}/${wbase}
330 sysconf=${Conf_Dir}/${wbase} 331 sysconf=${Conf_Dir}/${wbase}
331 userconf=~/.pkg_alternatives${Prefix}/${wbase} 332 userconf=~/.pkg_alternatives${Prefix}/${wbase}
332 333
333 [ $(id -un) = @ROOT_USER@ ] && userconf= 334 [ $(@ID@ -un) = @ROOT_USER@ ] && userconf=
334 alts=$(cat ${userconf} ${sysconf} ${dbconf} 2>/dev/null | grep -v '^#' | \ 335 alts=$(cat ${userconf} ${sysconf} ${dbconf} 2>/dev/null | grep -v '^#' | \
335 tr ' ' '¬') 336 sed -e 's# #__dE/lImIt/Er__#g')
336 337
337 found= 338 found=
338 for a in ${alts}; do 339 for a in ${alts}; do
339 prog=$(echo ${a} | cut -d '¬' -f 1) 340 prog=${a%%__dE/lImIt/Er__*}
340 if [ -x ${prog} ]; then 341 if [ -x ${prog} ]; then
341 found=$(echo ${a} | tr '¬' ' ') 342 found=$(echo ${a} | sed -e 's#__dE/lImIt/Er__# #g')
342 break 343 break
343 fi 344 fi
344 done 345 done
345 346
346 [ -n "${found}" ] || 347 [ -n "${found}" ] ||
347 err "the wrapper \`${wbase}' exists but has no valid alternatives" 348 err "the wrapper \`${wbase}' exists but has no valid alternatives"
348 349
349 echo "\`${wbase}' points to \`${found}'" 350 echo "\`${wbase}' points to \`${found}'"
350 for a in $(echo ${alts} | tr ' ' '\n' | sort | uniq); do 351 for a in $(echo ${alts} | tr ' ' '\n' | sort | uniq); do
351 echo " candidate: $(echo ${a} | tr '¬' ' ')" 352 echo " candidate: $(echo ${a} | sed -e 's#__dE/lImIt/Er__# #g')"
352 done 353 done
353} 354}
354 355
355# ------------------------------------------------------------------------- 356# -------------------------------------------------------------------------
356 357
357# action_unregister_package file 358# action_unregister_package file
358# 359#
359# Unregisters the given package (given by its +ALTERNATIVES file) and 360# Unregisters the given package (given by its +ALTERNATIVES file) and
360# removes all associated alternatives from their respective wrappers. 361# removes all associated alternatives from their respective wrappers.
361# 362#
362action_unregister_package() { 363action_unregister_package() {
363 validate_args unregister ${#} -eq 1 364 validate_args unregister ${#} -eq 1
364 365
365 set -- $(cat ${1} | tr ' ' '¬') 366 set -- $(cat ${1} | sed -e 's# #__dE/lImIt/Er__#g')
366 while [ ${#} -gt 0 ]; do 367 while [ ${#} -gt 0 ]; do
367 action_unregister_wrapper $(echo ${1} | tr '¬' ' ') 368 action_unregister_wrapper $(echo ${1} | sed -e 's#__dE/lImIt/Er__# #g')
368 shift 369 shift
369 done 370 done
370} 371}
371 372
372# ------------------------------------------------------------------------- 373# -------------------------------------------------------------------------
373 374
374# action_unregister_wrapper wrapper alternative arguments 375# action_unregister_wrapper wrapper alternative arguments
375# 376#
376# Unregisters an alternative for the given wrapper. The lookup is done 377# Unregisters an alternative for the given wrapper. The lookup is done
377# based on the alternative name and its arguments. I.e., there must be 378# based on the alternative name and its arguments. I.e., there must be
378# an exact match. If no alternatives remain after the removal, the wrapper 379# an exact match. If no alternatives remain after the removal, the wrapper
379# and its manpage are removed. 380# and its manpage are removed.
380# 381#
@@ -421,68 +422,68 @@ err() { @@ -421,68 +422,68 @@ err() {
421} 422}
422 423
423# ------------------------------------------------------------------------- 424# -------------------------------------------------------------------------
424 425
425# filter wrapper 426# filter wrapper
426# 427#
427# Reads the configuration filter from CONFDIR/filter.conf and, for the 428# Reads the configuration filter from CONFDIR/filter.conf and, for the
428# given wrapper, returns whether it is accepted or ignored. 429# given wrapper, returns whether it is accepted or ignored.
429# 430#
430filter() { 431filter() {
431 [ ! -f @CONFDIR@/filter.conf ] && return 0 432 [ ! -f @CONFDIR@/filter.conf ] && return 0
432 433
433 if [ ${Filter_Read} = no ]; then 434 if [ ${Filter_Read} = no ]; then
434 Filter=$(cat @CONFDIR@/filter.conf | grep -v '^#' | tr ' ' '¬') 435 Filter=$(cat @CONFDIR@/filter.conf | grep -v '^#' | sed -e 's# #__dE/lImIt/Er__#g')
435 Filter_Read=yes 436 Filter_Read=yes
436 fi 437 fi
437 438
438 [ -z "${Filter}" ] && return 0 439 [ -z "${Filter}" ] && return 0
439 440
440 for f in ${Filter}; do 441 for f in ${Filter}; do
441 what=$(echo ${f} | cut -d '¬' -f 1) 442 what=${f%%__dE/lImIt/Er__*}
442 case ${what} in 443 case ${what} in
443 accept) 444 accept)
444 name=$(echo ${f} | cut -d '¬' -f 2- | tr '¬' ' ') 445 name=$(echo ${f#*__dE/lImIt/Er__} | sed -e 's#__dE/lImIt/Er__# #g')
445 if echo ${1} | grep "${name}" >/dev/null; then 446 if echo ${1} | grep "${name}" >/dev/null; then
446 info "filter accepts \`${1}'" 447 info "filter accepts \`${1}'"
447 return 0 448 return 0
448 fi 449 fi
449 ;; 450 ;;
450 ignore) 451 ignore)
451 name=$(echo ${f} | cut -d '¬' -f 2- | tr '¬' ' ') 452 name=$(echo ${f#*__dE/lImIt/Er__} | sed -e 's#__dE/lImIt/Er__# #g')
452 if echo ${1} | grep "${name}" >/dev/null; then 453 if echo ${1} | grep "${name}" >/dev/null; then
453 info "filter ignores \`${1}'" 454 info "filter ignores \`${1}'"
454 return 1 455 return 1
455 fi 456 fi
456 ;; 457 ;;
457 *) 458 *)
458 warn "unknown filter type \`${what}'; ignoring" 459 warn "unknown filter type \`${what}'; ignoring"
459 ;; 460 ;;
460 esac 461 esac
461 done 462 done
462 463
463 true 464 true
464} 465}
465 466
466# ------------------------------------------------------------------------- 467# -------------------------------------------------------------------------
467 468
468# get_my_config 469# get_my_config
469# 470#
470# Prints the configuration directory for the current user. If root, this 471# Prints the configuration directory for the current user. If root, this
471# is the system-wide configuration directory. Otherwise, it is the user's 472# is the system-wide configuration directory. Otherwise, it is the user's
472# personal directory. 473# personal directory.
473# 474#
474get_my_config() { 475get_my_config() {
475 if [ $(id -un) = @ROOT_USER@ ]; then 476 if [ $(@ID@ -un) = @ROOT_USER@ ]; then
476 echo ${Conf_Dir} 477 echo ${Conf_Dir}
477 else 478 else
478 echo ~/.pkg_alternatives${Prefix} 479 echo ~/.pkg_alternatives${Prefix}
479 fi 480 fi
480} 481}
481 482
482# ------------------------------------------------------------------------- 483# -------------------------------------------------------------------------
483 484
484# get_manpage wrapper 485# get_manpage wrapper
485# 486#
486# Prints the absolute path to the manual page associated to wrapper. 487# Prints the absolute path to the manual page associated to wrapper.
487# Does no error checking; validate_wrapper has to be called before this 488# Does no error checking; validate_wrapper has to be called before this
488# function to ensure wrapper is a valid name. 489# function to ensure wrapper is a valid name.

cvs diff -r1.1.1.1 -r1.2 pkgsrc/pkgtools/pkg_alternatives/files/wrapper.sh (expand / switch to unified diff)

--- pkgsrc/pkgtools/pkg_alternatives/files/wrapper.sh 2005/01/25 13:00:46 1.1.1.1
+++ pkgsrc/pkgtools/pkg_alternatives/files/wrapper.sh 2012/06/13 15:35:32 1.2
@@ -1,16 +1,16 @@ @@ -1,16 +1,16 @@
1#!__SH__ 1#!__SH__
2# 2#
3# $NetBSD: wrapper.sh,v 1.1.1.1 2005/01/25 13:00:46 jmmv Exp $ 3# $NetBSD: wrapper.sh,v 1.2 2012/06/13 15:35:32 jperkin Exp $
4# 4#
5# pkg_alternatives - Generic wrappers for programs with similar interfaces 5# pkg_alternatives - Generic wrappers for programs with similar interfaces
6# Copyright (c) 2005 Julio M. Merino Vidal <jmmv@NetBSD.org> 6# Copyright (c) 2005 Julio M. Merino Vidal <jmmv@NetBSD.org>
7# 7#
8# Redistribution and use in source and binary forms, with or without 8# Redistribution and use in source and binary forms, with or without
9# modification, are permitted provided that the following conditions 9# modification, are permitted provided that the following conditions
10# are met: 10# are met:
11# 1. Redistributions of source code must retain the above copyright 11# 1. Redistributions of source code must retain the above copyright
12# notice, this list of conditions and the following disclaimer. 12# notice, this list of conditions and the following disclaimer.
13# 2. Redistributions in binary form must reproduce the above copyright 13# 2. Redistributions in binary form must reproduce the above copyright
14# notice, this list of conditions and the following disclaimer in 14# notice, this list of conditions and the following disclaimer in
15# the documentation and/or other materials provided with the 15# the documentation and/or other materials provided with the
16# distribution. 16# distribution.
@@ -29,36 +29,36 @@ @@ -29,36 +29,36 @@
29# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31# POSSIBILITY OF SUCH DAMAGE. 31# POSSIBILITY OF SUCH DAMAGE.
32# 32#
33 33
34wrapper="__WRAPPER__" 34wrapper="__WRAPPER__"
35progname="${wrapper##*/} (wrapper)" 35progname="${wrapper##*/} (wrapper)"
36 36
37if [ ! -f __DB_FILE__ ]; then 37if [ ! -f __DB_FILE__ ]; then
38 echo "${progname}: cannot open __DB_FILE__" 1>&2 38 echo "${progname}: cannot open __DB_FILE__" 1>&2
39 exit 1 39 exit 1
40fi 40fi
41 41
42if [ $(id -un) = __ROOT_USER__ ]; then 42if [ $(__ID__ -un) = __ROOT_USER__ ]; then
43 userfile= 43 userfile=
44else 44else
45 userfile=~/.pkg_alternatives/${wrapper} 45 userfile=~/.pkg_alternatives/${wrapper}
46fi 46fi
47alternatives=$(cat ${userfile} __CONF_FILE__ __DB_FILE__ 2>/dev/null | \ 47alternatives=$(cat ${userfile} __CONF_FILE__ __DB_FILE__ 2>/dev/null | \
48 grep -v "^#" | tr ' ' '¬') 48 grep -v "^#" | sed -e 's# #__dE/lImIt/Er__#g')
49 49
50found= 50found=
51for a in ${alternatives}; do 51for a in ${alternatives}; do
52 prog=$(echo ${a} | cut -d '¬' -f 1) 52 prog=${a%%__dE/lImIt/Er__*}
53 if [ -x ${prog} ]; then 53 if [ -x ${prog} ]; then
54 found=$(echo ${a} | tr '¬' ' ') 54 found=$(echo ${a} | sed -e 's#__dE/lImIt/Er__# #g')
55 break 55 break
56 fi 56 fi
57done 57done
58 58
59if [ -z "${found}" ]; then 59if [ -z "${found}" ]; then
60 echo "${progname}: no alternatives found" 1>&2 60 echo "${progname}: no alternatives found" 1>&2
61 exit 1 61 exit 1
62fi 62fi
63 63
64exec ${found} "${@}" 64exec ${found} "${@}"