Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 901209 | Differences between
and this patch

Collapse All | Expand All

(-)a/man/kernel.eselect.5 (+10 lines)
Lines 10-15 kernel.eselect \- The kernel symlink management module for Gentoo's eselect Link Here
10
.br
10
.br
11
.B eselect kernel list
11
.B eselect kernel list
12
.br
12
.br
13
.B eselect kernel update [ifunset]
14
br
13
.B eselect kernel set
15
.B eselect kernel set
14
.I target
16
.I target
15
.br
17
.br
Lines 30-35 Available kernel symlink targets: Link Here
30
  [1]   linux-2.6.11.11
32
  [1]   linux-2.6.11.11
31
  [2]   linux-2.6.12.5 *
33
  [2]   linux-2.6.12.5 *
32
  [3]   linux-2.6.13-rc6
34
  [3]   linux-2.6.13-rc6
35
.SH ACTION: UPDATE
36
.B eselect kernel update [ifunset]
37
.br
38
Updates the /usr/src/linux symlink to point to the sources of the
39
running kernel.  If
40
.IR ifunset
41
is given, then the symlink will only be updated if it is not currently
42
pointing to a valid kernel source tree.
33
.SH ACTION: SET
43
.SH ACTION: SET
34
.B eselect kernel set
44
.B eselect kernel set
35
.I target
45
.I target
(-)a/modules/kernel.eselect (-1 / +64 lines)
Lines 125-127 do_set() { Link Here
125
125
126
	set_symlink "$1" || die -q "Couldn't set a new symlink"
126
	set_symlink "$1" || die -q "Couldn't set a new symlink"
127
}
127
}
128
- 
128
129
### update action ###
130
131
describe_update() {
132
	echo "Update the kernel symlink to running kernel"
133
}
134
135
describe_update_options() {
136
	echo "ifunset: Do not override currently set version"
137
}
138
139
do_update() {
140
	[[ -z $1 || $1 == ifunset ]] || die -q "Usage error"
141
	[[ $# -gt 1 ]] && die -q "Too many parameters"
142
	test_for_root
143
144
	if [[ -e ${EROOT}/usr/src/linux && ! -L ${EROOT}/usr/src/linux ]]; then
145
		# we have something strange
146
		die -q "${EROOT}/usr/src/linux exists but is not a symlink"
147
	fi
148
149
	if [[ $1 == ifunset \
150
			  && -L ${EROOT}/usr/src/linux \
151
			  && -e ${EROOT}/usr/src/linux ]]; then
152
		# The /usr/src/linux symlink exists, points to a path that
153
		# exists, and 'ifunset' is provided. Nothing to do.
154
		return
155
	fi
156
157
	local targets=( $(find_targets) )
158
	local running_kernel_release=$(uname -r)
159
	local running_kernel_symlink_target="linux-${running_kernel_release}"
160
161
	if [[ -L ${EROOT}/usr/src/linux ]]; then
162
		local current_target
163
		current_target=$(basename "$(canonicalise "${EROOT}/usr/src/linux")")
164
		if [[ ${current_target} == ${running_kernel_symlink_target} ]]; then
165
			# The /usr/src/linux symlink already points to the running
166
			# kernel's sources. Nothing to do.
167
			return
168
		fi
169
	fi
170
171
	local target
172
	local target_list=()
173
	for target in ${targets[@]}; do
174
		if [[ ${target} == ${current_kernel_symlink_target} ]]; then
175
			set_symlink "${target}"
176
			return
177
		fi
178
		target_list+=("- ${target}\n")
179
	done
180
181
	local msg
182
	msg="No kernel sources for running kernel ${running_kernel_release} found."
183
	msg+=" Available sources:\n${target_list[@]}"
184
	die -q "${msg}"
185
}
186
187
### helper functions ###
188
189
test_for_root() {
190
	[[ -w ${EROOT}/usr/src ]] || die -q "${EROOT}/usr/src not writeable by current user. Are you root?"
191
}

Return to bug 901209