[med-svn] [openemr] 01/01: Reworking the pre[inst|rm], post[inst|rm] to move all calls to exit to end so that DEBHELPER would actually work.

Ian Wallace iankarlwallace-guest at moszumanska.debian.org
Thu Aug 14 03:53:39 UTC 2014


This is an automated email from the git hooks/post-receive script.

iankarlwallace-guest pushed a commit to branch master
in repository openemr.

commit 9230a7b2070fe8126239bdd546dcf3017aa6762b
Author: Ian Wallace <iankarlwallace at gmail.com>
Date:   Wed Aug 13 20:53:21 2014 -0700

    Reworking the pre[inst|rm],post[inst|rm] to move all calls to exit to end so that DEBHELPER would actually work.
---
 debian/control  |  9 +++++++--
 debian/postinst | 54 ++++++++++++++++++------------------------------------
 debian/postrm   |  9 ---------
 debian/preinst  | 37 ++++++++++++++++---------------------
 debian/prerm    | 14 ++------------
 5 files changed, 43 insertions(+), 80 deletions(-)

diff --git a/debian/control b/debian/control
index 3b697a7..5639e8c 100644
--- a/debian/control
+++ b/debian/control
@@ -14,8 +14,10 @@ Homepage: http://www.open-emr.org/
 
 Package: openemr
 Architecture: all
-Depends: ${shlibs:Depends},
-         ${misc:Depends},
+Pre-Depends: debconf
+Depends: ${misc:Depends},
+	 dbconfig-common,
+	 mysql-client,
          mysql-server,
          apache2-mpm-prefork,
          makepasswd,
@@ -36,6 +38,9 @@ Depends: ${shlibs:Depends},
          php5-mcrypt,
          php5-json,
          php-soap,
+	 libjs-jquery,
+	 libjs-jquery-cookie,
+	 smarty3,
          imagemagick
 Description: Comprehensive medical practice management
  OpenEMR is a free medical practice management, electronic medical
diff --git a/debian/postinst b/debian/postinst
index 874bc46..825c40b 100644
--- a/debian/postinst
+++ b/debian/postinst
@@ -44,26 +44,6 @@
 # Source debconf library.
 . /usr/share/debconf/confmodule
 
-function unsecure-file {
-		chown www-data:www-data $1
-		if [ -f "$1" ]; then
-			chmod 660 "$1"
-		else
-			chmod 770 "$1"
-		fi
-}
-
-unsecure-file /var/lib/openemr/sites/default/sqlconf.php
-unsecure-file /var/lib/openemr/sites/default/documents
-unsecure-file /var/lib/openemr/sites/default/edi
-unsecure-file /var/lib/openemr/sites/default/era
-unsecure-file /var/lib/openemr/sites/default/letter_templates
-unsecure-file /var/lib/openemr/gacl/admin/templates_c
-unsecure-file /var/lib/openemr/interface/main/calendar/modules/PostCalendar/pntemplates/compiled
-unsecure-file /var/lib/openemr/interface/main/calendar/modules/PostCalendar/pntemplates/cache
-
-exit 0
-
 case "$1" in
    configure)
 
@@ -198,16 +178,17 @@ case "$1" in
 
             #upgrade the sql database
             CONC_VERSION=$(echo $OLD_VERSION | cut -d \- -f 1)
-            echo "<?php \$_GET['site'] = '$SITENAME'; ?>" > $OPENEMR/TEMPsql_upgrade.php
-            cat $OPENEMR/sql_upgrade.php >> $OPENEMR/TEMPsql_upgrade.php
-            sed -i "/input type='submit'/d" $OPENEMR/TEMPsql_upgrade.php
-            sed -i "s/!empty(\$_POST\['form_submit'\])/empty(\$_POST\['form_submit'\])/" $OPENEMR/TEMPsql_upgrade.php
-            sed -i "s/^[   ]*\$form_old_version[   =].*$/\$form_old_version = \"$CONC_VERSION\";/" $OPENEMR/TEMPsql_upgrade.php
-            php -f $OPENEMR/TEMPsql_upgrade.php >> $LOG 2>&1
-            rm -f $OPENEMR/TEMPsql_upgrade.php
-
-
-## WARNING THIS HAS BEEN REMOVED AND WILL NEED TO BE REWORKED FOR DEBIAN.  Unsecure HANDLING OF tmp dirs.
+            echo "<?php \$_GET['site'] = '$SITENAME'; ?>" > $TMPDIR/TEMPsql_upgrade.php
+            cat $OPENEMR/sql_upgrade.php >> $TMPDIR/TEMPsql_upgrade.php
+            sed -i "/input type='submit'/d" $TMPDIR/TEMPsql_upgrade.php
+            sed -i "s/!empty(\$_POST\['form_submit'\])/empty(\$_POST\['form_submit'\])/" $TMPDIR/TEMPsql_upgrade.php
+            sed -i "s/^[   ]*\$form_old_version[   =].*$/\$form_old_version = \"$CONC_VERSION\";/" $TMPDIR/TEMPsql_upgrade.php
+            php -f $TMPDIR/TEMPsql_upgrade.php >> $LOG 2>&1
+            rm -f $TMPDIR/TEMPsql_upgrade.php
+
+#WARNING:: In the original scripts OpenEMR would keep a copy of the config.php
+#The only site that would probably be effected in the current package would be default since that ships with a config.php and a sqlconf.php
+#file.  For the moment multiple site upgrade should be considered broken until this can be reworked.
             #copy the old config file into new with the OLD at end to allow manual configuration of old
             # optional settings.
 #            if [ -d "$TMPDIR/openemr_web_$OLD_VERSION/sites/$SITENAME" ]; then
