Bug#670293: code-aster-{gui, run}: prompting due to modified conffiles which were not modified by the user

Julien Cristau jcristau at debian.org
Tue Jun 26 09:44:50 UTC 2012


On Tue, Apr 24, 2012 at 18:52:15 +0200, Andreas Beckmann wrote:

> Package: code-aster-gui,code-aster-run
> Version: 1.10.4-1
> Severity: serious
> User: debian-qa at lists.debian.org
> Usertags: piuparts
> 
> Hi,
> 
> during a test with piuparts I noticed your package failed the piuparts
> upgrade test because dpkg detected a conffile as being modified and then
> prompted the user for an action. As there is no user input, this fails.
> But this is not the real problem, the real problem is that this prompt
> shows up in the first place, as there was nobody modifying this conffile
> at all, the package has just been installed and upgraded...
> 
A configuration file can't both be shipped in the package (and thus be a
conffile) and handled using debconf.  The patch below should make them
non-conffile, and handle reconfiguration properly.  I haven't tested it
yet, not sure I can get to it today.

Changes:
- split templates in code-aster-run and code-aster-gui.  Some are
  shared.
- install files to /usr/share/codeaster instead of /etc/codeaster/asrun,
  /etc/codeaster/astk/prefs and /etc/codeaster/astk/config_serveurs
- in *.config, if the config file exists, read the value from it and
  seed that into debconf; if not use a default
- in *.postinst, on initial install copy the templates from
  /usr/share/codeaster; then proceed to reading the debconf stored
  values and writing them in the config files.

Hope this helps.

Cheers,
Julien

Index: debian/code-aster-run.postinst
===================================================================
--- debian/code-aster-run.postinst	(revision 45122)
+++ debian/code-aster-run.postinst	(working copy)
@@ -2,25 +2,29 @@
 
 set -ex
 
-# Source debconf library.
-. /usr/share/debconf/confmodule
+TEMPLATE=/usr/share/codeaster/asrun
+ASRUN=/etc/codeaster/asrun
 
-if [ "$1" = "configure" ] ; then
-	db_get astk/platform || true
-	platform=${RET}
-	perl -pi -le "s|plate-forme : .*|plate-forme : $platform|" /etc/codeaster/asrun
+if [ "$1" = "configure" ]; then
+	if [ -z "$2" ]; then
+		if [ "$(getconf LONG_BIT)" = 64 ]; then
+			platform=LINUX64
+		else
+			platform=LINUX
+		fi
 
-	db_get astk/node || true
-	node=${RET}
-	perl -pi -le "s|noeud : .*|noeud : $node|" /etc/codeaster/asrun
-	
+		node=$(hostname -s 2>/dev/null)
+
+		sed -e "s|^plate-forme : .*|plate-forme : $platform|;s|noeud : .*|noeud : $node|" < $TEMPLATE > $ASRUN
+	fi
+
 	db_get astk/EDITOR || true
 	editor=${RET}
-	perl -pi -le "s|editor : .*|editor : $editor|" /etc/codeaster/asrun
-	
+
 	db_get astk/TERMINAL || true
 	terminal=${RET}
-	perl -pi -le "s|terminal : .*|terminal : $terminal|" /etc/codeaster/asrun
+
+	sed -i -e "s|editor : .*|editor : $editor|;s|terminal : .*|terminal : $terminal|" $ASRUN
 	
 fi
 
Index: debian/code-aster-gui.config
===================================================================
--- debian/code-aster-gui.config	(revision 45122)
+++ debian/code-aster-gui.config	(working copy)
@@ -6,77 +6,30 @@
 # Source debconf library.
 . /usr/share/debconf/confmodule
 
-DEB_HOST_ARCH_OS="$(dpkg-architecture -qDEB_HOST_ARCH_OS | tr '[:lower:]' '[:upper:]')"
-DEB_HOST_ARCH_BITS="$(dpkg-architecture -qDEB_HOST_ARCH_BITS)"
-
-#Set default platform
-if [ "${dc_platform}" = "" ] ; then
-	dc_platform= "${DEB_HOST_ARCH_OS}" && \
-	db_set astk/platform "${dc_platform}"
-	if [ "${DEB_HOST_ARCH_BITS}" = "64" ] ; then
-	    dc_platform= "${DEB_HOST_ARCH_OS}${DEB_HOST_ARCH_BITS}" && \
-	    db_set astk/platform "${dc_platform}"
-	fi
-fi
-
 #Set default domain name
-if [ "${dc_domainname}" = "" ] ; then
-	dc_domainname="$(hostname --domain 2>/dev/null)" && \
-	db_set astk/domainname "${dc_domainname}"
-fi
 
