[DRE-commits] [diaspora] 02/04: add preinst

Praveen Arimbrathodiyil praveen at moszumanska.debian.org
Fri Aug 28 10:42:09 UTC 2015


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

praveen pushed a commit to branch master
in repository diaspora.

commit 467122af259e4197000538da74a74052b5e5ab21
Author: Praveen Arimbrathodiyil <praveen at debian.org>
Date:   Fri Aug 28 15:16:42 2015 +0530

    add preinst
---
 debian/changelog |  3 +++
 debian/preinst   | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index b0c3db6..e1c7e2a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,9 @@
 diaspora (0.5.2.0+debian-7) UNRELEASED; urgency=medium
 
   * Bump minimum version of diaspora-commin to 0.5.2.0+debian4 
+  * Remove bin directory before install (to support switching from
+     diaspora-installer)
+  * Stop diaspora before upgrade
 
  -- Pirate Praveen <praveen at debian.org>  Fri, 28 Aug 2015 14:52:07 +0530
 
diff --git a/debian/preinst b/debian/preinst
new file mode 100755
index 0000000..16454a1
--- /dev/null
+++ b/debian/preinst
@@ -0,0 +1,51 @@
+#! /bin/sh
+set -e
+
+# Read variables
+. /etc/diaspora/diaspora-common.conf
+. ${diaspora_conf}
+
+# Remove bin directory if upgrading from diaspora-installer
+if test -d ${diaspora_home}/bin
+then
+    rm -rf ${diaspora_home}/bin
+fi
+
+# Check if PostgreSQL database diaspora_production exist
+if su diaspora -s /bin/sh -c "psql  diaspora_production -c ''"
+then
+    echo "You already have a PostgreSQL database named 'diaspora_production'..."
+    export dbexist='true'
+fi
+
+case "$1" in
+    upgrade)
+        if ! test -z $dbexist
+        then
+            # Show current version of package
+            installed_diaspora_version=`echo $2|cut -d+ -f1`
+            installed_diaspora_major_version=`echo ${installed_diaspora_version} |cut -d. -f1,2`
+	    installed_diaspora_minor_version=`echo ${installed_diaspora_version} |cut -d. -f3,4`
+	    diaspora_minor_version=`echo ${diaspora_version} |cut -d. -f3,4`
+            if test $(echo "${installed_diaspora_major_version} < 0.5" |bc) -eq 1
+            then
+            	echo "Upgrade not supported"
+            elif test $(echo "${installed_diaspora_minor_version} < ${diaspora_minor_version}" |bc) -eq 1
+	    then
+            	echo "Stopping diaspora..."
+            	invoke-rc.d diaspora stop
+            fi
+            
+        fi
+        ;;
+    abort-upgrade|install)
+        ;;
+    *)
+        echo "preinst called with unknown argument \`$1'" >&2
+        exit 1
+        ;;
+esac
+
+#DEBHELPER#
+
+exit 0

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/diaspora.git



More information about the Pkg-ruby-extras-commits mailing list