[BusyBox 0000407]: Debian's update-alternatives

bugs at busybox.net bugs at busybox.net
Thu Nov 23 13:31:09 UTC 2006


The following issue requires your FEEDBACK. 
====================================================================== 
http://busybox.net/bugs/view.php?id=407 
====================================================================== 
Reported By:                davidvrabel
Assigned To:                BusyBox
====================================================================== 
Project:                    BusyBox
Issue ID:                   407
Category:                   New Features
Reproducibility:            N/A
Severity:                   feature
Priority:                   normal
Status:                     feedback
====================================================================== 
Date Submitted:             08-30-2005 02:52 PDT
Last Modified:              11-23-2006 05:31 PST
====================================================================== 
Summary:                    Debian's update-alternatives
Description: 
This patch adds a trimmed-down implementation of Debian's
update-alternatives utility for managing symbolic links determining
default commands (e.g., it's used to manage /usr/bin/editor on Debian
systems).

Supported features:
  --install, --remove, --set, and --auto options.

Additional features:
  --destdir or the DESTDIR environment variable can be used to set
  destination directory for created files.  Useful for building a
target's
  filesystem on a host system.

Some missing features:
  Interactive configuration (use --set instead).
  Support for slave links.
====================================================================== 

---------------------------------------------------------------------- 
 vda - 11-23-06 05:31  
---------------------------------------------------------------------- 
1. Why it can't be done as a shell script?

2. We use tabs for indentation.

3. This:

+static void parse_options(int *argc, char **argv[])
+{
+    int destdir_set = 0;
+
+    for(;;) {
+        static const struct option long_opts[] = {
+            {"install", 0, 0, 0},
+            {"remove", 0, 0, 0},
+            {"set", 0, 0, 0},
+            {"auto", 0, 0, 0},
+            {"altdir", 1, 0, 1},
+            {"admindir", 1, 0, 2},
+            {"destdir", 1, 0, 3},
+            {0,0,0,0},
+        };
+        int option_idx = 0;
+
+        switch (getopt_long(*argc, *argv, "", long_opts, &option_idx)) {
+        case 0:
+            if (Action)
+                bb_error_msg_and_die("only one of --install, --remove,
--set or --auto allowed");
+            switch (option_idx) {
+            case 0:
+                Action = ACTION_INSTALL;
+                break;
+            case 1:
+                Action = ACTION_REMOVE;
+                break;
+            case 2:
+                Action = ACTION_SET;
+                break;
+            case 3:
+                Action = ACTION_AUTO;
+                break;
+            }
+            break;
+        case 1:
+            AltDir = optarg;
+            break;
+        case 2:
+            AdminDir = optarg;
+            break;
+        case 3:
+            DestDir = optarg;
+            destdir_set = 1;
+            break;
+        case '?':
+            bb_show_usage();
+        case -1:
+            if (!destdir_set) {
+                char *d = getenv("DESTDIR");
+                if (d)
+                    DestDir = d;
+            }
+            *argc -= optind;
+            *argv += optind;
+            return;
+        }
+    }
+}

can be at least twice as small I think. 

Issue History 
Date Modified   Username       Field                    Change               
====================================================================== 
08-30-05 02:52  davidvrabel    New Issue                                    
08-30-05 02:52  davidvrabel    Status                   new => assigned     
08-30-05 02:52  davidvrabel    Assigned To               => BusyBox         
08-30-05 02:52  davidvrabel    File Added: busybox-update-alternatives.patch    
               
11-23-06 05:31  vda            Note Added: 0001795                          
11-23-06 05:31  vda            Status                   assigned => feedback
======================================================================




More information about the busybox-cvs mailing list