1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-12-21 23:38:49 -05:00

repo-add: use bsdtar optimization for better performance

When unzipping packages and the database archives, we don't need to look
through the entire archive to do what we need to do. For packages, .PKGINFO
should only be found once and should be the first file in the package. For
the database check, we only really need to look for one desc file.

The bsdtar -q option is very similar to the GNU tar --occurrence=1 option.

Example of speedup:

$ time repo-add junkdb.db.tar.gz *.pkg.tar.gz >/dev/null
real	0m16.159s
user	0m14.836s
sys	0m2.277s

$ time ./scripts/repo-add junkdb.db.tar.gz *.pkg.tar.gz >/dev/null
real	0m4.949s
user	0m3.730s
sys	0m2.093s

Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Dan McGee 2009-06-16 20:04:19 -05:00
parent f250b034b4
commit 8bbaf045b9

View File

@ -193,7 +193,7 @@ db_write_entry()
# read info from the zipped package
local line var val
for line in $(bsdtar -xOf "$pkgfile" .PKGINFO |
for line in $(bsdtar -xOqf "$pkgfile" .PKGINFO |
grep -v '^#' | sed 's|\(\w*\)\s*=\s*\(.*\)|\1 \2|'); do
# bash awesomeness here- var is always one word, val is everything else
var=${line%% *}
@ -305,7 +305,7 @@ check_repo_db()
fi
if [ -f "$REPO_DB_FILE" ]; then
if ! (bsdtar -tf "$REPO_DB_FILE" | grep -q "/desc"); then
if ! bsdtar -tqf "$REPO_DB_FILE" '*/desc' 2>&1 >/dev/null; then
error "$(gettext "Repository file '%s' is not a proper pacman database.")" "$REPO_DB_FILE"
exit 1
fi
@ -351,7 +351,7 @@ add()
fi
pkgfile=$1
if ! bsdtar -tf "$pkgfile" .PKGINFO 2>&1 >/dev/null; then
if ! bsdtar -tqf "$pkgfile" .PKGINFO 2>&1 >/dev/null; then
error "$(gettext "'%s' is not a package file, skipping")" "$pkgfile"
return 1
fi