Browse Source

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 years ago
parent
commit
34b105b0bc
3 changed files with 26 additions and 11 deletions
  1. 18
    5
      bin/saturnin.skel
  2. 1
    1
      config.mk
  3. 7
    5
      setup/mk.sh

+ 18
- 5
bin/saturnin.skel View File

1
 #!/bin/bash
1
 #!/bin/bash
2
 
2
 
3
 . <(ffoom init)
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
 ffoo import exit
20
 ffoo import exit
9
 ffoo import core
21
 ffoo import core
16
 print_help() {
28
 print_help() {
17
     echo "valid commands:"
29
     echo "valid commands:"
18
     echo ""
30
     echo ""
19
-    ls "$saturnin_libexec" \
31
+    ls "$SATURNIN_LIBEXEC" \
20
       | sed -e 's/saturnin-/    /'
32
       | sed -e 's/saturnin-/    /'
21
 }
33
 }
22
 
34
 
30
     *)              break;                          ;;
42
     *)              break;                          ;;
31
 esac done
43
 esac done
32
 
44
 
45
+debug -v FFOO_PATH SATURNIN_LIBEXEC FFOO_INI_PATH
33
 debug "\$@=$@"
46
 debug "\$@=$@"
34
 
47
 
35
 scmd=$1
48
 scmd=$1
38
 case $scmd in
51
 case $scmd in
39
     help)  print_help; exit $FFOO_EXIT_OK ;;
52
     help)  print_help; exit $FFOO_EXIT_OK ;;
40
     *)
53
     *)
41
-        lexpath="$saturnin_libexec/saturnin-$scmd"
54
+        lexpath="$SATURNIN_LIBEXEC/saturnin-$scmd"
42
         debug -v lexpath
55
         debug -v lexpath
43
         debug "\$@='$@'"
56
         debug "\$@='$@'"
44
         test -x "$lexpath" && exec "$lexpath" "$@"
57
         test -x "$lexpath" && exec "$lexpath" "$@"

+ 1
- 1
config.mk View File

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

+ 7
- 5
setup/mk.sh View File

8
 rm -f $tmp
8
 rm -f $tmp
9
 
9
 
10
 bindir=${DESTDIR}${PREFIX}/bin
10
 bindir=${DESTDIR}${PREFIX}/bin
11
-shrdir=${DESTDIR}${PREFIX}/share/saturnin/ffoo
11
+shrdir=${DESTDIR}${PREFIX}/share/saturnin
12
 lexdir=${DESTDIR}${PREFIX}/libexec/saturnin
12
 lexdir=${DESTDIR}${PREFIX}/libexec/saturnin
13
 
13
 
14
 list_of_bins() {
14
 list_of_bins() {
127
     # Expand variable values
127
     # Expand variable values
128
     #
128
     #
129
     perl -pe "
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
         s|__SATURNIN_LIBEXEC__|$lexdir|;
133
         s|__SATURNIN_LIBEXEC__|$lexdir|;
133
         s|__VERSION__|$(get_version)|;
134
         s|__VERSION__|$(get_version)|;
134
     "
135
     "
135
 }
136
 }
137
+
136
 install() {
138
 install() {
137
     mkdir -vp $bindir \
139
     mkdir -vp $bindir \
138
-              $shrdir \
140
+              $shrdir/ffoo \
139
               $lexdir
141
               $lexdir
140
     list_of_bins | xargs cp -vrt $bindir
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
     list_of_lexs | xargs cp -vrt $lexdir
144
     list_of_lexs | xargs cp -vrt $lexdir
143
     list_of_installed_bins | xargs chmod -v 755
145
     list_of_installed_bins | xargs chmod -v 755
144
     list_of_installed_lexs | xargs chmod -v 755
146
     list_of_installed_lexs | xargs chmod -v 755