`config /etc/fstab' can now be used in depend() functions to show that
the deptree should be regenerated if /etc/fstab has changed.
This commit is contained in:
parent
7d68200f24
commit
3950eb6eba
@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
15 Aug 2007; Roy Marples <uberlord@gentoo.org>:
|
15 Aug 2007; Roy Marples <uberlord@gentoo.org>:
|
||||||
|
|
||||||
|
`config /etc/fstab' can now be used in depend() functions to show that
|
||||||
|
the deptree should be regenerated if /etc/fstab has changed.
|
||||||
Add bzr port 4155 to /etc/services, #188970 thanks to Andrew Cowie.
|
Add bzr port 4155 to /etc/services, #188970 thanks to Andrew Cowie.
|
||||||
|
|
||||||
08 Aug 2007; Roy Marples <uberlord@gentoo.org>:
|
08 Aug 2007; Roy Marples <uberlord@gentoo.org>:
|
||||||
|
@ -42,15 +42,17 @@ if mountinfo "${RC_SVCDIR}" >/dev/null && [ -w "${RC_LIBDIR}" ] ; then
|
|||||||
fuser -k ${f_opts} "${svcdir}" 1>/dev/null 2>/dev/null
|
fuser -k ${f_opts} "${svcdir}" 1>/dev/null 2>/dev/null
|
||||||
sleep 2
|
sleep 2
|
||||||
fi
|
fi
|
||||||
cp -p "${RC_SVCDIR}"/deptree "${RC_SVCDIR}"/softlevel \
|
cp -p "${RC_SVCDIR}"/deptree "${RC_SVCDIR}"/depconfig \
|
||||||
"${RC_SVCDIR}"/nettree "${RC_LIBDIR}" 2>/dev/null
|
"${RC_SVCDIR}"/softlevel "${RC_SVCDIR}"/nettree \
|
||||||
|
"${RC_LIBDIR}" 2>/dev/null
|
||||||
umount "${RC_SVCDIR}"
|
umount "${RC_SVCDIR}"
|
||||||
rm -rf "${RC_SVCDIR}"/*
|
rm -rf "${RC_SVCDIR}"/*
|
||||||
# Pipe errors to /dev/null as we may have future timestamps
|
# Pipe errors to /dev/null as we may have future timestamps
|
||||||
cp -p "${RC_LIBDIR}"/deptree "${RC_LIBDIR}"/softlevel \
|
cp -p "${RC_LIBDIR}"/deptree "${RC_LIBDIR}"/depconfig \
|
||||||
"${RC_LIBDIR}"/nettree "${RC_SVCDIR}" 2>/dev/null
|
"${RC_LIBDIR}"/softlevel "${RC_LIBDIR}"/nettree \
|
||||||
rm -f "${RC_LIBDIR}"/deptree "${RC_LIBDIR}"/softlevel \
|
"${RC_SVCDIR}" 2>/dev/null
|
||||||
"${RC_LIBDIR}"/nettree
|
rm -f "${RC_LIBDIR}"/deptree "${RC_LIBDIR}"/depconfig \
|
||||||
|
"${RC_LIBDIR}"/softlevel "${RC_LIBDIR}"/nettree
|
||||||
# Release the memory disk if we used it
|
# Release the memory disk if we used it
|
||||||
case "${mnt}" in
|
case "${mnt}" in
|
||||||
"/dev/md"[0-9]*) mdconfig -d -u "${mnt#/dev/md*}" ;;
|
"/dev/md"[0-9]*) mdconfig -d -u "${mnt#/dev/md*}" ;;
|
||||||
|
@ -25,6 +25,7 @@ depend() {
|
|||||||
myuse="${myuse} ${pmap}"
|
myuse="${myuse} ${pmap}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
config /etc/fstab
|
||||||
need net ${myneed}
|
need net ${myneed}
|
||||||
use afc-client amd autofs dns nfs nfsmount ${myuse}
|
use afc-client amd autofs dns nfs nfsmount ${myuse}
|
||||||
}
|
}
|
||||||
|
@ -22,15 +22,15 @@ mount_svcdir() {
|
|||||||
try mdconfig -a -t malloc -s 1m -u 1
|
try mdconfig -a -t malloc -s 1m -u 1
|
||||||
try newfs /dev/md1
|
try newfs /dev/md1
|
||||||
try mount /dev/md1 "${RC_LIBDIR}"/tmp
|
try mount /dev/md1 "${RC_LIBDIR}"/tmp
|
||||||
cp -p "${RC_SVCDIR}"/deptree "${RC_SVCDIR}"/nettree \
|
cp -p "${RC_SVCDIR}"/deptree "${RC_SVCDIR}"/depconfig \
|
||||||
"${RC_LIBDIR}"/tmp 2>/dev/null
|
"${RC_SVCDIR}"/nettree "${RC_LIBDIR}"/tmp 2>/dev/null
|
||||||
fi
|
fi
|
||||||
try mdconfig -a -t malloc -s "${RC_SVCSIZE:-1024}"k -u 0
|
try mdconfig -a -t malloc -s "${RC_SVCSIZE:-1024}"k -u 0
|
||||||
try newfs -b 4096 -i 1024 -n /dev/md0
|
try newfs -b 4096 -i 1024 -n /dev/md0
|
||||||
try mount -o rw,noexec,nosuid /dev/md0 "${RC_SVCDIR}"
|
try mount -o rw,noexec,nosuid /dev/md0 "${RC_SVCDIR}"
|
||||||
if ${dotmp} ; then
|
if ${dotmp} ; then
|
||||||
cp -p "${RC_LIBDIR}"/tmp/deptree "${RC_LIBDIR}"/tmp/nettree \
|
cp -p "${RC_LIBDIR}"/tmp/deptree "${RC_LIBDIR}"/tmp/depconfig \
|
||||||
"${RC_SVCDIR}" 2>/dev/null
|
"${RC_LIBDIR}"/tmp/nettree "${RC_SVCDIR}" 2>/dev/null
|
||||||
try umount "${RC_LIBDIR}"/tmp
|
try umount "${RC_LIBDIR}"/tmp
|
||||||
try mdconfig -d -u 1
|
try mdconfig -d -u 1
|
||||||
fi
|
fi
|
||||||
|
@ -65,13 +65,13 @@ mount_svcdir() {
|
|||||||
if [ -e "${RC_SVCDIR}"/deptree ] ; then
|
if [ -e "${RC_SVCDIR}"/deptree ] ; then
|
||||||
dotmp=true
|
dotmp=true
|
||||||
try mount -n -t "${fs}" -o rw "${devtmp}" "${RC_LIBDIR}"/tmp
|
try mount -n -t "${fs}" -o rw "${devtmp}" "${RC_LIBDIR}"/tmp
|
||||||
cp -p "${RC_SVCDIR}"/deptree "${RC_SVCDIR}"/nettree \
|
cp -p "${RC_SVCDIR}"/deptree "${RC_SVCDIR}"/depconfig \
|
||||||
"${RC_LIBDIR}"/tmp 2>/dev/null
|
"${RC_SVCDIR}"/nettree "${RC_LIBDIR}"/tmp 2>/dev/null
|
||||||
fi
|
fi
|
||||||
try mount -n ${mntcmd}
|
try mount -n ${mntcmd}
|
||||||
if ${dotmp} ; then
|
if ${dotmp} ; then
|
||||||
cp -p "${RC_LIBDIR}"/tmp/deptree "${RC_LIBDIR}"/tmp/nettree \
|
cp -p "${RC_LIBDIR}"/tmp/deptree "${RC_LIBDIR}"/tmp/depconfig \
|
||||||
"${RC_SVCDIR}" 2>/dev/null
|
"${RC_LIBDIR}"/tmp/nettree "${RC_SVCDIR}" 2>/dev/null
|
||||||
try umount -n "${RC_LIBDIR}"/tmp
|
try umount -n "${RC_LIBDIR}"/tmp
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,9 @@
|
|||||||
|
|
||||||
. /etc/init.d/functions.sh
|
. /etc/init.d/functions.sh
|
||||||
|
|
||||||
|
config() {
|
||||||
|
[ -n "$*" ] && echo "${SVCNAME} config $*" >&3
|
||||||
|
}
|
||||||
need() {
|
need() {
|
||||||
[ -n "$*" ] && echo "${SVCNAME} ineed $*" >&3
|
[ -n "$*" ] && echo "${SVCNAME} ineed $*" >&3
|
||||||
}
|
}
|
||||||
@ -49,6 +52,7 @@ for SVCNAME in * ; do
|
|||||||
depend
|
depend
|
||||||
|
|
||||||
# Add any user defined depends
|
# Add any user defined depends
|
||||||
|
config ${RC_CONFIG}
|
||||||
need ${RC_NEED}
|
need ${RC_NEED}
|
||||||
use ${RC_USE}
|
use ${RC_USE}
|
||||||
before ${RC_BEFORE}
|
before ${RC_BEFORE}
|
||||||
|
@ -6,7 +6,9 @@
|
|||||||
|
|
||||||
#include "librc.h"
|
#include "librc.h"
|
||||||
|
|
||||||
#define GENDEP RC_LIBDIR "/sh/gendepends.sh"
|
#define GENDEP RC_LIBDIR "/sh/gendepends.sh"
|
||||||
|
|
||||||
|
#define RC_DEPCONFIG RC_SVCDIR "/depconfig"
|
||||||
|
|
||||||
static const char *bootlevel = NULL;
|
static const char *bootlevel = NULL;
|
||||||
|
|
||||||
@ -610,13 +612,14 @@ int rc_update_deptree (bool force)
|
|||||||
char *service;
|
char *service;
|
||||||
char *type;
|
char *type;
|
||||||
char *depend;
|
char *depend;
|
||||||
|
char **config = NULL;
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
rc_depinfo_t *deptree;
|
rc_depinfo_t *deptree;
|
||||||
rc_depinfo_t *depinfo;
|
rc_depinfo_t *depinfo;
|
||||||
rc_depinfo_t *di;
|
rc_depinfo_t *di;
|
||||||
rc_depinfo_t *last_depinfo = NULL;
|
rc_depinfo_t *last_depinfo = NULL;
|
||||||
rc_deptype_t *deptype;
|
rc_deptype_t *deptype = NULL;
|
||||||
rc_deptype_t *dt;
|
rc_deptype_t *dt;
|
||||||
rc_deptype_t *last_deptype = NULL;
|
rc_deptype_t *last_deptype = NULL;
|
||||||
char buffer[RC_LINEBUFFER];
|
char buffer[RC_LINEBUFFER];
|
||||||
@ -632,12 +635,33 @@ int rc_update_deptree (bool force)
|
|||||||
if (mkdir (depdirs[i], 0755) != 0)
|
if (mkdir (depdirs[i], 0755) != 0)
|
||||||
eerrorx ("mkdir `%s': %s", depdirs[i], strerror (errno));
|
eerrorx ("mkdir `%s': %s", depdirs[i], strerror (errno));
|
||||||
|
|
||||||
if (! force)
|
/* Quick test to see if anything we use has changed */
|
||||||
if (is_newer_than (RC_DEPTREE, RC_INITDIR) &&
|
if (! force &&
|
||||||
is_newer_than (RC_DEPTREE, RC_CONFDIR) &&
|
is_newer_than (RC_DEPTREE, RC_INITDIR) &&
|
||||||
is_newer_than (RC_DEPTREE, "/etc/rc.conf"))
|
is_newer_than (RC_DEPTREE, RC_CONFDIR) &&
|
||||||
|
is_newer_than (RC_DEPTREE, "/etc/rc.conf"))
|
||||||
|
{
|
||||||
|
bool newer = false;
|
||||||
|
|
||||||
|
/* Some init scripts dependencies change depending on config files
|
||||||
|
* outside of baselayout, like syslog-ng, so we check those too. */
|
||||||
|
if (! rc_exists (RC_DEPCONFIG))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
config = rc_get_list (NULL, RC_DEPCONFIG);
|
||||||
|
STRLIST_FOREACH (config, service, i) {
|
||||||
|
if (! is_newer_than (RC_DEPTREE, service)) {
|
||||||
|
newer = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rc_strlist_free (config);
|
||||||
|
config = NULL;
|
||||||
|
|
||||||
|
if (! newer)
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
ebegin ("Caching service dependencies");
|
ebegin ("Caching service dependencies");
|
||||||
|
|
||||||
/* Some init scripts need RC_LIBDIR to source stuff
|
/* Some init scripts need RC_LIBDIR to source stuff
|
||||||
@ -690,28 +714,31 @@ int rc_update_deptree (bool force)
|
|||||||
if (! type || ! depends)
|
if (! type || ! depends)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
last_deptype = NULL;
|
/* Get the type */
|
||||||
for (deptype = depinfo->depends; deptype; deptype = deptype->next)
|
if (strcmp (type, "config") != 0) {
|
||||||
{
|
last_deptype = NULL;
|
||||||
last_deptype = deptype;
|
for (deptype = depinfo->depends; deptype; deptype = deptype->next)
|
||||||
if (strcmp (deptype->type, type) == 0)
|
{
|
||||||
break;
|
last_deptype = deptype;
|
||||||
}
|
if (strcmp (deptype->type, type) == 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (! deptype)
|
if (! deptype)
|
||||||
{
|
|
||||||
if (! last_deptype)
|
|
||||||
{
|
{
|
||||||
depinfo->depends = rc_xmalloc (sizeof (rc_deptype_t));
|
if (! last_deptype)
|
||||||
deptype = depinfo->depends;
|
{
|
||||||
|
depinfo->depends = rc_xmalloc (sizeof (rc_deptype_t));
|
||||||
|
deptype = depinfo->depends;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
last_deptype->next = rc_xmalloc (sizeof (rc_deptype_t));
|
||||||
|
deptype = last_deptype->next;
|
||||||
|
}
|
||||||
|
memset (deptype, 0, sizeof (rc_deptype_t));
|
||||||
|
deptype->type = rc_xstrdup (type);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
last_deptype->next = rc_xmalloc (sizeof (rc_deptype_t));
|
|
||||||
deptype = last_deptype->next;
|
|
||||||
}
|
|
||||||
memset (deptype, 0, sizeof (rc_deptype_t));
|
|
||||||
deptype->type = rc_xstrdup (type);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now add each depend to our type.
|
/* Now add each depend to our type.
|
||||||
@ -721,6 +748,11 @@ int rc_update_deptree (bool force)
|
|||||||
if (depend[0] == 0)
|
if (depend[0] == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (strcmp (type, "config") == 0) {
|
||||||
|
config = rc_strlist_addsort (config, depend);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
/* .sh files are not init scripts */
|
/* .sh files are not init scripts */
|
||||||
len = strlen (depend);
|
len = strlen (depend);
|
||||||
if (len > 2 &&
|
if (len > 2 &&
|
||||||
@ -848,6 +880,19 @@ int rc_update_deptree (bool force)
|
|||||||
fclose (fp);
|
fclose (fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Save our external config files to disk */
|
||||||
|
if (config) {
|
||||||
|
if (! (fp = fopen (RC_DEPCONFIG, "w")))
|
||||||
|
eerror ("fopen `%s': %s", RC_DEPCONFIG, strerror (errno));
|
||||||
|
else
|
||||||
|
{
|
||||||
|
STRLIST_FOREACH (config, service, i)
|
||||||
|
fprintf (fp, "%s\n", service);
|
||||||
|
fclose (fp);
|
||||||
|
}
|
||||||
|
rc_strlist_free (config);
|
||||||
|
}
|
||||||
|
|
||||||
rc_free_deptree (deptree);
|
rc_free_deptree (deptree);
|
||||||
|
|
||||||
eend (retval, "Failed to update the service dependency tree");
|
eend (retval, "Failed to update the service dependency tree");
|
||||||
|
@ -11,6 +11,9 @@
|
|||||||
# define LIB "lib"
|
# define LIB "lib"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define RC_LEVEL_BOOT "boot"
|
||||||
|
#define RC_LEVEL_DEFAULT "default"
|
||||||
|
|
||||||
#define RC_LIBDIR "/" LIB "/rcscripts"
|
#define RC_LIBDIR "/" LIB "/rcscripts"
|
||||||
#define RC_SVCDIR RC_LIBDIR "/init.d"
|
#define RC_SVCDIR RC_LIBDIR "/init.d"
|
||||||
#define RC_DEPTREE RC_SVCDIR "/deptree"
|
#define RC_DEPTREE RC_SVCDIR "/deptree"
|
||||||
|
2
src/rc.h
2
src/rc.h
@ -23,11 +23,9 @@
|
|||||||
|
|
||||||
/* Special level names */
|
/* Special level names */
|
||||||
#define RC_LEVEL_SYSINIT "sysinit"
|
#define RC_LEVEL_SYSINIT "sysinit"
|
||||||
#define RC_LEVEL_BOOT "boot"
|
|
||||||
#define RC_LEVEL_SINGLE "single"
|
#define RC_LEVEL_SINGLE "single"
|
||||||
#define RC_LEVEL_SHUTDOWN "shutdown"
|
#define RC_LEVEL_SHUTDOWN "shutdown"
|
||||||
#define RC_LEVEL_REBOOT "reboot"
|
#define RC_LEVEL_REBOOT "reboot"
|
||||||
#define RC_LEVEL_DEFAULT "default"
|
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user