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 14-19 kernel.eselect \- The kernel symlink management module for Gentoo's eselect Link Here
14
.I target
14
.I target
15
.br
15
.br
16
.B eselect kernel show
16
.B eselect kernel show
17
.br
18
.B eselect kernel update [ifunset]
17
.SH DESCRIPTION
19
.SH DESCRIPTION
18
.B eselect
20
.B eselect
19
is Gentoo's configuration and management tool.  It features modules
21
is Gentoo's configuration and management tool.  It features modules
Lines 45-50 output). Link Here
45
.B eselect kernel show
47
.B eselect kernel show
46
.br
48
.br
47
Show the currently selected kernel.
49
Show the currently selected kernel.
50
.SH ACTION: UPDATE
51
.B eselect kernel update [ifunset]
52
.br
53
Updates the /usr/src/linux symlink to point to the sources of the
54
running kernel.  If
55
.IR ifunset
56
is given, then the symlink will only be updated if it is not currently
57
pointing to a valid kernel source tree.
48
.SH AUTHOR
58
.SH AUTHOR
49
Aaron Walker <ka0ttic@gentoo.org>
59
Aaron Walker <ka0ttic@gentoo.org>
50
.SH SEE ALSO
60
.SH SEE ALSO
(-)a/modules/kernel.eselect (-1 / +73 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 && -e ${EROOT}/usr/src/linux ]]; then
150
		# The /usr/src/linux symlink exists, points to a path that
151
		# exists, and 'ifunset' is provided. Nothing to do.
152
		return
153
	fi
154
155
	local targets=( $(find_targets) )
156
	if [[ ${#targets[@]} -eq 0 ]]; then
157
		die -q "No target kernel-source trees found"
158
	fi
159
160
	local running_kernel_release
161
	running_kernel_release=$(uname -r)
162
	if (( $? > 0 )); then
163
		die -q "Executing uname failed with $?"
164
	fi
165
	local running_kernel_symlink_target="linux-${running_kernel_release}"
166
167
	if [[ -e ${EROOT}/usr/src/linux ]]; then
168
		local current_target
169
		current_target=$(basename "$(canonicalise "${EROOT}/usr/src/linux")")
170
		if [[ ${current_target} == "${running_kernel_symlink_target}" ]]; then
171
			# The /usr/src/linux symlink already points to the running
172
			# kernel's sources. Nothing to do.
173
			return
174
		fi
175
	fi
176
177
	local target
178
	local target_list=()
179
	for target in "${targets[@]}"; do
180
		if [[ ${target} == "${running_kernel_symlink_target}" ]]; then
181
			set_symlink "${target}"
182
			return
183
		fi
184
		target_list+=("\n- ${target}")
185
	done
186
187
	write_error_msg "No kernel sources for running kernel ${running_kernel_release} found."
188
	if ! is_output_mode brief; then
189
	   do_list >&2
190
	fi
191
	die -q "Could not update the kernel symlink"
192
}
193
194
### helper functions ###
195
196
test_for_root() {
197
	if [[ ! -w ${EROOT}/usr/src ]]; then
198
		die -q "${EROOT}/usr/src not writeable by current user. Are you root?"
199
	fi
200
}

Return to bug 901209