Gentoo Archives: gentoo-commits

From: Aaron Swenson <titanofold@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/postgresql/eselect:master commit in: /
Date: Tue, 18 Apr 2017 19:43:45
Message-Id: 1463598619.7190ae6e3da59f7390b0e00081594d672bffc0db.titanofold@gentoo
1 commit: 7190ae6e3da59f7390b0e00081594d672bffc0db
2 Author: Aaron W. Swenson <titanofold <AT> gentoo <DOT> org>
3 AuthorDate: Wed May 18 19:10:19 2016 +0000
4 Commit: Aaron Swenson <titanofold <AT> gentoo <DOT> org>
5 CommitDate: Wed May 18 19:10:19 2016 +0000
6 URL: https://gitweb.gentoo.org/proj/postgresql/eselect.git/commit/?id=7190ae6e
7
8 Stateless: No longer rely on an 'active' file
9
10 Working towards a stateless module, no need to keep track of links or
11 active slot in a collection of files.
12
13 /usr/share/postgresql is symbolic link generated by this module. So, we're
14 able to determine which real directory it's pointing to, which will be
15 /usr/share/postgresql-SLOT. A bit of sed magic gets just the slot
16 portion off the end. Et voila! We no longer need to store the active
17 slot in a file.
18
19 If /usr/share/postgresql doesn't exist, then we haven't set a slot.
20
21 postgresql.eselect | 24 ++++++++++++------------
22 1 file changed, 12 insertions(+), 12 deletions(-)
23
24 diff --git a/postgresql.eselect b/postgresql.eselect
25 index 6468ab6..1e9ff3b 100644
26 --- a/postgresql.eselect
27 +++ b/postgresql.eselect
28 @@ -14,8 +14,11 @@ E_PATH="${EROOT%/}/etc/eselect/postgresql"
29 ENV_FILE="${EROOT%/}/etc/env.d/50postgresql"
30
31 active_slot() {
32 - if [[ -r ${E_PATH}/active && -n ${E_PATH}/active ]] ; then
33 - echo $( <"${E_PATH}"/active )
34 + # ${B_PATH}/share/postgresql is a symlink. See if it's there, then
35 + # find out where it links to
36 + if [[ -h "${B_PATH}/share/postgresql" ]] ; then
37 + canonicalise "${B_PATH}/share/postgresql" | \
38 + sed 's|.*postgresql-\([1-9][0-9.]*\)|\1|'
39 else
40 echo "(none)"
41 fi
42 @@ -246,7 +249,6 @@ do_set() {
43 ln -s "postgresql-${SLOT}" "${B_PATH}/share/postgresql"
44 echo "${B_PATH##${ROOT%/}/}/share/postgresql" >> "${E_PATH}/active.links"
45
46 - echo ${SLOT} > "${E_PATH}/active"
47 echo "done."
48 echo "Setting ${SLOT} as default was successful!"
49 }
50 @@ -261,7 +263,6 @@ do_unset() {
51 if [[ ${SLOT} = $(active_slot) ]] ; then
52 echo -n "Unsetting ${SLOT} as the default installation..."
53 unlinker "${E_PATH}/active.links"
54 - rm -f "${E_PATH}/active"
55 echo "done."
56 echo "Setting a new slot as the default."
57 do_update
58 @@ -289,13 +290,13 @@ describe_update() {
59
60 do_update() {
61 local slot=$(active_slot)
62 - # Check for files managed by postgresql.eselect before 1.0
63 - if [[ -h ${E_PATH}/active ]] ; then
64 - slot="$(basename $(canonicalise ${E_PATH}/active)))"
65 - rm -f "${E_PATH}/active"
66 - fi
67 - # Remove service file outright.
68 - [[ -h ${E_PATH}/service ]] && rm -f "${E_PATH}/service"
69 +
70 + # Remove some files outright as they're entirely useless now.
71 + local f
72 + for f in "${E_PATH}/active" "${E_PATH}/service"; do
73 + [[ -e "${f}" ]] && rm -f "${f}"
74 + done
75 +
76
77 local slots=($(get_slots))
78 local index=${#slots[@]}
79 @@ -313,7 +314,6 @@ do_update() {
80 for sym_links in "${E_PATH}"/active.links* ; do
81 unlinker "${sym_links}"
82 done
83 - rm -f "${E_PATH}/active"
84 rm -f "${ENV_FILE}"
85 do_action env update &> /dev/null
86 echo "Done!"