FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux Pacman Development

 
 
LinkBack Thread Tools
 
Old 04-06-2012, 10:07 PM
Florian Pritz
 
Default pkgdelta: implement requirments for delta generation

Big deltas or deltas for very small packages are not needed so we should
check that and not generate any.

Signed-off-by: Florian Pritz <bluewind@xinu.at>
---
This now checks for numeric values as per Dave suggestion.

scripts/pkgdelta.sh.in | 51 +++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 48 insertions(+), 3 deletions(-)

diff --git a/scripts/pkgdelta.sh.in b/scripts/pkgdelta.sh.in
index 0986986..da5d7c9 100644
--- a/scripts/pkgdelta.sh.in
+++ b/scripts/pkgdelta.sh.in
@@ -30,6 +30,13 @@ declare -r myver='@PACKAGE_VERSION@'

QUIET=0

+# minimal of package before deltas are generated (bytes)
+min_pkg_size=$((1024*1024))
+
+# percent of new package above which the delta will be discarded
+max_delta_size=80
+
+
# ensure we have a sane umask set
umask 0022

@@ -46,6 +53,8 @@ This delta file can then be added to a database using repo-add.

")"
echo
printf -- "$(gettext "Options:
")"
printf -- " -q ""$(gettext "quiet
")"
+ printf -- " --min-pkg-size ""$(gettext "minimal of package before deltas are generated (bytes)
")"
+ printf -- " --max-delta-size ""$(gettext "percent of new package above which the delta will be discarded
")"
}

version() {
@@ -56,6 +65,10 @@ This is free software; see the source for copying conditions.

There is NO WARRANTY, to the extent permitted by law.
")"
}

+isnumeric() {
+ [[ $1 != *[!0-9]* ]]
+}
+
read_pkginfo()
{
pkgname= pkgver= arch=
@@ -96,6 +109,13 @@ create_xdelta()
newver="$pkgver"
newarch="$arch"

+ pkgsize="$(@SIZECMD@ -L "$newfile")"
+
+ if ((pkgsize < min_pkg_size)); then
+ msg "$(gettext "Ignoring small package: %s")" "$pkgsize"
+ return 0
+ fi
+
if [[ $oldname != "$newname" ]]; then
error "$(gettext "The package names don't match : '%s' and '%s'")" "$oldname" "$newname"
return 1
@@ -119,10 +139,19 @@ create_xdelta()
if (( ret )); then
error "$(gettext "Delta could not be created.")"
return 1
- else
- msg "$(gettext "Generated delta : '%s'")" "$deltafile"
- (( QUIET )) && echo "$deltafile"
fi
+
+ deltasize="$(@SIZECMD@ -L "$deltafile")"
+
+ if ((max_delta_size * pkgsize / 100 < deltasize)); then
+ msg "$(gettext "Ignoring big delta: %s vs %s")" "$deltasize" "$pkgsize"
+ rm -f "$deltafile"
+ return 0
+ fi
+
+ msg "$(gettext "Generated delta : '%s'")" "$deltafile"
+ (( QUIET )) && echo "$deltafile"
+
return 0
}

@@ -134,6 +163,22 @@ while (( $# )); do
-h|--help) usage; exit 0 ;;
-V|--version) version; exit 0 ;;
-q|--quiet) QUIET=1;;
+ --min-pkg-size)
+ if ! isnumeric "$2"; then
+ echo "invalid argument '$2' for option -- '$1'"
+ exit 1
+ fi
+ min_pkg_size=$2
+ shift
+ ;;
+ --max-delta-size)
+ if ! isnumeric "$2"; then
+ echo "invalid argument '$2' for option -- '$1'"
+ exit 1
+ fi
+ max_delta_size=$2
+ shift
+ ;;
--) shift; args+=("$@"); break 2 ;;
-*) echo "invalid option -- '$1'"; usage; exit 1 ;;
*) args+=("$1");;
--
1.7.9.6
 
Old 04-07-2012, 12:28 PM
Florian Pritz
 
Default pkgdelta: implement requirments for delta generation

Big deltas or deltas for very small packages are not needed so we should
check that and not generate any.

Signed-off-by: Florian Pritz <bluewind@xinu.at>
---
doc/pkgdelta.8.txt | 12 ++++++++++-
scripts/pkgdelta.sh.in | 52 +++++++++++++++++++++++++++++++++++++++++++++---
2 files changed, 60 insertions(+), 4 deletions(-)

