85cc462e1d
* Moved helpers, common and triggers dirs into xbps-src, where they belong. * Renamed the templates dir to srcpkgs, it was so redundant before. * Make it possible to add subpkgs with no restriction in names, for example udev now has a subpkgs called "libgudev". Previously subpkgs were named "${sourcepkg}-${pkgname}". * xbps-src: changed to look for template files in current directory. That means that most arguments from the targets have been removed. * xbps-src: added a reinstall target, to remove + install. * xbps-src: do not overwrite binpkgs by default, skip them. And more that I forgot because it's a mega-commit that I've been working for some days already... --HG-- extra : convert_revision : 0f466878584d1e6895d2a234f07ea1b2d1e61b3e
80 lines
1.5 KiB
Bash
Executable File
80 lines
1.5 KiB
Bash
Executable File
#!/bin/sh
|
|
#
|
|
# Registers or unregisters OpenRC services into the specified
|
|
# runlevel.
|
|
#
|
|
# Arguments: $1 = action [run/targets]
|
|
# $2 = target [post-install/pre-remove]
|
|
# $3 = pkgname
|
|
# $4 = version
|
|
# $5 = update [yes/no]
|
|
#
|
|
ACTION="$1"
|
|
TARGET="$2"
|
|
PKGNAME="$3"
|
|
VERSION="$4"
|
|
UPDATE="$5"
|
|
|
|
initdir=etc/init.d
|
|
metadatadir=var/db/xbps/metadata/${PKGNAME}
|
|
|
|
case "$ACTION" in
|
|
targets)
|
|
echo "post-install pre-remove"
|
|
;;
|
|
run)
|
|
[ ! -x sbin/rc-update ] && exit 0
|
|
[ ! -x sbin/rc-service ] && exit 0
|
|
[ -z "$openrc_services" ] && exit 1
|
|
|
|
if [ "$TARGET" = "pre-remove" ]; then
|
|
rcupdate_args="del"
|
|
elif [ "$TARGET" = "post-install" ]; then
|
|
rcupdate_args="add"
|
|
else
|
|
exit 1
|
|
fi
|
|
|
|
[ ! -f etc/fstab ] && touch etc/fstab
|
|
|
|
set -- ${openrc_services}
|
|
while [ $# -gt 0 ]; do
|
|
srv_restart=$metadatadir/.$1_srv_restart
|
|
if [ "$TARGET" = "post-install" ]; then
|
|
if [ -f $srv_restart ]; then
|
|
# Restart service if it was running previously.
|
|
$initdir/$1 start
|
|
rm -f $srv_restart
|
|
else
|
|
# Register service.
|
|
if sbin/rc-service -e ${1}; then
|
|
sbin/rc-update add ${1} ${2}
|
|
fi
|
|
fi
|
|
else
|
|
# While removing always stop the service if running.
|
|
$initdir/$1 -q status
|
|
if [ $? -eq 0 ]; then
|
|
$initdir/$1 stop
|
|
fi
|
|
#
|
|
# While upgrading a package, don't remove the service.
|
|
#
|
|
if [ "$UPDATE" = "yes" ]; then
|
|
touch -f $srv_restart
|
|
else
|
|
# Unregister the service.
|
|
sbin/rc-update del ${1} ${2}
|
|
fi
|
|
fi
|
|
unset srv_restart
|
|
shift; shift;
|
|
done
|
|
;;
|
|
*)
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
exit 0
|