[PATCH 1/9] add profile support to pbuilder

Loïc Minier lool at dooz.org
Fri Jan 22 22:55:58 UTC 2010


On Sun, Jan 17, 2010, Loïc Minier wrote:
> "--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 "$@"
> +

 I find this is a bit heavy just for the --profile concept; it is a bit
 like --configfile which doesn't require this; the --configfile
 "EXTRA_CONFIGFILE" concept is not pretty either though.   :-/

 I think it would be ok if you would just source the profile at
 --profile time.  This will override things like ~/.pbuilderrc, but then
 --profile is a command-line argument, and things which are set in the
 profile config file should not conflict too much with things in
 ~/.pbuilderrc.

> --- 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}"

 I see you reverted that one later.  I tried sticking to GNU style vars;
 see info Automake "Standard Directory Variables", but there are more
 vars than just these such as pkglibdir, pkgincludedir etc.

> -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 

 (See above on profile config handling.)

> --- 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" "/"

 "their"

 I think the description should be generic instead of specifically
 pointing at "/var/cache/pbuilder/".  For instance you could mention
 that profile allow maintaining multiple build environments with
 different APT configurations, separate build dirs etc.

> --- 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.
> +#######################################################################

 Probably not the ideal place to have documentation; also, let's avoid
 duplicating these values -- these are set in multiple places already.

 Other changes look good.

> --- a/pbuilderrc.5
> +++ b/pbuilderrc.5
> +This moves default pbuilder data cache directories from thier normal
> +.B "/var/cache/pbuilder/"

 Ditto; and I think I'd document "PROFILE" as a valid way to set the
 default profile.  You might want to set PROFILE to "sid" by default and
 override on the command-line.

-- 
Loïc Minier



More information about the Pbuilder-maint mailing list