tags 333294 patch
# now that there is a working patch, fixing the bug is only a matter of
# merging the patch
severity 333294 minor
thanks

Eddy Petrișor wrote:
On 29/06/2007, Junichi Uekawa <[EMAIL PROTECTED]> wrote:
Hi,

Hello again,

This is a mail to say that I have returned to the issue and will
publish my results on alioth:

http://git.debian.org/?p=users/eddyp-guest/pbuilder.git;a=summary

I have pushed these changes into my repo, and, in the form they are now, they should be ok for inclusion in the package.


You can pull my changes from the master branch of this repo:
git://git.debian.org/git/users/eddyp-guest/pbuilder.git

For tacking purposes I have attached to the mail a monolithic patch realtive to current git master.



I have tested this in the following situations:
- no pbuilderrc, no sources.list, no sources.list.d/*.sources.list
- no pbuilderrc
- all present

It seems it works fine.

I haven't given any thought to add any test in the test suite.

What would be needed now would be a review of the po-debconf templates from the smith project, then a call for translations on the [EMAIL PROTECTED] list.

Progres details follow:

I ran debconf-updatepo and made a complete Romanian translation.

 2. generate /etc/pbuilderrc from /usr/share/pbuilder/pbuilderrc, using
   the debconf-provided defaults.

Needs to be done (postinst feeds on /etc/pbuilderrc even if it doesn't exist).

Done

Now uses information from /etc/apt/sources.list and /etc/apt/sources.list.d/*.sources.list. If that information proves to be insufficient to get the right information, it will fall back to user input. If the questions are not shown (e.g. priority critical), the fallback is to use
http://ftp.debian.org/debian

 3. make sure pbuilder doesn't change in such a way to require change in 
default configuration file

That is your problem :-)

 pbuilder should work fine with an empty or nonexisting
 /etc/pbuilderrc, since it can pull the default from

Does that work now?

I have left a TODO comment in the postinst about this issue, since I didn't knew if it was ok to leave just the MIRRORSITE in the configuration.

 /usr/share/pbuilder/pbuilderrc, and newer configuration variables will
 be taken from there, so upgrade cases shouldn't cause too much
 problem.

Does pbuilder work properly if pbuilderrc is minimalistic (i.e.
contains only MIRRORSITE=...)?

Then generating a minimal /etc/pbuilderrc with the default sources it
all that it takes to fix this bug (in the light of my existing work),
right?

Still waiting.

--
Regards,
EddyP
=============================================
"Imagination is more important than knowledge" A.Einstein
diff --git a/Makefile b/Makefile
index 945b0e0..e25c7e0 100644
--- a/Makefile
+++ b/Makefile
@@ -88,8 +88,8 @@ install:
 	$(INSTALL_EXECUTABLE) pbuilder-satisfydepends-checkparams $(DESTDIR)/usr/lib/pbuilder/
 	$(INSTALL_EXECUTABLE) pbuilder-satisfydepends-funcs $(DESTDIR)/usr/lib/pbuilder/
 	$(INSTALL_EXECUTABLE) pdebuild-internal $(DESTDIR)/usr/lib/pbuilder/
+	$(INSTALL_FILE) pbuilderrc $(DESTDIR)/usr/share/doc/pbuilder/examples
 	$(INSTALL_FILE) bash_completion.pbuilder $(DESTDIR)/etc/bash_completion.d/pbuilder
-	$(INSTALL_FILE) pbuilderrc $(DESTDIR)/etc
 	$(INSTALL_FILE) pbuilderrc $(DESTDIR)/usr/share/pbuilder
 	$(INSTALL_FILE) pbuilder-uml.conf $(DESTDIR)/etc/pbuilder
 	$(INSTALL_FILE) pbuilder-uml.conf $(DESTDIR)/usr/share/pbuilder
diff --git a/debian/changelog b/debian/changelog
index b76c51a..797b5df 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -4,7 +4,19 @@ pbuilder (0.179~1.gbpfaef96) UNRELEASED; urgency=low
 
   * UNRELEASED
 
- -- Junichi Uekawa <[EMAIL PROTECTED]>  Sat, 02 Feb 2008 12:27:36 +0900
+  [ Eddy Petrișor ]
+  * added support for detection of the default mirror in postinst
+    (Closes: #333294)
+    - /etc/pbuilderrc is no longer a conffile
+    - detection of the default MIRRORSITE relies on the information from
+      /etc/apt/sources.list and /etc/apt/sources.list.d/
+  * bumped versioned dependency on debhelper to (>= 4.1.16) as indicated in
+    po-debconf manual
+
+  [ po-debconf translations ]
+  * iniatial Romanian translation (by Eddy Petrișor)
+
+ -- Eddy Petrișor <[EMAIL PROTECTED]>  Sun, 02 Mar 2008 08:50:48 +0200
 
 pbuilder (0.178) unstable; urgency=low
 
diff --git a/debian/control b/debian/control
index f943fb5..2110a71 100644
--- a/debian/control
+++ b/debian/control
@@ -3,14 +3,14 @@ Section: devel
 Priority: extra
 Maintainer: Debian pbuilder maintenance team <[EMAIL PROTECTED]>
 Uploaders: Junichi Uekawa <[EMAIL PROTECTED]>, Matt Kraai <[EMAIL PROTECTED]>
-Build-Depends: debhelper (>= 4.1.0), docbook-xsl, ldp-docbook-xsl (>= 0.0.20040321-0.1), xsltproc, dpkg-dev (>= 1.13.19), dblatex, rootstrap [i386 amd64]
+Build-Depends: debhelper (>= 4.1.16), docbook-xsl, ldp-docbook-xsl (>= 0.0.20040321-0.1), xsltproc, dpkg-dev (>= 1.13.19), dblatex, rootstrap [i386 amd64], debconf|debconf-2.0, po-debconf
 Standards-Version: 3.7.2
 Vcs-Git: git://git.debian.org/git/pbuilder/pbuilder.git
 Vcs-Browser: http://git.debian.org/?p=pbuilder/pbuilder.git
 
 Package: pbuilder
 Architecture: all
-Depends: cdebootstrap|debootstrap, wget, gcc, debianutils (>= 1.13.1), coreutils (>= 4.5.8-1)
+Depends: cdebootstrap|debootstrap, wget, gcc, debianutils (>= 1.13.1), coreutils (>= 4.5.8-1), ${misc:Depends}
 Recommends: fakeroot, sudo, devscripts, cowdancer
 Suggests: pbuilder-uml
 Description: personal package builder for Debian packages
diff --git a/debian/pbuilder.postinst b/debian/pbuilder.postinst
new file mode 100755
index 0000000..3619353
--- /dev/null
+++ b/debian/pbuilder.postinst
@@ -0,0 +1,99 @@
+#!/bin/sh
+# postinst script for pbuilder
+#
+# see: dh_installdeb(1)
+
+. /usr/share/debconf/confmodule
+
+set -e
+
+# summary of how this script can be called:
+#        * <postinst> `configure' <most-recently-configured-version>
+#        * <old-postinst> `abort-upgrade' <new version>
+#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
+#          <new-version>
+#        * <postinst> `abort-remove'
+#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
+#          <failed-install-package> <version> `removing'
+#          <conflicting-package> <version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+
+case "$1" in
+    configure)
+
+        CONFFILE=/etc/pbuilderrc
+
+        # if there is a custom file, then we shouldn't touch it
+        if [ -f "$CONFFILE" ] ; then
+            CURRENTMIRROR=$(grep -E "^MIRRORSITE=" "$CONFFILE" | sed 's#MIRRORSITE=##g')
+            if [ "$CURRENTMIRROR" ] ; then
+                db_input low pbuilder/rewrite || [ $? = 30 ]
+                db_go
+
+                db_get pbuilder/rewrite
+                [ "$RET" = "true" ] || exit 0
+            fi
+        else
+            # TODO: try creating a file only with the MIRRORSITE line
+            cp "/usr/share/doc/pbuilder/examples/pbuilderrc" "$CONFFILE"
+            MIRRORSITE=""
+            db_set pbuilder/mirrorsite ""
+        fi
+
+        db_get pbuilder/mirrorsite
+        [ "$RET" = "_" ] && db_set pbuilder/mirrorsite "" || true
+        db_input medium pbuilder/mirrorsite || [ $? = 30 ]
+        db_go
+
+        db_get pbuilder/mirrorsite
+        MIRRORSITE="$RET"
+
+        # the "_" alternative is just a safety net,
+        # but that should really never happen
+        if [ -z "$MIRRORSITE" ] || [ "$MIRRORSITE" = "_" ] ; then
+            TMPSRC=`mktemp`
+            SRCLISTDIR=/etc/apt/sources.list.d
+            [ -f /etc/apt/sources.list ] && cat /etc/apt/sources.list > "$TMPSRC" || true
+            [ -f $SRCLISTDIR/*.sources.list ] && cat $SRCLISTDIR/*.sources.list >> "$TMPSRC" || true
+            MIRRORSITE=$(grep -E '^deb ' "$TMPSRC" | head -n 1 | awk '{print $2;}')
+            rm -f "$TMPSRC"
+            while [ -z "$MIRRORSITE" ] ; do
+                db_input high pbuilder/nomirror || true
+                db_input high pbuilder/mirrorsite && RETCODE=$? || RETCODE=$?
+                db_go
+
+                # if the interface is non-interactive, still set a valid mirror
+                if [ $RETCODE = 30 ] ; then
+                    MIRRORSITE="http://ftp.debian.org/debian";
+                else
+                    db_get pbuilder/mirrorsite
+                    MIRRORSITE="$RET"
+                fi
+            done
+            db_set pbuilder/mirrorsite "$MIRRORSITE"
+        fi
+
+        TMPFILE=`mktemp`
+        cat "$CONFFILE" | sed "s#MIRRORSITE=.*\$#MIRRORSITE=$MIRRORSITE#" > "$TMPFILE" && mv "$TMPFILE" "$CONFFILE"
+
+    ;;
+
+    abort-upgrade|abort-remove|abort-deconfigure)
+    ;;
+
+    *)
+        echo "postinst called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
+
+
diff --git a/debian/pbuilder.templates b/debian/pbuilder.templates
new file mode 100644
index 0000000..1b8f0ed
--- /dev/null
+++ b/debian/pbuilder.templates
@@ -0,0 +1,26 @@
+Template: pbuilder/mirrorsite
+Type: string
+Default: _
+_Description: Default mirror site:
+ Please enter the default mirror you want to be used by pbuilder.
+ .
+ If you leave this field blank, there will be one attempt to autodetect
+ this information. If this attempt fails, you will be prompted again
+ to insert some valid mirror information.
+ .
+ Here is a valid mirror example: http://ftp.debian.org/debian
+
+Template: pbuilder/nomirror
+Type: error
+_Description: Default mirror not found
+ Mirror information detection failed and the user provided no mirror information.
+ .
+ Please enter valid mirror information.
+
+Template: pbuilder/rewrite
+Type: boolean
+Default: false
+_Description: Overwrite current configuration?
+ Your system seems to have already pbuilder configuration.
+ Proceeding might discard or overwrite part or the entire
+ pbuilder's configuration.
diff --git a/debian/po/POTFILES.in b/debian/po/POTFILES.in
new file mode 100644
index 0000000..86d57fa
--- /dev/null
+++ b/debian/po/POTFILES.in
@@ -0,0 +1 @@
+[type: gettext/rfc822deb] pbuilder.templates
diff --git a/debian/po/ro.po b/debian/po/ro.po
new file mode 100644
index 0000000..bb52e2b
--- /dev/null
+++ b/debian/po/ro.po
@@ -0,0 +1,84 @@
+# translation of ro.po to Romanian
+# Romanian translations for PACKAGE package
+# Traducerea în limba română pentru pachetul PACKAGE.
+# Copyright (C) 2007 THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+#
+# Eddy Petrisor <[EMAIL PROTECTED]>, 2007.
+# Eddy Petrișor <[EMAIL PROTECTED]>, 2007, 2008.
+msgid ""
+msgstr ""
+"Project-Id-Version: ro\n"
+"Report-Msgid-Bugs-To: [EMAIL PROTECTED]"
+"POT-Creation-Date: 2008-03-02 08:23+0200\n"
+"PO-Revision-Date: 2008-03-02 08:50+0200\n"
+"Last-Translator: Eddy Petrișor <[EMAIL PROTECTED]>\n"
+"Language-Team: Romanian <[EMAIL PROTECTED]>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms:  nplurals=3; plural=n==1 ? 0 : (n==0 || (n%100 > 0 && n%100 < 20)) ? 1 : 2;\n"
+"X-Generator: KBabel 1.11.4\n"
+
+#. Type: string
+#. Description
+#: ../pbuilder.templates:1001
+msgid "Default mirror site:"
+msgstr "Saitul oglindă implicit:"
+
+#. Type: string
+#. Description
+#: ../pbuilder.templates:1001
+msgid "Please enter the default mirror you want to be used by pbuilder."
+msgstr "Introduceți saitul oglindă implicit pe care doriți să-l folosească pbuilder."
+
+#. Type: string
+#. Description
+#: ../pbuilder.templates:1001
+msgid ""
+"If you leave this field blank, there will be one attempt to autodetect this "
+"information. If this attempt fails, you will be prompted again to insert "
+"some valid mirror information."
+msgstr "Dacă lăsați liber acest câmp, se va încerca o singură dată să se detecteze automat această informație. Dacă această încercare eșuează, vi se va cere, din nou să introduceți niște informații valide despre saitul-oglindă."
+
+#. Type: string
+#. Description
+#: ../pbuilder.templates:1001
+msgid "Here is a valid mirror example: http://ftp.debian.org/debian";
+msgstr "Iată un exemplu valid de sait-oglindă: http://ftp.ro.debian.org/debian";
+
+#. Type: error
+#. Description
+#: ../pbuilder.templates:2001
+#| msgid "Default mirror site:"
+msgid "Default mirror not found"
+msgstr "Saitul oglindă implicit nu a fost găsit"
+
+#. Type: error
+#. Description
+#: ../pbuilder.templates:2001
+msgid ""
+"Mirror information detection failed and the user provided no mirror "
+"information."
+msgstr "Detectarea informațiilor despre saitul-oglindă a eșuat și utilizatorul nu a furnizat nici o informație despre saitul-oglindă."
+
+#. Type: error
+#. Description
+#: ../pbuilder.templates:2001
+msgid "Please enter valid mirror information."
+msgstr "Introduceți informație validă referitoare la saituri ."
+
+#. Type: boolean
+#. Description
+#: ../pbuilder.templates:3001
+msgid "Overwrite current configuration?"
+msgstr "Se suprascrie actualul fișier de configurație?"
+
+#. Type: boolean
+#. Description
+#: ../pbuilder.templates:3001
+msgid ""
+"Your system seems to have already pbuilder configuration. Proceeding might "
+"discard or overwrite part or the entire pbuilder's configuration."
+msgstr "Sistemul pare să aibă deja o configurație pentru pbuilder. Continuarea cu această acțiune ar putea duce la ștergerea sau suprascrierea parțială sau totală a fișierului de configurare aparținând lui pbuilder."
+
diff --git a/debian/po/templates.pot b/debian/po/templates.pot
new file mode 100644
index 0000000..ab08b04
--- /dev/null
+++ b/debian/po/templates.pot
@@ -0,0 +1,78 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <[EMAIL PROTECTED]>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: [EMAIL PROTECTED]"
+"POT-Creation-Date: 2008-03-02 08:23+0200\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <[EMAIL PROTECTED]>\n"
+"Language-Team: LANGUAGE <[EMAIL PROTECTED]>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#. Type: string
+#. Description
+#: ../pbuilder.templates:1001
+msgid "Default mirror site:"
+msgstr ""
+
+#. Type: string
+#. Description
+#: ../pbuilder.templates:1001
+msgid "Please enter the default mirror you want to be used by pbuilder."
+msgstr ""
+
+#. Type: string
+#. Description
+#: ../pbuilder.templates:1001
+msgid ""
+"If you leave this field blank, there will be one attempt to autodetect this "
+"information. If this attempt fails, you will be prompted again to insert "
+"some valid mirror information."
+msgstr ""
+
+#. Type: string
+#. Description
+#: ../pbuilder.templates:1001
+msgid "Here is a valid mirror example: http://ftp.debian.org/debian";
+msgstr ""
+
+#. Type: error
+#. Description
+#: ../pbuilder.templates:2001
+msgid "Default mirror not found"
+msgstr ""
+
+#. Type: error
+#. Description
+#: ../pbuilder.templates:2001
+msgid ""
+"Mirror information detection failed and the user provided no mirror "
+"information."
+msgstr ""
+
+#. Type: error
+#. Description
+#: ../pbuilder.templates:2001
+msgid "Please enter valid mirror information."
+msgstr ""
+
+#. Type: boolean
+#. Description
+#: ../pbuilder.templates:3001
+msgid "Overwrite current configuration?"
+msgstr ""
+
+#. Type: boolean
+#. Description
+#: ../pbuilder.templates:3001
+msgid ""
+"Your system seems to have already pbuilder configuration. Proceeding might "
+"discard or overwrite part or the entire pbuilder's configuration."
+msgstr ""
diff --git a/debian/rules b/debian/rules
index d69391d..40d082e 100755
--- a/debian/rules
+++ b/debian/rules
@@ -49,6 +49,7 @@ binary-indep: build install
 	dh_installdocs -i
 	dh_installman pbuilder.8 pbuilderrc.5 pdebuild.1 debuild-pbuilder.1 
 	dh_installchangelogs -i
+	dh_installdebconf
 	dh_link -i
 	dh_compress -i -X.pdf
 	dh_fixperms -i
diff --git a/pbuilderrc b/pbuilderrc
index f97456e..31cdb53 100755
--- a/pbuilderrc
+++ b/pbuilderrc
@@ -8,7 +8,7 @@ BASETGZ=/var/cache/pbuilder/base.tgz
 #EXTRAPACKAGES=gcc3.0-athlon-builder
 #export DEBIAN_BUILDARCH=athlon
 BUILDPLACE=/var/cache/pbuilder/build/
-MIRRORSITE=http://ftp.jp.debian.org/debian
+MIRRORSITE=_
 #OTHERMIRROR="deb http://www.home.com/updates/ ./"
 #export http_proxy=http://your-proxy:8080/
 USEPROC=yes

Reply via email to