[pacman-dev] [PATCH] makepkg: Put script sourcing before var validation
Allan McRae
allan at archlinux.org
Thu Jun 20 07:03:57 EDT 2013
On 20/06/13 19:32, William Giokas wrote:
> As it is possible to set things like LOGDEST and PKGDEST in a PKGBUILD,
> we should probably make sure that we can write to said directories
> before just assuming we can and breaking functions when we can't.
>
> Signed-off-by: William Giokas <1007380 at gmail.com>
> ---
>
> I don't think this should cause any issues, but packages that expect
> $srcdir, $pkgdir, etc. to be set when assigning variables will not work
> as intended anymore, but I have never come across any scrip that does
> that, so not really too concerned.
I have actually had to adjust some of my packages to avoid that and have
had several complaints about it not really working...
On the other hand... I have never seen anyone set PKGDEST within a
PKGBUILD.
> scripts/makepkg.sh.in | 40 ++++++++++++++++++++--------------------
> 1 file changed, 20 insertions(+), 20 deletions(-)
>
> diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
> index f8bf8e6..1fe7709 100644
> --- a/scripts/makepkg.sh.in
> +++ b/scripts/makepkg.sh.in
> @@ -2689,6 +2689,26 @@ if [[ -t 2 && ! $USE_COLOR = "n" ]] && check_buildenv "color" "y"; then
> fi
> readonly ALL_OFF BOLD BLUE GREEN RED YELLOW
>
> +unset pkgname pkgbase pkgver pkgrel epoch pkgdesc url license groups provides
> +unset md5sums replaces depends conflicts backup source install changelog build
> +unset makedepends optdepends options noextract
> +
> +BUILDFILE=${BUILDFILE:-$BUILDSCRIPT}
> +if [[ ! -f $BUILDFILE ]]; then
> + error "$(gettext "%s does not exist.")" "$BUILDFILE"
> + exit 1
> +else
> + if [[ $(<"$BUILDFILE") = *$'\r'* ]]; then
> + error "$(gettext "%s contains %s characters and cannot be sourced.")" "$BUILDFILE" "CRLF"
> + exit 1
> + fi
> +
> + if [[ ${BUILDFILE:0:1} != "/" ]]; then
> + BUILDFILE="$startdir/$BUILDFILE"
> + fi
> + source_safe "$BUILDFILE"
> +fi
> +
> # override settings with an environment variable for batch processing
> BUILDDIR=${_BUILDDIR:-$BUILDDIR}
> BUILDDIR=${BUILDDIR:-$startdir} #default to $startdir if undefined
> @@ -2769,26 +2789,6 @@ else
> fi
> fi
>
> -unset pkgname pkgbase pkgver pkgrel epoch pkgdesc url license groups provides
> -unset md5sums replaces depends conflicts backup source install changelog build
> -unset makedepends optdepends options noextract
> -
> -BUILDFILE=${BUILDFILE:-$BUILDSCRIPT}
> -if [[ ! -f $BUILDFILE ]]; then
> - error "$(gettext "%s does not exist.")" "$BUILDFILE"
> - exit 1
> -else
> - if [[ $(<"$BUILDFILE") = *$'\r'* ]]; then
> - error "$(gettext "%s contains %s characters and cannot be sourced.")" "$BUILDFILE" "CRLF"
> - exit 1
> - fi
> -
> - if [[ ${BUILDFILE:0:1} != "/" ]]; then
> - BUILDFILE="$startdir/$BUILDFILE"
> - fi
> - source_safe "$BUILDFILE"
> -fi
> -
> # set defaults if they weren't specified in buildfile
> pkgbase=${pkgbase:-${pkgname[0]}}
> epoch=${epoch:-0}
>
More information about the pacman-dev
mailing list