[evolvis-commits] r7535: Continuing the debconfisation of stuff, including on removal. ↵

mirabilos at evolvis.org mirabilos at evolvis.org
Thu Feb 24 15:43:06 CET 2011


Author: mirabilos
Date: 2011-02-24 15:43:06 +0100 (Thu, 24 Feb 2011)
New Revision: 7535

Modified:
   trunk/gforge_base/evolvisforge-5.1/gforge/deb-specific/install-apache.sh
   trunk/gforge_base/evolvisforge-5.1/gforge/deb-specific/install-db.sh
   trunk/gforge_base/evolvisforge-5.1/gforge/deb-specific/install-dns.sh
   trunk/gforge_base/evolvisforge-5.1/gforge/debian/sourceforge.postinst
   trunk/gforge_base/evolvisforge-5.1/gforge/debian/sourceforge.prerm
   trunk/gforge_base/evolvisforge-5.1/gforge/debian/sourceforge.templates
Log:
Continuing the debconfisation of stuff, including on removal.


Modified: trunk/gforge_base/evolvisforge-5.1/gforge/deb-specific/install-apache.sh
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge/deb-specific/install-apache.sh	2011-02-24 14:43:04 UTC (rev 7534)
+++ trunk/gforge_base/evolvisforge-5.1/gforge/deb-specific/install-apache.sh	2011-02-24 14:43:06 UTC (rev 7535)
@@ -6,7 +6,6 @@
 # Christian Bayle, Roland Mas, debian-sf (Sourceforge for Debian)
 
 set -e
-set -x
 
 if [ $(id -u) != 0 ] ; then
     echo "You must be root to run this, please enter passwd"
@@ -57,19 +56,22 @@
 	invoke-rc.d apache restart
 	;;
 
-    purge)
-  	if grep -q "Include /etc/sourceforge/sf-httpd.conf" /etc/apache/httpd.conf ; then
+    purge-files)
+	cp -a /etc/apache/httpd.conf /etc/apache/httpd.conf.sourceforge-new
+  	if grep -q "Include /etc/sourceforge/sf-httpd.conf" /etc/apache/httpd.conf.sourceforge-new ; then
 	    pattern=$(basename $0)
 	    tmp=$(mktemp /tmp/$pattern.XXXXXX)
-	    grep -v "Include /etc/sourceforge/sf-httpd.conf\|### Next line inserted by Sourceforge install" /etc/apache/httpd.conf > $tmp
-	    cat $tmp > /etc/apache/httpd.conf
+	    grep -v "Include /etc/sourceforge/sf-httpd.conf\|### Next line inserted by Sourceforge install" /etc/apache/httpd.conf.sourceforge-new > $tmp
+	    cat $tmp > /etc/apache/httpd.conf.sourceforge-new
 	    rm -f $tmp
-	    invoke-rc.d apache restart
   	fi
 	;;
+    purge)
+	invoke-rc.d apache restart
+	;;
 
     *)
-	echo "Usage: $0 {configure|purge}"
+	echo "Usage: $0 {configure|configure-files|purge|purge-files}"
 	exit 1
 	;;
 	

Modified: trunk/gforge_base/evolvisforge-5.1/gforge/deb-specific/install-db.sh
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge/deb-specific/install-db.sh	2011-02-24 14:43:04 UTC (rev 7534)
+++ trunk/gforge_base/evolvisforge-5.1/gforge/deb-specific/install-db.sh	2011-02-24 14:43:06 UTC (rev 7535)
@@ -19,6 +19,29 @@
 	echo "Usage: $0 {configure|purge}"
 	exit 1
 	;;
