1
0
forked from artix/alpm-hooks

1 Commits
1.0 ... no-help

Author SHA1 Message Date
fbeb2749c9 remove help hooks from default install 2021-07-01 21:39:09 +02:00
13 changed files with 61 additions and 63 deletions

View File

@@ -62,10 +62,10 @@ install_udev: install_common
install $(EMODE) $(UDEVSCRIPTS) $(DESTDIR)$(SCRIPTSDIR)
install $(MODE) $(UDEVHOOKS) $(DESTDIR)$(HOOKSDIR)
install_tmpfiles: install_hook_common
install_tmpfiles: install_common
install $(MODE) $(TMPFILESHOOKS) $(DESTDIR)$(HOOKSDIR)
install_sysusers: install_hook_common
install_sysusers: install_common
install $(MODE) $(SYSUSERSHOOKS) $(DESTDIR)$(HOOKSDIR)
install_openrc: install_common

View File

@@ -11,23 +11,23 @@ bundle_action() {
}
db_err_msg() {
echo "${CMD_UPD}: fatal: unable to take lock on ${DATABASE}: Permission denied"
echo "${CMD_UPD}: fatal: unable to take lock on ${DATABASE} Permission denied"
exit 1
}
bundle_err_msg() {
echo "'${BUNDLE}' is not an existing bundle. Create it with ${CMD}."
echo "${BUNDLE} is not an existing bundle. Create it with ${CMD}."
exit 1
}
bundle_entry_err_msg() {
name="$1"
echo "'$name' does not exist in bundle '${BUNDLE}'!"
echo "$name does not exist in bundle ${BUNDLE}!"
exit 1
}
bundle_add_err_msg() {
echo "Error when trying to add '${CONTENTS}'!"
echo "Error when trying to add ${CONTENTS}!"
}
cmd_help() {
@@ -154,10 +154,6 @@ for arg in "$@"; do
BUNDLE=$arg
continue
fi
if [ "${CONTENTS}" = "" ]; then
CONTENTS=$arg
continue
fi
CONTENTS="${CONTENTS} $arg"
done

View File

@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# {{{ functions
@@ -7,8 +7,8 @@ db_action() {
}
a_newbundle() {
for i in $new_bundles; do
if [ "$i" = "$1" ]; then
for j in $new_bundles; do
if [ "$j" = "$1" ]; then
return 0
fi
done
@@ -16,8 +16,8 @@ a_newbundle() {
}
service_exists() {
for j in $all_services; do
if [ "$j" = "$1" ]; then
for k in $all_services; do
if [ "$k" = "$1" ]; then
return 0
fi
done
@@ -26,8 +26,8 @@ service_exists() {
in_newbundle() {
bundle_contents=$(db_action contents "$1")
for k in $bundle_contents; do
if [ "$k" = "$2" ]; then
for l in $bundle_contents; do
if [ "$l" = "$2" ]; then
return 0
fi
done
@@ -42,36 +42,26 @@ in_newbundle() {
RCPATH='/etc/s6/rc'
DBPATH="${RCPATH}/compiled"
SVPATH='/etc/s6/sv'
ADMINSVPATH='/etc/s6/adminsv'
FALLBACKSVPATH='/etc/s6/fallbacksv'
SVDIRS='/run/s6-rc/servicedirs'
TIMESTAMP=$(date +%s)
if [ -e "${DBPATH}" ]; then
# Print contents of older bundles, using the format:
# <name1>
# <sv1> <sv2> <sv3> ... <svN>
# <name2>
# <sv1> ... <svN>
old_bundle_contents=$(
for bundle in $(db_action list bundles); do
printf '%s\n' "$bundle" "$(db_action contents "$bundle" | paste -sd" ")"
done
)
old_bundles="$(db_action list bundles)"
len=0
for bundle in $old_bundles; do
contents[$len]=$(db_action contents "$bundle")
len=$(( len + 1 ))
done
fi
if ! s6-rc-compile "${DBPATH}"-"${TIMESTAMP}" "${SVPATH}" "${ADMINSVPATH}"; then
echo "Error compiling database. Trying the system fallback paths!"
echo "Please double check the ${ADMINSVPATH} directories."
if ! s6-rc-compile "${DBPATH}"-"${TIMESTAMP}" "${SVPATH}" "${FALLBACKSVPATH}"; then
echo "The system fallback compilation failed. Something is really wrong with your service directories!"
echo "Check your ${SVPATH} and ${FALLBACKSVPATH} directories."
fi
if ! s6-rc-compile "${DBPATH}"-"${TIMESTAMP}" "${SVPATH}"; then
echo "Error compiling database."
echo "Please double check the ${SVPATH} directories. Exiting."
exit 1
fi
if [ -e "/run/s6-rc" ]; then
for dir in "${SVDIRS}"/*; do
for dir in ${SVDIRS}/*; do
if [ -e "${dir}/down" ]; then
s6-svc -x "${dir}"
fi
@@ -80,7 +70,8 @@ if [ -e "/run/s6-rc" ]; then
fi
if [ -d "${DBPATH}" ]; then
ln -sf "${DBPATH}"-"${TIMESTAMP}" "${DBPATH}"/compiled && mv -f "${DBPATH}"/compiled "${RCPATH}"
ln -sf "${DBPATH}"-"${TIMESTAMP}" "${DBPATH}"/compiled
mv -f "${DBPATH}"/compiled "${RCPATH}"
else
ln -sf "${DBPATH}"-"${TIMESTAMP}" "${DBPATH}"
fi
@@ -88,33 +79,44 @@ fi
new_bundles=$(db_action list bundles)
all_services=$(db_action list all)
while read -r l && read -r old_contents; do
CMD='s6-rc-bundle'
a_newbundle "$l"
ret=$?
if [ -n "$old_bundles" ]; then
len=0
for m in $old_bundles; do
old_contents=${contents[$len]}
a_newbundle "$m"
ret=$?
for m in $old_contents; do
# We should handle the service if it exists and either:
# [ $ret -eq 1 ] -> the bundle it is in not doesn't exist yet
# ! in_newbundle -> it's not in the bundle it used to be in
if service_exists "$m"; then
if [ $ret -eq 1 ] || ! in_newbundle "$l" "$m"; then
new_contents="$new_contents $m"
for n in $old_contents; do
service_exists "$n"
ret2=$?
if [ $ret -eq 1 ]; then
if [ $ret2 -eq 0 ]; then
new_contents="$new_contents $n"
fi
else
if [ $ret2 -eq 0 ]; then
in_newbundle "$m" "$n"
ret3=$?
if [ $ret3 -eq 1 ]; then
s6-rc-bundle-update -c "${DBPATH}" add "$m" "$n"
fi
fi
fi
done
if [ -n "$new_contents" ]; then
s6-rc-bundle -c "${DBPATH}" add "$m" $new_contents
fi
new_contents=""
len=$(( len + 1 ))
done
# If bundle exists, we're only going to update it
[ $ret -eq 1 ] || CMD="$CMD-update"
# Add or update bundle
[ -z "$new_contents" ] || "$CMD" -c "${DBPATH}" add "$l" $new_contents
new_contents=''
done <<EOF
$old_bundle_contents
EOF
fi
echo "==> Switched to a new database."
echo " Remove any old unwanted/unneeded database directories in ${RCPATH}."

View File

@@ -35,10 +35,9 @@ shutdown_service() {
if [ -d "$dir" ] && [ "$dir" != "etc/s6/sv/" ]; then
sv=$(basename "$dir")
active=$(s6-rc -a list | grep -Fx "$sv" || true)
if [ ! "$active" ]; then
continue
if [ -n $active ]; then
s6-rc -d change "$sv"
fi
s6-rc -d change "$sv"
fi
done
}

View File

@@ -10,6 +10,7 @@ udevd_live() {
op="$1"; shift
case "$op" in
#hwdb) /usr/bin/udev-hwdb --usr update ;;
hwdb) /usr/bin/udevadm hwdb --update ;;
udev-reload) udevd_live; /usr/bin/udevadm control --reload ;;
*) echo >&2 " Invalid operation '$op'"; exit 1 ;;