From e19f440a0df591a3e5174218d3bcc6d01ffb07ee Mon Sep 17 00:00:00 2001 From: Ethan Benson Date: Mon, 26 Apr 2004 00:27:48 +0000 Subject: [PATCH] Add support for initrd detection to yabootconfig * ybin/yabootconfig: If detected kernel appears to have a corresponding initrd image then include an initrd= line in generated yaboot.conf. git-archimport-id: erbenson@alaska.net--public/yaboot--devel--1.3--patch-69 --- 0arch-timestamps0 | 240 +++++++++++++++++++++++----------------------- ChangeLog | 14 +++ ybin/yabootconfig | 130 ++++++++++++++++++++++++- 3 files changed, 262 insertions(+), 122 deletions(-) diff --git a/0arch-timestamps0 b/0arch-timestamps0 index 6580764..3c70bdd 100644 --- a/0arch-timestamps0 +++ b/0arch-timestamps0 @@ -1,120 +1,120 @@ -./0arch-timestamps0 1080450123 1082248073 -./BUGS 1077455728 1000991730 -./COPYING 1077455728 1000991730 -./ChangeLog 1082248033 1082248069 -./Config 1077455728 1002101497 -./INSTALL 1077455728 1000991730 -./Makefile 1082247789 1082247755 -./README 1077455728 1044766458 -./README.man.patch 1077455728 1000991730 -./THANKS 1081026062 1006350263 -./TODO 1077455728 1044766566 -./changelog 1082247818 1082248025 -./doc/Makefile 1081829796 1019310768 -./doc/README.ofboot 1077455728 1000991730 -./doc/README.ofpath 1077455728 1000991730 -./doc/README.rs6000 1077455728 1007200689 -./doc/examples/README.dualboot.chrp 1077455728 1000991730 -./doc/examples/README.mbicons 1077455728 1000991730 -./doc/examples/README.simpleboot.chrp 1077455728 1000991730 -./doc/examples/dualboot.chrp 1077455728 1068017741 -./doc/examples/large-penguin.mbicon 1077455728 1000991730 -./doc/examples/simpleboot.chrp 1077455728 1068017750 -./doc/examples/yaboot.conf.multi-boot 1077455728 1006348765 -./doc/examples/yaboot.conf.rs6000 1077455728 1006348765 -./doc/examples 1082248073 1068017750 -./doc/yaboot-howto.de.sgml 1077455730 1077455488 -./doc/yaboot-howto.sgml 1081829886 1077455511 -./doc 1082248073 1081830064 -./etc/yaboot.conf 1077455728 1006348765 -./etc 1082248073 1007269243 -./first/ofboot 1078705056 1065311880 -./first 1082248073 1071492158 -./include/asm/elf.h 1077455728 1000991730 -./include/asm/ppc_asm.tmpl 1077455728 1000991730 -./include/asm/processor.h 1077455728 1000991730 -./include/asm 1082248073 1007269243 -./include/bootinfo.h 1077455728 1007200690 -./include/byteorder.h 1077455728 1000991730 -./include/cfg.h 1077455728 1007200690 -./include/cmdline.h 1077455728 1007200690 -./include/ctype.h 1077455728 1003656411 -./include/debug.h 1077455730 1007200690 -./include/errors.h 1077455728 1007200690 -./include/et/com_err.h 1077455729 1000991731 -./include/et 1082248073 1007269243 -./include/ext2fs/bitops.h 1077455729 1003927524 -./include/ext2fs/ext2_err.h 1077455729 1003927524 -./include/ext2fs/ext2_io.h 1077455729 1003927524 -./include/ext2fs/ext2fs.h 1077455729 1003927524 -./include/ext2fs 1082248073 1007269243 -./include/fdisk-part.h 1077455729 1007200690 -./include/file.h 1077455729 1007200690 -./include/fs.h 1077455729 1007200690 -./include/linux/elf.h 1077455729 1000991731 -./include/linux/ext2_fs.h 1077455729 1000991731 -./include/linux/iso_fs.h 1077455729 1000991731 -./include/linux/stat.h 1077455729 1000991731 -./include/linux/types.h 1077455729 1000991731 -./include/linux 1082248073 1007269243 -./include/mac-part.h 1077455729 1007200690 -./include/md5.h 1077455729 1000991730 -./include/partition.h 1077455729 1007200690 -./include/prom.h 1077455729 1007200690 -./include/reiserfs/reiserfs.h 1077455729 1025684115 -./include/reiserfs 1082248073 1025684115 -./include/setjm2.h 1077455729 1000991730 -./include/setjmp.h 1077455729 1000991730 -./include/stdlib.h 1077455729 1000991730 -./include/string.h 1077455729 1002620217 -./include/swab.h 1077455729 1000991730 -./include/types.h 1077455729 1000991730 -./include/xfs/xfs.h 1077455728 1002101334 -./include/xfs 1082248073 1007269244 -./include/yaboot.h 1077455729 1007200690 -./include 1082248073 1007269244 -./lib/ctype.c 1077455729 1000991731 -./lib/libext2fs.a 1077455729 1003927524 -./lib/malloc.c 1077455729 1007200690 -./lib/nosys.c 1077455729 1000991731 -./lib/string.S 1077455729 1007200690 -./lib/strstr.c 1077455729 1000991731 -./lib/strtol.c 1077455729 1000991731 -./lib/vsprintf.c 1077455729 1000991731 -./lib 1082248073 1069320301 -./man/bootstrap.8 1077455729 1000991731 -./man/mkofboot.8 1077455729 1006348765 -./man/ofpath.8 1077455729 1000991731 -./man/yaboot.8 1077455729 1006348765 -./man/yaboot.conf.5 1077455729 1004256691 -./man/yabootconfig.8 1077455729 1027929577 -./man/ybin.8 1077455729 1006348765 -./man 1082248073 1027929577 -./man.patch 1077455729 1006348761 -./second/cache.S 1077455729 1007200690 -./second/cfg.c 1077455729 1007200690 -./second/cmdline.c 1077455729 1032059589 -./second/crt0.S 1077455729 1000991731 -./second/file.c 1077455729 1044868693 -./second/fs.c 1077455729 1032059574 -./second/fs_ext2.c 1077455730 1032059564 -./second/fs_iso.c 1077455730 1007200690 -./second/fs_of.c 1077455730 1032059553 -./second/fs_reiserfs.c 1077455730 1007200690 -./second/fs_xfs.c 1077455728 1032059541 -./second/iso_util.c 1077455730 1003656415 -./second/md5.c 1077455730 1032059532 -./second/partition.c 1077455730 1032059525 -./second/prom.c 1077455730 1067937197 -./second/setjmp.S 1077455730 1000991732 -./second/yaboot.c 1077455730 1032059504 -./second 1082248073 1069320301 -./util/addnote.c 1077455730 1007200691 -./util/elfextract.c 1077455730 1007303237 -./util 1082248073 1069320301 -./ybin/mkofboot 1082248073 1073219938 -./ybin/ofpath 1082247789 1082247720 -./ybin/yabootconfig 1080897913 1044766426 -./ybin/ybin 1082247789 1082247741 -./ybin 1082248073 1080449901 -. 1082248073 1082248069 +./0arch-timestamps0 1082938563 1082939264 +./BUGS 1082938563 1000991730 +./COPYING 1082938564 1000991730 +./ChangeLog 1082939152 1082939261 +./Config 1082938563 1002101497 +./INSTALL 1082938564 1000991730 +./Makefile 1082938564 1082247755 +./README 1082938564 1044766458 +./README.man.patch 1082938564 1000991730 +./THANKS 1082938564 1006350263 +./TODO 1082938564 1044766566 +./changelog 1082938564 1082248025 +./doc/Makefile 1082938567 1019310768 +./doc/README.ofboot 1082938564 1000991730 +./doc/README.ofpath 1082938564 1000991730 +./doc/README.rs6000 1082938564 1007200689 +./doc/examples/README.dualboot.chrp 1082938564 1000991730 +./doc/examples/README.mbicons 1082938564 1000991730 +./doc/examples/README.simpleboot.chrp 1082938564 1000991730 +./doc/examples/dualboot.chrp 1082938564 1068017741 +./doc/examples/large-penguin.mbicon 1082938564 1000991730 +./doc/examples/simpleboot.chrp 1082938564 1068017750 +./doc/examples/yaboot.conf.multi-boot 1082938564 1006348765 +./doc/examples/yaboot.conf.rs6000 1082938564 1006348765 +./doc/examples 1082939264 1068017750 +./doc/yaboot-howto.de.sgml 1082938567 1077455488 +./doc/yaboot-howto.sgml 1082938567 1077455511 +./doc 1082939264 1081830064 +./etc/yaboot.conf 1082938564 1006348765 +./etc 1082939264 1007269243 +./first/ofboot 1082938564 1065311880 +./first 1082939264 1071492158 +./include/asm/elf.h 1082938564 1000991730 +./include/asm/ppc_asm.tmpl 1082938564 1000991730 +./include/asm/processor.h 1082938564 1000991730 +./include/asm 1082939264 1007269243 +./include/bootinfo.h 1082938564 1007200690 +./include/byteorder.h 1082938564 1000991730 +./include/cfg.h 1082938564 1007200690 +./include/cmdline.h 1082938564 1007200690 +./include/ctype.h 1082938564 1003656411 +./include/debug.h 1082938566 1007200690 +./include/errors.h 1082938563 1007200690 +./include/et/com_err.h 1082938564 1000991731 +./include/et 1082939264 1007269243 +./include/ext2fs/bitops.h 1082938564 1003927524 +./include/ext2fs/ext2_err.h 1082938564 1003927524 +./include/ext2fs/ext2_io.h 1082938564 1003927524 +./include/ext2fs/ext2fs.h 1082938564 1003927524 +./include/ext2fs 1082939264 1007269243 +./include/fdisk-part.h 1082938564 1007200690 +./include/file.h 1082938564 1007200690 +./include/fs.h 1082938564 1007200690 +./include/linux/elf.h 1082938564 1000991731 +./include/linux/ext2_fs.h 1082938564 1000991731 +./include/linux/iso_fs.h 1082938564 1000991731 +./include/linux/stat.h 1082938564 1000991731 +./include/linux/types.h 1082938564 1000991731 +./include/linux 1082939264 1007269243 +./include/mac-part.h 1082938564 1007200690 +./include/md5.h 1082938564 1000991730 +./include/partition.h 1082938564 1007200690 +./include/prom.h 1082938564 1007200690 +./include/reiserfs/reiserfs.h 1082938564 1025684115 +./include/reiserfs 1082939264 1025684115 +./include/setjm2.h 1082938564 1000991730 +./include/setjmp.h 1082938564 1000991730 +./include/stdlib.h 1082938564 1000991730 +./include/string.h 1082938564 1002620217 +./include/swab.h 1082938564 1000991730 +./include/types.h 1082938564 1000991730 +./include/xfs/xfs.h 1082938563 1002101334 +./include/xfs 1082939264 1007269244 +./include/yaboot.h 1082938564 1007200690 +./include 1082939264 1007269244 +./lib/ctype.c 1082938564 1000991731 +./lib/libext2fs.a 1082938566 1003927524 +./lib/malloc.c 1082938566 1007200690 +./lib/nosys.c 1082938566 1000991731 +./lib/string.S 1082938566 1007200690 +./lib/strstr.c 1082938566 1000991731 +./lib/strtol.c 1082938566 1000991731 +./lib/vsprintf.c 1082938566 1000991731 +./lib 1082939264 1069320301 +./man/bootstrap.8 1082938566 1000991731 +./man/mkofboot.8 1082938566 1006348765 +./man/ofpath.8 1082938566 1000991731 +./man/yaboot.8 1082938566 1006348765 +./man/yaboot.conf.5 1082938566 1004256691 +./man/yabootconfig.8 1082938566 1027929577 +./man/ybin.8 1082938566 1006348765 +./man 1082939264 1027929577 +./man.patch 1082938566 1006348761 +./second/cache.S 1082938566 1007200690 +./second/cfg.c 1082938566 1007200690 +./second/cmdline.c 1082938566 1032059589 +./second/crt0.S 1082938566 1000991731 +./second/file.c 1082938566 1044868693 +./second/fs.c 1082938566 1032059574 +./second/fs_ext2.c 1082938566 1032059564 +./second/fs_iso.c 1082938566 1007200690 +./second/fs_of.c 1082938566 1032059553 +./second/fs_reiserfs.c 1082938566 1007200690 +./second/fs_xfs.c 1082938563 1032059541 +./second/iso_util.c 1082938566 1003656415 +./second/md5.c 1082938566 1032059532 +./second/partition.c 1082938566 1032059525 +./second/prom.c 1082938566 1067937197 +./second/setjmp.S 1082938566 1000991732 +./second/yaboot.c 1082938566 1032059504 +./second 1082939264 1069320301 +./util/addnote.c 1082938566 1007200691 +./util/elfextract.c 1082938566 1007303237 +./util 1082939264 1069320301 +./ybin/mkofboot 1082939264 1073219938 +./ybin/ofpath 1082938566 1082247720 +./ybin/yabootconfig 1082932760 1082931877 +./ybin/ybin 1082938566 1082247741 +./ybin 1082939264 1082931877 +. 1082939264 1082939261 diff --git a/ChangeLog b/ChangeLog index 111223d..d192da5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,20 @@ # arch-tag: automatic-ChangeLog--erbenson@alaska.net--public/yaboot--devel--1.3 # +2004-04-26 00:27:48 GMT Ethan Benson patch-69 + + Summary: + Add support for initrd detection to yabootconfig + Revision: + yaboot--devel--1.3--patch-69 + + * ybin/yabootconfig: If detected kernel appears to have a corresponding + initrd image then include an initrd= line in generated yaboot.conf. + + modified files: + 0arch-timestamps0 ChangeLog ybin/yabootconfig + + 2004-04-18 00:27:59 GMT Ethan Benson patch-68 Summary: diff --git a/ybin/yabootconfig b/ybin/yabootconfig index 1523280..f343a7d 100755 --- a/ybin/yabootconfig +++ b/ybin/yabootconfig @@ -27,7 +27,7 @@ if [ -n "$PATH_PREFIX" ] ; then PATH="${PATH}:${PATH_PREFIX}/sbin:${PATH_PREFIX}/bin:${PATH_PREFIX}/usr/sbin:${PATH_PREFIX}/usr/bin:${PATH_PREFIX}/usr/local/sbin:${PATH_PREFIX}/usr/local/bin" fi PRG="${0##*/}" -VERSION=1.0.7 +VERSION=1.0.8-UNSUPPORTED_UNRELEASED_DEVEL CHROOT=/ ## $CONFIG is relative to $CHROOT CONFIG=etc/yaboot.conf @@ -441,12 +441,40 @@ fi ## user if we cannot find one. if [ -f "${CHROOT}vmlinux" ] ; then KERNEL="${CHROOT}vmlinux" + if [ -f "${CHROOT}initrd" ] ; then + INITRD="${CHROOT}initrd" + elif [ -f "${CHROOT}initrd.img" ] ; then + INITRD="${CHROOT}initrd.img" + elif [ -f "${CHROOT}initrd.gz" ] ; then + INITRD="${CHROOT}initrd.gz" + fi elif [ -f "${CHROOT}boot/vmlinux" ] ; then KERNEL="${CHROOT}boot/vmlinux" + if [ -f "${CHROOT}boot/initrd" ] ; then + INITRD="${CHROOT}boot/initrd" + elif [ -f "${CHROOT}boot/initrd.img" ] ; then + INITRD="${CHROOT}boot/initrd.img" + elif [ -f "${CHROOT}boot/initrd.gz" ] ; then + INITRD="${CHROOT}boot/initrd.gz" + fi elif [ -f "${CHROOT}boot/vmlinux-`uname -r`" ] ; then KERNEL="${CHROOT}boot/vmlinux-`uname -r`" + if [ -f "${CHROOT}boot/initrd-`uname -r`" ] ; then + INITRD="${CHROOT}boot/initrd-`uname -r`" + elif [ -f "${CHROOT}boot/initrd-`uname -r`.img" ] ; then + INITRD="${CHROOT}boot/initrd-`uname -r`.img" + elif [ -f "${CHROOT}boot/initrd-`uname -r`.gz" ] ; then + INITRD="${CHROOT}boot/initrd-`uname -r`.gz" + fi elif [ -f "${CHROOT}vmlinux-`uname -r`" ] ; then KERNEL="${CHROOT}vmlinux-`uname -r`" + if [ -f "${CHROOT}initrd-`uname -r`" ] ; then + INITRD="${CHROOT}initrd-`uname -r`" + elif [ -f "${CHROOT}initrd-`uname -r`.img" ] ; then + INITRD="${CHROOT}initrd-`uname -r`.img" + elif [ -f "${CHROOT}initrd-`uname -r`.gz" ] ; then + INITRD="${CHROOT}initrd-`uname -r`.gz" + fi elif [ "$QUIET" = 0 ] ; then echo 1>&2 "$PRG: Cannot find a kernel, please locate one" while true ; do @@ -463,12 +491,30 @@ elif [ "$QUIET" = 0 ] ; then echo 1>&2 "$PRG: $KERN: Is not a regular file" fi done + while true ; do + $PRINTF 1>&2 "Enter path to an initrd image (hit Enter for none): " + read IRD + if [ -z "$IRD" ] ; then + break + fi + if [ -f "$IRD" ] ; then + INITRD="$IRD" + break + elif [ ! -e "$IRD" ] ; then + echo 1>&2 "$PRG: $IRD: No such file or directory" + elif [ -d "$IRD" ] ; then + echo 1>&2 "$PRG: $IRD: Is a directory" + else + echo 1>&2 "$PRG: $IRD: Is not a regular file" + fi + done else echo 1>&2 "$PRG: Cannot find a kernel, aborting..." exit 1 fi debug "KERNEL=$KERNEL\n" +debug "INITRD=$INITRD\n" ## get partition number the kernel lives on, and the OF device= name ## of the whole disk. @@ -483,8 +529,27 @@ else KERNELDISK="${KERNDEV%%[0-9]*}" fi +if [ -n "$INITRD" ] ; then + ## get partition number the initrd lives on, and the OF device= name + ## of the whole disk. + IRDDEV="$(v=`df "$INITRD" 2> /dev/null | grep ^/dev/` ; echo ${v%%[ ]*})" + IRDDIR="$(v=`df "$INITRD" 2> /dev/null | grep ^/dev/` ; echo ${v##*[ ]})" + IRDLINKDEV="$(v=`df "${INITRD%/*}/" 2>/dev/null | grep ^/dev/` ; echo ${v%%[ ]*})" + IRDPARTITION="${KERNDEV##*[a-z]}" + + if ckdevfs "$IRDDEV" ; then + INITRDDISK="${IRDDEV%/*}/disc" + else + INITRDDISK="${IRDDEV%%[0-9]*}" + fi +fi + debug "KERNEL=$KERNEL\nKERNDEV=$KERNDEV\nKERNDIR=$KERNDIR\nLINKDEV=$LINKDEV\nPARTITION=$PARTITION\nKERNELDISK=$KERNELDISK\n" +if [ -n "$INITRD" ] ; then + debug "INITRD=$INITRD\nIRDDEV=$IRDDEV\nIRDDIR=$IRDDIR\nIRDLINKDEV=$IRDLINKDEV\nIRDPARTITION=$IRDPARTITION\nINITRDDISK=$INITRDDISK\n" +fi + ## sanity check for i in "$KERNDEV" "$KERNDIR" "$LINKDEV" "$PARTITION" "$KERNELDISK" ; do if [ -z "$i" ] ; then @@ -494,6 +559,17 @@ for i in "$KERNDEV" "$KERNDIR" "$LINKDEV" "$PARTITION" "$KERNELDISK" ; do fi done +if [ -n "$INITRD" ] ; then + ## sanity check + for i in "$IRDDEV" "$IRDDIR" "$IRDLINKDEV" "$IRDPARTITION" "$INITRDDISK" ; do + if [ -z "$i" ] ; then + echo 1>&2 "$PRG: Could not determine necessary information, aborting..." + echo 1>&2 "$PRG: Are you using chroot $PRG instead of $PRG --chroot ?" + exit 1 + fi + done +fi + ## check for cross device symlink if [ -L "$KERNEL" ] ; then if [ "$KERNDEV" != "$LINKDEV" ] ; then @@ -506,6 +582,26 @@ if [ -L "$KERNEL" ] ; then fi fi +if [ -n "$INITRD" ] ; then + ## initrd must be on same device as kernel. + if [ "$IRDDEV" != "$KERNDEV" -o "$IRDPARTITION" != "$IRDPARTITION" -o "$INITRDDISK" != "$KERNELDISK" ] ; then + echo 1>&2 "$PRG: Initrd image must be on same device as kernel image." + exit 1 + fi + + ## check for cross device symlink + if [ -L "$INITRD" ] ; then + if [ "$IRDDEV" != "$IRDLINKDEV" ] ; then + echo 1>&2 "$PRG: Warning: Cross device symlink $INITRD, using it's target instead" + INITRD="$(readlink -f "$INITRD" 2>/dev/null)" + if [ ! -f "$INITRD" ] ; then + echo 1>&2 "$PRG: Unable to canonicalize symlink's target. Do not create cross device symlinks." + exit 1 + fi + fi + fi +fi + ## only powermacs appear to need device= if (cat /proc/cpuinfo 2>/dev/null | grep -q pmac-generation 2> /dev/null) ; then DEVICE="\ndevice=$($OFPATH $KERNELDISK)" @@ -538,6 +634,31 @@ case "$IMAGE" in ;; esac +if [ -n "$INITRD" ] ; then + ## if there is a separate /boot partition we must strip off the /boot + ## mountpoint or else yaboot will not find the kernel. + if [ "$IRDDIR" != "$CHROOT" ] ; then + INITRDIMG="${INITRD##*$IRDDIR}" + else + INITRDIMG="$INITRD" + fi + + ## fix chrooted path + if [ "$CHROOT" != / ] ; then + INITRDIMG="${INITRDIMG##*$CHROOT}" + fi + + ## fix relative path (caused by chroot path fix) + case "$INITRDIMG" in + /*) + true + ;; + *) + INITRDIMG="/${INITRDIMG}" + ;; + esac +fi + ## figure out if yaboot is installed in /usr/local or not if [ -f /usr/local/lib/yaboot/yaboot ] ; then INSTALL=/usr/local/lib/yaboot/yaboot @@ -579,6 +700,11 @@ if [ -z "$APPEND" ] ; then fi fi +## generate initrd= lines +if [ -n "$INITRDIMG" ] ; then + INITRDIMGS="\tinitrd=$INITRDIMG\n\tinitrd-size=8192\n" +fi + ## generate global section of yaboot.conf GLOBAL="## yaboot.conf generated by $PRG $VERSION ## @@ -596,7 +722,7 @@ install=${INSTALL}${OFBOOT:-}\n" IMAGES=" image=$IMAGE \tlabel=Linux -\tread-only\n${APPEND:-}" +\tread-only\n${APPEND:-}${INITRDIMGS:-}" ## safely create a tmp file then move it into place after we are sure ## it was written. -- 2.39.2