ENHANCEMENT bug 83771. Add support for LABEL= and UUID=

git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/genkernel/trunk@249 67a159dc-881f-0410-a524-ba9dfbe2cb84
cleanup-cruft
Eric Edgar 20 years ago
parent 337696ff03
commit 77b46e6aef

@ -71,6 +71,7 @@ longusage() {
echo " --dmraid Include DMRAID support" echo " --dmraid Include DMRAID support"
echo " --bootloader=grub Add new kernel to GRUB configuration" echo " --bootloader=grub Add new kernel to GRUB configuration"
echo " --linuxrc=<file> Specifies a user created linuxrc" echo " --linuxrc=<file> Specifies a user created linuxrc"
echo " --disklabel Include disk label and uuid support in your initrd"
echo " Internals" echo " Internals"
echo " --arch-override=<arch> Force to arch instead of autodetect" echo " --arch-override=<arch> Force to arch instead of autodetect"
echo " --cachedir=<dir> Override the default cache location" echo " --cachedir=<dir> Override the default cache location"
@ -399,6 +400,10 @@ parse_cmdline() {
GENERATE_Z_IMAGE=1 GENERATE_Z_IMAGE=1
print_info 2 "GENERATE_Z_IMAGE: $GENERATE_Z_IMAGE" print_info 2 "GENERATE_Z_IMAGE: $GENERATE_Z_IMAGE"
;; ;;
--disklabel)
CMD_DISKLABEL=1
print_info 2 "CMD_DISKLABEL: $CMD_DISKLABEL"
;;
all) all)
BUILD_KERNEL=1 BUILD_KERNEL=1
BUILD_MODULES=1 BUILD_MODULES=1

@ -745,3 +745,33 @@ compile_udev() {
fi fi
} }
compile_e2fsprogs() {
if [ ! -f "${BLKID_BINCACHE}" ]
then
[ ! -f "${E2FSPROGS_SRCTAR}" ] &&
gen_die "Could not find e2fsprogs source tarball: ${E2FSPROGS_SRCTAR}. Please place it there, or place another version, changing /etc/genkernel.conf as necessary!"
cd "${TEMP}"
rm -rf "${E2FSPROGS_DIR}"
tar -zxpf "${E2FSPROGS_SRCTAR}"
[ ! -d "${E2FSPROGS_DIR}" ] &&
gen_die "e2fsprogs directory ${E2FSPROGS_DIR} invalid"
cd "${E2FSPROGS_DIR}"
print_info 1 'e2fsprogs: >> Configuring...'
./configure --with-ldopts=-static >> ${DEBUGFILE} 2>&1 ||
gen_die 'Configuring e2fsprogs failed!'
print_info 1 'e2fsprogs: >> Compiling...'
MAKE=${UTILS_MAKE} compile_generic "" ""
print_info 1 'blkid: >> Copying to cache...'
[ -f "${TEMP}/${E2FSPROGS_DIR}/misc/blkid" ] ||
gen_die 'Blkid executable does not exist!'
strip "${TEMP}/${E2FSPROGS_DIR}/misc/blkid" ||
gen_die 'Could not strip blkid binary!'
bzip2 "${TEMP}/${E2FSPROGS_DIR}/misc/blkid" ||
gen_die 'bzip2 compression of blkid failed!'
mv "${TEMP}/${E2FSPROGS_DIR}/misc/blkid.bz2" "${BLKID_BINCACHE}" ||
gen_die 'Could not copy the blkid binary to the package directory, does the directory exist?'
cd "${TEMP}"
rm -rf "${E2FSPROGS_DIR}" > /dev/null
fi
}

