Hi,

Here are my latest patches to do --mode option.

This starts at debian/0.181.

I have not merged with current master for easy review.

Osamu
>From ca64c56460c43be5ef89a585b11319677456f012 Mon Sep 17 00:00:00 2001
From: Osamu Aoki <[EMAIL PROTECTED]>
Date: Tue, 29 Jul 2008 23:36:19 +0900
Subject: [PATCH] added support for mode option

These modifications added support for --mode option and documented them.
Backward compatibility is maintained if --mode option is not used.

 moved: pbuilder-loadconfig --> pbuilder-loadconfig-new
---
 README.mode                 |   58 ++++++++++++++++++++++++
 pbuilder                    |   11 +++++
 pbuilder-loadconfig         |   18 ++++----
 pbuilder-loadconfig-classic |   26 +++++++++++
 pbuilder-loadconfig-new     |   37 +++++++++++++++
 pbuilder-modules            |  105 +++++++++++++++++++++++++++++++++++++++---
 pbuilder.8                  |   17 +++++---
 pbuilderrc                  |   21 ++++++---
 8 files changed, 264 insertions(+), 29 deletions(-)
 create mode 100644 README.mode
 create mode 100644 pbuilder-loadconfig-classic
 create mode 100644 pbuilder-loadconfig-new

