From b9a2318becfc9d6ffb92e602adf433faa8cec383 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Sat, 14 May 2011 12:54:03 -0400 Subject: trans.c: create transaction prior to checking DB version The addition of the DB version check introduces a lag time between the lockfile creation and the transaction initialization. In cases where the local DB is large enough and/or the user's disk is slow enough, this time is significant enough that its possible for a user to send a SIGINT and leave behind a db.lck file. Signed-off-by: Dave Reisner Signed-off-by: Dan McGee --- lib/libalpm/trans.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c index c5af7c69..7affbfbd 100644 --- a/lib/libalpm/trans.c +++ b/lib/libalpm/trans.c @@ -120,15 +120,6 @@ int SYMEXPORT alpm_trans_init(pmtransflag_t flags, } } - /* check database version */ - db_version = _alpm_db_version(handle->db_local); - if(db_version < required_db_version) { - _alpm_log(PM_LOG_ERROR, - _("%s database version is too old\n"), handle->db_local->treename); - remove_lock(handle); - RET_ERR(PM_ERR_DB_VERSION, -1); - } - trans = _alpm_trans_new(); if(trans == NULL) { RET_ERR(PM_ERR_MEMORY, -1); @@ -142,6 +133,16 @@ int SYMEXPORT alpm_trans_init(pmtransflag_t flags, handle->trans = trans; + /* check database version */ + db_version = _alpm_db_version(handle->db_local); + if(db_version < required_db_version) { + _alpm_log(PM_LOG_ERROR, + _("%s database version is too old\n"), handle->db_local->treename); + remove_lock(handle); + _alpm_trans_free(trans); + RET_ERR(PM_ERR_DB_VERSION, -1); + } + return(0); } -- cgit v1.2.3-24-g4f1b From ac6f6b317ae4bb7adf5ea08fbad6a75f024ff75a Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Mon, 16 May 2011 10:19:21 -0500 Subject: Transifex updates Signed-off-by: Dan McGee --- po/fi.po | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/po/fi.po b/po/fi.po index 3f32cbd4..5881f51e 100644 --- a/po/fi.po +++ b/po/fi.po @@ -8,9 +8,10 @@ msgstr "" "Project-Id-Version: Arch Linux Pacman package manager\n" "Report-Msgid-Bugs-To: http://bugs.archlinux.org/index.php?project=3\n" "POT-Creation-Date: 2011-04-18 11:23-0500\n" -"PO-Revision-Date: 2011-04-15 17:59+0000\n" -"Last-Translator: apuasi \n" -"Language-Team: Finnish \n" +"PO-Revision-Date: 2011-05-11 14:51+0000\n" +"Last-Translator: Larso \n" +"Language-Team: Finnish (http://www.transifex.net/projects/p/archlinux-pacman/" +"team/fi/)\n" "Language: fi\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -349,7 +350,7 @@ msgstr " -c, --cascade poista paketit ja kaikki niiden riippuvuudet\n" #, c-format msgid " -n, --nosave remove configuration files\n" -msgstr "" +msgstr " -n, --nosave poista myös asetustiedostot\n" #, c-format msgid "" @@ -359,7 +360,7 @@ msgstr "" #, c-format msgid " -u, --unneeded remove unneeded packages\n" -msgstr "" +msgstr " -u, --unneeded poista tarpeettomat paketit\n" #, c-format msgid " -c, --changelog view the changelog of a package\n" @@ -550,7 +551,7 @@ msgstr "" msgid "" " --print print the targets instead of performing the " "operation\n" -msgstr "" +msgstr " --print listaa paketit, mutta älä suorita operaatiota\n" #, c-format msgid "" @@ -950,7 +951,7 @@ msgstr "paketti %s ei ole kelvollinen tai se on vahingoittunut\n" #, c-format msgid "Errors occurred, no packages were upgraded.\n" -msgstr "Yhtään pakettia ei ole päivitetty tapahtuneiden virheiden vuoksi.\n" +msgstr "Yhtään pakettia ei päivitetty tapahtuneiden virheiden vuoksi.\n" #, c-format msgid ":: Synchronizing package databases...\n" -- cgit v1.2.3-24-g4f1b From 3000b6b473422dca3670c922c24d0e15e963281a Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Mon, 16 May 2011 11:08:32 -0500 Subject: pactest: treat symlinks with more respect Don't call os.stat() when we should be using os.lstat(); this allows us to actually test dead symlinks that don't have a corresponding file. Add a new LINK_EXIST rule that complements FILE_EXIST for a similar purpose. Signed-off-by: Dan McGee --- test/pacman/pmpkg.py | 2 +- test/pacman/pmrule.py | 8 ++++++++ test/pacman/util.py | 6 ++---- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/test/pacman/pmpkg.py b/test/pacman/pmpkg.py index 73156ab2..be177f35 100755 --- a/test/pacman/pmpkg.py +++ b/test/pacman/pmpkg.py @@ -102,7 +102,7 @@ class pmpkg(object): # Generate package file system for f in self.files: util.mkfile(f, f) - self.size += os.stat(util.getfilename(f))[stat.ST_SIZE] + self.size += os.lstat(util.getfilename(f))[stat.ST_SIZE] # .PKGINFO data = ["pkgname = %s" % self.name] diff --git a/test/pacman/pmrule.py b/test/pacman/pmrule.py index c68d085e..0f6ae602 100755 --- a/test/pacman/pmrule.py +++ b/test/pacman/pmrule.py @@ -146,6 +146,14 @@ class pmrule(object): else: print "FILE rule '%s' not found" % case success = -1 + elif kind == "LINK": + filename = os.path.join(test.root, key) + if case == "EXIST": + if not os.path.islink(filename): + success = 0 + else: + print "LINK rule '%s' not found" % case + success = -1 elif kind == "CACHE": cachedir = os.path.join(test.root, util.PM_CACHEDIR) if case == "EXISTS": diff --git a/test/pacman/util.py b/test/pacman/util.py index b771a345..47fde310 100755 --- a/test/pacman/util.py +++ b/test/pacman/util.py @@ -149,7 +149,6 @@ def getmd5sum(filename): """ """ if not os.path.isfile(filename): - print "file %s does not exist!" % filename return "" fd = open(filename, "rb") checksum = hashlib.md5() @@ -177,9 +176,8 @@ def getmtime(filename): """ """ if not os.path.exists(filename): - print "path %s does not exist!" % filename - return 0, 0, 0 - st = os.stat(filename) + return None, None, None + st = os.lstat(filename) return st[stat.ST_ATIME], st[stat.ST_MTIME], st[stat.ST_CTIME] # -- cgit v1.2.3-24-g4f1b From 93f02f5793ad7907aa0bc7c4a9fe64f0c7ce86f6 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Mon, 16 May 2011 11:32:33 -0500 Subject: Add test for FS#24230, dead backup symlink removal This currently causes a segfault, which is bad news. Signed-off-by: Dan McGee --- test/pacman/tests/symlink002.py | 45 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 test/pacman/tests/symlink002.py diff --git a/test/pacman/tests/symlink002.py b/test/pacman/tests/symlink002.py new file mode 100644 index 00000000..7dcafb0d --- /dev/null +++ b/test/pacman/tests/symlink002.py @@ -0,0 +1,45 @@ +self.description = "Dead backed-up symlink when removing package (FS#24230)" + +# symlink file is changed +lp = pmpkg("dummy") +lp.files = ["etc/brokenlink -> nonexistent", + "etc/exists"] +lp.backup = ["etc/brokenlink*"] +self.addpkg2db("local", lp) + +# symlink file is not changed +lp2 = pmpkg("dummy2") +lp2.files = ["etc/brokenlink2 -> nonexistent2", + "etc/exists2"] +lp2.backup = ["etc/brokenlink2"] +self.addpkg2db("local", lp2) + +# package is left alone, not uninstalled +lp3 = pmpkg("dummy3") +lp3.files = ["etc/brokenlink3 -> nonexistent3", + "etc/exists3"] +self.addpkg2db("local", lp3) + +self.args = "-R %s %s" % (lp.name, lp2.name) +#self.args = "-R" + +self.addrule("PACMAN_RETCODE=0") + +self.addrule("!PKG_EXIST=dummy") +self.addrule("!LINK_EXIST=etc/brokenlink") +self.addrule("!FILE_EXIST=etc/nonexistent") +self.addrule("!FILE_EXIST=etc/exists") + +self.addrule("!PKG_EXIST=dummy2") +self.addrule("!LINK_EXIST=etc/brokenlink2") +self.addrule("!FILE_EXIST=etc/nonexistent2") +self.addrule("!FILE_EXIST=etc/exists2") + +self.addrule("PKG_EXIST=dummy3") +self.addrule("LINK_EXIST=etc/brokenlink3") +self.addrule("!FILE_EXIST=etc/nonexistent") +self.addrule("FILE_EXIST=etc/exists3") +self.addrule("FILE_TYPE=etc/brokenlink3|link") +self.addrule("FILE_TYPE=etc/exists3|file") + +self.expectfailure = True -- cgit v1.2.3-24-g4f1b From aec60e37822509a1ca7fc53244878d3f1505d964 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Mon, 16 May 2011 11:50:13 -0500 Subject: Fix segfault when uninstalling broken backed-up symlink Issue FS#24230. If a symlink is broken and included in the removal process of a package, we blew up and segfaulted due to alpm_compute_md5sum() returning NULL and then performing a strcmp() operation. Signed-off-by: Dan McGee --- lib/libalpm/remove.c | 2 +- test/pacman/tests/symlink002.py | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c index 7c8a99fb..22ae2bb8 100644 --- a/lib/libalpm/remove.c +++ b/lib/libalpm/remove.c @@ -266,7 +266,7 @@ static void unlink_file(pmpkg_t *info, char *filename, alpm_list_t *skip_remove, FREE(pkghash); } else { char *filehash = alpm_compute_md5sum(file); - int cmp = strcmp(filehash,pkghash); + int cmp = filehash ? strcmp(filehash, pkghash) : 0; FREE(filehash); FREE(pkghash); if(cmp != 0) { diff --git a/test/pacman/tests/symlink002.py b/test/pacman/tests/symlink002.py index 7dcafb0d..6b7423d9 100644 --- a/test/pacman/tests/symlink002.py +++ b/test/pacman/tests/symlink002.py @@ -41,5 +41,3 @@ self.addrule("!FILE_EXIST=etc/nonexistent") self.addrule("FILE_EXIST=etc/exists3") self.addrule("FILE_TYPE=etc/brokenlink3|link") self.addrule("FILE_TYPE=etc/exists3|file") - -self.expectfailure = True -- cgit v1.2.3-24-g4f1b From ba467779bb0faa6ea81d91759c2224592091bbe3 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Mon, 16 May 2011 11:52:49 -0500 Subject: Ensure --print doesn't enable --noconfirm when not expected This is at best a hack around the way we currently do our --print magic, but at least prevents someone from shooting themselves in the foot as indicated in FS#24287. Signed-off-by: Dan McGee --- src/pacman/pacman.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 0ad03540..8bdb216e 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -1416,7 +1416,7 @@ int main(int argc, char *argv[]) } /* set up the print operations */ - if(config->print) { + if(config->print && !config->op_s_clean) { config->noconfirm = 1; config->flags |= PM_TRANS_FLAG_NOCONFLICTS; config->flags |= PM_TRANS_FLAG_NOLOCK; -- cgit v1.2.3-24-g4f1b From f2c4e7e55220addef0581d1c38cc7363b5a0884c Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Thu, 19 May 2011 16:59:53 -0500 Subject: Coding style cleanups; add a null check Signed-off-by: Dan McGee --- src/pacman/pacman.c | 3 ++- src/pacman/query.c | 12 ++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 8bdb216e..347d8af9 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -1265,8 +1265,9 @@ static void cl_to_log(int argc, char* argv[]) size += strlen(argv[i]) + 1; } char *cl_text = malloc(size); - if(!cl_text) + if(!cl_text) { return; + } char *p = cl_text; for(i = 0; iquiet) { + if(!config->quiet) { printf(_("%s is owned by %s %s\n"), filename, alpm_pkg_get_name(info), alpm_pkg_get_version(info)); } else { -- cgit v1.2.3-24-g4f1b