busybox --install [-s] [DIR]: allow a parameter - destination DIR
authorDenys Vlasenko <vda.linux@googlemail.com>
Tue, 14 Jul 2009 22:35:34 +0000 (00:35 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Tue, 14 Jul 2009 22:35:34 +0000 (00:35 +0200)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
libbb/appletlib.c

index 7b3f27c3658accae2004a2ab6c8576c37953c58a..b19680808f8a00815d53cfa02c8a3009d0220df9 100644 (file)
@@ -586,7 +586,8 @@ static void check_suid(int applet_no)
 
 #if ENABLE_FEATURE_INSTALLER
 /* 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,
+               char *custom_install_dir)
 {
        /* directory table
         * this should be consistent w/ the enum,
@@ -612,7 +613,7 @@ static void install_links(const char *busybox, int use_symbolic_links)
 
        for (i = 0; i < ARRAY_SIZE(applet_main); i++) {
                fpc = concat_path_file(
-                               install_dir[APPLET_INSTALL_LOC(i)],
+                               custom_install_dir ? custom_install_dir : install_dir[APPLET_INSTALL_LOC(i)],
                                APPLET_NAME(i));
                // debug: bb_error_msg("%slinking %s to busybox",
                //              use_symbolic_links ? "sym" : "", fpc);
@@ -624,7 +625,7 @@ static void install_links(const char *busybox, int use_symbolic_links)
        }
 }
 #else
-#define install_links(x,y) ((void)0)
+#define install_links(x,y,z) ((void)0)
 #endif /* FEATURE_INSTALLER */
 
 /* If we were called as "busybox..." */
@@ -683,12 +684,15 @@ static int busybox_main(char **argv)
        }
 
        if (ENABLE_FEATURE_INSTALLER && strcmp(argv[1], "--install") == 0) {
+               int use_symbolic_links;
                const char *busybox;
                busybox = xmalloc_readlink(bb_busybox_exec_path);
                if (!busybox)
                        busybox = bb_busybox_exec_path;
-               /* -s makes symlinks */
-               install_links(busybox, argv[2] && strcmp(argv[2], "-s") == 0);
+               /* -s makes symlinks, argv[3] is a custom defined */
+               /* install directory or NULL to use the hardcoded defaults */
+               use_symbolic_links = (argv[2] && strcmp(argv[2], "-s") == 0 && argv++);
+               install_links(busybox, use_symbolic_links, argv[2]);
                return 0;
        }