# $Id$ PNAME="initscripts" PVER="0.8.8" PBUILD="r1" # enable busybox initscripts y|n # disabled atm, busybox missing in tree BUSYBOX_ENABLED="n" # enable sysvinit initscripts y|n # disabled, we have replaced sysvinit with systemd SYSVINIT_ENABLED="n" SPLIT_PACKAGES="systemd-initscripts" [[ ${BUSYBOX_ENABLED} = y ]] && SPLIT_PACKAGES+=" busybox-initscripts" [[ ${SYSVINIT_ENABLED} = y ]] && SPLIT_PACKAGES+=" initscripts" PCAT="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/base-files-0.5 >= sys-apps/mage-release-R11 >= sys-apps/coreutils-5 >= sys-apps/findutils-4 >= sys-apps/grep-2 >= app-shells/bash-4 >= virtual/sed >= sys-apps/gawk-3 >= app-arch/bzip2-1 >= sys-apps/tar-1 >= net-misc/rsync-2 >= net-misc/wget-1" SYSTEMD_DEPEND=">= sys-apps/systemd-197" SDEPEND="${COMMON_DEPEND} ${SYSTEMD_DEPEND} >= dev-util/pkgconfig-0.25" if [[ ${BUSYBOX_ENABLED} = y ]] then BUSYBOX_DEPEND=">= sys-apps/busybox-1.17" SDEPEND="${SDEPEND} ${BUSYBOX_DEPEND}" fi if [[ ${SYSVINIT_ENABLED} = y ]] then SYSVINIT_DEPEND=">= sys-apps/sysvinit-2.88" SDEPEND="${SDEPEND} ${SYSVINIT_DEPEND}" fi PROVIDE="virtual/initscripts" SRCFILE="${PNAME}-${PVER}.tar.bz2" SRCDIR="${BUILDDIR}/${PNAME}-${PVER}" sminclude mtools systemd SRC_URI=( mirror://${PNAME}/${SRCFILE} ) SPECIAL_VARS="BLOCKER SYSVINIT_ENABLED BUSYBOX_ENABLED" if [[ ${SYSVINIT_ENABLED} = y ]] then split_info_initscripts() { DESCRIPTION="Magellan Initscripts for sysVinit." DEPEND="${COMMON_DEPEND} ${SYSVINIT_DEPEND}" BLOCKER="sys-apps/systemd-initscripts sys-apps/busybox-initscripts" } fi 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" local MCONFIG local config_protect_ignore cd ${SRCDIR} make DESTDIR=${BINDIR} LIBDIR=/usr/lib SBINDIR=/usr/sbin install_${method} || die } if [[ ${SYSVINIT_ENABLED} = y ]] then src_install_initscripts() { cd ${SRCDIR} common_install sysvinit || die } fi src_install_systemd-initscripts() { cd ${SRCDIR} common_install systemd || die # install these binaries for old sysvinit compat only if [[ ${SYSVINIT_ENABLED} = n ]] then minstalldir /usr/sbin || die minstallexec ${SRCDIR}/sysvinit/sbin/rc-config /usr/sbin || die minstalldir /etc/rc.d/init.d || die minstallfile ${SRCDIR}/sysvinit/rc/functions /etc/rc.d/init.d/ || die fi } if [[ ${BUSYBOX_ENABLED} = y ]] then src_install_busybox-initscripts() { cd ${SRCDIR} common_install busybox || 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 # move old /etc/conf.d/locale to /etc/locale.conf if [ -f ${MROOT}/etc/conf.d/locale ] then echo "Moving ${MROOT}/etc/conf.d/locale -> ${MROOT}/etc/locale.conf" cp ${MROOT}/etc/conf.d/locale ${MROOT}/etc/locale.conf rm ${MROOT}/etc/conf.d/locale fi # generate a valid /etc/vconsole.conf from old data if [ -f ${MROOT}/etc/conf.d/consolefont ] && [ -f ${MROOT}/etc/conf.d/keymap ] then echo "Generating ${MROOT}/etc/vconsole.conf with /etc/conf.d data" local consolefont=$(source ${MROOT}/etc/conf.d/consolefont; echo "${CONSOLEFONT}") local keymap=$(source ${MROOT}/etc/conf.d/keymap; echo "${KEYMAP}") cat > ${MROOT}/etc/vconsole.conf << EOF KEYMAP=${keymap} FONT=${consolefont} FONT_MAP=8851-1_to_uni EOF echo "Deleting old ${MROOT}/etc/conf.d/consolefont" rm ${MROOT}/etc/conf.d/consolefont echo "Deleting old ${MROOT}/etc/conf.d/keymap" rm ${MROOT}/etc/conf.d/keymap fi # move old sysctl.conf to new location (systemd only) if [ -x ${MROOT}/usr/bin/systemctl ] && [ -f ${MROOT}/etc/sysctl.conf ] then [ -d ${MROOT}/etc/sysctl.d ] || install -d ${MROOT}/etc/sysctl.d # only copy the file if they are not the same if ! diff -Naur ${MROOT}/etc/sysctl.conf ${MROOT}/etc/sysctl.d/99-sysctl.conf > /dev/null then cp ${MROOT}/etc/sysctl.conf ${MROOT}/etc/sysctl.d/99-sysctl.conf fi rm ${MROOT}/etc/sysctl.conf fi # sysvinit and busybox only! if [ -f ${MROOT}/etc/rc.d/init.d/functions ] && [[ ${BUSYBOX_ENABLED} = y ]] || [[ ${SYSVINIT_ENABLED} = y ]] 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 if [[ -x ${MROOT}/usr/sbin/rc-config ]] then 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}/usr/sbin/rc-config del ${i} > /dev/null ${MROOT}/usr/sbin/rc-config add ${i} > /dev/null done fi fi # enable network.service (systemd only) if [ -x ${MROOT}/usr/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 hostname hosts inittab 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 hostname hosts" for i in ${CONFIG_IGNORE} do [[ -e ${MROOT}/etc/${i} ]] && touch ${MROOT}/etc/${i} done }