From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1Lzzhb-0000OP-1Z for mharc-grub-devel@gnu.org; Fri, 01 May 2009 16:51:23 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LzzhZ-0000KS-7f for grub-devel@gnu.org; Fri, 01 May 2009 16:51:21 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LzzhU-00007R-5P for grub-devel@gnu.org; Fri, 01 May 2009 16:51:20 -0400 Received: from [199.232.76.173] (port=43737 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LzzhT-00006q-P2 for grub-devel@gnu.org; Fri, 01 May 2009 16:51:15 -0400 Received: from mail-bw0-f161.google.com ([209.85.218.161]:50405) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LzzhT-0005cL-5i for grub-devel@gnu.org; Fri, 01 May 2009 16:51:15 -0400 Received: by bwz5 with SMTP id 5so2654018bwz.42 for ; Fri, 01 May 2009 13:51:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:content-type; bh=9IDc6R3lpYxPQd0M08TsR6K6Emfa+XSz/EamaRJ6n2w=; b=Gkf5XGuTXuCbn74Ugh5ySPpkjE6PTIbst7wmNmcPLcrwEd6IVejIO3KmVK2pVNkkKc 3OHGiImhq8/VJN7Cm4ZLxS65GSpOVzo9ddVmN5fcMlveIZeFhEqjSpaeswL4U3Gy6RYC WHd3/g9kYSTmIqiOVSMSAz23ssmLi7384pSW4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :content-type; b=p/X9QrkrYpdfoIkBYEIfX9THHwLC1K26ULJkpRM916dZqGdlpMgdSrXUK1NsOslqCB AJInmI+5zFQk+IX0HLF8Yl6W2Mz7Aiv/iHh9aC3QR6TuMvVhpcxpQphHLpXdNFKp1MnH 6laR5kxavhso6e8jXo5xjHIgvL/pZnvSEHM+s= Received: by 10.204.115.143 with SMTP id i15mr2950946bkq.103.1241211072649; Fri, 01 May 2009 13:51:12 -0700 (PDT) Received: from ?192.168.178.44? (p5B0CFB6C.dip.t-dialin.net [91.12.251.108]) by mx.google.com with ESMTPS id 24sm3192154fxm.71.2009.05.01.13.51.11 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 01 May 2009 13:51:12 -0700 (PDT) Message-ID: <49FB60BE.7090806@googlemail.com> Date: Fri, 01 May 2009 22:51:10 +0200 From: Andreas Born User-Agent: Thunderbird 2.0.0.21 (X11/20090325) MIME-Version: 1.0 To: GRUB2 Devel Content-Type: multipart/mixed; boundary="------------010006020602030103030505" X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [PATCH] prevent duplicated entries due to symlinks X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 May 2009 20:51:21 -0000 This is a multi-part message in MIME format. --------------010006020602030103030505 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit If there's both a symlink and a kernel at which the symlink is pointing in the list of detected kernels of 10_linux, two entries are created for actually the same kernel. This patch checks for this condition and only uses the symlink (usually the wanted behaviour), in case the target of the symlink doesn't exist, it uses neither. Furthermore there may be kernel images named e.g. /boot/vmlinuz, so to detect those the patch doesn't require a hyphen in the kernel name. In this case the sed used to determine the kernel version, won't return as expected an empty string. Therefore I replaced it by another one with the wanted behaviour. If the kernel version can be empty we don't want to have a "GNU/Linux, linux " menuentry. Accordingly this patch adds a check for empty kernel version, so that only "GNU/Linux" will be displayed. Finally there's quite a bunch of other names for initrds. This patch adds support for initrd.gz and initrd.splash. Both initrd.img and initrd.gz become or were yet supported with two different version positions and without version at all. For initrd.splash this isn't needed because it's not kernel version dependent. This is my first contribution and although I tried to inform myself as good as possible and double-checked everything, I could have missed something to you probably obvious. If there are any such problems, let me know, I'll do my best to get it sorted out. Andreas --------------010006020602030103030505 Content-Type: text/plain; name="10_linux.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="10_linux.diff" diff --git a/ChangeLog b/ChangeLog index 9097f25..ddf1c3e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2009-05-01 Andreas Born + + * util/grub.d/10_linux.in: Prevent duplicated entries because both + symlink and symlinked kernel are detected, only use the symlink + then. Detect also kernels without a hyphen in a name and use an + empty version for those kernels. Don't display linux in + the menuentry title if version is empty. Detect more initrds e.g. + initrd.gz. + 2009-04-30 David S. Miller * util/hostdisk.c (device_is_wholedisk): New function. diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in index c2da413..66768eb 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -112,9 +112,18 @@ EOF EOF } -list=`for i in /boot/vmlinu[xz]-* /vmlinu[xz]-* ; do +list=`for i in /boot/vmlinu[xz]* /vmlinu[xz]* ; do if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi done` +for i in $list ; do + if test -h $i ; then + target="`readlink -f $i`" + list=`echo $list | tr ' ' '\n' | grep -vx $target | tr '\n' ' '` + if test ! -f $target ; then + list=`echo $list | tr ' ' '\n' | grep -vx $i | tr '\n' ' '` + fi + fi +done while [ "x$list" != "x" ] ; do linux=`find_latest $list` @@ -122,13 +131,16 @@ while [ "x$list" != "x" ] ; do basename=`basename $linux` dirname=`dirname $linux` rel_dirname=`make_system_path_relative_to_its_root $dirname` - version=`echo $basename | sed -e "s,^[^0-9]*-,,g"` + version=`echo $basename | sed -e "s,^[^\-]*-*,,"` alt_version=`echo $version | sed -e "s,\.old$,,g"` linux_root_device_thisversion="${LINUX_ROOT_DEVICE}" initrd= for i in "initrd.img-${version}" "initrd-${version}.img" \ - "initrd.img-${alt_version}" "initrd-${alt_version}.img"; do + "initrd.img-${alt_version}" "initrd-${alt_version}.img" \ + "initrd.gz-${version}" "initrd-${version}.gz" \ + "initrd.gz-${alt_version}" "initrd-${alt_version}.gz" \ + "initrd.img" "initrd.gz" "initrd.splash"; do if test -e "${dirname}/${i}" ; then initrd="$i" break @@ -140,10 +152,16 @@ while [ "x$list" != "x" ] ; do # "UUID=" magic is parsed by initrds. Since there's no initrd, it can't work here. linux_root_device_thisversion=${GRUB_DEVICE} fi + + if test -n "${version}" ; then + title="${OS}, linux ${version}" + else + title="${OS}" + fi - linux_entry "${OS}, linux ${version}" \ + linux_entry "${title}" \ "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" - linux_entry "${OS}, linux ${version} (recovery mode)" \ + linux_entry "${title} (recovery mode)" \ "single ${GRUB_CMDLINE_LINUX}" list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '` --------------010006020602030103030505--