Skip to contentSkip to conversation

scripts:prune-kernel:remove old kernels and modules dir from system

PATCH In review Bhaskar Chowdhury 4 participants 20 messages Nov 2, 2019 – Nov 18, 2019 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scripts:prune-kernel:remove old kernels and modules dir from system

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.

---
 scripts/prune-kernel | 82 +++++++++++++++++++++++++++++++++++---------
 1 file changed, 65 insertions(+), 17 deletions(-)
scripts/prune-kernel +65 -17
index e8aa940bc0a9..01d0778db71f 100755
@@ -1,21 +1,69 @@
 #!/bin/bash
 # SPDX-License-Identifier: GPL-2.0
+#This script will remove old kernels and modules directory related to it.
+#"-r" or "--remove" show how to silently remove old kernel and modules dir.
+# "-h" or "--help" show how to use this script or show without parameter.
+#"-i" or "--interactive" show how to remove interactively.
+
+flag=$1
+kernel_version=$2
+modules_version=$3
+boot_dir=/boot
+modules_dir=/lib/modules
+
+remove_old_kernel() {
+	cd $boot_dir
+	rm -If vmlinuz-$kernel_version System.map-$kernel_version config-$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/empty to exit:"
+		read kernel_version
+		if [[ $kernel_version != "" ]]; then
+			remove_old_kernel
+			printf "\nRemoved kernel version:$kernel_version from the system.\n\n"
+			printf "Please give the full modules directory name to remove:"
+			read modules_version
+			if [[ $modules_version != "" ]]; then
+				remove_old_modules_dir
+				printf "\n\nRemoved modules directory:$modules_version from the system.\n\n"
+			else
+				exit 1
+			fi
+		fi
+		;;
+	-h | --help)
+		usage
+		exit 0
+		;;
+	-r | --remove)
+		if [[ $# -ne 3 ]]; then
+			 printf "You need to provide kernel version and 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 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

--
2.23.0

Tested-by on v1 1/1
#1 lore raw
Quoted 8 lines · Bhaskar Chowdhury

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.

---
 scripts/prune-kernel | 82 +++++++++++++++++++++++++++++++++++---------
 1 file changed, 65 insertions(+), 17 deletions(-)

Hi,
I believe that this script now does what the patch author intends it to do. It does have a few whitespace issues, but no big deals. (see below)

Quoted 34 lines
scripts/prune-kernel +27 -0
index e8aa940bc0a9..01d0778db71f 100755
@@ -1,21 +1,69 @@
 #!/bin/bash
 # SPDX-License-Identifier: GPL-2.0
+#This script will remove old kernels and modules directory related to it.
+#"-r" or "--remove" show how to silently remove old kernel and modules dir.
+# "-h" or "--help" show how to use this script or show without parameter.
+#"-i" or "--interactive" show how to remove interactively.
+
+flag=$1
+kernel_version=$2
+modules_version=$3
+boot_dir=/boot
+modules_dir=/lib/modules
+
+remove_old_kernel() {
+	cd $boot_dir
+	rm -If vmlinuz-$kernel_version System.map-$kernel_version config-$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"

scripts/prune-kernel line 39

Quoted 10 lines
scripts/prune-kernel +10 -0
+	return 0
+}
+
+case "$flag" in
+	-i | --interactive)
+		printf "\nEnter kernel version to remove or blank/empty to exit:"
+		read kernel_version
+		if [[ $kernel_version != "" ]]; then
+			remove_old_kernel
+			printf "\nRemoved kernel version:$kernel_version from the system.\n\n"

space after ':'

drop one \n above.

scripts/prune-kernel line 44

Quoted 5 lines
scripts/prune-kernel +5 -0
+			printf "Please give the full modules directory name to remove:"
+			read modules_version
+			if [[ $modules_version != "" ]]; then
+				remove_old_modules_dir
+				printf "\n\nRemoved modules directory:$modules_version from the system.\n\n"

space after ':'

drop one \n above.

Quoted 18 lines
scripts/prune-kernel +18 -0
+			else
+				exit 1
+			fi
+		fi
+		;;
+	-h | --help)
+		usage
+		exit 0
+		;;
+	-r | --remove)
+		if [[ $# -ne 3 ]]; then
+			 printf "You need to provide kernel version and modules directory name.\n"
+			 exit 1
+		 else
+			 remove_old_kernel
+			 remove_old_modules_dir
+		fi
+		;;

scripts/prune-kernel line 69

Quoted 10 lines
scripts/prune-kernel +5 -3
+	*)
+		usage
+		exit 1
+		;;
+esac
 
-# 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:
 

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.

Quoted 15 lines
scripts/prune-kernel +0 -15
-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
--
Signature · 1 line
~Randy
#2 lore raw
Quoted 5 lines · Randy Dunlap
Quoted 4 lines · Bhaskar Chowdhury

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.

Quoted 8 lines
Quoted 4 lines
---
 scripts/prune-kernel | 82 +++++++++++++++++++++++++++++++++++---------
 1 file changed, 65 insertions(+), 17 deletions(-)

Hi,
I believe that this script now does what the patch author intends it 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 doing 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.

Quoted 115 lines
Quoted 34 lines
scripts/prune-kernel +27 -0
index e8aa940bc0a9..01d0778db71f 100755
@@ -1,21 +1,69 @@
 #!/bin/bash
 # SPDX-License-Identifier: GPL-2.0
+#This script will remove old kernels and modules directory related to it.
+#"-r" or "--remove" show how to silently remove old kernel and modules dir.
+# "-h" or "--help" show how to use this script or show without parameter.
+#"-i" or "--interactive" show how to remove interactively.
+
+flag=$1
+kernel_version=$2
+modules_version=$3
+boot_dir=/boot
+modules_dir=/lib/modules
+
+remove_old_kernel() {
+	cd $boot_dir
+	rm -If vmlinuz-$kernel_version System.map-$kernel_version config-$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"

scripts/prune-kernel line 39

Quoted 10 lines
scripts/prune-kernel +10 -0
+	return 0
+}
+
+case "$flag" in
+	-i | --interactive)
+		printf "\nEnter kernel version to remove or blank/empty to exit:"
+		read kernel_version
+		if [[ $kernel_version != "" ]]; then
+			remove_old_kernel
+			printf "\nRemoved kernel version:$kernel_version from the system.\n\n"

space after ':'

drop one \n above.

scripts/prune-kernel line 44

Quoted 5 lines
scripts/prune-kernel +5 -0
+			printf "Please give the full modules directory name to remove:"
+			read modules_version
+			if [[ $modules_version != "" ]]; then
+				remove_old_modules_dir
+				printf "\n\nRemoved modules directory:$modules_version from the system.\n\n"

space after ':'

drop one \n above.

