summaryrefslogtreecommitdiff
path: root/scripts/makepkg.sh.in
diff options
context:
space:
mode:
authorAllan McRae <allan@archlinux.org>2009-07-12 17:10:11 +1000
committerAllan McRae <allan@archlinux.org>2009-07-12 17:32:57 +1000
commit5dc0b80c2683551c10b96157ba34b277db25b82d (patch)
tree904168141a5bf70904f6a90ae70fccbed55f1036 /scripts/makepkg.sh.in
parent104daa16a69708c9b16fc59ac895f2932ea509d4 (diff)
downloadpacman-5dc0b80c2683551c10b96157ba34b277db25b82d.tar.xz
makepkg: clean up BUILDSCRIPT usage
FS#15448 (which is made worse by the "fix" for FS#14727...), highlighted some deficiencies in the usage of the BUILDSCRIPT variable. In particular, only relative paths worked with "-p" and some output was very strange in combination with the "-p" flag or reading from /dev/stdin. e.g. "Please add a license line to your /dev/stdin!". This patch adds a new variable, BUILDFILE, which contains the full path to the BUILDSCRIPT. This defaults to $startdir/$BUILDSCRIPT. Also, fix a missed quoting of $BUILD{SCRIPT->FILE} and remove warning about missing BUILDSCRIPT definition in makepkg.conf as the default BUILDSCRIPT value is now specified during configure. Add check that BUILDFILE is writable before updating VCS PKGBUILDs. When making a source package, the BUILDSCRIPT always gets given the default name, regardless of what it was originally called. Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'scripts/makepkg.sh.in')
-rw-r--r--scripts/makepkg.sh.in40
1 files changed, 20 insertions, 20 deletions
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 8998e0da..50cf54d1 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -1032,7 +1032,7 @@ create_srcpackage() {
mkdir "${srclinks}"/${pkgbase}
msg2 "$(gettext "Adding %s...")" "$BUILDSCRIPT"
- ln -s "${startdir}/${BUILDSCRIPT}" "${srclinks}/${pkgbase}/"
+ ln -s "${BUILDFILE}" "${srclinks}/${pkgbase}/${BUILDSCRIPT}"
if [ -n "$install" ]; then
if [ -f $install ]; then
@@ -1192,8 +1192,9 @@ devel_check() {
newpkgver=""
# Do not update pkgver if --holdver is set, when building a source package,
- # or when reading PKGBUILD from pipe
- if [ "$HOLDVER" -eq 1 -o "$SOURCEONLY" -ne 0 -o ! -f "./$BUILDSCRIPT" ]; then
+ # when reading PKGBUILD from pipe (-f), or if we cannot write to the file (-w)
+ if [ "$HOLDVER" -eq 1 -o "$SOURCEONLY" -ne 0 -o ! -f "$BUILDFILE" \
+ -o ! -w "$BUILDFILE" ]; then
return
fi
@@ -1262,10 +1263,10 @@ devel_update() {
#
if [ -n "$newpkgver" ]; then
if [ "$newpkgver" != "$pkgver" ]; then
- if [ -f "./$BUILDSCRIPT" ]; then
- @SEDINPLACE@ "s/^pkgver=[^ ]*/pkgver=$newpkgver/" "./$BUILDSCRIPT"
- @SEDINPLACE@ "s/^pkgrel=[^ ]*/pkgrel=1/" "./$BUILDSCRIPT"
- source "$BUILDSCRIPT"
+ if [ -f "$BUILDFILE" -a -w "$BUILDFILE" ]; then
+ @SEDINPLACE@ "s/^pkgver=[^ ]*/pkgver=$newpkgver/" "$BUILDFILE"
+ @SEDINPLACE@ "s/^pkgrel=[^ ]*/pkgrel=1/" "$BUILDFILE"
+ source "$BUILDFILE"
fi
fi
fi
@@ -1480,7 +1481,7 @@ while true; do
-L|--log) LOGGING=1 ;;
-m|--nocolor) USE_COLOR='n' ;;
-o|--nobuild) NOBUILD=1 ;;
- -p) shift; BUILDSCRIPT=$1 ;;
+ -p) shift; BUILDFILE=$1 ;;
-r|--rmdeps) RMDEPS=1 ;;
-R|--repackage) REPKG=1 ;;
--source) SOURCEONLY=1 ;;
@@ -1565,11 +1566,6 @@ if [ "$CLEANCACHE" -eq 1 ]; then
fi
fi
-if [ -z "$BUILDSCRIPT" ]; then
- error "$(gettext "BUILDSCRIPT is undefined! Ensure you have updated %s.")" "$MAKEPKG_CONF"
- exit 1
-fi
-
if [ "$INFAKEROOT" -eq 0 ]; then
if [ $EUID -eq 0 -a "$ASROOT" -eq 0 ]; then
# Warn those who like to live dangerously.
@@ -1616,23 +1612,27 @@ unset pkgname pkgbase pkgver pkgrel pkgdesc url license groups provides
unset md5sums replaces depends conflicts backup source install build
unset makedepends optdepends options noextract
-if [ ! -f "$BUILDSCRIPT" ]; then
+BUILDFILE=${BUILDFILE:-$BUILDSCRIPT}
+if [ ! -f "$BUILDFILE" ]; then
if [ -t 0 ]; then
- error "$(gettext "%s does not exist.")" "$BUILDSCRIPT"
+ error "$(gettext "%s does not exist.")" "$BUILDFILE"
exit 1
else
# PKGBUILD passed through a pipe
- BUILDSCRIPT=/dev/stdin
- source "$BUILDSCRIPT"
+ BUILDFILE=/dev/stdin
+ source "$BUILDFILE"
fi
else
- crlftest=$(file $BUILDSCRIPT | grep -F 'CRLF' || true)
+ crlftest=$(file "$BUILDFILE" | grep -F 'CRLF' || true)
if [ -n "$crlftest" ]; then
- error "$(gettext "%s contains CRLF characters and cannot be sourced.")" "$BUILDSCRIPT"
+ error "$(gettext "%s contains CRLF characters and cannot be sourced.")" "$BUILDFILE"
exit 1
fi
- source ./"$BUILDSCRIPT"
+ if [ "${BUILDFILE:0:1}" != "/" ]; then
+ BUILDFILE="$startdir/$BUILDFILE"
+ fi
+ source "$BUILDFILE"
fi
if [ "$GENINTEG" -eq 1 ]; then