1. Samuel Thomas
  2. iredmail

Commits

Zhang Huangbin  committed b122cc7

Code cleanup.

  • Participants
  • Parent commits 836601a
  • Branches default

Comments (0)

Files changed (4)

File iRedMail/conf/core

View file
     cmd="$1"
     pkg="$2"
 
-    ECHO_INFO "Checking necessary command/package: ${cmd}/${pkg} ..."
+    ECHO_INFO "Checking required command/package: ${cmd}/${pkg} ..."
     for i in $(echo $PATH|sed 's/:/ /g'); do
         [ -x $i/${cmd} ] && export HAS_CMD='YES' && break
     done
     # Check config tool: dialog.
     check_pkg ${BIN_DIALOG} ${PKG_DIALOG}
 
-    ECHO_INFO -n "Check configuration file: ${CONFIG_FILE} ..."
+    ECHO_INFO -n "Checking configuration file: ${CONFIG_FILE} ..."
     if [ -f ${CONFIG_FILE} ]; then
         grep '^#EOF$' ${CONFIG_FILE} >/dev/null
 
             . ${CONFIG_VIA_DIALOG}
         fi
     else
-        echo -e "\tNone."
+        echo -e "\t[UNCOMPLETED]"
         . ${CONFIG_VIA_DIALOG}
     fi
 }
 # Install/Remove binary packages on Gentoo
 install_pkg_gentoo()
 {
-    ECHO_INFO "Installing package(s): $@"
-    for i in $@; do
-        if [ X"${i}" != X'' ]; then
-            portname="$( echo ${i} | tr -d '-' | tr -d '/' | tr -d '\.' )"
+    ECHO_INFO "Installing package(s) with option(s) '${GENTOO_EMERGE_INSTALL_OPTIONS}': $@"
+    for pkg in $@; do
+        if [ X"${pkg}" != X'' ]; then
+            portname="$( echo ${pkg} | tr -d '-' | tr -d '/' | tr -d '\.' )"
             status="\$status_install_port_$portname"
             if [ X"$(eval echo ${status})" != X"DONE" ]; then
-                emerge ${GENTOO_EMERGE_INSTALL_OPTIONS} ${i}
+                ECHO_INFO "Installing package: ${pkg}"
+                emerge ${GENTOO_EMERGE_INSTALL_OPTIONS} ${pkg}
 
                 if [ X"$?" == X"0" ]; then
                     echo "export status_install_port_${portname}='DONE'" >> ${STATUS_FILE}
                     exit 255
                 fi
             else
-                ECHO_INFO "Skip package: ${i}."
+                ECHO_INFO "Skip package: ${pkg}."
             fi
         fi
     done
 
 gentoo_mask_package()
 {
-    [ -f /etc/portage/package.mask ] || touch /etc/portage/package.mask
-    ECHO_DEBUG "Mask packages in /etc/portage/package.mask: $@"
+    [ -f ${GENTOO_CONF_PACKAGE_MASK} ] || touch ${GENTOO_CONF_PACKAGE_MASK}
     for pkg in $@; do
-        if ! grep "^${pkg}$" /etc/portage/package.mask; then
-            echo ${pkg} >> /etc/portage/package.mask
+        comment_mark="# ${PROG_NAME}-${pkg}"
+        if ! grep "^${comment_mark}$" ${GENTOO_CONF_PACKAGE_MASK} &>/dev/null; then
+            ECHO_DEBUG "Mask packages in ${GENTOO_CONF_PACKAGE_MASK}: $@"
+            echo "${comment_mark}" >> ${GENTOO_CONF_PACKAGE_MASK}
+            echo "${pkg}" >> ${GENTOO_CONF_PACKAGE_MASK}
+        else
+            ECHO_DEBUG "Skip masking packages in ${GENTOO_CONF_PACKAGE_MASK}: $@"
         fi
     done
 }
 
 gentoo_unmask_package()
 {
-    [ -f /etc/portage/package.unmask ] || touch /etc/portage/package.unmask
+    [ -f ${GENTOO_CONF_PACKAGE_UNMASK} ] || touch ${GENTOO_CONF_PACKAGE_UNMASK}
     for pkg in $@; do
-        if ! grep "^${pkg}$" /etc/portage/package.unmask &>/dev/null; then
-            ECHO_DEBUG "Unmask packages in /etc/portage/package.unmask: $@"
-            echo ${pkg} >> /etc/portage/package.unmask
+        comment_mark="# ${PROG_NAME}-${pkg}"
+        if ! grep "^${comment_mark}$" ${GENTOO_CONF_PACKAGE_UNMASK} &>/dev/null; then
+            ECHO_DEBUG "Unmask packages in ${GENTOO_CONF_PACKAGE_UNMASK}: $@"
+            echo "${comment_mark}" >> ${GENTOO_CONF_PACKAGE_UNMASK}
+            echo "${pkg}" >> ${GENTOO_CONF_PACKAGE_UNMASK}
+        else
+            ECHO_DEBUG "Skip unmasking packages in ${GENTOO_CONF_PACKAGE_UNMASK}: $@"
         fi
     done
 }
 
 gentoo_add_use_flags()
 {
-    [ -f /etc/portage/package.use ] || touch /etc/portage/package.use
     # USAGE: gentoo_add_use_flags pkg_name USE_flags
+    [ -f ${GENTOO_CONF_PACKAGE_USE} ] || touch ${GENTOO_CONF_PACKAGE_USE}
     if [ X"$#" == X'2' ]; then
-        echo "${1} ${2}" >> /etc/portage/package.use
+        #echo "${1} ${2}" >> /etc/portage/package.use
+        pkg="${1}"
+        use_flags="${2}"
+        comment_mark="# ${PROG_NAME}-${pkg}"
+        if ! grep "^${comment_mark}$" ${GENTOO_CONF_PACKAGE_USE} &>/dev/null; then
+            ECHO_DEBUG "Add USE flags for package ${pkg} in ${GENTOO_CONF_PACKAGE_USE}."
+            echo "${comment_mark}" >> ${GENTOO_CONF_PACKAGE_USE}
+            echo "${pkg} ${use_flags}" >> ${GENTOO_CONF_PACKAGE_USE}
+        else
+            ECHO_DEBUG "Skip adding USE flags for package ${pkg} in ${GENTOO_CONF_PACKAGE_USE}."
+        fi
     fi
 }
 

File iRedMail/conf/global

View file
 
     # Options used for install package
     export GENTOO_EMERGE_INSTALL_OPTIONS='--buildpkg --quiet-build'
+    export GENTOO_CONF_PACKAGE_USE='/etc/portage/package.use'
+    export GENTOO_CONF_PACKAGE_MASK='/etc/portage/package.mask'
+    export GENTOO_CONF_PACKAGE_UNMASK='/etc/portage/package.unmask'
 
 elif [ X"${DISTRO}" == X"FREEBSD" ]; then
     # System user: root.

File iRedMail/dialog/config_via_dialog.sh

View file
 # --------------------- Backend --------------------
 # --------------------------------------------------
 # PGSQL is available on Ubuntu 11.04, 11.10.
-if [ X"${DISTRO_CODENAME}" == X"oneiric" -o X"${DISTRO_CODENAME}" == X"natty" ]; then
+if [ X"${DISTRO_CODENAME}" == X"oneiric" \
+    -o X"${DISTRO_CODENAME}" == X"natty" \
+    ]; then
     ${DIALOG} \
     --title "Choose your preferred backend used to store mail accounts" \
     --radiolist "\

File iRedMail/functions/packages.sh

View file
         fi
     elif [ X"${DISTRO}" == X"GENTOO" ]; then
         ENABLED_SERVICES="syslog-ng ${ENABLED_SERVICES}"
+        gentoo_add_use_flags 'net-nds/openldap' 'crypt ipv6 ssl tcpd overlays perl sasl syslog'
+        gentoo_add_use_flags 'dev-db/mysql' 'berkdb community perl ssl big-tables cluster'
+        gentoo_add_use_flags 'dev-db/postgresql-server' 'nls pam doc perl python xml'
     fi
 
     #################################################
         elif [ X"${DISTRO}" == X"GENTOO" ]; then
             ALL_PKGS="${ALL_PKGS} openldap"
             ENABLED_SERVICES="${ENABLED_SERVICES} slapd"
-            gentoo_add_use_flags 'net-nds/openldap' 'crypt ipv6 ssl tcpd overlays perl sasl syslog'
 
             # MySQL server and client.
             ALL_PKGS="${ALL_PKGS} mysql"
             ENABLED_SERVICES="${ENABLED_SERVICES} mysql"
-            gentoo_add_use_flags 'dev-db/mysql' 'berkdb community perl ssl big-tables cluster'
         fi
     elif [ X"${BACKEND}" == X"MYSQL" ]; then
         # MySQL server & client.
         elif [ X"${DISTRO}" == X'GENTOO' ]; then
             ALL_PKGS="${ALL_PKGS} mysql mod_auth_mysql"
             ENABLED_SERVICES="${ENABLED_SERVICES} mysql"
-            gentoo_add_use_flags 'dev-db/mysql' 'berkdb community perl ssl big-tables cluster'
         fi
     elif [ X"${BACKEND}" == X"PGSQL" ]; then
         export USE_IREDAPD='NO'
         elif [ X"${DISTRO}" == X'GENTOO' ]; then
             ALL_PKGS="${ALL_PKGS} postgresql-server mod_auth_pgsql"
             ENABLED_SERVICES="${ENABLED_SERVICES} postgresql-${PGSQL_VERSION}"
-            gentoo_add_use_flags 'dev-db/postgresql-server' 'nls pam doc perl python xml'
-
         fi
     fi