Quoted 18 lines
scripts/prune-kernel +18 -0
+			else
+				exit 1
+			fi
+		fi
+		;;
+	-h | --help)
+		usage
+		exit 0
+		;;
+	-r | --remove)
+		if [[ $# -ne 3 ]]; then
+			 printf "You need to provide kernel version and modules directory name.\n"
+			 exit 1
+		 else
+			 remove_old_kernel
+			 remove_old_modules_dir
+		fi
+		;;

scripts/prune-kernel line 69

Quoted 10 lines
scripts/prune-kernel +5 -3
+	*)
+		usage
+		exit 1
+		;;
+esac
 
-# 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:
 

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.

Quoted 15 lines
scripts/prune-kernel +0 -15
-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
--
Signature · 1 line
~Randy
#3 lore raw
Quoted 11 lines · J. Bruce Fields
Quoted 10 lines · Randy Dunlap
Quoted 8 lines · Bhaskar Chowdhury

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.

---
 scripts/prune-kernel | 82 +++++++++++++++++++++++++++++++++++---------
 1 file changed, 65 insertions(+), 17 deletions(-)
Quoted 8 lines
Quoted 3 lines

Hi,
I believe that this script now does what the patch author intends it 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 doing an "ls" and then removing the ones you want to. (In fact, with "rm" you'd also get the benefit of tab completion....)

Hi Bruce,
I am forcing user to put full modules directory name,kinda engagement to the process.It is not a trivial operation, so the users should be aware. OHT Could you please state what else you would like to be inducted in
the so it can be useful?? So sorry for my weak memory if you already explicitly stated something like that before.

Thanks,
Bhaskar

Quoted 121 lines

It's quite different from the original script and I don't really see the advantage.

--b.

Quoted 115 lines
Quoted 34 lines
scripts/prune-kernel +27 -0
index e8aa940bc0a9..01d0778db71f 100755
@@ -1,21 +1,69 @@
 #!/bin/bash
 # SPDX-License-Identifier: GPL-2.0
+#This script will remove old kernels and modules directory related to it.
+#"-r" or "--remove" show how to silently remove old kernel and modules dir.
+# "-h" or "--help" show how to use this script or show without parameter.
+#"-i" or "--interactive" show how to remove interactively.
+
+flag=$1
+kernel_version=$2
+modules_version=$3
+boot_dir=/boot
+modules_dir=/lib/modules
+
+remove_old_kernel() {
+	cd $boot_dir
+	rm -If vmlinuz-$kernel_version System.map-$kernel_version config-$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"

scripts/prune-kernel line 39

Quoted 10 lines
scripts/prune-kernel +10 -0
+	return 0
+}
+
+case "$flag" in
+	-i | --interactive)
+		printf "\nEnter kernel version to remove or blank/empty to exit:"
+		read kernel_version
+		if [[ $kernel_version != "" ]]; then
+			remove_old_kernel
+			printf "\nRemoved kernel version:$kernel_version from the system.\n\n"

space after ':'

drop one \n above.

scripts/prune-kernel line 44

Quoted 5 lines
scripts/prune-kernel +5 -0
+			printf "Please give the full modules directory name to remove:"
+			read modules_version
+			if [[ $modules_version != "" ]]; then
+				remove_old_modules_dir
+				printf "\n\nRemoved modules directory:$modules_version from the system.\n\n"

space after ':'

drop one \n above.

Quoted 18 lines
scripts/prune-kernel +18 -0
+			else
+				exit 1
+			fi
+		fi
+		;;
+	-h | --help)
+		usage
+		exit 0
+		;;
+	-r | --remove)
+		if [[ $# -ne 3 ]]; then
+			 printf "You need to provide kernel version and modules directory name.\n"
+			 exit 1
+		 else
+			 remove_old_kernel
+			 remove_old_modules_dir
+		fi
+		;;

scripts/prune-kernel line 69

Quoted 10 lines
scripts/prune-kernel +5 -3
+	*)
+		usage
+		exit 1
+		;;
+esac
 
-# 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:
 

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.

Quoted 15 lines
scripts/prune-kernel +0 -15
-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
--
Signature · 1 line
~Randy
#4 lore raw
Quoted 12 lines · Bhaskar Chowdhury
Quoted 11 lines · J. Bruce Fields
Quoted 10 lines · Randy Dunlap
Quoted 8 lines · Bhaskar Chowdhury

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.

---
 scripts/prune-kernel | 82 +++++++++++++++++++++++++++++++++++---------
 1 file changed, 65 insertions(+), 17 deletions(-)
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines

Hi,
I believe that this script now does what the patch author intends it 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 doing an "ls" and then removing the ones you want to. (In fact, with "rm" you'd also get the benefit of tab completion....)

Bruce,

There is -r or --remove option , with that you can pass the kernel version and modules directory name , and the script will remove those without prompting you for those.

For instance you need to pass the options like this :

./scripts/prune-kernel -r kernel_version modules_directory_name OR
./scripts/prune-kernel --remove kernel_version modules_directory_name

Which I certainly believe is not just "ls and rm" stuff...could you please give it a shot ,and let me know the shortcoming please??

So , I can fix the damn thing.

Quoted 141 lines

Hi Bruce,
I am forcing user to put full modules directory name,kinda engagement to the process.It is not a trivial operation, so the users should be aware. OHT Could you please state what else you would like to be inducted in
the so it can be useful?? So sorry for my weak memory if you already explicitly stated something like that before.

Thanks,
Bhaskar

Quoted 121 lines

It's quite different from the original script and I don't really see the advantage.

--b.

Quoted 115 lines
Quoted 34 lines
scripts/prune-kernel +27 -0
index e8aa940bc0a9..01d0778db71f 100755
@@ -1,21 +1,69 @@
 #!/bin/bash
 # SPDX-License-Identifier: GPL-2.0
+#This script will remove old kernels and modules directory related to it.
+#"-r" or "--remove" show how to silently remove old kernel and modules dir.
+# "-h" or "--help" show how to use this script or show without parameter.
+#"-i" or "--interactive" show how to remove interactively.
+
+flag=$1
+kernel_version=$2
+modules_version=$3
+boot_dir=/boot
+modules_dir=/lib/modules
+
+remove_old_kernel() {
+	cd $boot_dir
+	rm -If vmlinuz-$kernel_version System.map-$kernel_version config-$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"

scripts/prune-kernel line 39

Quoted 10 lines
scripts/prune-kernel +10 -0
+	return 0
+}
+
+case "$flag" in
+	-i | --interactive)
+		printf "\nEnter kernel version to remove or blank/empty to exit:"
+		read kernel_version
+		if [[ $kernel_version != "" ]]; then
+			remove_old_kernel
+			printf "\nRemoved kernel version:$kernel_version from the system.\n\n"

space after ':'

drop one \n above.

scripts/prune-kernel line 44

Quoted 5 lines
scripts/prune-kernel +5 -0
+			printf "Please give the full modules directory name to remove:"
+			read modules_version
+			if [[ $modules_version != "" ]]; then
+				remove_old_modules_dir
+				printf "\n\nRemoved modules directory:$modules_version from the system.\n\n"

space after ':'

drop one \n above.

Quoted 18 lines
scripts/prune-kernel +18 -0
+			else
+				exit 1
+			fi
+		fi
+		;;
+	-h | --help)
+		usage
+		exit 0
+		;;
+	-r | --remove)
+		if [[ $# -ne 3 ]]; then
+			 printf "You need to provide kernel version and modules directory name.\n"
+			 exit 1
+		 else
+			 remove_old_kernel
+			 remove_old_modules_dir
+		fi
+		;;

scripts/prune-kernel line 69

Quoted 10 lines
scripts/prune-kernel +5 -3
+	*)
+		usage
+		exit 1
+		;;
+esac
 
-# 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:
 

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.

Quoted 15 lines
scripts/prune-kernel +0 -15
-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
--
Signature · 1 line
~Randy

-----BEGIN PGP SIGNATURE-----

iQEzBAABCAAdFiEEnwF+nWawchZUPOuwsjqdtxFLKRUFAl3A/PMACgkQsjqdtxFL KRUyqQgAya3BYL2iEMk0N3b1/Ji3TVzjrhaMrYM1bc6MDs7UA83ikBBG7C/dSmZ9 3l9ANXfEnjaF64FpuLTNE2pT/tVxEj+xQz5iWw3JXV9TR7P2rq6814LH4b3hXX54 A9r0sIRz0xwCMq7ihtNtgXziyviLp8UkUjIK+1C4vQ0h9/CvP0YETq8fgRWASMrS 2+VErRPd06DryAAnapz9CnZz2Fju6S4mA2aaTJ3hiDLNmbj++6IoNQw+r5MZrWde yUqPQcfAzxs6/GIuUPK3uStudgofQjCKbHbPho9jjmwXrNSFH6/0/pjz5R91oMu9 AWpkl0vkvAvzLsjRIeMG/MmClx0c3w==
=VReA
-----END PGP SIGNATURE-----

#5 lore raw
In reply to J. Bruce Fields
Quoted 21 lines · J. Bruce Fields
Quoted 5 lines · Randy Dunlap
Quoted 4 lines · Bhaskar Chowdhury

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.

Quoted 8 lines
Quoted 4 lines
---
 scripts/prune-kernel | 82 +++++++++++++++++++++++++++++++++++---------
 1 file changed, 65 insertions(+), 17 deletions(-)

Hi,
I believe that this script now does what the patch author intends it 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 doing an "ls" and then removing the ones you want to. (In fact, with "rm" you'd also get the benefit of tab completion....)

Quoted 4 lines

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.

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

Quoted 107 lines
Quoted 107 lines
Quoted 34 lines
scripts/prune-kernel +27 -0
index e8aa940bc0a9..01d0778db71f 100755
@@ -1,21 +1,69 @@
 #!/bin/bash
 # SPDX-License-Identifier: GPL-2.0
+#This script will remove old kernels and modules directory related to it.
+#"-r" or "--remove" show how to silently remove old kernel and modules dir.
+# "-h" or "--help" show how to use this script or show without parameter.
+#"-i" or "--interactive" show how to remove interactively.
+
+flag=$1
+kernel_version=$2
+modules_version=$3
+boot_dir=/boot
+modules_dir=/lib/modules
+
+remove_old_kernel() {
+   cd $boot_dir
+   rm -If vmlinuz-$kernel_version System.map-$kernel_version config-$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"

scripts/prune-kernel line 39

Quoted 10 lines
scripts/prune-kernel +10 -0
+   return 0
+}
+
+case "$flag" in
+   -i | --interactive)
+           printf "\nEnter kernel version to remove or blank/empty to exit:"
+           read kernel_version
+           if [[ $kernel_version != "" ]]; then
+                   remove_old_kernel
+                   printf "\nRemoved kernel version:$kernel_version from the system.\n\n"

space after ':'

drop one \n above.

scripts/prune-kernel line 44

Quoted 5 lines
scripts/prune-kernel +5 -0
+                   printf "Please give the full modules directory name to remove:"
+                   read modules_version
+                   if [[ $modules_version != "" ]]; then
+                           remove_old_modules_dir
+                           printf "\n\nRemoved modules directory:$modules_version from the system.\n\n"

space after ':'

drop one \n above.

Quoted 18 lines
scripts/prune-kernel +18 -0
+                   else
+                           exit 1
+                   fi
+           fi
+           ;;
+   -h | --help)
+           usage
+           exit 0
+           ;;
+   -r | --remove)
+           if [[ $# -ne 3 ]]; then
+                    printf "You need to provide kernel version and modules directory name.\n"
+                    exit 1
+            else
+                    remove_old_kernel
+                    remove_old_modules_dir
+           fi
+           ;;

scripts/prune-kernel line 69

Quoted 10 lines
scripts/prune-kernel +5 -3
+   *)
+           usage
+           exit 1
+           ;;
+esac
 
-# 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:
 

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.

Quoted 11 lines
scripts/prune-kernel +0 -11
-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"
Quoted 8 lines
Quoted 8 lines

scripts/prune-kernel

Quoted 4 lines
scripts/prune-kernel +0 -4
-                new-kernel-pkg --remove $f
-        fi
-done
--

--
~Randy

--
Best Regards

Masahiro Yamada

#6 lore raw
Quoted 25 lines · Masahiro Yamada
Quoted 24 lines · J. Bruce Fields
Quoted 5 lines · Randy Dunlap
Quoted 4 lines · Bhaskar Chowdhury

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.

Quoted 8 lines
Quoted 4 lines
---
 scripts/prune-kernel | 82 +++++++++++++++++++++++++++++++++++---------
 1 file changed, 65 insertions(+), 17 deletions(-)

Hi,
I believe that this script now does what the patch author intends it 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 doing 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.

Quoted 6 lines
Quoted 1 line

--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????

Quoted 142 lines

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

Quoted 107 lines
Quoted 107 lines
Quoted 34 lines
scripts/prune-kernel +27 -0
index e8aa940bc0a9..01d0778db71f 100755
@@ -1,21 +1,69 @@
 #!/bin/bash
 # SPDX-License-Identifier: GPL-2.0
+#This script will remove old kernels and modules directory related to it.
+#"-r" or "--remove" show how to silently remove old kernel and modules dir.
+# "-h" or "--help" show how to use this script or show without parameter.
+#"-i" or "--interactive" show how to remove interactively.
+
+flag=$1
+kernel_version=$2
+modules_version=$3
+boot_dir=/boot
+modules_dir=/lib/modules
+
+remove_old_kernel() {
+   cd $boot_dir
+   rm -If vmlinuz-$kernel_version System.map-$kernel_version config-$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"

scripts/prune-kernel line 39

Quoted 10 lines
scripts/prune-kernel +10 -0
+   return 0
+}
+
+case "$flag" in
+   -i | --interactive)
+           printf "\nEnter kernel version to remove or blank/empty to exit:"
+           read kernel_version
+           if [[ $kernel_version != "" ]]; then
+                   remove_old_kernel
+                   printf "\nRemoved kernel version:$kernel_version from the system.\n\n"

space after ':'

drop one \n above.

scripts/prune-kernel line 44

Quoted 5 lines
scripts/prune-kernel +5 -0
+                   printf "Please give the full modules directory name to remove:"
+                   read modules_version
+                   if [[ $modules_version != "" ]]; then
+                           remove_old_modules_dir
+                           printf "\n\nRemoved modules directory:$modules_version from the system.\n\n"

space after ':'

drop one \n above.

Quoted 18 lines
scripts/prune-kernel +18 -0
+                   else
+                           exit 1
+                   fi
+           fi
+           ;;
+   -h | --help)
+           usage
+           exit 0
+           ;;
+   -r | --remove)
+           if [[ $# -ne 3 ]]; then
+                    printf "You need to provide kernel version and modules directory name.\n"
+                    exit 1
+            else
+                    remove_old_kernel
+                    remove_old_modules_dir
+           fi
+           ;;

scripts/prune-kernel line 69

Quoted 10 lines
scripts/prune-kernel +5 -3
+   *)
+           usage
+           exit 1
+           ;;
+esac
 
-# 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:
 

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.

Quoted 11 lines
scripts/prune-kernel +0 -11
-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"
Quoted 8 lines
Quoted 8 lines

scripts/prune-kernel

Quoted 4 lines
scripts/prune-kernel +0 -4
-                new-kernel-pkg --remove $f
-        fi
-done
--

--
~Randy

--
Best Regards

Masahiro Yamada

#7 lore raw
Quoted 29 lines · Bhaskar Chowdhury
Quoted 27 lines · Masahiro Yamada
Quoted 25 lines · J. Bruce Fields
Quoted 5 lines · Randy Dunlap
Quoted 4 lines · Bhaskar Chowdhury

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.

Quoted 8 lines
Quoted 4 lines
---
 scripts/prune-kernel | 82 +++++++++++++++++++++++++++++++++++---------
 1 file changed, 65 insertions(+), 17 deletions(-)

Hi,
I believe that this script now does what the patch author intends it 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 doing 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.

Quoted 7 lines
Quoted 4 lines

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

What is funny is, it takes the kernel_version and modules_version separately.
And now it requires -r option for the default behavior. I see nothing cool overall.

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."

I want to see a patch if and only if
you can add -i without intrusively changing the current code.

Masahiro

Quoted 141 lines
Quoted 141 lines

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

Quoted 107 lines
Quoted 107 lines
Quoted 34 lines
scripts/prune-kernel +27 -0
index e8aa940bc0a9..01d0778db71f 100755
@@ -1,21 +1,69 @@
 #!/bin/bash
 # SPDX-License-Identifier: GPL-2.0
+#This script will remove old kernels and modules directory related to it.
+#"-r" or "--remove" show how to silently remove old kernel and modules dir.
+# "-h" or "--help" show how to use this script or show without parameter.
+#"-i" or "--interactive" show how to remove interactively.
+
+flag=$1
+kernel_version=$2
+modules_version=$3
+boot_dir=/boot
+modules_dir=/lib/modules
+
+remove_old_kernel() {
+   cd $boot_dir
+   rm -If vmlinuz-$kernel_version System.map-$kernel_version config-$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"

scripts/prune-kernel line 39

Quoted 10 lines
scripts/prune-kernel +10 -0
+   return 0
+}
+
+case "$flag" in
+   -i | --interactive)
+           printf "\nEnter kernel version to remove or blank/empty to exit:"
+           read kernel_version
+           if [[ $kernel_version != "" ]]; then
+                   remove_old_kernel
+                   printf "\nRemoved kernel version:$kernel_version from the system.\n\n"

