Przeglądaj źródła

Revamp FFOO_INI_PATH logic

Config files can now be merged from 4 sources:  distribution-provided,
(share folder), local (/etc/saturnin), user-specific (~/.saturnin and
~/saturnin/ini.d/*)
Alois Mahdal 10 lat temu
rodzic
commit
34b105b0bc
3 zmienionych plików z 26 dodań i 11 usunięć
  1. 18
    5
      bin/saturnin.skel
  2. 1
    1
      config.mk
  3. 7
    5
      setup/mk.sh

+ 18
- 5
bin/saturnin.skel Wyświetl plik

@@ -1,9 +1,21 @@
1 1
 #!/bin/bash
2 2
 
3 3
 . <(ffoom init)
4
-export FFOO_INI_PATH="$SATURNIN_INI_PATH:__SATURNIN_INI_PATH__"
5
-export FFOO_PATH="__SATURNIN_FFOO_PATH__"
6
-saturnin_libexec="__SATURNIN_LIBEXEC__"
4
+
5
+mkinipath() {
6
+    local userd="__SATURNIN_INI_USER__/ini.d"
7
+    local user="__SATURNIN_INI_USER__"
8
+    local lcal="__SATURNIN_INI_LOCAL__"
9
+    local distd="__SATURNIN_SHARE__/ini.d"
10
+    test -d "$userd" && find "$userd" -mindepth 1 -maxdepth 1 -type d
11
+    echo "$user"
12
+    echo "$lcal"
13
+    test -d "$distd" && find "$distd" -mindepth 1 -maxdepth 1 -type d
14
+}
15
+
16
+export FFOO_PATH="__SATURNIN_SHARE__/ffoo"
17
+SATURNIN_LIBEXEC="__SATURNIN_LIBEXEC__"
18
+export FFOO_INI_PATH=$(mkinipath | tr '\n' :)
7 19
 
8 20
 ffoo import exit
9 21
 ffoo import core
@@ -16,7 +28,7 @@ usage() {
16 28
 print_help() {
17 29
     echo "valid commands:"
18 30
     echo ""
19
-    ls "$saturnin_libexec" \
31
+    ls "$SATURNIN_LIBEXEC" \
20 32
       | sed -e 's/saturnin-/    /'
21 33
 }
22 34
 
@@ -30,6 +42,7 @@ while true; do case $1 in
30 42
     *)              break;                          ;;
31 43
 esac done
32 44
 
45
+debug -v FFOO_PATH SATURNIN_LIBEXEC FFOO_INI_PATH
33 46
 debug "\$@=$@"
34 47
 
35 48
 scmd=$1
@@ -38,7 +51,7 @@ shift
38 51
 case $scmd in
39 52
     help)  print_help; exit $FFOO_EXIT_OK ;;
40 53
     *)
41
-        lexpath="$saturnin_libexec/saturnin-$scmd"
54
+        lexpath="$SATURNIN_LIBEXEC/saturnin-$scmd"
42 55
         debug -v lexpath
43 56
         debug "\$@='$@'"
44 57
         test -x "$lexpath" && exec "$lexpath" "$@"

+ 1
- 1
config.mk Wyświetl plik

@@ -3,5 +3,5 @@ VERSION = 0.0.0
3 3
 STAGE = devel
4 4
 PREFIX = /usr/local
5 5
 MANPREFIX = ${PREFIX}/share/man
6
-SATURNIN_INI_PATH_GLOBAL = /etc/saturnin
6
+SATURNIN_INI_PATH_LOCAL = /etc/saturnin
7 7
 SATURNIN_INI_PATH_USER = .saturnin

+ 7
- 5
setup/mk.sh Wyświetl plik

@@ -8,7 +8,7 @@ sed -e 's/ = /=/' < config.mk > $tmp
8 8
 rm -f $tmp
9 9
 
10 10
 bindir=${DESTDIR}${PREFIX}/bin
11
-shrdir=${DESTDIR}${PREFIX}/share/saturnin/ffoo
11
+shrdir=${DESTDIR}${PREFIX}/share/saturnin
12 12
 lexdir=${DESTDIR}${PREFIX}/libexec/saturnin
13 13
 
14 14
 list_of_bins() {
@@ -127,18 +127,20 @@ expand_variables() {
127 127
     # Expand variable values
128 128
     #
129 129
     perl -pe "
130
-        s|__SATURNIN_INI_PATH__|$SATURNIN_INI_PATH_GLOBAL:\\\$HOME/$SATURNIN_INI_PATH_USER|;
131
-        s|__SATURNIN_FFOO_PATH__|$shrdir|;
130
+        s|__SATURNIN_INI_LOCAL__|$SATURNIN_INI_PATH_LOCAL|;
131
+        s|__SATURNIN_INI_USER__|\\\$HOME/$SATURNIN_INI_PATH_USER|;
132
+        s|__SATURNIN_SHARE__|$shrdir|;
132 133
         s|__SATURNIN_LIBEXEC__|$lexdir|;
133 134
         s|__VERSION__|$(get_version)|;
134 135
     "
135 136
 }
137
+
136 138
 install() {
137 139
     mkdir -vp $bindir \
138
-              $shrdir \
140
+              $shrdir/ffoo \
139 141
               $lexdir
140 142
     list_of_bins | xargs cp -vrt $bindir
141
-    list_of_shrs | xargs cp -vrt $shrdir
143
+    list_of_shrs | xargs cp -vrt $shrdir/ffoo
142 144
     list_of_lexs | xargs cp -vrt $lexdir
143 145
     list_of_installed_bins | xargs chmod -v 755
144 146
     list_of_installed_lexs | xargs chmod -v 755