+    configure-files)
+	# Tell PostgreSQL to let us use the database
+	db_passwd=$(perl -e'require "/etc/sourceforge/local.pl"; print "$sys_dbpasswd\n";')
+	ip_address=$(perl -e'require "/etc/sourceforge/local.pl"; print "$sys_dbhost\n";')
+	pattern=$(basename $0).XXXXXX
+	cp -a /etc/postgresql/pg_hba.conf /etc/postgresql/pg_hba.conf.sourceforge-new
+	if grep -q "^host.*sourceforge_passwd$" /etc/postgresql/pg_hba.conf.sourceforge-new ; then
+	    perl -pi -e "s/^host.*sourceforge_passwd$/host  sourceforge        $ip_address     255.255.255.255           password sourceforge_passwd/" /etc/postgresql/pg_hba.conf.sourceforge-new
+	else
+	    cur=$(mktemp /tmp/$pattern)
+	    echo "### Next line inserted by Sourceforge install" > $cur
+	    echo "host  sourceforge        $ip_address     255.255.255.255           password sourceforge_passwd" >> $cur
+	    cat /etc/postgresql/pg_hba.conf.sourceforge-new >> $cur
+	    cat $cur > /etc/postgresql/pg_hba.conf.sourceforge-new
+	    rm -f $cur
+	fi
+	su postgres -c "touch /var/lib/postgres/data/sourceforge_passwd"
+	su postgres -c "/usr/lib/postgresql/bin/pg_passwd /var/lib/postgres/data/sourceforge_passwd > /dev/null" <<-EOF
+sourceforge
+$db_passwd
+$db_passwd
+EOF
+	;;
     configure)
 	# Create the appropriate database user
 	pattern=$(basename $0).XXXXXX
@@ -55,26 +78,6 @@
 	fi
 	rm -f $tmp1 $tmp2
 	
-	# Tell PostgreSQL to let us use the database
-	db_passwd=$(perl -e'require "/etc/sourceforge/local.pl"; print "$sys_dbpasswd\n";')
-	ip_address=$(perl -e'require "/etc/sourceforge/local.pl"; print "$sys_dbhost\n";')
-	su postgres -c "touch /var/lib/postgres/data/sourceforge_passwd"
-	su postgres -c "/usr/lib/postgresql/bin/pg_passwd /var/lib/postgres/data/sourceforge_passwd > /dev/null" <<-EOF
-sourceforge
-$db_passwd
-$db_passwd
-EOF
-	if grep -q "^host.*sourceforge_passwd$" /etc/postgresql/pg_hba.conf ; then
-	    perl -pi -e "s/^host.*sourceforge_passwd$/host  sourceforge        $ip_address     255.255.255.255           password sourceforge_passwd/" /etc/postgresql/pg_hba.conf
-	else
-	    cur=$(mktemp /tmp/$pattern)
-	    echo "### Next line inserted by Sourceforge install" > $cur
-	    echo "host  sourceforge        $ip_address     255.255.255.255           password sourceforge_passwd" >> $cur
-	    cat /etc/postgresql/pg_hba.conf >> $cur
-	    cat $cur > /etc/postgresql/pg_hba.conf
-	    rm -f $cur
-	fi
-
 	# Install/upgrade the database contents (tables and data)
 	# Dirty scripting for testing purpose
 #	psql -U sourceforge -h $ip_address sourceforge -f /usr/lib/sourceforge/db/sf-2.6-complete.sql <<-FIN
@@ -82,12 +85,15 @@
 #FIN
 	/usr/lib/sourceforge/bin/db-upgrade26.pl 2>&1 | grep -v ^NOTICE:
 	;;
-    purge)
-        if grep -q "### Next line inserted by Sourceforge install" /etc/postgresql/pg_hba.conf
+    purge-files)
+	cp -a /etc/postgresql/pg_hba.conf /etc/postgresql/pg_hba.conf.sourceforge-new
+        if grep -q "### Next line inserted by Sourceforge install" /etc/postgresql/pg_hba.conf.sourceforge-new
         then
-                perl -pi -e "s/### Next line inserted by Sourceforge install\n//" /etc/postgresql/pg_hba.conf
-                perl -pi -e "s/^host.*sourceforge_passwd\n//" /etc/postgresql/pg_hba.conf
+                perl -pi -e "s/### Next line inserted by Sourceforge install\n//" /etc/postgresql/pg_hba.conf.sourceforge-new
+                perl -pi -e "s/^host.*sourceforge_passwd\n//" /etc/postgresql/pg_hba.conf.sourceforge-new
         fi
+	;;
+    purge)
 	su postgres -c "dropdb sourceforge" &> /dev/null || true
 	su postgres -c "dropuser sourceforge" &> /dev/null || true
 	rm -f /var/lib/postgres/data/sourceforge_passwd

