[pacman-dev] [PATCH] makepkg: allow specifying subsets of packages to build
Allan McRae
allan at archlinux.org
Wed Oct 21 01:12:25 EDT 2009
Dan McGee wrote:
> On Tue, Oct 20, 2009 at 11:01 PM, Allan McRae <allan at archlinux.org> wrote:
>
>> This allows makepkg to only build a specified subset of packages
>> from a split PKGBUILD. This is very useful in combination with the
>> -R flag or when bumping the pkgrel of a single package.
>>
>> Fixes FS#15956.
>>
>> Signed-off-by: Allan McRae <allan at archlinux.org>
>> ---
>>
>> As always, my changes to the documenation could be improved. Suggestions welcome.
>>
>
> Would you mind splitting the ARGLIST patch into a separate one? It
> seems pretty independent and might be good to explain a bit more by
> itself in a commit message. (Easiest way to split a patch is probably
> git-reset HEAD^, then git add -i, ...)
>
No problem.
>
>> doc/makepkg.8.txt | 5 +++++
>> scripts/makepkg.sh.in | 26 +++++++++++++++++++++-----
>> 2 files changed, 26 insertions(+), 5 deletions(-)
>>
>> diff --git a/doc/makepkg.8.txt b/doc/makepkg.8.txt
>> index ec02875..8c68143 100644
>> --- a/doc/makepkg.8.txt
>> +++ b/doc/makepkg.8.txt
>> @@ -148,6 +148,11 @@ Options
>> remote builder, or a tarball upload. Because integrity checks are verified,
>> all source files of the package need to be present or downloadable.
>>
>> +*\--pkg <`list`>*::
>> + Builds only the listed packages. Useful in combination with package
>> + splitting. The use quotes is necessary when specifying multiple
>> + packages. e.g. `--pkg "pkg1 pkg3"`
>> +
>>
> If I wasn't reading this with split packages in mind, I might think
> this is some sort of yaourt automatic system where it goes an finds
> the package I want. "Builds only the designated packages in a split
> package build script" or something? I don't know. Now of course I just
> read the second sentence and see that you cleared it up; it might be
> worth trying to get the package splitting actually in the first
> sentence for stupid people like me that only read the first sentence.
> And "The use of quotes" might be what you were looking for.
>
>
>> *\--noconfirm*::
>> (Passed to pacman) Prevent pacman from waiting for user input before
>> proceeding with operations.
>> diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
>> index 7e10eef..c3672b1 100644
>> --- a/scripts/makepkg.sh.in
>> +++ b/scripts/makepkg.sh.in
>> @@ -72,6 +72,7 @@ IGNOREARCH=0
>> HOLDVER=0
>> PKGFUNC=0
>> SPLITPKG=0
>> +PKGLIST=""
>> COLORMSG=0
>>
>> # Forces the pkgver of the current PKGBUILD. Used by the fakeroot call
>> @@ -1243,6 +1244,15 @@ check_sanity() {
>> done
>> fi
>>
>> + if [ -n "$PKGLIST" ]; then
>>
> This would only check the first item in $PKGLIST, is that ok?
>
I think that is fine.
>> + for pkg in ${PKGLIST[@]}; do
>> + if ! in_array $pkg ${pkgname[@]}; then
>> + error "$(gettext "requested package %s is not provided in %s")" "$pkg" "$BUILDSCRIPT"
>> + return 1
>> + fi
>> + done
>> + fi
>> +
>> return 0
>> }
>>
>> @@ -1466,6 +1476,7 @@ usage() {
>> echo "$(gettext " --asroot Allow makepkg to run as root user")"
>> printf "$(gettext " --config <file> Use an alternate config file (instead of '%s')")\n" "$confdir/makepkg.conf"
>> echo "$(gettext " --holdver Prevent automatic version bumping for development PKGBUILDs")"
>> + echo "$(gettext " --pkg <list> Only build listed packages from a split package")"
>>
> So for the man page doc, this sentence is maybe succinct enough to be
> the lead sentence, then follow it with more detail.
>
>
>> echo "$(gettext " --skipinteg Do not fail when integrity checks are missing")"
>> echo "$(gettext " --source Generate a source-only tarball without downloaded sources")"
>> echo
>> @@ -1496,13 +1507,13 @@ if [ ! $(type -t gettext) ]; then
>> }
>> fi
>>
>> -ARGLIST=$@
>> +ARGLIST=("$@")
>>
>> # Parse Command Line Options.
>> OPT_SHORT="AcCdefFghiLmop:rRsV"
>> OPT_LONG="allsource,asroot,ignorearch,clean,cleancache,nodeps"
>> OPT_LONG="$OPT_LONG,noextract,force,forcever:,geninteg,help,holdver"
>> -OPT_LONG="$OPT_LONG,install,log,nocolor,nobuild,rmdeps,repackage,skipinteg"
>> +OPT_LONG="$OPT_LONG,install,log,nocolor,nobuild,pkg:,rmdeps,repackage,skipinteg"
>> OPT_LONG="$OPT_LONG,source,syncdeps,version,config:"
>> # Pacman Options
>> OPT_LONG="$OPT_LONG,noconfirm,noprogressbar"
>> @@ -1540,6 +1551,7 @@ while true; do
>> -m|--nocolor) USE_COLOR='n' ;;
>> -o|--nobuild) NOBUILD=1 ;;
>> -p) shift; BUILDFILE=$1 ;;
>> + --pkg) shift; PKGLIST=$1 ;;
>> -r|--rmdeps) RMDEPS=1 ;;
>> -R|--repackage) REPKG=1 ;;
>> --skipinteg) SKIPINTEG=1 ;;
>> @@ -1722,6 +1734,11 @@ fi
>>
>> pkgbase=${pkgbase:-${pkgname[0]}}
>>
>> +if [ -n "$PKGLIST" ]; then
>> + unset pkgname
>> + pkgname="${PKGLIST[@]}"
>> +fi
>> +
>> if [ "$SPLITPKG" -eq 0 ]; then
>> if [ \( -f "$PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT}" \
>> -o -f "$PKGDEST/${pkgname}-${pkgver}-${pkgrel}-any${PKGEXT}" \) \
>> @@ -1914,11 +1931,10 @@ else
>> fi
>>
>> msg "$(gettext "Entering fakeroot environment...")"
>> -
>> if [ -n "$newpkgver" ]; then
>> - fakeroot -- $0 --forcever $newpkgver -F $ARGLIST || exit $?
>> + fakeroot -- $0 --forcever $newpkgver -F "${ARGLIST[@]}" || exit $?
>> else
>> - fakeroot -- $0 -F $ARGLIST || exit $?
>> + fakeroot -- $0 -F "${ARGLIST[@]}" || exit $?
>> fi
>> fi
>> fi
>> --
>> 1.6.5.1
>>
>
> Without testing, I'm not sure how the flipflopping between treating
> $PKGLIST like a string and an array works, but it seems scary. Am I
> missing something obvious about the way bash does this?
>
The short answer is that it works... although I am sure someone could
find and edge case where it does not. I will adjust it to use array
syntax always.
Allan
More information about the pacman-dev
mailing list