Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2007-02-04 18:28:21 +0000
committerDan McGee <dan@archlinux.org>2007-02-04 18:28:21 +0000
commitb1cc72ebb3226f300c7432b742b05942f050532f (patch)
treeaa846f0393ddedb482667a8ce064f49bb25ee2f2 /scripts
parent1bb3cd34bfc8c00809e42b4ff084f56b59093fb5 (diff)
* Updated makepkg to use a new form of options. These two arrays now replace
most of the former options in makepkg.conf, and are described in detail there: BUILDENV=(fakeroot !distcc color !ccache) OPTIONS=(strip !docs !libtool emptydirs) Note that PKGBUILD specified options will always have final say. They will now be specified as they are above, except using lowercase 'options' array. * makepkg was fixed so options actually work as expected.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/makepkg82
1 files changed, 61 insertions, 21 deletions
diff --git a/scripts/makepkg b/scripts/makepkg
index ec1b2267..b5732433 100755
--- a/scripts/makepkg
+++ b/scripts/makepkg
@@ -32,7 +32,7 @@ BUILDSCRIPT="PKGBUILD"
PKGEXT="pkg.tar.gz"
source "/etc/abs/abs.conf"
-SRCROOT=$ABSROOT
+SRCROOT="$ABSROOT"
# Options
CLEANUP=0
@@ -63,7 +63,7 @@ fi
### SUBROUTINES ###
plain() {
- if [ "$USE_COLOR" = "Y" -o "$USE_COLOR" = "y" ]; then
+ if [ ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then
echo -e " \033[1;1m$1\033[1;0m" >&2
else
echo " $1" >&2
@@ -71,7 +71,7 @@ plain() {
}
msg() {
- if [ "$USE_COLOR" = "Y" -o "$USE_COLOR" = "y" ]; then
+ if [ ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then
echo -e "\033[1;32m==>\033[1;0m \033[1;1m$1\033[1;0m" >&2
else
echo "==> $1" >&2
@@ -79,7 +79,7 @@ msg() {
}
msg2() {
- if [ "$USE_COLOR" = "Y" -o "$USE_COLOR" = "y" ]; then
+ if [ ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then
echo -e " \033[1;34m->\033[1;0m \033[1;1m$1\033[1;0m" >&2
else
echo " -> $1" >&2
@@ -87,7 +87,7 @@ msg2() {
}
warning() {
- if [ "$USE_COLOR" = "Y" -o "$USE_COLOR" = "y" ]; then
+ if [ ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then
echo -e "\033[1;33m==> WARNING:\033[1;0m \033[1;1m$1\033[1;0m" >&2
else
echo "==> WARNING: $1" >&2
@@ -95,7 +95,7 @@ warning() {
}
error() {
- if [ "$USE_COLOR" = "Y" -o "$USE_COLOR" = "y" ]; then
+ if [ ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then
echo -e "\033[1;31m==> ERROR:\033[1;0m \033[1;1m$1\033[1;0m" >&2
else
echo "==> ERROR: $1" >&2
@@ -106,16 +106,54 @@ strip_url() {
echo "$1" | sed 's|^.*://.*/||g'
}
+# checks to see if options are present in makepkg.conf or PKGBUILD;
+# PKGBUILD options always take precedence
check_option() {
+ local needle=$(echo $1 | tr [:upper:] [:lower:])
local i
+ # loop PKGBUILD opts first so it overrides makepkg.conf
for i in ${options[@]}; do
- local uc=$(echo $i | tr [:lower:] [:upper:])
local lc=$(echo $i | tr [:upper:] [:lower:])
- if [ "$uc" = "$1" -o "$lc" = "$1" ]; then
- echo $1
+ if [ "$lc" = "$needle" ]; then
+ echo "y"
+ return
+ elif [ "$lc" = "!$needle" ]; then
+ echo "n"
+ return
+ fi
+ done
+ # fall back to makepkg.conf options
+ for i in ${OPTIONS[@]}; do
+ local lc=$(echo $i | tr [:upper:] [:lower:])
+ if [ "$lc" = "$needle" ]; then
+ echo "y"
+ return
+ elif [ "$lc" = "!$needle" ]; then
+ echo "n"
+ return
+ fi
+ done
+ echo "unknown"
+ return
+}
+
+# check if option is present in BUILDENV
+check_buildenv() {
+ local needle=$(echo $1 | tr [:upper:] [:lower:])
+ local i
+ # use options from makepkg.conf
+ for i in ${BUILDENV[@]}; do
+ local lc=$(echo $i | tr [:upper:] [:lower:])
+ if [ "$lc" = "$needle" ]; then
+ echo "y"
+ return
+ elif [ "$lc" = "!$needle" ]; then
+ echo "n"
return
fi
done
+ echo "unknown"
+ return
}
in_array() {
@@ -123,7 +161,7 @@ in_array() {
shift 1
[ -z "$1" ] && return 1
for i in $*; do
- [ "$i" == "$needle" ] && return 0
+ [ "$i" = "$needle" ] && return 0
done
return 1
}
@@ -347,7 +385,7 @@ while [ "$#" -ne "0" ]; do
--syncdeps) DEP_BIN=1 ;;
--sudosync) DEP_SUDO=1 ;;
--builddeps) DEP_SRC=1 ;;
- --noccache) USE_CCACHE=0 ;;
+ --noccache) USE_CCACHE="n" ;;
--nodeps) NODEPS=1 ;;
--noextract) NOEXTRACT=1 ;;
--install) INSTALL=1 ;;
@@ -370,7 +408,7 @@ while [ "$#" -ne "0" ]; do
while getopts "bBcCdefghij:Lmop:rRsS-" opt; do
case $opt in
b) DEP_SRC=1 ;;
- B) USE_CCACHE=0 ;;
+ B) USE_CCACHE="n" ;;
c) CLEANUP=1 ;;
C) CLEANCACHE=1 ;;
d) NODEPS=1 ;;
@@ -498,7 +536,7 @@ fi
# Enter the fakeroot environment if necessary. This will call the makepkg script again
# as the fake root user. We detect this by passing a sentinel option (-F) to makepkg
if [ "$EUID" != "0" ]; then
- if [ "$USE_FAKEROOT" = "y" -o "$USE_FAKEROOT" = "Y" ]; then
+ if [ "$(check_buildenv fakeroot)" = "y" ]; then
if [ $(type -p fakeroot) ]; then
msg "Entering fakeroot environment"
fakeroot -- $0 -F $ARGLIST
@@ -514,7 +552,7 @@ if [ "$EUID" != "0" ]; then
else
warning "Running makepkg as an unprivileged user will result in non-root"
plain "ownership of the packaged files. Try using the fakeroot"
- plain "environment. (USE_FAKEROOT=y in makepkg.conf)"
+ plain "environment. ('fakeroot' in BUILDENV in makepkg.conf)"
plain ""
sleep 1
fi
@@ -746,12 +784,13 @@ else
mkdir -p $startdir/pkg
# use distcc if requested
- if [ "$USE_DISTCC" = "y" ]; then
+ if [ "$(check_buildenv distcc)" = "y" ]; then
[ -d /usr/lib/distcc/bin ] && export PATH=/usr/lib/distcc/bin:$PATH
fi
# use ccache if it's available
- if [ "$USE_CCACHE" = "1" ]; then
+ # USE_CCACHE still here because it is a command line option
+ if [ ! "$USE_CCACHE" = "n" -a "$(check_buildenv ccache)" = "y" ]; then
[ -d /usr/lib/ccache/bin ] && export PATH=/usr/lib/ccache/bin:$PATH
fi
@@ -799,7 +838,7 @@ else
fi
fi
-if [ ! "$(check_option KEEPDOCS)" -a "$KEEPDOCS" = "0" ]; then
+if [ "$(check_option docs)" = "n" ]; then
# remove info/doc files
msg "Removing info/doc files..."
cd $startdir/pkg
@@ -833,7 +872,7 @@ done
cd $startdir
# strip binaries
-if [ ! "$(check_option NOSTRIP)" -a "$NOSTRIP" = "0" ]; then
+if [ "$(check_option strip)" = "y" ]; then
msg "Stripping debugging symbols from libraries..."
find pkg/{,usr,usr/local,opt/*}/lib -type f -not -name "*.dll" -not -name "*.exe" \
-exec /usr/bin/strip --strip-debug '{}' \; 2>&1 \
@@ -845,15 +884,16 @@ if [ ! "$(check_option NOSTRIP)" -a "$NOSTRIP" = "0" ]; then
fi
# remove libtool (.la) files
-if [ "$(check_option NOLIBTOOL)" -a "$NOLIBTOOL" = "1" ]; then
+if [ "$(check_option libtool)" = "n" ]; then
msg "Removing libtool .la files..."
find pkg -type f -name "*.la" -exec rm -f -- '{}' \;
fi
# remove empty directories
-if [ "$(check_option NOEMPTYDIRS)" -a "$NOEMPTYDIRS" = 1 ]; then
+if [ "$(check_option emptydirs)" = "n" ]; then
msg "Removing empty directories..."
- find pkg -depth -type d -empty -delete;
+ cd "$startdir/pkg"
+ find -depth -type d -empty -delete;
fi
# get some package meta info