diff --git a/README.mode b/README.mode
new file mode 100644
index 0000000..5cc2179
--- /dev/null
+++ b/README.mode
@@ -0,0 +1,58 @@
+Note on --mode option
+
+Basic precaution:
+If you do not use --mode option, pbuilder acts the same way as before including
+some ideosyncracies it has.  If you made modification to the /etc/pbuilderrc
+beyond what debhelper generated entry and do not provide
+/etc/pbuilder/$PBMODEOPTION/pbuilderrc, this --mode option may not function as
+expected.  (~/.pbuilderrc has no effects.)
+
+The directory contents in mode/$PBMODEOPTION in source tree are installed to
+/usr/share/pbuilder/$PBMODEOPTION/apt/ and copied to chroot as /etc/apt/* when
+using --mode option.
+
+
+Rationale:
+Initial implimentation of pbuilder tries to handle special case scenarios via
+conditionals.  This is good when you have only "experimental" to be adressed.
+But when we need to deal with "...-backports", "ubunts archives", "security
+updates for testing", "volatile", "volatile-sloppy", ... this methosd is not
+simple enough.  We need to separate logic and data.  Logic should be simple.
+Data can be complicated when addressing complex problems.  Considering
+inhomogineos nature of complexity to address under pbuilder, data is the way to
+go for addressing pbuilder usage scenarios.  
+
+Thus, I propose --mode option :) as in this package.
+
+Details:
+Please note this package is meant for testing and unstable.  Once stable is
+released, codename to suite name correspondence will be wrong until first
+stable updates happens or I care to place special update verion for testing
+just before release.  (now both codenames for testing and stable backports
+point to stable backports as work around)
+
+I use "suite name" per archive Release file for Debian.
+I use "codename"   per archive Release file for Ubuntu.
+
+If you are on Debian system, you need to install ubuntu-keyring package from
+ubuntu (use dpkg -i ...) to handle Ubuntu archive. cbootstrap is compatible.
+
+Unlike classic pbuilder, --mode option always upate apt-line (or entire
+/etc/apt/*) contets overwriting with
+ * /usr/share/pbuilder/<modename>/apt/*, 
+ * /etc/pbuilder/<modename>/apt/*,
+ * ~/.pbuilder/<modename>/apt/*,
+in this sequence.  If no <modename> configuration found, it provides
+sources.list based on default.
+
+As for pbuilderrc files under --mode option
+ * /usr/share/pbuilder/pbuilderrc,  (common for all --mode)
+ * /etc/pbuilder/<modename>/pbuilderrc, (if it does not exist, /etc/pbuilder/pbuilderrc)
+ * ~/.pbuilder/<modename>/pbuilderrc,
+are read in this sequence.  The <modename> directory based configurations ovride defaults.
+
+As for hook, no special support for --mode exists.  There is E11backportkey hookscript
+in examples which can be used to import backport key to chroot. 
+
+Osamu Aoki, Mon Jun 30 14:05:30 UTC 2008
+
diff --git a/pbuilder b/pbuilder
index ed35fb4..cb700d3 100755
--- a/pbuilder
+++ b/pbuilder
@@ -20,6 +20,17 @@
 
 set -e 
 
+# MODEOPTION: Osamu Aoki <[EMAIL PROTECTED]> 2008 Jul 29
+# export pbuilder operation mode specified by "--mode" option value.
+# export "" if not specified.
+if [ "$1" = "-m" ] || [ "$1" = "--mode" ] || [ "$1" = "mode" ]; then
+    PBMODEOPTION="$2"
+    shift 2
+else
+    PBMODEOPTION=""
+fi
+export PBMODEOPTION
+
 # export this so that programs know which command line
 # operation is currently done
 export PBCURRENTCOMMANDLINEOPERATION="$1"
diff --git a/pbuilder-loadconfig b/pbuilder-loadconfig
index 8367143..835662b 100644
--- a/pbuilder-loadconfig
+++ b/pbuilder-loadconfig
@@ -1,7 +1,9 @@
 #! /bin/bash 
 # this is sourced from pbuilder packages to process the optional parameters.
-#   pbuilder -- personal Debian package builder
-#   Copyright (C) 2001,2002,2006-2007 Junichi Uekawa
+# pbuilder-loadconfig switched between *-classic and *-new based on mode 
+# option existance.
+# 
+#   Copyright (C) 2008 Osamu Aoki
 #
 #   This program is free software; you can redistribute it and/or modify
 #   it under the terms of the GNU General Public License as published by
@@ -17,10 +19,8 @@
 #   along with this program; if not, write to the Free Software
 #   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 
-for RCFILE in /usr/share/pbuilder/pbuilderrc /etc/pbuilderrc ${HOME}/.pbuilderrc; do
-    if [ -f "$RCFILE" ]; then 
-	. "$RCFILE"
-    else
-	echo "W: $RCFILE does not exist" >&2
-    fi
-done
+if [ -z "${PBMODEOPTION}" ]; then 
+    . /usr/lib/pbuilder/pbuilder-loadconfig-classic
+else
+    . /usr/lib/pbuilder/pbuilder-loadconfig-new
+fi
diff --git a/pbuilder-loadconfig-classic b/pbuilder-loadconfig-classic
new file mode 100644
index 0000000..8367143
--- /dev/null
+++ b/pbuilder-loadconfig-classic
@@ -0,0 +1,26 @@
+#! /bin/bash 
+# this is sourced from pbuilder packages to process the optional parameters.
+#   pbuilder -- personal Debian package builder
+#   Copyright (C) 2001,2002,2006-2007 Junichi Uekawa
+#
+#   This program is free software; you can redistribute it and/or modify
+#   it under the terms of the GNU General Public License as published by
+#   the Free Software Foundation; either version 2 of the License, or
+#   (at your option) any later version.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#   GNU General Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License
+#   along with this program; if not, write to the Free Software
+#   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+
+for RCFILE in /usr/share/pbuilder/pbuilderrc /etc/pbuilderrc ${HOME}/.pbuilderrc; do
+    if [ -f "$RCFILE" ]; then 
+	. "$RCFILE"
+    else
+	echo "W: $RCFILE does not exist" >&2
+    fi
+done
diff --git a/pbuilder-loadconfig-new b/pbuilder-loadconfig-new
new file mode 100644
index 0000000..81ff8f5
--- /dev/null
+++ b/pbuilder-loadconfig-new
@@ -0,0 +1,37 @@
+#! /bin/bash 
+# this is sourced from pbuilder packages to process the optional parameters.
+# this loads apt file from directory specified by --mode
+#   pbuilder -- personal Debian package builder
+#   Copyright (C) 2001,2002,2006-2007 Junichi Uekawa
+#   Copyright (C) 2008 Osamu Aoki
+#
+#   This program is free software; you can redistribute it and/or modify
+#   it under the terms of the GNU General Public License as published by
+#   the Free Software Foundation; either version 2 of the License, or
+#   (at your option) any later version.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#   GNU General Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License
+#   along with this program; if not, write to the Free Software
+#   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+
+# Set pbuiler with pbuilderrc file in consistent location.
+for RCFILE in "/usr/share/pbuilder/pbuilderrc" "/etc/pbuilder/${PBMODEOPTION}/pbuilderrc" "${HOME}/.pbuilder/${PBMODEOPTION}/pbuilderrc" ; do
+    if [ -f "$RCFILE" ]; then 
+	. "$RCFILE"
+	echo "I: Loading  $RCFILE"
+    else
+	echo "I: Skipping $RCFILE (not found)"
+    	if [ "/etc/pbuilder/${PBMODEOPTION}/pbuilderrc" = "${RCFILE}" ] && \
+            [ -n "${PBMODEOPTION}" ] && \
+            [ -f "/etc/pbuilder/pbuilderrc" ]; then
+            . "/etc/pbuilder/pbuilderrc"
+	    echo "I: Loading  /etc/pbuilder/pbuilderrc"
+        fi
+    fi
+done
+
diff --git a/pbuilder-modules b/pbuilder-modules
index 26626f9..13bd658 100644
--- a/pbuilder-modules
+++ b/pbuilder-modules
@@ -24,27 +24,27 @@ pbuilder - a personal builder
 Copyright 2001-2007 Junichi Uekawa
 Distributed under GNU Public License version 2 or later
 
-pbuilder [operation] [pbuilder-options]
+pbuilder [mode] [operation] [pbuilder-options]
 pdebuild [pdebuild-options] -- [pbuilder-options]
 
 command lines:
-pbuilder --create [--basetgz base.tgz-path] [--distribution etch|lenny|sid|experimental]
+pbuilder [--mode modeop] --create [--basetgz base.tgz-path] [--distribution etch|lenny|sid|experimental]
   Creates a base.tgz
 
-pbuilder --update [--basetgz base.tgz-path] [--distribution etch|lenny|sid|experimental]
+pbuilder [--mode modeop] --update [--basetgz base.tgz-path] [--distribution etch|lenny|sid|experimental]
   Updates a base.tgz
 
-pbuilder --build [--basetgz base.tgz-path] pbuilder_2.2.0-1.dsc
+pbuilder [--mode modeop] --build [--basetgz base.tgz-path] pbuilder_2.2.0-1.dsc
   Builds using the base.tgz. Requires a .dsc filename
 
-pbuilder --clean
+pbuilder [--mode modeop] --clean
   Cleans the temporal build directory.
 
-pbuilder --login
-pbuilder --execute -- [command] [command-options]
+pbuilder [--mode modeop] --login
+pbuilder [--mode modeop] --execute -- [command] [command-options]
   Logs in to the build environment and execute command.
 
-pbuilder --dumpconfig
+pbuilder [--mode modeop] --dumpconfig
   Dumps configuration information to stdout for debugging.
 
 pbuilder-options:
@@ -311,6 +311,13 @@ function saveaptcache_umountproc_cleanbuildplace () {
 }
 
 function installaptlines (){
+    if [ -z "${PBMODEOPTION}" ]; then
+        installaptlines_classic
+    else
+        installaptlines_new
+    fi
+}
+function installaptlines_classic (){
     echo "  -> Installing apt-lines"
     rm -f "$BUILDPLACE"/etc/apt/sources.list
     if [ -z "$DISTRIBUTION" ]; then
@@ -355,6 +362,88 @@ EOF
     fi
 }
 
+function installaptlines_new (){
+    echo "  -> Installing apt-lines and other apt-directory contents"
+    # Set decent defaults
+    if [ -z "$MIRRORSITE" ] ; then
+        MIRRORSITE="http://ftp.us.debian.org/debian/";
+    fi
+    if [ -n "$OTHERMIRROR" ]; then 
+    	# /usr/share/pbuilder/${PBMODEOPTION}/apt/sources.list /etc/pbuilder/${PBMODEOPTION}/apt/sources.list and ~/.pbuilder/${PBMODEOPTION}/apt/sources.list on host are used to set the equivalent.
+	echo "The variable OTHERMIRROR  has no effect, when using --mode" >&2
+	echo "    $OTHERMIRROR" >&2
+    fi
+    if [ -z "$DISTRIBUTION" ]; then
+        # It should not come here : --mode "" goes -classic
+	echo "Distribution not specified, please specify" >&2
+	exit 1
+    fi
+    if [ -n "$EXPERIMENTAL" ]; then
+    	# This should not happen
+	echo "The variable EXPERIMENTAL=$EXPERIMENTAL should not happen, when using --mode" >&2
+	exit 1
+    fi
+    if [ -z "$COMPONENTS" ] ; then
+	COMPONENTS="main"
+    fi
+    if [ -n "$APTCONFDIR" ]; then 
+    	# /usr/share/pbuilder/${PBMODEOPTION}/apt/ /etc/pbuilder/${PBMODEOPTION}/apt/ and ~/.pbuilder/${PBMODEOPTION}/apt/ on host are used.
+	echo "The variable APTCONFDIR=$APTCONFDIR has no effect, when using --mode" >&2
+    fi
+    # force to create new /etc/apt/sources.list
+    rm -f "$BUILDPLACE"/etc/apt/sources.list
+    if [ ! -d "$BUILDPLACE"/etc/apt/apt.conf.d ]; then
+	echo "  -> Create /etc/apt/apt.conf.d/ inside chroot"
+	mkdir -p "$BUILDPLACE"/etc/apt/apt.conf.d
+    fi
+    # Copy /etc/apt contents into cheroot environment with files matching $PBMODEOPTION (--mode value).
+    for ETCAPT in /usr/share/pbuilder/${PBMODEOPTION}/apt /etc/pbuilder/${PBMODEOPTION}/apt ${HOME}/.pbuilder/${PBMODEOPTION}/apt ; do
+        if [ -d "$ETCAPT" ]; then
+	    # This not only updates sources.list, preferences within chroot
+	    # but copies all files in the configuration directories into chroot.
+	    # This opens door to use file:// in sources.list
+	    echo "I: Loading  $ETCAPT"
+	    cp -vfdR  $ETCAPT/* "$BUILDPLACE"/etc/apt/
+        else
+	    echo "I: Skipping $ETCAPT (not found)"
+        fi
+    done
+
+    # If all skipped, provide decent default for sources.list:
+    if [ ! -f "$BUILDPLACE"/etc/apt/sources.list ]; then
+	cat > "$BUILDPLACE"/etc/apt/sources.list << EOF
+deb @@@MIRRORSITE@@@ @@@DISTRIBUTION@@@ @@@COMPONENTS@@@
+EOF
+    fi
+    mv -f "$BUILDPLACE"/etc/apt/sources.list "$BUILDPLACE"/etc/apt/sources.list.tmp
+    sed -e "s#@@@MIRRORSITE@@@#$MIRRORSITE#" -e "s#@@@DISTRIBUTION@@@#$DISTRIBUTION#" -e "s#@@@COMPONENTS@@@#$COMPONENTS#" \
+        < "$BUILDPLACE"/etc/apt/sources.list.tmp    > "$BUILDPLACE"/etc/apt/sources.list
+    rm -f "$BUILDPLACE"/etc/apt/sources.list.tmp
+
+    # always need this for not using Recommends (preference is used for experimental)
+    if [ -f "$BUILDPLACE"/etc/apt/apt.conf.d/15pbuilder ]; then
+    # configure /etc/apt.conf.d/15pbuilder if missing
+    cat > "$BUILDPLACE"/etc/apt/apt.conf.d/15pbuilder <<EOF
+APT::Install-Recommends "false";
+EOF
+    fi
+    if [ -f "$BUILDPLACE"/etc/apt/sources.list ]; then
+    	echo "I: ==== Using /etc/apt/sources.list          ===="
+    	cat "$BUILDPLACE"/etc/apt/sources.list
+    else
+    	echo "I: ==== Missing /etc/apt/sources.list        ===="
+    fi
+    if [ -f "$BUILDPLACE"/etc/apt/preferences ]; then
+        echo "I: ==== Using /etc/apt/preferences           ===="
+        cat "$BUILDPLACE"/etc/apt/preferences
+    else
+    	echo "I: ==== Missing /etc/apt/preferences         ===="
+    fi
+    #echo "I: ==== Using /etc/apt/apt.conf.d/15pbuilder ===="
+    #cat "$BUILDPLACE"/etc/apt/apt.conf.d/15pbuilder
+    echo "I: =============================================="
+}
+
 function copy_local_configuration () {
     echo " -> copying local configuration"
     for a in hosts hostname resolv.conf; do 
diff --git a/pbuilder.8 b/pbuilder.8
index 3a36bcf..3b3d825 100644
--- a/pbuilder.8
+++ b/pbuilder.8
@@ -2,17 +2,17 @@
 .SH NAME
 pbuilder \- personal package builder
 .SH SYNOPSIS
-.BI "pbuilder --create [" "options" "]"
+.BI "pbuilder [--mode opmode] --create [" "options" "]"
 .PP
-.BI "pbuilder --update [" "options" "]"
+.BI "pbuilder [--mode opmode] --update [" "options" "]"
 .PP
-.BI "pbuilder --build [" "options" "] " ".dsc-file"
+.BI "pbuilder [--mode opmode] --build [" "options" "] " ".dsc-file"
 .PP
-.BI "pbuilder --execute [" "options" "] -- " "script [" "script options" "]"
+.BI "pbuilder [--mode opmode] --execute [" "options" "] -- " "script [" "script options" "]"
 .PP
-.BI "pbuilder --clean"
+.BI "pbuilder [--mode opmode] --clean"
 .PP
-.BI "pbuilder --login [" "options" "]"
+.BI "pbuilder [--mode opmode] --login [" "options" "]"
 .SH "DESCRIPTION"
 Front end program to the 
 .B "pbuilder"
@@ -22,6 +22,11 @@ and building Debian package in the chroot environment.
 .SH "COMMANDS"
 
 .TP
+.B "--mode opmode" | "-m opmode"
+Swiches pbuilder configuration to use a different set of configuration files specified by
+.B "opmode" .
+
+.TP
 .B "--create"
 Creates a 
 .B "base.tgz" 
diff --git a/pbuilderrc b/pbuilderrc
index 1445acb..d2ea3a1 100755
--- a/pbuilderrc
+++ b/pbuilderrc
@@ -1,30 +1,39 @@
 # this is your configuration file for pbuilder.
 # the file in /usr/share/pbuilder/pbuilderrc is the default template.
-# /etc/pbuilderrc is the one meant for editing.
+# /etc/pbuilderrc is the one meant for editing. (classic)
+#
+#  /etc/pbuilder/${PBMODEOPTION}/pbuilderrc
+#  ~/.pbuilder/${PBMODEOPTION}/pbuilderrc
+#   are the one meant for editing with --mode option.
 #
 # read pbuilderrc.5 document for notes on specific options.
 
-BASETGZ=/var/cache/pbuilder/base.tgz
+BASETGZ=/var/cache/pbuilder/${PBMODEOPTION}/base.tgz
 #EXTRAPACKAGES=gcc3.0-athlon-builder
 #export DEBIAN_BUILDARCH=athlon
-BUILDPLACE=/var/cache/pbuilder/build/
+BUILDPLACE=/var/cache/pbuilder/${PBMODEOPTION}/build/
+# This is used only for classic and --mode for Debian sites
+# it could be overidden by first line of <mode>/sources.list
 MIRRORSITE=http://cdn.debian.net/debian
+
+# Do not set OTHERMIRROR with --mode
 #OTHERMIRROR="deb http://www.home.com/updates/ ./"
+
 #export http_proxy=http://your-proxy:8080/
 USEPROC=yes
 USEDEVPTS=yes
 USEDEVFS=no
-BUILDRESULT=/var/cache/pbuilder/result/
+BUILDRESULT=/var/cache/pbuilder/${PBMODEOPTION}/result/
 
 # specifying the distribution forces the distribution on "pbuilder update"
 #DISTRIBUTION=lenny
 # specifying the components of the distribution
 COMPONENTS="main"
 #specify the cache for APT 
-APTCACHE="/var/cache/pbuilder/aptcache/"
+APTCACHE="/var/cache/pbuilder/${PBMODEOPTION}/aptcache/"
 APTCACHEHARDLINK="yes"
 REMOVEPACKAGES="lilo"
-#HOOKDIR="/usr/lib/pbuilder/hooks"
+#HOOKDIR="/usr/lib/pbuilder/${PBMODEOPTION}/hooks"
 HOOKDIR=""
 
 # make debconf not interact with user
-- 
1.5.6.3

From 536e0f20259df33b23a1cd2c59121b09d84144ff Mon Sep 17 00:00:00 2001
From: Osamu Aoki <[EMAIL PROTECTED]>
Date: Tue, 29 Jul 2008 23:42:28 +0900
Subject: [PATCH] updated build scripts

  RELEASE_LIST: release name definitions
  moved: debian/pbuilder.links --> debian/pbuilder.links.in
---
 Makefile                 |   20 ++++++++++++++++++--
 RELEASE_LIST             |    4 ++++
 debian/changelog         |   10 ++++++++++
 debian/docs              |    1 +
 debian/pbuilder.links    |    1 -
 debian/pbuilder.links.in |   10 ++++++++++
 debian/rules             |    7 ++++++-
 7 files changed, 49 insertions(+), 4 deletions(-)
 create mode 100644 RELEASE_LIST
 delete mode 100644 debian/pbuilder.links
 create mode 100644 debian/pbuilder.links.in

diff --git a/Makefile b/Makefile
index b5be113..9b2ecdb 100644
--- a/Makefile
+++ b/Makefile
@@ -12,6 +12,8 @@ SHELLCODES=pbuilder-buildpackage \
 	pbuilder-uml-checkparams \
 	pbuilder-createbuildenv \
 	pbuilder-loadconfig \
+	pbuilder-loadconfig-classic \
+	pbuilder-loadconfig-new \
 	pbuilder-modules \
 	pbuilder-runhooks \
 	pbuilder-satisfydepends-classic \
@@ -28,6 +30,15 @@ SHELLCODES=pbuilder-buildpackage \
 	pdebuild-user-mode-linux \
 	pdebuild-internal
 
+#
+# To add new supported mode, add it here and place them under apt/ directory, so they will be installed.
+#
+SUPPORTEDMODE=$(subst mode/, , $(wildcard mode/*))
+#
+# Conversion rule
+#
+include RELEASE_LIST
+
 check:
 	set -e;
 	for A in $(SHELLCODES); do \
@@ -56,6 +67,8 @@ install:
 	$(INSTALL_DIRECTORY) $(DESTDIR)/usr/bin
 	$(INSTALL_DIRECTORY) $(DESTDIR)/usr/lib/pbuilder
 	$(INSTALL_DIRECTORY) $(DESTDIR)/usr/share/pbuilder
+	for x in $(SUPPORTEDMODE); do $(INSTALL_DIRECTORY) $(DESTDIR)/usr/share/pbuilder/$$x ; done
+	for x in $(SUPPORTEDMODE); do $(INSTALL_DIRECTORY) $(DESTDIR)/usr/share/pbuilder/$$x/apt ; done
 	$(INSTALL_DIRECTORY) $(DESTDIR)/usr/share/doc/pbuilder/examples
 	$(INSTALL_DIRECTORY) $(DESTDIR)/usr/share/doc/pbuilder/examples/rebuild
 	$(INSTALL_DIRECTORY) $(DESTDIR)/usr/share/doc/pbuilder/examples/pbuilder-test
@@ -68,6 +81,8 @@ install:
 	$(INSTALL_EXECUTABLE) pbuilder-createbuildenv $(DESTDIR)/usr/lib/pbuilder/
 	$(INSTALL_EXECUTABLE) pbuilder-updatebuildenv $(DESTDIR)/usr/lib/pbuilder/
 	$(INSTALL_EXECUTABLE) pbuilder-loadconfig $(DESTDIR)/usr/lib/pbuilder/
+	$(INSTALL_EXECUTABLE) pbuilder-loadconfig-classic $(DESTDIR)/usr/lib/pbuilder/
+	$(INSTALL_EXECUTABLE) pbuilder-loadconfig-new $(DESTDIR)/usr/lib/pbuilder/
 	$(INSTALL_EXECUTABLE) pbuilder-runhooks $(DESTDIR)/usr/lib/pbuilder/
 	$(INSTALL_EXECUTABLE) pbuilder-checkparams $(DESTDIR)/usr/lib/pbuilder/
 	$(INSTALL_EXECUTABLE) pdebuild-checkparams $(DESTDIR)/usr/lib/pbuilder/
@@ -79,8 +94,7 @@ install:
 	$(INSTALL_EXECUTABLE) pbuilder-user-mode-linux $(DESTDIR)/usr/bin
 	$(INSTALL_EXECUTABLE) pdebuild-user-mode-linux $(DESTDIR)/usr/bin
 	$(INSTALL_EXECUTABLE) debuild-pbuilder $(DESTDIR)/usr/bin
-
-	#install aptitude as the default satisfydepends 
+	#install aptitude as the default satisfydepends
 	$(INSTALL_EXECUTABLE) pbuilder-satisfydepends-aptitude $(DESTDIR)/usr/lib/pbuilder/pbuilder-satisfydepends
 	$(INSTALL_EXECUTABLE) pbuilder-satisfydepends-classic $(DESTDIR)/usr/lib/pbuilder/
 	$(INSTALL_EXECUTABLE) pbuilder-satisfydepends-gdebi $(DESTDIR)/usr/lib/pbuilder/
@@ -90,6 +104,8 @@ install:
 	$(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
+	for x in $(SUPPORTEDMODE); do sed $(CONV) <mode/$$x/sources.list >$(DESTDIR)/usr/share/pbuilder/$$x/apt/sources.list ; done
+	for x in $(SUPPORTEDMODE); do sed $(CONV) <mode/$$x/preferences >$(DESTDIR)/usr/share/pbuilder/$$x/apt/preferences ; done
 	$(INSTALL_FILE) bash_completion.pbuilder $(DESTDIR)/etc/bash_completion.d/pbuilder
 	$(INSTALL_FILE) pbuilderrc $(DESTDIR)/usr/share/pbuilder
 	$(INSTALL_FILE) pbuilder-uml.conf $(DESTDIR)/etc/pbuilder
diff --git a/RELEASE_LIST b/RELEASE_LIST
new file mode 100644
index 0000000..e789669
--- /dev/null
+++ b/RELEASE_LIST
@@ -0,0 +1,4 @@
+#
+# Conversion rule
+#
+CONV=-e "s/@@@oldstable@@@/sarge/g" -e "s/@@@stable@@@/etch/g" -e "s/@@@testing@@@/lenny/g" -e "s/@@@unstable@@@/sid/g"
diff --git a/debian/changelog b/debian/changelog
index f7aa97f..2891aa8 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,13 @@
+pbuilder (0.181+osamu1) UNRELEASED; urgency=low
+
+  * Pbuilder to configure itself based on the target distribution via
+    --mode option.  (closes: #398404)
+  * Good support for Ubuntu archive with --mode option.
+  * Alternative default mirror value from sources.list under --mode 
+    option.
+
+ -- Osamu Aoki <[EMAIL PROTECTED]>  Thu, 26 Jun 2008 01:56:50 +0900
+
 pbuilder (0.181) unstable; urgency=low
 
   [ Esko Arajärvi ]
diff --git a/debian/docs b/debian/docs
index 9eb0398..368d7cd 100644
--- a/debian/docs
+++ b/debian/docs
@@ -1,4 +1,5 @@
 README
+README.mode
 AUTHORS
 THANKS
 debian/TODO
diff --git a/debian/pbuilder.links b/debian/pbuilder.links
deleted file mode 100644
index 59ac2d4..0000000
--- a/debian/pbuilder.links
+++ /dev/null
@@ -1 +0,0 @@
-/etc/pbuilderrc /etc/pbuilder/pbuilderrc
\ No newline at end of file
diff --git a/debian/pbuilder.links.in b/debian/pbuilder.links.in
new file mode 100644
index 0000000..b33f385
--- /dev/null
+++ b/debian/pbuilder.links.in
@@ -0,0 +1,10 @@
+/etc/pbuilderrc /etc/pbuilder/pbuilderrc
+/usr/share/pbuilder/unstable/apt /usr/share/pbuilder/sid/apt
+/usr/share/pbuilder/testing/apt /usr/share/pbuilder/@@@testing@@@/apt
+/usr/share/pbuilder/testing-proposed-updates/apt /usr/share/pbuilder/@@@testing@@@-proposed-updates/apt
+/usr/share/pbuilder/stable-backports/apt /usr/share/pbuilder/@@@testing@@@-backports/apt
+/usr/share/pbuilder/stable/apt /usr/share/pbuilder/@@@stable@@@/apt
+/usr/share/pbuilder/stable-backports/apt /usr/share/pbuilder/@@@stable@@@-backports/apt
+/usr/share/pbuilder/stable-proposed-updates/apt /usr/share/pbuilder/@@@stable@@@-proposed-updates/apt
+/usr/share/pbuilder/oldstable-proposed-updates/apt /usr/share/pbuilder/@@@oldstable@@@-proposed-updates/apt
+
diff --git a/debian/rules b/debian/rules
index 40d082e..6fb9a22 100755
--- a/debian/rules
+++ b/debian/rules
@@ -7,12 +7,16 @@
 
 # This is the debhelper compatability version to use.
 ARCH=$(shell dpkg-architecture -qDEB_HOST_ARCH)
+#
+# Conversion rule
+#
+include RELEASE_LIST
 
 configure: configure-stamp
 configure-stamp:
 	dh_testdir
 	# Add here commands to configure the package.
-
+	sed $(CONV) < debian/pbuilder.links.in > debian/pbuilder.links
 	touch configure-stamp
 
 build: configure-stamp build-stamp 
@@ -28,6 +32,7 @@ clean:
 
 	# Add here commands to clean up after the build process.
 	-$(MAKE) clean
+	-rm debian/pbuilder.links
 
 	dh_clean
 
-- 
1.5.6.3

>From e523bdce6a3710939490f185cf1a4e5dd93c0e82 Mon Sep 17 00:00:00 2001
From: Osamu Aoki <[EMAIL PROTECTED]>
Date: Tue, 29 Jul 2008 23:45:35 +0900
Subject: [PATCH] added example to add archive key within chroot

  Secure apt possible for backports.org
---
 examples/E11backportkey |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
 create mode 100755 examples/E11backportkey

diff --git a/examples/E11backportkey b/examples/E11backportkey
new file mode 100755
index 0000000..550a0e0
--- /dev/null
+++ b/examples/E11backportkey
@@ -0,0 +1,6 @@
+#!/bin/sh
+# Add backports.org GPG key
+apt-get -y install wget
+wget -O - http://backports.org/debian/archive.key | apt-key add -
+apt-get -y update
+apt-get -y dist-upgrade
-- 
1.5.6.3

>From b3341626151afca3e64ea9d0ad5ecc7797725583 Mon Sep 17 00:00:00 2001
From: Osamu Aoki <[EMAIL PROTECTED]>
Date: Tue, 29 Jul 2008 23:52:12 +0900
Subject: [PATCH] added source.list defaults for mode option

---
 mode/dapper/sources.list                     |    1 +
 mode/experimental/sources.list               |    3 +++
 mode/feisty/sources.list                     |    1 +
 mode/gutsy/sources.list                      |    1 +
 mode/hardy/sources.list                      |    1 +
 mode/intrepid/sources.list                   |    1 +
 mode/oldstable-backports/sources.list        |    3 +++
 mode/oldstable-proposed-updates/sources.list |    3 +++
 mode/oldstable/sources.list                  |    2 ++
 mode/stable-backports/sources.list           |    3 +++
 mode/stable-proposed-updates/sources.list    |    3 +++
 mode/stable/sources.list                     |    2 ++
 mode/testing-proposed-updates/sources.list   |    3 +++
 mode/testing/sources.list                    |    2 ++
 mode/unstable/sources.list                   |    1 +
 15 files changed, 30 insertions(+), 0 deletions(-)
 create mode 100644 mode/dapper/sources.list
 create mode 100644 mode/experimental/sources.list
 create mode 100644 mode/feisty/sources.list
 create mode 100644 mode/gutsy/sources.list
 create mode 100644 mode/hardy/sources.list
 create mode 100644 mode/intrepid/sources.list
 create mode 100644 mode/oldstable-backports/sources.list
 create mode 100644 mode/oldstable-proposed-updates/sources.list
 create mode 100644 mode/oldstable/sources.list
 create mode 100644 mode/stable-backports/sources.list
 create mode 100644 mode/stable-proposed-updates/sources.list
 create mode 100644 mode/stable/sources.list
 create mode 100644 mode/testing-proposed-updates/sources.list
 create mode 100644 mode/testing/sources.list
 create mode 100644 mode/unstable/sources.list

diff --git a/mode/dapper/sources.list b/mode/dapper/sources.list
new file mode 100644
index 0000000..6cc7dcc
--- /dev/null
+++ b/mode/dapper/sources.list
@@ -0,0 +1 @@
+deb http://archive.ubuntu.com/ubuntu/ dapper main restricted universe multiverse
diff --git a/mode/experimental/sources.list b/mode/experimental/sources.list
new file mode 100644
index 0000000..93d7e35
--- /dev/null
+++ b/mode/experimental/sources.list
@@ -0,0 +1,3 @@
+deb @@@MIRRORSITE@@@ unstable     @@@COMPONENTS@@@
+deb @@@MIRRORSITE@@@ experimental @@@COMPONENTS@@@
+#deb-src intentionally non-existent
diff --git a/mode/feisty/sources.list b/mode/feisty/sources.list
new file mode 100644
index 0000000..edb20b8
--- /dev/null
+++ b/mode/feisty/sources.list
@@ -0,0 +1 @@
+deb http://archive.ubuntu.com/ubuntu/ feisty main restricted universe multiverse
diff --git a/mode/gutsy/sources.list b/mode/gutsy/sources.list
new file mode 100644
index 0000000..7088a75
--- /dev/null
+++ b/mode/gutsy/sources.list
@@ -0,0 +1 @@
+deb http://archive.ubuntu.com/ubuntu/ gutsy main restricted universe multiverse
diff --git a/mode/hardy/sources.list b/mode/hardy/sources.list
new file mode 100644
index 0000000..245e93c
--- /dev/null
+++ b/mode/hardy/sources.list
@@ -0,0 +1 @@
+deb http://archive.ubuntu.com/ubuntu/ hardy main restricted universe multiverse
diff --git a/mode/intrepid/sources.list b/mode/intrepid/sources.list
new file mode 100644
index 0000000..b3c4807
--- /dev/null
+++ b/mode/intrepid/sources.list
@@ -0,0 +1 @@
+deb http://archive.ubuntu.com/ubuntu/ intrepid main restricted universe multiverse
diff --git a/mode/oldstable-backports/sources.list b/mode/oldstable-backports/sources.list
new file mode 100644
index 0000000..64cf2ac
--- /dev/null
+++ b/mode/oldstable-backports/sources.list
@@ -0,0 +1,3 @@
+deb @@@MIRRORSITE@@@                oldstable                 @@@COMPONENTS@@@
+deb http://security.debian.org/     oldstable/updates         @@@COMPONENTS@@@
+deb http://www.backports.org/debian @@@oldstable@@@-backports @@@COMPONENTS@@@
diff --git a/mode/oldstable-proposed-updates/sources.list b/mode/oldstable-proposed-updates/sources.list
new file mode 100644
index 0000000..ca410c0
--- /dev/null
+++ b/mode/oldstable-proposed-updates/sources.list
@@ -0,0 +1,3 @@
+deb @@@MIRRORSITE@@@            oldstable         @@@COMPONENTS@@@
+deb @@@MIRRORSITE@@@ oldstable-proposed-updates   @@@COMPONENTS@@@
+deb http://security.debian.org/ oldstable/updates @@@COMPONENTS@@@
diff --git a/mode/oldstable/sources.list b/mode/oldstable/sources.list
new file mode 100644
index 0000000..96949e3
--- /dev/null
+++ b/mode/oldstable/sources.list
@@ -0,0 +1,2 @@
+deb @@@MIRRORSITE@@@            oldstable         @@@COMPONENTS@@@
+deb http://security.debian.org/ oldstable/updates @@@COMPONENTS@@@
diff --git a/mode/stable-backports/sources.list b/mode/stable-backports/sources.list
new file mode 100644
index 0000000..d33e449
--- /dev/null
+++ b/mode/stable-backports/sources.list
@@ -0,0 +1,3 @@
+deb @@@MIRRORSITE@@@                stable                 @@@COMPONENTS@@@
+deb http://security.debian.org/     stable/updates         @@@COMPONENTS@@@
+deb http://www.backports.org/debian @@@stable@@@-backports @@@COMPONENTS@@@
diff --git a/mode/stable-proposed-updates/sources.list b/mode/stable-proposed-updates/sources.list
new file mode 100644
index 0000000..8c4dd92
--- /dev/null
+++ b/mode/stable-proposed-updates/sources.list
@@ -0,0 +1,3 @@
+deb @@@MIRRORSITE@@@            stable         @@@COMPONENTS@@@
+deb @@@MIRRORSITE@@@   stable-proposed-updates @@@COMPONENTS@@@
+deb http://security.debian.org/ stable/updates @@@COMPONENTS@@@
diff --git a/mode/stable/sources.list b/mode/stable/sources.list
new file mode 100644
index 0000000..b90d509
--- /dev/null
+++ b/mode/stable/sources.list
@@ -0,0 +1,2 @@
+deb @@@MIRRORSITE@@@            stable         @@@COMPONENTS@@@
+deb http://security.debian.org/ stable/updates @@@COMPONENTS@@@
diff --git a/mode/testing-proposed-updates/sources.list b/mode/testing-proposed-updates/sources.list
new file mode 100644
index 0000000..9cd4831
--- /dev/null
+++ b/mode/testing-proposed-updates/sources.list
@@ -0,0 +1,3 @@
+deb @@@MIRRORSITE@@@            testing         @@@COMPONENTS@@@
+deb @@@MIRRORSITE@@@   testing-proposed-updates @@@COMPONENTS@@@
+deb http://security.debian.org/ testing/updates @@@COMPONENTS@@@
diff --git a/mode/testing/sources.list b/mode/testing/sources.list
new file mode 100644
index 0000000..df22aaa
--- /dev/null
+++ b/mode/testing/sources.list
@@ -0,0 +1,2 @@
+deb @@@MIRRORSITE@@@            testing         @@@COMPONENTS@@@
+deb http://security.debian.org/ testing/updates @@@COMPONENTS@@@
diff --git a/mode/unstable/sources.list b/mode/unstable/sources.list
new file mode 100644
index 0000000..0cf4ff8
--- /dev/null
+++ b/mode/unstable/sources.list
@@ -0,0 +1 @@
+deb @@@MIRRORSITE@@@ unstable @@@COMPONENTS@@@
-- 
1.5.6.3

>From eb3b9d6327394dc7f678eec51486fc683080b317 Mon Sep 17 00:00:00 2001
From: Osamu Aoki <[EMAIL PROTECTED]>
Date: Tue, 29 Jul 2008 23:55:42 +0900
Subject: [PATCH] added work around for old debsign

  Work around for devscript << 2.10.31, Bug#487999
  This is not required if newer debsign, which no more interfares
  with group write permission of the result directory, is used.
---
 pbuilder-buildpackage |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/pbuilder-buildpackage b/pbuilder-buildpackage
index 18c781a..9264f95 100755
--- a/pbuilder-buildpackage
+++ b/pbuilder-buildpackage
@@ -67,6 +67,12 @@ if [ ! -d "${BUILDRESULT}" ]; then
     fi
 fi
 
+if [ -n "$PBMODEOPTION" ]; then
+    # only with new --mode, we use group result directory
+    chmod  2775 "${BUILDRESULT}"
+    chgrp "src" "${BUILDRESULT}"
+fi
+
 if [ -z "${PBUILDER_BUILD_LOGFILE}" ]; then
     if [ "${PKGNAME_LOGFILE}" = "yes" ]; then
 	PBUILDER_BUILD_LOGFILE="${BUILDRESULT}/"$(basename "${PACKAGENAME}" .dsc)"${PKGNAME_LOGFILE_EXTENTION}"
-- 
1.5.6.3

>From 0210f4c8acfb9ae2b3c1e8447319ccd58779dd05 Mon Sep 17 00:00:00 2001
From: Osamu Aoki <[EMAIL PROTECTED]>
Date: Wed, 30 Jul 2008 00:37:17 +0900
Subject: [PATCH] added default DISTRIBUTION support etc.

---
 pbuilder-checkparams |   39 +++++++++++++++++++++++++++++++++------
 1 files changed, 33 insertions(+), 6 deletions(-)

diff --git a/pbuilder-checkparams b/pbuilder-checkparams
index cadd24b..1fc58a6 100755
--- a/pbuilder-checkparams
+++ b/pbuilder-checkparams
@@ -242,12 +242,39 @@ if [ -z "${CHROOTEXEC}" ]; then
     CHROOTEXEC="chroot $BUILDPLACE "
 fi
 
-# handle 'experimental' specially. -- required for raw pbuilder (create/update) only.
-if [ "$DISTRIBUTION" = "experimental" ]; then
-    DISTRIBUTION="sid"
-    EXPERIMENTAL="true"
-else 
-    EXPERIMENTAL=
+EXPERIMENTAL=""
+if [ -z "${PBMODEOPTION}" ]; then
+    # classic mode: handle 'experimental' specially. -- required for raw pbuilder (create/update) only.
+    if [ "$DISTRIBUTION" = "experimental" ]; then
+        DISTRIBUTION="sid"
+        EXPERIMENTAL="true"
+    fi
+    # classic mode enhanced: use sid as default distribution
+    if [ -z "$DISTRIBUTION" ]; then
+        DISTRIBUTION="sid"
+    fi
+else
+    # new mode: default value
+    if [ -z "$DISTRIBUTION" ]; then
+        DISTRIBUTION=${PBMODEOPTION}
+    fi
+    # convert all odd distributions
+    if [ "$DISTRIBUTION" = "experimental" ]; then
+        DISTRIBUTION="sid"
+    elif [ "${DISTRIBUTION%/volatile}" != "${DISTRIBUTION}" ]; then
+        DISTRIBUTION="${DISTRIBUTION%/volatile}"
+    elif [ "${DISTRIBUTION%/volatile-sloppy}" != "${DISTRIBUTION}" ]; then
+        DISTRIBUTION="${DISTRIBUTION%/volatile-sloppy}"
+    elif [ "${DISTRIBUTION%-backports}" != "${DISTRIBUTION}" ]; then
+        DISTRIBUTION=${DISTRIBUTION%-backports}
+    fi
+    # Does mode use "@@@MIRRORSITE@@@"? If not, get it from sources.list
+    if [ -f /usr/share/pbuilder/${PBMODEOPTION}/apt/sources.list ]; then
+        ALTERNATIVE_MIRROR=$( sed -n -e '1s/^deb *\([^ ]*\) .*$/\1/p'</usr/share/pbuilder/${PBMODEOPTION}/apt/sources.list )
+        if [ ${ALTERNATIVE_MIRROR} != "@@@MIRRORSITE@@@" ]; then
+            MIRRORSITE="${ALTERNATIVE_MIRROR}"
+        fi
+    fi
 fi
 
 case "$PBCURRENTCOMMANDLINEOPERATION" in 
-- 
1.5.6.3

>From e5fc92f70a860850d775307282d08c60aafbab74 Mon Sep 17 00:00:00 2001
From: Osamu Aoki <[EMAIL PROTECTED]>
Date: Wed, 30 Jul 2008 01:08:15 +0900
Subject: [PATCH] Adjusted for mode option w/o preferences

  Since I now provide no files for preferences, I updated
  build script not to error.
---
 Makefile |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 9b2ecdb..ce1dc32 100644
--- a/Makefile
+++ b/Makefile
@@ -104,8 +104,16 @@ install:
 	$(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
-	for x in $(SUPPORTEDMODE); do sed $(CONV) <mode/$$x/sources.list >$(DESTDIR)/usr/share/pbuilder/$$x/apt/sources.list ; done
-	for x in $(SUPPORTEDMODE); do sed $(CONV) <mode/$$x/preferences >$(DESTDIR)/usr/share/pbuilder/$$x/apt/preferences ; done
+	for x in $(SUPPORTEDMODE); do \
+	    if [ -f mode/$$x/sources.list ]; then \
+	        sed $(CONV) <mode/$$x/sources.list >$(DESTDIR)/usr/share/pbuilder/$$x/apt/sources.list ; \
+	    fi ; \
+	done
+	for x in $(SUPPORTEDMODE); do \
+	    if [ -f mode/$$x/preferences  ]; then \
+	        sed $(CONV) <mode/$$x/preferences  >$(DESTDIR)/usr/share/pbuilder/$$x/apt/preferences  ; \
+	    fi ; \
+	done
 	$(INSTALL_FILE) bash_completion.pbuilder $(DESTDIR)/etc/bash_completion.d/pbuilder
 	$(INSTALL_FILE) pbuilderrc $(DESTDIR)/usr/share/pbuilder
 	$(INSTALL_FILE) pbuilder-uml.conf $(DESTDIR)/etc/pbuilder
-- 
1.5.6.3

Reply via email to