Hi all,
  this trivial patch adds support to --install option to specify a
prefix path for the links creation.

Don't know if anybody can find it useful, I added it because I needed
to keep a separate copy of busybox (with different configuration) in a
separate path and create links to it.

Bye,

 Alberto
diff -uNr busybox-1.5.1-orig/applets/busybox.c busybox-1.5.1/applets/busybox.c
--- busybox-1.5.1-orig/applets/busybox.c        2007-05-20 18:57:48.000000000 
+0200
+++ busybox-1.5.1/applets/busybox.c     2007-05-25 16:30:53.000000000 +0200
@@ -29,7 +29,7 @@
 typedef int (*link_func)(const char *, const char *);
 
 /* create (sym)links for each applet */
-static void install_links(const char *busybox, int use_symbolic_links)
+static void install_links(const char *busybox, int use_symbolic_links, const 
char *install_prefix)
 {
        link_func lf = link;
        char *fpc;
@@ -41,7 +41,9 @@
 
        for (i = 0; applets[i].name != NULL; i++) {
                fpc = concat_path_file(
-                               install_dir[applets[i].location],
+                               concat_path_file(
+                                       install_prefix,
+                                       install_dir[applets[i].location]),
                                applets[i].name);
                rc = lf(busybox, fpc);
                if (rc != 0 && errno != EEXIST) {
@@ -52,7 +54,7 @@
 }
 
 #else
-#define install_links(x,y)
+#define install_links(x,y,z)
 #endif /* CONFIG_FEATURE_INSTALLER */
 
 int main(int argc, char **argv)
@@ -84,18 +86,22 @@
        if (ENABLE_FEATURE_INSTALLER && argc > 1 && !strcmp(argv[1], 
"--install")) {
                int use_symbolic_links = 0;
                char *busybox;
+               char *install_prefix = NULL;
 
                /* to use symlinks, or not to use symlinks... */
                if (argc > 2)
                        if (strcmp(argv[2], "-s") == 0)
                                use_symbolic_links = 1;
 
+               if (argc > 3)
+                 install_prefix=argv[3];
+
                /* link */
 // XXX: FIXME: this is broken. Why not just use argv[0] ?
                busybox = xmalloc_readlink_or_warn("/proc/self/exe");
                if (!busybox)
                        return 1;
-               install_links(busybox, use_symbolic_links);
+               install_links(busybox, use_symbolic_links, install_prefix);
                if (ENABLE_FEATURE_CLEAN_UP)
                        free(busybox);
                return 0;
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox

Reply via email to