From 7ce90bb135c04b4421ca2824099e6e72659721b1 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Tue, 11 Jan 2011 15:15:07 -0600 Subject: repo-add: use pushd/popd Rather than explicit cd calls, we can use the directory stack to our advantage. This also removes the need to store and restore $startdir, so kill the variable entirely. Signed-off-by: Dan McGee --- scripts/repo-add.sh.in | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in index d09d1b48..1933950d 100644 --- a/scripts/repo-add.sh.in +++ b/scripts/repo-add.sh.in @@ -32,7 +32,6 @@ DELTA=0 REPO_DB_FILE= LOCKFILE= CLEAN_LOCK=0 -startdir="$PWD" # ensure we have a sane umask set umask 0022 @@ -73,7 +72,7 @@ specified on the command line from the given repo database. Multiple\n\ packages to remove can be specified on the command line.\n\n")" printf "$(gettext "\ Use the -q/--quiet flag to minimize output to basic messages, warnings,\n\ -and errors\n\n")" +and errors.\n\n")" printf "$(gettext "\ 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\ @@ -228,8 +227,7 @@ db_write_entry() return 1 fi - cd "$tmpdir" - + pushd "$tmpdir" >/dev/null if [[ -d $pkgname-$pkgver ]]; then warning "$(gettext "An entry for '%s' already existed")" "$pkgname-$pkgver" else @@ -247,7 +245,7 @@ db_write_entry() # create package directory mkdir "$pkgname-$pkgver" - cd "$pkgname-$pkgver" + pushd "$pkgname-$pkgver" >/dev/null # restore an eventual deltas file [[ -f ../$pkgname.deltas ]] && mv "../$pkgname.deltas" deltas @@ -289,7 +287,8 @@ db_write_entry() write_list_entry "PROVIDES" "$_provides" "depends" write_list_entry "OPTDEPENDS" "$_optdepends" "depends" - cd "$startdir" + popd >/dev/null + popd >/dev/null # create a delta file if [ -n "$oldfilename" -a -f "$oldfile" ]; then @@ -431,7 +430,6 @@ trap_exit() clean_up() { local exit_code=$? - cd "$startdir" [[ -d $tmpdir ]] && rm -rf "$tmpdir" (( CLEAN_LOCK )) && [[ -f $LOCKFILE ]] && rm -f "$LOCKFILE" @@ -503,7 +501,7 @@ if (( success )); then filename=$(basename "$REPO_DB_FILE") - cd "$tmpdir" + pushd "$tmpdir" >/dev/null if [[ -n $(ls) ]]; then bsdtar -c${TAR_OPT}f "$filename" * else @@ -511,7 +509,7 @@ if (( success )); then warning "$(gettext "No packages remain, creating empty database.")" bsdtar -c${TAR_OPT}f "$filename" -T /dev/null fi - cd "$startdir" + popd >/dev/null [[ -f $REPO_DB_FILE ]] && mv -f "$REPO_DB_FILE" "${REPO_DB_FILE}.old" [[ -f $tmpdir/$filename ]] && mv "$tmpdir/$filename" "$REPO_DB_FILE" -- cgit v1.2.3 From eda4d9ec00be1108ab4336a438299a283c5a0a90 Mon Sep 17 00:00:00 2001 From: PyroPeter Date: Tue, 11 Jan 2011 23:04:20 +0100 Subject: repo-add: Create/modify files databases Implements FS#11302. Dan: updated docs to not reference pkgfile. Signed-off-by: PyroPeter Signed-off-by: Dan McGee --- doc/repo-add.8.txt | 8 ++++++-- scripts/repo-add.sh.in | 18 +++++++++++++++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/doc/repo-add.8.txt b/doc/repo-add.8.txt index 81bf8377..2500ab8b 100644 --- a/doc/repo-add.8.txt +++ b/doc/repo-add.8.txt @@ -10,7 +10,7 @@ repo-add - package database maintenance utility Synopsis -------- -repo-add [-q] [ ...] +repo-add [-f] [-q] [ ...] repo-remove [-q] [ ...] @@ -30,11 +30,15 @@ on the command line. Options ------- +*-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*:: Force this program to keep quiet and run silent except for warning and error messages. - See Also -------- linkman:makepkg[8], linkman:pacman[8] diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in index 1933950d..65a63d85 100644 --- a/scripts/repo-add.sh.in +++ b/scripts/repo-add.sh.in @@ -29,6 +29,7 @@ confdir='@sysconfdir@' QUIET=0 DELTA=0 +WITHFILES=0 REPO_DB_FILE= LOCKFILE= CLEAN_LOCK=0 @@ -61,7 +62,7 @@ error() { # print usage instructions usage() { printf "repo-add, repo-remove (pacman) %s\n\n" "$myver" - printf "$(gettext "Usage: repo-add [-d] [-q] ...\n")" + printf "$(gettext "Usage: repo-add [-d] [-f] [-q] ...\n")" printf "$(gettext "Usage: repo-remove [-q] ...\n\n")" printf "$(gettext "\ repo-add will update a package database by reading a package file.\n\ @@ -77,6 +78,8 @@ and errors.\n\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\ 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-remove /path/to/repo.db.tar.gz kernel26")" } @@ -290,14 +293,22 @@ db_write_entry() 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 if [ -n "$oldfilename" -a -f "$oldfile" ]; then delta=$(pkgdelta -q $oldfile $1) if [ -f "$delta" ]; then db_write_delta $delta - else - warning "$(gettext "Old package file not found : %s")" "$oldfilename" fi + else + warning "$(gettext "Old package file not found : %s")" "$oldfilename" fi return 0 @@ -472,6 +483,7 @@ for arg in "$@"; do case "$arg" in -q|--quiet) QUIET=1;; -d|--delta) DELTA=1;; + -f|--files) WITHFILES=1;; *) if [[ -z $REPO_DB_FILE ]]; then REPO_DB_FILE="$arg" -- cgit v1.2.3 From d0c327df172942da18f1e5c9b6afb183e4d9ee18 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Tue, 11 Jan 2011 17:16:12 -0600 Subject: doc: add docs for repo-add -d option This never got added when the option was brought in, so fix it. Signed-off-by: Dan McGee --- doc/repo-add.8.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/doc/repo-add.8.txt b/doc/repo-add.8.txt index 2500ab8b..75f49ef5 100644 --- a/doc/repo-add.8.txt +++ b/doc/repo-add.8.txt @@ -10,7 +10,7 @@ repo-add - package database maintenance utility Synopsis -------- -repo-add [-f] [-q] [ ...] +repo-add [-d] [-f] [-q] [ ...] repo-remove [-q] [ ...] @@ -30,6 +30,10 @@ on the command line. 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 -- cgit v1.2.3