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

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2009-07-15 00:35:34 +02:00
parent b3ba9e28e8
commit 3b405437b8

View 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;
}