[csw-devel] SF.net SVN: gar:[11132] csw/mgar/pkg/alternatives/trunk
theferret at users.sourceforge.net
theferret at users.sourceforge.net
Sat Oct 2 19:57:10 CEST 2010
Revision: 11132
http://gar.svn.sourceforge.net/gar/?rev=11132&view=rev
Author: theferret
Date: 2010-10-02 17:57:09 +0000 (Sat, 02 Oct 2010)
Log Message:
-----------
alternatives: Added --config and --list. Fixed a bug about manual setting
Modified Paths:
--------------
csw/mgar/pkg/alternatives/trunk/alternatives
csw/mgar/pkg/alternatives/trunk/pkginfo
Added Paths:
-----------
csw/mgar/pkg/alternatives/trunk/README
Added: csw/mgar/pkg/alternatives/trunk/README
===================================================================
--- csw/mgar/pkg/alternatives/trunk/README (rev 0)
+++ csw/mgar/pkg/alternatives/trunk/README 2010-10-02 17:57:09 UTC (rev 11132)
@@ -0,0 +1,7 @@
+A quickie readme for the future, about this "alternatives" implementation:
+
+Phil decided that a from-scratch, CSW-custom implementation was needed,
+because the debian one was hugely bloated, and the redhat smaller one,
+did not play nicely with NFS-shared /opt/csw
+So pleaes dont go getting ideas that we can migrated back to redhat,etc
+in the future! :) we tried, and it failed.
Modified: csw/mgar/pkg/alternatives/trunk/alternatives
===================================================================
--- csw/mgar/pkg/alternatives/trunk/alternatives 2010-10-02 16:20:43 UTC (rev 11131)
+++ csw/mgar/pkg/alternatives/trunk/alternatives 2010-10-02 17:57:09 UTC (rev 11132)
@@ -5,7 +5,7 @@
# @(#) alternatives 1.8@(#)
PRIORITIESDIR=/opt/csw/share/alternatives
-MANUALDIR=/etc/opt/etc/alternatives #manual override location
+MANUALDIR=/etc/opt/csw/alternatives #manual override location
AWK=nawk
DEBUG=${DEBUG:-/bin/true}
@@ -18,7 +18,8 @@
print " $prog --display {name}"
print " $prog --auto {name}"
print " $prog --set {name} {/full/path}"
- # --config interactive chooser, not implemented at this time
+ print " $prog --config {name}"
+ print " $prog --list"
print " "
print " The following are provided for compatibility, but do not work"
print " in exactly the same way as linux variants"
@@ -86,13 +87,24 @@
# Start of subroutine area
# Usage: print_alternatives shortname
-# This prints only the INSTALLED alternatives lines, not manual settings
+# This prints only the INSTALLED alternatives lines for named software.
+# Does not display whether or not any have been manually chosen.
# Prints in priority-sorted order
+# This is used both as a user-facing display, and also internally
+#
function print_alternatives {
if [[ $# != 1 ]] ; then print ERROR print_alternatives needs an arg; fi
cat $PRIORITIESDIR/* 2>/dev/null|
nawk '$2 == "'$1'" {print}' | sort -nr +3
}
+
+# User facing function.
+# enables "alternatives --list"
+function list_alternatives {
+ print "List of installed software that uses the alternatives system:"
+ cat $PRIORITIESDIR/* 2>/dev/null| nawk '{print $2}' | sort -u
+}
+
# prints ONLY the manually set alternatives line, if present
function print_manual_set {
if [[ $# != 1 ]] ; then print ERROR print_manual_set needs an arg; fi
@@ -294,6 +306,13 @@
;;
esac
+ if [[ ! -d $MANUALDIR ]] ; then
+ mkdir $MANUALDIR 2>/dev/null
+ fi
+ if [[ ! -d $MANUALDIR ]] ; then
+ print Error: $MANUALDIR does not exist. Cannot continue
+ exit 1
+ fi
check=`egrep -l "^[^ ]* $1 $2 " $PRIORITIESDIR/*`
if [[ "$check" == "" ]] ; then
print Error: no installed match found for $1 $2
@@ -327,7 +346,39 @@
print_alternatives $1
}
+function config_alternative {
+ case $1 in
+ */*)
+ print Error: need short name as arg for --config
+ exit 1
+ ;;
+ "")
+ print Error: Need a name for --config
+ exit 1
+ ;;
+ esac
+ print "Chooser for software '$1'"
+ print_alternatives $1 |nawk '{print $4,$1,$3}'
+ print "Input the priority number for your desired choice, or 0 to quit"
+ read prio
+ case $prio in
+ 0|Q|q)
+ print Quitting without change
+ exit 0
+ ;;
+ esac
+ fullpath=`cat $PRIORITIESDIR/* |
+ nawk '$2 == "'$1'" && $4 == "'$prio'" {print $3}'`
+
+ if [[ "$fullpath" = "" ]] ; then
+ print Error: no match for priority $prio
+ exit 1
+ fi
+
+ set_manual_prio $1 $fullpath
+}
+
############################################################
# Return to "main" area below
@@ -365,10 +416,17 @@
shift
revert_to_auto $1
;;
+ --list)
+ list_alternatives
+ ;;
--display)
shift
display_choices $1
;;
+ --config)
+ shift
+ config_alternative $1
+ ;;
--set)
shift
set_manual_prio $1 $2
Modified: csw/mgar/pkg/alternatives/trunk/pkginfo
===================================================================
--- csw/mgar/pkg/alternatives/trunk/pkginfo 2010-10-02 16:20:43 UTC (rev 11131)
+++ csw/mgar/pkg/alternatives/trunk/pkginfo 2010-10-02 17:57:09 UTC (rev 11132)
@@ -1,9 +1,9 @@
PKG=CSWalternatives
ARCH=all
NAME=alternatives - an implementation of linux-style alternatives choice mgr
-VERSION=1.0,REV=2010.05.21
+VERSION=1.1,REV=YYYY.MM.DD
CATEGORY=system
VENDOR=http://www.opencsw.org written and packaged for CSW by Philip Brown
EMAIL=phil at opencsw.org
HOTLINE=http://www.opencsw.org/bugtrack/
-PSTAMP=cswalternatives v1.0
+PSTAMP=cswalternatives v1.1
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the devel
mailing list