Bug#292528: pine: postinstall asks questions without using debconf

2005-01-28 Thread Santiago Vila
On Thu, 27 Jan 2005, Tim Cutts wrote:

 Package: pine
 Severity: normal
 Tags: patch
 
 The package built by this source package does not use debconf to ask its
 questions.  The result is that (a) it overwrites the /etc/news/servers
 and /etc/mailname files which are configured with debconf elsewhere
 (say, by slrn or exim) and more seriously (b) it makes it impossible for
 the resulting package to be installed using FAI, since the fully
 automated install stops to ask the questions.
 
 I have modified the source package to build a pine package which uses
 debconf, and the patch is attached.

Thanks a lot for the patch. I will consider it for the next upload,
but I have to look at it carefully first, as I have not had time to
learn about debconf yet.

Would you have some good ideas to fix Bug#213260 as well?


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Bug#292528: pine: postinstall asks questions without using debconf

2005-01-27 Thread Tim Cutts
Package: pine
Severity: normal
Tags: patch


The package built by this source package does not use debconf to ask its
questions.  The result is that (a) it overwrites the /etc/news/servers
and /etc/mailname files which are configured with debconf elsewhere
(say, by slrn or exim) and more seriously (b) it makes it impossible for
the resulting package to be installed using FAI, since the fully
automated install stops to ask the questions.

I have modified the source package to build a pine package which uses
debconf, and the patch is attached.

-- System Information:
Debian Release: 3.1
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: alpha
Kernel: Linux 2.6.6
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)

-- Patch:

diff -ruN pine-4.62/debian/config ../pine-4.62/debian/config
--- pine-4.62/debian/config 1970-01-01 01:00:00.0 +0100
+++ ../pine-4.62/debian/config  2005-01-27 12:28:51.0 +
@@ -0,0 +1,50 @@
+#!/bin/sh -e
+
+. /usr/share/debconf/confmodule
+db_version 2.0
+
+# The following debconf magic comes from the slrn package
+
+db_beginblock
+
+if [ ! -s /etc/news/server ]; then
+   # No news server file currently exists (or it's empty).
+   db_get shared/news/server
+   SERVER=$RET
+   # If there is no server set, try to guess a good value.
+   if [ -z $SERVER ]; then
+   NETNAME=`hostname -d` || true
+   if [ ! -z $NETNAME ]; then
+   db_set shared/news/server news.$NETNAME
+   fi
+   fi
+else
+   # Reconfiguring the package, or a news server file already exists.
+   # Still ask the question, though it may or may not be seen. Just
+   # use the first line of the file now as the default answer.
+   db_set shared/news/server `head -1 /etc/news/server`
+   # Effectively, the question is seen -- since the file is set up..
+   db_fset shared/news/server seen true
+fi
+db_input medium shared/news/server || true
+
+if [ ! -s /etc/mailname ]; then
+   # No /etc/mailname file, or it's empty, so prompt for the mailname.
+   db_get shared/mailname
+   MAILNAME=$RET
+   if [ -z $MAILNAME ]; then
+   db_set shared/mailname `hostname --fqdn` || db_set 
shared/mailname `hostname`
+   fi
+else
+   # Reconfiguring the package, or a mailname file already exists.
+   # Still ask the question, though it may not be seen. Just use the
+   # first line of the file now as the default answer.
+   db_set shared/mailname `head -1 /etc/mailname`
+   # Effectively, the question is seen -- since the file is set up..
+   db_fset shared/mailname seen true
+fi
+db_input medium shared/mailname || true
+
+db_endblock
+
+db_go || true
diff -ruN pine-4.62/debian/postinst ../pine-4.62/debian/postinst
--- pine-4.62/debian/postinst   2005-01-27 14:51:12.0 +
+++ ../pine-4.62/debian/postinst2005-01-27 14:34:11.0 +
@@ -1,66 +1,39 @@
 #!/bin/sh
 set -e
 
-syshostname=`hostname --fqdn`
+. /usr/share/debconf/confmodule
 
-## figure out the system's mailname
+syshostname=`hostname --fqdn`
 
-if [ -f /etc/mailname ]; then
-  mailname=`cat /etc/mailname`
-else
-  echo 'Please enter the mail name of your system.  This is the hostname'
-  echo 'portion of the address to be shown on outgoing news and mail messages.'
-  echo The default is $syshostname, your system's host name.
-  echo
-  echo -n Mail name [$syshostname]: 
-  read mailname
-  echo
-  if [ $mailname ]; then
-echo $mailname /etc/mailname
-  else
-echo $syshostname /etc/mailname
-  fi
-fi
+if [ $1 = configure ]; then
 
-## figure out the default NNTP server
+mkdir -p /etc/news
 
-if [ ! -d /etc/news ]; then
-  mkdir /etc/news
-fi
+db_get shared/news/server
+servername=$RET
+echo $RET  /etc/news/server
 
-if [ -s /etc/news/server ]; then
-  servername=`grep -v ^# /etc/news/server`
-else
-  echo 'There is no default NNTP server defined for your system. This'
-  echo 'address is used by Pine and other programs to configure the default'
-  echo 'news server. Please enter the server name you wish to use.'
-  echo The default is $syshostname, your system's host name.
-  echo
-  echo -n Server name [$syshostname]: 
-  read servername
-  echo
-  if [ $servername ]; then
-echo $servername /etc/news/server
-  else
-echo $syshostname /etc/news/server
-  fi
-fi
+db_get shared/mailname
+mailname=$RET
+echo $RET  /etc/mailname
 
 ## Create /etc/pine.conf if it does not exist:
 ## user-domain=$mailname if the mailname doesn't equal the hostname.
 ## nntp-server=$servername if the news servername doesn't equal the hostname.
 
-if [ ! -f /etc/pine.conf ]; then
-  if [ $mailname != $syshostname ]; then
-expr1=s/^\(user-domain=\).*$/\1$mailname/
-  fi
-  if [ $servername != $syshostname ]; then
-expr2=s/^\(nntp-server=\).*$/\1$servername/
-  fi
-  expr3=s/^\(character-set=\).*$/\1iso-8859-1/
-  pine -conf | sed -e $expr1 -e