[PATCH 1/9] add profile support to pbuilder

Loïc Minier lool at dooz.org
Sun Jan 17 08:02:19 UTC 2010


"--profile" is an optional argument which is used to
manage multiple customized archives as follows:

$ sudo pbuilder --profile foo --create
$ sudo pbuilder --profile foo --login --save-after-login
  ... edit and customize chroot
  ^D
$ sudo pbuilder --profile foo --update
$ cd /path/to/package-source
$ pdebuild -- --profile foo
$ cd /var/cache/pbuilder/foo/result
$ sudo debi package_1.0_amd64.changes
---
 pbuilder-checkparams |   26 ++++++++++++++++++++++++++
 pbuilder-loadconfig  |   13 ++++++++++---
 pbuilder.8           |   39 +++++++++++++++++++++++++++++++++++++++
 pbuilderrc           |   25 ++++++++++++++++++++-----
 pbuilderrc.5         |   20 +++++++++++++++++++-
 5 files changed, 114 insertions(+), 9 deletions(-)

diff --git a/pbuilder-checkparams b/pbuilder-checkparams
index 2e350d0..5dded22 100755
--- a/pbuilder-checkparams
+++ b/pbuilder-checkparams
@@ -23,6 +23,28 @@
 
 export PBUILDER_PKGLIBDIR="${PBUILDER_PKGLIBDIR:-$PBUILDER_ROOT/usr/lib/pbuilder}"
 
+function preload_config () {
+    while [ -n "$1" ]; do 
+	case "$1" in 
+	    --profile|-p)
+		PROFILE="$2";
+		shift; shift;
+		;;
+	    --) # end of processing for this
+		shift;
+		break;
+		;;
+	    *)
+		shift;
+		;;
+	esac
+    done
+}
+
+# Set default archive information based on distribution
+
+preload_config "$@"
+
 . "$PBUILDER_PKGLIBDIR"/pbuilder-loadconfig
 . "$PBUILDER_PKGLIBDIR"/pbuilder-modules
 
@@ -43,6 +65,10 @@ IGNORE_UMOUNT=""
 
 while [ -n "$1" ]; do 
     case "$1" in 
+	--profile|-p)
+	    # preloaded
+	    shift; shift;
+	    ;;
 	--basetgz) 
 	    case "${PBCURRENTCOMMANDLINEOPERATION}" in
 		create|--create)
diff --git a/pbuilder-loadconfig b/pbuilder-loadconfig
index bd42461..b1bdcd5 100644
--- a/pbuilder-loadconfig
+++ b/pbuilder-loadconfig
@@ -18,10 +18,17 @@
 #   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 
 export PBUILDER_PKGDATADIR="${PBUILDER_PKGDATADIR:-$PBUILDER_ROOT/usr/share/pbuilder}"
-export PBUILDER_SYSCONFDIR="${PBUILDER_SYSCONFDIR:-$PBUILDER_ROOT/etc}"
+export PBUILDER_SYSCONFDIR="${PBUILDER_SYSCONFDIR:-$PBUILDER_ROOT/etc/pbuilder}"
+export PBUILDER_CACHEDIR="${PBUILDER_CACHEDIR:-$PBUILDER_ROOT/var/cache/pbuilder}"
 
-for RCFILE in "$PBUILDER_PKGDATADIR"/pbuilderrc "$PBUILDER_SYSCONFDIR"/pbuilderrc "$HOME"/.pbuilderrc; do
-    if [ -f "$RCFILE" ]; then 
+for RCFILE in \
+    "${PBUILDER_PKGDATADIR}/pbuilderrc" \
+    "${PBUILDER_SYSCONFDIR}/pbuilderrc" \
+    "${PROFILE:+$PBUILDER_SYSCONFDIR/$PROFILE.rc}" \
+    "${HOME}/.pbuilderrc"; do
+    if [ -z "$RCFILE" ]; then 
+        : # If no profile set, do nothing and normal
+    elif [ -f "$RCFILE" ]; then 
 	. "$RCFILE"
     else
 	# log() is not available
diff --git a/pbuilder.8 b/pbuilder.8
index a1f45d8..86f6f7c 100644
--- a/pbuilder.8
+++ b/pbuilder.8
@@ -399,6 +399,24 @@ This is useful when you keep a aptcache directory for each distribution
 and want to keep the size of the aptcache down.
 
 .TP
+.BI "\-\-profile|\-p " "profile"
+Move default pbuilder data cache directories from thier normal
+.B "/var/cache/pbuilder/"
+to
+.BI "/var/cache/pbuilder/" "profile" "/"
+consistently.  This option is evaluated before other options no matter 
+where this is located in the command line.  This ensures other specific options such as 
+.B \-\-buildplace
+can override this setting.
+
+Internally, this sets the internal environment variable
+.B $PROFILE
+to the value
+.I "profile"
+when this is used.  The default value of this environment variable is the null
+string.  
+
+.TP
 .BI "\-\-help"
 
 Show a brief help message.
@@ -622,6 +640,27 @@ Building the build Environment
 	.
 .hy
 