space after ':'

drop one \n above.

scripts/prune-kernel line 44

Quoted 5 lines
scripts/prune-kernel +5 -0
+                   printf "Please give the full modules directory name to remove:"
+                   read modules_version
+                   if [[ $modules_version != "" ]]; then
+                           remove_old_modules_dir
+                           printf "\n\nRemoved modules directory:$modules_version from the system.\n\n"

space after ':'

drop one \n above.

Quoted 18 lines
scripts/prune-kernel +18 -0
+                   else
+                           exit 1
+                   fi
+           fi
+           ;;
+   -h | --help)
+           usage
+           exit 0
+           ;;
+   -r | --remove)
+           if [[ $# -ne 3 ]]; then
+                    printf "You need to provide kernel version and modules directory name.\n"
+                    exit 1
+            else
+                    remove_old_kernel
+                    remove_old_modules_dir
+           fi
+           ;;

scripts/prune-kernel line 69

Quoted 10 lines
scripts/prune-kernel +5 -3
+   *)
+           usage
+           exit 1
+           ;;
+esac
 
-# 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:
 

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.

Quoted 11 lines
scripts/prune-kernel +0 -11
-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"
Quoted 8 lines
Quoted 8 lines

scripts/prune-kernel

Quoted 4 lines
scripts/prune-kernel +0 -4
-                new-kernel-pkg --remove $f
-        fi
-done
--

--
~Randy

--
Best Regards

Masahiro Yamada

Signature · 2 lines
Best Regards
Masahiro Yamada
#8 lore raw
Quoted 45 lines · Masahiro Yamada
Quoted 29 lines · Bhaskar Chowdhury
Quoted 27 lines · Masahiro Yamada
Quoted 25 lines · J. Bruce Fields
Quoted 5 lines · Randy Dunlap
Quoted 4 lines · Bhaskar Chowdhury

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.

Quoted 8 lines
Quoted 4 lines
---
 scripts/prune-kernel | 82 +++++++++++++++++++++++++++++++++++---------
 1 file changed, 65 insertions(+), 17 deletions(-)

Hi,
I believe that this script now does what the patch author intends it 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 doing 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.

Quoted 7 lines
Quoted 4 lines

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

Quoted 7 lines

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???

Quoted 3 lines

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.

Quoted 1 line

And now it requires -r option for the default behavior.

Because other flags are involved and they do different things.

Quoted 2 lines

I see nothing cool overall.

Meh... I am interpreting you "cool" literal way...which you certainly didn't mean it...do you??

Quoted 7 lines

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.

Quoted 4 lines

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.

Quoted 5 lines

Masahiro

Bhaskar

Quoted 148 lines
Quoted 142 lines
Quoted 142 lines

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

Quoted 107 lines
Quoted 107 lines
Quoted 34 lines
scripts/prune-kernel +27 -0
index e8aa940bc0a9..01d0778db71f 100755
@@ -1,21 +1,69 @@
 #!/bin/bash
 # SPDX-License-Identifier: GPL-2.0
+#This script will remove old kernels and modules directory related to it.
+#"-r" or "--remove" show how to silently remove old kernel and modules dir.
+# "-h" or "--help" show how to use this script or show without parameter.
+#"-i" or "--interactive" show how to remove interactively.
+
+flag=$1
+kernel_version=$2
+modules_version=$3
+boot_dir=/boot
+modules_dir=/lib/modules
+
+remove_old_kernel() {
+   cd $boot_dir
+   rm -If vmlinuz-$kernel_version System.map-$kernel_version config-$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"

scripts/prune-kernel line 39

Quoted 10 lines
scripts/prune-kernel +10 -0
+   return 0
+}
+
+case "$flag" in
+   -i | --interactive)
+           printf "\nEnter kernel version to remove or blank/empty to exit:"
+           read kernel_version
+           if [[ $kernel_version != "" ]]; then
+                   remove_old_kernel
+                   printf "\nRemoved kernel version:$kernel_version from the system.\n\n"

space after ':'

drop one \n above.

scripts/prune-kernel line 44

Quoted 5 lines
scripts/prune-kernel +5 -0
+                   printf "Please give the full modules directory name to remove:"
+                   read modules_version
+                   if [[ $modules_version != "" ]]; then
+                           remove_old_modules_dir
+                           printf "\n\nRemoved modules directory:$modules_version from the system.\n\n"

space after ':'

drop one \n above.

