1
0
mirror of https://github.com/moparisthebest/pacman synced 2025-01-12 14:28:03 -05:00

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>
This commit is contained in:
Dan McGee 2009-01-17 09:42:23 -06:00
parent fba5771fa4
commit 350c3eb6ec

View File

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