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

Collapse All | Expand All

(-)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 --kernel-release)
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 901205