@@ -218,6 +199,7 @@ case "$1" in
 #            fi
 
             #log
+            log_only "WARNING: PLEASE CHECK YOUR UPGRADED SITES CAREFULLY!  Postinst is still in transition."
             log_only "Upgraded OpenEMR site ($SITENAME) with sql database ($SQLDATABASE) and sql user ($SQLUSER)."
 
          done
@@ -249,7 +231,7 @@ case "$1" in
          fi
 
          #secure openemr
-         chown -Rf root:root $OPENEMR
+         #chown -Rf root:root $OPENEMR <<== Already done by packaging system
          chmod 600 $OPENEMR/acl_setup.php
          chmod 600 $OPENEMR/acl_upgrade.php
          chmod 600 $OPENEMR/sl_convert.php
@@ -302,9 +284,6 @@ case "$1" in
       elif [ "$PLAN" == "install" ] ; then
          #continue with installation
          log_only "Installing OpenEMR"
-      else
-         unable_exit "Error reading plan variable in configuration file."
-      fi      
 
       #collect the mysql root password (if applicable)
       MPASS=""
@@ -612,12 +591,14 @@ case "$1" in
       #stop db
       db_stop
 
-      exit 0
+      # Can't understand what the /etc/openemr/openemr configuration is asking to do.
+      else
+         unable_exit "Error reading plan variable in configuration file."
+      fi      
    ;;
    abort-upgrade|abort-remove|abort-deconfigure)
    
       echo "postinst asked to do $1"
-      exit 0
    ;;
    *)
       echo "postinst called with unknown argument \`$1'" >&2
@@ -630,5 +611,6 @@ esac
 
 #DEBHELPER#
 
+# Sleep statement was in original script but unclear why we need it there other than to allow MySQL or Apache to restart
 sleep 5
 exit 0
diff --git a/debian/postrm b/debian/postrm
index ba4da60..d879084 100644
--- a/debian/postrm
+++ b/debian/postrm
@@ -29,8 +29,6 @@
 # Source debconf library.
 . /usr/share/debconf/confmodule
 
-exit 0
-
 #constants
 
 LOGDIR=/var/log/openemr
@@ -41,38 +39,31 @@ case "$1" in
       rm -rf $LOGDIR
       # Remove db prompt stuff.
       db_purge
-      exit 0
    ;;
 
    purge)
       echo "postrm asked to do purge"
-      exit 0
    ;;
 
    upgrade)
       #echo "No need for upgrade instructions in postrm script to version $2"
-      exit 0
    ;;
 
    failed-upgrade)
       echo "postrm asked to do failed-upgrade from version $2"
-      exit 0
    ;;
 
    abort-install)
       echo "postrm asked to do abort-install"
-      exit 0
    ;;
 
    abort-upgrade)
       echo "postrm asked to do abort-upgrade from version $2"
-      exit 0
    ;;
 
 
    disappear)
       echo "postrm asked to do disappear"
-      exit 0
    ;;
 
    *)
diff --git a/debian/preinst b/debian/preinst
index 6a5812a..9777feb 100644
--- a/debian/preinst
+++ b/debian/preinst
@@ -39,15 +39,13 @@
 # Source debconf library.
 . /usr/share/debconf/confmodule
 
-exit 0
-
 #constants and paths
 LOGDIR=/var/log/openemr
 LOG=$LOGDIR/install
 CONFIGDIR=/etc/openemr
 CONFIG=$CONFIGDIR/openemr.conf
 TMPDIR=`mktemp -d openemr-tmp-XXX`
-WEB=/var/www
+WEB=/usr/share
 OPENEMR=$WEB/openemr
 SITEDIR=$OPENEMR/sites
 #hardcoded mysql user and database for install (not pertinent for upgrading)
