summaryrefslogtreecommitdiff
path: root/lib/libalpm/util.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-06-07 16:13:58 -0500
committerDan McGee <dan@archlinux.org>2011-06-13 19:41:16 -0500
commit52bffd2457b7ba3b6fb08d3aa959ea0b53a45dc8 (patch)
treef426280f674b10c2175bd99feba8ec0e42d7b0de /lib/libalpm/util.c
parente2aa952689da8763d534d1c19310eb97009f4f76 (diff)
downloadpacman-52bffd2457b7ba3b6fb08d3aa959ea0b53a45dc8.tar.xz
Switch all logging to use handle directly
This is the last user of our global handle object. Once again the diff is large but the functional changes are not. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/util.c')
-rw-r--r--lib/libalpm/util.c51
1 files changed, 25 insertions, 26 deletions
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c
index 1e6dd617..357ce506 100644
--- a/lib/libalpm/util.c
+++ b/lib/libalpm/util.c
@@ -262,7 +262,7 @@ int _alpm_unpack(pmhandle_t *handle, const char *archive, const char *prefix,
if(archive_read_open_filename(_archive, archive,
ARCHIVE_DEFAULT_BYTES_PER_BLOCK) != ARCHIVE_OK) {
- _alpm_log(PM_LOG_ERROR, _("could not open file %s: %s\n"), archive,
+ _alpm_log(handle, PM_LOG_ERROR, _("could not open file %s: %s\n"), archive,
archive_error_string(_archive));
RET_ERR(handle, PM_ERR_PKG_OPEN, 1);
}
@@ -271,14 +271,14 @@ int _alpm_unpack(pmhandle_t *handle, const char *archive, const char *prefix,
/* save the cwd so we can restore it later */
if(getcwd(cwd, PATH_MAX) == NULL) {
- _alpm_log(PM_LOG_ERROR, _("could not get current working directory\n"));
+ _alpm_log(handle, PM_LOG_ERROR, _("could not get current working directory\n"));
} else {
restore_cwd = 1;
}
/* just in case our cwd was removed in the upgrade operation */
if(chdir(prefix) != 0) {
- _alpm_log(PM_LOG_ERROR, _("could not change directory to %s (%s)\n"),
+ _alpm_log(handle, PM_LOG_ERROR, _("could not change directory to %s (%s)\n"),
prefix, strerror(errno));
ret = 1;
goto cleanup;
@@ -313,7 +313,7 @@ int _alpm_unpack(pmhandle_t *handle, const char *archive, const char *prefix,
}
continue;
} else {
- _alpm_log(PM_LOG_DEBUG, "extracting: %s\n", entryname);
+ _alpm_log(handle, PM_LOG_DEBUG, "extracting: %s\n", entryname);
}
}
@@ -321,10 +321,10 @@ int _alpm_unpack(pmhandle_t *handle, const char *archive, const char *prefix,
int readret = archive_read_extract(_archive, entry, 0);
if(readret == ARCHIVE_WARN) {
/* operation succeeded but a non-critical error was encountered */
- _alpm_log(PM_LOG_WARNING, _("warning given when extracting %s (%s)\n"),
+ _alpm_log(handle, PM_LOG_WARNING, _("warning given when extracting %s (%s)\n"),
entryname, archive_error_string(_archive));
} else if(readret != ARCHIVE_OK) {
- _alpm_log(PM_LOG_ERROR, _("could not extract %s (%s)\n"),
+ _alpm_log(handle, PM_LOG_ERROR, _("could not extract %s (%s)\n"),
entryname, archive_error_string(_archive));
ret = 1;
goto cleanup;
@@ -339,7 +339,7 @@ cleanup:
umask(oldmask);
archive_read_finish(_archive);
if(restore_cwd && chdir(cwd) != 0) {
- _alpm_log(PM_LOG_ERROR, _("could not change directory to %s (%s)\n"),
+ _alpm_log(handle, PM_LOG_ERROR, _("could not change directory to %s (%s)\n"),
cwd, strerror(errno));
}
return ret;
@@ -429,26 +429,26 @@ int _alpm_run_chroot(pmhandle_t *handle, const char *path, char *const argv[])
/* save the cwd so we can restore it later */
if(getcwd(cwd, PATH_MAX) == NULL) {
- _alpm_log(PM_LOG_ERROR, _("could not get current working directory\n"));
+ _alpm_log(handle, PM_LOG_ERROR, _("could not get current working directory\n"));
} else {
restore_cwd = 1;
}
/* just in case our cwd was removed in the upgrade operation */
if(chdir(handle->root) != 0) {
- _alpm_log(PM_LOG_ERROR, _("could not change directory to %s (%s)\n"),
+ _alpm_log(handle, PM_LOG_ERROR, _("could not change directory to %s (%s)\n"),
handle->root, strerror(errno));
goto cleanup;
}
- _alpm_log(PM_LOG_DEBUG, "executing \"%s\" under chroot \"%s\"\n",
+ _alpm_log(handle, PM_LOG_DEBUG, "executing \"%s\" under chroot \"%s\"\n",
path, handle->root);
/* Flush open fds before fork() to avoid cloning buffers */
fflush(NULL);
if(pipe(pipefd) == -1) {
- _alpm_log(PM_LOG_ERROR, _("could not create pipe (%s)\n"), strerror(errno));
+ _alpm_log(handle, PM_LOG_ERROR, _("could not create pipe (%s)\n"), strerror(errno));
retval = 1;
goto cleanup;
}
@@ -456,7 +456,7 @@ int _alpm_run_chroot(pmhandle_t *handle, const char *path, char *const argv[])
/* fork- parent and child each have seperate code blocks below */
pid = fork();
if(pid == -1) {
- _alpm_log(PM_LOG_ERROR, _("could not fork a new process (%s)\n"), strerror(errno));
+ _alpm_log(handle, PM_LOG_ERROR, _("could not fork a new process (%s)\n"), strerror(errno));
retval = 1;
goto cleanup;
}
@@ -507,7 +507,7 @@ int _alpm_run_chroot(pmhandle_t *handle, const char *path, char *const argv[])
while(waitpid(pid, &status, 0) == -1) {
if(errno != EINTR) {
- _alpm_log(PM_LOG_ERROR, _("call to waitpid failed (%s)\n"), strerror(errno));
+ _alpm_log(handle, PM_LOG_ERROR, _("call to waitpid failed (%s)\n"), strerror(errno));
retval = 1;
goto cleanup;
}
@@ -515,14 +515,14 @@ int _alpm_run_chroot(pmhandle_t *handle, const char *path, char *const argv[])
/* report error from above after the child has exited */
if(retval != 0) {
- _alpm_log(PM_LOG_ERROR, _("could not open pipe (%s)\n"), strerror(errno));
+ _alpm_log(handle, PM_LOG_ERROR, _("could not open pipe (%s)\n"), strerror(errno));
goto cleanup;
}
/* check the return status, make sure it is 0 (success) */
if(WIFEXITED(status)) {
- _alpm_log(PM_LOG_DEBUG, "call to waitpid succeeded\n");
+ _alpm_log(handle, PM_LOG_DEBUG, "call to waitpid succeeded\n");
if(WEXITSTATUS(status) != 0) {
- _alpm_log(PM_LOG_ERROR, _("command failed to execute correctly\n"));
+ _alpm_log(handle, PM_LOG_ERROR, _("command failed to execute correctly\n"));
retval = 1;
}
}
@@ -530,7 +530,7 @@ int _alpm_run_chroot(pmhandle_t *handle, const char *path, char *const argv[])
cleanup:
if(restore_cwd && chdir(cwd) != 0) {
- _alpm_log(PM_LOG_ERROR, _("could not change directory to %s (%s)\n"), cwd, strerror(errno));
+ _alpm_log(handle, PM_LOG_ERROR, _("could not change directory to %s (%s)\n"), cwd, strerror(errno));
}
return retval;
@@ -540,7 +540,7 @@ int _alpm_ldconfig(pmhandle_t *handle)
{
char line[PATH_MAX];
- _alpm_log(PM_LOG_DEBUG, "running ldconfig\n");
+ _alpm_log(handle, PM_LOG_DEBUG, "running ldconfig\n");
snprintf(line, PATH_MAX, "%setc/ld.so.conf", handle->root);
if(access(line, F_OK) == 0) {
@@ -579,7 +579,7 @@ char *_alpm_filecache_find(pmhandle_t *handle, const char *filename)
filename);
if(stat(path, &buf) == 0 && S_ISREG(buf.st_mode)) {
retpath = strdup(path);
- _alpm_log(PM_LOG_DEBUG, "found cached pkg: %s\n", retpath);
+ _alpm_log(handle, PM_LOG_DEBUG, "found cached pkg: %s\n", retpath);
return retpath;
}
}
@@ -603,17 +603,17 @@ const char *_alpm_filecache_setup(pmhandle_t *handle)
cachedir = alpm_list_getdata(i);
if(stat(cachedir, &buf) != 0) {
/* cache directory does not exist.... try creating it */
- _alpm_log(PM_LOG_WARNING, _("no %s cache exists, creating...\n"),
+ _alpm_log(handle, PM_LOG_WARNING, _("no %s cache exists, creating...\n"),
cachedir);
if(_alpm_makepath(cachedir) == 0) {
- _alpm_log(PM_LOG_DEBUG, "using cachedir: %s\n", cachedir);
+ _alpm_log(handle, PM_LOG_DEBUG, "using cachedir: %s\n", cachedir);
return cachedir;
}
} else if(S_ISDIR(buf.st_mode) && (buf.st_mode & S_IWUSR)) {
- _alpm_log(PM_LOG_DEBUG, "using cachedir: %s\n", cachedir);
+ _alpm_log(handle, PM_LOG_DEBUG, "using cachedir: %s\n", cachedir);
return cachedir;
} else {
- _alpm_log(PM_LOG_DEBUG, "skipping cachedir: %s\n", cachedir);
+ _alpm_log(handle, PM_LOG_DEBUG, "skipping cachedir: %s\n", cachedir);
}
}
@@ -621,8 +621,8 @@ const char *_alpm_filecache_setup(pmhandle_t *handle)
tmp = alpm_list_add(NULL, "/tmp/");
alpm_option_set_cachedirs(handle, tmp);
alpm_list_free(tmp);
- _alpm_log(PM_LOG_DEBUG, "using cachedir: %s\n", "/tmp/");
- _alpm_log(PM_LOG_WARNING, _("couldn't create package cache, using /tmp instead\n"));
+ _alpm_log(handle, PM_LOG_DEBUG, "using cachedir: %s\n", "/tmp/");
+ _alpm_log(handle, PM_LOG_WARNING, _("couldn't create package cache, using /tmp instead\n"));
return "/tmp/";
}
@@ -716,7 +716,6 @@ char SYMEXPORT *alpm_compute_md5sum(const char *filename)
}
md5sum[32] = '\0';
- _alpm_log(PM_LOG_DEBUG, "md5(%s) = %s\n", filename, md5sum);
return md5sum;
}