2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-12-04 08:07:04 +00:00

refactor(packaging): share explicit-target init detection

This commit is contained in:
Vinícius Ferrão
2026-11-25 14:13:01 -03:00
parent b1cdbf15fd
commit ef45085eee
2 changed files with 15 additions and 22 deletions
@@ -30,19 +30,7 @@ uses_systemd()
fi
if [ "$detection_mode" = explicit ]; then
if [ -L "$compat_root/sbin/init" ]; then
init_target=$(readlink "$compat_root/sbin/init" 2>/dev/null || true)
case "$init_target" in
*systemd*) return 0 ;;
*) return 1 ;;
esac
fi
if [ -e "$compat_root/sbin/init" ]; then
return 1
fi
if xcat_systemd_os_release_status "$compat_root"; then
if xcat_explicit_init_status "$compat_root"; then
return 0
else
os_release_status=$?
@@ -49,25 +49,30 @@ xcat_systemd_os_release_status()
}
xcat_target_uses_systemd()
xcat_explicit_init_status()
{
if [ -d /run/systemd/system ]; then
return 0
fi
if [ -L /sbin/init ]; then
init_target=$(readlink /sbin/init 2>/dev/null || true)
if [ -L "${1-}/sbin/init" ]; then
init_target=$(readlink "${1-}/sbin/init" 2>/dev/null || true)
case "$init_target" in
*systemd*) return 0 ;;
*) return 1 ;;
esac
fi
if [ -e /sbin/init ]; then
if [ -e "${1-}/sbin/init" ]; then
return 1
fi
if xcat_systemd_os_release_status; then
xcat_systemd_os_release_status "${1-}"
}
xcat_target_uses_systemd()
{
if [ -d /run/systemd/system ]; then
return 0
fi
if xcat_explicit_init_status; then
return 0
else
os_release_status=$?