Dash:
[t2.git] / misc / jailing / parse-config
blobdb728e2a0c041dd8615cf51c7836dc06dcb2113e
1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
3
4 # T2 SDE: misc/jailing/parse-config
5 # Copyright (C) 2004 - 2005 The T2 SDE Project
6 # Copyright (C) 1998 - 2003 ROCK Linux Project
7
8 # More information can be found in the files COPYING and README.
9
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; version 2 of the License. A copy of the
13 # GNU General Public License can be found in the file COPYING.
14 # --- T2-COPYRIGHT-NOTE-END ---
17 # Revwrite --with-<option>=<pkg_path> in confopt
18 # to correct <path> when <option> is relative to
19 # a jailed package.
21 jail_confopt_paths_rewrite() {
22         # This list will grow
23         for y in mysql postgresql openldap apache; do
24                 if eval "[ \"\${SDECFG_JAILING_$y}\" = 1 ]" ; then
25                         # Correct eventual misconfigured jail
26                         # To be removed!
27                         if eval "[ ! \"\${SDECFG_JAILDIR_$y}\"  ]" ; then
28                                 eval "export \${SDECFG_JAILDIR_$y}=\
29                                         \"${SDECFG_BASEJAIL}/$y\""
30                         fi
32                         eval "y_path=$root/\"\${SDECFG_JAILDIR_$y}/usr\""
34                         var_append LDFLAGS ' ' "-L/${y_path}/lib"
36                         # Set correct optname and y_path
37                         # This will grow too
38                         case "$y" in
39                                 postgresql) optname=pgsql ;;
40                                 openldap) optname=ldap ;;
41                                 apache) optname=apxs2
42                                         y_path=${y_path}/sbin/apxs ;;
43                                 *) optname=$y ;;
44                         esac
46                         # Rewrite
47                         confopt=$(eval "echo $confopt" | xargs -n1 | sed " \
48                                 s|^--with-${optname}=shared.*$|--with-${optname}=shared,${y_path}|g; \
49                                 s|^--with-${optname}=[^,]*$|--with-${optname}=${y_path}|g; \
50                                 " | xargs)
52                         # Sometime pkg has internal support for <optname> so
53                         # if there's no =... or =shared it means internal
54                         # support want to be used.
55                         # Only mysql in php is using this ... for now
56                         if [ ! "`echo ${has_internal} | grep $optname`" ] ; then
57                                 confopt=$(echo $confopt | xargs -n1 | sed " \
58                                         s|^--with-${optname}$|--with-${optname}=${y_path}|g \
59                                         " | xargs)
60                         fi
61                 fi
62         done
63         export LDFLAGS
64         unset y optname y_path
68 jail_samejail() {
69         eval "export SDECFG_JAILING_$1=\"\$SDECFG_JAILING_$2\""
70         eval "export SDECFG_JAILDIR_$1=\"\$SDECFG_JAILDIR_$2\""
74 if [ "${SDECFG_JAILING}" = 1 ] ; then
75         [ "$pkg" = php ] && jail_samejail php apache
76         [ "$pkg" = subversion ] && jail_samejail subversion apache
77         
78         if eval "[ \"\${SDECFG_JAILING_$pkg}\" = 1 ]" ; then
79                 . $base/misc/jailing/jail-functions
80                 . $base/misc/jailing/package-functions
81                 if eval "[ ! \"\${SDECFG_JAILDIR_$pkg}\"  ]" ; then
82                         eval "export \${SDECFG_JAILDIR_$pkg}=\"${SDECFG_BASEJAIL}/$pkg\""
83                 fi
84                 eval "export jail=\"\${SDECFG_JAILDIR_$pkg}\""
86                 case "$pkg" in
87                         # Setting destvar 
88                         postfix) destvar='install_root' ;;
89                         php) destvar='INSTALL_ROOT' ;;
90                         *) destvar='DESTDIR' ;;
91                 esac
93                 [ -e $base/misc/jailing/$pkg.patch ] && var_append patchfiles ' ' $base/misc/jailing/$pkg.patch
94                 for i in `ls $base/misc/jailing/$pkg-*.patch 2>/dev/null` ; do
95                         var_append patchfiles ' ' "$i"
96                 done
98                 case "$pkg" in
99                         # Special package settings
100                         apache) postmake='jail_pkg_apache_postmake' ;;
101                         postfix) postmake='jail_pkg_postfix_postmake' ;;
102                         openldap) postmake='jail_ensure_users ldap' ;;
103                         mysql) var_append extraconfopt " " "--with-mysql-user=$pkg"
104                                 inmake='jail_ensure_users mysql'
105                                 postmake='jail_pkg_mysql_postmake' ;;
106                         php) has_internal='mysql' ;;
107                 esac
109                 createprefix='0'
110                 createdocs='0'
111                 hook_add prepare 7 jail_set_confopt
112                 hook_add preconf 1 jail_create
113                 hook_add inmake 9 '[ "$destvar" ] && var_append makeinstopt " " "$destvar=$root/$jail"'
114                 hook_add postmake 9 jail_copy_needed_libs
115                 var_append flistroot " " "$jail"
117                 echo_status "Jailing support activated to directory "'$root/'"$jail"
118         fi
119         hook_add preconf 6 'jail_confopt_paths_rewrite'