diff options
author | John Beppu <beppu@lbox.org> | 2000-06-27 04:50:02 +0000 |
---|---|---|
committer | John Beppu <beppu@lbox.org> | 2000-06-27 04:50:02 +0000 |
commit | 8f425dbf9a8af9d3ee9848a18a641a93d9fe039b (patch) | |
tree | 923bb7b84d2d450eb0c2a0598e4cbb0e6163fad7 /applets | |
parent | 83a949cb225e5f327929c8911010cd947ffd08d5 (diff) | |
download | busybox-8f425dbf9a8af9d3ee9848a18a641a93d9fe039b.tar.gz |
+ busybox --install [-s]
is almost good to go. Here is my work in progress.
+ Look at the FIXME in busybox.c
to see what I need. The actual (sym)linking is disabled
for now, although I'm sure it works ;)
(Am I going to have to dig through /proc to find
out where the currently running busybox is sitting?)
+ I put an #ifdef BB_FEATURE_INSTALLER around
the new bits of code in busybox.c, and I have a
#define BB_FEATURE_INSTALLER in busybox.def.h
towards the bottom.
Diffstat (limited to 'applets')
-rw-r--r-- | applets/busybox.c | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/applets/busybox.c b/applets/busybox.c index 84629d218..78f07e338 100644 --- a/applets/busybox.c +++ b/applets/busybox.c @@ -358,6 +358,60 @@ const struct BB_applet applets[] = { }; +#ifdef BB_FEATURE_INSTALLER +/* + * directory table + * this should be consistent w/ the enum, internal.h::Location, + * or else... + */ +static char* install_dir[] = { + "/", + "/bin", + "/sbin", + "/usr/bin", + "/usr/sbin", + NULL +}; + +/* abstract link() */ +typedef int (*__link_f)(const char *, const char *); + +/* create (sym)links for each applet */ +int install_links(const char *busybox, int use_symbolic_links) +{ + __link_f Link = link; + + char command[256]; + int i; + int rc = 0; + + if (use_symbolic_links) Link = symlink; + + for (i = 0; applets[i].name != NULL; i++) { + sprintf ( + command, + "%s/%s", + install_dir[applets[i].location], + applets[i].name + ); +#if 0 + rc |= Link(busybox, command); +#else + puts(command); +#endif + if (rc) { + fprintf(stderr,"busybox : %s : %s\n", command, strerror(errno)); + break; + } + } + return rc; +} + +#if 0 +int uninstall_links() ? +#endif +#endif /* BB_FEATURE_INSTALLER */ + int main(int argc, char **argv) { @@ -365,6 +419,26 @@ int main(int argc, char **argv) char *name; const struct BB_applet *a = applets; +#ifdef BB_FEATURE_INSTALLER + if (argc > 1 && (strcmp(argv[1], "--install") == 0)) { + int use_symbolic_links = 0; + + /* to use symlinks, or to not use symlinks... */ + if (argc > 2) { + if ((strcmp(argv[2], "-s") == 0)) { + use_symbolic_links = 1; + } + } + /* + * FIXME : + * I need a clever unix trick that'll tell + * me where to find the currently running + * busybox binary + */ + return install_links("/bin/busybox", use_symbolic_links); + } +#endif /* BB_FEATURE_INSTALLER */ + for (s = name = argv[0]; *s != '\0';) { if (*s++ == '/') name = s; |