Quoted 18 lines
scripts/prune-kernel +18 -0
+                   else
+                           exit 1
+                   fi
+           fi
+           ;;
+   -h | --help)
+           usage
+           exit 0
+           ;;
+   -r | --remove)
+           if [[ $# -ne 3 ]]; then
+                    printf "You need to provide kernel version and modules directory name.\n"
+                    exit 1
+            else
+                    remove_old_kernel
+                    remove_old_modules_dir
+           fi
+           ;;

scripts/prune-kernel line 69

Quoted 10 lines
scripts/prune-kernel +5 -3
+   *)
+           usage
+           exit 1
+           ;;
+esac
 
-# 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:
 

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.

Quoted 11 lines
scripts/prune-kernel +0 -11
-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"
Quoted 8 lines
Quoted 8 lines

scripts/prune-kernel

Quoted 4 lines
scripts/prune-kernel +0 -4
-                new-kernel-pkg --remove $f
-        fi
-done
--

--
~Randy

--
Best Regards

Masahiro Yamada

Signature · 2 lines
Best Regards
Masahiro Yamada
#9 lore raw
In reply to Masahiro Yamada
Quoted 4 lines · Masahiro Yamada

BTW.
Bruce,
Does the current script expect RHEL or something? I do not see 'new-kernel-pkg' on my Ubuntu machine.

I test on Fedora. Looks like on recent Fedora that's only provided by an rpm "grubby-deprecated", which is an inauspicious name....

I think maybe you're supposed to use "grubby" itself now. Do you have that?

Quoted 6 lines

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

Looks like it's what updates the grub configuration, which is probably a nice thing to do if you can.

--b.

#10 lore raw
Quoted 15 lines · J. Bruce Fields
Quoted 4 lines · Masahiro Yamada

BTW.
Bruce,
Does the current script expect RHEL or something? I do not see 'new-kernel-pkg' on my Ubuntu machine.

I test on Fedora. Looks like on recent Fedora that's only provided by an rpm "grubby-deprecated", which is an inauspicious name....

I think maybe you're supposed to use "grubby" itself now. Do you have that?

Quoted 3 lines

It would still work with 'new-kernel-pkg: command not found' warning.

Quoted 6 lines
Quoted 3 lines

We could bypass it if we like.

command -v new-kernel-pkg && new-kernel-pkg --remove $f

Looks like it's what updates the grub configuration, which is probably a nice thing to do if you can.

on openSUSE, I don't have new-kernel-pkg or grubby.

Signature · 1 line
~Randy
#11 lore raw
In reply to J. Bruce Fields
Quoted 15 lines · J. Bruce Fields
Quoted 4 lines · Masahiro Yamada

BTW.
Bruce,
Does the current script expect RHEL or something? I do not see 'new-kernel-pkg' on my Ubuntu machine.

I test on Fedora. Looks like on recent Fedora that's only provided by an rpm "grubby-deprecated", which is an inauspicious name....

I think maybe you're supposed to use "grubby" itself now. Do you have that?

Quoted 3 lines

It would still work with 'new-kernel-pkg: command not found' warning.

Quoted 8 lines
Quoted 3 lines

We could bypass it if we like.

command -v new-kernel-pkg && new-kernel-pkg --remove $f

Looks like it's what updates the grub configuration, which is probably a nice thing to do if you can.

--b.

Bruce,

Two things,

If the system doesn't run grub , how the fallback policy???

This binary "new-kernel-pkg" also missing in other systems too...I can confirm that... i.e gentoo,slackware,

So , you are only targeting the rpm based system????

~
Bhaskar

#12 lore raw
Quoted 27 lines · Bhaskar Chowdhury
Quoted 15 lines · J. Bruce Fields
Quoted 4 lines · Masahiro Yamada

BTW.
Bruce,
Does the current script expect RHEL or something? I do not see 'new-kernel-pkg' on my Ubuntu machine.

I test on Fedora. Looks like on recent Fedora that's only provided by an rpm "grubby-deprecated", which is an inauspicious name....

I think maybe you're supposed to use "grubby" itself now. Do you have that?

Quoted 3 lines

It would still work with 'new-kernel-pkg: command not found' warning.

Quoted 8 lines
Quoted 3 lines

We could bypass it if we like.

command -v new-kernel-pkg && new-kernel-pkg --remove $f

Looks like it's what updates the grub configuration, which is probably a nice thing to do if you can.

--b.

Bruce,

Quoted 8 lines

Two things,

If the system doesn't run grub , how the fallback policy???

This binary "new-kernel-pkg" also missing in other systems too...I can confirm that... i.e gentoo,slackware,

So , you are only targeting the rpm based system????

It's just what I happen to use. If someone wants to make it work elsewhere that'd be great, as long as we don't break what already works.

I think Debian uses grub2-mkconfig? Might be OK for Fedora too, I dunno.

--b.

#13 lore raw
Quoted 37 lines · J. Bruce Fields
Quoted 27 lines · Bhaskar Chowdhury
Quoted 15 lines · J. Bruce Fields
Quoted 4 lines · Masahiro Yamada

BTW.
Bruce,
Does the current script expect RHEL or something? I do not see 'new-kernel-pkg' on my Ubuntu machine.

I test on Fedora. Looks like on recent Fedora that's only provided by an rpm "grubby-deprecated", which is an inauspicious name....

I think maybe you're supposed to use "grubby" itself now. Do you have that?

Quoted 3 lines

It would still work with 'new-kernel-pkg: command not found' warning.

Quoted 8 lines
Quoted 3 lines

We could bypass it if we like.

command -v new-kernel-pkg && new-kernel-pkg --remove $f

Looks like it's what updates the grub configuration, which is probably a nice thing to do if you can.

--b.

Bruce,

Quoted 8 lines

Two things,

If the system doesn't run grub , how the fallback policy???

This binary "new-kernel-pkg" also missing in other systems too...I can confirm that... i.e gentoo,slackware,

So , you are only targeting the rpm based system????

Quoted 7 lines

It's just what I happen to use. If someone wants to make it work elsewhere that'd be great, as long as we don't break what already works.

I think Debian uses grub2-mkconfig? Might be OK for Fedora too, I dunno.

--b.

Okay , thanks for the input. I was trying to write something in generalize way , that is why my code spins off.And if you see the subject line of my very first attempt to patch written was "removing old kernels and modules dir in selective way"... that was it.

Now, there are plenty of distros around, not only rpm based one(yes I do agree that ,you wrote it while using and testing on it, but that is limited in nature),the broader user base might be using something else.

we simply can not restrict it to certain packaging version or several packaging versions of selected distros. We are making and building this (worth an effort) to make it as generalized as possible.

Importantly I was only thinking of people who put the stuff in standard places in the FSH and use it. I might be wrong.

As I have said it before, I was no way trying to bypass your work ,but it seems very limited in nature to adopted. So trying to widen the spectrum.

I am trying to incorporating both the pole, different kind user base in mind, like you , who don't like to be prompted for this operation and assuming things should go well, and you are right.

On the other hand , I am kinda guy , sometime I need to know what is going on, so the prompting.

Well, I have never taken into account about modifying the bootloader config by looking at your work. Had I been, I would have done it already and it would be extremely trivial in nature.

Now, Grub, no doubt it's fantastic piece of software, but complexity is paramount with it. Don't you think so??? I HAVE NOTHING AGAINST GRUB!

I have personally stops using it for years and using something very rudimentary and simple and useful. That is because I know what I am doing and my system well.

Caveat emptor: that was me, not every one else in the wild. Grub is used by the most distro by default,everybody knows it,but certainly not the norm.

I would love to give it a stab again and if you better people feel it is necessary, but I need some concrete understanding from you,Masahiro and Randy(who is helping me actively).

Say, You people might come up ,

We need these :

a)
b)
c)

and we don't need these:

a)
b)
c)

My two cents! kindly, flame me with your thoughts.

~Bhaskar

#14 lore raw
Quoted 102 lines · Bhaskar Chowdhury
Quoted 37 lines · J. Bruce Fields
Quoted 27 lines · Bhaskar Chowdhury
Quoted 15 lines · J. Bruce Fields
Quoted 4 lines · Masahiro Yamada

BTW.
Bruce,
Does the current script expect RHEL or something? I do not see 'new-kernel-pkg' on my Ubuntu machine.

I test on Fedora. Looks like on recent Fedora that's only provided by an rpm "grubby-deprecated", which is an inauspicious name....

I think maybe you're supposed to use "grubby" itself now. Do you have that?

Quoted 3 lines

It would still work with 'new-kernel-pkg: command not found' warning.

Quoted 8 lines
Quoted 3 lines

We could bypass it if we like.

command -v new-kernel-pkg && new-kernel-pkg --remove $f

Looks like it's what updates the grub configuration, which is probably a nice thing to do if you can.

--b.

Bruce,

Quoted 8 lines

Two things,

If the system doesn't run grub , how the fallback policy???

This binary "new-kernel-pkg" also missing in other systems too...I can confirm that... i.e gentoo,slackware,

So , you are only targeting the rpm based system????

Quoted 7 lines

It's just what I happen to use. If someone wants to make it work elsewhere that'd be great, as long as we don't break what already works.

I think Debian uses grub2-mkconfig? Might be OK for Fedora too, I dunno.

--b.

Okay , thanks for the input. I was trying to write something in generalize way , that is why my code spins off.And if you see the subject line of my very first attempt to patch written was "removing old kernels and modules dir in selective way"... that was it.

Now, there are plenty of distros around, not only rpm based one(yes I do agree that ,you wrote it while using and testing on it, but that is limited in nature),the broader user base might be using something else.

we simply can not restrict it to certain packaging version or several packaging versions of selected distros. We are making and building this (worth an effort) to make it as generalized as possible.

Importantly I was only thinking of people who put the stuff in standard places in the FSH and use it. I might be wrong.

As I have said it before, I was no way trying to bypass your work ,but it seems very limited in nature to adopted. So trying to widen the spectrum.

I am trying to incorporating both the pole, different kind user base in mind, like you , who don't like to be prompted for this operation and assuming things should go well, and you are right.

On the other hand , I am kinda guy , sometime I need to know what is going on, so the prompting.

Well, I have never taken into account about modifying the bootloader config by looking at your work. Had I been, I would have done it already and it would be extremely trivial in nature.

Now, Grub, no doubt it's fantastic piece of software, but complexity is paramount with it. Don't you think so??? I HAVE NOTHING AGAINST GRUB!

I have personally stops using it for years and using something very rudimentary and simple and useful. That is because I know what I am doing and my system well.

Caveat emptor: that was me, not every one else in the wild. Grub is used by the most distro by default,everybody knows it,but certainly not the norm.

