1 |
aballier 08/04/07 21:29:18 |
2 |
|
3 |
Added: unison.eselect-0.1 |
4 |
Log: |
5 |
Initial import. eselect module for SLOTted net-misc/unison by Martin von Gagern <Martin.vGagern@×××.net>, bug #207746 |
6 |
(Portage version: 2.1.5_rc2) |
7 |
|
8 |
Revision Changes Path |
9 |
1.1 app-admin/eselect-unison/files/unison.eselect-0.1 |
10 |
|
11 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/app-admin/eselect-unison/files/unison.eselect-0.1?rev=1.1&view=markup |
12 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/app-admin/eselect-unison/files/unison.eselect-0.1?rev=1.1&content-type=text/plain |
13 |
|
14 |
Index: unison.eselect-0.1 |
15 |
=================================================================== |
16 |
# Copyright 1999-2007 Gentoo Foundation |
17 |
# Distributed under the terms of the GNU General Public License v2 |
18 |
# $Id: unison.eselect-0.1,v 1.1 2008/04/07 21:29:18 aballier Exp $ |
19 |
|
20 |
DESCRIPTION="Manage /usr/bin/unison versions" |
21 |
MAINTAINER="ml@g.o" |
22 |
SVN_DATE='$Date: 2008/04/07 21:29:18 $' |
23 |
VERSION=$(svn_date_to_version "${SVN_DATE}" ) |
24 |
|
25 |
# find a list of unison symlink targets, best first |
26 |
find_targets() { |
27 |
local f |
28 |
for f in "${ROOT}"/usr/bin/unison-[0-9]*; do |
29 |
if [[ -f ${f} ]] ; then |
30 |
echo "${f##*/unison-}" |
31 |
fi |
32 |
done | tac |
33 |
} |
34 |
|
35 |
# find version number of currently symlinked version |
36 |
identify_target() { |
37 |
local f |
38 |
f="$(canonicalise "${ROOT}"/usr/bin/unison)" |
39 |
echo "${f##*/unison-}" |
40 |
} |
41 |
|
42 |
# try to remove the unison symlink |
43 |
remove_symlinks() { |
44 |
rm -f "${ROOT}"/usr/bin/unison &>/dev/null |
45 |
} |
46 |
|
47 |
# set the unison symlink |
48 |
set_symlinks() { |
49 |
local target="${1}" targets |
50 |
if is_number "${target}" && [[ ${target} -ge 1 ]] ; then |
51 |
targets=( $(find_targets ) ) |
52 |
target=${targets[$(( ${target} - 1 ))]} |
53 |
fi |
54 |
if [[ -f "${ROOT}/usr/bin/unison-${target}" ]] ; then |
55 |
remove_symlinks |
56 |
ln -s "unison-${target}" "${ROOT}/usr/bin/unison" || \ |
57 |
die "Could not set ${target} /usr/bin/unison symlink" |
58 |
else |
59 |
die -q "Target \"${target}\" doesn't appear to be valid!" |
60 |
fi |
61 |
} |
62 |
|
63 |
### show action ### |
64 |
|
65 |
describe_show() { |
66 |
echo "Show the current unison version" |
67 |
} |
68 |
|
69 |
do_show() { |
70 |
[[ -z "${@}" ]] || die -q "Too many parameters" |
71 |
|
72 |
write_list_start "Current unison verson:" |
73 |
if [[ -L "${ROOT}/usr/bin/unison" ]] ; then |
74 |
write_kv_list_entry "$(identify_target)" "" |
75 |
elif [[ -e "${ROOT}/usr/bin/unison" ]] ; then |
76 |
write_kv_list_entry "(not a symlink)" "" |
77 |
else |
78 |
write_kv_list_entry "(unset)" "" |
79 |
fi |
80 |
} |
81 |
|
82 |
### list action ### |
83 |
|
84 |
describe_list() { |
85 |
echo "List available unison versions" |
86 |
} |
87 |
|
88 |
do_list() { |
89 |
[[ -z "${@}" ]] || die -q "Too many parameters" |
90 |
|
91 |
local i targets current |
92 |
targets=( $(find_targets ) ) |
93 |
current=$(identify_target) |
94 |
if [[ -n ${targets[@]} ]] ; then |
95 |
for (( i = 0 ; i < ${#targets[@]} ; i = i + 1 )) ; do |
96 |
[[ ${targets[${i}]} == ${current} ]] && \ |
97 |
targets[${i}]="${targets[${i}]} $(highlight '*' )" |
98 |
done |
99 |
write_list_start "Available unison versions:" |
100 |
write_numbered_list "${targets[@]}" |
101 |
else |
102 |
write_kv_list_entry "(none found)" "" |
103 |
fi |
104 |
} |
105 |
|
106 |
### set action ### |
107 |
|
108 |
describe_set() { |
109 |
echo "Set a new unison version" |
110 |
} |
111 |
|
112 |
describe_set_options() { |
113 |
echo "target : Target version number or index from 'list' action" |
114 |
} |
115 |
|
116 |
describe_set_parameters() { |
117 |
echo "<target>" |
118 |
} |
119 |
|
120 |
do_set() { |
121 |
if [[ -z "${1}" ]] ; then |
122 |
die -q "You didn't give me a version number" |
123 |
|
124 |
elif [[ -n "${2}" ]] ; then |
125 |
die -q "Too many parameters" |
126 |
|
127 |
elif [[ -L "${ROOT}/usr/bin/unison" ]] ; then |
128 |
if ! remove_symlinks ; then |
129 |
die -q "Can't remove existing version symlink" |
130 |
elif ! set_symlinks "${1}" ; then |
131 |
die -q "Can't set new version" |
132 |
fi |
133 |
|
134 |
elif [[ -e "${ROOT}/usr/bin/unison" ]] ; then |
135 |
die -q "${ROOT}/usr/bin/unison seems to be from an old ebuild, please remove manually" |
136 |
|
137 |
else |
138 |
set_symlinks "${1}" || die -q "Can't set new version" |
139 |
fi |
140 |
} |
141 |
|
142 |
### update action ### |
143 |
|
144 |
describe_update() { |
145 |
echo "Automatically update the unison version number" |
146 |
} |
147 |
|
148 |
describe_update_options() { |
149 |
echo "--if-unset : Do not override currently selected version" |
150 |
} |
151 |
|
152 |
do_update() { |
153 |
[[ -z "${1}" ]] || ( [[ -z "${2}" ]] && [[ "${1}" == "--if-unset" ]] ) || \ |
154 |
die -q "Usage error" |
155 |
|
156 |
if [[ -L "${ROOT}/usr/bin/unison" ]] ; then |
157 |
[[ ${1} == "--if-unset" ]] && return |
158 |
remove_symlinks || die -q "Can't remove existing symlink" |
159 |
fi |
160 |
if [[ -e "${ROOT}/usr/bin/unison" ]] ; then |
161 |
die -q "${ROOT}/usr/bin/unison seems to be from an old ebuild, please remove manually" |
162 |
elif ! [[ -z $(find_targets ) ]] ; then |
163 |
set_symlinks 1 || die -q "Can't set a new version" |
164 |
fi |
165 |
} |
166 |
|
167 |
# vim: set ft=eselect : |
168 |
|
169 |
|
170 |
|
171 |
-- |
172 |
gentoo-commits@l.g.o mailing list |