Lines 2-22
Link Here
|
2 |
# Distributed under the terms of the GNU General Public License v2 |
2 |
# Distributed under the terms of the GNU General Public License v2 |
3 |
# $Id: kernel.eselect 367 2007-03-28 14:35:23Z pioto $ |
3 |
# $Id: kernel.eselect 367 2007-03-28 14:35:23Z pioto $ |
4 |
|
4 |
|
5 |
DESCRIPTION="Manage the /usr/src/linux symlink" |
5 |
case `uname -s` in |
|
|
6 |
FreeBSD) KERNEL="sys";; |
7 |
*) KERNEL="linux";; |
8 |
esac |
9 |
|
10 |
DESCRIPTION="Manage the /usr/src/$KERNEL symlink" |
6 |
MAINTAINER="ciaranm@gentoo.org" |
11 |
MAINTAINER="ciaranm@gentoo.org" |
7 |
SVN_DATE='$Date: 2007-03-28 10:35:23 -0400 (Wed, 28 Mar 2007) $' |
12 |
SVN_DATE='$Date: 2007-03-28 10:35:23 -0400 (Wed, 28 Mar 2007) $' |
8 |
VERSION=$(svn_date_to_version "${SVN_DATE}" ) |
13 |
VERSION=$(svn_date_to_version "${SVN_DATE}" ) |
9 |
|
14 |
|
10 |
# find a list of kernel symlink targets |
15 |
# find a list of kernel symlink targets |
11 |
find_targets() { |
16 |
find_targets() { |
12 |
for f in ${ROOT}/usr/src/linux-[[:digit:]]* ; do |
17 |
for f in ${ROOT}/usr/src/$KERNEL-[[:digit:]]* ; do |
13 |
[[ -d ${f} ]] && echo $(basename ${f} ) |
18 |
[[ -d ${f} ]] && echo $(basename ${f} ) |
14 |
done |
19 |
done |
15 |
} |
20 |
} |
16 |
|
21 |
|
17 |
# try to remove the kernel symlink |
22 |
# try to remove the kernel symlink |
18 |
remove_symlink() { |
23 |
remove_symlink() { |
19 |
rm "${ROOT}/usr/src/linux" |
24 |
rm "${ROOT}/usr/src/$KERNEL" |
20 |
} |
25 |
} |
21 |
|
26 |
|
22 |
# set the kernel symlink |
27 |
# set the kernel symlink |
Lines 30-40
Link Here
|
30 |
die -q "Target \"${1}\" doesn't appear to be valid!" |
35 |
die -q "Target \"${1}\" doesn't appear to be valid!" |
31 |
elif [[ -d "${ROOT}/usr/src/${target}" ]] ; then |
36 |
elif [[ -d "${ROOT}/usr/src/${target}" ]] ; then |
32 |
pushd "${ROOT}/usr/src" 1>/dev/null |
37 |
pushd "${ROOT}/usr/src" 1>/dev/null |
33 |
ln -s "${target}" "linux" |
38 |
ln -s "${target}" "$KERNEL" |
34 |
popd 1>/dev/null |
39 |
popd 1>/dev/null |
35 |
elif [[ -d "${ROOT}/usr/src/linux-${target}" ]] ; then |
40 |
elif [[ -d "${ROOT}/usr/src/$KERNEL-${target}" ]] ; then |
36 |
pushd "${ROOT}/usr/src" 1>/dev/null |
41 |
pushd "${ROOT}/usr/src" 1>/dev/null |
37 |
ln -s "linux-${target}" "linux" |
42 |
ln -s "$KERNEL-${target}" "$KERNEL" |
38 |
popd 1>/dev/null |
43 |
popd 1>/dev/null |
39 |
else |
44 |
else |
40 |
die -q "Target \"${1}\" doesn't appear to be valid!" |
45 |
die -q "Target \"${1}\" doesn't appear to be valid!" |
Lines 51-58
Link Here
|
51 |
local kernel |
56 |
local kernel |
52 |
|
57 |
|
53 |
write_list_start "Current kernel symlink:" |
58 |
write_list_start "Current kernel symlink:" |
54 |
if [[ -L "${ROOT}/usr/src/linux" ]] ; then |
59 |
if [[ -L "${ROOT}/usr/src/$KERNEL" ]] ; then |
55 |
kernel=$(canonicalise ${ROOT}/usr/src/linux ) |
60 |
kernel=$(canonicalise ${ROOT}/usr/src/$KERNEL ) |
56 |
write_kv_list_entry "${kernel%/}" "" |
61 |
write_kv_list_entry "${kernel%/}" "" |
57 |
else |
62 |
else |
58 |
write_kv_list_entry "(unset)" "" |
63 |
write_kv_list_entry "(unset)" "" |
Lines 71-77
Link Here
|
71 |
if [[ -n ${targets[@]} ]] ; then |
76 |
if [[ -n ${targets[@]} ]] ; then |
72 |
local i |
77 |
local i |
73 |
for (( i = 0 ; i < ${#targets[@]} ; i = i + 1 )) ; do |
78 |
for (( i = 0 ; i < ${#targets[@]} ; i = i + 1 )) ; do |
74 |
[[ ${targets[${i}]} == $(basename $(canonicalise ${ROOT}/usr/src/linux)) ]] && \ |
79 |
[[ ${targets[${i}]} == $(basename $(canonicalise ${ROOT}/usr/src/$KERNEL)) ]] && \ |
75 |
targets[${i}]="${targets[${i}]} $(highlight '*' )" |
80 |
targets[${i}]="${targets[${i}]} $(highlight '*' )" |
76 |
done |
81 |
done |
77 |
write_numbered_list "${targets[@]}" |
82 |
write_numbered_list "${targets[@]}" |
Lines 99-105
Link Here
|
99 |
# no parameter |
104 |
# no parameter |
100 |
die -q "You didn't tell me what to set the symlink to" |
105 |
die -q "You didn't tell me what to set the symlink to" |
101 |
|
106 |
|
102 |
elif [[ -L "${ROOT}/usr/src/linux" ]] ; then |
107 |
elif [[ -L "${ROOT}/usr/src/$KERNEL" ]] ; then |
103 |
# existing symlink |
108 |
# existing symlink |
104 |
if ! remove_symlink ; then |
109 |
if ! remove_symlink ; then |
105 |
die -q "Couldn't remove existing symlink" |
110 |
die -q "Couldn't remove existing symlink" |
Lines 107-115
Link Here
|
107 |
die -q "Couldn't set a new symlink" |
112 |
die -q "Couldn't set a new symlink" |
108 |
fi |
113 |
fi |
109 |
|
114 |
|
110 |
elif [[ -e "${ROOT}/usr/src/linux" ]] ; then |
115 |
elif [[ -e "${ROOT}/usr/src/$KERNEL" ]] ; then |
111 |
# we have something strange |
116 |
# we have something strange |
112 |
die -q "Sorry, ${ROOT}/usr/src/linux confuses me" |
117 |
die -q "Sorry, ${ROOT}/usr/src/$KERNEL confuses me" |
113 |
|
118 |
|
114 |
else |
119 |
else |
115 |
set_symlink "${1}" || die -q "Couldn't set a new symlink" |
120 |
set_symlink "${1}" || die -q "Couldn't set a new symlink" |