+ 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.
This commit is contained in:
John Beppu 2000-06-27 04:50:02 +00:00
parent 83a949cb22
commit 8f425dbf9a
3 changed files with 153 additions and 0 deletions

View File

@ -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;

View File

@ -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;

View File

@ -230,6 +230,11 @@
//#define BB_FEATURE_INSMOD_VERSION_CHECKING
//
//
// Enable busybox --install [-s]
// to create links (or symlinks) for all the commands that are
// compiled into the binary.
#define BB_FEATURE_INSTALLER
//
// End of Features List
//
//