BusyBox Bug and Patch Tracking
BusyBox
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0000407 [BusyBox] New Features feature N/A 08-30-05 02:52 11-23-06 05:31
Reporter davidvrabel View Status public  
Assigned To BusyBox
Priority normal Resolution open  
Status feedback   Product Version 1.00
Summary 0000407: 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.
Additional Information
Attached Files  busybox-update-alternatives.patch [^] (15,678 bytes) 08-30-05 02:52

- Relationships

- Notes
(0001795)
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


Copyright © 2000 - 2006 Mantis Group
Powered by Mantis Bugtracker