summaryrefslogtreecommitdiffstats
path: root/scripts/pkgdelta.sh.in
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2012-04-26 04:28:39 +0200
committerDan McGee <dan@archlinux.org>2012-06-26 06:39:28 +0200
commitab8431c92953c4562af214e5170f8ef321037108 (patch)
treed1f0fdc0556d60648ff44be0217c3c57e25cdfaf /scripts/pkgdelta.sh.in
parentb58489d29a1898a4bff1b5da6ca4bfb14003dbfe (diff)
downloadpacman-ab8431c92953c4562af214e5170f8ef321037108.tar.gz
pacman-ab8431c92953c4562af214e5170f8ef321037108.tar.xz
pkgdelta: use human_to_size to parse --min-pkg-size
Update the documentation accordingly to mention that users can expect huamn readable sizes to be acceptable. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Diffstat (limited to 'scripts/pkgdelta.sh.in')
-rw-r--r--scripts/pkgdelta.sh.in13
1 files changed, 7 insertions, 6 deletions
diff --git a/scripts/pkgdelta.sh.in b/scripts/pkgdelta.sh.in
index 03193667..3d80261f 100644
--- a/scripts/pkgdelta.sh.in
+++ b/scripts/pkgdelta.sh.in
@@ -54,8 +54,8 @@ This delta file can then be added to a database using repo-add.\n\n")"
echo
printf -- "$(gettext "Options:\n")"
printf -- "$(gettext " -q, --quiet minimize output\n")"
- printf -- "$(gettext " --min-pkg-size minimum package size before deltas are generated (bytes)\n")"
- printf -- "$(gettext " --max-delta-size percent of package size above which deltas will be discarded\n")"
+ printf -- "$(gettext " --min-pkg-size minimum package size before deltas are generated\n")"
+ printf -- "$(gettext " --max-delta-size percent of new package above which the delta will be discarded\n")"
}
version() {
@@ -66,6 +66,8 @@ This is free software; see the source for copying conditions.\n\
There is NO WARRANTY, to the extent permitted by law.\n")"
}
+m4_include(library/human_to_size.sh)
+
isnumeric() {
[[ $1 != *[!0-9]* ]]
}
@@ -176,15 +178,14 @@ while :; do
-q|--quiet)
QUIET=1;;
--min-pkg-size)
- if ! isnumeric "$2"; then
+ if ! min_pkg_size=$(human_to_size "$2"); then
echo "invalid argument '$2' for option -- '$1'"
exit 1
fi
- min_pkg_size=$2
shift ;;
--max-delta-size)
- arg=$(echo "$2" | awk '{print $1 * 100}')
- if ! isnumeric "$arg" || (($arg > 200)); then
+ arg=$(awk -v val="$2" 'BEGIN { print val * 100 }')
+ if ! isnumeric "$arg" || (( arg > 200 )); then
echo "invalid argument '$2' for option -- '$1'"
exit 1
fi