[pacman-dev] [PATCH] makepkg: Put script sourcing before var validation
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@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. 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} -- 1.8.3.1.448.gfb7dfaa
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@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}
On Thu, Jun 20, 2013 at 09:03:57PM +1000, Allan McRae wrote:
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@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.
Just some quick re-reading of this, and the build scripts are sourced before setting srcdir and pkgdir without this. I just wasn't thinking. Thanks, -- William Giokas | KaiSforza | http://kaictl.net/ GnuPG Key: 0x73CD09CF Fingerprint: F73F 50EF BBE2 9846 8306 E6B8 6902 06D8 73CD 09CF
participants (2)
-
Allan McRae
-
William Giokas