The following commit has been merged in the master branch:
commit 7a6e69f7b8c0428628feb5fa7434634c33b6b468
Author: Raphael Hertzog <hert...@debian.org>
Date:   Sun Feb 22 16:20:24 2009 +0100

    update-alternatives: add new option --get-selections
    
    The new option list all master alternatives and their status
    in a format simple to parse. It's also a practical way to know
    the name of all available alternatives. Closes: #273406, #392429

diff --git a/ChangeLog b/ChangeLog
index c042ac8..d31e292 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2009-02-22  Raphael Hertzog  <hert...@debian.org>
 
+       * scripts/update-alternatives.pl: Implement --get-selections.
+       The new option lists all master alternatives and their status in a
+       format simple to parse.
+       * man/update-alternatives.8: Document this option.
+
+2009-02-22  Raphael Hertzog  <hert...@debian.org>
+
        * scripts/update-alternatives.pl: Installation of a slave
        alternative link is only done if the corresponding slave file is
        available.
diff --git a/debian/changelog b/debian/changelog
index 9d19387..e68c20e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -163,6 +163,9 @@ dpkg (1.15.0) UNRELEASED; urgency=low
     - new sanity checks on --install parameters. Closes: #423176
     - install slave link only if the corresponding slave file is available.
       Closes: #143701
+    - new option --get-selections to export the configuration of all
+      alternatives. It's a simple way to discover the name of all available
+      alternatives. Closes: #273406, #392429
 
   [ Pierre Habouzit ]
   * Add a --query option to update-alternatives. Closes: #336091, #441904
diff --git a/man/update-alternatives.8 b/man/update-alternatives.8
index 122168c..3086305 100644
--- a/man/update-alternatives.8
+++ b/man/update-alternatives.8
@@ -287,6 +287,14 @@ what other alternatives are available
 (and their corresponding slave alternatives),
 and the highest priority alternative currently installed.
 .TP
+\fB\-\-get\-selections\fR
+List all master alternative names (those controlling a link group)
+and their status. Each line contains up to 3 fields (separated by
+one or more spaces). The first field is the alternative name, the second
+one is the status (either "auto" or "manual"), and the last one contains
+the current choice in the alternative (beware: it's a filename and thus
+might contain spaces).
+.TP
 \fB\-\-query\fR \fIname\fR
 Display information about the link group
 like \-\-display does, but in a machine parseable way
diff --git a/scripts/update-alternatives.pl b/scripts/update-alternatives.pl
index 6f79d70..65726d5 100755
--- a/scripts/update-alternatives.pl
+++ b/scripts/update-alternatives.pl
@@ -70,8 +70,8 @@ while (@ARGV) {
        set_action($1);
         @ARGV || badusage(_g("--%s needs <name>"), $1);
         $alternative = Alternative->new(shift(@ARGV));
-    } elsif (m/^--all$/) {
-       set_action('all');
+    } elsif (m/^--(all|get-selections)$/) {
+       set_action($1);
     } elsif (m/^--slave$/) {
         badusage(_g("--slave only allowed with --install"))
             unless $action eq "install";
@@ -105,8 +105,9 @@ while (@ARGV) {
     }
 }
 
-badusage(_g("need --display, --query, --list, --config, --set, --install," .
-            "--remove, --all, --remove-all or --auto")) unless $action;
+badusage(_g("need --display, --query, --list, --get-selections, --config," .
+            "--set, --install, --remove, --all, --remove-all or --auto"))
+    unless $action;
 
 # Load infos about all alternatives to be able to check for mistakes
 my %ALL;
@@ -168,6 +169,12 @@ if ($action eq "install") {
 if ($action eq 'all') {
     config_all();
     exit 0;
+} elsif ($action eq 'get-selections') {
+    foreach my $alt_name (sort keys %{$ALL{objects}}) {
+        my $obj = $ALL{objects}{$alt_name};
+        printf "%-30s %-8s %s\n", $alt_name, $obj->status(), $obj->current() 
|| "";
+    }
+    exit 0;
 }
 
 # Load the alternative info, stop on failure except for --install

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to