All of lore.kernel.org
 help / color / mirror / Atom feed
From: Randy Dunlap <rdunlap@infradead.org>
To: Bhaskar Chowdhury <unixbhaskar@gmail.com>,
	yamada.masahiro@socionext.com, michal.lkml@markovi.net
Cc: bfields@fieldses.org, linux-kbuild@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] scripts : prune-kernel : prune kernels generalized way
Date: Thu, 17 Oct 2019 13:16:42 -0700	[thread overview]
Message-ID: <7965fdbe-eb2b-1178-61c3-ad54fa147fb3@infradead.org> (raw)
In-Reply-To: <20191017063126.2005-1-unixbhaskar@gmail.com>

On 10/16/19 11:31 PM, Bhaskar Chowdhury wrote:
> This patch will remove old kernel from the system in a selective way.
> 
> Signed-off-by: Bhaskar Chowdhury <unixbhaskar@gmail.com>
> ---
> For Randy :
> ✔ ~/git-linux/linux-kbuild [master|AM/REBASE ↑·8|✔]
> 11:42 $ ./scripts/checkpatch.pl -f
> scripts/0001-Fix-all-the-concern-raised-by-Randy.patch
> total: 0 errors, 0 warnings, 93 lines checked
> 
> scripts/0001-Fix-all-the-concern-raised-by-Randy.patch has no obvious
> style problems and is ready for submission.
> 
> scripts/prune-kernel | 75 ++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 75 insertions(+)
> 
> diff --git a/scripts/prune-kernel b/scripts/prune-kernel
> index e69de29bb2d1..9461ae2bc122 100755
> --- a/scripts/prune-kernel
> +++ b/scripts/prune-kernel
> @@ -0,0 +1,75 @@
> +#!/bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +
> +# because I use CONFIG_LOCALVERSION_AUTO, not the same version again and
> +# again, /boot and /lib/modules/ eventually fill up.
> +# Dumb script to purge that stuff:
> +
> +#for f in "$@"
> +#do
> +#        if rpm -qf "/lib/modules/$f" >/dev/null; then
> +#                echo "keeping $f (installed from rpm)"
> +#        elif [ $(uname -r) = "$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
> +boot_dir=/boot
> +modules_dir=/lib/modules
> +function remove_old_kernel(){
> +	cd $boot_dir
> +	rm -If vmlinuz-$kernel_version System.map-$kernel_version config-$kernel_verison

typo/spello: not tested:                                                  ^^^^^^^^^^^^^^

> +}
> +function remove_old_kernel_modules_dir(){
> +	cd $modules_dir
> +	rm -rf $modules_version
> +}
> +printf "\n\n Enlist the installed kernels \n\n"
> +
> +find $boot_dir -name "vmlinuz-*" -type f  -exec ls -1 {} \;
> +
> +printf "\n\n\n Please give the kernel version to remove: %s"
> +read kernel_version
> +if [[ $kernel_version -eq "" ]];then
> +	printf "You have forgotten the version to give for removal"

No message needed IMO -- just exit.

> +	exit 1
> +else
> +        remove_old_kernel
> +fi
> +
> +printf "\n\n Enlist the installed modules directory \n\n"
> +
> +find $modules_dir  -maxdepth 0 -type d -exec ls -1 {} \;
> +
> +printf "\n\n Please give the full modules directory name to remove: %s"
> +read modules_version
> +if [[ $modules_version -eq "" ]];then
> +	printf "You have forgotten to give the modules dir to remove"

ditto.

> +else
> +        remove_old_kernel_modules_dir
> +fi
> +
> +printf "\n\n Removed kernel version: $kernel_version and associated modules: $modules_version ...Done \n"
> +while :
> +  do
> +     printf "\n\n Do you want to remove another?[YN] : %s"
> +     read response
> +
> +       if [[ $response == "Y" ]];then

Odd indentation here.  Some lines use tab, some lines use spaces.

> +	printf "Please give another version to remove : %s"
> +	read kernel_version
> +	remove_old_kernel
> +	printf "\n\n Please give the full modules directory name to remove: %s"
> +	read modules_version
> +	remove_old_kernel_modules_dir
> +        printf "\n\n Removed kernel version: $kernel_version and associated modules: $modules_version ...Done \n"
> +
> +      elif [[ $response == "N" ]];then
> +	   exit 1
> +      fi
> +  done
> --
> 2.21.0


And lastly, 'patch' will apply this patch cleanly, but it ends up with
almost all of this patch inserted into the new prune-kernel source file
before the current contents of the prune-kernel source file,
so I think that the emailed patch file has a problem.

-- 
~Randy


  reply	other threads:[~2019-10-17 20:17 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-17  6:31 [PATCH] scripts : prune-kernel : prune kernels generalized way Bhaskar Chowdhury
2019-10-17 20:16 ` Randy Dunlap [this message]
2019-10-17 23:00   ` Bhaskar Chowdhury
  -- strict thread matches above, loose matches on Subject: below --
2019-10-19 13:07 [PATCH] scripts: " Bhaskar Chowdhury
2019-10-19 16:01 ` J. Bruce Fields
2019-10-19 22:16   ` Bhaskar Chowdhury
2019-10-16  6:13 [PATCH] scripts : " Bhaskar Chowdhury
2019-10-16 16:08 ` Randy Dunlap
2019-10-17  6:19   ` Bhaskar Chowdhury

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7965fdbe-eb2b-1178-61c3-ad54fa147fb3@infradead.org \
    --to=rdunlap@infradead.org \
    --cc=bfields@fieldses.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.lkml@markovi.net \
    --cc=unixbhaskar@gmail.com \
    --cc=yamada.masahiro@socionext.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.