I would love to give it a stab again and if you better people feel it is necessary, but I need some concrete understanding from you,Masahiro and Randy(who is helping me actively).

Say, You people might come up ,

We need these :

a)
b)
c)

Quoted 8 lines

and we don't need these:

a)
b)
c)

My two cents! kindly, flame me with your thoughts.

Honestly, I did not even know this script before you submitted the patch.

I prune stale kernel/modules with my own script, and I guess people do similar to meet their demand.

I am not sure how many people are using this.
If somebody is passionate to improve this script
in a simple way, that is fine, but
I do not want to see messy code for covering various use-cases.

Signature · 2 lines
Best Regards
Masahiro Yamada
#15 lore raw
Quoted 110 lines · Masahiro Yamada
Quoted 109 lines · Bhaskar Chowdhury
Quoted 37 lines · J. Bruce Fields
Quoted 27 lines · Bhaskar Chowdhury
Quoted 15 lines · J. Bruce Fields
Quoted 4 lines · Masahiro Yamada

BTW.
Bruce,
Does the current script expect RHEL or something? I do not see 'new-kernel-pkg' on my Ubuntu machine.

I test on Fedora. Looks like on recent Fedora that's only provided by an rpm "grubby-deprecated", which is an inauspicious name....

I think maybe you're supposed to use "grubby" itself now. Do you have that?

Quoted 3 lines

It would still work with 'new-kernel-pkg: command not found' warning.

Quoted 8 lines
Quoted 3 lines

We could bypass it if we like.

command -v new-kernel-pkg && new-kernel-pkg --remove $f

Looks like it's what updates the grub configuration, which is probably a nice thing to do if you can.

--b.

Bruce,

Quoted 8 lines

Two things,

If the system doesn't run grub , how the fallback policy???

This binary "new-kernel-pkg" also missing in other systems too...I can confirm that... i.e gentoo,slackware,

So , you are only targeting the rpm based system????

Quoted 7 lines

It's just what I happen to use. If someone wants to make it work elsewhere that'd be great, as long as we don't break what already works.

I think Debian uses grub2-mkconfig? Might be OK for Fedora too, I dunno.

--b.

Okay , thanks for the input. I was trying to write something in generalize way , that is why my code spins off.And if you see the subject line of my very first attempt to patch written was "removing old kernels and modules dir in selective way"... that was it.

Now, there are plenty of distros around, not only rpm based one(yes I do agree that ,you wrote it while using and testing on it, but that is limited in nature),the broader user base might be using something else.

we simply can not restrict it to certain packaging version or several packaging versions of selected distros. We are making and building this (worth an effort) to make it as generalized as possible.

Importantly I was only thinking of people who put the stuff in standard places in the FSH and use it. I might be wrong.

As I have said it before, I was no way trying to bypass your work ,but it seems very limited in nature to adopted. So trying to widen the spectrum.

I am trying to incorporating both the pole, different kind user base in mind, like you , who don't like to be prompted for this operation and assuming things should go well, and you are right.

On the other hand , I am kinda guy , sometime I need to know what is going on, so the prompting.

Well, I have never taken into account about modifying the bootloader config by looking at your work. Had I been, I would have done it already and it would be extremely trivial in nature.

Now, Grub, no doubt it's fantastic piece of software, but complexity is paramount with it. Don't you think so??? I HAVE NOTHING AGAINST GRUB!

I have personally stops using it for years and using something very rudimentary and simple and useful. That is because I know what I am doing and my system well.

Caveat emptor: that was me, not every one else in the wild. Grub is used by the most distro by default,everybody knows it,but certainly not the norm.

I would love to give it a stab again and if you better people feel it is necessary, but I need some concrete understanding from you,Masahiro and Randy(who is helping me actively).

Say, You people might come up ,

We need these :

a)
b)
c)

and we don't need these:

a)
b)
c)

Quoted 6 lines
Quoted 1 line

My two cents! kindly, flame me with your thoughts.

Honestly, I did not even know this script before you submitted the patch.

:)

Quoted 3 lines

I prune stale kernel/modules with my own script, and I guess people do similar to meet their demand.

I do the same.

Quoted 1 line

I am not sure how many people are using this.

Only people who look up in the kernel source scripts directory , nobody else for sure.

Quoted 3 lines

If somebody is passionate to improve this script
in a simple way, that is fine, but
I do not want to see messy code for covering various use-cases.

Agreed. That is why need guideline from you people(You, Randy and Bruce needs to tell me clearly), like what I mentioned, we can do these and we can not do these. I am asking because you people have had more exposure ,so might come up with some valid points to build up.

Quoted 4 lines
Signature · 3 lines
-- 
Best Regards
Masahiro Yamada

Thanks,
Bhaskar

#16 lore raw
Quoted 128 lines · Bhaskar Chowdhury
Quoted 110 lines · Masahiro Yamada
Quoted 109 lines · Bhaskar Chowdhury
Quoted 37 lines · J. Bruce Fields
Quoted 27 lines · Bhaskar Chowdhury
Quoted 15 lines · J. Bruce Fields
Quoted 4 lines · Masahiro Yamada

BTW.
Bruce,
Does the current script expect RHEL or something? I do not see 'new-kernel-pkg' on my Ubuntu machine.

I test on Fedora. Looks like on recent Fedora that's only provided by an rpm "grubby-deprecated", which is an inauspicious name....

I think maybe you're supposed to use "grubby" itself now. Do you have that?

Quoted 3 lines

It would still work with 'new-kernel-pkg: command not found' warning.

Quoted 8 lines
Quoted 3 lines

We could bypass it if we like.

command -v new-kernel-pkg && new-kernel-pkg --remove $f

Looks like it's what updates the grub configuration, which is probably a nice thing to do if you can.

--b.

Bruce,

Quoted 8 lines

Two things,

If the system doesn't run grub , how the fallback policy???

This binary "new-kernel-pkg" also missing in other systems too...I can confirm that... i.e gentoo,slackware,

So , you are only targeting the rpm based system????

Quoted 7 lines

It's just what I happen to use. If someone wants to make it work elsewhere that'd be great, as long as we don't break what already works.

I think Debian uses grub2-mkconfig? Might be OK for Fedora too, I dunno.

--b.

Okay , thanks for the input. I was trying to write something in generalize way , that is why my code spins off.And if you see the subject line of my very first attempt to patch written was "removing old kernels and modules dir in selective way"... that was it.

Now, there are plenty of distros around, not only rpm based one(yes I do agree that ,you wrote it while using and testing on it, but that is limited in nature),the broader user base might be using something else.

we simply can not restrict it to certain packaging version or several packaging versions of selected distros. We are making and building this (worth an effort) to make it as generalized as possible.

Importantly I was only thinking of people who put the stuff in standard places in the FSH and use it. I might be wrong.

As I have said it before, I was no way trying to bypass your work ,but it seems very limited in nature to adopted. So trying to widen the spectrum.

I am trying to incorporating both the pole, different kind user base in mind, like you , who don't like to be prompted for this operation and assuming things should go well, and you are right.

On the other hand , I am kinda guy , sometime I need to know what is going on, so the prompting.

Well, I have never taken into account about modifying the bootloader config by looking at your work. Had I been, I would have done it already and it would be extremely trivial in nature.

Now, Grub, no doubt it's fantastic piece of software, but complexity is paramount with it. Don't you think so??? I HAVE NOTHING AGAINST GRUB!

I have personally stops using it for years and using something very rudimentary and simple and useful. That is because I know what I am doing and my system well.

Caveat emptor: that was me, not every one else in the wild. Grub is used by the most distro by default,everybody knows it,but certainly not the norm.

I would love to give it a stab again and if you better people feel it is necessary, but I need some concrete understanding from you,Masahiro and Randy(who is helping me actively).

Say, You people might come up ,

We need these :

a)
b)
c)

and we don't need these:

a)
b)
c)

Quoted 6 lines
Quoted 1 line

My two cents! kindly, flame me with your thoughts.

Honestly, I did not even know this script before you submitted the patch.

:)

Quoted 3 lines

I prune stale kernel/modules with my own script, and I guess people do similar to meet their demand.

I do the same.

Quoted 1 line

I am not sure how many people are using this.

Only people who look up in the kernel source scripts directory , nobody else for sure.

Quoted 8 lines
Quoted 3 lines

If somebody is passionate to improve this script
in a simple way, that is fine, but
I do not want to see messy code for covering various use-cases.

Agreed. That is why need guideline from you people(You, Randy and Bruce needs to tell me clearly), like what I mentioned, we can do these and we can not do these. I am asking because you people have had more exposure ,so might come up with some valid points to build up.

Quoted 1 line

We have two topics here.

[1] add the interactive option
[2] do nice things for non-rpm systems

They should be done by separate patches.

I think [1] is easy to do in a few liners.

For [2], I am not sure how well it goes
until I see an actual patch.

Signature · 2 lines
Best Regards
Masahiro Yamada
#17 lore raw
Quoted 138 lines · Masahiro Yamada
Quoted 128 lines · Bhaskar Chowdhury
Quoted 110 lines · Masahiro Yamada
Quoted 109 lines · Bhaskar Chowdhury
Quoted 37 lines · J. Bruce Fields
Quoted 27 lines · Bhaskar Chowdhury
Quoted 15 lines · J. Bruce Fields
Quoted 4 lines · Masahiro Yamada

BTW.
Bruce,
Does the current script expect RHEL or something? I do not see 'new-kernel-pkg' on my Ubuntu machine.

I test on Fedora. Looks like on recent Fedora that's only provided by an rpm "grubby-deprecated", which is an inauspicious name....

I think maybe you're supposed to use "grubby" itself now. Do you have that?

Quoted 3 lines

It would still work with 'new-kernel-pkg: command not found' warning.

Quoted 8 lines
Quoted 3 lines

We could bypass it if we like.

command -v new-kernel-pkg && new-kernel-pkg --remove $f

Looks like it's what updates the grub configuration, which is probably a nice thing to do if you can.

--b.

Bruce,

Quoted 8 lines

Two things,

If the system doesn't run grub , how the fallback policy???

This binary "new-kernel-pkg" also missing in other systems too...I can confirm that... i.e gentoo,slackware,

So , you are only targeting the rpm based system????

Quoted 7 lines

It's just what I happen to use. If someone wants to make it work elsewhere that'd be great, as long as we don't break what already works.

I think Debian uses grub2-mkconfig? Might be OK for Fedora too, I dunno.

--b.

Okay , thanks for the input. I was trying to write something in generalize way , that is why my code spins off.And if you see the subject line of my very first attempt to patch written was "removing old kernels and modules dir in selective way"... that was it.

Now, there are plenty of distros around, not only rpm based one(yes I do agree that ,you wrote it while using and testing on it, but that is limited in nature),the broader user base might be using something else.

we simply can not restrict it to certain packaging version or several packaging versions of selected distros. We are making and building this (worth an effort) to make it as generalized as possible.

Importantly I was only thinking of people who put the stuff in standard places in the FSH and use it. I might be wrong.

As I have said it before, I was no way trying to bypass your work ,but it seems very limited in nature to adopted. So trying to widen the spectrum.

I am trying to incorporating both the pole, different kind user base in mind, like you , who don't like to be prompted for this operation and assuming things should go well, and you are right.

On the other hand , I am kinda guy , sometime I need to know what is going on, so the prompting.

Well, I have never taken into account about modifying the bootloader config by looking at your work. Had I been, I would have done it already and it would be extremely trivial in nature.

Now, Grub, no doubt it's fantastic piece of software, but complexity is paramount with it. Don't you think so??? I HAVE NOTHING AGAINST GRUB!

I have personally stops using it for years and using something very rudimentary and simple and useful. That is because I know what I am doing and my system well.

Caveat emptor: that was me, not every one else in the wild. Grub is used by the most distro by default,everybody knows it,but certainly not the norm.

I would love to give it a stab again and if you better people feel it is necessary, but I need some concrete understanding from you,Masahiro and Randy(who is helping me actively).

Say, You people might come up ,

We need these :

a)
b)
c)

and we don't need these:

a)
b)
c)

Quoted 6 lines
Quoted 1 line

My two cents! kindly, flame me with your thoughts.

Honestly, I did not even know this script before you submitted the patch.

:)

Quoted 3 lines

I prune stale kernel/modules with my own script, and I guess people do similar to meet their demand.

I do the same.

Quoted 1 line

I am not sure how many people are using this.

Only people who look up in the kernel source scripts directory , nobody else for sure.

Quoted 8 lines
Quoted 3 lines

If somebody is passionate to improve this script
in a simple way, that is fine, but
I do not want to see messy code for covering various use-cases.

Agreed. That is why need guideline from you people(You, Randy and Bruce needs to tell me clearly), like what I mentioned, we can do these and we can not do these. I am asking because you people have had more exposure ,so might come up with some valid points to build up.

Quoted 1 line
Quoted 3 lines

We have two topics here.

[1] add the interactive option

For that, my last patch stand , I have covered it in a sane way, please try that once more with options.Yes , you said, the modules directory should be pruned at once with kernel. But , every system keeps the modules directory in different names AFAIK. So, the explicitness of the calling.

Quoted 1 line

[2] do nice things for non-rpm systems

Bruce's code cover the base for RPM based system , which can be applied to other similar distribution using that format.Provided I figure out the "unknown binary" in the code.

I might add other packaging format distribution to cover. Those will append behind the existing code.

Quoted 4 lines

They should be done by separate patches.

Agreed. Moduler and clear.

Quoted 2 lines

I think [1] is easy to do in a few liners.

My last patch stand.AFAIK...let me know if you feel it should be done differently.

Quoted 4 lines

For [2], I am not sure how well it goes
until I see an actual patch.

That would be a undertaking to deal with the native packaging system for different distributions.

Quoted 3 lines
Signature · 2 lines
Best Regards
Masahiro Yamada

Thanks,
Bhaskar

#18 lore raw
Quoted 156 lines · Bhaskar Chowdhury
Quoted 138 lines · Masahiro Yamada
Quoted 128 lines · Bhaskar Chowdhury
Quoted 110 lines · Masahiro Yamada
Quoted 109 lines · Bhaskar Chowdhury
Quoted 37 lines · J. Bruce Fields
Quoted 27 lines · Bhaskar Chowdhury
Quoted 15 lines · J. Bruce Fields
Quoted 4 lines · Masahiro Yamada

BTW.
Bruce,
Does the current script expect RHEL or something? I do not see 'new-kernel-pkg' on my Ubuntu machine.

I test on Fedora. Looks like on recent Fedora that's only provided by an rpm "grubby-deprecated", which is an inauspicious name....

I think maybe you're supposed to use "grubby" itself now. Do you have that?

Quoted 3 lines

It would still work with 'new-kernel-pkg: command not found' warning.

Quoted 8 lines
Quoted 3 lines

We could bypass it if we like.

command -v new-kernel-pkg && new-kernel-pkg --remove $f

Looks like it's what updates the grub configuration, which is probably a nice thing to do if you can.

--b.

Bruce,

Quoted 8 lines

Two things,

If the system doesn't run grub , how the fallback policy???

This binary "new-kernel-pkg" also missing in other systems too...I can confirm that... i.e gentoo,slackware,

So , you are only targeting the rpm based system????

Quoted 7 lines

It's just what I happen to use. If someone wants to make it work elsewhere that'd be great, as long as we don't break what already works.

I think Debian uses grub2-mkconfig? Might be OK for Fedora too, I dunno.

--b.

Okay , thanks for the input. I was trying to write something in generalize way , that is why my code spins off.And if you see the subject line of my very first attempt to patch written was "removing old kernels and modules dir in selective way"... that was it.

Now, there are plenty of distros around, not only rpm based one(yes I do agree that ,you wrote it while using and testing on it, but that is limited in nature),the broader user base might be using something else.

we simply can not restrict it to certain packaging version or several packaging versions of selected distros. We are making and building this (worth an effort) to make it as generalized as possible.

Importantly I was only thinking of people who put the stuff in standard places in the FSH and use it. I might be wrong.

As I have said it before, I was no way trying to bypass your work ,but it seems very limited in nature to adopted. So trying to widen the spectrum.

I am trying to incorporating both the pole, different kind user base in mind, like you , who don't like to be prompted for this operation and assuming things should go well, and you are right.

On the other hand , I am kinda guy , sometime I need to know what is going on, so the prompting.

Well, I have never taken into account about modifying the bootloader config by looking at your work. Had I been, I would have done it already and it would be extremely trivial in nature.

Now, Grub, no doubt it's fantastic piece of software, but complexity is paramount with it. Don't you think so??? I HAVE NOTHING AGAINST GRUB!

I have personally stops using it for years and using something very rudimentary and simple and useful. That is because I know what I am doing and my system well.

Caveat emptor: that was me, not every one else in the wild. Grub is used by the most distro by default,everybody knows it,but certainly not the norm.

I would love to give it a stab again and if you better people feel it is necessary, but I need some concrete understanding from you,Masahiro and Randy(who is helping me actively).

Say, You people might come up ,

We need these :

a)
b)
c)

and we don't need these:

a)
b)
c)

Quoted 6 lines
Quoted 1 line

My two cents! kindly, flame me with your thoughts.

Honestly, I did not even know this script before you submitted the patch.

:)

Quoted 3 lines

I prune stale kernel/modules with my own script, and I guess people do similar to meet their demand.

I do the same.

Quoted 1 line

I am not sure how many people are using this.

Only people who look up in the kernel source scripts directory , nobody else for sure.

Quoted 8 lines
Quoted 3 lines

If somebody is passionate to improve this script
in a simple way, that is fine, but
I do not want to see messy code for covering various use-cases.

Agreed. That is why need guideline from you people(You, Randy and Bruce needs to tell me clearly), like what I mentioned, we can do these and we can not do these. I am asking because you people have had more exposure ,so might come up with some valid points to build up.

Quoted 1 line
Quoted 3 lines

We have two topics here.

[1] add the interactive option

For that, my last patch stand , I have covered it in a sane way, please try that once more with options.Yes , you said, the modules directory should be pruned at once with kernel. But , every system keeps the modules directory in different names AFAIK. So, the explicitness of the calling.

Quoted 1 line

[2] do nice things for non-rpm systems

Bruce's code cover the base for RPM based system , which can be applied to other similar distribution using that format.Provided I figure out the "unknown binary" in the code.

I might add other packaging format distribution to cover. Those will append behind the existing code.

Quoted 2 lines
Quoted 10 lines
Quoted 2 lines

They should be done by separate patches.

Agreed. Moduler and clear.

Quoted 2 lines

I think [1] is easy to do in a few liners.

My last patch stand.AFAIK...let me know if you feel it should be done differently.

Quoted 3 lines

For [2], I am not sure how well it goes
until I see an actual patch.

As I said before, your patch is replacing everything, and breaking how it previously worked.

If you want to support the interactive mode, what you need to do is quite simple -
1) check the command line option -i
2) if -i is given, show a prompt before the removal

It would be possible to do these
in smaller changes.
I attached a sample patch.

Quoted 9 lines

That would be a undertaking to deal with the native packaging system for different distributions.

Quoted 3 lines

--
Best Regards
Masahiro Yamada

Thanks,
Bhaskar

Signature · 2 lines
Best Regards
Masahiro Yamada
scripts/prune-kernel +20 -5
index e8aa940bc0a9..9091ee1125f5 100755
@@ -5,6 +5,11 @@
 # again, /boot and /lib/modules/ eventually fill up.
 # Dumb script to purge that stuff:
 
+if [ "$1" = -i ]; then
+	interactive=y
+	shift
+fi
+
 for f in "$@"
 do
         if rpm -qf "/lib/modules/$f" >/dev/null; then
@@ -12,10 +17,20 @@ do
         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
+		for g in $(ls -d /boot/initramfs-$f.img /boot/System.map-$f \
+			   /boot/vmlinuz-$f /boot/config-$f /lib/modules/$f \
+			   2>/dev/null)
+		do
+			if [ "$interactive" = y ]; then
+				printf "remove '$g'? "
+				read ans
+				if [ $ans != Y -a $ans != y ]; then
+					continue
+				fi
+			else
+				echo "removing '$g'"
+			fi
+			rm -rf $g
+		done
         fi
 done
#19 lore raw
In reply to Randy Dunlap
Quoted 10 lines · Randy Dunlap
Quoted 8 lines · Bhaskar Chowdhury

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.

---
 scripts/prune-kernel | 82 +++++++++++++++++++++++++++++++++++---------
 1 file changed, 65 insertions(+), 17 deletions(-)
Quoted 7 lines

Hi,
I believe that this script now does what the patch author intends it to do. It does have a few whitespace issues, but no big deals. (see below)

Thank you Randy..

Quoted 47 lines
Quoted 34 lines
scripts/prune-kernel +27 -0
index e8aa940bc0a9..01d0778db71f 100755
@@ -1,21 +1,69 @@
 #!/bin/bash
 # SPDX-License-Identifier: GPL-2.0
+#This script will remove old kernels and modules directory related to it.
+#"-r" or "--remove" show how to silently remove old kernel and modules dir.
+# "-h" or "--help" show how to use this script or show without parameter.
+#"-i" or "--interactive" show how to remove interactively.
+
+flag=$1
+kernel_version=$2
+modules_version=$3
+boot_dir=/boot
+modules_dir=/lib/modules
+
+remove_old_kernel() {
+	cd $boot_dir
+	rm -If vmlinuz-$kernel_version System.map-$kernel_version config-$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"

scripts/prune-kernel line 39

Quoted 10 lines
scripts/prune-kernel +10 -0
+	return 0
+}
+
+case "$flag" in
+	-i | --interactive)
+		printf "\nEnter kernel version to remove or blank/empty to exit:"
+		read kernel_version
+		if [[ $kernel_version != "" ]]; then
+			remove_old_kernel
+			printf "\nRemoved kernel version:$kernel_version from the system.\n\n"

space after ':'

Quoted 2 lines

drop one \n above.

Will do.

Quoted 10 lines

scripts/prune-kernel line 44

Quoted 5 lines
scripts/prune-kernel +5 -0
+			printf "Please give the full modules directory name to remove:"
+			read modules_version
+			if [[ $modules_version != "" ]]; then
+				remove_old_modules_dir
+				printf "\n\nRemoved modules directory:$modules_version from the system.\n\n"

space after ':'

drop one \n above.

Will do.

Quoted 24 lines
Quoted 24 lines
scripts/prune-kernel +23 -0
+			else
+				exit 1
+			fi
+		fi
+		;;
+	-h | --help)
+		usage
+		exit 0
+		;;
+	-r | --remove)
+		if [[ $# -ne 3 ]]; then
+			 printf "You need to provide kernel version and modules directory name.\n"
+			 exit 1
+		 else
+			 remove_old_kernel
+			 remove_old_modules_dir
+		fi
+		;;
+	*)
+		usage
+		exit 1
+		;;
+esac
 
Quoted 9 lines

scripts/prune-kernel line 69

Quoted 4 lines
scripts/prune-kernel +0 -3
-# 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:
 

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.

Will do.

Quoted 7 lines
Quoted 7 lines
scripts/prune-kernel +0 -7
-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
Quoted 13 lines
Quoted 8 lines
scripts/prune-kernel +0 -8
-                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
--
Signature · 1 line
~Randy

Bhaskar