-#Set default server name
-if [ "${dc_servername}" = "" ] ; then
-	dc_servername="$(hostname 2>/dev/null)"  && \
-	db_set astk/servername "${dc_servername}"
+servername=$(hostname 2>/dev/null)
+domainname=$(hostname --domain 2>/dev/null)
+if [ -f /etc/codeaster/astkrc/config_serveurs ]; then
+	servername=$(sed -ne '/^serveur/ { s/^serveur[[:space:]]*:[[:space:]]*//; p; q }' /etc/codeaster/astkrc/config_serveurs)
 fi
-
-#Set default node name
-if [ "${dc_node}" = "" ] ; then
-	dc_node="$(hostname -s 2>/dev/null)" && \
-	db_set astk/node "${dc_node}"
+if [ -f /etc/codeaster/astkrc/prefs ]; then
+	domainname=$(sed -ne '/^nom_domaine/ { s/^nom_domaine[[:space:]]*:[[:space:]]*//; p; q }' /etc/codeaster/astkrc/prefs
+	editor=$(sed -ne '/^editeur/ { s/^editeur[[:space:]]*:[[:space:]]*//; p; q }' /etc/codeaster/astkrc/prefs
+	terminal=$(sed -ne '/^terminal/ { s/^terminal[[:space:]]*:[[:space:]]*//; p; q }' /etc/codeaster/astkrc/prefs
+	db_set astk/EDITOR "${editor}"
+	db_set astk/TERMINAL "${terminal}"
 fi
 
-#Set default editor name
-if [ "${dc_editor}" = "" ] ; then
-	dc_editor="/usr/bin/gedit --display=\@D" && \
-	db_set astk/EDITOR "${dc_editor}"
-fi
+db_set astk/servername "${servername}"
+db_set astk/domainname "${domainname}"
 
-#Set default terminal name
-if [ "${dc_terminal}" = "" ] ; then
-	dc_terminal="/usr/bin/gnome-terminal --display=\@D --command=\@E" && \
-	db_set astk/TERMINAL "${dc_terminal}"
-fi
-
-db_version 2.0
-
-# Choose Platform
-db_input medium astk/platform || true
-dc_platform="$RET"
-db_go
-
-# Node name
-db_input medium astk/node || true
-dc_node="$RET"
-db_go
-
 # Server name
 db_input medium astk/servername || true
-dc_servername="$RET"
-db_go
-
 # Domain name
 db_input medium astk/domainname || true
-dc_domainname="$RET"
-db_go
-
 # Choose Editor
 db_input medium astk/EDITOR || true
-dc_editor="$RET"
-db_go
-
 # Choose TERMINAL
 db_input medium astk/TERMINAL || true
-dc_terminal="$RET"
-db_go
+db_go || true
Index: debian/code-aster-gui.install
===================================================================
--- debian/code-aster-gui.install	(revision 45122)
+++ debian/code-aster-gui.install	(working copy)
@@ -13,7 +13,10 @@
 debian/tmp/usr/lib/astk/RELNOTES* usr/share/astk
 
 # config
-debian/tmp/etc/codeaster/astkrc/* etc/codeaster/astkrc
+debian/tmp/etc/codeaster/astkrc/prefs usr/share/codeaster/astkrc
+debian/tmp/etc/codeaster/astkrc/config_serveurs usr/share/codeaster/astkrc
+debian/tmp/etc/codeaster/astkrc/outils etc/codeaster/astkrc
+debian/tmp/etc/codeaster/astkrc/ASTKRC_INFO.txt etc/codeaster/astkrc
 
 # menu
 debian/code-aster-gui.desktop usr/share/applications
Index: debian/code-aster-run.templates
===================================================================
--- debian/code-aster-run.templates	(revision 0)
+++ debian/code-aster-run.templates	(working copy)
@@ -0,0 +1,38 @@
+# These templates have been reviewed by the debian-l10n-english
+# team
+#
+# If modifications/additions/rewording are needed, please ask
+# debian-l10n-english at lists.debian.org for advice.
+#
+# Even minor modifications require translation updates and such
+# changes should be coordinated with translators and reviewers.
+
+Template: astk/platform
+Type: select
+Choices: LINUX, P_LINUX, LINUX64, P_LINUX64
+Default: LINUX64
+_Description: Aster platform:
+ Select Aster platform.
+
+Template: astk/node
+Type: string
+_Description: ASTK client node name:
+ Please enter the public name by which this client will be known on
+ the network. It must be a unique name within the domain.
+
+Template: astk/EDITOR
+Type: select
+Choices: /usr/bin/nedit, /usr/bin/gedit --display=\@D, /usr/bin/kwrite --display \@D, /usr/bin/xemacs -display \@D, /usr/bin/emacs -display \@D, /usr/bin/xedit -display \@D, /usr/bin/xterm  -display \@D -e \@E -e vi
+Default: /usr/bin/nedit
+_Description: Standard editor:
+ Please select the command line that ASTK should use to launch an
+ editor.
+
+Template: astk/TERMINAL
+Type: select
+Choices: /usr/bin/xterm -display \@D -e \@E, /usr/bin/gnome-terminal --display=\@D --command=\@E, /usr/bin/konsole --display \@D -e \@E
+Default: /usr/bin/gnome-terminal --display=\@D --command=\@E
+_Description: Standard terminal emulator:
+ Please select the command line that ASTK should use to launch a
+ terminal window.
+
Index: debian/code-aster-gui.postinst
===================================================================
--- debian/code-aster-gui.postinst	(revision 45122)
+++ debian/code-aster-gui.postinst	(working copy)
@@ -6,6 +6,13 @@
 . /usr/share/debconf/confmodule
 
 if [ "$1" = "configure" ] ; then
+	if [ -z "$2" ]; then
+		mkdir -p /etc/codeaster/astk
+		cp -a /usr/share/codeaster/astk/config_serveurs \
+			/usr/share/codeaster/astk/prefs \
+			/etc/codeaster/astk/
+	fi
+
 	db_get astk/servername || true
 	servername=${RET}
 	perl -pi -le "s|serveur : .*|serveur : $servername|" /etc/codeaster/astkrc/config_serveurs
Index: debian/code-aster-gui.templates
===================================================================
--- debian/code-aster-gui.templates	(revision 45122)
+++ debian/code-aster-gui.templates	(working copy)
@@ -7,13 +7,6 @@
 # Even minor modifications require translation updates and such
 # changes should be coordinated with translators and reviewers.
 
-Template: astk/platform
-Type: select
-Choices: LINUX, P_LINUX, LINUX64, P_LINUX64
-Default: LINUX64
-_Description: Aster platform:
- Select Aster platform.
-
 Template: astk/domainname
 Type: string
 _Description: ASTK server domain name:
@@ -26,12 +19,6 @@
  Please enter the host name (without domain name) of the server
  that this ASTK client should connect to.
 
-Template: astk/node
-Type: string
-_Description: ASTK client node name:
- Please enter the public name by which this client will be known on
- the network. It must be a unique name within the domain.
-
 Template: astk/EDITOR
 Type: select
 Choices: /usr/bin/nedit, /usr/bin/gedit --display=\@D, /usr/bin/kwrite --display \@D, /usr/bin/xemacs -display \@D, /usr/bin/emacs -display \@D, /usr/bin/xedit -display \@D, /usr/bin/xterm  -display \@D -e \@E -e vi
@@ -48,18 +35,3 @@
  Please select the command line that ASTK should use to launch a
  terminal window.
 
-Template: astk/MPIRUN
-Type: select
-Choices: LAM, OPENMPI, MPICH2
-Default: OPENMPI
-_Description: ASTK server MPI implementation:
- Please select the MPI implementation used by the server that this ASTK
- client should connect to.
-
-Template: astk/IFDEF
-Type: select
-Choices: LINUX, LINUX64
-Default: LINUX64
-_Description: ASTK server bit width:
- Please select the bit width of the server that this ASTK client should
- connect to.         
Index: debian/code-aster-run.config
===================================================================
--- debian/code-aster-run.config	(revision 0)
+++ debian/code-aster-run.config	(working copy)
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+set -ex
+
+# Source debconf library.
+. /usr/share/debconf/confmodule
+
+ASRUN=/etc/codeaster/asrun
+
+if [ -f "$ASRUN" ]; then
+	editor=$(sed -ne 's/^editor[[:space:]]*:[[:space:]]*//; p; q}' $ASRUN)
+	terminal=$(sed -ne '/^terminal/ { s/^terminal[[:space:]]*:[[:space:]]*//; p; q}' $ASRUN)
+	db_set astk/EDITOR "$editor"
+	db_set astk/TERMINAL "$terminal"
+fi
+db_input low astk/EDITOR || true
+db_input low astk/TERMINAL || true
+db_go || true
Index: debian/code-aster-run.install
===================================================================
--- debian/code-aster-run.install	(revision 45122)
+++ debian/code-aster-run.install	(working copy)
@@ -9,7 +9,7 @@
 ASTK_SERV/etc/config_nodename etc/codeaster
 ASTK_SERV/etc/aster etc/codeaster
 ASTK_SERV/etc/profile.csh etc/codeaster
-ASTK_SERV/etc/asrun etc/codeaster
+ASTK_SERV/etc/asrun usr/share/codeaster
 debian/aster-mpihosts etc/codeaster
 
 # ASTER_ROOT
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.alioth.debian.org/pipermail/debian-science-maintainers/attachments/20120626/e2714d0d/attachment.pgp>


More information about the debian-science-maintainers mailing list