Gentoo Archives: gentoo-commits

From: Virgil Dupras <vdupras@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: app-eselect/eselect-unison/files/, app-eselect/eselect-unison/
Date: Mon, 27 Aug 2018 18:48:08
Message-Id: 1535395549.0c0c9072bebf9ecd237ccccba1cfd7999f1c9c59.vdupras@gentoo
1 commit: 0c0c9072bebf9ecd237ccccba1cfd7999f1c9c59
2 Author: Virgil Dupras <vdupras <AT> gentoo <DOT> org>
3 AuthorDate: Mon Aug 27 18:37:26 2018 +0000
4 Commit: Virgil Dupras <vdupras <AT> gentoo <DOT> org>
5 CommitDate: Mon Aug 27 18:45:49 2018 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=0c0c9072
7
8 app-eselect/eselect-unison: bump to 0.4
9
10 This adds support for slotted fsmonitor which will be added in upcoming
11 net-misc/unison ebuilds
12
13 Package-Manager: Portage-2.3.48, Repoman-2.3.10
14
15 .../eselect-unison/eselect-unison-0.4.ebuild | 25 ++++
16 .../eselect-unison/files/unison.eselect-0.4 | 156 +++++++++++++++++++++
17 2 files changed, 181 insertions(+)
18
19 diff --git a/app-eselect/eselect-unison/eselect-unison-0.4.ebuild b/app-eselect/eselect-unison/eselect-unison-0.4.ebuild
20 new file mode 100644
21 index 00000000000..d8f2e3d228f
22 --- /dev/null
23 +++ b/app-eselect/eselect-unison/eselect-unison-0.4.ebuild
24 @@ -0,0 +1,25 @@
25 +# Copyright 1999-2018 Gentoo Foundation
26 +# Distributed under the terms of the GNU General Public License v2
27 +
28 +EAPI=7
29 +
30 +DESCRIPTION="unison module for eselect"
31 +HOMEPAGE="https://www.gentoo.org/proj/en/eselect/"
32 +SRC_URI=""
33 +S="${WORKDIR}"
34 +
35 +LICENSE="GPL-2"
36 +SLOT="0"
37 +KEYWORDS="~amd64 ~arm ~ppc ~x86 ~amd64-linux ~x86-linux"
38 +IUSE=""
39 +
40 +DEPEND=""
41 +RDEPEND=">=app-admin/eselect-1.2.3"
42 +
43 +src_install() {
44 + local MODULEDIR="/usr/share/eselect/modules"
45 + local MODULE="unison"
46 + dodir ${MODULEDIR}
47 + insinto ${MODULEDIR}
48 + newins "${FILESDIR}/${MODULE}.eselect-${PVR}" ${MODULE}.eselect
49 +}
50
51 diff --git a/app-eselect/eselect-unison/files/unison.eselect-0.4 b/app-eselect/eselect-unison/files/unison.eselect-0.4
52 new file mode 100644
53 index 00000000000..b65381985bc
54 --- /dev/null
55 +++ b/app-eselect/eselect-unison/files/unison.eselect-0.4
56 @@ -0,0 +1,156 @@
57 +# -*-eselect-*- vim: ft=eselect
58 +# Copyright 1999-2018 Gentoo Foundation
59 +# Distributed under the terms of the GNU General Public License v2
60 +
61 +DESCRIPTION="Manage /usr/bin/unison versions"
62 +MAINTAINER="ml@g.o"
63 +VERSION="0.4"
64 +
65 +# find a list of unison symlink targets, best first
66 +find_targets() {
67 + local f
68 + for f in "${EROOT}"/usr/bin/unison-[0-9]*; do
69 + if [[ -f ${f} ]] ; then
70 + echo "${f##*/unison-}"
71 + fi
72 + done | tac
73 +}
74 +
75 +# find version number of currently symlinked version
76 +identify_target() {
77 + local f
78 + f="$(canonicalise "${EROOT}"/usr/bin/unison)"
79 + echo "${f##*/unison-}"
80 +}
81 +
82 +function is_link_or_empty() {
83 + if [[ ! -e "$1" ]] || [[ -L "$1" ]]; then
84 + return 0
85 + else
86 + return 1
87 + fi
88 +}
89 +
90 +# set the unison symlink
91 +set_symlinks() {
92 + local target="${1}" targets
93 + if is_number "${target}" && [[ ${target} -ge 1 ]] ; then
94 + targets=( $(find_targets) )
95 + target=${targets[target - 1]}
96 + fi
97 + if [[ -f "${EROOT}/usr/bin/unison-${target}" ]] ; then
98 + ln -sf "unison-${target}" "${EROOT}/usr/bin/unison" || \
99 + die "Could not set ${target} /usr/bin/unison symlink"
100 + else
101 + die -q "Target \"${target}\" doesn't appear to be valid!"
102 + fi
103 + # If unison-fsmonitor isn't a symlink, it means that we still have a
104 + # unison version (<2.48-r1) that doesn't properly slot that binary.
105 + # Don't mess with it if that's the case.
106 + if is_link_or_empty "${EROOT}/usr/bin/unison-fsmonitor" ; then
107 + # not a regular file. safe to symlink.
108 + ln -sf "unison-fsmonitor-${target}" \
109 + "${EROOT}/usr/bin/unison-fsmonitor" \
110 + || die "Could not set ${target} /usr/bin/unison-fsmonitor symlink"
111 + fi
112 +}
113 +
114 +### show action ###
115 +
116 +describe_show() {
117 + echo "Show the current unison version"
118 +}
119 +
120 +do_show() {
121 + [[ -z "${@}" ]] || die -q "Too many parameters"
122 +
123 + write_list_start "Current unison verson:"
124 + if [[ -L "${EROOT}/usr/bin/unison" ]] ; then
125 + write_kv_list_entry "$(identify_target)" ""
126 + elif [[ -e "${EROOT}/usr/bin/unison" ]] ; then
127 + write_kv_list_entry "(not a symlink)" ""
128 + else
129 + write_kv_list_entry "(unset)" ""
130 + fi
131 +}
132 +
133 +### list action ###
134 +
135 +describe_list() {
136 + echo "List available unison versions"
137 +}
138 +
139 +do_list() {
140 + [[ $# -eq 0 ]] || die -q "Too many parameters"
141 +
142 + local i targets current
143 + targets=( $(find_targets ) )
144 + current=$(identify_target)
145 + for (( i = 0; i < ${#targets[@]}; i++ )); do
146 + [[ ${targets[i]} = ${current} ]] \
147 + && targets[i]=$(highlight_marker "${targets[i]}")
148 + done
149 + write_list_start "Available unison versions:"
150 + write_numbered_list -m "(none found)" "${targets[@]}"
151 +}
152 +
153 +### set action ###
154 +
155 +describe_set() {
156 + echo "Set a new unison version"
157 +}
158 +
159 +describe_set_options() {
160 + echo "target : Target version number or index from 'list' action"
161 +}
162 +
163 +describe_set_parameters() {
164 + echo "<target>"
165 +}
166 +
167 +do_set() {
168 + if [[ -z "${1}" ]] ; then
169 + die -q "You didn't give me a version number"
170 +
171 + elif [[ -n "${2}" ]] ; then
172 + die -q "Too many parameters"
173 +
174 + elif [[ -L "${EROOT}/usr/bin/unison" ]] ; then
175 + if ! set_symlinks "${1}" ; then
176 + die -q "Can't set new version"
177 + fi
178 +
179 + elif [[ -e "${EROOT}/usr/bin/unison" ]] ; then
180 + die -q "${EROOT}/usr/bin/unison seems to be from an old ebuild, please remove manually"
181 +
182 + else
183 + set_symlinks "${1}" || die -q "Can't set new version"
184 + fi
185 +}
186 +
187 +### update action ###
188 +
189 +describe_update() {
190 + echo "Automatically update the unison version number"
191 +}
192 +
193 +describe_update_options() {
194 + echo "--if-unset : Do not override currently selected version"
195 +}
196 +
197 +do_update() {
198 + [[ -z "${1}" ]] || ( [[ -z "${2}" ]] && [[ "${1}" == "--if-unset" ]] ) || \
199 + die -q "Usage error"
200 +
201 + if [[ -L "${EROOT}/usr/bin/unison" ]] && [[ ${1} == "--if-unset" ]]; then
202 + return
203 + fi
204 + if ! is_link_or_empty "${EROOT}/usr/bin/unison" ; then
205 + die -q "${EROOT}/usr/bin/unison seems to be from an old ebuild, please remove manually"
206 + elif [[ -z $(find_targets ) ]] ; then
207 + rm -f "${EROOT}/usr/bin/unison"
208 + rm -f "${EROOT}/usr/bin/unison-fsmonitor"
209 + else
210 + set_symlinks 1 || die -q "Can't set a new version"
211 + fi
212 +}