@@ -183,7 +181,7 @@ upgrade_prepare_database () {
 # 2nd param is whether raw or package upgrade
 upgrade_function () {
 
-      #Check for /var/www/openemr. If does not exist, then exit.
+      #Check for OpenEMR directory. If does not exist, then exit.
       if ! [ -d "$OPENEMR" ]; then
          prompt_input openemr/upgrade_not_installed critical ret_result
          unable_exit "OpenEMR is not installed ($OPENEMR), so can not upgrade the OpenEMR Package."
@@ -268,12 +266,16 @@ previous_version=$OLD_VERSION\n"
          done
       fi
 
+      # This is an attempt to keep old configuration files that might need to be upgraded and should actually be handled correctly
+      # With out this backup method since they are *not* included in the default package (i.e. the "sites" directory is shipped
+      # empty.  It is nice to create a backup for those who have personally modified the source/contributions locally so we should still
+      # provide that (usually though it was in /var/www/html or /var/www originally)
       #create the tmp web directory
-			WEBTMPDIR=`mktemp --tmpdir $TMPDIR openemr_web_$OLD_VERSION`
-      #mkdir -p $TMPDIR/openemr_web_$OLD_VERSION
+      WEBTMPDIR=`mktemp --tmpdir $TMPDIR openemr_web_$OLD_VERSION`
 
       #backup web directory to tmp
       cp -fr $OPENEMR/* $WEBTMPDIR
+      log_only "Backup copy of your [$OPENEMR] is located in [$WEBTMPDIR]"
 
       #clear the temporary openemr cache directories (no need to keep these during upgrade)
       rm -fr $OPENEMR/interface/main/calendar/modules/PostCalendar/pntemplates/compiled/*
@@ -295,7 +297,7 @@ case "$1" in
       #create the log file directory
       mkdir -p $LOGDIR
 
-      #Check for /var/www/openemr, if exist then see if upgrade is possible
+      #Check for OpenEMR directory, if exist then see if upgrade is possible
       if [ -d "$OPENEMR" ]; then
 
          #collect current version
@@ -323,34 +325,27 @@ case "$1" in
          fi
          upgrade_function $RAWVERSION "raw"
 
-         exit 0
-      fi
-
-      #Create the config file to pass to the postinst script 
-      # to signal that this is a new install
-      SETTING="#Optional settings\n\
+      else 
+         #Create the config file to pass to the postinst script 
+	 # to signal that this is a new install
+         SETTING="#Optional settings\n\
 #(currently empty, plan to use in subsequent versions of OpenEMR)\n\
 \n\
 #Installation settings\n\
 # (DO NOT EDIT below!!!)\n\
 process=pending\n\
 plan=install"
-      mkdir -p $CONFIGDIR
-      echo -e $SETTING > $CONFIG
-
-      exit 0
+         mkdir -p $CONFIGDIR
+         echo -e $SETTING > $CONFIG
+      fi
    ;;
 
    upgrade)
-
       upgrade_function $2 "package"
-
-      exit 0
    ;;
 
    abort-upgrade)
       echo "preinst asked to do abort-upgrade"
-      exit 0
    ;;
 
    *)
diff --git a/debian/prerm b/debian/prerm
index ec67102..50f85bd 100644
--- a/debian/prerm
+++ b/debian/prerm
@@ -34,8 +34,6 @@
 # Source debconf library.
 . /usr/share/debconf/confmodule
 
-exit 0
-
 case "$1" in
    remove)
 
@@ -45,7 +43,7 @@ case "$1" in
       CONFIGDIR=/etc/openemr
       CONFIG=$CONFIGDIR/openemr.conf
       TMPDIR=`mktemp -d`
-      WEB=/var/www
+      WEB=/usr/share
       OPENEMR=$WEB/openemr
       SITEDIR=$OPENEMR/sites
 
@@ -173,7 +171,7 @@ case "$1" in
       log_only "Finished removing OpenEMR web directory"
 
       #remove tmp directory
-      sudo rm -fr $TMPDIR
+      rm -fr $TMPDIR
       log_only "Removed OpenEMR tmp directory"
 
       #removes the configuration section for OpenEMR in Apache config file
@@ -182,26 +180,18 @@ case "$1" in
 
       #stop db
       db_stop
-
-      exit 0
    ;;
 
    upgrade)
-
       #echo "No need for upgrade instructions in prerm script to version $2"
-      exit 0
    ;;
 
    deconfigure)
-
       echo "prerm asked to do deconfigure"
-      exit 0
    ;;
 
    failed-upgrade)
-
       echo "prerm asked to do failed-upgrade from version $2"
-      exit 0
    ;;
 
    *)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/openemr.git



More information about the debian-med-commit mailing list