FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux Pacman Development

 
 
LinkBack Thread Tools
 
Old 06-27-2012, 12:20 AM
Dave Reisner
 
Default makepkg: provide mechanism for auto-updating pkgver

On Wed, Jun 27, 2012 at 09:18:53AM +1000, Allan McRae wrote:
> Now that VCS repos are provided in the source array, it becomes too
> complicated to have automatic updating pkgver as was the case with
> the old VCS PKGBUILDs (there can be multiple repos of different types
> in the source array, the VCS repo may not be the package primary
> source, etc).
>
> Instead provide an optional way for a PKGBUILD to update the pkgver
> value through the specifing of a pkgver() function that returns the
> new version string. This is run after all source files are downloaded
> so can access the VCS repo if needed.
>
> Signed-off-by: Allan McRae <allan@archlinux.org>
> ---
> scripts/makepkg.sh.in | 21 +++++++++++++++++++++
> 1 file changed, 21 insertions(+)
>
> diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
> index 0b282a5..5cc378d 100644
> --- a/scripts/makepkg.sh.in
> +++ b/scripts/makepkg.sh.in
> @@ -471,9 +471,30 @@ download_sources() {
> esac
> done
>
> + if declare -f pkgver >/dev/null; then
> + update_pkgver
> + fi
> +
> popd &>/dev/null
> }
>
> +# Automatically update pkgver variable if a pkgver() function is provided
> +# Re-sources the PKGBUILD afterwards to allow for other variables that use $pkgver
> +update_pkgver() {
> + newpkgver=$(pkgver)

This is arbitrary code from the user. Should we be wrapping this in the
error trap?

> +
> + if [[ -n $newpkgver && $newpkgver != "$pkgver" ]]; then
> + if [[ -f $BUILDFILE && -w $BUILDFILE ]]; then
> + @SEDINPLACE@ "s/^pkgver=[^ ]*/pkgver=$newpkgver/" "$BUILDFILE"
> + @SEDINPLACE@ "s/^pkgrel=[^ ]*/pkgrel=1/" "$BUILDFILE"
> + source "$BUILDFILE"
> + else
> + warning "$(gettext "%s is not writeable -- pkgver will not be updated")"
> + "$BUILDFILE"
> + fi
> + fi

Hmmm, maybe a warning if $newpkgver is empty?

> +}
> +
> # Print 'source not found' error message and exit makepkg
> missing_source_file() {
> error "$(gettext "Unable to find source file %s.")" "$(get_filename "$1")"
> --
> 1.7.11.1
>
>
 
Old 06-29-2012, 03:19 AM
Allan McRae
 
Default makepkg: provide mechanism for auto-updating pkgver

On 27/06/12 10:20, Dave Reisner wrote:
> On Wed, Jun 27, 2012 at 09:18:53AM +1000, Allan McRae wrote:
>> Now that VCS repos are provided in the source array, it becomes too
>> complicated to have automatic updating pkgver as was the case with
>> the old VCS PKGBUILDs (there can be multiple repos of different types
>> in the source array, the VCS repo may not be the package primary
>> source, etc).
>>
>> Instead provide an optional way for a PKGBUILD to update the pkgver
>> value through the specifing of a pkgver() function that returns the
>> new version string. This is run after all source files are downloaded
>> so can access the VCS repo if needed.
>>
>> Signed-off-by: Allan McRae <allan@archlinux.org>
>> ---
>> scripts/makepkg.sh.in | 21 +++++++++++++++++++++
>> 1 file changed, 21 insertions(+)
>>
>> diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
>> index 0b282a5..5cc378d 100644
>> --- a/scripts/makepkg.sh.in
>> +++ b/scripts/makepkg.sh.in
>> @@ -471,9 +471,30 @@ download_sources() {
>> esac
>> done
>>
>> + if declare -f pkgver >/dev/null; then
>> + update_pkgver
>> + fi
>> +
>> popd &>/dev/null
>> }
>>
>> +# Automatically update pkgver variable if a pkgver() function is provided
>> +# Re-sources the PKGBUILD afterwards to allow for other variables that use $pkgver
>> +update_pkgver() {
>> + newpkgver=$(pkgver)
>
> This is arbitrary code from the user. Should we be wrapping this in the
> error trap?

Done.

>> +
>> + if [[ -n $newpkgver && $newpkgver != "$pkgver" ]]; then
>> + if [[ -f $BUILDFILE && -w $BUILDFILE ]]; then
>> + @SEDINPLACE@ "s/^pkgver=[^ ]*/pkgver=$newpkgver/" "$BUILDFILE"
>> + @SEDINPLACE@ "s/^pkgrel=[^ ]*/pkgrel=1/" "$BUILDFILE"
>> + source "$BUILDFILE"
>> + else
>> + warning "$(gettext "%s is not writeable -- pkgver will not be updated")"
>> + "$BUILDFILE"
>> + fi
>> + fi
>
> Hmmm, maybe a warning if $newpkgver is empty?

We really need to run all the pkgver checks here to ensure it is valid
(on the TODO list...). An empty pkgver will be caught there.

>> +}
>> +
>> # Print 'source not found' error message and exit makepkg
>> missing_source_file() {
>> error "$(gettext "Unable to find source file %s.")" "$(get_filename "$1")"
>> --
>> 1.7.11.1
>>
>>
>
>
>
 

Thread Tools




All times are GMT. The time now is 04:46 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org