Hi,
this trivial patch allows to specify a custom directory path
to busybox --install e.g.:
./busybox --install -s /system/xbin/
This allows to use --install also on systems that don't honour
the standard path. If no path is specified the hardcoded
busybox values are used. I've looked in the usage.h file
to add some help text for this hack but i was not able
to find a help text for the --install switch.
Please apply if you like it.
Hints, critics or improvements are welcome.
Ciao,
Tito
diff --git a/libbb/appletlib.c b/libbb/appletlib.c
index 7b3f27c..42aedc0 100644
--- a/libbb/appletlib.c
+++ b/libbb/appletlib.c
@@ -586,7 +586,7 @@ 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 +612,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);
@@ -687,8 +687,9 @@ static int busybox_main(char **argv)
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 */
+ install_links(busybox, argv[2] && strcmp(argv[2], "-s") == 0,
argv[3]);
return 0;
}
diff --git a/libbb/appletlib.c b/libbb/appletlib.c
index 7b3f27c..42aedc0 100644
--- a/libbb/appletlib.c
+++ b/libbb/appletlib.c
@@ -586,7 +586,7 @@ 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 +612,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);
@@ -687,8 +687,9 @@ static int busybox_main(char **argv)
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 */
+ install_links(busybox, argv[2] && strcmp(argv[2], "-s") == 0, argv[3]);
return 0;
}
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox