megabaks / kernel-cleaner

12 stars 2 forks source link

Tidyup support for System.map-genkernel... files in /boot? #2

Open bobwya opened 9 years ago

bobwya commented 9 years ago

Hi,

I like your little kernel cleaner utility... I thought it perhaps would clear out all the left-over kernel files in /boot... But I'm seeing the following (after some cleaning up using kernel-cleaner)...

-rw------- 1 root root  11M Mar 16 15:17 initramfs-genkernel-x86_64-3.17.8-gentoo-r1
-rw------- 1 root root 5.6M Mar 30 16:39 initramfs-genkernel-x86_64-3.18.0-gentoo
-rw------- 1 root root  11M Mar 26 14:49 initramfs-genkernel-x86_64-3.18.10-gentoo
-rw------- 1 root root 5.6M Mar 30 16:57 initramfs-genkernel-x86_64-3.18.1-gentoo
-rw------- 1 root root  11M Mar 16 15:03 initramfs-genkernel-x86_64-3.19.1-gentoo
-rw------- 1 root root  11M Mar 26 14:17 initramfs-genkernel-x86_64-3.19.2-gentoo
-rw-r--r-- 1 root root    0 Feb 10 15:35 .keep
-rw-r--r-- 1 root root 5.3M Mar 16 15:09 kernel-genkernel-x86_64-3.17.8-gentoo-r1
-rw-r--r-- 1 root root 5.3M Mar 26 14:41 kernel-genkernel-x86_64-3.18.10-gentoo
-rw-r--r-- 1 root root 5.3M Mar 30 16:49 kernel-genkernel-x86_64-3.18.9-gentoo
-rw-r--r-- 1 root root 5.3M Mar 16 14:54 kernel-genkernel-x86_64-3.19.1-gentoo
-rw-r--r-- 1 root root 5.3M Mar 26 14:09 kernel-genkernel-x86_64-3.19.2-gentoo
-rw-r--r-- 1 root root 2.7M Mar 16 15:09 System.map-genkernel-x86_64-3.17.8-gentoo-r1
-rw-r--r-- 1 root root 2.7M Mar 26 14:41 System.map-genkernel-x86_64-3.18.10-gentoo
-rw-r--r-- 1 root root 2.7M Feb  6 08:07 System.map-genkernel-x86_64-3.18.4-gentoo
-rw-r--r-- 1 root root 2.7M Mar 16 15:51 System.map-genkernel-x86_64-3.18.8-gentoo
-rw-r--r-- 1 root root 2.7M Mar 30 16:49 System.map-genkernel-x86_64-3.18.9-gentoo
-rw-r--r-- 1 root root 2.7M Mar 16 16:15 System.map-genkernel-x86_64-3.19.0-gentoo
-rw-r--r-- 1 root root 2.7M Mar 16 14:54 System.map-genkernel-x86_64-3.19.1-gentoo
-rw-r--r-- 1 root root 2.7M Mar 26 14:09 System.map-genkernel-x86_64-3.19.2-gentoo
megabaks commented 9 years ago

my pc dead and i have not time now. sorry.

bobwya commented 9 years ago

If you don't mind I'll try and get around to fixing a few issues and perhaps do a pull request? It's a useful script after all. :-) Thanks

megabaks commented 9 years ago

ok

megabaks commented 9 years ago

news?

bobwya commented 9 years ago

Line 306 is borked... Back slashes, in the system map file path (m_file), break the BASH substitution replacement you used...

    MAPS_ORPHANS="${MAPS_ORPHANS/"${m_file}"*/}"

A simple fix is...

   MAPS_ORPHANS=$( echo "${MAPS_ORPHANS}" | awk -vm_file="${m_file}" \
                                    '{if ($0 != m_file) print $0; }' )

That covers the issue I noticed... But I see you've used that "hack" in a few other places! The same fix would apply to these instances as well...

I'll probably bash on (excuse the pun!) and tidy the code up a bit...

  1. There's extensive use of the ls command - which shouldn't be seen anywhere in a BASH script!
  2. Kernel selection could be a bit less painful (i.e. boom multiple kernels are selected)...
  3. I'll do some punctuation tidy up in the user facing text.

It'll be up to you if you want to pull in the changes or I'll just maintain a fork on Github...

megabaks commented 9 years ago

Collaborators : Robert Walker you can fix original :3

megabaks commented 9 years ago

what you wait!? you have rw perms...

bobwya commented 9 years ago

Hi megabaks, Sorry, but I'm only part way through a major re-factoring of the script. My flatmate keeps dumping broken computer equipment on me to repair and I've got my day job, allotment, etc. = quite busy!! I can't push what I've done or major parts of the script won't work at present. Hopefully I'll get it all sorted before I go away on hols in 2 weeks...