initramfs-tools: more ROOTDIR love.

This commit is contained in:
Juan RP 2011-10-17 18:09:15 +02:00
parent 86d5a9f1a3
commit adcc7b2c39
13 changed files with 46 additions and 42 deletions

View File

@ -11,8 +11,6 @@ chrooted() {
case "${ACTION}" in
pre)
mkdir -p /etc/initramfs-tools/conf.d
# First time install. Can we autodetect the RESUME partition?
if [ -r /proc/swaps ]; then
RESUME=$(tail -n $(($(wc -l /proc/swaps | awk ' { print $1 } ') - 1)) \
@ -29,6 +27,7 @@ pre)
# write conf.d/resume if not in a chroot
if [ -n "${RESUME}" ] && ! chrooted; then
mkdir -p /etc/initramfs-tools/conf.d
echo "RESUME=${RESUME}" > /etc/initramfs-tools/conf.d/resume
fi
;;

View File

@ -15,9 +15,9 @@ prereqs)
;;
esac
. /usr/share/initramfs-tools/hook-functions
. ${ROOTDIR}/usr/share/initramfs-tools/hook-functions
# from libblkid
copy_exec /sbin/blkid /sbin
copy_exec ${ROOTDIR}/sbin/blkid /sbin
exit 0

View File

@ -15,7 +15,7 @@ prereqs)
;;
esac
. /usr/share/initramfs-tools/hook-functions
copy_exec /bin/busybox
. ${ROOTDIR}/usr/share/initramfs-tools/hook-functions
copy_exec ${ROOTDIR}/bin/busybox
exit 0

View File

@ -16,7 +16,7 @@ prereqs)
esac
# Hook to add the DRM/KMS modules
. /usr/share/initramfs-tools/hook-functions
. ${ROOTDIR}/usr/share/initramfs-tools/hook-functions
manual_add_modules fbcon
manual_add_modules intel-agp

View File

@ -20,12 +20,12 @@ if [ "$KEYMAP" != "y" ] && [ "$KEYMAP" != "Y" ]; then
exit 0
fi
[ ! -x /sbin/loadkeys -a ! -x /sbin/dumpkeys ] && exit 0
[ ! -x ${ROOTDIR}/sbin/loadkeys -a ! -x ${ROOTDIR}/sbin/dumpkeys ] && exit 0
. /usr/share/initramfs-tools/hook-functions
. ${ROOTDIR}/usr/share/initramfs-tools/hook-functions
/sbin/dumpkeys > ${DESTDIR}/kmap-tmp
/sbin/loadkeys -u -b ${DESTDIR}/kmap-tmp > ${DESTDIR}/etc/bkeymap
${ROOTDIR}/sbin/dumpkeys > ${DESTDIR}/kmap-tmp
${ROOTDIR}/sbin/loadkeys -u -b ${DESTDIR}/kmap-tmp > ${DESTDIR}/etc/bkeymap
rm -f ${DESTDIR}/kmap-tmp
exit 0

View File

@ -15,9 +15,9 @@ prereqs)
;;
esac
. /usr/share/initramfs-tools/hook-functions
. ${ROOTDIR}/usr/share/initramfs-tools/hook-functions
# resume from klibc.
copy_exec /bin/resume /bin
copy_exec ${ROOTDIR}/bin/resume /bin
exit 0

View File

