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

Collapse All | Expand All

(-)app-admin/eselect-maven/files/maven-0.2.eselect (-10 / +35 lines)
Lines 8-13 Link Here
8
VERSION="0.2"
8
VERSION="0.2"
9
9
10
MVN="${EROOT}/usr/bin/mvn"
10
MVN="${EROOT}/usr/bin/mvn"
11
MVNDEBUG="${EROOT}/usr/bin/mvnDebug"
11
12
12
# find a list of mvn symlink targets, best first.
13
# find a list of mvn symlink targets, best first.
13
find_targets() {
14
find_targets() {
Lines 35-45 Link Here
35
	fi
36
	fi
36
}
37
}
37
38
39
# get a named or numbered target for the debug script.
40
find_debug_target() {
41
	local target=$(find_target ${1} | sed -r 's/(mvn)(-.*)/\1Debug\2/')
42
43
	if [[ -n "${target}" ]] && [[ -f "${EROOT}/usr/bin/${target}" ]] ; then
44
		echo ${target}
45
	else
46
		die -q "Target \"${1}\" doesn't appear to be valid!"
47
	fi
48
}
49
38
# try to remove the mvn symlink.
50
# try to remove the mvn symlink.
39
remove_symlink() {
51
remove_symlink() {
40
	rm "${MVN}" &>/dev/null
52
	rm "${MVN}" &>/dev/null
41
}
53
}
42
54
55
# try to remove the mvnDebug symlink.
56
remove_debug_symlink() {
57
	rm "${MVNDEBUG}" &>/dev/null
58
}
59
60
# try to remove the mvn symlink.
61
remove_symlinks() {
62
	remove_symlink && remove_debug_symlink
63
}
64
43
# determine the current target.
65
# determine the current target.
44
get_target() {
66
get_target() {
45
	local canonicalised=$(canonicalise "${MVN}")
67
	local canonicalised=$(canonicalise "${MVN}")
Lines 53-58 Link Here
53
	ln -s "${target}" "${MVN}" || die "Couldn't set ${target} symlink."
75
	ln -s "${target}" "${MVN}" || die "Couldn't set ${target} symlink."
54
}
76
}
55
77
78
# set the Maven debug (mvnDebug) symlink.
79
set_debug_symlink() {
80
	local target=$(find_debug_target "${1}")
81
	remove_debug_symlink
82
	ln -s "${target}" "${MVNDEBUG}" || die "Couldn't set ${target} symlink."
83
}
84
56
### show action ###
85
### show action ###
57
86
58
describe_show() {
87
describe_show() {
Lines 122-137 Link Here
122
151
123
	if [[ -z "${target}" ]] ; then
152
	if [[ -z "${target}" ]] ; then
124
		die -q "You didn't give me a target name or number."
153
		die -q "You didn't give me a target name or number."
125
	elif [[ -L "${MVN}" ]] ; then
154
	elif [[ -e "${MVN}" && ! -L "${MVN}" ]] ; then
126
		if ! remove_symlink ; then
127
			die -q "Can't remove existing Maven provider."
128
		elif ! set_symlink "${1}" ; then
129
			die -q "Can't set new Maven provider."
130
		fi
131
	elif [[ -e "${MVN}" ]] ; then
132
		write_warning_msg "Can't set a new Maven provider. There's a file in the way at ${MVN}. You can try removing it manually, and then re-running this command."
155
		write_warning_msg "Can't set a new Maven provider. There's a file in the way at ${MVN}. You can try removing it manually, and then re-running this command."
133
	else
156
	elif [[ -e "${MVNDEBUG}" && ! -L "${MVNDEBUG}" ]] ; then
134
		set_symlink "${target}" || die -q "Wasn't able to set a new provider."
157
		write_warning_msg "Can't set a new Maven provider. There's a file in the way at ${MVNDEBUG}. You can try removing it manually, and then re-running this command."
158
	elif ! set_symlink "${target}" || ! set_debug_symlink "${target}" ; then
159
		die -q "Wasn't able to set a new provider."
135
	fi
160
	fi
136
}
161
}
137
162
Lines 156-162 Link Here
156
181
157
	# For pkg_postrm
182
	# For pkg_postrm
158
	if [[ ! $(find_targets) ]]; then
183
	if [[ ! $(find_targets) ]]; then
159
		remove_symlink
184
		remove_symlinks
160
		return
185
		return
161
	fi
186
	fi
162
187

Return to bug 450410