@ -54,6 +54,13 @@ get_KV() {
fi fi
fi fi
if isTrue "${CMD_DISKLABEL}"
then
DISKLABEL=1
else
DISKLABEL=0
fi
} }
determine_real_args() { determine_real_args() {
@ -176,6 +183,7 @@ determine_real_args() {
DMRAID_BINCACHE=`cache_replace "${DMRAID_BINCACHE}"` DMRAID_BINCACHE=`cache_replace "${DMRAID_BINCACHE}"`
UNIONFS_BINCACHE=`cache_replace "${UNIONFS_BINCACHE}"` UNIONFS_BINCACHE=`cache_replace "${UNIONFS_BINCACHE}"`
UNIONFS_MODULES_BINCACHE=`cache_replace "${UNIONFS_MODULES_BINCACHE}"` UNIONFS_MODULES_BINCACHE=`cache_replace "${UNIONFS_MODULES_BINCACHE}"`
BLKID_BINCACHE=`cache_replace "${BLKID_BINCACHE}"`
DEFAULT_KERNEL_CONFIG=`arch_replace "${DEFAULT_KERNEL_CONFIG}"` DEFAULT_KERNEL_CONFIG=`arch_replace "${DEFAULT_KERNEL_CONFIG}"`
BUSYBOX_CONFIG=`arch_replace "${BUSYBOX_CONFIG}"` BUSYBOX_CONFIG=`arch_replace "${BUSYBOX_CONFIG}"`
@ -192,6 +200,7 @@ determine_real_args() {
DMRAID_BINCACHE=`arch_replace "${DMRAID_BINCACHE}"` DMRAID_BINCACHE=`arch_replace "${DMRAID_BINCACHE}"`
UNIONFS_BINCACHE=`arch_replace "${UNIONFS_BINCACHE}"` UNIONFS_BINCACHE=`arch_replace "${UNIONFS_BINCACHE}"`
UNIONFS_MODULES_BINCACHE=`arch_replace "${UNIONFS_MODULES_BINCACHE}"` UNIONFS_MODULES_BINCACHE=`arch_replace "${UNIONFS_MODULES_BINCACHE}"`
BLKID_BINCACHE=`arch_replace "${BLKID_BINCACHE}"`
if [ "${CMD_BOOTSPLASH}" != '' ] if [ "${CMD_BOOTSPLASH}" != '' ]
then then

@ -99,6 +99,21 @@ create_udev_cpio(){
rm -rf "${TEMP}/initramfs-udev-temp" > /dev/null rm -rf "${TEMP}/initramfs-udev-temp" > /dev/null
} }
create_blkid_cpio(){
if [ -d "${TEMP}/initramfs-blkid-temp" ]
then
rm -r "${TEMP}/initramfs-blkid-temp/"
fi
cd ${TEMP}
mkdir -p "${TEMP}/initramfs-blkid-temp/bin/"
[ "${DISKLABEL}" -eq '1' ] && { /bin/bzip2 -dc "${BLKID_BINCACHE}" > "${TEMP}/initramfs-blkid-temp/bin/blkid" ||
gen_die "Could not extract blkid binary cache!"; }
chmod a+x "${TEMP}/initramfs-blkid-temp/bin/blkid"
cd "${TEMP}/initramfs-blkid-temp/"
find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_DIR}/cpio/initramfs-blkid-${E2FSPROGS_VER}.cpio.gz
rm -rf "${TEMP}/initramfs-blkid-temp" > /dev/null
}
create_devfs_cpio(){ create_devfs_cpio(){
if [ -d "${TEMP}/initramfs-devfs-temp" ] if [ -d "${TEMP}/initramfs-devfs-temp" ]
then then
@ -419,6 +434,10 @@ merge_initramfs_cpio_archives(){
then then
MERGE_LIST="${MERGE_LIST} initramfs-udev-${UDEV_VER}.cpio.gz" MERGE_LIST="${MERGE_LIST} initramfs-udev-${UDEV_VER}.cpio.gz"
fi fi
if [ "${DISKLABEL}" -eq '1' -a -e ${CACHE_DIR}/cpio/initramfs-blkid-${E2FSPROGS_VER}.cpio.gz ]
then
MERGE_LIST="${MERGE_LIST} initramfs-blkid-${E2FSPROGS_VER}.cpio.gz"
fi
if [ "${UNIONFS}" -eq '1' -a -e ${CACHE_DIR}/cpio/initramfs-unionfs-${UNIONFS_VER}-tools.cpio.gz ] if [ "${UNIONFS}" -eq '1' -a -e ${CACHE_DIR}/cpio/initramfs-unionfs-${UNIONFS_VER}-tools.cpio.gz ]
then then
MERGE_LIST="${MERGE_LIST} initramfs-unionfs-${UNIONFS_VER}-tools.cpio.gz" MERGE_LIST="${MERGE_LIST} initramfs-unionfs-${UNIONFS_VER}-tools.cpio.gz"
@ -549,6 +568,12 @@ create_initramfs() {
print_info 1 "initramfs: Not copying modules..." print_info 1 "initramfs: Not copying modules..."
fi fi
if [ "${DISKLABEL}" -eq '1' ]
then
print_info 1 " >> Creating blkid cpio archive..."
create_blkid_cpio
fi
create_gensplash create_gensplash
if [ "${INITRAMFS_OVERLAY}" != '' ] if [ "${INITRAMFS_OVERLAY}" != '' ]

@ -57,6 +57,14 @@ create_base_initrd_sys() {
MAKEDEV std MAKEDEV std
MAKEDEV console MAKEDEV console
if [ "${DISKLABEL}" -eq '1' ]; then
cp "${BLKID_BINCACHE}" "${TEMP}/initrd-temp/bin/blkid.bz2" ||
gen_die 'Could not copy blkid from bincache!'
bunzip2 "${TEMP}/initrd-temp/bin/blkid.bz2" ||
gen_die 'Could not uncompress blkid!'
chmod +x "${TEMP}/initrd-temp/bin/blkid"
fi
cp "${BUSYBOX_BINCACHE}" "${TEMP}/initrd-temp/bin/busybox.bz2" || cp "${BUSYBOX_BINCACHE}" "${TEMP}/initrd-temp/bin/busybox.bz2" ||
gen_die 'Could not copy busybox from bincache!' gen_die 'Could not copy busybox from bincache!'
bunzip2 "${TEMP}/initrd-temp/bin/busybox.bz2" || bunzip2 "${TEMP}/initrd-temp/bin/busybox.bz2" ||

@ -5,10 +5,23 @@ backup() {
echo -ne "\033[0G\033[0K" echo -ne "\033[0G\033[0K"
} }
strlen()
{
if [ -z "$1" ]
then
echo "usage: strlen <variable_name>"
die
fi
eval echo "\${#${1}}"
}
parse_opt() { parse_opt() {
case "$1" in case "$1" in
*\=*) *\=*)
echo "$1" | cut -f2 -d= local key_name="`echo "$1" | cut -f1 -d=`"
local key_len=`strlen key_name`
local value_start=$((key_len+2))
echo "$1" | cut -c ${value_start}-
;; ;;
esac esac
} }

@ -256,6 +256,40 @@ while true
do do
while [ "${got_good_root}" != '1' ] while [ "${got_good_root}" != '1' ]
do do
case "${REAL_ROOT}" in
LABEL\=*|UUID\=*)
ROOT_DEV=""
retval=1
if [ "${retval}" -ne '0' ]; then
ROOT_DEV=`findfs "${REAL_ROOT}" 2>/dev/null`
retval=$?
fi
if [ "$retval" -ne '0' ]; then
ROOT_DEV=`busybox findfs "${REAL_ROOT}" 2>/dev/null`
retval=$?
fi
if [ "${retval}" -ne '0' ]; then
ROOT_DEV=`blkid -t "${REAL_ROOT}" | cut -d ":" -f 1 2>/dev/null`
retval=$?
fi
if [ "${retval}" -eq '0' ] && [ -n "${ROOT_DEV}" ]; then
good_msg "Detected real_root=${ROOT_DEV}"
REAL_ROOT="${ROOT_DEV}"
else
bad_msg "Could not find root block device: ${REAL_ROOT}"
echo ' Please specify a device to boot, or "shell" for a shell...'
echo -n 'boot() :: '
read REAL_ROOT
got_good_root=0
continue
fi
;;
esac
if [ "${REAL_ROOT}" = 'shell' ] if [ "${REAL_ROOT}" = 'shell' ]
then then

@ -268,6 +268,8 @@ then
fi fi
fi fi
[ "${DISKLABEL}" -eq '1' ] && compile_e2fsprogs
if [ "${PAT}" -gt '4' -a "${UDEV}" -eq '1' ] if [ "${PAT}" -gt '4' -a "${UDEV}" -eq '1' ]
then then
compile_udev compile_udev

@ -115,3 +115,9 @@ UNIONFS_DIR="unionfs-${UNIONFS_VER}"
UNIONFS_SRCTAR="${GK_SHARE}/pkg/unionfs-${UNIONFS_VER}.tar.gz" UNIONFS_SRCTAR="${GK_SHARE}/pkg/unionfs-${UNIONFS_VER}.tar.gz"
UNIONFS_BINCACHE="%%CACHE%%/unionfs-${UNIONFS_VER}-tools-%%ARCH%%.tar.bz2" UNIONFS_BINCACHE="%%CACHE%%/unionfs-${UNIONFS_VER}-tools-%%ARCH%%.tar.bz2"
UNIONFS_MODULES_BINCACHE="%%CACHE%%/unionfs-${UNIONFS_VER}-modules-%%KV%%-%%ARCH%%.tar.bz2" UNIONFS_MODULES_BINCACHE="%%CACHE%%/unionfs-${UNIONFS_VER}-modules-%%KV%%-%%ARCH%%.tar.bz2"
E2FSPROGS_VER="1.38"
E2FSPROGS_DIR="e2fsprogs-${E2FSPROGS_VER}"
E2FSPROGS_SRCTAR="${GK_SHARE}/pkg/e2fsprogs-${E2FSPROGS_VER}.tar.gz"
BLKID_BINCACHE="%%CACHE%%/blkid-${E2FSPROGS_VER}-%%ARCH%%.bz2"

Loading…
Cancel
Save