@ -15,12 +15,12 @@ prereqs)
;;
esac
. /usr/share/initramfs-tools/hook-functions
. ${ROOTDIR}/usr/share/initramfs-tools/hook-functions
# module-init-tools
copy_exec /sbin/modprobe /sbin
copy_exec /sbin/rmmod /sbin
copy_exec ${ROOTDIR}/sbin/modprobe /sbin
copy_exec ${ROOTDIR}/sbin/rmmod /sbin
mkdir -p "${DESTDIR}/etc/modprobe.d"
cp -a /etc/modprobe.d/* "${DESTDIR}/etc/modprobe.d/"
cp -a ${ROOTDIR}/etc/modprobe.d/* "${DESTDIR}/etc/modprobe.d/"
exit 0

View File

@ -17,7 +17,7 @@ esac
# Hooks for loading thermal bits into the initramfs
. /usr/share/initramfs-tools/hook-functions
. ${ROOTDIR}/usr/share/initramfs-tools/hook-functions
case "$DPKG_ARCH" in
# copy the right modules

View File

@ -11,5 +11,7 @@ if [ ! -x /usr/sbin/update-initramfs ]; then
exit 0
fi
env ROOTDIR="." update-initramfs -c -t -k ${VERSION}
export ROOTDIR="."
update-initramfs -c -t -k ${VERSION}
exit $?

View File

@ -11,5 +11,6 @@ if [ ! -x /usr/sbin/update-initramfs ]; then
exit 0
fi
env ROOTDIR="." update-initramfs -d -t -k ${VERSION}
export ROOTDIR="."
update-initramfs -d -t -k ${VERSION}
exit $?

View File

@ -5,7 +5,7 @@ export PATH='/usr/bin:/sbin:/bin'
# Defaults
keep="n"
CONFDIR="/etc/initramfs-tools"
CONFDIR="${ROOTDIR}/etc/initramfs-tools"
verbose="n"
OPTIONS=`getopt -o c:d:ko:r:v -n "$0" -- "$@"`
@ -57,12 +57,12 @@ while true; do
done
# For dependency ordered mkinitramfs hook scripts.
. /usr/share/initramfs-tools/scripts/functions
. /usr/share/initramfs-tools/hook-functions
. ${ROOTDIR}/usr/share/initramfs-tools/scripts/functions
. ${ROOTDIR}/usr/share/initramfs-tools/hook-functions
. "${CONFDIR}/initramfs.conf"
EXTRA_CONF=''
for i in /usr/share/initramfs-tools/conf.d/* ${CONFDIR}/conf.d/*; do
for i in ${ROOTDIR}/usr/share/initramfs-tools/conf.d/* ${CONFDIR}/conf.d/*; do
[ -e $i ] && EXTRA_CONF="${EXTRA_CONF} $(basename $i \
| grep '^[[:alnum:]][[:alnum:]\._-]*$' | grep -v '\.dpkg-.*$')";
done
@ -71,13 +71,13 @@ done
for i in ${EXTRA_CONF}; do
if [ -e ${CONFDIR}/conf.d/${i} ]; then
. ${CONFDIR}/conf.d/${i}
elif [ -e /usr/share/initramfs-tools/conf.d/${i} ]; then
. /usr/share/initramfs-tools/conf.d/${i}
elif [ -e ${ROOTDIR}/usr/share/initramfs-tools/conf.d/${i} ]; then
. ${ROOTDIR}/usr/share/initramfs-tools/conf.d/${i}
fi
done
# source package confs
for i in /usr/share/initramfs-tools/conf-hooks.d/*; do
for i in ${ROOTDIR}/usr/share/initramfs-tools/conf-hooks.d/*; do
if [ -e "${i}" ]; then
. "${i}"
fi
@ -105,7 +105,7 @@ fi
# Check that we're using a new enough kernel version, first for ourselves,
# then for each of the hooks, which can have a MINKVER variable defined
check_minkver ${version}
check_minkver ${version} /usr/share/initramfs-tools/hooks
check_minkver ${version} ${ROOTDIR}/usr/share/initramfs-tools/hooks
check_minkver ${version} ${CONFDIR}/hooks
case "${version}" in
@ -155,11 +155,11 @@ fi
MODULESDIR="/lib/modules/${version}"
if [ ! -e "${MODULESDIR}" ]; then
if [ ! -e "${ROOTDIR}${MODULESDIR}" ]; then
echo "WARNING: missing ${MODULESDIR}"
echo "Device driver support needs thus be built-in linux image!"
fi
if [ ! -e "${MODULESDIR}/modules.dep" ]; then
if [ ! -e "${ROOTDIR}${MODULESDIR}/modules.dep" ]; then
depmod ${version}
fi
@ -168,7 +168,7 @@ chmod 755 "${DESTDIR}"
# do not execute cache_run_scripts() if mounted with noexec
NOEXEC=""
if [ -r /etc/mtab ]; then
if [ -r ${ROOTDIR}/etc/mtab ]; then
fs=$(df -P $DESTDIR | tail -1 | awk '{print $6}')
if [ -n "$fs" ] && mount | grep -q "on $fs .*noexec" ; then
NOEXEC=1
@ -198,13 +198,13 @@ for d in bin conf/conf.d etc lib/modules run sbin scripts ${MODULESDIR}; do
done
# Copy the modules.order file in
if [ -f "${MODULESDIR}/modules.order" ]; then
cp -p "${MODULESDIR}/modules.order" \
if [ -f "${ROOTDIR}${MODULESDIR}/modules.order" ]; then
cp -p "${ROOTDIR}${MODULESDIR}/modules.order" \
"${DESTDIR}${MODULESDIR}/modules.order"
fi
# MODULES=list case. Always honour.
for x in "${CONFDIR}/modules" /usr/share/initramfs-tools/modules.d/*; do
for x in "${CONFDIR}/modules" ${ROOTDIR}/usr/share/initramfs-tools/modules.d/*; do
if [ -f "${x}" ]; then
add_modules_from_file "${x}"
fi
@ -238,14 +238,14 @@ hidden_dep_add_modules
# Have to do each file, because cpio --dereference doesn't recurse down
# symlinks.
cp -p /usr/share/initramfs-tools/init ${DESTDIR}/init
cp -p ${ROOTDIR}/usr/share/initramfs-tools/init ${DESTDIR}/init
# add existant boot scripts
for b in $(cd /usr/share/initramfs-tools/scripts/ && find -L . \
for b in $(cd ${ROOTDIR}/usr/share/initramfs-tools/scripts/ && find -L . \
-regextype posix-extended -regex '.*/[[:alnum:]\._-]+$' -type f); do
[ -d "${DESTDIR}/scripts/$(dirname "${b}")" ] \
|| mkdir -p "${DESTDIR}/scripts/$(dirname "${b}")"
cp -p "/usr/share/initramfs-tools/scripts/${b}" \
cp -p "${ROOTDIR}/usr/share/initramfs-tools/scripts/${b}" \
"${DESTDIR}/scripts/$(dirname "${b}")/"
done
for b in $(cd "${CONFDIR}/scripts" && find -L . \
@ -259,8 +259,8 @@ cp -p "${CONFDIR}/initramfs.conf" ${DESTDIR}/conf
for i in ${EXTRA_CONF}; do
if [ -e "${CONFDIR}/conf.d/${i}" ]; then
copy_exec "${CONFDIR}/conf.d/${i}" /conf/conf.d
elif [ -e "/usr/share/initramfs-tools/conf.d/${i}" ]; then
copy_exec "/usr/share/initramfs-tools/conf.d/${i}" /conf/conf.d
elif [ -e "${ROOTDIR}/usr/share/initramfs-tools/conf.d/${i}" ]; then
copy_exec "${ROOTDIR}/usr/share/initramfs-tools/conf.d/${i}" /conf/conf.d
fi
done
@ -274,7 +274,7 @@ if ! command -v ldd >/dev/null 2>&1 ; then
exit 1
fi
run_scripts /usr/share/initramfs-tools/hooks
run_scripts ${ROOTDIR}/usr/share/initramfs-tools/hooks
run_scripts "${CONFDIR}"/hooks
# cache boot run order
@ -291,7 +291,7 @@ depmod -a -b "${DESTDIR}" ${version}
rm -f "${DESTDIR}/lib/modules/${version}"/modules.*map
# make sure that library search path is up to date
cp -ar /etc/ld.so.conf* "$DESTDIR"/etc/
cp -ar ${ROOTDIR}/etc/ld.so.conf* "$DESTDIR"/etc/
if ! ldconfig -r "$DESTDIR" ; then
[ $(id -u) != "0" ] \
&& echo "ldconfig might need uid=0 (root) for chroot()" >&2

View File

@ -1,5 +1,7 @@
#!/bin/sh
export ROOTDIR="$ROOTDIR"
INITRAMFS_TOOLS_VERSION=@VERSION@
STATEDIR=${ROOTDIR}/var/lib/initramfs-tools
BOOTDIR=${ROOTDIR}/boot

View File

@ -1,6 +1,6 @@
# Template file for 'initramfs-tools'
pkgname=initramfs-tools
_localver=106 # This is the XBPS version
_localver=107 # This is the XBPS version
_distver=0.99 # This should match debian version
version=${_distver}.${_localver}
build_style=custom-install