diff options
author | Ulrich Müller <ulm@gentoo.org> | 2009-06-06 08:37:06 +0000 |
---|---|---|
committer | Ulrich Müller <ulm@gentoo.org> | 2009-06-06 08:37:06 +0000 |
commit | 744966a329fc0f906f2a945fd953da4a5391c920 (patch) | |
tree | fdb2f66766053cd60614384e591f83d4ab332940 /modules/kernel.eselect | |
parent | Add "--unused" option to show status of scripts that are not assigned (diff) | |
download | eselect-744966a329fc0f906f2a945fd953da4a5391c920.tar.gz eselect-744966a329fc0f906f2a945fd953da4a5391c920.tar.bz2 eselect-744966a329fc0f906f2a945fd953da4a5391c920.zip |
Sort kernel versions properly, bug 207889.
svn path=/trunk/; revision=579
Diffstat (limited to 'modules/kernel.eselect')
-rw-r--r-- | modules/kernel.eselect | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/modules/kernel.eselect b/modules/kernel.eselect index d66e336..1e6b710 100644 --- a/modules/kernel.eselect +++ b/modules/kernel.eselect @@ -7,12 +7,32 @@ MAINTAINER="eselect@gentoo.org" SVN_DATE='$Date$' VERSION=$(svn_date_to_version "${SVN_DATE}") +# sort function for kernel versions, to be used in a pipe +sort_kernel_versions() { + local vsort="sort --version-sort" + # Test if our sort supports the --version-sort option + # (it should since the kernel module is Linux specific) + ${vsort} </dev/null &>/dev/null || vsort=sort + + # We sort kernel versions as follows: + # 1. Run sed to prepend the version string by the numeric version + # and an additional rank indicator that is 0 for release candidates + # or 1 otherwise. After this step we have, for example: + # 2.6.29 1 linux-2.6.29 + # 2.6.29 0 linux-2.6.29-rc8 + # 2. sort --version-sort + # 3. Run sed again to remove the prepended keys from step 1. + sed -e 's/^\(linux-\)\?\([[:digit:].]\+\)[-_]rc/\2 0 &/' \ + -e 't;s/^\(linux-\)\?\([[:digit:].]\+\)/\2 1 &/' \ + | ${vsort} | sed 's/.* //' +} + # find a list of kernel symlink targets find_targets() { local f for f in "${ROOT}"/usr/src/linux-[[:digit:]]* ; do [[ -d ${f} ]] && basename "${f}" - done + done | sort_kernel_versions } # try to remove the kernel symlink |