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 / +75 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 && ]]; then
145
		if [[ ! -L ${EROOT}/usr/src/linux ]]; then
146
			# we have something strange
147
			die -q "${EROOT}/usr/src/linux exists but is not a symlink"
148
		fi
149
150
		if [[ $1 == ifunset ]]; then
151
			# The /usr/src/linux symlink exists, points to a path that
152
			# exists, and 'ifunset' is provided. Nothing to do.
153
			return
154
		fi
155
	fi
156
157
	local targets=( $(find_targets) )
158
	if [[ ${#targets[@]} -eq 0 ]]; then
159
		die -q "No target kernel-source trees found"
160
	fi
161
162
	local running_kernel_release
163
	running_kernel_release=$(uname -r)
164
	if (( $? > 0 )); then
165
		die -q "Executing uname failed with $?"
166
	fi
167
	local running_kernel_symlink_target="linux-${running_kernel_release}"
168
169
	if [[ -e ${EROOT}/usr/src/linux ]]; then
170
		local current_target
171
		current_target=$(basename "$(canonicalise "${EROOT}/usr/src/linux")")
172
		if [[ ${current_target} == "${running_kernel_symlink_target}" ]]; then
173
			# The /usr/src/linux symlink already points to the running
174
			# kernel's sources. Nothing to do.
175
			return
176
		fi
177
	fi
178
179
	local target
180
	local target_list=()
181
	for target in "${targets[@]}"; do
182
		if [[ ${target} == "${running_kernel_symlink_target}" ]]; then
183
			set_symlink "${target}"
184
			return
185
		fi
186
		target_list+=("\n- ${target}")
187
	done
188
189
	write_error_msg "No kernel sources for running kernel ${running_kernel_release} found."
190
	if ! is_output_mode brief; then
191
	   do_list >&2
192
	fi
193
	die -q "Could not update the kernel symlink"
194
}
195
196
### helper functions ###
197
198
test_for_root() {
199
	if [[ ! -w ${EROOT}/usr/src ]]; then
200
		die -q "${EROOT}/usr/src not writeable by current user. Are you root?"
201
	fi
202
}

Return to bug 901209