summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2009-01-17 09:42:23 -0600
committerDan McGee <dan@archlinux.org>2009-01-18 13:46:23 -0600
commit350c3eb6ec25b91b0402fa86422a7312ba7330d6 (patch)
treee77447c27225fdc045c25af6a94ce6959c3daa39 /scripts
parentfba5771fa4c774457531a4bbbcd66340c7c3fb6a (diff)
downloadpacman-350c3eb6ec25b91b0402fa86422a7312ba7330d6.tar.xz
makepkg: clean up test usage
In a lot of places, we had the following construct: [ "$foobar" = "0" ] which is better represented by using the integer tests: [ $foobar -eq 0 ] Attempt to unify makepkg to use the latter rather than the former in all places. From here on out we should ensure anything that is set to 0, 1, etc. uses the -eq format rather than =. In addition, fix a few other test anomalies including usage of double equals. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/makepkg.sh.in101
1 files changed, 51 insertions, 50 deletions
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 17210486..f9927bf0 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -129,7 +129,7 @@ error() {
# the fakeroot call, the error message will be printed by the main call.
##
trap_exit() {
- if [ "$INFAKEROOT" = "0" ]; then
+ if [ "$INFAKEROOT" -eq 0 ]; then
echo
error "$@"
fi
@@ -143,12 +143,12 @@ trap_exit() {
clean_up() {
local EXIT_CODE=$?
- if [ "$INFAKEROOT" = "1" ]; then
+ if [ "$INFAKEROOT" -eq 1 ]; then
# Don't clean up when leaving fakeroot, we're not done yet.
return
fi
- if [ $EXIT_CODE -eq 0 -a "$CLEANUP" = "1" ]; then
+ if [ $EXIT_CODE -eq 0 -a "$CLEANUP" -eq 1 ]; then
# If it's a clean exit and -c/--clean has been passed...
msg "$(gettext "Cleaning up...")"
rm -rf "$pkgdir" "$srcdir"
@@ -277,7 +277,7 @@ get_downloadclient() {
local i
for i in "${DLAGENTS[@]}"; do
local handler=$(echo $i | sed 's|::.*||')
- if [ "$proto" == "$handler" ]; then
+ if [ "$proto" = "$handler" ]; then
agent=$(echo $i | sed 's|^.*::||')
break
fi
@@ -353,16 +353,16 @@ handledeps() {
local deplist="$*"
- if [ "$DEP_BIN" = "0" ]; then
+ if [ "$DEP_BIN" -eq 0 ]; then
return $R_DEPS_MISSING
fi
- if [ "$DEP_BIN" = "1" ]; then
+ if [ "$DEP_BIN" -eq 1 ]; then
# install missing deps from binary packages (using pacman -S)
msg "$(gettext "Installing missing dependencies...")"
local ret=0
- if [ "$ASROOT" = 0 ]; then
+ if [ "$ASROOT" -eq 0 ]; then
sudo pacman $PACMAN_OPTS -S --asdeps $deplist || ret=$?
else
pacman $PACMAN_OPTS -S --asdeps $deplist || ret=$?
@@ -398,7 +398,7 @@ resolve_deps() {
# check deps again to make sure they were resolved
deplist="$(check_deps $*)"
[ "$deplist" = "" ] && return $R_DEPS_SATISFIED
- elif [ "$DEP_BIN" = "1" ]; then
+ elif [ "$DEP_BIN" -eq 1 ]; then
error "$(gettext "Failed to install all missing dependencies.")"
fi
@@ -414,7 +414,7 @@ resolve_deps() {
# fix flyspray bug #5923
remove_deps() {
# $pkgdeps is a GLOBAL variable, set by resolve_deps()
- [ "$RMDEPS" = "0" ] && return
+ [ "$RMDEPS" -eq 0 ] && return
[ "$pkgdeps" = "" ] && return
local dep depstrip deplist
@@ -426,7 +426,7 @@ remove_deps() {
msg "Removing installed dependencies..."
local ret=0
- if [ "$ASROOT" = "0" ]; then
+ if [ "$ASROOT" -eq 0 ]; then
sudo pacman $PACMAN_OPTS -Rns $deplist || ret=$?
else
pacman $PACMAN_OPTS -Rns $deplist || ret=$?
@@ -686,7 +686,7 @@ run_build() {
local shellopts=$(shopt -p)
local ret=0
- if [ "$LOGGING" = "1" ]; then
+ if [ "$LOGGING" -eq 1 ]; then
BUILDLOG="${startdir}/${pkgname}-${pkgver}-${pkgrel}-${CARCH}-build.log"
if [ -f "$BUILDLOG" ]; then
local i=1
@@ -736,7 +736,7 @@ run_package() {
export CFLAGS CXXFLAGS LDFLAGS MAKEFLAGS CHOST
local ret=0
- if [ "$LOGGING" = "1" ]; then
+ if [ "$LOGGING" -eq 1 ]; then
BUILDLOG="${startdir}/${nameofpkg}-${pkgver}-${pkgrel}-${CARCH}-package.log"
if [ -f "$BUILDLOG" ]; then
local i=1
@@ -785,7 +785,7 @@ tidy_install() {
msg2 "$(gettext "Purging other files...")"
local pt
for pt in "${PURGE_TARGETS[@]}"; do
- if [ "${pt}" == "${pt//\/}" ]; then
+ if [ "${pt}" = "${pt//\/}" ]; then
find . -type f -name "${pt}" -exec rm -f -- '{}' \;
else
rm -f ${pt}
@@ -881,7 +881,7 @@ create_package() {
# write the .PKGINFO file
msg2 "$(gettext "Generating .PKGINFO file...")"
echo "# Generated by makepkg $myver" >.PKGINFO
- if [ "$INFAKEROOT" = "1" ]; then
+ if [ "$INFAKEROOT" -eq 1 ]; then
echo "# using $(fakeroot -v)" >>.PKGINFO
fi
echo "# $(LC_ALL=C date -u)" >>.PKGINFO
@@ -1048,7 +1048,7 @@ create_xdelta() {
create_srcpackage() {
cd "$startdir"
- if [ "$SOURCEONLY" = "2" ]; then
+ if [ "$SOURCEONLY" -eq 2 ]; then
# get back to our src directory so we can begin with sources
mkdir -p "$srcdir"
cd "$srcdir"
@@ -1084,7 +1084,7 @@ create_srcpackage() {
if [ -f "$netfile" ]; then
msg2 "$(gettext "Adding %s...")" "$netfile"
ln -s "${startdir}/$netfile" "${srclinks}/${pkgname}"
- elif [ "$SOURCEONLY" = "2" -a -f "$SRCDEST/$file" ]; then
+ elif [ "$SOURCEONLY" -eq 2 -a -f "$SRCDEST/$file" ]; then
msg2 "$(gettext "Adding %s...")" "$file"
ln -s "$SRCDEST/$file" "${srclinks}/${pkgname}/"
fi
@@ -1112,9 +1112,9 @@ create_srcpackage() {
}
install_package() {
- [ "$INSTALL" = "0" ] && return
+ [ "$INSTALL" -eq 0 ] && return
msg "$(gettext "Installing package ${pkgname} with pacman -U...")"
- if [ "$ASROOT" = "0" ]; then
+ if [ "$ASROOT" -eq 0 ]; then
sudo pacman $PACMAN_OPTS -U $PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT} || exit $?
else
pacman $PACMAN_OPTS -U $PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT} || exit $?
@@ -1124,7 +1124,7 @@ install_package() {
devel_check() {
newpkgver=""
# Only update pkgver if --holdver is not set
- if [ "$HOLDVER" = "1" ]; then
+ if [ "$HOLDVER" -eq 1 ]; then
return
fi
# Cannot update pkgver/pkgrel if reading PKGBUILD from pipe
@@ -1453,13 +1453,13 @@ SRCDEST=${_SRCDEST:-$SRCDEST}
SRCDEST=${SRCDEST:-$startdir} #default to $startdir if undefined
-if [ "$HOLDVER" = "1" -a "$FORCE_VER" != "" ]; then
+if [ "$HOLDVER" -eq 1 -a "$FORCE_VER" != "" ]; then
# The '\\0' is here to prevent gettext from thinking --holdver is an option
error "$(gettext "\\0--holdver and --forcever cannot both be specified" )"
exit 1
fi
-if [ "$CLEANCACHE" = "1" ]; then
+if [ "$CLEANCACHE" -eq 1 ]; then
#fix flyspray feature request #5223
if [ -n "$SRCDEST" -a "$SRCDEST" != "$startdir" ]; then
msg "$(gettext "Cleaning up ALL files from %s.")" "$SRCDEST"
@@ -1495,14 +1495,14 @@ if [ -z "$BUILDSCRIPT" ]; then
exit 1
fi
-if [ "$INFAKEROOT" = "0" ]; then
- if [ $EUID -eq 0 -a "$ASROOT" = "0" ]; then
+if [ "$INFAKEROOT" -eq 0 ]; then
+ if [ $EUID -eq 0 -a "$ASROOT" -eq 0 ]; then
# Warn those who like to live dangerously.
error "$(gettext "Running makepkg as root is a BAD idea and can cause")"
plain "$(gettext "permanent, catastrophic damage to your system. If you")"
plain "$(gettext "wish to run as root, please use the --asroot option.")"
exit 1 # $E_USER_ABORT
- elif [ $EUID -gt 0 -a "$ASROOT" = "1" ]; then
+ elif [ $EUID -gt 0 -a "$ASROOT" -eq 1 ]; then
# Warn those who try to use the --asroot option when they are not root
error "$(gettext "The --asroot option is meant for the root user only.")"
plain "$(gettext "Please rerun makepkg without the --asroot flag.")"
@@ -1527,8 +1527,8 @@ else
fi
# check for sudo if we will need it during makepkg execution
-if [ "$ASROOT" = "0" \
- -a \( "$DEP_BIN" = "1" -o "$RMDEPS" = "1" -o "$INSTALL" = "1" \) ]; then
+if [ "$ASROOT" -eq 0 \
+ -a \( "$DEP_BIN" -eq 1 -o "$RMDEPS" -eq 1 -o "$INSTALL" -eq 1 \) ]; then
if [ ! "$(type -p sudo)" ]; then
error "$(gettext "Cannot find the sudo binary! Is sudo installed?")"
plain "$(gettext "Missing dependencies cannot be installed or removed as a normal user")"
@@ -1559,7 +1559,7 @@ fi
source "$BUILDSCRIPT"
-if [ "$GENINTEG" = "1" ]; then
+if [ "$GENINTEG" -eq 1 ]; then
mkdir -p "$srcdir"
cd "$srcdir"
download_sources
@@ -1567,7 +1567,7 @@ if [ "$GENINTEG" = "1" ]; then
exit 0 # $E_OK
fi
-if [ "$(type -t package)" == "function" ]; then
+if [ "$(type -t package)" = "function" ]; then
PKGFUNC=1
fi
@@ -1602,7 +1602,7 @@ if [ "$arch" = 'any' ]; then
fi
if ! in_array $CARCH ${arch[@]}; then
- if [ "$IGNOREARCH" = "0" ]; then
+ if [ "$IGNOREARCH" -eq 0 ]; then
error "$(gettext "%s is not available for the '%s' architecture.")" "$pkgname" "$CARCH"
plain "$(gettext "Note that many packages may need a line added to their %s")" "$BUILDSCRIPT"
plain "$(gettext "such as arch=('%s').")" "$CARCH"
@@ -1650,8 +1650,8 @@ devel_check
devel_update
if [ -f "$PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT}" \
- -a "$FORCE" = "0" -a "$SOURCEONLY" = "0" -a "$NOBUILD" = "0" ]; then
- if [ "$INSTALL" = "1" ]; then
+ -a "$FORCE" -eq 0 -a "$SOURCEONLY" -eq 0 -a "$NOBUILD" -eq 0 ]; then
+ if [ "$INSTALL" -eq 1 ]; then
warning "$(gettext "A package has already been built, installing existing package...")"
install_package
exit $?
@@ -1662,10 +1662,10 @@ if [ -f "$PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT}" \
fi
# Run the bare minimum in fakeroot
-if [ "$INFAKEROOT" = "1" ]; then
- if [ "$SPLITPKG" = "0" ]; then
- if [ "$PKGFUNC" = "0" ]; then
- if [ "$REPKG" = "0" ]; then
+if [ "$INFAKEROOT" -eq 1 ]; then
+ if [ "$SPLITPKG" -eq 0 ]; then
+ if [ "$PKGFUNC" -eq 0 ]; then
+ if [ "$REPKG" -eq 0 ]; then
run_build
fi
else
@@ -1693,9 +1693,9 @@ fi
msg "$(gettext "Making package: %s")" "$pkgname $pkgver-$pkgrel $CARCH ($(date))"
# if we are creating a source-only package, go no further
-if [ "$SOURCEONLY" != "0" ]; then
+if [ "$SOURCEONLY" -ne 0 ]; then
if [ -f "$PKGDEST/${pkgname}-${pkgver}-${pkgrel}${SRCEXT}" \
- -a "$FORCE" = "0" ]; then
+ -a "$FORCE" -eq 0 ]; then
error "$(gettext "A package has already been built. (use -f to overwrite)")"
exit 1
fi
@@ -1705,9 +1705,9 @@ if [ "$SOURCEONLY" != "0" ]; then
fi
# fix flyspray bug #5973
-if [ "$NODEPS" = "1" -o "$NOBUILD" = "1" -o "$REPKG" = "1" ]; then
+if [ "$NODEPS" -eq 1 -o "$NOBUILD" -eq 1 -o "$REPKG" -eq 1 ]; then
# no warning message needed for nobuild, repkg
- if [ "$NODEPS" = "1" ]; then
+ if [ "$NODEPS" -eq 1 ]; then
warning "$(gettext "Skipping dependency checks.")"
fi
elif [ $(type -p pacman) ]; then
@@ -1735,18 +1735,18 @@ umask 0022
mkdir -p "$srcdir"
cd "$srcdir"
-if [ "$NOEXTRACT" = "1" ]; then
+if [ "$NOEXTRACT" -eq 1 ]; then
warning "$(gettext "Skipping source retrieval -- using existing src/ tree")"
warning "$(gettext "Skipping source integrity checks -- using existing src/ tree")"
warning "$(gettext "Skipping source extraction -- using existing src/ tree")"
- if [ "$NOEXTRACT" = "1" -a "$(ls "$srcdir" 2>/dev/null)" = "" ]; then
+ if [ "$NOEXTRACT" -eq 1 -a "$(ls "$srcdir" 2>/dev/null)" = "" ]; then
error "$(gettext "The source directory is empty, there is nothing to build!")"
plain "$(gettext "Aborting...")"
exit 1
fi
-elif [ "$REPKG" = "1" ]; then
- if [ "$PKGFUNC" = "0" -a "$SPLITPKG" = "0" \
+elif [ "$REPKG" -eq 1 ]; then
+ if [ "$PKGFUNC" -eq 0 -a "$SPLITPKG" -eq 0 \
-a \( ! -d "$pkgdir" -o "$(ls "$pkgdir" 2>/dev/null)" = "" \) ]; then
error "$(gettext "The package directory is empty, there is nothing to repackage!")"
plain "$(gettext "Aborting...")"
@@ -1758,12 +1758,13 @@ else
extract_sources
fi
-if [ "$NOBUILD" = "1" ]; then
+if [ "$NOBUILD" -eq 1 ]; then
msg "$(gettext "Sources are ready.")"
exit 0 #E_OK
else
# check for existing pkg directory; don't remove if we are repackaging
- if [ -d "$pkgdir" -a \( "$REPKG" = "0" -o "$PKGFUNC" = "1" -o "$SPLITPKG" = "1" \) ]; then
+ if [ -d "$pkgdir" \
+ -a \( "$REPKG" -eq 0 -o "$PKGFUNC" -eq 1 -o "$SPLITPKG" -eq 1 \) ]; then
msg "$(gettext "Removing existing pkg/ directory...")"
rm -rf "$pkgdir"
fi
@@ -1772,15 +1773,15 @@ else
# if we are root or if fakeroot is not enabled, then we don't use it
if [ "$(check_buildenv fakeroot)" != "y" -o $EUID -eq 0 ]; then
- if [ "$REPKG" = "0" ]; then
+ if [ "$REPKG" -eq 0 ]; then
devel_update
run_build
fi
- if [ "$SPLITPKG" = "0" ]; then
- if [ "$PKGFUNC" = "1" ]; then
+ if [ "$SPLITPKG" -eq 0 ]; then
+ if [ "$PKGFUNC" -eq 1 ]; then
run_package
tidy_install
- elif [ "$REPKG" = "0" ]; then
+ elif [ "$REPKG" -eq 0 ]; then
tidy_install
fi
create_package
@@ -1797,7 +1798,7 @@ else
done
fi
else
- if [ "$REPKG" = "0" -a \( "$PKGFUNC" == "1" -o "$SPLITPKG" = "1" \) ]; then
+ if [ "$REPKG" -eq 0 -a \( "$PKGFUNC" -eq 1 -o "$SPLITPKG" -eq 1 \) ]; then
devel_update
run_build
cd "$startdir"