summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Reynolds <fauno@kiwwwi.com.ar>2012-01-22 23:32:00 -0300
committerNicolas Reynolds <fauno@kiwwwi.com.ar>2012-01-22 23:32:00 -0300
commit0f72189f9a62af346592ce54a55810f973d8d7ed (patch)
tree25616354e16a021f6fef2e895fc69ec0af9116be
parent787ef61e1997deeda97e055f7f0fe27a1b7ab2b5 (diff)
Quicker is_built, only one call to pacman
time shows this version is 1s long against 5s from before
-rwxr-xr-x[-rw-r--r--]fullpkg-find2
-rwxr-xr-xis_built31
-rwxr-xr-xtreepkg5
3 files changed, 25 insertions, 13 deletions
diff --git a/fullpkg-find b/fullpkg-find
index d253913..8c0c063 100644..100755
--- a/fullpkg-find
+++ b/fullpkg-find
@@ -47,7 +47,7 @@ find_deps() {
fi
fi
- if is_built "${pkgbase}>=${fullver}"; then
+ if is_built "${pkgbase}" "${fullver}"; then
exit 0 # pkg is built and updated
fi
diff --git a/is_built b/is_built
index 60f24e9..c01ad53 100755
--- a/is_built
+++ b/is_built
@@ -2,9 +2,10 @@
usage() {
echo "$0 "
echo
- echo "Detect is a package is installed or in a database"
+ echo "Detect if a given package version is already in repos"
+ echo "Assuming you want greater or equal"
echo
- echo "Example usage: is_built \"pcre>=20\""
+ echo "Example usage: is_built 'pcre' '20'"
}
while getopts 'h' arg; do
@@ -14,12 +15,24 @@ while getopts 'h' arg; do
esac
done
-# Checks for package, if -T returns non-zero output, egrep will return 0
-# because it finds it, so we negate the value to say it's not built.
-# -Sp works backwards, it will print output only when the package already
-# exists
+set -x
-!(sudo pacman -T "$1" | egrep "*" >/dev/null) || \
-sudo pacman -Sp "$1" --print-format "%n-%v" 2>/dev/null | egrep "*" >/dev/null
+ver=${2}
+pkg=${1}
+pver=$(LC_ALL=C pacman -Sp --print-format "%v" "${pkg}" 2>/dev/null)
-exit $?
+# if pacman fails or returns nothing
+r=$?
+[ "${pver}" = " there is nothing to do" ] && r=1
+
+result=$(vercmp "${pver}" "${ver}")
+
+# if vercmp > 1 means our version is bigger
+if [ ${result} -ge 0 -a ${r} -eq 0 ]; then
+ exit 0
+else
+ exit 1
+fi
+
+# just in case
+exit 1
diff --git a/treepkg b/treepkg
index 622b979..ccabe20 100755
--- a/treepkg
+++ b/treepkg
@@ -83,7 +83,7 @@ BUILD=${B:-true}
touch "${BUILDORDER}"
# If this package is already built quit silently
-if is_built "${pkgbase}>=${fullver}"; then
+if is_built "${pkgbase}" "${fullver}"; then
add_order "ignore"
exit 0
fi
@@ -132,14 +132,13 @@ done
# Only build at the end
if [ ${DEPTH} -eq 0 ]; then
+ ${VERBOSE} && msg "Starting build" || true
-# TODO fill this var with a flag
if ${BUILD}; then
${VERBOSE} && msg "Build tree stored in ${BUILDORDER}" || true
# Build everything sorting the build dir
# The reverse order ensures we start by the deepest packages
- ${VERBOSE} && msg "Starting build" || true
for _pkg in $(ls -r "${BUILDDIR}"); do
# Ignore if there's no PKGBUILD
if [ ! -f "${BUILDDIR}/${_pkg}/PKGBUILD" ]; then continue; fi