1
0
mirror of https://github.com/moparisthebest/pacman synced 2025-01-10 21:38:19 -05:00

Merge branch 'repo-add-improvements'

This commit is contained in:
Dan McGee 2011-01-11 21:20:07 -06:00
commit 0284cf2128
2 changed files with 32 additions and 14 deletions

View File

@ -10,7 +10,7 @@ repo-add - package database maintenance utility
Synopsis Synopsis
-------- --------
repo-add [-q] <path-to-db> <package1> [<package2> ...] repo-add [-d] [-f] [-q] <path-to-db> <package1> [<package2> ...]
repo-remove [-q] <path-to-db> <packagename> [<packagename2> ...] repo-remove [-q] <path-to-db> <packagename> [<packagename2> ...]
@ -30,11 +30,19 @@ on the command line.
Options Options
------- -------
*-d, \--delta*::
Automatically generate and add a delta file between the old entry and the
new one, if the old package file is found next to the new one.
*-f, \--files*::
Tells repo-add also to create and include a list of the files in the
specified packages. This is useful for creating databases listing all files
in a given sync repository for tools that may use this information.
*-q, \--quiet*:: *-q, \--quiet*::
Force this program to keep quiet and run silent except for warning and Force this program to keep quiet and run silent except for warning and
error messages. error messages.
See Also See Also
-------- --------
linkman:makepkg[8], linkman:pacman[8] linkman:makepkg[8], linkman:pacman[8]

View File

