Merge branch 'maint'

This commit is contained in:
Dan McGee 2008-10-12 21:36:45 -05:00
commit fa02a71abd
17 changed files with 82 additions and 71 deletions

View file

@ -3,6 +3,9 @@ if WANT_DOC
SUBDIRS += doc SUBDIRS += doc
endif 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: # Some files automatically included, so they aren't specified below:
# AUTHORS, COPYING, NEWS, README # AUTHORS, COPYING, NEWS, README
EXTRA_DIST = HACKING EXTRA_DIST = HACKING

View file

@ -103,11 +103,6 @@ AC_ARG_ENABLE(doxygen,
AS_HELP_STRING([--enable-doxygen], [build your own API docs via Doxygen]), AS_HELP_STRING([--enable-doxygen], [build your own API docs via Doxygen]),
[wantdoxygen=$enableval], [wantdoxygen=no]) [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 # Help line for debug
AC_ARG_ENABLE(debug, AC_ARG_ENABLE(debug,
AS_HELP_STRING([--enable-debug], [enable debugging support]), AS_HELP_STRING([--enable-debug], [enable debugging support]),
@ -273,23 +268,6 @@ else
fi fi
AM_CONDITIONAL(USE_DOXYGEN, test "x$usedoxygen" = "xyes") 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 # Enable or disable debug code
AC_MSG_CHECKING(for debug mode request) AC_MSG_CHECKING(for debug mode request)
if test "x$debug" = "xyes" ; then if test "x$debug" = "xyes" ; then
@ -389,7 +367,6 @@ ${PACKAGE_NAME}:
Run make in doc/ dir : ${wantdoc} Run make in doc/ dir : ${wantdoc}
Use download library : ${internaldownload} Use download library : ${internaldownload}
Doxygen support : ${usedoxygen} Doxygen support : ${usedoxygen}
Asciidoc support : ${useasciidoc}
debug support : ${debug} debug support : ${debug}
" "

View file

@ -15,6 +15,7 @@ ASCIIDOC_MANS = \
DOXYGEN_MANS = $(wildcard man3/*.3) DOXYGEN_MANS = $(wildcard man3/*.3)
EXTRA_DIST = \ EXTRA_DIST = \
asciidoc.conf \
pacman.8.txt \ pacman.8.txt \
makepkg.8.txt \ makepkg.8.txt \
repo-add.8.txt \ repo-add.8.txt \
@ -29,8 +30,12 @@ EXTRA_DIST = \
$(DOXYGEN_MANS) $(DOXYGEN_MANS)
# Files that should be removed, but which Automake does not know. # Files that should be removed, but which Automake does not know.
MOSTLYCLEANFILES = *.xml MOSTLYCLEANFILES = *.xml $(ASCIIDOC_MANS)
MAINTAINERCLEANFILES = $(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 if USE_GIT_VERSION
GIT_VERSION := $(shell sh -c 'git describe --abbrev=4 | sed s/^v//')-dirty GIT_VERSION := $(shell sh -c 'git describe --abbrev=4 | sed s/^v//')-dirty
@ -39,20 +44,18 @@ else
REAL_PACKAGE_VERSION = $(PACKAGE_VERSION) REAL_PACKAGE_VERSION = $(PACKAGE_VERSION)
endif endif
man_MANS = man_MANS =
dist_man_MANS = $(ASCIIDOC_MANS) repo-remove.8 dist_man_MANS = $(ASCIIDOC_MANS) repo-remove.8
if USE_DOXYGEN if USE_DOXYGEN
man_MANS += $(DOXYGEN_MANS) man_MANS += $(DOXYGEN_MANS)
all: doxygen.in all-local: doxygen.in
doxygen.in: doxygen.in:
$(DOXYGEN) $(srcdir)/Doxyfile $(DOXYGEN) $(srcdir)/Doxyfile
endif endif
if USE_ASCIIDOC
ASCIIDOC_OPTS = \ ASCIIDOC_OPTS = \
-f asciidoc.conf \ -f asciidoc.conf \
-a pacman_version="$(REAL_PACKAGE_VERSION)" \ -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.list.enabled 0' \
--xsltproc-opts='-param man.endnotes.are.numbered 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 # These rules are due to the includes and files of the asciidoc text
$(ASCIIDOC_MANS): asciidoc.conf footer.txt $(ASCIIDOC_MANS): asciidoc.conf footer.txt
a2x $(A2X_OPTS) --asciidoc-opts="$(ASCIIDOC_OPTS)" $@.txt
pacman.8: pacman.8.txt pacman.8: pacman.8.txt
makepkg.8: makepkg.8.txt makepkg.8: makepkg.8.txt
repo-add.8: repo-add.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 libalpm.3: libalpm.3.txt
# this one is just a symlink # this one is just a symlink
repo-remove.8: repo-add.8 repo-remove.8: repo-add.8
ln -s repo-add.8 repo-remove.8 rm -f repo-remove.8
endif $(LN_S) repo-add.8 repo-remove.8
# vim:set ts=2 sw=2 noet: # vim:set ts=2 sw=2 noet:

View file

@ -19,7 +19,6 @@
#include "config.h" #include "config.h"
#include <unistd.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <errno.h> #include <errno.h>

View file

@ -25,7 +25,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <unistd.h>
#include <string.h> #include <string.h>
#include <limits.h> #include <limits.h>
#include <sys/stat.h> #include <sys/stat.h>

View file

@ -23,7 +23,6 @@
#include "config.h" #include "config.h"
#include <unistd.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <errno.h> #include <errno.h>

View file

@ -30,7 +30,6 @@
#include <errno.h> #include <errno.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h>
/* libarchive */ /* libarchive */
#include <archive.h> #include <archive.h>

View file

@ -30,7 +30,6 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/statvfs.h> #include <sys/statvfs.h>
#include <unistd.h>
#include <errno.h> #include <errno.h>
/* libalpm */ /* libalpm */
@ -205,7 +204,7 @@ int SYMEXPORT alpm_trans_release()
/* unlock db */ /* unlock db */
if(handle->lckfd != -1) { if(handle->lckfd != -1) {
close(handle->lckfd); while(close(handle->lckfd) == -1 && errno == EINTR);
handle->lckfd = -1; handle->lckfd = -1;
} }
if(_alpm_lckrm()) { if(_alpm_lckrm()) {
@ -567,7 +566,7 @@ int _alpm_runscriptlet(const char *root, const char *installfn,
/* this code runs for the parent only (wait on the child) */ /* this code runs for the parent only (wait on the child) */
pid_t retpid; pid_t retpid;
int status; int status;
retpid = waitpid(pid, &status, 0); while((retpid = waitpid(pid, &status, 0)) == -1 && errno == EINTR);
if(retpid == -1) { if(retpid == -1) {
_alpm_log(PM_LOG_ERROR, _("call to waitpid failed (%s)\n"), _alpm_log(PM_LOG_ERROR, _("call to waitpid failed (%s)\n"),
strerror(errno)); strerror(errno));

View file

@ -254,7 +254,8 @@ int _alpm_lckmk()
_alpm_makepath(dir); _alpm_makepath(dir);
FREE(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); return(fd > 0 ? fd : -1);
} }

View file

@ -197,9 +197,7 @@ class pmtest:
cmd.append("fakeroot") cmd.append("fakeroot")
fakechroot = which("fakechroot") fakechroot = which("fakechroot")
if not fakechroot: if fakechroot:
print "WARNING: fakechroot not found, scriptlet tests WILL fail!!!"
else:
cmd.append("fakechroot") cmd.append("fakechroot")
if pacman["gdb"]: if pacman["gdb"]:

View file

@ -14,3 +14,7 @@ self.args = "--debug -U %s" % p1.filename()
self.addrule("PACMAN_RETCODE=0") self.addrule("PACMAN_RETCODE=0")
self.addrule("PACMAN_OUTPUT=" + pre) self.addrule("PACMAN_OUTPUT=" + pre)
self.addrule("PACMAN_OUTPUT=" + post) self.addrule("PACMAN_OUTPUT=" + post)
fakechroot = which("fakechroot")
if not fakechroot:
self.expectfailure = True

View file

@ -14,3 +14,7 @@ self.args = "--debug -R %s" % p1.name
self.addrule("PACMAN_RETCODE=0") self.addrule("PACMAN_RETCODE=0")
self.addrule("PACMAN_OUTPUT=" + pre) self.addrule("PACMAN_OUTPUT=" + pre)
self.addrule("PACMAN_OUTPUT=" + post) self.addrule("PACMAN_OUTPUT=" + post)
fakechroot = which("fakechroot")
if not fakechroot:
self.expectfailure = True

View file

@ -137,11 +137,9 @@ static void fill_progress(const int bar_percent, const int disp_percent,
} }
printf("]"); printf("]");
} }
/* print percent after progress bar */ /* print display percent after progress bar */
if(proglen > 5) { if(proglen > 5) {
/* show total download percent if option is enabled */ printf(" %3d%%", disp_percent);
int p = config->totaldownload ? disp_percent : bar_percent;
printf(" %3d%%", p);
} }
if(bar_percent == 100) { if(bar_percent == 100) {
@ -435,6 +433,7 @@ void cb_dl_progress(const char *filename, off_t file_xfered, off_t file_total)
int len, wclen, wcwid, padwid; int len, wclen, wcwid, padwid;
wchar_t *wcfname; wchar_t *wcfname;
int totaldownload;
off_t xfered, total; off_t xfered, total;
float rate = 0.0, timediff = 0.0, f_xfered = 0.0; float rate = 0.0, timediff = 0.0, f_xfered = 0.0;
unsigned int eta_h = 0, eta_m = 0, eta_s = 0; unsigned int eta_h = 0, eta_m = 0, eta_s = 0;
@ -450,6 +449,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 */ /* only use TotalDownload if enabled and we have a callback value */
if(config->totaldownload && list_total) { if(config->totaldownload && list_total) {
totaldownload = 1;
} else {
totaldownload = 0;
}
if(totaldownload) {
xfered = list_xfered + file_xfered; xfered = list_xfered + file_xfered;
total = list_total; total = list_total;
} else { } else {
@ -462,8 +467,7 @@ void cb_dl_progress(const char *filename, off_t file_xfered, off_t file_total)
if(file_xfered == 0) { if(file_xfered == 0) {
/* set default starting values, ensure we only call this once /* set default starting values, ensure we only call this once
* if TotalDownload is enabled */ * if TotalDownload is enabled */
if(!(config->totaldownload) if(!totaldownload || (totaldownload && list_xfered == 0)) {
|| (config->totaldownload && list_xfered == 0)) {
gettimeofday(&initial_time, NULL); gettimeofday(&initial_time, NULL);
xfered_last = (off_t)0; xfered_last = (off_t)0;
rate_last = 0.0; rate_last = 0.0;
@ -500,7 +504,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; 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) / total_percent = (int)((float)list_xfered + file_xfered) /
((float)list_total) * 100; ((float)list_total) * 100;
@ -581,7 +585,11 @@ void cb_dl_progress(const char *filename, off_t file_xfered, off_t file_total)
free(fname); free(fname);
free(wcfname); 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; return;
} }

View file

@ -135,9 +135,11 @@ void dump_pkg_full(pmpkg_t *pkg, int level)
/* Print additional package info if info flag passed more than once */ /* Print additional package info if info flag passed more than once */
if(level > 1) { if(level > 1) {
dump_pkg_backups(pkg); dump_pkg_backups(pkg);
printf("\n");
} }
/* final newline to separate packages */
printf("\n");
FREELIST(depstrings); FREELIST(depstrings);
} }

View file

@ -36,6 +36,7 @@
#include <sys/utsname.h> /* uname */ #include <sys/utsname.h> /* uname */
#include <locale.h> /* setlocale */ #include <locale.h> /* setlocale */
#include <time.h> /* time_t */ #include <time.h> /* time_t */
#include <errno.h>
#if defined(PACMAN_DEBUG) && defined(HAVE_MCHECK_H) #if defined(PACMAN_DEBUG) && defined(HAVE_MCHECK_H)
#include <mcheck.h> /* debug tracing (mtrace) */ #include <mcheck.h> /* debug tracing (mtrace) */
#endif #endif
@ -211,21 +212,34 @@ static void cleanup(int ret) {
exit(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 /** Catches thrown signals. Performs necessary cleanup to ensure database is
* in a consistant state. * in a consistant state.
* @param signum the thrown signal * @param signum the thrown signal
*/ */
static RETSIGTYPE handler(int signum) static RETSIGTYPE handler(int signum)
{ {
if(signum==SIGSEGV) int out = fileno(stdout);
{ int err = fileno(stderr);
/* write a log message and write to stderr */ if(signum == SIGSEGV) {
pm_printf(PM_LOG_ERROR, _("segmentation fault\n")); const char *msg1 = "error: segmentation fault\n";
pm_fprintf(stderr, PM_LOG_ERROR, const char *msg2 = "Internal pacman error: Segmentation fault.\n"
_("Internal pacman error: Segmentation fault.\n" "Please submit a full bug report with --debug if appropriate.\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); exit(signum);
} else if((signum == SIGINT)) { } else if((signum == SIGINT)) {
const char *msg = "\nInterrupt signal received\n";
xwrite(err, msg, strlen(msg));
if(alpm_trans_interrupt() == 0) { if(alpm_trans_interrupt() == 0) {
/* a transaction is being interrupted, don't exit pacman yet. */ /* a transaction is being interrupted, don't exit pacman yet. */
return; return;
@ -233,7 +247,7 @@ static RETSIGTYPE handler(int signum)
/* no commiting transaction, we can release it now and then exit pacman */ /* no commiting transaction, we can release it now and then exit pacman */
alpm_trans_release(); alpm_trans_release();
/* output a newline to be sure we clear any line we may be on */ /* output a newline to be sure we clear any line we may be on */
printf("\n"); xwrite(out, "\n", 1);
} }
cleanup(signum); cleanup(signum);
} }
@ -262,11 +276,13 @@ static void setlibpaths(void)
cleanup(ret); cleanup(ret);
} }
if(!config->dbpath) { 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); config->dbpath = strdup(path);
} }
if(!config->logfile) { 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); config->logfile = strdup(path);
} }
} }

View file

@ -59,7 +59,7 @@ int trans_init(pmtranstype_t type, pmtransflag_t flags)
return(0); return(0);
} }
int trans_release() int trans_release(void)
{ {
if(alpm_trans_release() == -1) { if(alpm_trans_release() == -1) {
pm_fprintf(stderr, PM_LOG_ERROR, _("failed to release transaction (%s)\n"), pm_fprintf(stderr, PM_LOG_ERROR, _("failed to release transaction (%s)\n"),
@ -69,7 +69,7 @@ int trans_release()
return(0); 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_MAIN && config->op != PM_OP_QUERY && config->op != PM_OP_DEPTEST) {
if((config->op == PM_OP_SYNC && !config->op_s_sync && if((config->op == PM_OP_SYNC && !config->op_s_sync &&
@ -85,7 +85,7 @@ int needs_transaction()
} }
/* gets the current screen column width */ /* gets the current screen column width */
int getcols() int getcols(void)
{ {
if(!isatty(1)) { if(!isatty(1)) {
/* We will default to 80 columns if we're not a tty /* 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; wchar_t *wcstr;
const wchar_t *p; const wchar_t *p;
int len, cidx; int len, cidx, cols;
if(!str) { if(!str) {
return; return;
@ -267,6 +267,7 @@ void indentprint(const char *str, int indent)
if(!p) { if(!p) {
return; return;
} }
cols = getcols();
while(*p) { while(*p) {
if(*p == L' ') { if(*p == L' ') {
@ -283,7 +284,7 @@ void indentprint(const char *str, int indent)
while(q < next) { while(q < next) {
len += wcwidth(*q++); len += wcwidth(*q++);
} }
if(len > (getcols() - cidx - 1)) { if(len > (cols - cidx - 1)) {
/* wrap to a newline and reindent */ /* wrap to a newline and reindent */
fprintf(stdout, "\n%-*s", indent, ""); fprintf(stdout, "\n%-*s", indent, "");
cidx = indent; cidx = indent;

View file

@ -37,9 +37,9 @@
#define UPDATE_SPEED_SEC 0.2f #define UPDATE_SPEED_SEC 0.2f
int trans_init(pmtranstype_t type, pmtransflag_t flags); int trans_init(pmtranstype_t type, pmtransflag_t flags);
int trans_release(); int trans_release(void);
int needs_transaction(); int needs_transaction(void);
int getcols(); int getcols(void);
int makepath(const char *path); int makepath(const char *path);
int rmrf(const char *path); int rmrf(const char *path);
char *mbasename(const char *path); char *mbasename(const char *path);