# $Id$ PNAME="initscripts" PVER="0.7.0.3" PBUILD="r1" # enable busybox initscripts y|n # disabled atm, busybox missing in tree BUSYBOX_ENABLED="n" SPLIT_PACKAGES="initscripts systemd-initscripts" [[ ${BUSYBOX_ENABLED} = y ]] && SPLIT_PACKAGES+=" busybox-initscripts" PCATEGORIE="sys-apps" HOMEPAGE="http://magellan-linux.net" # the pkgs "coreutils, findutils, sed, gawk, bzip2, tar, rsync, wget" # are needed to fix the /etc/profile issue COMMON_DEPEND=">= sys-apps/coreutils-5 >= sys-apps/findutils-4 >= sys-apps/grep-2 >= sys-apps/sed-4 >= sys-apps/gawk-3 >= app-arch/bzip2-1 >= sys-apps/tar-1 >= net-misc/rsync-2 >= net-misc/wget-1 >= sys-apps/sysvinit-2.88 >= sys-apps/which-2.20" SYSVINIT_DEPEND=">= sys-apps/sysvinit-2.88" SYSTEMD_DEPEND=">= sys-apps/systemd-28" SDEPEND="${COMMON_DEPEND} ${SYSVINIT_DEPEND} ${SYSTEMD_DEPEND}" if [[ ${BUSYBOX_ENABLED} = y ]] then BUSYBOX_DEPEND=">= sys-apps/busybox-1.17" SDEPEND="${SDEPEND} ${BUSYBOX_DEPEND}" fi PROVIDE="virtual/initscripts" SRCFILE="${PNAME}-${PVER}.tar.bz2" SRCDIR="${BUILDDIR}/${PNAME}-${PVER}" # fixes mageversion and system-release; # the makefile uses the date as version number # but for release we want to use the release version RELEASE_MAGEVERSION="svn$(date +%Y%m%d)" RELEASE_SYSTEMRELEASE="Magellan-Linux release 11 (NEXT-${RELEASE_MAGEVERSION})" SRC_URI=( mirror://${PNAME}/${SRCFILE} ) SPECIAL_VARS="BLOCKER" split_info_initscripts() { DESCRIPTION="Magellan Initscripts for sysVinit." DEPEND="${COMMON_DEPEND} ${SYSVINIT_DEPEND}" BLOCKER="sys-apps/systemd-initscripts sys-apps/busybox-initscripts" } split_info_systemd-initscripts() { DESCRIPTION="Magellan Initscripts for systemd." DEPEND="${COMMON_DEPEND} ${SYSTEMD_DEPEND}" BLOCKER="sys-apps/initscripts sys-apps/busybox-initscripts" } if [[ ${BUSYBOX_ENABLED} = y ]] then split_info_busybox-initscripts() { DESCRIPTION="Magellan Initscripts for busybox." DEPEND="${COMMON_DEPEND} ${BUSYBOX_DEPEND}" BLOCKER="sys-apps/initscripts sys-apps/systemd-initscripts" } fi src_prepare() { munpack ${SRCFILE} || die } src_compile() { cd ${SRCDIR} mmake || die } common_install() { local method="$1" cd ${SRCDIR} make DESTDIR=${BINDIR} install_${method} || die install -d ${BINDIR}/etc/env.d || die # always overwrite /etc/mageversion echo 'CONFIG_PROTECT_MASK="/etc/mageversion"' >> ${BINDIR}/etc/env.d/01initscripts || die # always keep this files even if the user edited them local config_protect_ignore config_protect_ignore="/etc/fstab" config_protect_ignore+=" /etc/group" config_protect_ignore+=" /etc/hostname" config_protect_ignore+=" /etc/hosts" config_protect_ignore+=" /etc/inittab" config_protect_ignore+=" /etc/passwd" config_protect_ignore+=" /etc/conf.d/net.eth0" config_protect_ignore+=" /etc/conf.d/net.routes" echo "CONFIG_PROTECT_IGNORE=\"${config_protect_ignore}\"" >> ${BINDIR}/etc/env.d/01initscripts || die # fix mageversion if any release version is given if [[ ! -z ${RELEASE_MAGEVERSION} ]] then echo "${RELEASE_MAGEVERSION}" > ${BINDIR}/etc/mageversion || die fi # fix system-release if any release version is given if [[ ! -z ${RELEASE_SYSTEMRELEASE} ]] then echo "${RELEASE_SYSTEMRELEASE}" > ${BINDIR}/etc/system-release || die fi } src_install_initscripts() { local flavor="sysvinit" cd ${SRCDIR} common_install ${flavor} || die # CONFIG_PROTECT_MASK for /etc/rc.d/init.d install -d ${BINDIR}/etc/env.d || die echo "CONFIG_PROTECT_MASK=\"/etc/rc.d/init.d\"" > ${BINDIR}/etc/env.d/01${flavor} || die local config_protect_ignore config_protect_ignore+=" /etc/modules.autoload.d/kernel-2.4" config_protect_ignore+=" /etc/modules.autoload.d/kernel-2.6" config_protect_ignore+=" /etc/modules.autoload" echo "CONFIG_PROTECT_IGNORE=\"${config_protect_ignore}\"" >> ${BINDIR}/etc/env.d/01${flavor} || die } src_install_systemd-initscripts() { local flavor="systemd" cd ${SRCDIR} common_install ${flavor} || die # CONFIG_PROTECT_MASK for /etc/rc.d/init.d install -d ${BINDIR}/etc/env.d || die local config_protect_ignore config_protect_ignore+=" /etc/systemd/system" echo "CONFIG_PROTECT_IGNORE=\"${config_protect_ignore}\"" >> ${BINDIR}/etc/env.d/01${flavor} || die } if [[ ${BUSYBOX_ENABLED} = y ]] then src_install_busybox-initscripts() { local flavor="busybox" cd ${SRCDIR} common_install ${flavor} || die # CONFIG_PROTECT_MASK for /etc/rc.d/init.d install -d ${BINDIR}/etc/env.d || die echo "CONFIG_PROTECT_MASK=\"/etc/rc.d/init.d\"" > ${BINDIR}/etc/env.d/01${flavor} || die local config_protect_ignore config_protect_ignore+=" /etc/modules.autoload.d/kernel-2.4" config_protect_ignore+=" /etc/modules.autoload.d/kernel-2.6" config_protect_ignore+=" /etc/modules.autoload" echo "CONFIG_PROTECT_IGNORE=\"${config_protect_ignore}\"" >> ${BINDIR}/etc/env.d/01${flavor} || die # add conf.d/kernel to protect current udev|mdev configuration config_protect_ignore+=" /etc/conf.d/kernel" echo "CONFIG_PROTECT_IGNORE=\"${config_protect_ignore}\"" >> ${BINDIR}/etc/env.d/01${flavor} || die } fi postinstall() { # emulate seq; its needed to run rc-config # this fixes some annyoing warning when building # livecd or bootstrapping a system. # this hack will be removed when the toolchain is fixed if [ ! -f /usr/bin/seq ] then echo "Using fake 'seq' command ..." seq() { start=$1 end=$2 for ((i=start; i < end+1; i++)) do echo $i done } export -f seq fi # sysvinit and busybox only! if [ -f ${MROOT}/etc/rc.d/init.d/functions ] then # create service state dir mountpoint # needed by >=initscripts-0.3.2-r1 [ ! -d ${MROOT}/var/lib/init.d ] && install -d ${MROOT}/var/lib/init.d # mark this dir as undeletable touch ${MROOT}/var/lib/init.d/.keep echo "Creating Runlevels ..." local i for i in checkfs cleanfs halt \ loadkeys localnet modules mountfs \ network reboot sendsignals \ setclock swap sysctl consolefont do echo -e "\tAdded ${i} ..." ${MROOT}/sbin/rc-config del ${i} > /dev/null ${MROOT}/sbin/rc-config add ${i} > /dev/null done fi # enable network.service (systemd only) if [ -x ${MROOT}/bin/systemctl ] then mstartunit network.service fi # keep this only for transitional purposes # do not ask the user about following files # # if they exist let config_protect process them # but then remove the protected files, to keep only the original file # # file-root is ${MROOT}/etc local CONFIG_IGNORE="fstab group hostname hosts inittab passwd conf.d/net.eth0 modules.autoload.d/kernel-2.4 modules.autoload.d/kernel-2.6 modules.autoload" local i file path for i in ${CONFIG_IGNORE} do file="$(basename ${i})" path="$(dirname ${i})/" [[ ${path} == ./ ]] && path="" rm -f ${MROOT}/etc/${path}._cfg????_${file} done # initscripts >= 0.5.0: rc file moved to /etc/conf.d/rc if [[ -f ${MROOT}/etc/conf.d/rc ]] && [[ -f ${MROOT}/etc/sysconfig/rc ]] then rm -f ${MROOT}/etc/sysconfig/rc fi # aliases and i368 got renamed to *.conf local i for i in aliases i386 do if [[ -f ${MROOT}/etc/modules.d/${i} ]] then rm ${MROOT}/etc/modules.d/${i} fi done } preinstall() { # ignore this while package building if [[ ! -f /.installrc ]] then local package for package in ${BLOCKER} do if [[ ! -z $(magequery -n ${package##*/}) ]] then echo -e ${COLRED} echo -e "Error: ${package} is installed!!" echo -e "This initscript flavor cannot co-exist ${package}." echo -e "Please uninstall ${package} first!" echo -e ${COLDEFAULT} die "${package} found!" fi done fi } preremove() { # protect these files, that they do not get removed from the system local CONFIG_IGNORE="fstab group hostname hosts passwd" for i in ${CONFIG_IGNORE} do [[ -e ${MROOT}/etc/${i} ]] && touch ${MROOT}/etc/${i} done }