Gentoo Archives: gentoo-commits

From: Aaron Swenson <titanofold@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/pgsql-patches:eselect commit in: /
Date: Fri, 01 Apr 2011 11:14:53
Message-Id: 3649a7c33c1da8e0d70a4ad436472ad502e6be5f.titanofold@gentoo
1 commit: 3649a7c33c1da8e0d70a4ad436472ad502e6be5f
2 Author: Aaron W. Swenson <titanofold <AT> gentoo <DOT> org>
3 AuthorDate: Thu Mar 31 21:42:05 2011 +0000
4 Commit: Aaron Swenson <titanofold <AT> gentoo <DOT> org>
5 CommitDate: Thu Mar 31 21:42:05 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/pgsql-patches.git;a=commit;h=3649a7c3
7
8 Variable quoting for paths.
9
10 ---
11 postgresql.eselect | 102 ++++++++++++++++++++++++++--------------------------
12 1 files changed, 51 insertions(+), 51 deletions(-)
13
14 diff --git a/postgresql.eselect b/postgresql.eselect
15 index 7b7501b..36fedb8 100644
16 --- a/postgresql.eselect
17 +++ b/postgresql.eselect
18 @@ -15,8 +15,8 @@ E_PATH="${EROOT%/}/etc/eselect/postgresql"
19 ENV_FILE="${EROOT%/}/etc/env.d/50postgresql"
20
21 active_slot() {
22 - if [[ -r ${E_PATH}/active && -n ${E_PATH}/active ]] ; then
23 - echo $( <${E_PATH}/active )
24 + if [[ -r "${E_PATH}"/active && -n "${E_PATH}"/active ]] ; then
25 + echo $( <"${E_PATH}"/active )
26 else
27 echo "(none)"
28 fi
29 @@ -48,16 +48,16 @@ linker() {
30 local suffix=$4
31 local link_source
32
33 - for link_source in $(find ${source_dir} -maxdepth 1 ${pattern}) ; do
34 + for link_source in $(find "${source_dir}" -maxdepth 1 ${pattern}) ; do
35 local link_target="${target_dir%/}/$(basename ${link_source})${suffix}"
36
37 # For good measure, remove target before creating the symlink
38 - [[ -h ${link_target} ]] && rm -f ${link_target}
39 - [[ -e ${link_target} ]] && \
40 + [[ -h "${link_target}" ]] && rm -f "${link_target}"
41 + [[ -e "${link_target}" ]] && \
42 die -q "The target '${link_target}' still exists and could not be removed!"
43
44 - ln -s ${link_source} ${link_target} || die -q "Unable to create link!"
45 - echo ${link_target} >> ${E_PATH}/active.links${suffix}
46 + ln -s "${link_source}" "${link_target}" || die -q "Unable to create link!"
47 + echo "${link_target}" >> "${E_PATH}"/active.links${suffix}
48 done
49 }
50
51 @@ -66,15 +66,15 @@ linker() {
52 # - Full path to active links file (e.g. /etc/eselect/postgresql/active.links)
53 unlinker() {
54 local active_link_file=$1
55 - if [ -r ${active_link_file} ] ; then
56 - local active_links=($(<${active_link_file}))
57 + if [ -r "${active_link_file}" ] ; then
58 + local active_links=($(<"${active_link_file}"))
59 for (( i=0; $i < ${#active_links[@]}; i++ )) ; do
60 - [ -h ${active_links[$i]} ] && rm -f ${active_links[$i]}
61 - [ -e ${active_links[$i]} ] && \
62 + [ -h "${active_links[$i]}" ] && rm -f "${active_links[$i]}"
63 + [ -e "${active_links[$i]}" ] && \
64 die -q "The target '${active_links[$i]}' still exists and could not be removed!"
65 done
66
67 - rm -f ${active_link_file}
68 + rm -f "${active_link_file}"
69 fi
70 }
71
72 @@ -101,8 +101,8 @@ do_list() {
73 for slot in $(get_slots) ; do
74 local postgres_ebuilds=""
75 local src
76 - for src in ${E_PATH}/slots/${slot}/{server,service,base,docs} ; do
77 - [ -r ${src} ] && source ${src}
78 + for src in "${E_PATH}"/slots/${slot}/{server,service,base,docs} ; do
79 + [ -r "${src}" ] && source "${src}"
80 done
81
82 case "${slot}" in
83 @@ -143,7 +143,7 @@ describe_set() {
84
85 do_set() {
86 local SLOT=$1
87 - if [ ! -d ${B_PATH}/$(lib_dir)/postgresql-${SLOT} ] ; then
88 + if [ ! -d "${B_PATH}"/$(lib_dir)/postgresql-${SLOT} ] ; then
89 die -q "Not a valid slot."
90 fi
91
92 @@ -157,41 +157,41 @@ do_set() {
93 echo -ne "\tGenerating new links..."
94 # Sources and targets for header files
95 local sources=(
96 - ${B_PATH}/include/postgresql-${SLOT}
97 - ${B_PATH}/include/postgresql-${SLOT}/libpq-fe.h
98 - ${B_PATH}/include/postgresql-${SLOT}/pg_config_manual.h
99 - ${B_PATH}/include/postgresql-${SLOT}/libpq
100 - ${B_PATH}/include/postgresql-${SLOT}/postgres_ext.h
101 + "${B_PATH}"/include/postgresql-${SLOT}
102 + "${B_PATH}"/include/postgresql-${SLOT}/libpq-fe.h
103 + "${B_PATH}"/include/postgresql-${SLOT}/pg_config_manual.h
104 + "${B_PATH}"/include/postgresql-${SLOT}/libpq
105 + "${B_PATH}"/include/postgresql-${SLOT}/postgres_ext.h
106 )
107 local targets=(
108 - ${B_PATH}/include/postgresql
109 - ${B_PATH}/include/libpq-fe.h
110 - ${B_PATH}/include/pg_config_manual.h
111 - ${B_PATH}/include/libpq
112 - ${B_PATH}/include/postgres_ext.h
113 + "${B_PATH}"/include/postgresql
114 + "${B_PATH}"/include/libpq-fe.h
115 + "${B_PATH}"/include/pg_config_manual.h
116 + "${B_PATH}"/include/libpq
117 + "${B_PATH}"/include/postgres_ext.h
118 )
119 # The linker function cannot accomadate this special purpose.
120 local i
121 for (( i=0; $i < ${#sources[@]}; i++ )) ; do
122 # Remove target before creating the symlink
123 - rm -f ${targets[$i]}
124 + [[ -h "${targets[$i]}" ]] && rm -f "${targets[$i]}"
125
126 # Check if link_target still exists
127 - [[ -e ${targets[$i]} ]] && \
128 + [[ -e "${targets[$i]}" ]] && \
129 die -q "The target '${targets[$i]}' exists and could not be removed!"
130
131 - ln -s ${sources[$i]} ${targets[$i]} || die -q "Unable to create link!"
132 - echo ${targets[$i]} >> ${E_PATH}/active.links
133 + ln -s "${sources[$i]}" "${targets[$i]}" || die -q "Unable to create link!"
134 + echo "${targets[$i]}" >> "${E_PATH}"/active.links
135 done
136
137 # Link modules to /usr/lib{,lib32,lib64}/
138 local x
139 for x in $(list_libdirs) ; do
140 - if [[ -d ${B_PATH}/${x}/postgresql-${SLOT}/${x} ]] ; then
141 + if [[ -d "${B_PATH}/${x}/postgresql-${SLOT}/${x}" ]] ; then
142 # 'linker' function doesn't work for linking directories.
143 # Default lib path
144 - ln -s ${B_PATH}/${x}/postgresql-${SLOT}/${x} ${B_PATH}/${x}/postgresql
145 - echo ${B_PATH}/${x}/postgresql >> ${E_PATH}/active.links
146 + ln -s "${B_PATH}/${x}/postgresql-${SLOT}/${x}" "${B_PATH}/${x}/postgresql"
147 + echo "${B_PATH}/${x}/postgresql" >> "${E_PATH}"/active.links
148 # Linker works for files
149 linker "${B_PATH}/${x}/postgresql-${SLOT}/${x}" \
150 "-name lib*[a|dylib|so]" "${B_PATH}/${x}"
151 @@ -203,10 +203,10 @@ do_set() {
152 "-xtype f" "${B_PATH}/bin"
153
154 # Default share path
155 - ln -s ${B_PATH}/share/postgresql-${SLOT} ${B_PATH}/share/postgresql
156 - echo ${B_PATH}/share/postgresql >> ${E_PATH}/active.links
157 + ln -s "${B_PATH}/share/postgresql-${SLOT}" "${B_PATH}/share/postgresql"
158 + echo "${B_PATH}/share/postgresql" >> "${E_PATH}/active.links"
159
160 - echo ${SLOT} > ${E_PATH}/active
161 + echo ${SLOT} > "${E_PATH}/active"
162 echo "done."
163 echo "Setting ${SLOT} as default was successful!"
164 }
165 @@ -220,8 +220,8 @@ do_unset() {
166 local SLOT=$1
167 if [[ "${SLOT}" = "$(active_slot)" ]] ; then
168 echo -n "Unsetting ${SLOT} as the default installation..."
169 - unlinker ${E_PATH}/active.links
170 - rm -f ${E_PATH}/active
171 + unlinker "${E_PATH}/active.links"
172 + rm -f "${E_PATH}/active"
173 echo "done."
174 else
175 echo "Inactive slot selected. No work to do."
176 @@ -248,11 +248,10 @@ describe_update() {
177 do_update() {
178 local slot=$(active_slot)
179 # Check for files managed by postgresql.eselect before 1.0
180 - [[ -h /etc/eselect/postgresql/active ]] && \
181 - slot="$(basename $(canonicalise /etc/eselect/postgesql/active))"
182 + [[ -h "${E_PATH}active" ]] && \
183 + slot="$(basename $(canonicalise ${E_PATH/active))"
184 # Remove service file outright.
185 - [[ -h /etc/eselect/postgresql/service ]] && \
186 - rm -f /etc/eselect/postgresql/service
187 + [[ -h "${E_PATH}/service" ]] && rm -f "${E_PATH}/service"
188
189 local slots=($(get_slots))
190 local index=${#slots[@]}
191 @@ -266,11 +265,12 @@ do_update() {
192 echo -n " $i"
193 sleep 1
194 done
195 - for sym_links in ${E_PATH}/active.links* ; do
196 - unlinker ${sym_links}
197 + local sym_links
198 + for sym_links in "${E_PATH}"/active.links* ; do
199 + unlinker "${sym_links}"
200 done
201 - rm -f ${E_PATH}/active
202 - rm -f ${ENV_FILE}
203 + rm -f "${E_PATH}/active"
204 + rm -f "${ENV_FILE}"
205 do_action env update &> /dev/null
206 echo "Done!"
207 return 0
208 @@ -287,8 +287,8 @@ do_update() {
209
210 echo -en "\nCleaning out old links before refreshing..."
211 local sym_links
212 - for sym_links in ${E_PATH}/active.links?* ; do
213 - unlinker ${sym_links}
214 + for sym_links in "${E_PATH}"/active.links?* ; do
215 + unlinker "${sym_links}"
216 done
217 echo "done."
218
219 @@ -296,7 +296,7 @@ do_update() {
220 local ldpath
221 local x
222 for x in $(list_libdirs) ; do
223 - [[ -h ${B_PATH}/${x}/postgresql ]] && \
224 + [[ -h "${B_PATH}"/${x}/postgresql ]] && \
225 ldpath+="${B_PATH}/${x}/postgresql:"
226 done
227 ldpath="${ldpath%:}"
228 @@ -317,9 +317,9 @@ do_update() {
229 done
230
231 # Remove environment files that have been generated by the ebuilds
232 - rm -f ${ENV_FILE}-*
233 + rm -f "${ENV_FILE}"-*
234
235 - store_config ${ENV_FILE} LDPATH "${ldpath}"
236 - store_config ${ENV_FILE} MANPATH "${manpath}"
237 + store_config "${ENV_FILE}" LDPATH "${ldpath}"
238 + store_config "${ENV_FILE}" MANPATH "${manpath}"
239 do_action env update &> /dev/null
240 }