From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1M1Rv8-00064d-77 for mharc-grub-devel@gnu.org; Tue, 05 May 2009 17:11:22 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M1Rv6-00062J-Cj for grub-devel@gnu.org; Tue, 05 May 2009 17:11:20 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M1Rv1-0005vy-F9 for grub-devel@gnu.org; Tue, 05 May 2009 17:11:19 -0400 Received: from [199.232.76.173] (port=54119 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M1Rv1-0005vn-8A for grub-devel@gnu.org; Tue, 05 May 2009 17:11:15 -0400 Received: from mail-fx0-f169.google.com ([209.85.220.169]:62894) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1M1Rv0-0000wf-Mq for grub-devel@gnu.org; Tue, 05 May 2009 17:11:15 -0400 Received: by fxm17 with SMTP id 17so5329241fxm.42 for ; Tue, 05 May 2009 14:11:11 -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:references:in-reply-to :content-type; bh=3pzkeG50QNwYnNLBO6zo3du3LNY8J3wC3elGWezY0PE=; b=lvLS7IPYeylzNEOins6Si02RJ0z1pycs7VxFIxkAqZxTi2+ewiuFK2P50R2N4fDdFL GSk2YeQFQU9Y3cFZYq86Q2OzJI8+S+UkMuxlu0ImoR30PylIL8Eb2jPDB6WPtvI3JaX5 b+QiLT9QbXuY58ekzTFGAFBBKMKehXJ9cJhKU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type; b=AYKabdx2LML3uJFYTjt9QP3k66wNo4Imgum2QkMjk5ph+PAV3drbpeOMmwVCFFMUBB 9lfgxA75NbmhMcQeTW3GoVkTP7gBZZOdDvMjWx0R0SrDMzbPwBF6hzlsjtxMHq/hG1Ye /iJvBBVNSCOMUxR/AtQ+mZAerWbxHt2SKY8lk= Received: by 10.204.61.204 with SMTP id u12mr440164bkh.149.1241557870983; Tue, 05 May 2009 14:11:10 -0700 (PDT) Received: from ?192.168.178.44? (p5B0CE544.dip.t-dialin.net [91.12.229.68]) by mx.google.com with ESMTPS id 8sm7472154fxm.35.2009.05.05.14.11.01 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 05 May 2009 14:11:04 -0700 (PDT) Message-ID: <4A00AB64.3040904@googlemail.com> Date: Tue, 05 May 2009 23:11:00 +0200 From: Andreas Born User-Agent: Thunderbird 2.0.0.21 (X11/20090325) MIME-Version: 1.0 To: The development of GRUB 2 References: <49FB60BE.7090806@googlemail.com> <1241411539.26483.42.camel@mj> <49FF1BBE.4090001@googlemail.com> <1241471594.9047.28.camel@mj> In-Reply-To: <1241471594.9047.28.camel@mj> Content-Type: multipart/mixed; boundary="------------070805000305080401010600" X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: Re: [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: Tue, 05 May 2009 21:11:20 -0000 This is a multi-part message in MIME format. --------------070805000305080401010600 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Pavel Roskin schrieb: > Suppose I have Linux 2.6.29 and 2.6.28. Your script makes entries for > "Linux default" and "Linux 2.6.28". Then I install Linux 2.6.30 and > don't run grub-mkconfig. Then I can boot Linux 2.6.30 and 2.6.28 form > the menu, but not 2.6.29. > > Even if I run grub-mkconfig, there is still something I lose. By > selecting "Linux default" I still don't know it it's Linux 2.6.30 or > something else. > > For me, the convenience of not having to rerun grub-mkconfig doesn't > outweigh the convenience of knowing what I'm loading. > > I know, it's have to argue about preferences, but if you want you > changes to be accepted, you need to present a good case. > It's also that kind of discussion which eventually separates the wheat from the chaff. Thus I welcome it. > I would consider placing the kernel pointed to by the vmlinuz link to > the first position of the Linux kernels. Another approach would be to > have an entry for the link without suppressing any versioned entries. > Ok, I understand and if it is a preference why don't make it a preference. :) You can find attached a new version of the patch, which per default will read the symlink and create an entry for the target, not the symlink. You can change this behaviour with "GRUB_USE_LINUX_SYMLINK=yes". If you define this environment variable with that value, it will use the behaviour I implemented before. This means it uses the symlink and ignores the kernel the symlink is currently pointing at. I think this is the best solution, because it prevents duplicated entries (only one entry for symlink or symlink target) and it gives the user the choice which behaviour he wants (rerun of grub-mkconfig needed or not needed). Is that solution all right? >>> Please specify where those names are used. Can you give the >>> distribution name and version where such names are used? >>> >>> >> Zenwalk, Slackware for example. I think more Slackware derivates are >> using it too. >> > > Let's add support for more versioned names first. That should be rather > non-controversial. I see no more versioned names which could be added for the existing extension(s). There is initrd-. and initrd.-. Whereas can either be $version or $alt_version and can be "img" or "gz" ("gz" is new) and at the very end as a last resort initrd.img initrd.gz and initrd.splash are tried in that order (that's also new). Roughly speaking only new fallback options. Do you see a problem there or do you have a concrete versioned name to add? Andreas --------------070805000305080401010600 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 2203b68..f1606ba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -0,0 +1,12 @@ +2009-05-05 Andreas Born + + * util/grub.d/10_linux.in: Prevent duplicated entries because both + symlink and symlinked kernel are detected. + Default: use only target of the symlink + GRUB_USE_LINUX_SYMLINK=yes: use only the symlink + 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. + diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in index c2da413..f2649be 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -112,9 +112,32 @@ 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 + continue # no symlink + fi + target="`readlink -f $i`" + if test ! -f $target ; then + # inexistent target + list=`echo $list | tr ' ' '\n' | grep -vx $i | grep -vx $target \ + | tr '\n' ' '` + continue + fi + + # default: use the target, not the symlink + if [ "${GRUB_USE_LINUX_SYMLINK}" = "yes" ] ; then + list=`echo $list | tr ' ' '\n' | grep -vx $target | tr '\n' ' '` + else + list=`echo $list | tr ' ' '\n' | grep -vx $i | tr '\n' ' '` + if ! echo $list | grep -qw $target ; then + list="$list $target" + fi + fi +done while [ "x$list" != "x" ] ; do linux=`find_latest $list` @@ -122,13 +145,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 +166,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' ' '` --------------070805000305080401010600--