diff --git a/doc/pkgdelta.8.txt b/doc/pkgdelta.8.txt
index 3804c5d..5913dba 100644
--- a/doc/pkgdelta.8.txt
+++ b/doc/pkgdelta.8.txt
@@ -11,7 +11,7 @@ pkgdelta - package delta generation utility

Synopsis
--------
-'pkgdelta' [-q] <package1> <package2>
+'pkgdelta' [options] <package1> <package2>


Description
@@ -27,6 +27,16 @@ significantly.

Options
-------
+*--max-delta-size <ratio>*::
+ Only create delta files if the delta is smaller than ratio * package_size.
+ Possible values: 0.0 to 2.0.
+ Recommended values: 0.2 to 0.9.
+ Default value: 0.7
+
+*--min-pkg-size <size>*::
+ Minimal size of the package file in bytes to be considered for delta creation.
+ Default value: 1048576 bytes = 1MiB
+
*-q, --quiet*::
Be quiet. Do not output anything but warnings and errors.

diff --git a/scripts/pkgdelta.sh.in b/scripts/pkgdelta.sh.in
index 0986986..f76d1ca 100644
--- a/scripts/pkgdelta.sh.in
+++ b/scripts/pkgdelta.sh.in
@@ -30,6 +30,13 @@ declare -r myver='@PACKAGE_VERSION@'

QUIET=0

+# minimal of package before deltas are generated (bytes)
+min_pkg_size=$((1024*1024))
+
+# percent of new package above which the delta will be discarded
+max_delta_size=70
+
+
# ensure we have a sane umask set
umask 0022

@@ -46,6 +53,8 @@ This delta file can then be added to a database using repo-add.

")"
echo
printf -- "$(gettext "Options:
")"
printf -- " -q ""$(gettext "quiet
")"
+ printf -- " --min-pkg-size ""$(gettext "minimal of package before deltas are generated (bytes)
")"
+ printf -- " --max-delta-size ""$(gettext "percent of new package above which the delta will be discarded
")"
}

version() {
@@ -56,6 +65,10 @@ This is free software; see the source for copying conditions.

There is NO WARRANTY, to the extent permitted by law.
")"
}

+isnumeric() {
+ [[ $1 != *[!0-9]* ]]
+}
+
read_pkginfo()
{
pkgname= pkgver= arch=
@@ -96,6 +109,13 @@ create_xdelta()
newver="$pkgver"
newarch="$arch"

+ pkgsize="$(@SIZECMD@ -L "$newfile")"
+
+ if ((pkgsize < min_pkg_size)); then
+ msg "$(gettext "Skipping delta creation for small package: %s - size %s")" "$newname" "$pkgsize"
+ return 0
+ fi
+
if [[ $oldname != "$newname" ]]; then
error "$(gettext "The package names don't match : '%s' and '%s'")" "$oldname" "$newname"
return 1
@@ -119,10 +139,19 @@ create_xdelta()
if (( ret )); then
error "$(gettext "Delta could not be created.")"
return 1
- else
- msg "$(gettext "Generated delta : '%s'")" "$deltafile"
- (( QUIET )) && echo "$deltafile"
fi
+
+ deltasize="$(@SIZECMD@ -L "$deltafile")"
+
+ if ((max_delta_size * pkgsize / 100 < deltasize)); then
+ msg "$(gettext "Delta package larger than maximum size. Removing.")"
+ rm -f "$deltafile"
+ return 0
+ fi
+
+ msg "$(gettext "Generated delta : '%s'")" "$deltafile"
+ (( QUIET )) && echo "$deltafile"
+
return 0
}

@@ -134,6 +163,23 @@ while (( $# )); do
-h|--help) usage; exit 0 ;;
-V|--version) version; exit 0 ;;
-q|--quiet) QUIET=1;;
+ --min-pkg-size)
+ if ! isnumeric "$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
+ echo "invalid argument '$2' for option -- '$1'"
+ exit 1
+ fi
+ max_delta_size=$arg
+ shift
+ ;;
--) shift; args+=("$@"); break 2 ;;
-*) echo "invalid option -- '$1'"; usage; exit 1 ;;
*) args+=("$1");;
--
1.7.9.6
 

Thread Tools




All times are GMT. The time now is 11:09 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org