From 95ea6fb3c19a8d72d5b2e71ab5e37f2da8c77d5d Mon Sep 17 00:00:00 2001 From: Xavier Chantry Date: Thu, 28 Aug 2008 20:55:26 +0200 Subject: Separate targets on -Qi/-Si with a newline. This fixes FS#11331 The newline was lost with commit 9451b2e4f23a3c566fcfe3420c379b3cb3eb1f90. Signed-off-by: Xavier Chantry --- src/pacman/package.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pacman/package.c b/src/pacman/package.c index fddce94a..71be2d8c 100644 --- a/src/pacman/package.c +++ b/src/pacman/package.c @@ -135,9 +135,11 @@ void dump_pkg_full(pmpkg_t *pkg, int level) /* Print additional package info if info flag passed more than once */ if(level > 1) { dump_pkg_backups(pkg); - printf("\n"); } + /* final newline to separate packages */ + printf("\n"); + FREELIST(depstrings); } -- cgit v1.2.3 From 242e9e90f4190b9f770a0230e99d302f7ec53e70 Mon Sep 17 00:00:00 2001 From: Xavier Chantry Date: Fri, 29 Aug 2008 17:24:34 +0200 Subject: Another attempt at fixing totaldownload. This fixes FS#11339, which is a regression of commit 89c2c5196: When totaldownload is enabled, the database downloading percent (-Sy) is always at 0. That is because we have no guarantee that the totaldownload callback was called by libalpm. In particular, it is not called (and it would not make sense to) when a single file is downloaded, like it is the case with databases. So the correct way to detect if totaldownload should be used is checking both config->totaldownload and list_total, like it was already done in several places in the cb_dl_progress function. Signed-off-by: Xavier Chantry Signed-off-by: Dan McGee --- src/pacman/callback.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/pacman/callback.c b/src/pacman/callback.c index a6349874..82dabae3 100644 --- a/src/pacman/callback.c +++ b/src/pacman/callback.c @@ -137,11 +137,9 @@ static void fill_progress(const int bar_percent, const int disp_percent, } printf("]"); } - /* print percent after progress bar */ + /* print display percent after progress bar */ if(proglen > 5) { - /* show total download percent if option is enabled */ - int p = config->totaldownload ? disp_percent : bar_percent; - printf(" %3d%%", p); + printf(" %3d%%", disp_percent); } if(bar_percent == 100) { @@ -438,6 +436,7 @@ void cb_dl_progress(const char *filename, off_t file_xfered, off_t file_total) int len, wclen, wcwid, padwid; wchar_t *wcfname; + int totaldownload; off_t xfered, total; float rate = 0.0, timediff = 0.0, f_xfered = 0.0; unsigned int eta_h = 0, eta_m = 0, eta_s = 0; @@ -453,6 +452,12 @@ void cb_dl_progress(const char *filename, off_t file_xfered, off_t file_total) /* only use TotalDownload if enabled and we have a callback value */ if(config->totaldownload && list_total) { + totaldownload = 1; + } else { + totaldownload = 0; + } + + if(totaldownload) { xfered = list_xfered + file_xfered; total = list_total; } else { @@ -465,8 +470,7 @@ void cb_dl_progress(const char *filename, off_t file_xfered, off_t file_total) if(file_xfered == 0) { /* set default starting values, ensure we only call this once * if TotalDownload is enabled */ - if(!(config->totaldownload) - || (config->totaldownload && list_xfered == 0)) { + if(!totaldownload || (totaldownload && list_xfered == 0)) { gettimeofday(&initial_time, NULL); xfered_last = (off_t)0; rate_last = 0.0; @@ -503,7 +507,7 @@ void cb_dl_progress(const char *filename, off_t file_xfered, off_t file_total) file_percent = (int)((float)file_xfered) / ((float)file_total) * 100; - if(config->totaldownload && list_total) { + if(totaldownload) { total_percent = (int)((float)list_xfered + file_xfered) / ((float)list_total) * 100; @@ -584,7 +588,11 @@ void cb_dl_progress(const char *filename, off_t file_xfered, off_t file_total) free(fname); free(wcfname); - fill_progress(file_percent, total_percent, getcols() - infolen); + if(totaldownload) { + fill_progress(file_percent, total_percent, getcols() - infolen); + } else { + fill_progress(file_percent, file_percent, getcols() - infolen); + } return; } -- cgit v1.2.3 From 18452a6c51827e91f37978397552c30cb92c26cd Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sun, 28 Sep 2008 19:33:56 -0500 Subject: Ensure we don't have double slashes when creating frontend paths MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Because libalpm always returns a root path with a trailing slash, when we use it to create our unspecified paths we get double slashes in the result. Use the fix suggested by Jürgen Hötzel to remedy this. Signed-off-by: Dan McGee --- src/pacman/pacman.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 81f07dac..3a56a9d3 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -262,11 +262,13 @@ static void setlibpaths(void) cleanup(ret); } if(!config->dbpath) { - snprintf(path, PATH_MAX, "%s%s", alpm_option_get_root(), DBPATH); + /* omit leading slash from our static DBPATH, root handles it */ + snprintf(path, PATH_MAX, "%s%s", alpm_option_get_root(), DBPATH + 1); config->dbpath = strdup(path); } if(!config->logfile) { - snprintf(path, PATH_MAX, "%s%s", alpm_option_get_root(), LOGFILE); + /* omit leading slash from our static LOGFILE path, root handles it */ + snprintf(path, PATH_MAX, "%s%s", alpm_option_get_root(), LOGFILE + 1); config->logfile = strdup(path); } } -- cgit v1.2.3 From f9be2334f7b01ba30235500cb12d4ed61fff564b Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Wed, 10 Sep 2008 14:29:50 -0500 Subject: libalpm: handle syscall interruption correctly It is possible to throw EINTR from a system call such as open(), close(), or waitpid() if custom signal handlers are set up and they are not initialized with the SA_RESTART flag. This was noticed by Andreas Radke when ^C (SIGINT) was given during the call to waitpid(), causing it to throw the EINTR error and we could not accommodate it. Simply wrap these calls in a simple loop that allows us to retry the call if interrupted. Signed-off-by: Dan McGee --- lib/libalpm/trans.c | 5 ++--- lib/libalpm/util.c | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c index d6b165d3..f996c02c 100644 --- a/lib/libalpm/trans.c +++ b/lib/libalpm/trans.c @@ -30,7 +30,6 @@ #include #include #include -#include #include /* libalpm */ @@ -205,7 +204,7 @@ int SYMEXPORT alpm_trans_release() /* unlock db */ if(handle->lckfd != -1) { - close(handle->lckfd); + while(close(handle->lckfd) == -1 && errno == EINTR); handle->lckfd = -1; } if(_alpm_lckrm()) { @@ -576,7 +575,7 @@ int _alpm_runscriptlet(const char *root, const char *installfn, /* this code runs for the parent only (wait on the child) */ pid_t retpid; int status; - retpid = waitpid(pid, &status, 0); + while((retpid = waitpid(pid, &status, 0)) == -1 && errno == EINTR); if(retpid == -1) { _alpm_log(PM_LOG_ERROR, _("call to waitpid failed (%s)\n"), strerror(errno)); diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index b26c9702..da3463b0 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/util.c @@ -254,7 +254,8 @@ int _alpm_lckmk() _alpm_makepath(dir); FREE(dir); - fd = open(file, O_WRONLY | O_CREAT | O_EXCL, 0000); + while((fd = open(file, O_WRONLY | O_CREAT | O_EXCL, 0000)) == -1 + && errno == EINTR); return(fd > 0 ? fd : -1); } -- cgit v1.2.3 From ce3d70aa99ab86d49756d1858580750f2f13dd9e Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sat, 20 Sep 2008 10:09:17 -0500 Subject: Reduce number of calls to getcols() Every call to getcols() results in two ioctl() calls, which we really didn't need as changing the number of columns in mid-print would be pretty crazy. Signed-off-by: Dan McGee --- src/pacman/util.c | 11 ++++++----- src/pacman/util.h | 6 +++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/pacman/util.c b/src/pacman/util.c index c31714e4..8cfa675a 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -59,7 +59,7 @@ int trans_init(pmtranstype_t type, pmtransflag_t flags) return(0); } -int trans_release() +int trans_release(void) { if(alpm_trans_release() == -1) { pm_fprintf(stderr, PM_LOG_ERROR, _("failed to release transaction (%s)\n"), @@ -69,7 +69,7 @@ int trans_release() return(0); } -int needs_transaction() +int needs_transaction(void) { if(config->op != PM_OP_MAIN && config->op != PM_OP_QUERY && config->op != PM_OP_DEPTEST) { if((config->op == PM_OP_SYNC && !config->op_s_sync && @@ -85,7 +85,7 @@ int needs_transaction() } /* gets the current screen column width */ -int getcols() +int getcols(void) { if(!isatty(1)) { /* We will default to 80 columns if we're not a tty @@ -252,7 +252,7 @@ void indentprint(const char *str, int indent) { wchar_t *wcstr; const wchar_t *p; - int len, cidx; + int len, cidx, cols; if(!str) { return; @@ -267,6 +267,7 @@ void indentprint(const char *str, int indent) if(!p) { return; } + cols = getcols(); while(*p) { if(*p == L' ') { @@ -283,7 +284,7 @@ void indentprint(const char *str, int indent) while(q < next) { len += wcwidth(*q++); } - if(len > (getcols() - cidx - 1)) { + if(len > (cols - cidx - 1)) { /* wrap to a newline and reindent */ fprintf(stdout, "\n%-*s", indent, ""); cidx = indent; diff --git a/src/pacman/util.h b/src/pacman/util.h index f94f0aed..5eeec8d2 100644 --- a/src/pacman/util.h +++ b/src/pacman/util.h @@ -37,9 +37,9 @@ #define UPDATE_SPEED_SEC 0.2f int trans_init(pmtranstype_t type, pmtransflag_t flags); -int trans_release(); -int needs_transaction(); -int getcols(); +int trans_release(void); +int needs_transaction(void); +int getcols(void); int makepath(const char *path); int rmrf(const char *path); char *mbasename(const char *path); -- cgit v1.2.3 From 927ce2b7a52360507da3d81804520dbba4a9700d Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sun, 31 Aug 2008 18:38:23 -0500 Subject: Rework fakechroot checking Do the checks in the tests that need it, and get rid of some of the cluttered output when it is not available (one line per test run). Signed-off-by: Dan McGee --- pactest/pmtest.py | 4 +--- pactest/tests/scriptlet001.py | 4 ++++ pactest/tests/scriptlet002.py | 4 ++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/pactest/pmtest.py b/pactest/pmtest.py index 39f4deab..7bb32812 100755 --- a/pactest/pmtest.py +++ b/pactest/pmtest.py @@ -197,9 +197,7 @@ class pmtest: cmd.append("fakeroot") fakechroot = which("fakechroot") - if not fakechroot: - print "WARNING: fakechroot not found, scriptlet tests WILL fail!!!" - else: + if fakechroot: cmd.append("fakechroot") if pacman["gdb"]: diff --git a/pactest/tests/scriptlet001.py b/pactest/tests/scriptlet001.py index 54a46aae..ff7fcd20 100644 --- a/pactest/tests/scriptlet001.py +++ b/pactest/tests/scriptlet001.py @@ -14,3 +14,7 @@ self.args = "--debug -U %s" % p1.filename() self.addrule("PACMAN_RETCODE=0") self.addrule("PACMAN_OUTPUT=" + pre) self.addrule("PACMAN_OUTPUT=" + post) + +fakechroot = which("fakechroot") +if not fakechroot: + self.expectfailure = True diff --git a/pactest/tests/scriptlet002.py b/pactest/tests/scriptlet002.py index dd792b82..cc316a10 100644 --- a/pactest/tests/scriptlet002.py +++ b/pactest/tests/scriptlet002.py @@ -14,3 +14,7 @@ self.args = "--debug -R %s" % p1.name self.addrule("PACMAN_RETCODE=0") self.addrule("PACMAN_OUTPUT=" + pre) self.addrule("PACMAN_OUTPUT=" + post) + +fakechroot = which("fakechroot") +if not fakechroot: + self.expectfailure = True -- cgit v1.2.3 From d7e502a467c054cf3bf7c50362ff7f8087b0c382 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Tue, 5 Aug 2008 21:03:59 -0500 Subject: Attempt to idiot-proof making and refreshing docs I mess this up more often than not, and maybe this will do the trick. Remove the --enable-asciidoc option as it has been superseded by the --disable-doc option in usefulness. If you want to skip building docs, you skip building all docs which is much easier when it comes to ensuring the make 'dist' and 'distcheck' targets will always build the manpages and always build the most up to date manpages. Developers shouldn't be affected in their normal builds, nor should end users of the source tarball. Signed-off-by: Dan McGee --- Makefile.am | 3 +++ configure.ac | 23 ----------------------- doc/Makefile.am | 22 ++++++++++++---------- 3 files changed, 15 insertions(+), 33 deletions(-) diff --git a/Makefile.am b/Makefile.am index ea3b0e07..ed9a34d3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3,6 +3,9 @@ if WANT_DOC SUBDIRS += doc endif +# Make sure we test and build manpages when doing distcheck +DISTCHECK_CONFIGURE_FLAGS = --enable-doc --disable-git-version + # Some files automatically included, so they aren't specified below: # AUTHORS, COPYING, NEWS, README EXTRA_DIST = HACKING diff --git a/configure.ac b/configure.ac index 3a032d1a..c3b3722c 100644 --- a/configure.ac +++ b/configure.ac @@ -103,11 +103,6 @@ AC_ARG_ENABLE(doxygen, AS_HELP_STRING([--enable-doxygen], [build your own API docs via Doxygen]), [wantdoxygen=$enableval], [wantdoxygen=no]) -# Help line for asciidoc -AC_ARG_ENABLE(asciidoc, - AS_HELP_STRING([--enable-asciidoc], [build your own manpages with Asciidoc]), - [wantasciidoc=$enableval], [wantasciidoc=no]) - # Help line for debug AC_ARG_ENABLE(debug, AS_HELP_STRING([--enable-debug], [enable debugging support]), @@ -273,23 +268,6 @@ else fi AM_CONDITIONAL(USE_DOXYGEN, test "x$usedoxygen" = "xyes") -# Check for asciidoc support and status -AC_CHECK_PROGS([ASCIIDOC], [asciidoc]) -AC_MSG_CHECKING([for asciidoc]) -if test "x$wantasciidoc" = "xyes" ; then - if test $ASCIIDOC ; then - AC_MSG_RESULT([yes]) - useasciidoc=yes - else - AC_MSG_RESULT([no, asciidoc missing]) - useasciidoc=no - fi -else - AC_MSG_RESULT([no, disabled by configure]) - useasciidoc=no -fi -AM_CONDITIONAL(USE_ASCIIDOC, test "x$useasciidoc" = "xyes") - # Enable or disable debug code AC_MSG_CHECKING(for debug mode request) if test "x$debug" = "xyes" ; then @@ -388,7 +366,6 @@ ${PACKAGE_NAME}: Run make in doc/ dir : ${wantdoc} Use download library : ${internaldownload} Doxygen support : ${usedoxygen} - Asciidoc support : ${useasciidoc} debug support : ${debug} " diff --git a/doc/Makefile.am b/doc/Makefile.am index 476a21c3..cce0a711 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -15,6 +15,7 @@ ASCIIDOC_MANS = \ DOXYGEN_MANS = $(wildcard man3/*.3) EXTRA_DIST = \ + asciidoc.conf \ pacman.8.txt \ makepkg.8.txt \ repo-add.8.txt \ @@ -29,8 +30,12 @@ EXTRA_DIST = \ $(DOXYGEN_MANS) # Files that should be removed, but which Automake does not know. -MOSTLYCLEANFILES = *.xml -MAINTAINERCLEANFILES = $(ASCIIDOC_MANS) +MOSTLYCLEANFILES = *.xml $(ASCIIDOC_MANS) + +# Ensure manpages are fresh when building a dist tarball +dist-hook: + $(MAKE) $(AM_MAKEFLAGS) clean + $(MAKE) $(AM_MAKEFLAGS) all if USE_GIT_VERSION GIT_VERSION := $(shell sh -c 'git describe --abbrev=4 | sed s/^v//')-dirty @@ -39,20 +44,18 @@ else REAL_PACKAGE_VERSION = $(PACKAGE_VERSION) endif - man_MANS = dist_man_MANS = $(ASCIIDOC_MANS) repo-remove.8 if USE_DOXYGEN man_MANS += $(DOXYGEN_MANS) -all: doxygen.in +all-local: doxygen.in doxygen.in: $(DOXYGEN) $(srcdir)/Doxyfile endif -if USE_ASCIIDOC ASCIIDOC_OPTS = \ -f asciidoc.conf \ -a pacman_version="$(REAL_PACKAGE_VERSION)" \ @@ -64,11 +67,10 @@ A2X_OPTS = \ --xsltproc-opts='-param man.endnotes.list.enabled 0' \ --xsltproc-opts='-param man.endnotes.are.numbered 0' -$(ASCIIDOC_MANS): - a2x $(A2X_OPTS) --asciidoc-opts="$(ASCIIDOC_OPTS)" $@.txt - # These rules are due to the includes and files of the asciidoc text $(ASCIIDOC_MANS): asciidoc.conf footer.txt + a2x $(A2X_OPTS) --asciidoc-opts="$(ASCIIDOC_OPTS)" $@.txt + pacman.8: pacman.8.txt makepkg.8: makepkg.8.txt repo-add.8: repo-add.8.txt @@ -78,7 +80,7 @@ pacman.conf.5: pacman.conf.5.txt libalpm.3: libalpm.3.txt # this one is just a symlink repo-remove.8: repo-add.8 - ln -s repo-add.8 repo-remove.8 -endif + rm -f repo-remove.8 + $(LN_S) repo-add.8 repo-remove.8 # vim:set ts=2 sw=2 noet: -- cgit v1.2.3 From f0e1846b51dfdeb095038b6b04d307ddfdec0029 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Wed, 10 Sep 2008 14:32:24 -0500 Subject: Remove unnecessary unistd.h header inclusion Signed-off-by: Dan McGee --- lib/libalpm/cache.c | 1 - lib/libalpm/conflict.c | 1 - lib/libalpm/db.c | 1 - lib/libalpm/package.c | 1 - 4 files changed, 4 deletions(-) diff --git a/lib/libalpm/cache.c b/lib/libalpm/cache.c index 032cc978..10857792 100644 --- a/lib/libalpm/cache.c +++ b/lib/libalpm/cache.c @@ -19,7 +19,6 @@ #include "config.h" -#include #include #include #include diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c index a8bcdd59..a044fc60 100644 --- a/lib/libalpm/conflict.c +++ b/lib/libalpm/conflict.c @@ -25,7 +25,6 @@ #include #include -#include #include #include #include diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c index 191c8ba0..5632ffac 100644 --- a/lib/libalpm/db.c +++ b/lib/libalpm/db.c @@ -23,7 +23,6 @@ #include "config.h" -#include #include #include #include diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c index eaef688d..a9f4b43d 100644 --- a/lib/libalpm/package.c +++ b/lib/libalpm/package.c @@ -30,7 +30,6 @@ #include #include #include -#include /* libarchive */ #include -- cgit v1.2.3 From 30851a24ff68b00898565a1144926d83c623e6bf Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sun, 12 Oct 2008 21:07:49 -0500 Subject: Make interrupt handler async-safe Calling printf() in a signal handler can be dangerous, so avoid it by writing directly which is guaranteed to be safe according to signal(7). Signed-off-by: Dan McGee --- src/pacman/pacman.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 3a56a9d3..0e133df6 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -36,6 +36,7 @@ #include /* uname */ #include /* setlocale */ #include /* time_t */ +#include #if defined(PACMAN_DEBUG) && defined(HAVE_MCHECK_H) #include /* debug tracing (mtrace) */ #endif @@ -211,21 +212,34 @@ static void cleanup(int ret) { exit(ret); } +/** Write function that correctly handles EINTR. + */ +static ssize_t xwrite(int fd, const void *buf, size_t count) +{ + ssize_t ret; + while((ret = write(fd, buf, count)) == -1 && errno == EINTR); + return(ret); +} + /** Catches thrown signals. Performs necessary cleanup to ensure database is * in a consistant state. * @param signum the thrown signal */ static RETSIGTYPE handler(int signum) { - if(signum==SIGSEGV) - { - /* write a log message and write to stderr */ - pm_printf(PM_LOG_ERROR, _("segmentation fault\n")); - pm_fprintf(stderr, PM_LOG_ERROR, - _("Internal pacman error: Segmentation fault.\n" - "Please submit a full bug report with --debug if appropriate.\n")); + int out = fileno(stdout); + int err = fileno(stderr); + if(signum == SIGSEGV) { + const char *msg1 = "error: segmentation fault\n"; + const char *msg2 = "Internal pacman error: Segmentation fault.\n" + "Please submit a full bug report with --debug if appropriate.\n"; + /* write a error message to out, the rest to err */ + xwrite(out, msg1, strlen(msg1)); + xwrite(err, msg2, strlen(msg2)); exit(signum); } else if((signum == SIGINT)) { + const char *msg = "\nInterrupt signal received\n"; + xwrite(err, msg, strlen(msg)); if(alpm_trans_interrupt() == 0) { /* a transaction is being interrupted, don't exit pacman yet. */ return; @@ -233,7 +247,7 @@ static RETSIGTYPE handler(int signum) /* no commiting transaction, we can release it now and then exit pacman */ alpm_trans_release(); /* output a newline to be sure we clear any line we may be on */ - printf("\n"); + xwrite(out, "\n", 1); } cleanup(signum); } -- cgit v1.2.3