[pacman-dev] [PATCH] makepkg: Put script sourcing before var validation

William Giokas 1007380 at gmail.com
Thu Jun 20 05:32:27 EDT 2013


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.

 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



More information about the pacman-dev mailing list