@ -29,10 +29,10 @@ confdir='@sysconfdir@'
QUIET=0 QUIET=0
DELTA=0 DELTA=0
WITHFILES=0
REPO_DB_FILE= REPO_DB_FILE=
LOCKFILE= LOCKFILE=
CLEAN_LOCK=0 CLEAN_LOCK=0
startdir="$PWD"
# ensure we have a sane umask set # ensure we have a sane umask set
umask 0022 umask 0022
@ -62,7 +62,7 @@ error() {
# print usage instructions # print usage instructions
usage() { usage() {
printf "repo-add, repo-remove (pacman) %s\n\n" "$myver" printf "repo-add, repo-remove (pacman) %s\n\n" "$myver"
printf "$(gettext "Usage: repo-add [-d] [-q] <path-to-db> <package|delta> ...\n")" printf "$(gettext "Usage: repo-add [-d] [-f] [-q] <path-to-db> <package|delta> ...\n")"
printf "$(gettext "Usage: repo-remove [-q] <path-to-db> <packagename|delta> ...\n\n")" printf "$(gettext "Usage: repo-remove [-q] <path-to-db> <packagename|delta> ...\n\n")"
printf "$(gettext "\ printf "$(gettext "\
repo-add will update a package database by reading a package file.\n\ repo-add will update a package database by reading a package file.\n\
@ -73,11 +73,13 @@ specified on the command line from the given repo database. Multiple\n\
packages to remove can be specified on the command line.\n\n")" packages to remove can be specified on the command line.\n\n")"
printf "$(gettext "\ printf "$(gettext "\
Use the -q/--quiet flag to minimize output to basic messages, warnings,\n\ Use the -q/--quiet flag to minimize output to basic messages, warnings,\n\
and errors\n\n")" and errors.\n\n")"
printf "$(gettext "\ printf "$(gettext "\
Use the -d/--delta flag to automatically generate and add a delta file\n\ Use the -d/--delta flag to automatically generate and add a delta file\n\
between the old entry and the new one, if the old package file is found\n\ between the old entry and the new one, if the old package file is found\n\
next to the new one.\n\n")" next to the new one.\n\n")"
printf "$(gettext "\
Use the -f/--files flag to update a database including file entries.\n\n")"
echo "$(gettext "Example: repo-add /path/to/repo.db.tar.gz pacman-3.0.0.pkg.tar.gz")" echo "$(gettext "Example: repo-add /path/to/repo.db.tar.gz pacman-3.0.0.pkg.tar.gz")"
echo "$(gettext "Example: repo-remove /path/to/repo.db.tar.gz kernel26")" echo "$(gettext "Example: repo-remove /path/to/repo.db.tar.gz kernel26")"
} }
@ -228,8 +230,7 @@ db_write_entry()
return 1 return 1
fi fi
cd "$tmpdir" pushd "$tmpdir" >/dev/null
if [[ -d $pkgname-$pkgver ]]; then if [[ -d $pkgname-$pkgver ]]; then
warning "$(gettext "An entry for '%s' already existed")" "$pkgname-$pkgver" warning "$(gettext "An entry for '%s' already existed")" "$pkgname-$pkgver"
else else
@ -247,7 +248,7 @@ db_write_entry()
# create package directory # create package directory
mkdir "$pkgname-$pkgver" mkdir "$pkgname-$pkgver"
cd "$pkgname-$pkgver" pushd "$pkgname-$pkgver" >/dev/null
# restore an eventual deltas file # restore an eventual deltas file
[[ -f ../$pkgname.deltas ]] && mv "../$pkgname.deltas" deltas [[ -f ../$pkgname.deltas ]] && mv "../$pkgname.deltas" deltas
@ -289,17 +290,26 @@ db_write_entry()
write_list_entry "PROVIDES" "$_provides" "depends" write_list_entry "PROVIDES" "$_provides" "depends"
write_list_entry "OPTDEPENDS" "$_optdepends" "depends" write_list_entry "OPTDEPENDS" "$_optdepends" "depends"
cd "$startdir" popd >/dev/null
popd >/dev/null
# create files file if wanted
if (( WITHFILES )); then
msg2 "$(gettext "Creating 'files' db entry...")"
local files_path="$tmpdir/$pkgname-$pkgver/files"
echo "%FILES%" >$files_path
bsdtar --exclude='.*' -tf "$pkgfile" >>$files_path
fi
# create a delta file # create a delta file
if [ -n "$oldfilename" -a -f "$oldfile" ]; then if [ -n "$oldfilename" -a -f "$oldfile" ]; then
delta=$(pkgdelta -q $oldfile $1) delta=$(pkgdelta -q $oldfile $1)
if [ -f "$delta" ]; then if [ -f "$delta" ]; then
db_write_delta $delta db_write_delta $delta
fi
else else
warning "$(gettext "Old package file not found : %s")" "$oldfilename" warning "$(gettext "Old package file not found : %s")" "$oldfilename"
fi fi
fi
return 0 return 0
} # end db_write_entry } # end db_write_entry
@ -431,7 +441,6 @@ trap_exit()
clean_up() { clean_up() {
local exit_code=$? local exit_code=$?
cd "$startdir"
[[ -d $tmpdir ]] && rm -rf "$tmpdir" [[ -d $tmpdir ]] && rm -rf "$tmpdir"
(( CLEAN_LOCK )) && [[ -f $LOCKFILE ]] && rm -f "$LOCKFILE" (( CLEAN_LOCK )) && [[ -f $LOCKFILE ]] && rm -f "$LOCKFILE"
@ -474,6 +483,7 @@ for arg in "$@"; do
case "$arg" in case "$arg" in
-q|--quiet) QUIET=1;; -q|--quiet) QUIET=1;;
-d|--delta) DELTA=1;; -d|--delta) DELTA=1;;
-f|--files) WITHFILES=1;;
*) *)
if [[ -z $REPO_DB_FILE ]]; then if [[ -z $REPO_DB_FILE ]]; then
REPO_DB_FILE="$arg" REPO_DB_FILE="$arg"
@ -503,7 +513,7 @@ if (( success )); then
filename=$(basename "$REPO_DB_FILE") filename=$(basename "$REPO_DB_FILE")
cd "$tmpdir" pushd "$tmpdir" >/dev/null
if [[ -n $(ls) ]]; then if [[ -n $(ls) ]]; then
bsdtar -c${TAR_OPT}f "$filename" * bsdtar -c${TAR_OPT}f "$filename" *
else else
@ -511,7 +521,7 @@ if (( success )); then
warning "$(gettext "No packages remain, creating empty database.")" warning "$(gettext "No packages remain, creating empty database.")"
bsdtar -c${TAR_OPT}f "$filename" -T /dev/null bsdtar -c${TAR_OPT}f "$filename" -T /dev/null
fi fi
cd "$startdir" popd >/dev/null
[[ -f $REPO_DB_FILE ]] && mv -f "$REPO_DB_FILE" "${REPO_DB_FILE}.old" [[ -f $REPO_DB_FILE ]] && mv -f "$REPO_DB_FILE" "${REPO_DB_FILE}.old"
[[ -f $tmpdir/$filename ]] && mv "$tmpdir/$filename" "$REPO_DB_FILE" [[ -f $tmpdir/$filename ]] && mv "$tmpdir/$filename" "$REPO_DB_FILE"