[git commit] busybox --install [-s] [DIR]: allow a parameter - destination DIR

Denys Vlasenko vda.linux at googlemail.com
Tue Jul 14 22:35:34 UTC 2009


commit: http://git.busybox.net/busybox/commit/?id=3b405437b8bf7884c6679a5bca8d48c1edb2bf11
branch: http://git.busybox.net/busybox/commit/?id=refs/heads/master


Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 libbb/appletlib.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/libbb/appletlib.c b/libbb/appletlib.c
index 7b3f27c..b196808 100644
--- a/libbb/appletlib.c
+++ b/libbb/appletlib.c
@@ -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;
 	}
 
-- 
1.6.3.3


More information about the busybox-cvs mailing list