openrc/sh/gendepends.sh.in

91 lines
1.8 KiB
Bash
Raw Normal View History

#!@SHELL@
# Shell wrapper to list our dependencies
2009-05-01 15:11:40 +01:00
# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
# Released under the 2-clause BSD license.
. @LIBEXECDIR@/sh/functions.sh
. @LIBEXECDIR@/sh/rc-functions.sh
config() {
2009-04-26 21:13:26 +00:00
[ -n "$*" ] && echo "$RC_SVCNAME config $*" >&3
}
need() {
2009-04-26 21:13:26 +00:00
[ -n "$*" ] && echo "$RC_SVCNAME ineed $*" >&3
}
use() {
2009-04-26 21:13:26 +00:00
[ -n "$*" ] && echo "$RC_SVCNAME iuse $*" >&3
}
before() {
2009-04-26 21:13:26 +00:00
[ -n "$*" ] && echo "$RC_SVCNAME ibefore $*" >&3
}
after() {
2009-04-26 21:13:26 +00:00
[ -n "$*" ] && echo "$RC_SVCNAME iafter $*" >&3
}
provide() {
2009-04-26 21:13:26 +00:00
[ -n "$*" ] && echo "$RC_SVCNAME iprovide $*" >&3
}
2008-02-19 14:36:22 +00:00
keyword() {
2009-04-26 21:13:26 +00:00
[ -n "$*" ] && echo "$RC_SVCNAME keyword $*" >&3
}
depend() {
:
}
_done_dirs=
for _dir in \
2008-03-25 18:33:45 +00:00
@SYSCONFDIR@/init.d \
@PKG_PREFIX@/etc/init.d \
@LOCAL_PREFIX@/etc/init.d
do
2009-04-26 21:13:26 +00:00
[ -d "$_dir" ] || continue
# Don't do the same dir twice
2009-04-26 21:13:26 +00:00
for _d in $_done_dirs; do
[ "$_d" = "$_dir" ] && continue 2
done
unset _d
2009-04-26 21:13:26 +00:00
_done_dirs="$_done_dirs $_dir"
2009-04-26 21:13:26 +00:00
cd "$_dir"
for RC_SERVICE in *; do
2009-04-26 21:13:26 +00:00
[ -x "$RC_SERVICE" -a -f "$RC_SERVICE" ] || continue
# Only generate dependencies for runscripts
2009-04-26 21:13:26 +00:00
read one two three <"$RC_SERVICE"
[ "$one" = "#!@SBINDIR@/runscript" ] || \
[ "$one" = "#!" -a "$two" = "@SBINDIR@/runscript" ] || \
2009-04-26 21:13:26 +00:00
continue
unset one two three
RC_SVCNAME=${RC_SERVICE##*/} ; export RC_SVCNAME
# Compat
SVCNAME=$RC_SVCNAME ; export SVCNAME
(
# Save stdout in fd3, then remap it to stderr
exec 3>&1 1>&2
_rc_c=${RC_SVCNAME%%.*}
2009-04-26 21:13:26 +00:00
if [ -n "$_rc_c" -a "$_rc_c" != "$RC_SVCNAME" ]; then
if [ -e "$_dir/../conf.d/$_rc_c" ]; then
. "$_dir/../conf.d/$_rc_c"
fi
fi
unset _rc_c
2009-04-26 21:13:26 +00:00
if [ -e "$_dir/../conf.d/$RC_SVCNAME" ]; then
. "$_dir/../conf.d/$RC_SVCNAME"
fi
2007-07-22 11:28:38 +00:00
2008-03-25 18:33:45 +00:00
[ -e @SYSCONFDIR@/rc.conf ] && . @SYSCONFDIR@/rc.conf
2008-01-02 15:42:52 +00:00
2009-04-26 21:13:26 +00:00
if . "$_dir/$RC_SVCNAME"; then
echo "$RC_SVCNAME" >&3
_depend
fi
)
done
done