Modified: trunk/gforge_base/evolvisforge-5.1/gforge/deb-specific/install-dns.sh
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge/deb-specific/install-dns.sh	2011-02-24 14:43:04 UTC (rev 7534)
+++ trunk/gforge_base/evolvisforge-5.1/gforge/deb-specific/install-dns.sh	2011-02-24 14:43:06 UTC (rev 7535)
@@ -13,17 +13,20 @@
 fi
 
 case "$1" in
-    configure)
+    configure-files)
+	cp -a /etc/bind/named.conf /etc/bind/named.conf.sourceforge-new
 	domain_name=$(perl -e'require "/etc/sourceforge/local.pl"; print "$domain_name\n";')
 	ip_address=$(perl -e'require "/etc/sourceforge/local.pl"; print "$sys_dbhost\n";')
 	# export domain_name=$1
 	# export ip_address=$2
-  	if ! grep -q "// Next line inserted by Sourceforge install" /etc/bind/named.conf ; then
-	    cat >> /etc/bind/named.conf <<-EOF
+  	if ! grep -q "// Next line inserted by Sourceforge install" /etc/bind/named.conf.sourceforge-new ; then
+	    cat >> /etc/bind/named.conf.sourceforge-new <<-EOF
 // Next line inserted by Sourceforge install
 zone "$domain_name" { type master; file "/var/lib/sourceforge/bind/dns.zone"; };
 EOF
   	fi
+	;;
+    configure)
   	echo "Creating /var/lib/sourceforge/bind/dns.head"
   	serial=`date '+%Y%m%d'`01
   	# cvs_host lists_host are useless for now
@@ -49,20 +52,19 @@
 
 	;;
 
-    purge)
-	if grep -q "// Next line inserted by Sourceforge install" /etc/bind/named.conf ; then
-	    perl -pi -e "s:zone.*sourceforge.*};\n::" /etc/bind/named.conf
-	    perl -pi -e "s:// Next line inserted by Sourceforge install\n::" /etc/bind/named.conf
-
-	    invoke-rc.d bind9 restart
-	    # This is equivalent but require some signature, not always there
-	    # /usr/sbin/rndc reload
-
+    purge-files)
+	cp -a /etc/bind/named.conf /etc/bind/named.conf.sourceforge-new
+	if grep -q "// Next line inserted by Sourceforge install" /etc/bind/named.conf.sourceforge-new ; then
+	    perl -pi -e "s:zone.*sourceforge.*};\n::" /etc/bind/named.conf.sourceforge-new
+	    perl -pi -e "s:// Next line inserted by Sourceforge install\n::" /etc/bind/named.conf.sourceforge-new
 	fi
 	;;
+    purge)
+	invoke-rc.d bind9 restart
+	;;
 
     *)
-	echo "Usage: $0 {configure|purge}"
+	echo "Usage: $0 {configure|configure-files|purge|purge-files}"
 	exit 1
 	;;
 

Modified: trunk/gforge_base/evolvisforge-5.1/gforge/debian/sourceforge.postinst
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge/debian/sourceforge.postinst	2011-02-24 14:43:04 UTC (rev 7534)
+++ trunk/gforge_base/evolvisforge-5.1/gforge/debian/sourceforge.postinst	2011-02-24 14:43:06 UTC (rev 7535)
@@ -35,11 +35,11 @@
 	# Old file and new file are identical
 	rm -f ${file}.sourceforge-new
     else
-	db_fset sourceforge/internal/replace_file seen false
-	db_subst sourceforge/internal/replace_file file $file
-	db_input high sourceforge/internal/replace_file || true
+	db_fset sourceforge/internal/replace_file_install seen false
+	db_subst sourceforge/internal/replace_file_install file $file
+	db_input high sourceforge/internal/replace_file_install || true
 	db_go || true
-	db_get sourceforge/internal/replace_file || true
+	db_get sourceforge/internal/replace_file_install || true
 	case "$RET" in
 	    "true")
 		echo >&2 "Replacing file $file with changed version"
@@ -75,13 +75,23 @@
         done
 	/usr/sbin/sourceforge-config
     	
