Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp104821ybx; Tue, 5 Nov 2019 20:30:41 -0800 (PST) X-Google-Smtp-Source: APXvYqzfk3ACWW7D8m9goMTHX0Hn93Tt6VYaxS9ZnriJL1py0zkzezjgDx2hoZ/Bqv3EI75ed2pd X-Received: by 2002:a50:ed12:: with SMTP id j18mr509730eds.172.1573014641333; Tue, 05 Nov 2019 20:30:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573014641; cv=none; d=google.com; s=arc-20160816; b=i6YxdJ0XJdSqidy35JB0G1vdGwie4xj7G9bmLnFLJAtRiEasO7xmhsBnPi7GH0HbGX uaKndNYLxIJujxjNlGINkFLIwURdp0PYlI3TEp1x9ae/7f6HxVwp85AL6JvNWp3CT6yd 6ZQhpCdNfzgZzsL95Kv6vG+D1OQic8vJcvX8uR6y2f0pk+R3Se5pqBhNgGmtc9RLWW2W ZEem2gz5S57kmFlCqUm+LXYZyC0oYOJEG6V3FnW2SWiKnT8C8TCodFyEmkBXf+DHOhgO t4D73+Q3cqNr058bMlx4gHCsGDSwHGsLWGb7jAAHQw7erSpCSt/NR/KUf8MyrkEAR3Wj SdSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=cEzk/8oDOYv4rMZYFovcOC7T1s33B/sHCx+vVjslo00=; b=rmkMM2zhGIRYI8UtlbABVaUpvRADVYMVYzb9JiPrxo3Helxx1XQIzVLjtJMfgPl6u/ n5nvUZ5KCt756kTYq44trdEhiP/AlmJmGTL2bHp/M/P9Bqitv0zdDu1TKxDcyywOjPCy r0nJt7bIuz2ccvvVBrzFE7AZzLS1vix8rPCTXTKWj0T6adMSFE6e6EwEAbFcG+n7Myn0 P1npHE1LPq5a86Ajn0Sp87qiF3v+naxj3ofO9vmJ8Oz3eNM3xBoXV0S6p4U/pj7PN7MJ qFbUgyWLH17Y0vgM8h9/u16oIEO76w9w0j6O/toTag1KtwhSbDQZOSxlhtVnjof7csPL O3ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=MRQqUCi8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a16si7816047ejs.215.2019.11.05.20.30.16; Tue, 05 Nov 2019 20:30:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=MRQqUCi8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731110AbfKFE3l (ORCPT + 99 others); Tue, 5 Nov 2019 23:29:41 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:41835 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730583AbfKFE3l (ORCPT ); Tue, 5 Nov 2019 23:29:41 -0500 Received: by mail-pf1-f193.google.com with SMTP id p26so17852736pfq.8; Tue, 05 Nov 2019 20:29:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=cEzk/8oDOYv4rMZYFovcOC7T1s33B/sHCx+vVjslo00=; b=MRQqUCi8y0aLkzs4AZYTW/zPFCyBHiASaOkVNuVKqNmwCvsbkmKdrTPGqd2MBG+m/l Nq0jiD8KcAi3guexyAxW8BVf165wcY3RLdtPv0UO3Ifo6kj9JbpWsCPuJsxSLCxqk1aP m0iNsgcXprGPrKH92kdqkNNAYFmUOoZpq/Vxs30xSP5OAvRTI4uuT4M43XmwWV2mY95y FNLx7brsby7djad1ukEO9PEISqaaE07N/dw4n+vP88Wtv0jAMdM8rUliFssn1kFkKROw sfHgf00bMM9iJjIsAxXQd9/qwiyPQ2e0SPu/roKXVPfUFj9YH08m+w+2kjS6qQ+s7W7Y EH0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=cEzk/8oDOYv4rMZYFovcOC7T1s33B/sHCx+vVjslo00=; b=T1wdjtYBuI23QnCqnLggNuZs//elGWYd0diSoYcouX+5xvCJcMVRuNXDJChOrjbQxD f7sI9zV8bcsXNT2Lx/ciC3ZLqVzhCDX1wfIrVFoczt9/ptLdGclhL0Jfz7z6suot/z6y ntRkXlVjxRQ/3JX6U2bKB4v8Du74r8KyCYntvPJRCwLuo2wlKNCFAQNh0Oboc/pQHuIs CLqTtyv44wGvRc4MKNHLPX6tlfSUORbI+xLGqIeE+kHBGWegLBufbv3QbN3kMhP758ax dWN9t2sruKd97LuIoIKkYE8yyKi/5/vY/lp6gwR5OfE8NGxu81WToAHR6P/K+KAfyGDl Lv8A== X-Gm-Message-State: APjAAAWiFFs26ikLgKvPJ3pIcAlcu9k3SqUS7AElRHmRbIisEk1pOieq 7rhAnp58egAt6roXxID1aPI= X-Received: by 2002:a62:1c89:: with SMTP id c131mr807915pfc.168.1573014579877; Tue, 05 Nov 2019 20:29:39 -0800 (PST) Received: from Gentoo ([103.231.91.67]) by smtp.gmail.com with ESMTPSA id x9sm1048459pje.27.2019.11.05.20.29.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Nov 2019 20:29:39 -0800 (PST) Date: Wed, 6 Nov 2019 09:59:25 +0530 From: Bhaskar Chowdhury To: Masahiro Yamada Cc: "J. Bruce Fields" , Randy Dunlap , Michal Marek , Linux Kbuild mailing list , Linux Kernel Mailing List Subject: Re: [PATCH] scripts:prune-kernel:remove old kernels and modules dir from system Message-ID: <20191106042922.GD20442@Gentoo> References: <20191102063036.28601-1-unixbhaskar@gmail.com> <50680c37-9e85-0050-c1e1-700260a0471c@infradead.org> <20191105023243.GA16635@fieldses.org> <20191106031027.GA20442@Gentoo> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="EP0wieDxd4TSJjHq" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --EP0wieDxd4TSJjHq Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 13:03 Wed 06 Nov 2019, Masahiro Yamada wrote: >On Wed, Nov 6, 2019 at 12:10 PM Bhaskar Chowdhury = wrote: >> >> On 11:53 Wed 06 Nov 2019, Masahiro Yamada wrote: >> >On Tue, Nov 5, 2019 at 11:32 AM J. Bruce Fields = wrote: >> >> >> >> On Mon, Nov 04, 2019 at 06:03:13PM -0800, Randy Dunlap wrote: >> >> > On 11/1/19 11:30 PM, Bhaskar Chowdhury wrote: >> >> > > This patch allow you to remove old kernels and associated modules >> >> > > directory from the system.You can do it at once with the -r flag >> >> > > and interactively with the -i flag. >> >> > > >> >> > > Signed-off-by: Bhaskar Chowdhury >> >> > > --- >> >> > > scripts/prune-kernel | 82 +++++++++++++++++++++++++++++++++++---= ------ >> >> > > 1 file changed, 65 insertions(+), 17 deletions(-) >> >> > >> >> > Hi, >> >> > I believe that this script now does what the patch author intends i= t to do. >> >> > It does have a few whitespace issues, but no big deals. (see below) >> >> >> >> My original comment stands: looks like it prompts for full module path >> >> and kernel versions which means it's no more convenient than just doi= ng >> >> an "ls" and then removing the ones you want to. (In fact, with "rm" >> >> you'd also get the benefit of tab completion....) >> >> >> >> It's quite different from the original script and I don't really see = the >> >> advantage. >> >> >> >> --b. >> > >> >I am with Bruce. >> > >> >This patch is trying to replace everything >> >with worse code. >> Well,Masahiro, >> I won't mind dropping the idea, which you already concluded.But, would >> you care to let me know how worse the code seems to be???? > > >As far as I understood this script, >it is useful to delete stale versions with a single command. > >scripts/prune-kernel 5.2-rc1 5.2-rc2 5.2-rc3 > > >This patch is dropping the 'for f in "$@"' loop, >so you would end up with running this script multiple times. > >scripts/prune-kernel -r 5.2-rc1 5.2-rc1 >scripts/prune-kernel -r 5.2-rc2 5.2-rc2 >scripts/prune-kernel -r 5.2-rc3 5.2-rc3 > Yes, true. You don't want all the stale kernels to be discarded at once, do you??? > >What is funny is, it takes the kernel_version and modules_version >separately. Lack of farsight of mine ...will take your suggestion. Should have realized it before, but was writing for different purpose. >And now it requires -r option for the default behavior. Because other flags are involved and they do different things. >I see nothing cool overall. > Meh... I am interpreting you "cool" literal way...which you certainly didn't mean it...do you?? > > >J. Bruce Fields suggested: >"But if somebody does actually use it as-is, it'd be nicer to keep the >current behavior and add an option ("-i" or something) for the >interactive behavior." > Yes, that's true ...and now I understood. On the contrary ,if I recollect properly, Bruce ,once told that he won't if do something which will be useful to the wider users..not sure that stands anymore. > >I want to see a patch if and only if >you can add -i without intrusively changing the current code. > Hopefully , you wish get fulfilled sooner than later. > >Masahiro > > > Bhaskar > >> > >> >BTW. >> >Bruce, >> >Does the current script expect RHEL or something? >> >I do not see 'new-kernel-pkg' on my Ubuntu machine. >> > >> >It would still work with 'new-kernel-pkg: command not found' >> >warning. >> > >> >We could bypass it if we like. >> > >> >command -v new-kernel-pkg && new-kernel-pkg --remove $f >> > >> > >> > >> >Masahiro Yamada >> > >> > >> > >> >> > >> >> > Tested-by: Randy Dunlap >> >> > >> >> > >> >> > > diff --git a/scripts/prune-kernel b/scripts/prune-kernel >> >> > > index e8aa940bc0a9..01d0778db71f 100755 >> >> > > --- a/scripts/prune-kernel >> >> > > +++ b/scripts/prune-kernel >> >> > > @@ -1,21 +1,69 @@ >> >> > > #!/bin/bash >> >> > > # SPDX-License-Identifier: GPL-2.0 >> >> > > +#This script will remove old kernels and modules directory relat= ed to it. >> >> > > +#"-r" or "--remove" show how to silently remove old kernel and m= odules dir. >> >> > > +# "-h" or "--help" show how to use this script or show without p= arameter. >> >> > > +#"-i" or "--interactive" show how to remove interactively. >> >> > > + >> >> > > +flag=3D$1 >> >> > > +kernel_version=3D$2 >> >> > > +modules_version=3D$3 >> >> > > +boot_dir=3D/boot >> >> > > +modules_dir=3D/lib/modules >> >> > > + >> >> > > +remove_old_kernel() { >> >> > > + cd $boot_dir >> >> > > + rm -If vmlinuz-$kernel_version System.map-$kernel_version con= fig-$kernel_version >> >> > > + return 0 >> >> > > +} >> >> > > + >> >> > > +remove_old_modules_dir() { >> >> > > + cd $modules_dir >> >> > > + rm -rf $modules_version >> >> > > + return 0 >> >> > > +} >> >> > > + >> >> > > +usage() { >> >> > > + printf "Usage: $(basename $0) [-ri]\n" >> >> > > + printf "\n -r or --remove kernel_version modules_version\n" >> >> > > + printf "\n -i or --interactive do as interactive way\n" >> >> > > + return 0 >> >> > > +} >> >> > > + >> >> > > +case "$flag" in >> >> > > + -i | --interactive) >> >> > > + printf "\nEnter kernel version to remove or blank/emp= ty to exit:" >> >> > > + read kernel_version >> >> > > + if [[ $kernel_version !=3D "" ]]; then >> >> > > + remove_old_kernel >> >> > > + printf "\nRemoved kernel version:$kernel_vers= ion from the system.\n\n" >> >> > >> >> > space after ':' >> >> > >> >> > drop one \n above. >> >> > >> >> > > + printf "Please give the full modules director= y name to remove:" >> >> > > + read modules_version >> >> > > + if [[ $modules_version !=3D "" ]]; then >> >> > > + remove_old_modules_dir >> >> > > + printf "\n\nRemoved modules directory= :$modules_version from the system.\n\n" >> >> > >> >> > space after ':' >> >> > >> >> > drop one \n above. >> >> > >> >> > > + else >> >> > > + exit 1 >> >> > > + fi >> >> > > + fi >> >> > > + ;; >> >> > > + -h | --help) >> >> > > + usage >> >> > > + exit 0 >> >> > > + ;; >> >> > > + -r | --remove) >> >> > > + if [[ $# -ne 3 ]]; then >> >> > > + printf "You need to provide kernel version a= nd modules directory name.\n" >> >> > > + exit 1 >> >> > > + else >> >> > > + remove_old_kernel >> >> > > + remove_old_modules_dir >> >> > > + fi >> >> > > + ;; >> >> > > + *) >> >> > > + usage >> >> > > + exit 1 >> >> > > + ;; >> >> > > +esac >> >> > > >> >> > > -# because I use CONFIG_LOCALVERSION_AUTO, not the same version a= gain and >> >> > > -# again, /boot and /lib/modules/ eventually fill up. >> >> > > -# Dumb script to purge that stuff: >> >> > > >> >> > >> >> > OK, the former script's loop is removed.. good. >> >> > But the 2 preceding blank lines are not removed, so the script >> >> > now ends with 2 unnecessary blank lines. >> >> > >> >> > > -for f in "$@" >> >> > > -do >> >> > > - if rpm -qf "/lib/modules/$f" >/dev/null; then >> >> > > - echo "keeping $f (installed from rpm)" >> >> > > - elif [ $(uname -r) =3D "$f" ]; then >> >> > > - echo "keeping $f (running kernel) " >> >> > > - else >> >> > > - echo "removing $f" >> >> > > - rm -f "/boot/initramfs-$f.img" "/boot/System.map= -$f" >> >> > > - rm -f "/boot/vmlinuz-$f" "/boot/config-$f" >> >> > > - rm -rf "/lib/modules/$f" >> >> > > - new-kernel-pkg --remove $f >> >> > > - fi >> >> > > -done >> >> > > -- >> >> > >> >> > >> >> > -- >> >> > ~Randy >> > >> > >> > >> >-- >> >Best Regards >> > >> >Masahiro Yamada > > > >--=20 >Best Regards >Masahiro Yamada --EP0wieDxd4TSJjHq Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEnwF+nWawchZUPOuwsjqdtxFLKRUFAl3CTB8ACgkQsjqdtxFL KRW5NAgA0uVcwzRFLEvGndfy6LOeW2pEg7NLPhU6RiPRpAdGpvf4U02sO6H7B3DR TC47joFXWmi8cbrQVQYyjlCspa2EenGfaD6qQWLtuYUoEux++H2CWsd1cyw1U6UX LYv5Ibs3htO0LRjt+0r79Rt+v6RMucrs0A1Z3zrYrTJOPAhyQzaPJ6GZv06asx9Z A9dC+An5s2tlirX3oKp/ERRBliR5WLHR+G3Yiae3JtwtjYtVXBgs9RuVjrrwsblJ PcULONU318O8M2WGjNkASmnyN18TqSBtZltive5e7F+CnNNZ58QkwMe+zSJeYbcS 89FEJ3oG87N+PHp5XOXg+PJ9k1x7Cg== =UI0O -----END PGP SIGNATURE----- --EP0wieDxd4TSJjHq--