Gentoo Archives: gentoo-commits

From: "Ulrich Mueller (ulm)" <ulm@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in app-eselect/eselect-pinentry/files: eselect-pinentry-0.3 pinentry.eselect-0.4
Date: Tue, 31 Mar 2015 16:54:11
Message-Id: 20150331165408.2B58614EE2@oystercatcher.gentoo.org
1 ulm 15/03/31 16:54:08
2
3 Added: eselect-pinentry-0.3 pinentry.eselect-0.4
4 Log:
5 Move package from app-admin to app-eselect category.
6
7 (Portage version: 2.2.18/cvs/Linux x86_64, RepoMan options: --force, signed Manifest commit with key 9433907D693FB5B8!)
8
9 Revision Changes Path
10 1.1 app-eselect/eselect-pinentry/files/eselect-pinentry-0.3
11
12 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-eselect/eselect-pinentry/files/eselect-pinentry-0.3?rev=1.1&view=markup
13 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-eselect/eselect-pinentry/files/eselect-pinentry-0.3?rev=1.1&content-type=text/plain
14
15 Index: eselect-pinentry-0.3
16 ===================================================================
17 # Copyright 1999-2015 Gentoo Foundation
18 # Distributed under the terms of the GNU General Public License v2
19 # $Id: eselect-pinentry-0.3,v 1.1 2015/03/31 16:54:08 ulm Exp $
20
21 # Based on eselect-sh by Michał Górny
22
23 DESCRIPTION="Manage /usr/bin/pinentry symlink"
24 MAINTAINER="ssuominen@g.o"
25 VERSION="0.2"
26
27 ## Functions ##
28
29 # find a list of pinentry symlink targets, best first
30 find_targets() {
31 local t
32 for t in \
33 pinentry-qt \
34 pinentry-gtk-2 \
35 pinentry-qt4 \
36 pinentry-curses \
37 ; do
38 if [[ -x ${EROOT}/usr/bin/${t} ]]; then
39 echo ${t}
40 fi
41 done
42 }
43
44 # set the pinentry symlink
45 set_symlinks() {
46 local target="${1}" targets
47
48 [[ ! -L ${EROOT}/usr/bin/pinentry && -e ${EROOT}/usr/bin/pinentry ]] && \
49 die -q "/usr/bin/pinentry is not a symlink!"
50
51 if is_number "${target}" && [[ ${target} -ge 1 ]]; then
52 targets=( $(find_targets) )
53
54 # If no targets are found, remove the symlink and exit
55 if [[ -L ${EROOT}/usr/bin/pinentry && -z ${targets} ]]; then
56 rm -f "${EROOT}"/usr/bin/pinentry
57 return
58 fi
59
60 target=${targets[target-1]}
61 fi
62
63 if [[ -x ${EROOT}/usr/bin/${target} ]]; then
64 local tmpf="${EROOT}"/usr/bin/pinentry.new
65 # we could use 'ln -f' to directly replace the symlink
66 # but 'mv' is an atomic operation so it should be more fault-proof
67
68 ln -s "${target}" "${tmpf}" || \
69 die -q "Unable to create temporary symlink"
70 if ! mv "${tmpf}" "${EROOT}"/usr/bin/pinentry; then
71 rm -f "${tmpf}" # cleanup
72 die -q "Unable to replace /usr/bin/pinentry symlink with ${target}"
73 fi
74 else
75 die -q "Target '${target}' doesn't appear to be valid!"
76 fi
77 }
78
79 ### show action ###
80
81 describe_show() {
82 echo "Show the current pinentry implementation"
83 }
84
85 do_show() {
86 [[ -z ${@} ]] || die -q "Too many parameters"
87
88 write_list_start "Current pinentry implementation:"
89 if [[ -L ${EROOT}/usr/bin/pinentry ]]; then
90 write_kv_list_entry "$(basename $(readlink ${EROOT}/usr/bin/pinentry))" ""
91 elif [[ -e ${EROOT}/usr/bin/pinentry ]]; then
92 write_kv_list_entry "(not a symlink)" ""
93 else
94 write_kv_list_entry "(unset)" ""
95 fi
96 }
97
98 ### list action ###
99
100 describe_list() {
101 echo "List available pinentry implementations"
102 }
103
104 do_list() {
105 [[ -z ${@} ]] || die -q "Too many parameters"
106
107 local i targets
108 targets=( $(find_targets) )
109 if [[ -n ${targets[@]} ]]; then
110 for (( i = 0; i < ${#targets[@]}; i++ )) ; do
111 [[ ${targets[${i}]} == $(basename $(readlink ${EROOT}/usr/bin/pinentry)) ]] && \
112 targets[${i}]="${targets[${i}]} $(highlight '*')"
113 done
114 write_list_start "Available pinentry implementations:"
115 write_numbered_list "${targets[@]}"
116 else
117 write_kv_list_entry "(none found)" ""
118 fi
119 }
120
121 ### set action ###
122
123 describe_set() {
124 echo "Set a new pinentry implementation"
125 }
126
127 describe_set_options() {
128 echo "target : Target name or number (from 'list' action)"
129 }
130
131 describe_set_parameters() {
132 echo "<target>"
133 }
134
135 do_set() {
136 if [[ -z ${1} ]]; then
137 die -q "Not enough parameters"
138 elif [[ -n ${2} ]]; then
139 die -q "Too many parameters"
140 else
141 set_symlinks "${1}"
142 fi
143 }
144
145 ### update action ###
146
147 describe_update() {
148 echo "Automatically update the pinentry implementation"
149 }
150
151 describe_update_options() {
152 echo "ifunset : Do not override existing implementation"
153 }
154
155 do_update() {
156 [[ -z ${1} || ( -z ${2} && ( ${1} == ifunset || ${1} == '--if-unset' ) ) ]] || \
157 die -q "Usage error"
158
159 [[ ( ${1} == ifunset || ${1} == '--if-unset' ) && -L ${EROOT}/usr/bin/pinentry && -x ${EROOT}/usr/bin/pinentry ]] && \
160 return
161
162 set_symlinks 1
163 }
164
165
166
167 1.1 app-eselect/eselect-pinentry/files/pinentry.eselect-0.4
168
169 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-eselect/eselect-pinentry/files/pinentry.eselect-0.4?rev=1.1&view=markup
170 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-eselect/eselect-pinentry/files/pinentry.eselect-0.4?rev=1.1&content-type=text/plain
171
172 Index: pinentry.eselect-0.4
173 ===================================================================
174 # Copyright 1999-2015 Gentoo Foundation
175 # Distributed under the terms of the GNU General Public License v2
176 # $Id: pinentry.eselect-0.4,v 1.1 2015/03/31 16:54:08 ulm Exp $
177
178 DESCRIPTION="Manage /usr/bin/pinentry implementation"
179 MAINTAINER="ssuominen@g.o"
180 VERSION="0.4"
181
182 SYMLINK_PATH=/usr/bin/pinentry
183 SYMLINK_TARGETS=( pinentry-qt pinentry-gtk-2 pinentry-qt4 pinentry-curses )
184 SYMLINK_DESCRIPTION='pinentry binary'
185
186 inherit bin-symlink