summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/repo-add.8.txt12
-rw-r--r--lib/libalpm/alpm.h1
-rw-r--r--lib/libalpm/be_package.c2
-rw-r--r--lib/libalpm/sync.c12
-rw-r--r--scripts/repo-add.sh.in34
-rw-r--r--src/pacman/callback.c9
-rw-r--r--src/pacman/util.c4
7 files changed, 55 insertions, 19 deletions
diff --git a/doc/repo-add.8.txt b/doc/repo-add.8.txt
index 81bf8377..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 [-q] <path-to-db> <package1> [<package2> ...]
+repo-add [-d] [-f] [-q] <path-to-db> <package1> [<package2> ...]
repo-remove [-q] <path-to-db> <packagename> [<packagename2> ...]
@@ -30,11 +30,19 @@ 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
+ 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/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index 32a2856c..7c4cd48b 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -395,6 +395,7 @@ typedef enum _pmtransprog_t {
PM_TRANS_PROGRESS_REMOVE_START,
PM_TRANS_PROGRESS_CONFLICTS_START,
PM_TRANS_PROGRESS_DISKSPACE_START,
+ PM_TRANS_PROGRESS_INTEGRITY_START,
} pmtransprog_t;
/* Transaction Event callback */
diff --git a/lib/libalpm/be_package.c b/lib/libalpm/be_package.c
index 42f33599..b69161b4 100644
--- a/lib/libalpm/be_package.c
+++ b/lib/libalpm/be_package.c
@@ -279,6 +279,8 @@ static pmpkg_t *pkg_load(const char *pkgfile, int full)
newpkg->filename = strdup(pkgfile);
newpkg->size = st.st_size;
+ _alpm_log(PM_LOG_DEBUG, "starting package load for %s\n", pkgfile);
+
/* If full is false, only read through the archive until we find our needed
* metadata. If it is true, read through the entire archive, which serves
* as a verfication of integrity and allows us to create the filelist. */
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index dce1daff..b1eab55b 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -822,7 +822,7 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
{
alpm_list_t *i, *j, *files = NULL;
alpm_list_t *deltas = NULL;
- size_t replaces = 0;
+ size_t numtargs, current = 0, replaces = 0;
int errors = 0;
const char *cachedir = NULL;
int ret = -1;
@@ -949,14 +949,18 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
}
/* Check integrity of packages */
+ numtargs = alpm_list_count(trans->add);
EVENT(trans, PM_TRANS_EVT_INTEGRITY_START, NULL, NULL);
errors = 0;
for(i = trans->add; i; i = i->next) {
pmpkg_t *spkg = i->data;
+ int percent = (current * 100) / numtargs;
if(spkg->origin == PKG_FROM_FILE) {
continue; /* pkg_load() has been already called, this package is valid */
}
+ PROGRESS(trans, PM_TRANS_PROGRESS_INTEGRITY_START, "", percent,
+ numtargs, current);
const char *filename = alpm_pkg_get_filename(spkg);
const char *md5sum = alpm_pkg_get_md5sum(spkg);
@@ -982,12 +986,16 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
pkgfile->reason = spkg->reason; /* copy over install reason */
i->data = pkgfile;
_alpm_pkg_free_trans(spkg); /* spkg has been removed from the target list */
+ current++;
}
+ PROGRESS(trans, PM_TRANS_PROGRESS_INTEGRITY_START, "", 100,
+ numtargs, current);
+ EVENT(trans, PM_TRANS_EVT_INTEGRITY_DONE, NULL, NULL);
if(errors) {
pm_errno = PM_ERR_PKG_INVALID;
goto error;
}
- EVENT(trans, PM_TRANS_EVT_INTEGRITY_DONE, NULL, NULL);
+
if(trans->flags & PM_TRANS_FLAG_DOWNLOADONLY) {
ret = 0;
goto error;
diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in
index d09d1b48..65a63d85 100644
--- a/scripts/repo-add.sh.in
+++ b/scripts/repo-add.sh.in
@@ -29,10 +29,10 @@ confdir='@sysconfdir@'
QUIET=0
DELTA=0
+WITHFILES=0
REPO_DB_FILE=
LOCKFILE=
CLEAN_LOCK=0
-startdir="$PWD"
# ensure we have a sane umask set
umask 0022
@@ -62,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] <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 "\
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")"
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\
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")"
}
@@ -228,8 +230,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 +248,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,16 +290,25 @@ db_write_entry()
write_list_entry "PROVIDES" "$_provides" "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
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
@@ -431,7 +441,6 @@ trap_exit()
clean_up() {
local exit_code=$?
- cd "$startdir"
[[ -d $tmpdir ]] && rm -rf "$tmpdir"
(( CLEAN_LOCK )) && [[ -f $LOCKFILE ]] && rm -f "$LOCKFILE"
@@ -474,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"
@@ -503,7 +513,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 +521,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"
diff --git a/src/pacman/callback.c b/src/pacman/callback.c
index da07b161..e3feea16 100644
--- a/src/pacman/callback.c
+++ b/src/pacman/callback.c
@@ -161,7 +161,7 @@ void cb_trans_evt(pmtransevt_t event, void *data1, void *data2)
break;
case PM_TRANS_EVT_FILECONFLICTS_START:
if(config->noprogressbar) {
- printf(_("checking for file conflicts...\n"));
+ printf(_("checking for file conflicts...\n"));
}
break;
case PM_TRANS_EVT_RESOLVEDEPS_START:
@@ -204,7 +204,9 @@ void cb_trans_evt(pmtransevt_t event, void *data1, void *data2)
display_new_optdepends(data2,data1);
break;
case PM_TRANS_EVT_INTEGRITY_START:
- printf(_("checking package integrity...\n"));
+ if(config->noprogressbar) {
+ printf(_("checking package integrity...\n"));
+ }
break;
case PM_TRANS_EVT_DELTA_INTEGRITY_START:
printf(_("checking delta integrity...\n"));
@@ -374,6 +376,9 @@ void cb_trans_progress(pmtransprog_t event, const char *pkgname, int percent,
case PM_TRANS_PROGRESS_DISKSPACE_START:
opr = _("checking available disk space");
break;
+ case PM_TRANS_PROGRESS_INTEGRITY_START:
+ opr = _("checking package integrity");
+ break;
default:
return;
}
diff --git a/src/pacman/util.c b/src/pacman/util.c
index fbc1a184..d91d1d43 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -523,7 +523,9 @@ void display_targets(const alpm_list_t *pkgs, int install)
for(i = pkgs; i; i = alpm_list_next(i)) {
pmpkg_t *pkg = alpm_list_getdata(i);
- dlsize += alpm_pkg_download_size(pkg);
+ if(install) {
+ dlsize += alpm_pkg_download_size(pkg);
+ }
isize += alpm_pkg_get_isize(pkg);
/* print the package size with the output if ShowSize option set */