tags 553538 + patch
thanks

Hi,

Attached is an improved interdiff for my suggestion
on an NMU-patched package iog_1.03-3.2.

This revised patch uses 'ucf/ucfr' to handle the configuration
file at '/etc/iog.cfg', and it uses a single debconf-question
to offer the possibility of migrating old data in '/var/www/iog/'
to '/var/lib/iog/'. Or to refrain from migration, whatever the
case might be.

I have tested this with and without migration, and for the latter
case also a later migration using 'dpkg-reconfigure'. The mechanism
pleases my eyes at least.


Best regards,

Mats Erik Andersson <mats.anders...@gisladisker.se>
diff -u iog-1.03/iog.cfg iog-1.03/iog.cfg
--- iog-1.03/iog.cfg
+++ iog-1.03/iog.cfg
@@ -27,6 +27,6 @@
 # sw2-port20:192.168.0.11:public:ifHCInOctets.20:ifHCOutOctets.20:/www/iog/
 #
-[localhost:127.0.0.1:public:sysUpTime.0:/var/www/iog]
-localhost:127.0.0.1:public:ifInOctets.2:ifOutOctets.2:/var/www/iog
+[localhost:127.0.0.1:public:sysUpTime.0:/var/lib/iog]
+localhost:127.0.0.1:public:ifInOctets.2:ifOutOctets.2:/var/lib/iog
 
 
diff -u iog-1.03/debian/rules iog-1.03/debian/rules
--- iog-1.03/debian/rules
+++ iog-1.03/debian/rules
@@ -46,8 +46,10 @@
 	dh_installdocs
 	dh_installexamples iog.cfg
 	dh_installcron
+	dh_link
 	dh_undocumented iog.1
 	dh_installchangelogs 
+	dh_installdebconf
 	dh_compress
 	dh_fixperms
 	dh_installdeb
