Merge lp:~shnatsel/elementaryos/enchanced-kernel-handling-ebuild into lp:elementaryos/0.1-jupiter

Proposed by Sergey "Shnatsel" Davidoff
Status: Merged
Merged at revision: 89
Proposed branch: lp:~shnatsel/elementaryos/enchanced-kernel-handling-ebuild
Merge into: lp:elementaryos/0.1-jupiter
Diff against target: 64 lines (+44/-3)
1 file modified
conf.sh (+44/-3)
To merge this branch: bzr merge lp:~shnatsel/elementaryos/enchanced-kernel-handling-ebuild
Reviewer Review Type Date Requested Status
Sergey "Shnatsel" Davidoff (community) Approve
Review via email: mp+56766@code.launchpad.net

Description of the change

This branch automates cleanup after kernel upgrades. In Jupiter it's not fully cleaned up and maintaining eBuild when it uses hard-coded kernel version will be time-consuming (read: it's simply a waste of time). It can even remove all the kernels and kernel headers but the latest ones if there are more than two kernel packages installed.

This code is tested on my production machine.

To post a comment you must log in.
Revision history for this message
Sergey "Shnatsel" Davidoff (shnatsel) wrote :

The code was tested in real chroot ISO builds on Natty several times, seems to work fine.

review: Approve
Revision history for this message
Eduard Gotwig (gotwig) wrote :

how can it work fine, if elementary-theme and other packages are not even packaged for natty?

Revision history for this message
Sergey "Shnatsel" Davidoff (shnatsel) wrote :

I mean the kernel handling part. I tested only the kernel part myself, the whole script was tested by other people from #elementary.

Revision history for this message
Sergey "Shnatsel" Davidoff (shnatsel) wrote :

And, for some mysterious reason, they didn't complain about missing theming.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'conf.sh'
2--- conf.sh 2011-03-21 22:45:57 +0000
3+++ conf.sh 2011-04-07 13:29:29 +0000
4@@ -163,8 +163,49 @@
5 apt-get update -f -y
6 apt-get dist-upgrade -f -y --allow-unauthenticated
7
8-# Remove obsolete kernel packages (and only use new one in updates)
9-apt-get remove -f -y --purge linux-image-2.6.35-22
10+# START BLOCK: Remove obsolete kernel packages (and only use new one in updates)
11+
12+# Find package name for the oldest kernel image currently installed
13+old_linux_image=$(dpkg-query -W 'linux-image-2.*' | rev | cut -b 2- | rev | cut -s -f1 | grep generic | head -n 1)
14+
15+# The same for headers-generic
16+old_linux_headers_generic=$(dpkg-query -W 'linux-headers-2.*' | rev | cut -b 2- | rev | cut -s -f1 | grep generic | head -n 1)
17+
18+# Determine the name of headers metapackage (without -generic)
19+old_linux_headers=$(echo "$old_linux_headers_generic" | cut -d'-' -f1-4)
20+
21+
22+# Find package name for the newest kernel image currently installed
23+new_linux_image=$(dpkg-query -W 'linux-image-2.*' | rev | cut -b 2- | rev | cut -s -f1 | grep generic | tail -n 1)
24+
25+# The same for headers-generic
26+new_linux_headers_generic=$(dpkg-query -W 'linux-headers-2.*' | rev | cut -b 2- | rev | cut -s -f1 | grep generic | tail -n 1)
27+
28+# Determine the name of headers metapackage (without -generic)
29+new_linux_headers=$(echo "$new_linux_headers_generic" | cut -d'-' -f1-4)
30+
31+# Remove all kernel images but the most recent one
32+while [ "$old_linux_image" != "$new_linux_image" ]
33+do
34+apt-get remove -f -y --purge "$old_linux_image"
35+
36+# Find package name for the oldest kernel image currently installed
37+old_linux_image=$(dpkg-query -W 'linux-image-2.*' | rev | cut -b 2- | rev | cut -s -f1 | grep generic | head -n 1)
38+done
39+
40+# Remove all kernel headers but the most recent ones
41+while [ "$old_linux_headers" != "$new_linux_headers" ]
42+do
43+apt-get remove -f -y --purge "$old_linux_headers"
44+
45+# Find package name for the oldest headers currently installed
46+old_linux_headers_generic=$(dpkg-query -W 'linux-headers-2.*' | rev | cut -b 2- | rev | cut -s -f1 | grep generic | head -n 1)
47+
48+# Determine the name of headers metapackage (without -generic)
49+old_linux_headers=$(echo "$old_linux_headers_generic" | cut -d'-' -f1-4)
50+done
51+
52+# END BLOCK: Remove obsolete kernel packages (and only use new one in updates)
53
54 # Install apps for elementary deskop --no-install-recommends
55 apt-get install -f -y --no-install-recommends --allow-unauthenticated abiword abiword-plugin-grammar bcmwl-kernel-source cups contractor dexter dockmanager docky elementary-theme elementary-icon-theme elementary-wallpapers gdebi gdebi-core gloobus-preview gnumeric indicator-applet-complete indicator-datetime libgl1-mesa-dri-experimental midori nautilus ntp purple postler plymouth-theme-elementary-logo preload telepathy-salut ttf-droid ttf-unifont ttf-dejavu zeitgeist zeitgeist-fts-extension
56@@ -235,7 +276,7 @@
57 mkdir -p /usr/share/themes/Ambiance/gtk-2.0/apps/img/
58 ln -s /usr/share/themes/elementary/gtk-2.0/Panel/panel-dark.png /usr/share/themes/Ambiance/gtk-2.0/apps/img/panel.png
59
60-# Kill the destop with fire
61+# Kill the desktop with fire
62 cp /tmp/user-dirs.defaults /etc/xdg/
63 cp /tmp/rm.desktop /etc/skel/.config/autostart/
64 cp /tmp/killdesktop.sh /home

Subscribers

People subscribed via source and target branches