-        # Setup our Apache files
+        # Patch Apache configuration files
 	/usr/lib/sourceforge/bin/install-apache.sh configure-files
 
 	propose_update /etc/apache/httpd.conf
 	propose_update /etc/php4/apache/php.ini
 	propose_update /etc/php4/cgi/php.ini
 
+        # Patch DB configuration files
+	/usr/lib/sourceforge/bin/install-db.sh configure-files
+
+	propose_update /etc/postgresql/pg_hba.conf
+	
+	# Patch Bind configuration files
+	/usr/lib/sourceforge/bin/install-dns.sh configure-files
+
+	propose_update /etc/bind/named.conf
+	
 	# Clean debconf after ourselves
 	db_stop
 

Modified: trunk/gforge_base/evolvisforge-5.1/gforge/debian/sourceforge.prerm
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge/debian/sourceforge.prerm	2011-02-24 14:43:04 UTC (rev 7534)
+++ trunk/gforge_base/evolvisforge-5.1/gforge/debian/sourceforge.prerm	2011-02-24 14:43:06 UTC (rev 7535)
@@ -19,9 +19,57 @@
     rm -f /usr/doc/pkg
 fi
 
+replace_file () {
+    file=$1
+    cp $file ${file}.sourceforge-old
+    mv ${file}.sourceforge-new $file
+}
+
+propose_update () {
+    file=$1
+    if diff -q ${file} ${file}.sourceforge-new &> /dev/null ; then
+	# Old file and new file are identical
+	rm -f ${file}.sourceforge-new
+    else
+	db_fset sourceforge/internal/replace_file_remove seen false
+	db_subst sourceforge/internal/replace_file_remove file $file
+	db_input high sourceforge/internal/replace_file_remove || true
+	db_go || true
+	db_get sourceforge/internal/replace_file_remove || true
+	case "$RET" in
+	    "true")
+		echo >&2 "Replacing file $file with changed version"
+		replace_file $file
+		;;
+	    "false")
+		# Do nothing
+		;;
+	esac
+    fi
+}
+
 case "$1" in
     remove)
-#       install-info --quiet --remove /usr/info/sourceforge.info.gz
+	. /usr/share/debconf/confmodule
+
+        # Unpatch Apache configuration files
+	/usr/lib/sourceforge/bin/install-apache.sh purge-files
+
+	propose_update /etc/apache/httpd.conf
+
+        # Unpatch DB configuration files
+	/usr/lib/sourceforge/bin/install-db.sh purge-files
+
+	propose_update /etc/postgresql/pg_hba.conf
+	
+	# Unpatch Bind configuration files
+	/usr/lib/sourceforge/bin/install-dns.sh purge-files
+
+	propose_update /etc/bind/named.conf
+	
+	# Clean debconf after ourselves
+	db_stop
+
         # FTP config removal
 	/usr/lib/sourceforge/bin/install-ftp.sh purge
 

Modified: trunk/gforge_base/evolvisforge-5.1/gforge/debian/sourceforge.templates
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge/debian/sourceforge.templates	2011-02-24 14:43:04 UTC (rev 7534)
+++ trunk/gforge_base/evolvisforge-5.1/gforge/debian/sourceforge.templates	2011-02-24 14:43:06 UTC (rev 7535)
@@ -237,7 +237,7 @@
  passe pour le compte administrateur de libpam-ldap et pour le mot de
  passe LDAP de Sourceforge.
 
-Template: sourceforge/internal/replace_file
+Template: sourceforge/internal/replace_file_install
 Type: boolean
 Default: false
 Description: Do you want ${file} to be updated?
@@ -250,3 +250,17 @@
  ${file} yourself.
  .
  Shall I modify the ${file} automatically?
+
+Template: sourceforge/internal/replace_file_remove
+Type: boolean
+Default: false
+Description: Do you want ${file} to be updated?
+ In order for Sourceforge to be fully deinstalled, some changes must
+ be made to the ${file} file.
+ .
+ I can either do them for you (and backup the current version in
+ ${file}.sourceforge-old), or write the changes to another file
+ (${file}.sourceforge-new) and let you propagate the changes to
+ ${file} yourself.
+ .
+ Shall I modify the ${file} automatically?



More information about the evolvis-commits mailing list