ENHANCEMENT bug 83771. Add support for LABEL= and UUID=
authorEric Edgar <rocket@gentoo.org>
Mon, 11 Jul 2005 20:02:22 +0000 (20:02 +0000)
committerEric Edgar <rocket@gentoo.org>
Mon, 11 Jul 2005 20:02:22 +0000 (20:02 +0000)
git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/genkernel/trunk@249 67a159dc-881f-0410-a524-ba9dfbe2cb84

gen_cmdline.sh
gen_compile.sh
gen_determineargs.sh
gen_initramfs.sh
gen_initrd.sh
generic/initrd.scripts
generic/linuxrc
genkernel
genkernel.conf

index 3d031f1d8e67b37f084dab13afc158ee662d9ac3..3d8f36b65649b25ba10bd2639bd4e122eb174b90 100755 (executable)
@@ -71,6 +71,7 @@ longusage() {
   echo "       --dmraid                Include DMRAID support"
   echo "       --bootloader=grub       Add new kernel to GRUB configuration"
   echo "       --linuxrc=<file>        Specifies a user created linuxrc"
+  echo "       --disklabel             Include disk label and uuid support in your initrd"
   echo "  Internals"
   echo "       --arch-override=<arch>  Force to arch instead of autodetect"
   echo "       --cachedir=<dir>        Override the default cache location"
@@ -399,6 +400,10 @@ parse_cmdline() {
                        GENERATE_Z_IMAGE=1
                        print_info 2 "GENERATE_Z_IMAGE: $GENERATE_Z_IMAGE"
              ;;
+             --disklabel)
+                     CMD_DISKLABEL=1
+                     print_info 2 "CMD_DISKLABEL: $CMD_DISKLABEL"
+             ;;
              all)
                      BUILD_KERNEL=1
                      BUILD_MODULES=1
index b0f7b8d678fe0118ecb3f6ea96490e1faf153de8..d2b9f953fee8a2af914346288e72d39fa6cf40f8 100644 (file)
@@ -745,3 +745,33 @@ compile_udev() {
        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
+}
index f6ce9248db603748fbfba3197f746deb2dbd723e..e2484fc807149e2b95cfc86e8495bab6b558d9e0 100644 (file)
@@ -54,6 +54,13 @@ get_KV() {
                fi
 
        fi
+
+       if isTrue "${CMD_DISKLABEL}"
+       then
+               DISKLABEL=1
+       else
+               DISKLABEL=0
+       fi
 }
 
 determine_real_args() {
@@ -176,6 +183,7 @@ determine_real_args() {
        DMRAID_BINCACHE=`cache_replace "${DMRAID_BINCACHE}"`
        UNIONFS_BINCACHE=`cache_replace "${UNIONFS_BINCACHE}"`
        UNIONFS_MODULES_BINCACHE=`cache_replace "${UNIONFS_MODULES_BINCACHE}"`
+       BLKID_BINCACHE=`cache_replace "${BLKID_BINCACHE}"`
   
        DEFAULT_KERNEL_CONFIG=`arch_replace "${DEFAULT_KERNEL_CONFIG}"`
        BUSYBOX_CONFIG=`arch_replace "${BUSYBOX_CONFIG}"`
@@ -192,6 +200,7 @@ determine_real_args() {
        DMRAID_BINCACHE=`arch_replace "${DMRAID_BINCACHE}"`
        UNIONFS_BINCACHE=`arch_replace "${UNIONFS_BINCACHE}"`
        UNIONFS_MODULES_BINCACHE=`arch_replace "${UNIONFS_MODULES_BINCACHE}"`
+       BLKID_BINCACHE=`arch_replace "${BLKID_BINCACHE}"`
        
        if [ "${CMD_BOOTSPLASH}" != '' ]
        then
index bd52559b8d13af99e809e89cdd263e6a8617e0fb..389ee18269ecc77b6d90fa006d8c9e506e5dbe17 100644 (file)
@@ -99,6 +99,21 @@ create_udev_cpio(){
        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(){
        if [ -d "${TEMP}/initramfs-devfs-temp" ]
        then
@@ -419,6 +434,10 @@ merge_initramfs_cpio_archives(){
        then
                MERGE_LIST="${MERGE_LIST} initramfs-udev-${UDEV_VER}.cpio.gz"
        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 ]
        then
                MERGE_LIST="${MERGE_LIST} initramfs-unionfs-${UNIONFS_VER}-tools.cpio.gz"
@@ -549,6 +568,12 @@ create_initramfs() {
                print_info 1 "initramfs: Not copying modules..."
        fi
        
+       if [ "${DISKLABEL}" -eq '1' ]
+       then
+               print_info 1 "        >> Creating blkid cpio archive..."
+               create_blkid_cpio
+       fi
+               
        create_gensplash
        
        if [ "${INITRAMFS_OVERLAY}" != '' ]
index 18ae9406b28afb1cecce7a61fe3d479f058e26f7..25896a6e74fefb0616b8e3d4d2c0768d24fe605f 100644 (file)
@@ -57,6 +57,14 @@ create_base_initrd_sys() {
        MAKEDEV std
        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" ||
                gen_die 'Could not copy busybox from bincache!'
        bunzip2 "${TEMP}/initrd-temp/bin/busybox.bz2" ||
index a06052308bd50d4a1a821a778a15340fd3601add..100648c65b2b8db8daef6cbddceebd62fc88dac3 100644 (file)
@@ -5,10 +5,23 @@ backup() {
        echo -ne "\033[0G\033[0K"
 }
 
+strlen()
+{
+       if [ -z "$1" ]
+       then
+               echo "usage: strlen <variable_name>"
+               die
+       fi
+       eval echo "\${#${1}}"
+}
+
 parse_opt() {
        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
 }
index 7087227ff82d61c201c35b6e8e924e2614b00f18..859345a4dfe3fda0357a764108725de5cd42e1f1 100644 (file)
@@ -256,7 +256,41 @@ while true
 do
        while [ "${got_good_root}" != '1' ]
        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' ]
                then
                        run_shell
index 62a8914013ae5cd3224e2d3d8f9bdb57d25174ec..64ee5b5c7a90ec000112863697e4dac168516116 100755 (executable)
--- a/genkernel
+++ b/genkernel
@@ -267,6 +267,8 @@ then
                        compile_modutils
                fi
        fi
+       
+       [ "${DISKLABEL}" -eq '1' ] && compile_e2fsprogs
 
        if [ "${PAT}" -gt '4' -a "${UDEV}" -eq '1' ] 
        then
index 8955c4076eab9b0301b720b5a1e22e0a1b0ea041..37891cde89a62c39ac7c156fca632f0e945804e2 100755 (executable)
@@ -115,3 +115,9 @@ UNIONFS_DIR="unionfs-${UNIONFS_VER}"
 UNIONFS_SRCTAR="${GK_SHARE}/pkg/unionfs-${UNIONFS_VER}.tar.gz"
 UNIONFS_BINCACHE="%%CACHE%%/unionfs-${UNIONFS_VER}-tools-%%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"
+