index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
-rw-r--r-- | doc/repo-add.8.txt | 12 | ||||
-rw-r--r-- | lib/libalpm/be_local.c | 22 | ||||
-rw-r--r-- | lib/libalpm/remove.c | 18 | ||||
-rw-r--r-- | scripts/repo-add.sh.in | 34 | ||||
-rwxr-xr-x | test/pacman/pmdb.py | 10 | ||||
-rw-r--r-- | test/pacman/tests/remove002.py | 12 | ||||
-rw-r--r-- | test/pacman/tests/upgrade006.py | 18 |
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/be_local.c b/lib/libalpm/be_local.c index d0662d91..5471fee4 100644 --- a/lib/libalpm/be_local.c +++ b/lib/libalpm/be_local.c @@ -424,6 +424,10 @@ static int local_db_populate(pmdb_t *db) continue; } + pkg->origin = PKG_FROM_LOCALDB; + pkg->origin_data.db = db; + pkg->ops = &local_pkg_ops; + /* explicitly read with only 'BASE' data, accessors will handle the rest */ if(_alpm_local_db_read(db, pkg, INFRQ_BASE) == -1) { _alpm_log(PM_LOG_ERROR, _("corrupted database entry '%s'\n"), name); @@ -431,10 +435,6 @@ static int local_db_populate(pmdb_t *db) continue; } - pkg->origin = PKG_FROM_LOCALDB; - pkg->ops = &local_pkg_ops; - - pkg->origin_data.db = db; /* add to the collection */ _alpm_log(PM_LOG_FUNCTION, "adding '%s' to package cache for db '%s'\n", pkg->name, db->treename); @@ -480,8 +480,10 @@ int _alpm_local_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq) return(-1); } - if(info->origin == PKG_FROM_FILE) { - _alpm_log(PM_LOG_DEBUG, "request to read database info for a file-based package '%s', skipping...\n", info->name); + if(info->origin != PKG_FROM_LOCALDB) { + _alpm_log(PM_LOG_DEBUG, + "request to read info for a non-local package '%s', skipping...\n", + info->name); return(-1); } @@ -491,7 +493,7 @@ int _alpm_local_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq) * & result: 00000100 * == to inforeq? nope, we need to load more info. */ if((info->infolevel & inforeq) == inforeq) { - /* already loaded this info, do nothing */ + /* already loaded all of this info, do nothing */ return(0); } _alpm_log(PM_LOG_FUNCTION, "loading package data for %s : level=0x%x\n", @@ -510,7 +512,7 @@ int _alpm_local_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq) } /* DESC */ - if(inforeq & INFRQ_DESC) { + if(inforeq & INFRQ_DESC && !(info->infolevel & INFRQ_DESC)) { snprintf(path, PATH_MAX, "%sdesc", pkgpath); if((fp = fopen(path, "r")) == NULL) { _alpm_log(PM_LOG_ERROR, _("could not open file %s: %s\n"), path, strerror(errno)); @@ -639,7 +641,7 @@ int _alpm_local_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq) } /* FILES */ - if(inforeq & INFRQ_FILES) { + if(inforeq & INFRQ_FILES && !(info->infolevel & INFRQ_FILES)) { snprintf(path, PATH_MAX, "%sfiles", pkgpath); if((fp = fopen(path, "r")) == NULL) { _alpm_log(PM_LOG_ERROR, _("could not open file %s: %s\n"), path, strerror(errno)); @@ -666,7 +668,7 @@ int _alpm_local_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq) } /* INSTALL */ - if(inforeq & INFRQ_SCRIPTLET) { + if(inforeq & INFRQ_SCRIPTLET && !(info->infolevel & INFRQ_SCRIPTLET)) { snprintf(path, PATH_MAX, "%sinstall", pkgpath); if(access(path, F_OK) == 0) { info->scriptlet = 1; diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c index d4e3b94a..5fba0b07 100644 --- a/lib/libalpm/remove.c +++ b/lib/libalpm/remove.c @@ -298,10 +298,12 @@ static void unlink_file(pmpkg_t *info, char *filename, alpm_list_t *skip_remove, } } -int _alpm_upgraderemove_package(pmpkg_t *oldpkg, pmpkg_t *newpkg, pmtrans_t *trans) +int _alpm_upgraderemove_package(pmpkg_t *oldpkg, pmpkg_t *newpkg, + pmtrans_t *trans) { alpm_list_t *skip_remove, *b; alpm_list_t *newfiles, *lp; + size_t filenum; alpm_list_t *files = alpm_pkg_get_files(oldpkg); const char *pkgname = alpm_pkg_get_name(oldpkg); @@ -315,8 +317,9 @@ int _alpm_upgraderemove_package(pmpkg_t *oldpkg, pmpkg_t *newpkg, pmtrans_t *tra } /* copy the remove skiplist over */ - skip_remove = - alpm_list_join(alpm_list_strdup(trans->skip_remove),alpm_list_strdup(handle->noupgrade)); + skip_remove = alpm_list_join( + alpm_list_strdup(trans->skip_remove), + alpm_list_strdup(handle->noupgrade)); /* Add files in the NEW backup array to the skip_remove array * so this removal operation doesn't kill them */ /* old package backup list */ @@ -340,6 +343,9 @@ int _alpm_upgraderemove_package(pmpkg_t *oldpkg, pmpkg_t *newpkg, pmtrans_t *tra } } + filenum = alpm_list_count(files); + _alpm_log(PM_LOG_DEBUG, "removing %ld files\n", (unsigned long)filenum); + /* iterate through the list backwards, unlinking files */ newfiles = alpm_list_reverse(files); for(lp = newfiles; lp; lp = alpm_list_next(lp)) { @@ -406,6 +412,9 @@ int _alpm_remove_packages(pmtrans_t *trans, pmdb_t *db) if(!(trans->flags & PM_TRANS_FLAG_DBONLY)) { alpm_list_t *files = alpm_pkg_get_files(info); + alpm_list_t *newfiles; + size_t filenum; + for(lp = files; lp; lp = lp->next) { if(!can_remove_file(lp->data, NULL)) { _alpm_log(PM_LOG_DEBUG, "not removing package '%s', can't remove all files\n", @@ -414,8 +423,7 @@ int _alpm_remove_packages(pmtrans_t *trans, pmdb_t *db) } } - size_t filenum = alpm_list_count(files); - alpm_list_t *newfiles; + filenum = alpm_list_count(files); _alpm_log(PM_LOG_DEBUG, "removing %ld files\n", (unsigned long)filenum); /* init progress bar */ 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/test/pacman/pmdb.py b/test/pacman/pmdb.py index 60460ce2..b4d0e2d5 100755 --- a/test/pacman/pmdb.py +++ b/test/pacman/pmdb.py @@ -38,16 +38,14 @@ def _mkfilelist(files): usr/local/bin/ usr/local/bin/dummy """ - i = [] + file_list = set() for f in files: dir = getfilename(f) - i.append(dir) + file_list.add(dir) while "/" in dir: [dir, tmp] = dir.rsplit("/", 1) - if not dir + "/" in files: - i.append(dir + "/") - i.sort() - return i + file_list.add(dir + "/") + return sorted(file_list) def _mkbackuplist(backup): """ diff --git a/test/pacman/tests/remove002.py b/test/pacman/tests/remove002.py new file mode 100644 index 00000000..1deffb0d --- /dev/null +++ b/test/pacman/tests/remove002.py @@ -0,0 +1,12 @@ +self.description = "Remove a package with several files" + +p = pmpkg("foo") +p.files = ["usr/share/file_%d" % n for n in range(1000)] +self.addpkg2db("local", p) + +self.args = "-R %s" % p.name + +self.addrule("PACMAN_RETCODE=0") +self.addrule("!PKG_EXIST=foo") +self.addrule("!FILE_EXIST=usr/share/file_0") +self.addrule("!FILE_EXIST=usr/share/file_999") diff --git a/test/pacman/tests/upgrade006.py b/test/pacman/tests/upgrade006.py new file mode 100644 index 00000000..5e5173b5 --- /dev/null +++ b/test/pacman/tests/upgrade006.py @@ -0,0 +1,18 @@ +self.description = "Upgrade a package with several files" + +lp = pmpkg("dummy") +lp.files = ["usr/share/file_%d" % n for n in range(250, 750)] +self.addpkg2db("local", lp) + +p = pmpkg("dummy", "1.1-1") +p.files = ["usr/share/file_%d" % n for n in range(600, 1000)] +self.addpkg(p) + +self.args = "-U %s" % p.filename() + +self.addrule("PACMAN_RETCODE=0") +self.addrule("PKG_VERSION=dummy|1.1-1") +self.addrule("!FILE_EXIST=usr/share/file_250") +self.addrule("!FILE_EXIST=usr/share/file_599") +self.addrule("FILE_EXIST=usr/share/file_600") +self.addrule("FILE_EXIST=usr/share/file_999") |