On 6/11/19 10:18 am, Ethan Sommer wrote:
> Read PKGBUILD into an array and replace the pkgver and pkgrel with
> bash parameter substitution, then use shell redirection to write to to
> the file. Because shell redirection follows symlinks, this accomplishes
> the same thing as the previous default of using the GNU-specific
> --follow-symlinks sed flag.
> 
> Remove SEDPATH and SEDINPLACEFLAGS from the build systems as they are
> not used elsewhere.
> ---

I like the idea, but am concerned about unintended consequences...

I saw the following mentioned on IRC:
- potential for changed line endings
- added newline at the end of files without one
- removing any null characters

I'm leaning on the side of these being fine, but need to mull on it some
more.

Anything else I missed?

<snip>

> diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
> index c49ac57a..b9e83458 100644
> --- a/scripts/makepkg.sh.in
> +++ b/scripts/makepkg.sh.in
> @@ -199,13 +199,14 @@ update_pkgver() {
>       fi
>  
>       if [[ -n $newpkgver && $newpkgver != "$pkgver" ]]; then
> -             if [[ -f $BUILDFILE && -w $BUILDFILE ]]; then
> -                     if ! @SEDPATH@ @SEDINPLACEFLAGS@ "s:^pkgver=[^ 
> ]*:pkgver=$newpkgver:" "$BUILDFILE"; then
> +             if [[ -w $BUILDFILE ]]; then
> +                     mapfile -t buildfile < "$BUILDFILE"
> +                     buildfile=("${buildfile[@]/#pkgver=*([^ 
> ])/pkgver=$newpkgver}")
> +                     if ! printf '%s\n' "${buildfile[@]/#pkgrel=*([^ 
> ])/pkgrel=1}" > "$BUILDFILE"; then

split into two lines:

buildfile=("${buildfile[@]/#pkgrel=*([^ ])/pkgrel=1}")
if ! print '%s\n" "${buildfile[@]}"...

>                               error "$(gettext "Failed to update %s from %s 
> to %s")" \
>                                               "pkgver" "$pkgver" "$newpkgver"
>                               exit $E_PKGBUILD_ERROR
>                       fi
> -                     @SEDPATH@ @SEDINPLACEFLAGS@ "s:^pkgrel=[^ ]*:pkgrel=1:" 
> "$BUILDFILE"
>                       source_safe "$BUILDFILE"
>                       local fullver=$(get_full_version)
>                       msg "$(gettext "Updated version: %s")" "$pkgbase 
> $fullver"
> 

Reply via email to