If we need to regenrate the deptree in the boot runlevel, remove it afterwards as the dependencies may need programs brought up by localmount. The dependencies will be regenerated correctly in the next runlevel.

This commit is contained in:
Roy Marples 2007-12-14 12:23:13 +00:00
parent f8db842dd2
commit b73bd04cf3
4 changed files with 18 additions and 8 deletions

View File

@ -37,4 +37,4 @@ int runscript (int argc, char **argv);
int start_stop_daemon (int argc, char **argv);
/* Handy function so we can wrap einfo around our deptree */
rc_depinfo_t *_rc_deptree_load (void);
rc_depinfo_t *_rc_deptree_load (int *regen);

View File

@ -48,10 +48,13 @@
#include "rc-misc.h"
#include "strlist.h"
rc_depinfo_t *_rc_deptree_load (void) {
rc_depinfo_t *_rc_deptree_load (int *regen) {
if (rc_deptree_update_needed ()) {
int retval;
if (regen)
*regen = 1;
ebegin ("Caching service dependencies");
retval = rc_deptree_update ();
eend (retval ? 0 : -1, "Failed to update the dependency tree");
@ -129,7 +132,7 @@ int rc_depend (int argc, char **argv)
eerrorx ("Failed to update the dependency tree");
}
if (! (deptree = _rc_deptree_load ()))
if (! (deptree = _rc_deptree_load (NULL)))
eerrorx ("failed to load deptree");
if (! runlevel)

View File

@ -803,6 +803,7 @@ int main (int argc, char **argv)
DIR *dp;
struct dirent *d;
bool parallel;
int regen = 0;
atexit (cleanup);
if (argv[0])
@ -1105,7 +1106,7 @@ int main (int argc, char **argv)
}
/* Load our deptree now */
if ((deptree = _rc_deptree_load ()) == NULL)
if ((deptree = _rc_deptree_load (&regen)) == NULL)
eerrorx ("failed to load deptree");
/* Clean the failed services state dir now */
@ -1437,7 +1438,6 @@ int main (int argc, char **argv)
}
#endif
STRLIST_FOREACH (start_services, service, i) {
if (rc_service_state (service) & RC_SERVICE_STOPPED) {
pid_t pid;
@ -1502,6 +1502,12 @@ interactive_option:
unlink (INTERACTIVE);
}
/* If we're in the boot runlevel and we regenerated our dependencies
* we need to delete them so that they are regenerated again in the
* default runlevel as they may depend on things that are now available */
if (regen && strcmp (runlevel, bootlevel) == 0)
unlink (RC_DEPTREE);
return (EXIT_SUCCESS);
}

View File

@ -684,7 +684,7 @@ static void svc_start (bool deps)
depoptions |= RC_DEP_START;
if (deps) {
if (! deptree && ((deptree = _rc_deptree_load ()) == NULL))
if (! deptree && ((deptree = _rc_deptree_load (NULL)) == NULL))
eerrorx ("failed to load deptree");
rc_strlist_free (services);
@ -898,7 +898,7 @@ static void svc_stop (bool deps)
if (rc_runlevel_stopping ())
depoptions |= RC_DEP_STOP;
if (! deptree && ((deptree = _rc_deptree_load ()) == NULL))
if (! deptree && ((deptree = _rc_deptree_load (NULL)) == NULL))
eerrorx ("failed to load deptree");
rc_strlist_free (tmplist);
@ -1078,6 +1078,7 @@ int runscript (int argc, char **argv)
/* Show help if insufficient args */
if (argc < 3) {
setenv ("SVCNAME", applet, 1);
execl (RCSCRIPT_HELP, RCSCRIPT_HELP, service, (char *) NULL);
eerrorx ("%s: failed to exec `" RCSCRIPT_HELP "': %s",
applet, strerror (errno));
@ -1259,7 +1260,7 @@ int runscript (int argc, char **argv)
if (rc_conf_yesno ("rc_depend_strict"))
depoptions |= RC_DEP_STRICT;
if (! deptree && ((deptree = _rc_deptree_load ()) == NULL))
if (! deptree && ((deptree = _rc_deptree_load (NULL)) == NULL))
eerrorx ("failed to load deptree");
rc_strlist_free (services);