diff -u iog-1.03/debian/changelog iog-1.03/debian/changelog
--- iog-1.03/debian/changelog
+++ iog-1.03/debian/changelog
@@ -1,3 +1,32 @@
+iog (1.03-3.2) unstable; urgency=low
+
+  * Non-maintainer upload.
+  * Repair 'dir-or-file-in-var-www'. (Closes: #553538)
+    + debian/NEWS: New file with package notes refering to FHS.
+    + debian/README.Debian: New file with further hints.
+    + debian/control: Policy compliant dependencies:
+      - Depends: Add ucf, debconf, and ${misc:Depends}.
+      - Build-Depends-Indep: po-debconf.
+      - Build-Depends: debhelper.
+    + Replace '/var/www/iog' with '/var/lib/iog' in 'iog.cfg'.
+    + Use 'ucf' to handle '/etc/iog.cfg'. The package ships the new
+      configuration file as '/usr/share/iog/iog.cfg'.
+    + Use 'debconf' to handle the interaction needed for migrating old
+      data in '/var/www/iog/' to preferred location '/var/lib/iog/'.
+      - debian/iog.templates: New file.
+      - debian/iog.config: New file.
+      - debian/po/*: New files.
+    + debian/postinst: Now acts on '/var/lib/iog'. Registers the file
+      '/etc/iog.cfg' with 'ucf' and 'ucfr'. Uses debconf for migration.
+    + debian/postrm: New file. Upon purge, deregisters '/etc/iog.cfg'
+      using 'ucf' and 'ucfr'.
+    + Store images '*.gif' in '/usr/share/iog/' and symlink these
+      to '/var/lib/iog/'.
+    + debian/rules: Use dh_link, dh_installdebconf.
+    + debian/iog.links: New file, describes links of images.
+
+ -- Mats Erik Andersson <mats.anders...@gisladisker.se>  Tue, 19 Jan 2010 12:28:05 +0100
+
 iog (1.03-3.1) unstable; urgency=low
 
   * Non-maintainer upload.
diff -u iog-1.03/debian/control iog-1.03/debian/control
--- iog-1.03/debian/control
+++ iog-1.03/debian/control
@@ -2,12 +2,13 @@
 Section: net
 Priority: extra
 Maintainer: Mark Purcell <m...@debian.org>
-Build-Depends-Indep: debhelper (>> 3.0.0)
+Build-Depends: debhelper (>> 3.0.0)
+Build-Depends-Indep: po-debconf
 Standards-Version: 3.5.2
 
 Package: iog
 Architecture: all
-Depends: libsnmp-session-perl
+Depends: libsnmp-session-perl, ucf, debconf, ${misc:Depends}
 Recommends: snmpd
 Description: Network I/O byte grapher
  IOG is a network I/O byte grapher made to graph cumulative KB/MB/GB
diff -u iog-1.03/debian/iog.install iog-1.03/debian/iog.install
--- iog-1.03/debian/iog.install
+++ iog-1.03/debian/iog.install
@@ -1,3 +1,3 @@
-*.gif	var/www/iog/
+*.gif	usr/share/iog/
 iog	usr/sbin/
-iog.cfg etc/
+iog.cfg usr/share/iog/
diff -u iog-1.03/debian/dirs iog-1.03/debian/dirs
--- iog-1.03/debian/dirs
+++ iog-1.03/debian/dirs
@@ -3 +3,2 @@
-var/www/iog
+usr/share/iog
+var/lib/iog
diff -u iog-1.03/debian/postinst iog-1.03/debian/postinst
--- iog-1.03/debian/postinst
+++ iog-1.03/debian/postinst
@@ -11,10 +11,34 @@
 #          <failed-install-package> <version> `removing'
 #          <conflicting-package> <version>
 
+LIBRARY=/usr/share/iog
+OLDLOCATION=/var/www/iog
+NEWLOCATION=/var/lib/iog
+
+CONFIG=/etc/iog.cfg
+PKGCONFIG=$LIBRARY/iog.cfg
+
 case "$1" in
     configure)
 
-	chown -R www-data.www-data /var/www/iog
+	chown -R www-data:www-data /var/lib/iog
+	test -x /usr/bin/ucf && ucf --three-way --debconf-ok $PKGCONFIG $CONFIG
+	test -x /usr/bin/ucfr && ucfr iog $CONFIG
+
+	# Detect an old page depository and activate the desired location.
+
+	if [ -f $OLDLOCATION/uptimes.pag ]
+	then
+		. /usr/share/debconf/confmodule
+		db_get iog/migrate || RET=false
+		if [ $RET = true ]
+		then
+			mv $OLDLOCATION/* $NEWLOCATION/ 2>/dev/null
+		else
+			# Reactivate old content by reinstalling the purged images.
+			cp -a $LIBRARY/*.gif $OLDLOCATION/ 2>/dev/null
+		fi
+	fi
 
     ;;
 
only in patch2:
unchanged:
--- iog-1.03.orig/debian/NEWS
+++ iog-1.03/debian/NEWS
@@ -0,0 +1,18 @@
+iog (1.03-3.2) unstable; urgency=low
+
+  Due to FHS compliance prescribed by the Debian Policy, the images
+  used by this package are now deposited in '/usr/share/iog/', but
+  are symlinked from '/var/lib/iog/'.
+
+  The enclosed configuration file '/etc/iog.cfg' is written to generate
+  the hourly statistics in '/var/lib/iog/', instead of the previous
+  location '/var/www/iog/'. The FHS necessitates this.
+
+  However, the present package initially contains the new configuration
+  file in '/usr/share/iog/iog.cfg', and uses the services 'ucf' and 'ucfr'
+  to update a possibly existing file '/etc/iog.cfg'.
+
+  The migration of old content in '/var/www/iog/' to '/var/lib/iog/'
+  is handled by a debconf-question.
+
+ -- Mats Erik Andersson <mats.anders...@gisladisker.se>  Tue, 19 Jan 2010 12:17:59 +0100
only in patch2:
unchanged:
--- iog-1.03.orig/debian/iog.config
+++ iog-1.03/debian/iog.config
@@ -0,0 +1,19 @@
+#!/bin/sh -e
+
+. /usr/share/debconf/confmodule
+
+OLDLOCATION=/var/www/iog
+NEWLOCATION=/var/lib/iog
+
+LIBRARY=/usr/share/iog
+
+# Detect an old page depository and activate the desired location.
+
+if [ -f $OLDLOCATION/uptimes.pag ]
+then
+	db_input high iog/migrate || true
+	db_go || true
+	# Insert an answer even if 'db_get' fails.
+	db_get iog/migrate || db_set iog/migrate false || true
+fi
+
only in patch2:
unchanged:
--- iog-1.03.orig/debian/iog.templates
+++ iog-1.03/debian/iog.templates
@@ -0,0 +1,13 @@
+Template: iog/migrate
+Type: boolean
+Default: false
+_Description: Migrate old install out of '/var/www/iog/'?
+ It was detected that a previous package release has data installed in the
+ directory '/var/www/iog/'. The present IOG package suggests the use of
+ '/var/lib/iog/' for the same purpose.
+ .
+ Accepting migration will move all old network data to the new location.
+ .
+ By changing the directory pointers to '/var/lib/iog' in the configuration
+ '/etc/iog.cfg', and writing an alias declaration for the web server,
+ IOG will then serve uninterrupted statistics also after the upgrade.
only in patch2:
unchanged:
--- iog-1.03.orig/debian/README.Debian
+++ iog-1.03/debian/README.Debian
@@ -0,0 +1,43 @@
+Due to Debian Policy regarding FHS compliance, this package
+is not immediately ready for displaying network statistics.
+
+The packaged configuration file '/etc/iog.cfg' is written so as to
+deposit the dynamically generated web content in
+
+    /var/lib/iog/
+
+at every run of the cron-script. For full page rendering, the three
+static images
+
+    /usr/share/iog/{in,out,ioglogo}.gif
+
+are symlinked to '/var/lib/iog'.
+
+To make the package productive, the Administrator should preferably
+write an alias declaration (in the style of Apache):
+
+    Alias /iog /var/lib/iog
+
+in order that the web server can begin to display content like
+
+    http://localhost/iog/localhost.html.
+
+Another possibility is to alter '/etc/iog.cfg' to yield the actual
+base directory in use, and also to deposit copies of the images
+in the same directory:
+
+  [localhost:127.0.0.1:public:sysUpTime.0:/path-to-web-base/iog]
+  localhost:127.0.0.1:public:ifInOctets.2:ifOutOctets.2:/path-to-web-base/iog
+
+Observe that the only needed change is to replace '/var/lib/iog'
+with a correct and live path '/path-to-web-base/iog' at the very
+end of both lines. The cron-script is run with owner 'www-data',
+so the directory '/path-to-web-server/iog' needs to be writable
+for this owner.
+
+Whether all this works for your snmpd-setup is another matter!
+You need at least a 'rocommunity' entry for 'public'.
+
+When upgrading from an earlier version, the new package will offer
+help in conducting a migration of old data, or to keep the old
+location '/var/www/iog/' in productive use.
only in patch2:
unchanged:
--- iog-1.03.orig/debian/postrm
+++ iog-1.03/debian/postrm
@@ -0,0 +1,15 @@
+#!/bin/sh -e
+
+CONFIG=/etc/iog.cfg
+PKGCONFIG=/usr/share/iog/iog.cfg
+
+if [ $1 = purge ]
+then
+	test -x /usr/bin/ucfr && ucfr --purge iog $CONFIG
+	test -x /usr/bin/ucf && ucf --purge $CONFIG
+	rm -f $CONFIG
+fi
+
+#DEBHELPER#
+
+exit 0
only in patch2:
unchanged:
--- iog-1.03.orig/debian/iog.links
+++ iog-1.03/debian/iog.links
@@ -0,0 +1,3 @@
+usr/share/iog/in.gif var/lib/iog/in.gif
+usr/share/iog/out.gif var/lib/iog/out.gif
+usr/share/iog/ioglogo.gif var/lib/iog/ioglogo.gif
only in patch2:
unchanged:
--- iog-1.03.orig/debian/po/templates.pot
+++ iog-1.03/debian/po/templates.pot
@@ -0,0 +1,50 @@
+# Trivial translation of template to English po-file.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: IOG\n"
+"Report-Msgid-Bugs-To: i...@packages.debian.org\n"
+"POT-Creation-Date: 2010-01-19 10:18+0100\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <em...@address>\n"
+"Language-Team: LANGUAGE <l...@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=ASCII\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#. Type: boolean
+#. Description
+#: ../iog.templates:1001
+msgid "Migrate old install out of '/var/www/iog/'?"
+msgstr "Migrate old install out of '/var/www/iog/'?"
+
+#. Type: boolean
+#. Description
+#: ../iog.templates:1001
+msgid ""
+"It was detected that a previous package release has data installed in the "
+"directory '/var/www/iog/'. The present IOG package suggests the use of '/var/"
+"lib/iog/' for the same purpose."
+msgstr ""
+"It was detected that a previous package release has data installed in the "
+"directory '/var/www/iog/'. The present IOG package suggests the use of '/var/"
+"lib/iog/' for the same purpose."
+
+#. Type: boolean
+#. Description
+#: ../iog.templates:1001
+msgid "Accepting migration will move all old network data to the new location."
+msgstr "Accepting migration will move all old network data to the new location."
+
+#. Type: boolean
+#. Description
+#: ../iog.templates:1001
+msgid ""
+"By changing the directory pointers to '/var/lib/iog' in the configuration '/"
+"etc/iog.cfg', and writing an alias declaration for the web server, IOG will "
+"then serve uninterrupted statistics also after the upgrade."
+msgstr ""
+"By changing the directory pointers to '/var/lib/iog' in the configuration '/"
+"etc/iog.cfg', and writing an alias declaration for the web server, IOG will "
+"then serve uninterrupted statistics also after the upgrade."
only in patch2:
unchanged:
--- iog-1.03.orig/debian/po/en.po
+++ iog-1.03/debian/po/en.po
@@ -0,0 +1,52 @@
+# Trivial translation of template to 'en.po'.
+# Copyright (C) 2010
+# This file is distributed under the same license as the IOG package.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: IOG\n"
+"Report-Msgid-Bugs-To: i...@packages.debian.org\n"
+"POT-Creation-Date: 2010-01-19 10:18+0100\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <em...@address>\n"
+"Language-Team: LANGUAGE <l...@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=ASCII\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#. Type: boolean
+#. Description
+#: ../iog.templates:1001
+msgid "Migrate old install out of '/var/www/iog/'?"
+msgstr "Migrate old install out of '/var/www/iog/'?"
+
+#. Type: boolean
+#. Description
+#: ../iog.templates:1001
+msgid ""
+"It was detected that a previous package release has data installed in the "
+"directory '/var/www/iog/'. The present IOG package suggests the use of '/var/"
+"lib/iog/' for the same purpose."
+msgstr ""
+"It was detected that a previous package release has data installed in the "
+"directory '/var/www/iog/'. The present IOG package suggests the use of '/var/"
+"lib/iog/' for the same purpose."
+
+#. Type: boolean
+#. Description
+#: ../iog.templates:1001
+msgid "Accepting migration will move all old network data to the new location."
+msgstr "Accepting migration will move all old network data to the new location."
+
+#. Type: boolean
+#. Description
+#: ../iog.templates:1001
+msgid ""
+"By changing the directory pointers to '/var/lib/iog' in the configuration '/"
+"etc/iog.cfg', and writing an alias declaration for the web server, IOG will "
+"then serve uninterrupted statistics also after the upgrade."
+msgstr ""
+"By changing the directory pointers to '/var/lib/iog' in the configuration '/"
+"etc/iog.cfg', and writing an alias declaration for the web server, IOG will "
+"then serve uninterrupted statistics also after the upgrade."
only in patch2:
unchanged:
--- iog-1.03.orig/debian/po/POTFILES.in
+++ iog-1.03/debian/po/POTFILES.in
@@ -0,0 +1 @@
+[type: gettext/rfc822deb] iog.templates

Reply via email to