+.TP
+.BI "pbuilder \-\-profile " "profile" " \-\-create" 
+
+This creates chroot data in
+.BI "/var/cache/pbuilder/" "profile" "/base.tgz" "."
+
+
+.TP
+.BI "pbuilder \-\-login \-\-profile " "profile" " \-\-save\-after\-login"
+
+This let you login to chroot data in
+.BI "/var/cache/pbuilder/" "profile" "/base.tgz"
+and save modifications into it after leaving login with ^D.
+
+.TP
+.BI "pbuilder \-\-profile " "profile" " \-\-create \-\-no\-targz"
+
+This creates chroot tree under
+.BI "/var/cache/pbuilder/" "profile" "/"
+which can be directly modified.
+
 .SH "BUGS"
 This program is starting to have too many options already.
 
diff --git a/pbuilderrc b/pbuilderrc
index cb00f5e..af91ace 100755
--- a/pbuilderrc
+++ b/pbuilderrc
@@ -1,17 +1,32 @@
 # pbuilder defaults; edit /etc/pbuilderrc to override these and see
 # pbuilderrc.5 for documentation
 
-BASETGZ=/var/cache/pbuilder/base.tgz
+# Default values set by the calling program:
+#   ${PROFILE}             ""
+#   ${PBUILDER_CACHEDIR}   "/var/cache/pbuilder"
+#   ${PBUILDER_PKGLIBDIR}  "/usr/lib/pbuilder"
+#   ${PBUILDER_PKGDATADIR} "/usr/share/pbuilder"
+#   ${PBUILDER_SYSCONFDIR} "/etc/pbuilder"
+#
+# ${PROFILE} is set to "bar" if pbuilder is started by 
+# "pbuilder -p bar ..." or pdebuild is started by 
+# "pdebuild ... -- -p bar ...".
+#
+# The configuration of the "/usr/share/pbuilder/pbuilderrc" and 
+# "/etc/pbuilderrc" may be overriden by "/etc/pbuilder/bar.rc" 
+# if this exists.
+#######################################################################
+BASETGZ="${PBUILDER_CACHEDIR}/${PROFILE:+$PROFILE/}base.tgz"
 #EXTRAPACKAGES=""
 #export DEBIAN_BUILDARCH=athlon
-BUILDPLACE=/var/cache/pbuilder/build/
+BUILDPLACE="${PBUILDER_CACHEDIR}/${PROFILE:+$PROFILE/}build/"
 MIRRORSITE=http://cdn.debian.net/debian
 #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="${PBUILDER_CACHEDIR}/${PROFILE:+$PROFILE/}result/"
 
 # specifying the distribution forces the distribution on "pbuilder update"
 #DISTRIBUTION=sid
@@ -23,13 +38,13 @@ BUILDRESULT=/var/cache/pbuilder/result/
 # restricted universe multiverse"
 COMPONENTS="main"
 #specify the cache for APT 
-APTCACHE="/var/cache/pbuilder/aptcache/"
+APTCACHE="${PBUILDER_CACHEDIR}/${PROFILE:+$PROFILE/}aptcache/"
 APTCACHEHARDLINK="yes"
 REMOVEPACKAGES=""
 #HOOKDIR="/usr/lib/pbuilder/hooks"
 HOOKDIR=""
 # NB: this var is private to pbuilder; ccache uses "CCACHE_DIR" instead
-CCACHEDIR="/var/cache/pbuilder/ccache"
+CCACHEDIR="${PBUILDER_CACHEDIR}/${PROFILE:+$PROFILE/}ccache"
 
 # make debconf not interact with user
 export DEBIAN_FRONTEND="noninteractive"
diff --git a/pbuilderrc.5 b/pbuilderrc.5
index 2dd6187..eed2103 100644
--- a/pbuilderrc.5
+++ b/pbuilderrc.5
@@ -9,6 +9,7 @@ program invocation.
 .PP
 The file itself is sourced by a shell script, so
 it is required that the file conforms to shell script conventions.
+
 .SH "FORMAT"
 
 .TP
@@ -405,6 +406,23 @@ Always run with
 -B "--autocleanaptcache"
 option.
 
+.SH "PROFILE"
+
+When pbuilder is invoked with 
+.BI "--profile " "profile"
+, it sets the internal environment variable
+.B $PROFILE
+to the value
+.I "profile" "."
+This moves default pbuilder data cache directories from thier normal
+.B "/var/cache/pbuilder/"
+to
+.BI "/var/cache/pbuilder/" "profile" "/"
+consistently and let pbuilder to source additional configuration file
+.BI "/etc/pbuilder/" "profile" ".rc"
+after 
+.B "/etc/pbuilderrc" "."
+
 .SH "AUTHOR"
 Initial coding, and main maintenance is done by 
 Junichi Uekawa <dancer at debian.org>.
@@ -415,7 +433,7 @@ The homepage is available at
 
 
 .SH "FILES"
-.I "/etc/pbuilderrc, ${HOME}/.pbuilderrc"
+.BI "/etc/pbuilderrc, /etc/pbuilder/" "profile" ".rc, ${HOME}/.pbuilderrc"
 .SH "SEE ALSO"
 .BR "/usr/share/doc/pbuilder/pbuilder-doc.html" ", "
 .BR "pbuilder" "(8), "
-- 
1.6.5




More information about the Pbuilder-maint mailing list