mirror of
https://github.com/moparisthebest/pacman
synced 2024-08-13 17:03:46 -04:00
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>
This commit is contained in:
parent
e2aa952689
commit
52bffd2457
@ -68,10 +68,10 @@ int SYMEXPORT alpm_add_pkg(pmhandle_t *handle, pmpkg_t *pkg)
|
|||||||
pkgname = pkg->name;
|
pkgname = pkg->name;
|
||||||
pkgver = pkg->version;
|
pkgver = pkg->version;
|
||||||
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "adding package '%s'\n", pkgname);
|
_alpm_log(handle, PM_LOG_DEBUG, "adding package '%s'\n", pkgname);
|
||||||
|
|
||||||
if(_alpm_pkg_find(trans->add, pkgname)) {
|
if(_alpm_pkg_find(trans->add, pkgname)) {
|
||||||
RET_ERR(pkg->handle, PM_ERR_TRANS_DUP_TARGET, -1);
|
RET_ERR(handle, PM_ERR_TRANS_DUP_TARGET, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
local = _alpm_db_get_pkgfromcache(handle->db_local, pkgname);
|
local = _alpm_db_get_pkgfromcache(handle->db_local, pkgname);
|
||||||
@ -83,23 +83,23 @@ int SYMEXPORT alpm_add_pkg(pmhandle_t *handle, pmpkg_t *pkg)
|
|||||||
if(cmp == 0) {
|
if(cmp == 0) {
|
||||||
if(trans->flags & PM_TRANS_FLAG_NEEDED) {
|
if(trans->flags & PM_TRANS_FLAG_NEEDED) {
|
||||||
/* with the NEEDED flag, packages up to date are not reinstalled */
|
/* with the NEEDED flag, packages up to date are not reinstalled */
|
||||||
_alpm_log(PM_LOG_WARNING, _("%s-%s is up to date -- skipping\n"),
|
_alpm_log(handle, PM_LOG_WARNING, _("%s-%s is up to date -- skipping\n"),
|
||||||
localpkgname, localpkgver);
|
localpkgname, localpkgver);
|
||||||
return 0;
|
return 0;
|
||||||
} else if(!(trans->flags & PM_TRANS_FLAG_DOWNLOADONLY)) {
|
} else if(!(trans->flags & PM_TRANS_FLAG_DOWNLOADONLY)) {
|
||||||
_alpm_log(PM_LOG_WARNING, _("%s-%s is up to date -- reinstalling\n"),
|
_alpm_log(handle, PM_LOG_WARNING, _("%s-%s is up to date -- reinstalling\n"),
|
||||||
localpkgname, localpkgver);
|
localpkgname, localpkgver);
|
||||||
}
|
}
|
||||||
} else if(cmp < 0) {
|
} else if(cmp < 0) {
|
||||||
/* local version is newer */
|
/* local version is newer */
|
||||||
_alpm_log(PM_LOG_WARNING, _("downgrading package %s (%s => %s)\n"),
|
_alpm_log(handle, PM_LOG_WARNING, _("downgrading package %s (%s => %s)\n"),
|
||||||
localpkgname, localpkgver, pkgver);
|
localpkgname, localpkgver, pkgver);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add the package to the transaction */
|
/* add the package to the transaction */
|
||||||
pkg->reason = PM_PKG_REASON_EXPLICIT;
|
pkg->reason = PM_PKG_REASON_EXPLICIT;
|
||||||
_alpm_log(PM_LOG_DEBUG, "adding package %s-%s to the transaction add list\n",
|
_alpm_log(handle, PM_LOG_DEBUG, "adding package %s-%s to the transaction add list\n",
|
||||||
pkgname, pkgver);
|
pkgname, pkgver);
|
||||||
trans->add = alpm_list_add(trans->add, pkg);
|
trans->add = alpm_list_add(trans->add, pkg);
|
||||||
|
|
||||||
@ -119,10 +119,10 @@ static int perform_extraction(pmhandle_t *handle, struct archive *archive,
|
|||||||
ret = archive_read_extract(archive, entry, archive_flags);
|
ret = archive_read_extract(archive, entry, archive_flags);
|
||||||
if(ret == ARCHIVE_WARN && archive_errno(archive) != ENOSPC) {
|
if(ret == ARCHIVE_WARN && archive_errno(archive) != ENOSPC) {
|
||||||
/* operation succeeded but a "non-critical" error was encountered */
|
/* 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"),
|
||||||
origname, archive_error_string(archive));
|
origname, archive_error_string(archive));
|
||||||
} else if(ret != ARCHIVE_OK) {
|
} else if(ret != 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"),
|
||||||
origname, archive_error_string(archive));
|
origname, archive_error_string(archive));
|
||||||
alpm_logaction(handle, "error: could not extract %s (%s)\n",
|
alpm_logaction(handle, "error: could not extract %s (%s)\n",
|
||||||
origname, archive_error_string(archive));
|
origname, archive_error_string(archive));
|
||||||
@ -160,7 +160,7 @@ static int extract_single_file(pmhandle_t *handle, struct archive *archive,
|
|||||||
} else if(*entryname == '.') {
|
} else if(*entryname == '.') {
|
||||||
/* for now, ignore all files starting with '.' that haven't
|
/* for now, ignore all files starting with '.' that haven't
|
||||||
* already been handled (for future possibilities) */
|
* already been handled (for future possibilities) */
|
||||||
_alpm_log(PM_LOG_DEBUG, "skipping extraction of '%s'\n", entryname);
|
_alpm_log(handle, PM_LOG_DEBUG, "skipping extraction of '%s'\n", entryname);
|
||||||
archive_read_data_skip(archive);
|
archive_read_data_skip(archive);
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
@ -170,7 +170,7 @@ static int extract_single_file(pmhandle_t *handle, struct archive *archive,
|
|||||||
|
|
||||||
/* if a file is in NoExtract then we never extract it */
|
/* if a file is in NoExtract then we never extract it */
|
||||||
if(alpm_list_find_str(handle->noextract, entryname)) {
|
if(alpm_list_find_str(handle->noextract, entryname)) {
|
||||||
_alpm_log(PM_LOG_DEBUG, "%s is in NoExtract, skipping extraction\n",
|
_alpm_log(handle, PM_LOG_DEBUG, "%s is in NoExtract, skipping extraction\n",
|
||||||
entryname);
|
entryname);
|
||||||
alpm_logaction(handle, "note: %s is in NoExtract, skipping extraction\n",
|
alpm_logaction(handle, "note: %s is in NoExtract, skipping extraction\n",
|
||||||
entryname);
|
entryname);
|
||||||
@ -209,20 +209,20 @@ static int extract_single_file(pmhandle_t *handle, struct archive *archive,
|
|||||||
if(lsbuf.st_mode != entrymode) {
|
if(lsbuf.st_mode != entrymode) {
|
||||||
/* if filesystem perms are different than pkg perms, warn user */
|
/* if filesystem perms are different than pkg perms, warn user */
|
||||||
mode_t mask = 07777;
|
mode_t mask = 07777;
|
||||||
_alpm_log(PM_LOG_WARNING, _("directory permissions differ on %s\n"
|
_alpm_log(handle, PM_LOG_WARNING, _("directory permissions differ on %s\n"
|
||||||
"filesystem: %o package: %o\n"), entryname, lsbuf.st_mode & mask,
|
"filesystem: %o package: %o\n"), entryname, lsbuf.st_mode & mask,
|
||||||
entrymode & mask);
|
entrymode & mask);
|
||||||
alpm_logaction(handle, "warning: directory permissions differ on %s\n"
|
alpm_logaction(handle, "warning: directory permissions differ on %s\n"
|
||||||
"filesystem: %o package: %o\n", entryname, lsbuf.st_mode & mask,
|
"filesystem: %o package: %o\n", entryname, lsbuf.st_mode & mask,
|
||||||
entrymode & mask);
|
entrymode & mask);
|
||||||
}
|
}
|
||||||
_alpm_log(PM_LOG_DEBUG, "extract: skipping dir extraction of %s\n",
|
_alpm_log(handle, PM_LOG_DEBUG, "extract: skipping dir extraction of %s\n",
|
||||||
entryname);
|
entryname);
|
||||||
archive_read_data_skip(archive);
|
archive_read_data_skip(archive);
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
/* case 10/11: trying to overwrite dir with file/symlink, don't allow it */
|
/* case 10/11: trying to overwrite dir with file/symlink, don't allow it */
|
||||||
_alpm_log(PM_LOG_ERROR, _("extract: not overwriting dir with file %s\n"),
|
_alpm_log(handle, PM_LOG_ERROR, _("extract: not overwriting dir with file %s\n"),
|
||||||
entryname);
|
entryname);
|
||||||
archive_read_data_skip(archive);
|
archive_read_data_skip(archive);
|
||||||
return 1;
|
return 1;
|
||||||
@ -231,20 +231,20 @@ static int extract_single_file(pmhandle_t *handle, struct archive *archive,
|
|||||||
/* case 9: existing symlink, dir in package */
|
/* case 9: existing symlink, dir in package */
|
||||||
if(S_ISDIR(sbuf.st_mode)) {
|
if(S_ISDIR(sbuf.st_mode)) {
|
||||||
/* the symlink on FS is to a directory, so we'll use it */
|
/* the symlink on FS is to a directory, so we'll use it */
|
||||||
_alpm_log(PM_LOG_DEBUG, "extract: skipping symlink overwrite of %s\n",
|
_alpm_log(handle, PM_LOG_DEBUG, "extract: skipping symlink overwrite of %s\n",
|
||||||
entryname);
|
entryname);
|
||||||
archive_read_data_skip(archive);
|
archive_read_data_skip(archive);
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
/* this is BAD. symlink was not to a directory */
|
/* this is BAD. symlink was not to a directory */
|
||||||
_alpm_log(PM_LOG_ERROR, _("extract: symlink %s does not point to dir\n"),
|
_alpm_log(handle, PM_LOG_ERROR, _("extract: symlink %s does not point to dir\n"),
|
||||||
entryname);
|
entryname);
|
||||||
archive_read_data_skip(archive);
|
archive_read_data_skip(archive);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
} else if(S_ISREG(lsbuf.st_mode) && S_ISDIR(entrymode)) {
|
} else if(S_ISREG(lsbuf.st_mode) && S_ISDIR(entrymode)) {
|
||||||
/* case 6: trying to overwrite file with dir */
|
/* case 6: trying to overwrite file with dir */
|
||||||
_alpm_log(PM_LOG_DEBUG, "extract: overwriting file with dir %s\n",
|
_alpm_log(handle, PM_LOG_DEBUG, "extract: overwriting file with dir %s\n",
|
||||||
entryname);
|
entryname);
|
||||||
} else if(S_ISREG(entrymode)) {
|
} else if(S_ISREG(entrymode)) {
|
||||||
/* case 4,7: */
|
/* case 4,7: */
|
||||||
@ -318,10 +318,10 @@ static int extract_single_file(pmhandle_t *handle, struct archive *archive,
|
|||||||
backups->data = backup;
|
backups->data = backup;
|
||||||
}
|
}
|
||||||
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "checking hashes for %s\n", entryname_orig);
|
_alpm_log(handle, PM_LOG_DEBUG, "checking hashes for %s\n", entryname_orig);
|
||||||
_alpm_log(PM_LOG_DEBUG, "current: %s\n", hash_local);
|
_alpm_log(handle, PM_LOG_DEBUG, "current: %s\n", hash_local);
|
||||||
_alpm_log(PM_LOG_DEBUG, "new: %s\n", hash_pkg);
|
_alpm_log(handle, PM_LOG_DEBUG, "new: %s\n", hash_pkg);
|
||||||
_alpm_log(PM_LOG_DEBUG, "original: %s\n", hash_orig);
|
_alpm_log(handle, PM_LOG_DEBUG, "original: %s\n", hash_orig);
|
||||||
|
|
||||||
if(!oldpkg) {
|
if(!oldpkg) {
|
||||||
if(strcmp(hash_local, hash_pkg) != 0) {
|
if(strcmp(hash_local, hash_pkg) != 0) {
|
||||||
@ -332,7 +332,7 @@ static int extract_single_file(pmhandle_t *handle, struct archive *archive,
|
|||||||
|
|
||||||
/* move the existing file to the "pacorig" */
|
/* move the existing file to the "pacorig" */
|
||||||
if(rename(filename, newpath)) {
|
if(rename(filename, newpath)) {
|
||||||
_alpm_log(PM_LOG_ERROR, _("could not rename %s to %s (%s)\n"),
|
_alpm_log(handle, PM_LOG_ERROR, _("could not rename %s to %s (%s)\n"),
|
||||||
filename, newpath, strerror(errno));
|
filename, newpath, strerror(errno));
|
||||||
alpm_logaction(handle, "error: could not rename %s to %s (%s)\n",
|
alpm_logaction(handle, "error: could not rename %s to %s (%s)\n",
|
||||||
filename, newpath, strerror(errno));
|
filename, newpath, strerror(errno));
|
||||||
@ -340,13 +340,13 @@ static int extract_single_file(pmhandle_t *handle, struct archive *archive,
|
|||||||
} else {
|
} else {
|
||||||
/* rename the file we extracted to the real name */
|
/* rename the file we extracted to the real name */
|
||||||
if(rename(checkfile, filename)) {
|
if(rename(checkfile, filename)) {
|
||||||
_alpm_log(PM_LOG_ERROR, _("could not rename %s to %s (%s)\n"),
|
_alpm_log(handle, PM_LOG_ERROR, _("could not rename %s to %s (%s)\n"),
|
||||||
checkfile, filename, strerror(errno));
|
checkfile, filename, strerror(errno));
|
||||||
alpm_logaction(handle, "error: could not rename %s to %s (%s)\n",
|
alpm_logaction(handle, "error: could not rename %s to %s (%s)\n",
|
||||||
checkfile, filename, strerror(errno));
|
checkfile, filename, strerror(errno));
|
||||||
errors++;
|
errors++;
|
||||||
} else {
|
} else {
|
||||||
_alpm_log(PM_LOG_WARNING, _("%s saved as %s\n"), filename, newpath);
|
_alpm_log(handle, PM_LOG_WARNING, _("%s saved as %s\n"), filename, newpath);
|
||||||
alpm_logaction(handle, "warning: %s saved as %s\n", filename, newpath);
|
alpm_logaction(handle, "warning: %s saved as %s\n", filename, newpath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -360,11 +360,11 @@ static int extract_single_file(pmhandle_t *handle, struct archive *archive,
|
|||||||
if(strcmp(hash_orig, hash_local) == 0) {
|
if(strcmp(hash_orig, hash_local) == 0) {
|
||||||
/* installed file has NOT been changed by user */
|
/* installed file has NOT been changed by user */
|
||||||
if(strcmp(hash_orig, hash_pkg) != 0) {
|
if(strcmp(hash_orig, hash_pkg) != 0) {
|
||||||
_alpm_log(PM_LOG_DEBUG, "action: installing new file: %s\n",
|
_alpm_log(handle, PM_LOG_DEBUG, "action: installing new file: %s\n",
|
||||||
entryname_orig);
|
entryname_orig);
|
||||||
|
|
||||||
if(rename(checkfile, filename)) {
|
if(rename(checkfile, filename)) {
|
||||||
_alpm_log(PM_LOG_ERROR, _("could not rename %s to %s (%s)\n"),
|
_alpm_log(handle, PM_LOG_ERROR, _("could not rename %s to %s (%s)\n"),
|
||||||
checkfile, filename, strerror(errno));
|
checkfile, filename, strerror(errno));
|
||||||
alpm_logaction(handle, "error: could not rename %s to %s (%s)\n",
|
alpm_logaction(handle, "error: could not rename %s to %s (%s)\n",
|
||||||
checkfile, filename, strerror(errno));
|
checkfile, filename, strerror(errno));
|
||||||
@ -373,33 +373,33 @@ static int extract_single_file(pmhandle_t *handle, struct archive *archive,
|
|||||||
} else {
|
} else {
|
||||||
/* there's no sense in installing the same file twice, install
|
/* there's no sense in installing the same file twice, install
|
||||||
* ONLY is the original and package hashes differ */
|
* ONLY is the original and package hashes differ */
|
||||||
_alpm_log(PM_LOG_DEBUG, "action: leaving existing file in place\n");
|
_alpm_log(handle, PM_LOG_DEBUG, "action: leaving existing file in place\n");
|
||||||
unlink(checkfile);
|
unlink(checkfile);
|
||||||
}
|
}
|
||||||
} else if(strcmp(hash_orig, hash_pkg) == 0) {
|
} else if(strcmp(hash_orig, hash_pkg) == 0) {
|
||||||
/* originally installed file and new file are the same - this
|
/* originally installed file and new file are the same - this
|
||||||
* implies the case above failed - i.e. the file was changed by a
|
* implies the case above failed - i.e. the file was changed by a
|
||||||
* user */
|
* user */
|
||||||
_alpm_log(PM_LOG_DEBUG, "action: leaving existing file in place\n");
|
_alpm_log(handle, PM_LOG_DEBUG, "action: leaving existing file in place\n");
|
||||||
unlink(checkfile);
|
unlink(checkfile);
|
||||||
} else if(strcmp(hash_local, hash_pkg) == 0) {
|
} else if(strcmp(hash_local, hash_pkg) == 0) {
|
||||||
/* this would be magical. The above two cases failed, but the
|
/* this would be magical. The above two cases failed, but the
|
||||||
* user changes just so happened to make the new file exactly the
|
* user changes just so happened to make the new file exactly the
|
||||||
* same as the one in the package... skip it */
|
* same as the one in the package... skip it */
|
||||||
_alpm_log(PM_LOG_DEBUG, "action: leaving existing file in place\n");
|
_alpm_log(handle, PM_LOG_DEBUG, "action: leaving existing file in place\n");
|
||||||
unlink(checkfile);
|
unlink(checkfile);
|
||||||
} else {
|
} else {
|
||||||
char newpath[PATH_MAX];
|
char newpath[PATH_MAX];
|
||||||
_alpm_log(PM_LOG_DEBUG, "action: keeping current file and installing"
|
_alpm_log(handle, PM_LOG_DEBUG, "action: keeping current file and installing"
|
||||||
" new one with .pacnew ending\n");
|
" new one with .pacnew ending\n");
|
||||||
snprintf(newpath, PATH_MAX, "%s.pacnew", filename);
|
snprintf(newpath, PATH_MAX, "%s.pacnew", filename);
|
||||||
if(rename(checkfile, newpath)) {
|
if(rename(checkfile, newpath)) {
|
||||||
_alpm_log(PM_LOG_ERROR, _("could not install %s as %s (%s)\n"),
|
_alpm_log(handle, PM_LOG_ERROR, _("could not install %s as %s (%s)\n"),
|
||||||
filename, newpath, strerror(errno));
|
filename, newpath, strerror(errno));
|
||||||
alpm_logaction(handle, "error: could not install %s as %s (%s)\n",
|
alpm_logaction(handle, "error: could not install %s as %s (%s)\n",
|
||||||
filename, newpath, strerror(errno));
|
filename, newpath, strerror(errno));
|
||||||
} else {
|
} else {
|
||||||
_alpm_log(PM_LOG_WARNING, _("%s installed as %s\n"),
|
_alpm_log(handle, PM_LOG_WARNING, _("%s installed as %s\n"),
|
||||||
filename, newpath);
|
filename, newpath);
|
||||||
alpm_logaction(handle, "warning: %s installed as %s\n",
|
alpm_logaction(handle, "warning: %s installed as %s\n",
|
||||||
filename, newpath);
|
filename, newpath);
|
||||||
@ -416,12 +416,12 @@ static int extract_single_file(pmhandle_t *handle, struct archive *archive,
|
|||||||
/* we didn't need a backup */
|
/* we didn't need a backup */
|
||||||
if(notouch) {
|
if(notouch) {
|
||||||
/* change the path to a .pacnew extension */
|
/* change the path to a .pacnew extension */
|
||||||
_alpm_log(PM_LOG_DEBUG, "%s is in NoUpgrade -- skipping\n", filename);
|
_alpm_log(handle, PM_LOG_DEBUG, "%s is in NoUpgrade -- skipping\n", filename);
|
||||||
_alpm_log(PM_LOG_WARNING, _("extracting %s as %s.pacnew\n"), filename, filename);
|
_alpm_log(handle, PM_LOG_WARNING, _("extracting %s as %s.pacnew\n"), filename, filename);
|
||||||
alpm_logaction(handle, "warning: extracting %s as %s.pacnew\n", filename, filename);
|
alpm_logaction(handle, "warning: extracting %s as %s.pacnew\n", filename, filename);
|
||||||
strncat(filename, ".pacnew", PATH_MAX - strlen(filename));
|
strncat(filename, ".pacnew", PATH_MAX - strlen(filename));
|
||||||
} else {
|
} else {
|
||||||
_alpm_log(PM_LOG_DEBUG, "extracting %s\n", filename);
|
_alpm_log(handle, PM_LOG_DEBUG, "extracting %s\n", filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(handle->trans->flags & PM_TRANS_FLAG_FORCE) {
|
if(handle->trans->flags & PM_TRANS_FLAG_FORCE) {
|
||||||
@ -449,7 +449,7 @@ static int extract_single_file(pmhandle_t *handle, struct archive *archive,
|
|||||||
if(!oldbackup || strcmp(oldbackup, entryname_orig) != 0) {
|
if(!oldbackup || strcmp(oldbackup, entryname_orig) != 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
_alpm_log(PM_LOG_DEBUG, "appending backup entry for %s\n", filename);
|
_alpm_log(handle, PM_LOG_DEBUG, "appending backup entry for %s\n", filename);
|
||||||
|
|
||||||
hash = alpm_compute_md5sum(filename);
|
hash = alpm_compute_md5sum(filename);
|
||||||
MALLOC(backup, backup_len, RET_ERR(handle, PM_ERR_MEMORY, -1));
|
MALLOC(backup, backup_len, RET_ERR(handle, PM_ERR_MEMORY, -1));
|
||||||
@ -491,7 +491,7 @@ static int commit_single_pkg(pmhandle_t *handle, pmpkg_t *newpkg,
|
|||||||
_alpm_local_db_read(oldpkg->origin_data.db, oldpkg, INFRQ_ALL);
|
_alpm_local_db_read(oldpkg->origin_data.db, oldpkg, INFRQ_ALL);
|
||||||
|
|
||||||
EVENT(trans, PM_TRANS_EVT_UPGRADE_START, newpkg, oldpkg);
|
EVENT(trans, PM_TRANS_EVT_UPGRADE_START, newpkg, oldpkg);
|
||||||
_alpm_log(PM_LOG_DEBUG, "upgrading package %s-%s\n",
|
_alpm_log(handle, PM_LOG_DEBUG, "upgrading package %s-%s\n",
|
||||||
newpkg->name, newpkg->version);
|
newpkg->name, newpkg->version);
|
||||||
|
|
||||||
/* copy over the install reason */
|
/* copy over the install reason */
|
||||||
@ -506,7 +506,7 @@ static int commit_single_pkg(pmhandle_t *handle, pmpkg_t *newpkg,
|
|||||||
is_upgrade = 0;
|
is_upgrade = 0;
|
||||||
|
|
||||||
EVENT(trans, PM_TRANS_EVT_ADD_START, newpkg, NULL);
|
EVENT(trans, PM_TRANS_EVT_ADD_START, newpkg, NULL);
|
||||||
_alpm_log(PM_LOG_DEBUG, "adding package %s-%s\n",
|
_alpm_log(handle, PM_LOG_DEBUG, "adding package %s-%s\n",
|
||||||
newpkg->name, newpkg->version);
|
newpkg->name, newpkg->version);
|
||||||
|
|
||||||
/* pre_install scriptlet */
|
/* pre_install scriptlet */
|
||||||
@ -548,7 +548,7 @@ static int commit_single_pkg(pmhandle_t *handle, pmpkg_t *newpkg,
|
|||||||
char cwd[PATH_MAX] = "";
|
char cwd[PATH_MAX] = "";
|
||||||
int restore_cwd = 0;
|
int restore_cwd = 0;
|
||||||
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "extracting files\n");
|
_alpm_log(handle, PM_LOG_DEBUG, "extracting files\n");
|
||||||
|
|
||||||
if((archive = archive_read_new()) == NULL) {
|
if((archive = archive_read_new()) == NULL) {
|
||||||
handle->pm_errno = PM_ERR_LIBARCHIVE;
|
handle->pm_errno = PM_ERR_LIBARCHIVE;
|
||||||
@ -559,7 +559,7 @@ static int commit_single_pkg(pmhandle_t *handle, pmpkg_t *newpkg,
|
|||||||
archive_read_support_compression_all(archive);
|
archive_read_support_compression_all(archive);
|
||||||
archive_read_support_format_all(archive);
|
archive_read_support_format_all(archive);
|
||||||
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "archive: %s\n", newpkg->origin_data.file);
|
_alpm_log(handle, PM_LOG_DEBUG, "archive: %s\n", newpkg->origin_data.file);
|
||||||
if(archive_read_open_filename(archive, newpkg->origin_data.file,
|
if(archive_read_open_filename(archive, newpkg->origin_data.file,
|
||||||
ARCHIVE_DEFAULT_BYTES_PER_BLOCK) != ARCHIVE_OK) {
|
ARCHIVE_DEFAULT_BYTES_PER_BLOCK) != ARCHIVE_OK) {
|
||||||
handle->pm_errno = PM_ERR_PKG_OPEN;
|
handle->pm_errno = PM_ERR_PKG_OPEN;
|
||||||
@ -569,15 +569,15 @@ static int commit_single_pkg(pmhandle_t *handle, pmpkg_t *newpkg,
|
|||||||
|
|
||||||
/* save the cwd so we can restore it later */
|
/* save the cwd so we can restore it later */
|
||||||
if(getcwd(cwd, PATH_MAX) == NULL) {
|
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 {
|
} else {
|
||||||
restore_cwd = 1;
|
restore_cwd = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* libarchive requires this for extracting hard links */
|
/* libarchive requires this for extracting hard links */
|
||||||
if(chdir(newpkg->handle->root) != 0) {
|
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"),
|
||||||
newpkg->handle->root, strerror(errno));
|
handle->root, strerror(errno));
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -600,7 +600,7 @@ static int commit_single_pkg(pmhandle_t *handle, pmpkg_t *newpkg,
|
|||||||
* (missing metadata sizes) */
|
* (missing metadata sizes) */
|
||||||
int64_t pos = archive_position_compressed(archive);
|
int64_t pos = archive_position_compressed(archive);
|
||||||
percent = (pos * 100) / newpkg->size;
|
percent = (pos * 100) / newpkg->size;
|
||||||
_alpm_log(PM_LOG_DEBUG, "decompression progress: "
|
_alpm_log(handle, PM_LOG_DEBUG, "decompression progress: "
|
||||||
"%d%% (%"PRId64" / %jd)\n",
|
"%d%% (%"PRId64" / %jd)\n",
|
||||||
percent, pos, (intmax_t)newpkg->size);
|
percent, pos, (intmax_t)newpkg->size);
|
||||||
if(percent >= 100) {
|
if(percent >= 100) {
|
||||||
@ -627,18 +627,18 @@ static int commit_single_pkg(pmhandle_t *handle, pmpkg_t *newpkg,
|
|||||||
|
|
||||||
/* restore the old cwd if we have it */
|
/* restore the old cwd if we have it */
|
||||||
if(restore_cwd && chdir(cwd) != 0) {
|
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(errors) {
|
if(errors) {
|
||||||
ret = -1;
|
ret = -1;
|
||||||
if(is_upgrade) {
|
if(is_upgrade) {
|
||||||
_alpm_log(PM_LOG_ERROR, _("problem occurred while upgrading %s\n"),
|
_alpm_log(handle, PM_LOG_ERROR, _("problem occurred while upgrading %s\n"),
|
||||||
newpkg->name);
|
newpkg->name);
|
||||||
alpm_logaction(handle, "error: problem occurred while upgrading %s\n",
|
alpm_logaction(handle, "error: problem occurred while upgrading %s\n",
|
||||||
newpkg->name);
|
newpkg->name);
|
||||||
} else {
|
} else {
|
||||||
_alpm_log(PM_LOG_ERROR, _("problem occurred while installing %s\n"),
|
_alpm_log(handle, PM_LOG_ERROR, _("problem occurred while installing %s\n"),
|
||||||
newpkg->name);
|
newpkg->name);
|
||||||
alpm_logaction(handle, "error: problem occurred while installing %s\n",
|
alpm_logaction(handle, "error: problem occurred while installing %s\n",
|
||||||
newpkg->name);
|
newpkg->name);
|
||||||
@ -649,11 +649,11 @@ static int commit_single_pkg(pmhandle_t *handle, pmpkg_t *newpkg,
|
|||||||
/* make an install date (in UTC) */
|
/* make an install date (in UTC) */
|
||||||
newpkg->installdate = time(NULL);
|
newpkg->installdate = time(NULL);
|
||||||
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "updating database\n");
|
_alpm_log(handle, PM_LOG_DEBUG, "updating database\n");
|
||||||
_alpm_log(PM_LOG_DEBUG, "adding database entry '%s'\n", newpkg->name);
|
_alpm_log(handle, PM_LOG_DEBUG, "adding database entry '%s'\n", newpkg->name);
|
||||||
|
|
||||||
if(_alpm_local_db_write(db, newpkg, INFRQ_ALL)) {
|
if(_alpm_local_db_write(db, newpkg, INFRQ_ALL)) {
|
||||||
_alpm_log(PM_LOG_ERROR, _("could not update database entry %s-%s\n"),
|
_alpm_log(handle, PM_LOG_ERROR, _("could not update database entry %s-%s\n"),
|
||||||
alpm_pkg_get_name(newpkg), alpm_pkg_get_version(newpkg));
|
alpm_pkg_get_name(newpkg), alpm_pkg_get_version(newpkg));
|
||||||
alpm_logaction(handle, "error: could not update database entry %s-%s\n",
|
alpm_logaction(handle, "error: could not update database entry %s-%s\n",
|
||||||
alpm_pkg_get_name(newpkg), alpm_pkg_get_version(newpkg));
|
alpm_pkg_get_name(newpkg), alpm_pkg_get_version(newpkg));
|
||||||
@ -663,7 +663,7 @@ static int commit_single_pkg(pmhandle_t *handle, pmpkg_t *newpkg,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(_alpm_db_add_pkgincache(db, newpkg) == -1) {
|
if(_alpm_db_add_pkgincache(db, newpkg) == -1) {
|
||||||
_alpm_log(PM_LOG_ERROR, _("could not add entry '%s' in cache\n"),
|
_alpm_log(handle, PM_LOG_ERROR, _("could not add entry '%s' in cache\n"),
|
||||||
alpm_pkg_get_name(newpkg));
|
alpm_pkg_get_name(newpkg));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,13 +279,13 @@ static int checkdbdir(pmdb_t *db)
|
|||||||
const char *path = _alpm_db_path(db);
|
const char *path = _alpm_db_path(db);
|
||||||
|
|
||||||
if(stat(path, &buf) != 0) {
|
if(stat(path, &buf) != 0) {
|
||||||
_alpm_log(PM_LOG_DEBUG, "database dir '%s' does not exist, creating it\n",
|
_alpm_log(db->handle, PM_LOG_DEBUG, "database dir '%s' does not exist, creating it\n",
|
||||||
path);
|
path);
|
||||||
if(_alpm_makepath(path) != 0) {
|
if(_alpm_makepath(path) != 0) {
|
||||||
RET_ERR(db->handle, PM_ERR_SYSTEM, -1);
|
RET_ERR(db->handle, PM_ERR_SYSTEM, -1);
|
||||||
}
|
}
|
||||||
} else if(!S_ISDIR(buf.st_mode)) {
|
} else if(!S_ISDIR(buf.st_mode)) {
|
||||||
_alpm_log(PM_LOG_WARNING, _("removing invalid database: %s\n"), path);
|
_alpm_log(db->handle, PM_LOG_WARNING, _("removing invalid database: %s\n"), path);
|
||||||
if(unlink(path) != 0 || _alpm_makepath(path) != 0) {
|
if(unlink(path) != 0 || _alpm_makepath(path) != 0) {
|
||||||
RET_ERR(db->handle, PM_ERR_SYSTEM, -1);
|
RET_ERR(db->handle, PM_ERR_SYSTEM, -1);
|
||||||
}
|
}
|
||||||
@ -383,7 +383,7 @@ static int local_db_populate(pmdb_t *db)
|
|||||||
}
|
}
|
||||||
/* split the db entry name */
|
/* split the db entry name */
|
||||||
if(_alpm_splitname(name, pkg) != 0) {
|
if(_alpm_splitname(name, pkg) != 0) {
|
||||||
_alpm_log(PM_LOG_ERROR, _("invalid name for database entry '%s'\n"),
|
_alpm_log(db->handle, PM_LOG_ERROR, _("invalid name for database entry '%s'\n"),
|
||||||
name);
|
name);
|
||||||
_alpm_pkg_free(pkg);
|
_alpm_pkg_free(pkg);
|
||||||
continue;
|
continue;
|
||||||
@ -391,7 +391,7 @@ static int local_db_populate(pmdb_t *db)
|
|||||||
|
|
||||||
/* duplicated database entries are not allowed */
|
/* duplicated database entries are not allowed */
|
||||||
if(_alpm_pkghash_find(db->pkgcache, pkg->name)) {
|
if(_alpm_pkghash_find(db->pkgcache, pkg->name)) {
|
||||||
_alpm_log(PM_LOG_ERROR, _("duplicated database entry '%s'\n"), pkg->name);
|
_alpm_log(db->handle, PM_LOG_ERROR, _("duplicated database entry '%s'\n"), pkg->name);
|
||||||
_alpm_pkg_free(pkg);
|
_alpm_pkg_free(pkg);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -403,13 +403,13 @@ static int local_db_populate(pmdb_t *db)
|
|||||||
|
|
||||||
/* explicitly read with only 'BASE' data, accessors will handle the rest */
|
/* explicitly read with only 'BASE' data, accessors will handle the rest */
|
||||||
if(_alpm_local_db_read(db, pkg, INFRQ_BASE) == -1) {
|
if(_alpm_local_db_read(db, pkg, INFRQ_BASE) == -1) {
|
||||||
_alpm_log(PM_LOG_ERROR, _("corrupted database entry '%s'\n"), name);
|
_alpm_log(db->handle, PM_LOG_ERROR, _("corrupted database entry '%s'\n"), name);
|
||||||
_alpm_pkg_free(pkg);
|
_alpm_pkg_free(pkg);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add to the collection */
|
/* add to the collection */
|
||||||
_alpm_log(PM_LOG_FUNCTION, "adding '%s' to package cache for db '%s'\n",
|
_alpm_log(db->handle, PM_LOG_FUNCTION, "adding '%s' to package cache for db '%s'\n",
|
||||||
pkg->name, db->treename);
|
pkg->name, db->treename);
|
||||||
db->pkgcache = _alpm_pkghash_add(db->pkgcache, pkg);
|
db->pkgcache = _alpm_pkghash_add(db->pkgcache, pkg);
|
||||||
count++;
|
count++;
|
||||||
@ -419,7 +419,7 @@ static int local_db_populate(pmdb_t *db)
|
|||||||
if(count > 0) {
|
if(count > 0) {
|
||||||
db->pkgcache->list = alpm_list_msort(db->pkgcache->list, (size_t)count, _alpm_pkg_cmp);
|
db->pkgcache->list = alpm_list_msort(db->pkgcache->list, (size_t)count, _alpm_pkg_cmp);
|
||||||
}
|
}
|
||||||
_alpm_log(PM_LOG_DEBUG, "added %d packages to package cache for db '%s'\n",
|
_alpm_log(db->handle, PM_LOG_DEBUG, "added %d packages to package cache for db '%s'\n",
|
||||||
count, db->treename);
|
count, db->treename);
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
@ -448,12 +448,13 @@ int _alpm_local_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq)
|
|||||||
char *pkgpath = NULL;
|
char *pkgpath = NULL;
|
||||||
|
|
||||||
if(info == NULL || info->name == NULL || info->version == NULL) {
|
if(info == NULL || info->name == NULL || info->version == NULL) {
|
||||||
_alpm_log(PM_LOG_DEBUG, "invalid package entry provided to _alpm_local_db_read, skipping\n");
|
_alpm_log(db->handle, PM_LOG_DEBUG,
|
||||||
|
"invalid package entry provided to _alpm_local_db_read, skipping\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(info->origin != PKG_FROM_LOCALDB) {
|
if(info->origin != PKG_FROM_LOCALDB) {
|
||||||
_alpm_log(PM_LOG_DEBUG,
|
_alpm_log(db->handle, PM_LOG_DEBUG,
|
||||||
"request to read info for a non-local package '%s', skipping...\n",
|
"request to read info for a non-local package '%s', skipping...\n",
|
||||||
info->name);
|
info->name);
|
||||||
return -1;
|
return -1;
|
||||||
@ -468,7 +469,7 @@ int _alpm_local_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq)
|
|||||||
/* already loaded all of this info, do nothing */
|
/* already loaded all of this info, do nothing */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
_alpm_log(PM_LOG_FUNCTION, "loading package data for %s : level=0x%x\n",
|
_alpm_log(db->handle, PM_LOG_FUNCTION, "loading package data for %s : level=0x%x\n",
|
||||||
info->name, inforeq);
|
info->name, inforeq);
|
||||||
|
|
||||||
/* clear out 'line', to be certain - and to make valgrind happy */
|
/* clear out 'line', to be certain - and to make valgrind happy */
|
||||||
@ -478,7 +479,7 @@ int _alpm_local_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq)
|
|||||||
|
|
||||||
if(access(pkgpath, F_OK)) {
|
if(access(pkgpath, F_OK)) {
|
||||||
/* directory doesn't exist or can't be opened */
|
/* directory doesn't exist or can't be opened */
|
||||||
_alpm_log(PM_LOG_DEBUG, "cannot find '%s-%s' in db '%s'\n",
|
_alpm_log(db->handle, PM_LOG_DEBUG, "cannot find '%s-%s' in db '%s'\n",
|
||||||
info->name, info->version, db->treename);
|
info->name, info->version, db->treename);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -487,7 +488,7 @@ int _alpm_local_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq)
|
|||||||
if(inforeq & INFRQ_DESC && !(info->infolevel & INFRQ_DESC)) {
|
if(inforeq & INFRQ_DESC && !(info->infolevel & INFRQ_DESC)) {
|
||||||
snprintf(path, PATH_MAX, "%sdesc", pkgpath);
|
snprintf(path, PATH_MAX, "%sdesc", pkgpath);
|
||||||
if((fp = fopen(path, "r")) == NULL) {
|
if((fp = fopen(path, "r")) == NULL) {
|
||||||
_alpm_log(PM_LOG_ERROR, _("could not open file %s: %s\n"), path, strerror(errno));
|
_alpm_log(db->handle, PM_LOG_ERROR, _("could not open file %s: %s\n"), path, strerror(errno));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
while(!feof(fp)) {
|
while(!feof(fp)) {
|
||||||
@ -500,7 +501,7 @@ int _alpm_local_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq)
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if(strcmp(_alpm_strtrim(line), info->name) != 0) {
|
if(strcmp(_alpm_strtrim(line), info->name) != 0) {
|
||||||
_alpm_log(PM_LOG_ERROR, _("%s database is inconsistent: name "
|
_alpm_log(db->handle, PM_LOG_ERROR, _("%s database is inconsistent: name "
|
||||||
"mismatch on package %s\n"), db->treename, info->name);
|
"mismatch on package %s\n"), db->treename, info->name);
|
||||||
}
|
}
|
||||||
} else if(strcmp(line, "%VERSION%") == 0) {
|
} else if(strcmp(line, "%VERSION%") == 0) {
|
||||||
@ -508,7 +509,7 @@ int _alpm_local_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq)
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if(strcmp(_alpm_strtrim(line), info->version) != 0) {
|
if(strcmp(_alpm_strtrim(line), info->version) != 0) {
|
||||||
_alpm_log(PM_LOG_ERROR, _("%s database is inconsistent: version "
|
_alpm_log(db->handle, PM_LOG_ERROR, _("%s database is inconsistent: version "
|
||||||
"mismatch on package %s\n"), db->treename, info->name);
|
"mismatch on package %s\n"), db->treename, info->name);
|
||||||
}
|
}
|
||||||
} else if(strcmp(line, "%DESC%") == 0) {
|
} else if(strcmp(line, "%DESC%") == 0) {
|
||||||
@ -611,7 +612,7 @@ int _alpm_local_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq)
|
|||||||
if(inforeq & INFRQ_FILES && !(info->infolevel & INFRQ_FILES)) {
|
if(inforeq & INFRQ_FILES && !(info->infolevel & INFRQ_FILES)) {
|
||||||
snprintf(path, PATH_MAX, "%sfiles", pkgpath);
|
snprintf(path, PATH_MAX, "%sfiles", pkgpath);
|
||||||
if((fp = fopen(path, "r")) == NULL) {
|
if((fp = fopen(path, "r")) == NULL) {
|
||||||
_alpm_log(PM_LOG_ERROR, _("could not open file %s: %s\n"), path, strerror(errno));
|
_alpm_log(db->handle, PM_LOG_ERROR, _("could not open file %s: %s\n"), path, strerror(errno));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
while(fgets(line, sizeof(line), fp)) {
|
while(fgets(line, sizeof(line), fp)) {
|
||||||
@ -670,7 +671,7 @@ int _alpm_local_db_prepare(pmdb_t *db, pmpkg_t *info)
|
|||||||
pkgpath = get_pkgpath(db, info);
|
pkgpath = get_pkgpath(db, info);
|
||||||
|
|
||||||
if((retval = mkdir(pkgpath, 0755)) != 0) {
|
if((retval = mkdir(pkgpath, 0755)) != 0) {
|
||||||
_alpm_log(PM_LOG_ERROR, _("could not create directory %s: %s\n"),
|
_alpm_log(db->handle, PM_LOG_ERROR, _("could not create directory %s: %s\n"),
|
||||||
pkgpath, strerror(errno));
|
pkgpath, strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -704,11 +705,12 @@ int _alpm_local_db_write(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq)
|
|||||||
|
|
||||||
/* DESC */
|
/* DESC */
|
||||||
if(inforeq & INFRQ_DESC) {
|
if(inforeq & INFRQ_DESC) {
|
||||||
_alpm_log(PM_LOG_DEBUG, "writing %s-%s DESC information back to db\n",
|
_alpm_log(db->handle, PM_LOG_DEBUG, "writing %s-%s DESC information back to db\n",
|
||||||
info->name, info->version);
|
info->name, info->version);
|
||||||
snprintf(path, PATH_MAX, "%sdesc", pkgpath);
|
snprintf(path, PATH_MAX, "%sdesc", pkgpath);
|
||||||
if((fp = fopen(path, "w")) == NULL) {
|
if((fp = fopen(path, "w")) == NULL) {
|
||||||
_alpm_log(PM_LOG_ERROR, _("could not open file %s: %s\n"), path, strerror(errno));
|
_alpm_log(db->handle, PM_LOG_ERROR, _("could not open file %s: %s\n"),
|
||||||
|
path, strerror(errno));
|
||||||
retval = -1;
|
retval = -1;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -805,11 +807,12 @@ int _alpm_local_db_write(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq)
|
|||||||
|
|
||||||
/* FILES */
|
/* FILES */
|
||||||
if(inforeq & INFRQ_FILES) {
|
if(inforeq & INFRQ_FILES) {
|
||||||
_alpm_log(PM_LOG_DEBUG, "writing %s-%s FILES information back to db\n",
|
_alpm_log(db->handle, PM_LOG_DEBUG, "writing %s-%s FILES information back to db\n",
|
||||||
info->name, info->version);
|
info->name, info->version);
|
||||||
snprintf(path, PATH_MAX, "%sfiles", pkgpath);
|
snprintf(path, PATH_MAX, "%sfiles", pkgpath);
|
||||||
if((fp = fopen(path, "w")) == NULL) {
|
if((fp = fopen(path, "w")) == NULL) {
|
||||||
_alpm_log(PM_LOG_ERROR, _("could not open file %s: %s\n"), path, strerror(errno));
|
_alpm_log(db->handle, PM_LOG_ERROR, _("could not open file %s: %s\n"),
|
||||||
|
path, strerror(errno));
|
||||||
retval = -1;
|
retval = -1;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -908,7 +911,7 @@ done:
|
|||||||
closedir(dbdir);
|
closedir(dbdir);
|
||||||
}
|
}
|
||||||
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "local database version %d\n", version);
|
_alpm_log(db->handle, PM_LOG_DEBUG, "local database version %d\n", version);
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -922,7 +925,7 @@ pmdb_t *_alpm_db_register_local(pmhandle_t *handle)
|
|||||||
{
|
{
|
||||||
pmdb_t *db;
|
pmdb_t *db;
|
||||||
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "registering local database\n");
|
_alpm_log(handle, PM_LOG_DEBUG, "registering local database\n");
|
||||||
|
|
||||||
db = _alpm_db_new("local", 1);
|
db = _alpm_db_new("local", 1);
|
||||||
if(db == NULL) {
|
if(db == NULL) {
|
||||||
|
@ -137,7 +137,7 @@ static struct pkg_operations *get_file_pkg_ops(void)
|
|||||||
*
|
*
|
||||||
* @return 0 on success, -1 on error
|
* @return 0 on success, -1 on error
|
||||||
*/
|
*/
|
||||||
static int parse_descfile(struct archive *a, pmpkg_t *newpkg)
|
static int parse_descfile(pmhandle_t *handle, struct archive *a, pmpkg_t *newpkg)
|
||||||
{
|
{
|
||||||
char *ptr = NULL;
|
char *ptr = NULL;
|
||||||
char *key = NULL;
|
char *key = NULL;
|
||||||
@ -159,7 +159,7 @@ static int parse_descfile(struct archive *a, pmpkg_t *newpkg)
|
|||||||
ptr = line;
|
ptr = line;
|
||||||
key = strsep(&ptr, "=");
|
key = strsep(&ptr, "=");
|
||||||
if(key == NULL || ptr == NULL) {
|
if(key == NULL || ptr == NULL) {
|
||||||
_alpm_log(PM_LOG_DEBUG, "%s: syntax error in description file line %d\n",
|
_alpm_log(handle, PM_LOG_DEBUG, "%s: syntax error in description file line %d\n",
|
||||||
newpkg->name ? newpkg->name : "error", linenum);
|
newpkg->name ? newpkg->name : "error", linenum);
|
||||||
} else {
|
} else {
|
||||||
key = _alpm_strtrim(key);
|
key = _alpm_strtrim(key);
|
||||||
@ -207,14 +207,14 @@ static int parse_descfile(struct archive *a, pmpkg_t *newpkg)
|
|||||||
} else if(strcmp(key, "makepkgopt") == 0) {
|
} else if(strcmp(key, "makepkgopt") == 0) {
|
||||||
/* not used atm */
|
/* not used atm */
|
||||||
} else {
|
} else {
|
||||||
_alpm_log(PM_LOG_DEBUG, "%s: unknown key '%s' in description file line %d\n",
|
_alpm_log(handle, PM_LOG_DEBUG, "%s: unknown key '%s' in description file line %d\n",
|
||||||
newpkg->name ? newpkg->name : "error", key, linenum);
|
newpkg->name ? newpkg->name : "error", key, linenum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
line[0] = '\0';
|
line[0] = '\0';
|
||||||
}
|
}
|
||||||
if(ret != ARCHIVE_EOF) {
|
if(ret != ARCHIVE_EOF) {
|
||||||
_alpm_log(PM_LOG_DEBUG, "error parsing package descfile\n");
|
_alpm_log(handle, PM_LOG_DEBUG, "error parsing package descfile\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,18 +258,18 @@ pmpkg_t *_alpm_pkg_load_internal(pmhandle_t *handle, const char *pkgfile,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* first steps- validate the package file */
|
/* first steps- validate the package file */
|
||||||
_alpm_log(PM_LOG_DEBUG, "md5sum: %s\n", md5sum);
|
_alpm_log(handle, PM_LOG_DEBUG, "md5sum: %s\n", md5sum);
|
||||||
if(md5sum) {
|
if(md5sum) {
|
||||||
_alpm_log(PM_LOG_DEBUG, "checking md5sum for %s\n", pkgfile);
|
_alpm_log(handle, PM_LOG_DEBUG, "checking md5sum for %s\n", pkgfile);
|
||||||
if(_alpm_test_md5sum(pkgfile, md5sum) != 0) {
|
if(_alpm_test_md5sum(pkgfile, md5sum) != 0) {
|
||||||
alpm_pkg_free(newpkg);
|
alpm_pkg_free(newpkg);
|
||||||
RET_ERR(handle, PM_ERR_PKG_INVALID, NULL);
|
RET_ERR(handle, PM_ERR_PKG_INVALID, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "base64_sig: %s\n", base64_sig);
|
_alpm_log(handle, PM_LOG_DEBUG, "base64_sig: %s\n", base64_sig);
|
||||||
if(check_sig != PM_PGP_VERIFY_NEVER) {
|
if(check_sig != PM_PGP_VERIFY_NEVER) {
|
||||||
_alpm_log(PM_LOG_DEBUG, "checking signature for %s\n", pkgfile);
|
_alpm_log(handle, PM_LOG_DEBUG, "checking signature for %s\n", pkgfile);
|
||||||
ret = _alpm_gpgme_checksig(handle, pkgfile, base64_sig);
|
ret = _alpm_gpgme_checksig(handle, pkgfile, base64_sig);
|
||||||
if((check_sig == PM_PGP_VERIFY_ALWAYS && ret != 0) ||
|
if((check_sig == PM_PGP_VERIFY_ALWAYS && ret != 0) ||
|
||||||
(check_sig == PM_PGP_VERIFY_OPTIONAL && ret == 1)) {
|
(check_sig == PM_PGP_VERIFY_OPTIONAL && ret == 1)) {
|
||||||
@ -293,7 +293,7 @@ pmpkg_t *_alpm_pkg_load_internal(pmhandle_t *handle, const char *pkgfile,
|
|||||||
RET_ERR(handle, PM_ERR_PKG_OPEN, NULL);
|
RET_ERR(handle, PM_ERR_PKG_OPEN, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "starting package load for %s\n", pkgfile);
|
_alpm_log(handle, PM_LOG_DEBUG, "starting package load for %s\n", pkgfile);
|
||||||
|
|
||||||
/* If full is false, only read through the archive until we find our needed
|
/* If full is false, only read through the archive until we find our needed
|
||||||
* metadata. If it is true, read through the entire archive, which serves
|
* metadata. If it is true, read through the entire archive, which serves
|
||||||
@ -303,17 +303,17 @@ pmpkg_t *_alpm_pkg_load_internal(pmhandle_t *handle, const char *pkgfile,
|
|||||||
|
|
||||||
if(strcmp(entry_name, ".PKGINFO") == 0) {
|
if(strcmp(entry_name, ".PKGINFO") == 0) {
|
||||||
/* parse the info file */
|
/* parse the info file */
|
||||||
if(parse_descfile(archive, newpkg) != 0) {
|
if(parse_descfile(handle, archive, newpkg) != 0) {
|
||||||
_alpm_log(PM_LOG_ERROR, _("could not parse package description file in %s\n"),
|
_alpm_log(handle, PM_LOG_ERROR, _("could not parse package description file in %s\n"),
|
||||||
pkgfile);
|
pkgfile);
|
||||||
goto pkg_invalid;
|
goto pkg_invalid;
|
||||||
}
|
}
|
||||||
if(newpkg->name == NULL || strlen(newpkg->name) == 0) {
|
if(newpkg->name == NULL || strlen(newpkg->name) == 0) {
|
||||||
_alpm_log(PM_LOG_ERROR, _("missing package name in %s\n"), pkgfile);
|
_alpm_log(handle, PM_LOG_ERROR, _("missing package name in %s\n"), pkgfile);
|
||||||
goto pkg_invalid;
|
goto pkg_invalid;
|
||||||
}
|
}
|
||||||
if(newpkg->version == NULL || strlen(newpkg->version) == 0) {
|
if(newpkg->version == NULL || strlen(newpkg->version) == 0) {
|
||||||
_alpm_log(PM_LOG_ERROR, _("missing package version in %s\n"), pkgfile);
|
_alpm_log(handle, PM_LOG_ERROR, _("missing package version in %s\n"), pkgfile);
|
||||||
goto pkg_invalid;
|
goto pkg_invalid;
|
||||||
}
|
}
|
||||||
config = 1;
|
config = 1;
|
||||||
@ -329,7 +329,7 @@ pmpkg_t *_alpm_pkg_load_internal(pmhandle_t *handle, const char *pkgfile,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(archive_read_data_skip(archive)) {
|
if(archive_read_data_skip(archive)) {
|
||||||
_alpm_log(PM_LOG_ERROR, _("error while reading package %s: %s\n"),
|
_alpm_log(handle, PM_LOG_ERROR, _("error while reading package %s: %s\n"),
|
||||||
pkgfile, archive_error_string(archive));
|
pkgfile, archive_error_string(archive));
|
||||||
handle->pm_errno = PM_ERR_LIBARCHIVE;
|
handle->pm_errno = PM_ERR_LIBARCHIVE;
|
||||||
goto error;
|
goto error;
|
||||||
@ -342,14 +342,14 @@ pmpkg_t *_alpm_pkg_load_internal(pmhandle_t *handle, const char *pkgfile,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(ret != ARCHIVE_EOF && ret != ARCHIVE_OK) { /* An error occured */
|
if(ret != ARCHIVE_EOF && ret != ARCHIVE_OK) { /* An error occured */
|
||||||
_alpm_log(PM_LOG_ERROR, _("error while reading package %s: %s\n"),
|
_alpm_log(handle, PM_LOG_ERROR, _("error while reading package %s: %s\n"),
|
||||||
pkgfile, archive_error_string(archive));
|
pkgfile, archive_error_string(archive));
|
||||||
handle->pm_errno = PM_ERR_LIBARCHIVE;
|
handle->pm_errno = PM_ERR_LIBARCHIVE;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!config) {
|
if(!config) {
|
||||||
_alpm_log(PM_LOG_ERROR, _("missing package metadata in %s\n"), pkgfile);
|
_alpm_log(handle, PM_LOG_ERROR, _("missing package metadata in %s\n"), pkgfile);
|
||||||
goto pkg_invalid;
|
goto pkg_invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -363,7 +363,7 @@ pmpkg_t *_alpm_pkg_load_internal(pmhandle_t *handle, const char *pkgfile,
|
|||||||
|
|
||||||
if(full) {
|
if(full) {
|
||||||
/* "checking for conflicts" requires a sorted list, ensure that here */
|
/* "checking for conflicts" requires a sorted list, ensure that here */
|
||||||
_alpm_log(PM_LOG_DEBUG, "sorting package filelist for %s\n", pkgfile);
|
_alpm_log(handle, PM_LOG_DEBUG, "sorting package filelist for %s\n", pkgfile);
|
||||||
newpkg->files = alpm_list_msort(newpkg->files, alpm_list_count(newpkg->files),
|
newpkg->files = alpm_list_msort(newpkg->files, alpm_list_count(newpkg->files),
|
||||||
_alpm_str_cmp);
|
_alpm_str_cmp);
|
||||||
newpkg->infolevel = INFRQ_ALL;
|
newpkg->infolevel = INFRQ_ALL;
|
||||||
|
@ -103,14 +103,14 @@ int SYMEXPORT alpm_db_update(int force, pmdb_t *db)
|
|||||||
oldmask = umask(0022);
|
oldmask = umask(0022);
|
||||||
|
|
||||||
if(stat(syncpath, &buf) != 0) {
|
if(stat(syncpath, &buf) != 0) {
|
||||||
_alpm_log(PM_LOG_DEBUG, "database dir '%s' does not exist, creating it\n",
|
_alpm_log(handle, PM_LOG_DEBUG, "database dir '%s' does not exist, creating it\n",
|
||||||
syncpath);
|
syncpath);
|
||||||
if(_alpm_makepath(syncpath) != 0) {
|
if(_alpm_makepath(syncpath) != 0) {
|
||||||
free(syncpath);
|
free(syncpath);
|
||||||
RET_ERR(handle, PM_ERR_SYSTEM, -1);
|
RET_ERR(handle, PM_ERR_SYSTEM, -1);
|
||||||
}
|
}
|
||||||
} else if(!S_ISDIR(buf.st_mode)) {
|
} else if(!S_ISDIR(buf.st_mode)) {
|
||||||
_alpm_log(PM_LOG_WARNING, _("removing invalid file: %s\n"), syncpath);
|
_alpm_log(handle, PM_LOG_WARNING, _("removing invalid file: %s\n"), syncpath);
|
||||||
if(unlink(syncpath) != 0 || _alpm_makepath(syncpath) != 0) {
|
if(unlink(syncpath) != 0 || _alpm_makepath(syncpath) != 0) {
|
||||||
free(syncpath);
|
free(syncpath);
|
||||||
RET_ERR(handle, PM_ERR_SYSTEM, -1);
|
RET_ERR(handle, PM_ERR_SYSTEM, -1);
|
||||||
@ -155,7 +155,8 @@ int SYMEXPORT alpm_db_update(int force, pmdb_t *db)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
} else if(ret == -1) {
|
} else if(ret == -1) {
|
||||||
/* pm_errno was set by the download code */
|
/* pm_errno was set by the download code */
|
||||||
_alpm_log(PM_LOG_DEBUG, "failed to sync db: %s\n", alpm_strerror(handle->pm_errno));
|
_alpm_log(handle, PM_LOG_DEBUG, "failed to sync db: %s\n",
|
||||||
|
alpm_strerror(handle->pm_errno));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -255,11 +256,11 @@ static int sync_db_populate(pmdb_t *db)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "opening database archive %s\n", dbpath);
|
_alpm_log(db->handle, PM_LOG_DEBUG, "opening database archive %s\n", dbpath);
|
||||||
|
|
||||||
if(archive_read_open_filename(archive, dbpath,
|
if(archive_read_open_filename(archive, dbpath,
|
||||||
ARCHIVE_DEFAULT_BYTES_PER_BLOCK) != ARCHIVE_OK) {
|
ARCHIVE_DEFAULT_BYTES_PER_BLOCK) != ARCHIVE_OK) {
|
||||||
_alpm_log(PM_LOG_ERROR, _("could not open file %s: %s\n"), dbpath,
|
_alpm_log(db->handle, PM_LOG_ERROR, _("could not open file %s: %s\n"), dbpath,
|
||||||
archive_error_string(archive));
|
archive_error_string(archive));
|
||||||
archive_read_finish(archive);
|
archive_read_finish(archive);
|
||||||
RET_ERR(db->handle, PM_ERR_DB_OPEN, -1);
|
RET_ERR(db->handle, PM_ERR_DB_OPEN, -1);
|
||||||
@ -292,7 +293,7 @@ static int sync_db_populate(pmdb_t *db)
|
|||||||
name = archive_entry_pathname(entry);
|
name = archive_entry_pathname(entry);
|
||||||
|
|
||||||
if(_alpm_splitname(name, pkg) != 0) {
|
if(_alpm_splitname(name, pkg) != 0) {
|
||||||
_alpm_log(PM_LOG_ERROR, _("invalid name for database entry '%s'\n"),
|
_alpm_log(db->handle, PM_LOG_ERROR, _("invalid name for database entry '%s'\n"),
|
||||||
name);
|
name);
|
||||||
_alpm_pkg_free(pkg);
|
_alpm_pkg_free(pkg);
|
||||||
pkg = NULL;
|
pkg = NULL;
|
||||||
@ -301,7 +302,7 @@ static int sync_db_populate(pmdb_t *db)
|
|||||||
|
|
||||||
/* duplicated database entries are not allowed */
|
/* duplicated database entries are not allowed */
|
||||||
if(_alpm_pkghash_find(db->pkgcache, pkg->name)) {
|
if(_alpm_pkghash_find(db->pkgcache, pkg->name)) {
|
||||||
_alpm_log(PM_LOG_ERROR, _("duplicated database entry '%s'\n"), pkg->name);
|
_alpm_log(db->handle, PM_LOG_ERROR, _("duplicated database entry '%s'\n"), pkg->name);
|
||||||
_alpm_pkg_free(pkg);
|
_alpm_pkg_free(pkg);
|
||||||
pkg = NULL;
|
pkg = NULL;
|
||||||
continue;
|
continue;
|
||||||
@ -313,14 +314,14 @@ static int sync_db_populate(pmdb_t *db)
|
|||||||
pkg->handle = db->handle;
|
pkg->handle = db->handle;
|
||||||
|
|
||||||
/* add to the collection */
|
/* add to the collection */
|
||||||
_alpm_log(PM_LOG_FUNCTION, "adding '%s' to package cache for db '%s'\n",
|
_alpm_log(db->handle, PM_LOG_FUNCTION, "adding '%s' to package cache for db '%s'\n",
|
||||||
pkg->name, db->treename);
|
pkg->name, db->treename);
|
||||||
db->pkgcache = _alpm_pkghash_add(db->pkgcache, pkg);
|
db->pkgcache = _alpm_pkghash_add(db->pkgcache, pkg);
|
||||||
count++;
|
count++;
|
||||||
} else {
|
} else {
|
||||||
/* we have desc, depends or deltas - parse it */
|
/* we have desc, depends or deltas - parse it */
|
||||||
if(sync_db_read(db, archive, entry, pkg) != 0) {
|
if(sync_db_read(db, archive, entry, pkg) != 0) {
|
||||||
_alpm_log(PM_LOG_ERROR,
|
_alpm_log(db->handle, PM_LOG_ERROR,
|
||||||
_("could not parse package '%s' description file from db '%s'\n"),
|
_("could not parse package '%s' description file from db '%s'\n"),
|
||||||
pkg->name, db->treename);
|
pkg->name, db->treename);
|
||||||
_alpm_pkg_free(pkg);
|
_alpm_pkg_free(pkg);
|
||||||
@ -334,7 +335,7 @@ static int sync_db_populate(pmdb_t *db)
|
|||||||
db->pkgcache->list = alpm_list_msort(db->pkgcache->list, (size_t)count, _alpm_pkg_cmp);
|
db->pkgcache->list = alpm_list_msort(db->pkgcache->list, (size_t)count, _alpm_pkg_cmp);
|
||||||
}
|
}
|
||||||
archive_read_finish(archive);
|
archive_read_finish(archive);
|
||||||
_alpm_log(PM_LOG_DEBUG, "added %d packages to package cache for db '%s'\n",
|
_alpm_log(db->handle, PM_LOG_DEBUG, "added %d packages to package cache for db '%s'\n",
|
||||||
count, db->treename);
|
count, db->treename);
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
@ -368,11 +369,12 @@ static int sync_db_read(pmdb_t *db, struct archive *archive,
|
|||||||
|
|
||||||
entryname = archive_entry_pathname(entry);
|
entryname = archive_entry_pathname(entry);
|
||||||
if(entryname == NULL) {
|
if(entryname == NULL) {
|
||||||
_alpm_log(PM_LOG_DEBUG, "invalid archive entry provided to _alpm_sync_db_read, skipping\n");
|
_alpm_log(db->handle, PM_LOG_DEBUG,
|
||||||
|
"invalid archive entry provided to _alpm_sync_db_read, skipping\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
_alpm_log(PM_LOG_FUNCTION, "loading package data from archive entry %s\n",
|
_alpm_log(db->handle, PM_LOG_FUNCTION, "loading package data from archive entry %s\n",
|
||||||
entryname);
|
entryname);
|
||||||
|
|
||||||
memset(&buf, 0, sizeof(buf));
|
memset(&buf, 0, sizeof(buf));
|
||||||
@ -398,7 +400,7 @@ static int sync_db_read(pmdb_t *db, struct archive *archive,
|
|||||||
pkg = _alpm_pkghash_find(db->pkgcache, pkgname);
|
pkg = _alpm_pkghash_find(db->pkgcache, pkgname);
|
||||||
}
|
}
|
||||||
if(pkg == NULL) {
|
if(pkg == NULL) {
|
||||||
_alpm_log(PM_LOG_DEBUG, "package %s not found in %s sync database",
|
_alpm_log(db->handle, PM_LOG_DEBUG, "package %s not found in %s sync database",
|
||||||
pkgname, db->treename);
|
pkgname, db->treename);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -412,13 +414,13 @@ static int sync_db_read(pmdb_t *db, struct archive *archive,
|
|||||||
if(strcmp(line, "%NAME%") == 0) {
|
if(strcmp(line, "%NAME%") == 0) {
|
||||||
READ_NEXT(line);
|
READ_NEXT(line);
|
||||||
if(strcmp(line, pkg->name) != 0) {
|
if(strcmp(line, pkg->name) != 0) {
|
||||||
_alpm_log(PM_LOG_ERROR, _("%s database is inconsistent: name "
|
_alpm_log(db->handle, PM_LOG_ERROR, _("%s database is inconsistent: name "
|
||||||
"mismatch on package %s\n"), db->treename, pkg->name);
|
"mismatch on package %s\n"), db->treename, pkg->name);
|
||||||
}
|
}
|
||||||
} else if(strcmp(line, "%VERSION%") == 0) {
|
} else if(strcmp(line, "%VERSION%") == 0) {
|
||||||
READ_NEXT(line);
|
READ_NEXT(line);
|
||||||
if(strcmp(line, pkg->version) != 0) {
|
if(strcmp(line, pkg->version) != 0) {
|
||||||
_alpm_log(PM_LOG_ERROR, _("%s database is inconsistent: version "
|
_alpm_log(db->handle, PM_LOG_ERROR, _("%s database is inconsistent: version "
|
||||||
"mismatch on package %s\n"), db->treename, pkg->name);
|
"mismatch on package %s\n"), db->treename, pkg->name);
|
||||||
}
|
}
|
||||||
} else if(strcmp(line, "%FILENAME%") == 0) {
|
} else if(strcmp(line, "%FILENAME%") == 0) {
|
||||||
@ -490,14 +492,14 @@ static int sync_db_read(pmdb_t *db, struct archive *archive,
|
|||||||
/* currently do nothing with this file */
|
/* currently do nothing with this file */
|
||||||
} else {
|
} else {
|
||||||
/* unknown database file */
|
/* unknown database file */
|
||||||
_alpm_log(PM_LOG_DEBUG, "unknown database file: %s\n", filename);
|
_alpm_log(db->handle, PM_LOG_DEBUG, "unknown database file: %s\n", filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
FREE(pkgname);
|
FREE(pkgname);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
_alpm_log(PM_LOG_DEBUG, "error parsing database file: %s\n", filename);
|
_alpm_log(db->handle, PM_LOG_DEBUG, "error parsing database file: %s\n", filename);
|
||||||
FREE(pkgname);
|
FREE(pkgname);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -517,7 +519,7 @@ pmdb_t *_alpm_db_register_sync(pmhandle_t *handle, const char *treename)
|
|||||||
{
|
{
|
||||||
pmdb_t *db;
|
pmdb_t *db;
|
||||||
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "registering sync database '%s'\n", treename);
|
_alpm_log(handle, PM_LOG_DEBUG, "registering sync database '%s'\n", treename);
|
||||||
|
|
||||||
db = _alpm_db_new(treename, 0);
|
db = _alpm_db_new(treename, 0);
|
||||||
if(db == NULL) {
|
if(db == NULL) {
|
||||||
|
@ -93,19 +93,21 @@ static int conflict_isin(pmconflict_t *needle, alpm_list_t *haystack)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Adds the pkg1/pkg2 conflict to the baddeps list
|
/** Adds the pkg1/pkg2 conflict to the baddeps list.
|
||||||
* @param *baddeps list to add conflict to
|
* @param handle the context handle
|
||||||
|
* @param baddeps list to add conflict to
|
||||||
* @param pkg1 first package
|
* @param pkg1 first package
|
||||||
* @param pkg2 package causing conflict
|
* @param pkg2 package causing conflict
|
||||||
|
* @param reason reason for this conflict
|
||||||
*/
|
*/
|
||||||
static int add_conflict(alpm_list_t **baddeps, const char *pkg1,
|
static int add_conflict(pmhandle_t *handle, alpm_list_t **baddeps,
|
||||||
const char *pkg2, const char *reason)
|
const char *pkg1, const char *pkg2, const char *reason)
|
||||||
{
|
{
|
||||||
pmconflict_t *conflict = conflict_new(pkg1, pkg2, reason);
|
pmconflict_t *conflict = conflict_new(pkg1, pkg2, reason);
|
||||||
if(!conflict) {
|
if(!conflict) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
_alpm_log(PM_LOG_DEBUG, "package %s conflicts with %s (by %s)\n",
|
_alpm_log(handle, PM_LOG_DEBUG, "package %s conflicts with %s (by %s)\n",
|
||||||
pkg1, pkg2, reason);
|
pkg1, pkg2, reason);
|
||||||
if(!conflict_isin(conflict, *baddeps)) {
|
if(!conflict_isin(conflict, *baddeps)) {
|
||||||
*baddeps = alpm_list_add(*baddeps, conflict);
|
*baddeps = alpm_list_add(*baddeps, conflict);
|
||||||
@ -121,14 +123,16 @@ static int add_conflict(alpm_list_t **baddeps, const char *pkg1,
|
|||||||
* If a conflict (pkg1, pkg2) is found, it is added to the baddeps list
|
* If a conflict (pkg1, pkg2) is found, it is added to the baddeps list
|
||||||
* in this order if order >= 0, or reverse order (pkg2,pkg1) otherwise.
|
* in this order if order >= 0, or reverse order (pkg2,pkg1) otherwise.
|
||||||
*
|
*
|
||||||
|
* @param handle the context handle
|
||||||
* @param list1 first list of packages
|
* @param list1 first list of packages
|
||||||
* @param list2 second list of packages
|
* @param list2 second list of packages
|
||||||
* @param *baddeps list to store conflicts
|
* @param baddeps list to store conflicts
|
||||||
* @param order if >= 0 the conflict order is preserved, if < 0 it's reversed
|
* @param order if >= 0 the conflict order is preserved, if < 0 it's reversed
|
||||||
*/
|
*/
|
||||||
static void check_conflict(alpm_list_t *list1, alpm_list_t *list2,
|
static void check_conflict(pmhandle_t *handle,
|
||||||
|
alpm_list_t *list1, alpm_list_t *list2,
|
||||||
alpm_list_t **baddeps, int order) {
|
alpm_list_t **baddeps, int order) {
|
||||||
alpm_list_t *i, *j, *k;
|
alpm_list_t *i;
|
||||||
|
|
||||||
if(!baddeps) {
|
if(!baddeps) {
|
||||||
return;
|
return;
|
||||||
@ -136,9 +140,11 @@ static void check_conflict(alpm_list_t *list1, alpm_list_t *list2,
|
|||||||
for(i = list1; i; i = i->next) {
|
for(i = list1; i; i = i->next) {
|
||||||
pmpkg_t *pkg1 = i->data;
|
pmpkg_t *pkg1 = i->data;
|
||||||
const char *pkg1name = alpm_pkg_get_name(pkg1);
|
const char *pkg1name = alpm_pkg_get_name(pkg1);
|
||||||
|
alpm_list_t *j;
|
||||||
|
|
||||||
for(j = alpm_pkg_get_conflicts(pkg1); j; j = j->next) {
|
for(j = alpm_pkg_get_conflicts(pkg1); j; j = j->next) {
|
||||||
const char *conflict = j->data;
|
const char *conflict = j->data;
|
||||||
|
alpm_list_t *k;
|
||||||
pmdepend_t *parsed_conflict = _alpm_splitdep(conflict);
|
pmdepend_t *parsed_conflict = _alpm_splitdep(conflict);
|
||||||
|
|
||||||
for(k = list2; k; k = k->next) {
|
for(k = list2; k; k = k->next) {
|
||||||
@ -152,9 +158,9 @@ static void check_conflict(alpm_list_t *list1, alpm_list_t *list2,
|
|||||||
|
|
||||||
if(_alpm_depcmp(pkg2, parsed_conflict)) {
|
if(_alpm_depcmp(pkg2, parsed_conflict)) {
|
||||||
if(order >= 0) {
|
if(order >= 0) {
|
||||||
add_conflict(baddeps, pkg1name, pkg2name, conflict);
|
add_conflict(handle, baddeps, pkg1name, pkg2name, conflict);
|
||||||
} else {
|
} else {
|
||||||
add_conflict(baddeps, pkg2name, pkg1name, conflict);
|
add_conflict(handle, baddeps, pkg2name, pkg1name, conflict);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -168,8 +174,8 @@ alpm_list_t *_alpm_innerconflicts(pmhandle_t *handle, alpm_list_t *packages)
|
|||||||
{
|
{
|
||||||
alpm_list_t *baddeps = NULL;
|
alpm_list_t *baddeps = NULL;
|
||||||
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "check targets vs targets\n");
|
_alpm_log(handle, PM_LOG_DEBUG, "check targets vs targets\n");
|
||||||
check_conflict(packages, packages, &baddeps, 0);
|
check_conflict(handle, packages, packages, &baddeps, 0);
|
||||||
|
|
||||||
return baddeps;
|
return baddeps;
|
||||||
}
|
}
|
||||||
@ -190,10 +196,10 @@ alpm_list_t *_alpm_outerconflicts(pmdb_t *db, alpm_list_t *packages)
|
|||||||
packages, _alpm_pkg_cmp);
|
packages, _alpm_pkg_cmp);
|
||||||
|
|
||||||
/* two checks to be done here for conflicts */
|
/* two checks to be done here for conflicts */
|
||||||
_alpm_log(PM_LOG_DEBUG, "check targets vs db\n");
|
_alpm_log(db->handle, PM_LOG_DEBUG, "check targets vs db\n");
|
||||||
check_conflict(packages, dblist, &baddeps, 1);
|
check_conflict(db->handle, packages, dblist, &baddeps, 1);
|
||||||
_alpm_log(PM_LOG_DEBUG, "check db vs targets\n");
|
_alpm_log(db->handle, PM_LOG_DEBUG, "check db vs targets\n");
|
||||||
check_conflict(dblist, packages, &baddeps, -1);
|
check_conflict(db->handle, dblist, packages, &baddeps, -1);
|
||||||
|
|
||||||
alpm_list_free(dblist);
|
alpm_list_free(dblist);
|
||||||
return baddeps;
|
return baddeps;
|
||||||
@ -206,7 +212,8 @@ alpm_list_t *_alpm_outerconflicts(pmdb_t *db, alpm_list_t *packages)
|
|||||||
* @return an alpm_list_t of pmconflict_t
|
* @return an alpm_list_t of pmconflict_t
|
||||||
*/
|
*/
|
||||||
alpm_list_t SYMEXPORT *alpm_checkconflicts(pmhandle_t *handle,
|
alpm_list_t SYMEXPORT *alpm_checkconflicts(pmhandle_t *handle,
|
||||||
alpm_list_t *pkglist) {
|
alpm_list_t *pkglist)
|
||||||
|
{
|
||||||
return _alpm_innerconflicts(handle, pkglist);
|
return _alpm_innerconflicts(handle, pkglist);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,9 +279,9 @@ static alpm_list_t *filelist_operation(alpm_list_t *filesA, alpm_list_t *filesB,
|
|||||||
* two package names or one package name and NULL. This is a wrapper for former
|
* two package names or one package name and NULL. This is a wrapper for former
|
||||||
* functionality that was done inline.
|
* functionality that was done inline.
|
||||||
*/
|
*/
|
||||||
static alpm_list_t *add_fileconflict(alpm_list_t *conflicts,
|
static alpm_list_t *add_fileconflict(pmhandle_t *handle,
|
||||||
pmfileconflicttype_t type, const char *filestr,
|
alpm_list_t *conflicts, pmfileconflicttype_t type, const char *filestr,
|
||||||
const char* name1, const char* name2)
|
const char *name1, const char *name2)
|
||||||
{
|
{
|
||||||
pmfileconflict_t *conflict;
|
pmfileconflict_t *conflict;
|
||||||
MALLOC(conflict, sizeof(pmfileconflict_t), return NULL);
|
MALLOC(conflict, sizeof(pmfileconflict_t), return NULL);
|
||||||
@ -289,7 +296,7 @@ static alpm_list_t *add_fileconflict(alpm_list_t *conflicts,
|
|||||||
}
|
}
|
||||||
|
|
||||||
conflicts = alpm_list_add(conflicts, conflict);
|
conflicts = alpm_list_add(conflicts, conflict);
|
||||||
_alpm_log(PM_LOG_DEBUG, "found file conflict %s, packages %s and %s\n",
|
_alpm_log(handle, PM_LOG_DEBUG, "found file conflict %s, packages %s and %s\n",
|
||||||
filestr, name1, name2 ? name2 : "(filesystem)");
|
filestr, name1, name2 ? name2 : "(filesystem)");
|
||||||
|
|
||||||
return conflicts;
|
return conflicts;
|
||||||
@ -381,7 +388,7 @@ alpm_list_t *_alpm_db_find_fileconflicts(pmhandle_t *handle,
|
|||||||
PROGRESS(trans, PM_TRANS_PROGRESS_CONFLICTS_START, "", percent,
|
PROGRESS(trans, PM_TRANS_PROGRESS_CONFLICTS_START, "", percent,
|
||||||
numtargs, current);
|
numtargs, current);
|
||||||
/* CHECK 1: check every target against every target */
|
/* CHECK 1: check every target against every target */
|
||||||
_alpm_log(PM_LOG_DEBUG, "searching for file conflicts: %s\n",
|
_alpm_log(handle, PM_LOG_DEBUG, "searching for file conflicts: %s\n",
|
||||||
alpm_pkg_get_name(p1));
|
alpm_pkg_get_name(p1));
|
||||||
for(j = i->next; j; j = j->next) {
|
for(j = i->next; j; j = j->next) {
|
||||||
p2 = j->data;
|
p2 = j->data;
|
||||||
@ -394,7 +401,7 @@ alpm_list_t *_alpm_db_find_fileconflicts(pmhandle_t *handle,
|
|||||||
if(tmpfiles) {
|
if(tmpfiles) {
|
||||||
for(k = tmpfiles; k; k = k->next) {
|
for(k = tmpfiles; k; k = k->next) {
|
||||||
snprintf(path, PATH_MAX, "%s%s", handle->root, (char *)k->data);
|
snprintf(path, PATH_MAX, "%s%s", handle->root, (char *)k->data);
|
||||||
conflicts = add_fileconflict(conflicts, PM_FILECONFLICT_TARGET, path,
|
conflicts = add_fileconflict(handle, conflicts, PM_FILECONFLICT_TARGET, path,
|
||||||
alpm_pkg_get_name(p1), alpm_pkg_get_name(p2));
|
alpm_pkg_get_name(p1), alpm_pkg_get_name(p2));
|
||||||
if(!conflicts) {
|
if(!conflicts) {
|
||||||
FREELIST(conflicts);
|
FREELIST(conflicts);
|
||||||
@ -411,7 +418,7 @@ alpm_list_t *_alpm_db_find_fileconflicts(pmhandle_t *handle,
|
|||||||
char *filestr = NULL;
|
char *filestr = NULL;
|
||||||
|
|
||||||
/* CHECK 2: check every target against the filesystem */
|
/* CHECK 2: check every target against the filesystem */
|
||||||
_alpm_log(PM_LOG_DEBUG, "searching for filesystem conflicts: %s\n", p1->name);
|
_alpm_log(handle, PM_LOG_DEBUG, "searching for filesystem conflicts: %s\n", p1->name);
|
||||||
dbpkg = _alpm_db_get_pkgfromcache(handle->db_local, p1->name);
|
dbpkg = _alpm_db_get_pkgfromcache(handle->db_local, p1->name);
|
||||||
|
|
||||||
/* Do two different checks here. If the package is currently installed,
|
/* Do two different checks here. If the package is currently installed,
|
||||||
@ -439,15 +446,15 @@ alpm_list_t *_alpm_db_find_fileconflicts(pmhandle_t *handle,
|
|||||||
|
|
||||||
if(path[strlen(path)-1] == '/') {
|
if(path[strlen(path)-1] == '/') {
|
||||||
if(S_ISDIR(lsbuf.st_mode)) {
|
if(S_ISDIR(lsbuf.st_mode)) {
|
||||||
_alpm_log(PM_LOG_DEBUG, "%s is a directory, not a conflict\n", path);
|
_alpm_log(handle, PM_LOG_DEBUG, "%s is a directory, not a conflict\n", path);
|
||||||
continue;
|
continue;
|
||||||
} else if(S_ISLNK(lsbuf.st_mode) && S_ISDIR(sbuf.st_mode)) {
|
} else if(S_ISLNK(lsbuf.st_mode) && S_ISDIR(sbuf.st_mode)) {
|
||||||
_alpm_log(PM_LOG_DEBUG,
|
_alpm_log(handle, PM_LOG_DEBUG,
|
||||||
"%s is a symlink to a dir, hopefully not a conflict\n", path);
|
"%s is a symlink to a dir, hopefully not a conflict\n", path);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_alpm_log(PM_LOG_DEBUG, "checking possible conflict: %s\n", path);
|
_alpm_log(handle, PM_LOG_DEBUG, "checking possible conflict: %s\n", path);
|
||||||
|
|
||||||
int resolved_conflict = 0; /* have we acted on this conflict? */
|
int resolved_conflict = 0; /* have we acted on this conflict? */
|
||||||
|
|
||||||
@ -455,7 +462,7 @@ alpm_list_t *_alpm_db_find_fileconflicts(pmhandle_t *handle,
|
|||||||
for(k = remove; k && !resolved_conflict; k = k->next) {
|
for(k = remove; k && !resolved_conflict; k = k->next) {
|
||||||
pmpkg_t *rempkg = k->data;
|
pmpkg_t *rempkg = k->data;
|
||||||
if(rempkg && alpm_list_find_str(alpm_pkg_get_files(rempkg), filestr)) {
|
if(rempkg && alpm_list_find_str(alpm_pkg_get_files(rempkg), filestr)) {
|
||||||
_alpm_log(PM_LOG_DEBUG, "local file will be removed, not a conflict: %s\n", filestr);
|
_alpm_log(handle, PM_LOG_DEBUG, "local file will be removed, not a conflict: %s\n", filestr);
|
||||||
resolved_conflict = 1;
|
resolved_conflict = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -475,7 +482,7 @@ alpm_list_t *_alpm_db_find_fileconflicts(pmhandle_t *handle,
|
|||||||
* by its new owner (whether the file is in backup array or not */
|
* by its new owner (whether the file is in backup array or not */
|
||||||
handle->trans->skip_remove =
|
handle->trans->skip_remove =
|
||||||
alpm_list_add(handle->trans->skip_remove, strdup(filestr));
|
alpm_list_add(handle->trans->skip_remove, strdup(filestr));
|
||||||
_alpm_log(PM_LOG_DEBUG, "file changed packages, adding to remove skiplist: %s\n", filestr);
|
_alpm_log(handle, PM_LOG_DEBUG, "file changed packages, adding to remove skiplist: %s\n", filestr);
|
||||||
resolved_conflict = 1;
|
resolved_conflict = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -485,7 +492,7 @@ alpm_list_t *_alpm_db_find_fileconflicts(pmhandle_t *handle,
|
|||||||
char *dir = malloc(strlen(filestr) + 2);
|
char *dir = malloc(strlen(filestr) + 2);
|
||||||
sprintf(dir, "%s/", filestr);
|
sprintf(dir, "%s/", filestr);
|
||||||
if(alpm_list_find_str(alpm_pkg_get_files(dbpkg),dir)) {
|
if(alpm_list_find_str(alpm_pkg_get_files(dbpkg),dir)) {
|
||||||
_alpm_log(PM_LOG_DEBUG, "check if all files in %s belongs to %s\n",
|
_alpm_log(handle, PM_LOG_DEBUG, "check if all files in %s belongs to %s\n",
|
||||||
dir, dbpkg->name);
|
dir, dbpkg->name);
|
||||||
resolved_conflict = dir_belongsto_pkg(handle->root, filestr, dbpkg);
|
resolved_conflict = dir_belongsto_pkg(handle->root, filestr, dbpkg);
|
||||||
}
|
}
|
||||||
@ -506,8 +513,7 @@ alpm_list_t *_alpm_db_find_fileconflicts(pmhandle_t *handle,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!resolved_conflict) {
|
if(!resolved_conflict) {
|
||||||
_alpm_log(PM_LOG_DEBUG, "file found in conflict: %s\n", path);
|
conflicts = add_fileconflict(handle, conflicts, PM_FILECONFLICT_FILESYSTEM,
|
||||||
conflicts = add_fileconflict(conflicts, PM_FILECONFLICT_FILESYSTEM,
|
|
||||||
path, p1->name, NULL);
|
path, p1->name, NULL);
|
||||||
if(!conflicts) {
|
if(!conflicts) {
|
||||||
FREELIST(conflicts);
|
FREELIST(conflicts);
|
||||||
|
@ -64,7 +64,7 @@ void _alpm_db_unregister(pmdb_t *db)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "unregistering database '%s'\n", db->treename);
|
_alpm_log(db->handle, PM_LOG_DEBUG, "unregistering database '%s'\n", db->treename);
|
||||||
_alpm_db_free(db);
|
_alpm_db_free(db);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,18 +128,14 @@ int SYMEXPORT alpm_db_unregister(pmdb_t *db)
|
|||||||
/** Get the serverlist of a database. */
|
/** Get the serverlist of a database. */
|
||||||
alpm_list_t SYMEXPORT *alpm_db_get_servers(const pmdb_t *db)
|
alpm_list_t SYMEXPORT *alpm_db_get_servers(const pmdb_t *db)
|
||||||
{
|
{
|
||||||
/* Sanity checks */
|
|
||||||
ASSERT(db != NULL, return NULL);
|
ASSERT(db != NULL, return NULL);
|
||||||
|
|
||||||
return db->servers;
|
return db->servers;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set the serverlist of a database. */
|
/** Set the serverlist of a database. */
|
||||||
int SYMEXPORT alpm_db_set_servers(pmdb_t *db, alpm_list_t *servers)
|
int SYMEXPORT alpm_db_set_servers(pmdb_t *db, alpm_list_t *servers)
|
||||||
{
|
{
|
||||||
/* Sanity checks */
|
|
||||||
ASSERT(db != NULL, return -1);
|
ASSERT(db != NULL, return -1);
|
||||||
|
|
||||||
if(db->servers) FREELIST(db->servers);
|
if(db->servers) FREELIST(db->servers);
|
||||||
db->servers = servers;
|
db->servers = servers;
|
||||||
return 0;
|
return 0;
|
||||||
@ -176,7 +172,7 @@ int SYMEXPORT alpm_db_add_server(pmdb_t *db, const char *url)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
db->servers = alpm_list_add(db->servers, newurl);
|
db->servers = alpm_list_add(db->servers, newurl);
|
||||||
_alpm_log(PM_LOG_DEBUG, "adding new server URL to database '%s': %s\n",
|
_alpm_log(db->handle, PM_LOG_DEBUG, "adding new server URL to database '%s': %s\n",
|
||||||
db->treename, newurl);
|
db->treename, newurl);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -203,7 +199,7 @@ int SYMEXPORT alpm_db_remove_server(pmdb_t *db, const char *url)
|
|||||||
db->servers = alpm_list_remove_str(db->servers, newurl, &vdata);
|
db->servers = alpm_list_remove_str(db->servers, newurl, &vdata);
|
||||||
free(newurl);
|
free(newurl);
|
||||||
if(vdata) {
|
if(vdata) {
|
||||||
_alpm_log(PM_LOG_DEBUG, "removed server URL from database '%s': %s\n",
|
_alpm_log(db->handle, PM_LOG_DEBUG, "removed server URL from database '%s': %s\n",
|
||||||
db->treename, newurl);
|
db->treename, newurl);
|
||||||
free(vdata);
|
free(vdata);
|
||||||
return 0;
|
return 0;
|
||||||
@ -222,7 +218,7 @@ int SYMEXPORT alpm_db_set_pgp_verify(pmdb_t *db, pgp_verify_t verify)
|
|||||||
ASSERT(db != NULL, return -1);
|
ASSERT(db != NULL, return -1);
|
||||||
|
|
||||||
db->pgp_verify = verify;
|
db->pgp_verify = verify;
|
||||||
_alpm_log(PM_LOG_DEBUG, "adding VerifySig option to database '%s': %d\n",
|
_alpm_log(db->handle, PM_LOG_DEBUG, "adding VerifySig option to database '%s': %d\n",
|
||||||
db->treename, verify);
|
db->treename, verify);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -302,7 +298,7 @@ int SYMEXPORT alpm_db_set_pkgreason(pmdb_t *db, const char *name, pmpkgreason_t
|
|||||||
RET_ERR(db->handle, PM_ERR_PKG_NOT_FOUND, -1);
|
RET_ERR(db->handle, PM_ERR_PKG_NOT_FOUND, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "setting install reason %u for %s/%s\n", reason, db->treename, name);
|
_alpm_log(db->handle, PM_LOG_DEBUG, "setting install reason %u for %s/%s\n", reason, db->treename, name);
|
||||||
if(alpm_pkg_get_reason(pkg) == reason) {
|
if(alpm_pkg_get_reason(pkg) == reason) {
|
||||||
/* we are done */
|
/* we are done */
|
||||||
return 0;
|
return 0;
|
||||||
@ -355,7 +351,7 @@ const char *_alpm_db_path(pmdb_t *db)
|
|||||||
|
|
||||||
dbpath = alpm_option_get_dbpath(db->handle);
|
dbpath = alpm_option_get_dbpath(db->handle);
|
||||||
if(!dbpath) {
|
if(!dbpath) {
|
||||||
_alpm_log(PM_LOG_ERROR, _("database path is undefined\n"));
|
_alpm_log(db->handle, PM_LOG_ERROR, _("database path is undefined\n"));
|
||||||
RET_ERR(db->handle, PM_ERR_DB_OPEN, NULL);
|
RET_ERR(db->handle, PM_ERR_DB_OPEN, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -369,7 +365,7 @@ const char *_alpm_db_path(pmdb_t *db)
|
|||||||
/* all sync DBs now reside in the sync/ subdir of the dbpath */
|
/* all sync DBs now reside in the sync/ subdir of the dbpath */
|
||||||
sprintf(db->_path, "%ssync/%s.db", dbpath, db->treename);
|
sprintf(db->_path, "%ssync/%s.db", dbpath, db->treename);
|
||||||
}
|
}
|
||||||
_alpm_log(PM_LOG_DEBUG, "database path for tree %s set to %s\n",
|
_alpm_log(db->handle, PM_LOG_DEBUG, "database path for tree %s set to %s\n",
|
||||||
db->treename, db->_path);
|
db->treename, db->_path);
|
||||||
}
|
}
|
||||||
return db->_path;
|
return db->_path;
|
||||||
@ -406,7 +402,7 @@ alpm_list_t *_alpm_db_search(pmdb_t *db, const alpm_list_t *needles)
|
|||||||
}
|
}
|
||||||
ret = NULL;
|
ret = NULL;
|
||||||
targ = i->data;
|
targ = i->data;
|
||||||
_alpm_log(PM_LOG_DEBUG, "searching for target '%s'\n", targ);
|
_alpm_log(db->handle, PM_LOG_DEBUG, "searching for target '%s'\n", targ);
|
||||||
|
|
||||||
if(regcomp(®, targ, REG_EXTENDED | REG_NOSUB | REG_ICASE | REG_NEWLINE) != 0) {
|
if(regcomp(®, targ, REG_EXTENDED | REG_NOSUB | REG_ICASE | REG_NEWLINE) != 0) {
|
||||||
RET_ERR(db->handle, PM_ERR_INVALID_REGEX, NULL);
|
RET_ERR(db->handle, PM_ERR_INVALID_REGEX, NULL);
|
||||||
@ -448,7 +444,7 @@ alpm_list_t *_alpm_db_search(pmdb_t *db, const alpm_list_t *needles)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(matched != NULL) {
|
if(matched != NULL) {
|
||||||
_alpm_log(PM_LOG_DEBUG, " search target '%s' matched '%s'\n",
|
_alpm_log(db->handle, PM_LOG_DEBUG, " search target '%s' matched '%s'\n",
|
||||||
targ, matched);
|
targ, matched);
|
||||||
ret = alpm_list_add(ret, pkg);
|
ret = alpm_list_add(ret, pkg);
|
||||||
}
|
}
|
||||||
@ -474,10 +470,10 @@ int _alpm_db_load_pkgcache(pmdb_t *db)
|
|||||||
}
|
}
|
||||||
_alpm_db_free_pkgcache(db);
|
_alpm_db_free_pkgcache(db);
|
||||||
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "loading package cache for repository '%s'\n",
|
_alpm_log(db->handle, PM_LOG_DEBUG, "loading package cache for repository '%s'\n",
|
||||||
db->treename);
|
db->treename);
|
||||||
if(db->ops->populate(db) == -1) {
|
if(db->ops->populate(db) == -1) {
|
||||||
_alpm_log(PM_LOG_DEBUG,
|
_alpm_log(db->handle, PM_LOG_DEBUG,
|
||||||
"failed to load package cache for repository '%s'\n", db->treename);
|
"failed to load package cache for repository '%s'\n", db->treename);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -492,7 +488,7 @@ void _alpm_db_free_pkgcache(pmdb_t *db)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "freeing package cache for repository '%s'\n",
|
_alpm_log(db->handle, PM_LOG_DEBUG, "freeing package cache for repository '%s'\n",
|
||||||
db->treename);
|
db->treename);
|
||||||
|
|
||||||
alpm_list_free_inner(_alpm_db_get_pkgcache(db),
|
alpm_list_free_inner(_alpm_db_get_pkgcache(db),
|
||||||
@ -515,7 +511,7 @@ pmpkghash_t *_alpm_db_get_pkgcache_hash(pmdb_t *db)
|
|||||||
|
|
||||||
/* hmmm, still NULL ?*/
|
/* hmmm, still NULL ?*/
|
||||||
if(!db->pkgcache) {
|
if(!db->pkgcache) {
|
||||||
_alpm_log(PM_LOG_DEBUG, "warning: pkgcache is NULL for db '%s'\n", db->treename);
|
_alpm_log(db->handle, PM_LOG_DEBUG, "warning: pkgcache is NULL for db '%s'\n", db->treename);
|
||||||
}
|
}
|
||||||
|
|
||||||
return db->pkgcache;
|
return db->pkgcache;
|
||||||
@ -546,7 +542,7 @@ int _alpm_db_add_pkgincache(pmdb_t *db, pmpkg_t *pkg)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "adding entry '%s' in '%s' cache\n",
|
_alpm_log(db->handle, PM_LOG_DEBUG, "adding entry '%s' in '%s' cache\n",
|
||||||
alpm_pkg_get_name(newpkg), db->treename);
|
alpm_pkg_get_name(newpkg), db->treename);
|
||||||
db->pkgcache = _alpm_pkghash_add_sorted(db->pkgcache, newpkg);
|
db->pkgcache = _alpm_pkghash_add_sorted(db->pkgcache, newpkg);
|
||||||
|
|
||||||
@ -563,13 +559,13 @@ int _alpm_db_remove_pkgfromcache(pmdb_t *db, pmpkg_t *pkg)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "removing entry '%s' from '%s' cache\n",
|
_alpm_log(db->handle, PM_LOG_DEBUG, "removing entry '%s' from '%s' cache\n",
|
||||||
alpm_pkg_get_name(pkg), db->treename);
|
alpm_pkg_get_name(pkg), db->treename);
|
||||||
|
|
||||||
db->pkgcache = _alpm_pkghash_remove(db->pkgcache, pkg, &data);
|
db->pkgcache = _alpm_pkghash_remove(db->pkgcache, pkg, &data);
|
||||||
if(data == NULL) {
|
if(data == NULL) {
|
||||||
/* package not found */
|
/* package not found */
|
||||||
_alpm_log(PM_LOG_DEBUG, "cannot remove entry '%s' from '%s' cache: not found\n",
|
_alpm_log(db->handle, PM_LOG_DEBUG, "cannot remove entry '%s' from '%s' cache: not found\n",
|
||||||
alpm_pkg_get_name(pkg), db->treename);
|
alpm_pkg_get_name(pkg), db->treename);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -589,7 +585,7 @@ pmpkg_t *_alpm_db_get_pkgfromcache(pmdb_t *db, const char *target)
|
|||||||
|
|
||||||
pmpkghash_t *pkgcache = _alpm_db_get_pkgcache_hash(db);
|
pmpkghash_t *pkgcache = _alpm_db_get_pkgcache_hash(db);
|
||||||
if(!pkgcache) {
|
if(!pkgcache) {
|
||||||
_alpm_log(PM_LOG_DEBUG, "warning: failed to get '%s' from NULL pkgcache\n",
|
_alpm_log(db->handle, PM_LOG_DEBUG, "warning: failed to get '%s' from NULL pkgcache\n",
|
||||||
target);
|
target);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -607,7 +603,7 @@ int _alpm_db_load_grpcache(pmdb_t *db)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "loading group cache for repository '%s'\n",
|
_alpm_log(db->handle, PM_LOG_DEBUG, "loading group cache for repository '%s'\n",
|
||||||
db->treename);
|
db->treename);
|
||||||
|
|
||||||
for(lp = _alpm_db_get_pkgcache(db); lp; lp = lp->next) {
|
for(lp = _alpm_db_get_pkgcache(db); lp; lp = lp->next) {
|
||||||
@ -657,7 +653,7 @@ void _alpm_db_free_grpcache(pmdb_t *db)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "freeing group cache for repository '%s'\n",
|
_alpm_log(db->handle, PM_LOG_DEBUG, "freeing group cache for repository '%s'\n",
|
||||||
db->treename);
|
db->treename);
|
||||||
|
|
||||||
for(lg = db->grpcache; lg; lg = lg->next) {
|
for(lg = db->grpcache; lg; lg = lg->next) {
|
||||||
|
@ -235,14 +235,14 @@ off_t _alpm_shortest_delta_path(pmhandle_t *handle, alpm_list_t *deltas,
|
|||||||
return bestsize;
|
return bestsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "started delta shortest-path search for '%s'\n", to);
|
_alpm_log(handle, PM_LOG_DEBUG, "started delta shortest-path search for '%s'\n", to);
|
||||||
|
|
||||||
vertices = graph_init(deltas, 0);
|
vertices = graph_init(deltas, 0);
|
||||||
graph_init_size(handle, vertices);
|
graph_init_size(handle, vertices);
|
||||||
dijkstra(vertices);
|
dijkstra(vertices);
|
||||||
bestsize = shortest_path(vertices, to, &bestpath);
|
bestsize = shortest_path(vertices, to, &bestpath);
|
||||||
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "delta shortest-path search complete : '%jd'\n", (intmax_t)bestsize);
|
_alpm_log(handle, PM_LOG_DEBUG, "delta shortest-path search complete : '%jd'\n", (intmax_t)bestsize);
|
||||||
|
|
||||||
alpm_list_free_inner(vertices, _alpm_graph_free);
|
alpm_list_free_inner(vertices, _alpm_graph_free);
|
||||||
alpm_list_free(vertices);
|
alpm_list_free(vertices);
|
||||||
@ -340,8 +340,6 @@ pmdelta_t *_alpm_delta_parse(char *line)
|
|||||||
tmp2 = tmp;
|
tmp2 = tmp;
|
||||||
STRDUP(delta->to, tmp2, return NULL);
|
STRDUP(delta->to, tmp2, return NULL);
|
||||||
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "delta : %s %s '%jd'\n", delta->from, delta->to, (intmax_t)delta->delta_size);
|
|
||||||
|
|
||||||
return delta;
|
return delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,7 +126,8 @@ static alpm_list_t *dep_graph_init(alpm_list_t *targets)
|
|||||||
* This function returns the new alpm_list_t* target list.
|
* This function returns the new alpm_list_t* target list.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
alpm_list_t *_alpm_sortbydeps(alpm_list_t *targets, int reverse)
|
alpm_list_t *_alpm_sortbydeps(pmhandle_t *handle,
|
||||||
|
alpm_list_t *targets, int reverse)
|
||||||
{
|
{
|
||||||
alpm_list_t *newtargs = NULL;
|
alpm_list_t *newtargs = NULL;
|
||||||
alpm_list_t *vertices = NULL;
|
alpm_list_t *vertices = NULL;
|
||||||
@ -137,7 +138,7 @@ alpm_list_t *_alpm_sortbydeps(alpm_list_t *targets, int reverse)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "started sorting dependencies\n");
|
_alpm_log(handle, PM_LOG_DEBUG, "started sorting dependencies\n");
|
||||||
|
|
||||||
vertices = dep_graph_init(targets);
|
vertices = dep_graph_init(targets);
|
||||||
|
|
||||||
@ -160,13 +161,13 @@ alpm_list_t *_alpm_sortbydeps(alpm_list_t *targets, int reverse)
|
|||||||
pmpkg_t *childpkg = nextchild->data;
|
pmpkg_t *childpkg = nextchild->data;
|
||||||
const char *message;
|
const char *message;
|
||||||
|
|
||||||
_alpm_log(PM_LOG_WARNING, _("dependency cycle detected:\n"));
|
_alpm_log(handle, PM_LOG_WARNING, _("dependency cycle detected:\n"));
|
||||||
if(reverse) {
|
if(reverse) {
|
||||||
message =_("%s will be removed after its %s dependency\n");
|
message =_("%s will be removed after its %s dependency\n");
|
||||||
} else {
|
} else {
|
||||||
message =_("%s will be installed before its %s dependency\n");
|
message =_("%s will be installed before its %s dependency\n");
|
||||||
}
|
}
|
||||||
_alpm_log(PM_LOG_WARNING, message, vertexpkg->name, childpkg->name);
|
_alpm_log(handle, PM_LOG_WARNING, message, vertexpkg->name, childpkg->name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!found) {
|
if(!found) {
|
||||||
@ -185,7 +186,7 @@ alpm_list_t *_alpm_sortbydeps(alpm_list_t *targets, int reverse)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "sorting dependencies finished\n");
|
_alpm_log(handle, PM_LOG_DEBUG, "sorting dependencies finished\n");
|
||||||
|
|
||||||
if(reverse) {
|
if(reverse) {
|
||||||
/* reverse the order */
|
/* reverse the order */
|
||||||
@ -288,7 +289,7 @@ alpm_list_t SYMEXPORT *alpm_checkdeps(pmhandle_t *handle, alpm_list_t *pkglist,
|
|||||||
/* look for unsatisfied dependencies of the upgrade list */
|
/* look for unsatisfied dependencies of the upgrade list */
|
||||||
for(i = upgrade; i; i = i->next) {
|
for(i = upgrade; i; i = i->next) {
|
||||||
pmpkg_t *tp = i->data;
|
pmpkg_t *tp = i->data;
|
||||||
_alpm_log(PM_LOG_DEBUG, "checkdeps: package %s-%s\n",
|
_alpm_log(handle, PM_LOG_DEBUG, "checkdeps: package %s-%s\n",
|
||||||
alpm_pkg_get_name(tp), alpm_pkg_get_version(tp));
|
alpm_pkg_get_name(tp), alpm_pkg_get_version(tp));
|
||||||
|
|
||||||
for(j = alpm_pkg_get_depends(tp); j; j = j->next) {
|
for(j = alpm_pkg_get_depends(tp); j; j = j->next) {
|
||||||
@ -301,7 +302,7 @@ alpm_list_t SYMEXPORT *alpm_checkdeps(pmhandle_t *handle, alpm_list_t *pkglist,
|
|||||||
/* Unsatisfied dependency in the upgrade list */
|
/* Unsatisfied dependency in the upgrade list */
|
||||||
pmdepmissing_t *miss;
|
pmdepmissing_t *miss;
|
||||||
char *missdepstring = alpm_dep_compute_string(depend);
|
char *missdepstring = alpm_dep_compute_string(depend);
|
||||||
_alpm_log(PM_LOG_DEBUG, "checkdeps: missing dependency '%s' for package '%s'\n",
|
_alpm_log(handle, PM_LOG_DEBUG, "checkdeps: missing dependency '%s' for package '%s'\n",
|
||||||
missdepstring, alpm_pkg_get_name(tp));
|
missdepstring, alpm_pkg_get_name(tp));
|
||||||
free(missdepstring);
|
free(missdepstring);
|
||||||
miss = depmiss_new(alpm_pkg_get_name(tp), depend, NULL);
|
miss = depmiss_new(alpm_pkg_get_name(tp), depend, NULL);
|
||||||
@ -328,7 +329,7 @@ alpm_list_t SYMEXPORT *alpm_checkdeps(pmhandle_t *handle, alpm_list_t *pkglist,
|
|||||||
!find_dep_satisfier(dblist, depend)) {
|
!find_dep_satisfier(dblist, depend)) {
|
||||||
pmdepmissing_t *miss;
|
pmdepmissing_t *miss;
|
||||||
char *missdepstring = alpm_dep_compute_string(depend);
|
char *missdepstring = alpm_dep_compute_string(depend);
|
||||||
_alpm_log(PM_LOG_DEBUG, "checkdeps: transaction would break '%s' dependency of '%s'\n",
|
_alpm_log(handle, PM_LOG_DEBUG, "checkdeps: transaction would break '%s' dependency of '%s'\n",
|
||||||
missdepstring, alpm_pkg_get_name(lp));
|
missdepstring, alpm_pkg_get_name(lp));
|
||||||
free(missdepstring);
|
free(missdepstring);
|
||||||
miss = depmiss_new(lp->name, depend, alpm_pkg_get_name(causingpkg));
|
miss = depmiss_new(lp->name, depend, alpm_pkg_get_name(causingpkg));
|
||||||
@ -481,7 +482,7 @@ static int can_remove_package(pmdb_t *db, pmpkg_t *pkg, alpm_list_t *targets,
|
|||||||
if(!include_explicit) {
|
if(!include_explicit) {
|
||||||
/* see if it was explicitly installed */
|
/* see if it was explicitly installed */
|
||||||
if(alpm_pkg_get_reason(pkg) == PM_PKG_REASON_EXPLICIT) {
|
if(alpm_pkg_get_reason(pkg) == PM_PKG_REASON_EXPLICIT) {
|
||||||
_alpm_log(PM_LOG_DEBUG, "excluding %s -- explicitly installed\n",
|
_alpm_log(db->handle, PM_LOG_DEBUG, "excluding %s -- explicitly installed\n",
|
||||||
alpm_pkg_get_name(pkg));
|
alpm_pkg_get_name(pkg));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -529,7 +530,7 @@ void _alpm_recursedeps(pmdb_t *db, alpm_list_t *targs, int include_explicit)
|
|||||||
pmpkg_t *deppkg = j->data;
|
pmpkg_t *deppkg = j->data;
|
||||||
if(_alpm_dep_edge(pkg, deppkg)
|
if(_alpm_dep_edge(pkg, deppkg)
|
||||||
&& can_remove_package(db, deppkg, targs, include_explicit)) {
|
&& can_remove_package(db, deppkg, targs, include_explicit)) {
|
||||||
_alpm_log(PM_LOG_DEBUG, "adding '%s' to the targets\n",
|
_alpm_log(db->handle, PM_LOG_DEBUG, "adding '%s' to the targets\n",
|
||||||
alpm_pkg_get_name(deppkg));
|
alpm_pkg_get_name(deppkg));
|
||||||
/* add it to the target list */
|
/* add it to the target list */
|
||||||
targs = alpm_list_add(targs, _alpm_pkg_dup(deppkg));
|
targs = alpm_list_add(targs, _alpm_pkg_dup(deppkg));
|
||||||
@ -570,7 +571,7 @@ static pmpkg_t *resolvedep(pmhandle_t *handle, pmdepend_t *dep,
|
|||||||
QUESTION(handle->trans, PM_TRANS_CONV_INSTALL_IGNOREPKG, pkg,
|
QUESTION(handle->trans, PM_TRANS_CONV_INSTALL_IGNOREPKG, pkg,
|
||||||
NULL, NULL, &install);
|
NULL, NULL, &install);
|
||||||
} else {
|
} else {
|
||||||
_alpm_log(PM_LOG_WARNING, _("ignoring package %s-%s\n"), pkg->name, pkg->version);
|
_alpm_log(handle, PM_LOG_WARNING, _("ignoring package %s-%s\n"), pkg->name, pkg->version);
|
||||||
}
|
}
|
||||||
if(!install) {
|
if(!install) {
|
||||||
ignored = 1;
|
ignored = 1;
|
||||||
@ -592,14 +593,14 @@ static pmpkg_t *resolvedep(pmhandle_t *handle, pmdepend_t *dep,
|
|||||||
QUESTION(handle->trans, PM_TRANS_CONV_INSTALL_IGNOREPKG,
|
QUESTION(handle->trans, PM_TRANS_CONV_INSTALL_IGNOREPKG,
|
||||||
pkg, NULL, NULL, &install);
|
pkg, NULL, NULL, &install);
|
||||||
} else {
|
} else {
|
||||||
_alpm_log(PM_LOG_WARNING, _("ignoring package %s-%s\n"), pkg->name, pkg->version);
|
_alpm_log(handle, PM_LOG_WARNING, _("ignoring package %s-%s\n"), pkg->name, pkg->version);
|
||||||
}
|
}
|
||||||
if(!install) {
|
if(!install) {
|
||||||
ignored = 1;
|
ignored = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_alpm_log(PM_LOG_DEBUG, "provider found (%s provides %s)\n",
|
_alpm_log(handle, PM_LOG_DEBUG, "provider found (%s provides %s)\n",
|
||||||
pkg->name, dep->name);
|
pkg->name, dep->name);
|
||||||
providers = alpm_list_add(providers, pkg);
|
providers = alpm_list_add(providers, pkg);
|
||||||
/* keep looking for other providers in the all dbs */
|
/* keep looking for other providers in the all dbs */
|
||||||
@ -706,7 +707,7 @@ int _alpm_resolvedeps(pmhandle_t *handle, alpm_list_t *localpkgs, pmpkg_t *pkg,
|
|||||||
on that list */
|
on that list */
|
||||||
*packages = alpm_list_add(*packages, pkg);
|
*packages = alpm_list_add(*packages, pkg);
|
||||||
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "started resolving dependencies\n");
|
_alpm_log(handle, PM_LOG_DEBUG, "started resolving dependencies\n");
|
||||||
for(i = alpm_list_last(*packages); i; i = i->next) {
|
for(i = alpm_list_last(*packages); i; i = i->next) {
|
||||||
pmpkg_t *tpkg = i->data;
|
pmpkg_t *tpkg = i->data;
|
||||||
targ = alpm_list_add(NULL, tpkg);
|
targ = alpm_list_add(NULL, tpkg);
|
||||||
@ -732,7 +733,7 @@ int _alpm_resolvedeps(pmhandle_t *handle, alpm_list_t *localpkgs, pmpkg_t *pkg,
|
|||||||
if(!spkg) {
|
if(!spkg) {
|
||||||
handle->pm_errno = PM_ERR_UNSATISFIED_DEPS;
|
handle->pm_errno = PM_ERR_UNSATISFIED_DEPS;
|
||||||
char *missdepstring = alpm_dep_compute_string(missdep);
|
char *missdepstring = alpm_dep_compute_string(missdep);
|
||||||
_alpm_log(PM_LOG_WARNING,
|
_alpm_log(handle, PM_LOG_WARNING,
|
||||||
_("cannot resolve \"%s\", a dependency of \"%s\"\n"),
|
_("cannot resolve \"%s\", a dependency of \"%s\"\n"),
|
||||||
missdepstring, tpkg->name);
|
missdepstring, tpkg->name);
|
||||||
free(missdepstring);
|
free(missdepstring);
|
||||||
@ -741,7 +742,7 @@ int _alpm_resolvedeps(pmhandle_t *handle, alpm_list_t *localpkgs, pmpkg_t *pkg,
|
|||||||
}
|
}
|
||||||
ret = -1;
|
ret = -1;
|
||||||
} else {
|
} else {
|
||||||
_alpm_log(PM_LOG_DEBUG, "pulling dependency %s (needed by %s)\n",
|
_alpm_log(handle, PM_LOG_DEBUG, "pulling dependency %s (needed by %s)\n",
|
||||||
alpm_pkg_get_name(spkg), alpm_pkg_get_name(tpkg));
|
alpm_pkg_get_name(spkg), alpm_pkg_get_name(tpkg));
|
||||||
*packages = alpm_list_add(*packages, spkg);
|
*packages = alpm_list_add(*packages, spkg);
|
||||||
_alpm_depmiss_free(miss);
|
_alpm_depmiss_free(miss);
|
||||||
@ -756,55 +757,43 @@ int _alpm_resolvedeps(pmhandle_t *handle, alpm_list_t *localpkgs, pmpkg_t *pkg,
|
|||||||
} else {
|
} else {
|
||||||
alpm_list_free(packages_copy);
|
alpm_list_free(packages_copy);
|
||||||
}
|
}
|
||||||
_alpm_log(PM_LOG_DEBUG, "finished resolving dependencies\n");
|
_alpm_log(handle, PM_LOG_DEBUG, "finished resolving dependencies\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char SYMEXPORT *alpm_miss_get_target(const pmdepmissing_t *miss)
|
const char SYMEXPORT *alpm_miss_get_target(const pmdepmissing_t *miss)
|
||||||
{
|
{
|
||||||
/* Sanity checks */
|
|
||||||
ASSERT(miss != NULL, return NULL);
|
ASSERT(miss != NULL, return NULL);
|
||||||
|
|
||||||
return miss->target;
|
return miss->target;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char SYMEXPORT *alpm_miss_get_causingpkg(const pmdepmissing_t *miss)
|
const char SYMEXPORT *alpm_miss_get_causingpkg(const pmdepmissing_t *miss)
|
||||||
{
|
{
|
||||||
/* Sanity checks */
|
|
||||||
ASSERT(miss != NULL, return NULL);
|
ASSERT(miss != NULL, return NULL);
|
||||||
|
|
||||||
return miss->causingpkg;
|
return miss->causingpkg;
|
||||||
}
|
}
|
||||||
|
|
||||||
pmdepend_t SYMEXPORT *alpm_miss_get_dep(pmdepmissing_t *miss)
|
pmdepend_t SYMEXPORT *alpm_miss_get_dep(pmdepmissing_t *miss)
|
||||||
{
|
{
|
||||||
/* Sanity checks */
|
|
||||||
ASSERT(miss != NULL, return NULL);
|
ASSERT(miss != NULL, return NULL);
|
||||||
|
|
||||||
return miss->depend;
|
return miss->depend;
|
||||||
}
|
}
|
||||||
|
|
||||||
pmdepmod_t SYMEXPORT alpm_dep_get_mod(const pmdepend_t *dep)
|
pmdepmod_t SYMEXPORT alpm_dep_get_mod(const pmdepend_t *dep)
|
||||||
{
|
{
|
||||||
/* Sanity checks */
|
|
||||||
ASSERT(dep != NULL, return -1);
|
ASSERT(dep != NULL, return -1);
|
||||||
|
|
||||||
return dep->mod;
|
return dep->mod;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char SYMEXPORT *alpm_dep_get_name(const pmdepend_t *dep)
|
const char SYMEXPORT *alpm_dep_get_name(const pmdepend_t *dep)
|
||||||
{
|
{
|
||||||
/* Sanity checks */
|
|
||||||
ASSERT(dep != NULL, return NULL);
|
ASSERT(dep != NULL, return NULL);
|
||||||
|
|
||||||
return dep->name;
|
return dep->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char SYMEXPORT *alpm_dep_get_version(const pmdepend_t *dep)
|
const char SYMEXPORT *alpm_dep_get_version(const pmdepend_t *dep)
|
||||||
{
|
{
|
||||||
/* Sanity checks */
|
|
||||||
ASSERT(dep != NULL, return NULL);
|
ASSERT(dep != NULL, return NULL);
|
||||||
|
|
||||||
return dep->version;
|
return dep->version;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -819,7 +808,6 @@ char SYMEXPORT *alpm_dep_compute_string(const pmdepend_t *dep)
|
|||||||
char *str;
|
char *str;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
/* Sanity checks */
|
|
||||||
ASSERT(dep != NULL, return NULL);
|
ASSERT(dep != NULL, return NULL);
|
||||||
|
|
||||||
if(dep->name) {
|
if(dep->name) {
|
||||||
|
@ -45,7 +45,7 @@ struct __pmdepmissing_t {
|
|||||||
void _alpm_dep_free(pmdepend_t *dep);
|
void _alpm_dep_free(pmdepend_t *dep);
|
||||||
pmdepend_t *_alpm_dep_dup(const pmdepend_t *dep);
|
pmdepend_t *_alpm_dep_dup(const pmdepend_t *dep);
|
||||||
void _alpm_depmiss_free(pmdepmissing_t *miss);
|
void _alpm_depmiss_free(pmdepmissing_t *miss);
|
||||||
alpm_list_t *_alpm_sortbydeps(alpm_list_t *targets, int reverse);
|
alpm_list_t *_alpm_sortbydeps(pmhandle_t *handle, alpm_list_t *targets, int reverse);
|
||||||
void _alpm_recursedeps(pmdb_t *db, alpm_list_t *targs, int include_explicit);
|
void _alpm_recursedeps(pmdb_t *db, alpm_list_t *targs, int include_explicit);
|
||||||
int _alpm_resolvedeps(pmhandle_t *handle, alpm_list_t *localpkgs, pmpkg_t *pkg,
|
int _alpm_resolvedeps(pmhandle_t *handle, alpm_list_t *localpkgs, pmpkg_t *pkg,
|
||||||
alpm_list_t *preferred, alpm_list_t **packages, alpm_list_t *remove,
|
alpm_list_t *preferred, alpm_list_t **packages, alpm_list_t *remove,
|
||||||
|
@ -77,11 +77,11 @@ static alpm_list_t *mount_point_list(pmhandle_t *handle)
|
|||||||
|
|
||||||
while((mnt = getmntent(fp))) {
|
while((mnt = getmntent(fp))) {
|
||||||
if(!mnt) {
|
if(!mnt) {
|
||||||
_alpm_log(PM_LOG_WARNING, _("could not get filesystem information\n"));
|
_alpm_log(handle, PM_LOG_WARNING, _("could not get filesystem information\n"));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(statvfs(mnt->mnt_dir, &fsp) != 0) {
|
if(statvfs(mnt->mnt_dir, &fsp) != 0) {
|
||||||
_alpm_log(PM_LOG_WARNING,
|
_alpm_log(handle, PM_LOG_WARNING,
|
||||||
_("could not get filesystem information for %s: %s\n"),
|
_("could not get filesystem information for %s: %s\n"),
|
||||||
mnt->mnt_dir, strerror(errno));
|
mnt->mnt_dir, strerror(errno));
|
||||||
continue;
|
continue;
|
||||||
@ -126,7 +126,7 @@ static alpm_list_t *mount_point_list(pmhandle_t *handle)
|
|||||||
mount_point_cmp);
|
mount_point_cmp);
|
||||||
for(ptr = mount_points; ptr != NULL; ptr = ptr->next) {
|
for(ptr = mount_points; ptr != NULL; ptr = ptr->next) {
|
||||||
mp = ptr->data;
|
mp = ptr->data;
|
||||||
_alpm_log(PM_LOG_DEBUG, "mountpoint: %s\n", mp->mount_dir);
|
_alpm_log(handle, PM_LOG_DEBUG, "mountpoint: %s\n", mp->mount_dir);
|
||||||
}
|
}
|
||||||
return mount_points;
|
return mount_points;
|
||||||
}
|
}
|
||||||
@ -171,7 +171,7 @@ static int calculate_removed_size(pmhandle_t *handle,
|
|||||||
|
|
||||||
mp = match_mount_point(mount_points, path);
|
mp = match_mount_point(mount_points, path);
|
||||||
if(mp == NULL) {
|
if(mp == NULL) {
|
||||||
_alpm_log(PM_LOG_WARNING,
|
_alpm_log(handle, PM_LOG_WARNING,
|
||||||
_("could not determine mount point for file %s\n"), filename);
|
_("could not determine mount point for file %s\n"), filename);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -233,7 +233,7 @@ static int calculate_installed_size(pmhandle_t *handle,
|
|||||||
|
|
||||||
mp = match_mount_point(mount_points, path);
|
mp = match_mount_point(mount_points, path);
|
||||||
if(mp == NULL) {
|
if(mp == NULL) {
|
||||||
_alpm_log(PM_LOG_WARNING,
|
_alpm_log(handle, PM_LOG_WARNING,
|
||||||
_("could not determine mount point for file %s\n"), filename);
|
_("could not determine mount point for file %s\n"), filename);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -244,7 +244,7 @@ static int calculate_installed_size(pmhandle_t *handle,
|
|||||||
mp->used |= USED_INSTALL;
|
mp->used |= USED_INSTALL;
|
||||||
|
|
||||||
if(archive_read_data_skip(archive)) {
|
if(archive_read_data_skip(archive)) {
|
||||||
_alpm_log(PM_LOG_ERROR, _("error while reading package %s: %s\n"),
|
_alpm_log(handle, PM_LOG_ERROR, _("error while reading package %s: %s\n"),
|
||||||
pkg->name, archive_error_string(archive));
|
pkg->name, archive_error_string(archive));
|
||||||
handle->pm_errno = PM_ERR_LIBARCHIVE;
|
handle->pm_errno = PM_ERR_LIBARCHIVE;
|
||||||
break;
|
break;
|
||||||
@ -269,12 +269,12 @@ int _alpm_check_diskspace(pmhandle_t *handle)
|
|||||||
numtargs = alpm_list_count(trans->add);
|
numtargs = alpm_list_count(trans->add);
|
||||||
mount_points = mount_point_list(handle);
|
mount_points = mount_point_list(handle);
|
||||||
if(mount_points == NULL) {
|
if(mount_points == NULL) {
|
||||||
_alpm_log(PM_LOG_ERROR, _("could not determine filesystem mount points\n"));
|
_alpm_log(handle, PM_LOG_ERROR, _("could not determine filesystem mount points\n"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
root_mp = match_mount_point(mount_points, handle->root);
|
root_mp = match_mount_point(mount_points, handle->root);
|
||||||
if(root_mp == NULL) {
|
if(root_mp == NULL) {
|
||||||
_alpm_log(PM_LOG_ERROR, _("could not determine root mount point %s\n"),
|
_alpm_log(handle, PM_LOG_ERROR, _("could not determine root mount point %s\n"),
|
||||||
handle->root);
|
handle->root);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -321,7 +321,7 @@ int _alpm_check_diskspace(pmhandle_t *handle)
|
|||||||
for(i = mount_points; i; i = alpm_list_next(i)) {
|
for(i = mount_points; i; i = alpm_list_next(i)) {
|
||||||
alpm_mountpoint_t *data = i->data;
|
alpm_mountpoint_t *data = i->data;
|
||||||
if(data->used && data->read_only) {
|
if(data->used && data->read_only) {
|
||||||
_alpm_log(PM_LOG_ERROR, _("Partition %s is mounted read only\n"),
|
_alpm_log(handle, PM_LOG_ERROR, _("Partition %s is mounted read only\n"),
|
||||||
data->mount_dir);
|
data->mount_dir);
|
||||||
abort = 1;
|
abort = 1;
|
||||||
} else if(data->used & USED_INSTALL) {
|
} else if(data->used & USED_INSTALL) {
|
||||||
@ -330,12 +330,12 @@ int _alpm_check_diskspace(pmhandle_t *handle)
|
|||||||
long twentymb = (20 * 1024 * 1024 / (long)data->fsp.f_bsize) + 1;
|
long twentymb = (20 * 1024 * 1024 / (long)data->fsp.f_bsize) + 1;
|
||||||
long cushion = fivepc < twentymb ? fivepc : twentymb;
|
long cushion = fivepc < twentymb ? fivepc : twentymb;
|
||||||
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "partition %s, needed %ld, cushion %ld, free %ld\n",
|
_alpm_log(handle, PM_LOG_DEBUG, "partition %s, needed %ld, cushion %ld, free %ld\n",
|
||||||
data->mount_dir, data->max_blocks_needed, cushion,
|
data->mount_dir, data->max_blocks_needed, cushion,
|
||||||
(unsigned long)data->fsp.f_bfree);
|
(unsigned long)data->fsp.f_bfree);
|
||||||
if(data->max_blocks_needed + cushion >= 0 &&
|
if(data->max_blocks_needed + cushion >= 0 &&
|
||||||
(unsigned long)(data->max_blocks_needed + cushion) > data->fsp.f_bfree) {
|
(unsigned long)(data->max_blocks_needed + cushion) > data->fsp.f_bfree) {
|
||||||
_alpm_log(PM_LOG_ERROR, _("Partition %s too full: %ld blocks needed, %ld blocks free\n"),
|
_alpm_log(handle, PM_LOG_ERROR, _("Partition %s too full: %ld blocks needed, %ld blocks free\n"),
|
||||||
data->mount_dir, data->max_blocks_needed + cushion,
|
data->mount_dir, data->max_blocks_needed + cushion,
|
||||||
(unsigned long)data->fsp.f_bfree);
|
(unsigned long)data->fsp.f_bfree);
|
||||||
abort = 1;
|
abort = 1;
|
||||||
|
@ -129,7 +129,6 @@ static int curl_gethost(const char *url, char *buffer)
|
|||||||
hostlen = strcspn(p, "/");
|
hostlen = strcspn(p, "/");
|
||||||
if(hostlen > 255) {
|
if(hostlen > 255) {
|
||||||
/* buffer overflow imminent */
|
/* buffer overflow imminent */
|
||||||
_alpm_log(PM_LOG_ERROR, _("buffer overflow detected"));
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
snprintf(buffer, hostlen + 1, "%s", p);
|
snprintf(buffer, hostlen + 1, "%s", p);
|
||||||
@ -172,7 +171,7 @@ static int curl_download_internal(pmhandle_t *handle,
|
|||||||
dlfile.initial_size = 0.0;
|
dlfile.initial_size = 0.0;
|
||||||
dlfile.filename = get_filename(url);
|
dlfile.filename = get_filename(url);
|
||||||
if(!dlfile.filename || curl_gethost(url, hostname) != 0) {
|
if(!dlfile.filename || curl_gethost(url, hostname) != 0) {
|
||||||
_alpm_log(PM_LOG_ERROR, _("url '%s' is invalid\n"), url);
|
_alpm_log(handle, PM_LOG_ERROR, _("url '%s' is invalid\n"), url);
|
||||||
RET_ERR(handle, PM_ERR_SERVER_BAD_URL, -1);
|
RET_ERR(handle, PM_ERR_SERVER_BAD_URL, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,7 +211,7 @@ static int curl_download_internal(pmhandle_t *handle,
|
|||||||
/* a previous partial download exists, resume from end of file. */
|
/* a previous partial download exists, resume from end of file. */
|
||||||
open_mode = "ab";
|
open_mode = "ab";
|
||||||
curl_easy_setopt(handle->curl, CURLOPT_RESUME_FROM, (long)st.st_size);
|
curl_easy_setopt(handle->curl, CURLOPT_RESUME_FROM, (long)st.st_size);
|
||||||
_alpm_log(PM_LOG_DEBUG, "tempfile found, attempting continuation");
|
_alpm_log(handle, PM_LOG_DEBUG, "tempfile found, attempting continuation");
|
||||||
dlfile.initial_size = (double)st.st_size;
|
dlfile.initial_size = (double)st.st_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -250,10 +249,10 @@ static int curl_download_internal(pmhandle_t *handle,
|
|||||||
} else if(handle->curlerr != CURLE_OK) {
|
} else if(handle->curlerr != CURLE_OK) {
|
||||||
if(!errors_ok) {
|
if(!errors_ok) {
|
||||||
handle->pm_errno = PM_ERR_LIBCURL;
|
handle->pm_errno = PM_ERR_LIBCURL;
|
||||||
_alpm_log(PM_LOG_ERROR, _("failed retrieving file '%s' from %s : %s\n"),
|
_alpm_log(handle, PM_LOG_ERROR, _("failed retrieving file '%s' from %s : %s\n"),
|
||||||
dlfile.filename, hostname, error_buffer);
|
dlfile.filename, hostname, error_buffer);
|
||||||
} else {
|
} else {
|
||||||
_alpm_log(PM_LOG_DEBUG, "failed retrieving file '%s' from %s : %s\n",
|
_alpm_log(handle, PM_LOG_DEBUG, "failed retrieving file '%s' from %s : %s\n",
|
||||||
dlfile.filename, hostname, error_buffer);
|
dlfile.filename, hostname, error_buffer);
|
||||||
}
|
}
|
||||||
unlink(tempfile);
|
unlink(tempfile);
|
||||||
@ -280,7 +279,7 @@ static int curl_download_internal(pmhandle_t *handle,
|
|||||||
if(!DOUBLE_EQ(remote_size, -1) && !DOUBLE_EQ(bytes_dl, -1) &&
|
if(!DOUBLE_EQ(remote_size, -1) && !DOUBLE_EQ(bytes_dl, -1) &&
|
||||||
!DOUBLE_EQ(bytes_dl, remote_size)) {
|
!DOUBLE_EQ(bytes_dl, remote_size)) {
|
||||||
handle->pm_errno = PM_ERR_RETRIEVE;
|
handle->pm_errno = PM_ERR_RETRIEVE;
|
||||||
_alpm_log(PM_LOG_ERROR, _("%s appears to be truncated: %jd/%jd bytes\n"),
|
_alpm_log(handle, PM_LOG_ERROR, _("%s appears to be truncated: %jd/%jd bytes\n"),
|
||||||
dlfile.filename, (intmax_t)bytes_dl, (intmax_t)remote_size);
|
dlfile.filename, (intmax_t)bytes_dl, (intmax_t)remote_size);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -346,10 +345,10 @@ char SYMEXPORT *alpm_fetch_pkgurl(pmhandle_t *handle, const char *url)
|
|||||||
/* download the file */
|
/* download the file */
|
||||||
ret = _alpm_download(handle, url, cachedir, 0, 1, 0);
|
ret = _alpm_download(handle, url, cachedir, 0, 1, 0);
|
||||||
if(ret == -1) {
|
if(ret == -1) {
|
||||||
_alpm_log(PM_LOG_WARNING, _("failed to download %s\n"), url);
|
_alpm_log(handle, PM_LOG_WARNING, _("failed to download %s\n"), url);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
_alpm_log(PM_LOG_DEBUG, "successfully downloaded %s\n", url);
|
_alpm_log(handle, PM_LOG_DEBUG, "successfully downloaded %s\n", url);
|
||||||
|
|
||||||
/* attempt to download the signature */
|
/* attempt to download the signature */
|
||||||
if(ret == 0 && (handle->sigverify == PM_PGP_VERIFY_ALWAYS ||
|
if(ret == 0 && (handle->sigverify == PM_PGP_VERIFY_ALWAYS ||
|
||||||
@ -364,11 +363,11 @@ char SYMEXPORT *alpm_fetch_pkgurl(pmhandle_t *handle, const char *url)
|
|||||||
|
|
||||||
ret = _alpm_download(handle, sig_url, cachedir, 1, 0, errors_ok);
|
ret = _alpm_download(handle, sig_url, cachedir, 1, 0, errors_ok);
|
||||||
if(ret == -1 && !errors_ok) {
|
if(ret == -1 && !errors_ok) {
|
||||||
_alpm_log(PM_LOG_WARNING, _("failed to download %s\n"), sig_url);
|
_alpm_log(handle, PM_LOG_WARNING, _("failed to download %s\n"), sig_url);
|
||||||
/* Warn now, but don't return NULL. We will fail later during package
|
/* Warn now, but don't return NULL. We will fail later during package
|
||||||
* load time. */
|
* load time. */
|
||||||
} else if(ret == 0) {
|
} else if(ret == 0) {
|
||||||
_alpm_log(PM_LOG_DEBUG, "successfully downloaded %s\n", sig_url);
|
_alpm_log(handle, PM_LOG_DEBUG, "successfully downloaded %s\n", sig_url);
|
||||||
}
|
}
|
||||||
FREE(sig_url);
|
FREE(sig_url);
|
||||||
}
|
}
|
||||||
|
@ -54,17 +54,14 @@ void _alpm_grp_free(pmgrp_t *grp)
|
|||||||
|
|
||||||
const char SYMEXPORT *alpm_grp_get_name(const pmgrp_t *grp)
|
const char SYMEXPORT *alpm_grp_get_name(const pmgrp_t *grp)
|
||||||
{
|
{
|
||||||
/* Sanity checks */
|
|
||||||
ASSERT(grp != NULL, return NULL);
|
ASSERT(grp != NULL, return NULL);
|
||||||
|
|
||||||
return grp->name;
|
return grp->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
alpm_list_t SYMEXPORT *alpm_grp_get_pkgs(const pmgrp_t *grp)
|
alpm_list_t SYMEXPORT *alpm_grp_get_pkgs(const pmgrp_t *grp)
|
||||||
{
|
{
|
||||||
/* Sanity checks */
|
|
||||||
ASSERT(grp != NULL, return NULL);
|
ASSERT(grp != NULL, return NULL);
|
||||||
|
|
||||||
return grp->packages;
|
return grp->packages;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vim: set ts=2 sw=2 noet: */
|
/* vim: set ts=2 sw=2 noet: */
|
||||||
|
@ -298,7 +298,7 @@ int SYMEXPORT alpm_option_add_cachedir(pmhandle_t *handle, const char *cachedir)
|
|||||||
|
|
||||||
newcachedir = canonicalize_path(cachedir);
|
newcachedir = canonicalize_path(cachedir);
|
||||||
handle->cachedirs = alpm_list_add(handle->cachedirs, newcachedir);
|
handle->cachedirs = alpm_list_add(handle->cachedirs, newcachedir);
|
||||||
_alpm_log(PM_LOG_DEBUG, "backend option 'cachedir' = %s\n", newcachedir);
|
_alpm_log(handle, PM_LOG_DEBUG, "option 'cachedir' = %s\n", newcachedir);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -362,7 +362,7 @@ int SYMEXPORT alpm_option_set_logfile(pmhandle_t *handle, const char *logfile)
|
|||||||
fclose(handle->logstream);
|
fclose(handle->logstream);
|
||||||
handle->logstream = NULL;
|
handle->logstream = NULL;
|
||||||
}
|
}
|
||||||
_alpm_log(PM_LOG_DEBUG, "option 'logfile' = %s\n", handle->logfile);
|
_alpm_log(handle, PM_LOG_DEBUG, "option 'logfile' = %s\n", handle->logfile);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -379,7 +379,7 @@ int SYMEXPORT alpm_option_set_signaturedir(pmhandle_t *handle, const char *signa
|
|||||||
}
|
}
|
||||||
handle->signaturedir = strdup(signaturedir);
|
handle->signaturedir = strdup(signaturedir);
|
||||||
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "option 'signaturedir' = %s\n", handle->signaturedir);
|
_alpm_log(handle, PM_LOG_DEBUG, "option 'signaturedir' = %s\n", handle->signaturedir);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ int SYMEXPORT alpm_logaction(pmhandle_t *handle, const char *fmt, ...)
|
|||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
void _alpm_log(pmloglevel_t flag, const char *fmt, ...)
|
void _alpm_log(pmhandle_t *handle, pmloglevel_t flag, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
alpm_cb_log logcb = alpm_option_get_logcb(handle);
|
alpm_cb_log logcb = alpm_option_get_logcb(handle);
|
||||||
|
@ -22,7 +22,8 @@
|
|||||||
|
|
||||||
#include "alpm.h"
|
#include "alpm.h"
|
||||||
|
|
||||||
void _alpm_log(pmloglevel_t flag, const char *fmt, ...) __attribute__((format(printf,2,3)));
|
void _alpm_log(pmhandle_t *handle, pmloglevel_t flag,
|
||||||
|
const char *fmt, ...) __attribute__((format(printf,3,4)));
|
||||||
|
|
||||||
#endif /* _ALPM_LOG_H */
|
#endif /* _ALPM_LOG_H */
|
||||||
|
|
||||||
|
@ -17,9 +17,10 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
#include "pkghash.h"
|
#include "pkghash.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "log.h"
|
|
||||||
|
|
||||||
/* List of primes for possible sizes of hash tables.
|
/* List of primes for possible sizes of hash tables.
|
||||||
*
|
*
|
||||||
@ -66,7 +67,7 @@ pmpkghash_t *_alpm_pkghash_create(size_t size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(hash->buckets < size) {
|
if(hash->buckets < size) {
|
||||||
_alpm_log(PM_LOG_ERROR, _("database larger than maximum size\n"));
|
errno = ERANGE;
|
||||||
free(hash);
|
free(hash);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -46,8 +46,8 @@
|
|||||||
|
|
||||||
int SYMEXPORT alpm_remove_pkg(pmhandle_t *handle, pmpkg_t *pkg)
|
int SYMEXPORT alpm_remove_pkg(pmhandle_t *handle, pmpkg_t *pkg)
|
||||||
{
|
{
|
||||||
pmtrans_t *trans;
|
|
||||||
const char *pkgname;
|
const char *pkgname;
|
||||||
|
pmtrans_t *trans;
|
||||||
|
|
||||||
/* Sanity checks */
|
/* Sanity checks */
|
||||||
ASSERT(handle != NULL, return -1);
|
ASSERT(handle != NULL, return -1);
|
||||||
@ -64,7 +64,7 @@ int SYMEXPORT alpm_remove_pkg(pmhandle_t *handle, pmpkg_t *pkg)
|
|||||||
RET_ERR(handle, PM_ERR_TRANS_DUP_TARGET, -1);
|
RET_ERR(handle, PM_ERR_TRANS_DUP_TARGET, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "adding package %s to the transaction remove list\n",
|
_alpm_log(handle, PM_LOG_DEBUG, "adding package %s to the transaction remove list\n",
|
||||||
pkgname);
|
pkgname);
|
||||||
trans->remove = alpm_list_add(trans->remove, _alpm_pkg_dup(pkg));
|
trans->remove = alpm_list_add(trans->remove, _alpm_pkg_dup(pkg));
|
||||||
return 0;
|
return 0;
|
||||||
@ -81,12 +81,12 @@ static void remove_prepare_cascade(pmhandle_t *handle, alpm_list_t *lp)
|
|||||||
pmpkg_t *info = _alpm_db_get_pkgfromcache(handle->db_local, miss->target);
|
pmpkg_t *info = _alpm_db_get_pkgfromcache(handle->db_local, miss->target);
|
||||||
if(info) {
|
if(info) {
|
||||||
if(!_alpm_pkg_find(trans->remove, alpm_pkg_get_name(info))) {
|
if(!_alpm_pkg_find(trans->remove, alpm_pkg_get_name(info))) {
|
||||||
_alpm_log(PM_LOG_DEBUG, "pulling %s in target list\n",
|
_alpm_log(handle, PM_LOG_DEBUG, "pulling %s in target list\n",
|
||||||
alpm_pkg_get_name(info));
|
alpm_pkg_get_name(info));
|
||||||
trans->remove = alpm_list_add(trans->remove, _alpm_pkg_dup(info));
|
trans->remove = alpm_list_add(trans->remove, _alpm_pkg_dup(info));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_alpm_log(PM_LOG_ERROR, _("could not find %s in database -- skipping\n"),
|
_alpm_log(handle, PM_LOG_ERROR, _("could not find %s in database -- skipping\n"),
|
||||||
miss->target);
|
miss->target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -115,7 +115,7 @@ static void remove_prepare_keep_needed(pmhandle_t *handle, alpm_list_t *lp)
|
|||||||
&vpkg);
|
&vpkg);
|
||||||
pkg = vpkg;
|
pkg = vpkg;
|
||||||
if(pkg) {
|
if(pkg) {
|
||||||
_alpm_log(PM_LOG_WARNING, _("removing %s from target list\n"),
|
_alpm_log(handle, PM_LOG_WARNING, _("removing %s from target list\n"),
|
||||||
alpm_pkg_get_name(pkg));
|
alpm_pkg_get_name(pkg));
|
||||||
_alpm_pkg_free(pkg);
|
_alpm_pkg_free(pkg);
|
||||||
}
|
}
|
||||||
@ -141,7 +141,7 @@ int _alpm_remove_prepare(pmhandle_t *handle, alpm_list_t **data)
|
|||||||
pmdb_t *db = handle->db_local;
|
pmdb_t *db = handle->db_local;
|
||||||
|
|
||||||
if((trans->flags & PM_TRANS_FLAG_RECURSE) && !(trans->flags & PM_TRANS_FLAG_CASCADE)) {
|
if((trans->flags & PM_TRANS_FLAG_RECURSE) && !(trans->flags & PM_TRANS_FLAG_CASCADE)) {
|
||||||
_alpm_log(PM_LOG_DEBUG, "finding removable dependencies\n");
|
_alpm_log(handle, PM_LOG_DEBUG, "finding removable dependencies\n");
|
||||||
_alpm_recursedeps(db, trans->remove,
|
_alpm_recursedeps(db, trans->remove,
|
||||||
trans->flags & PM_TRANS_FLAG_RECURSEALL);
|
trans->flags & PM_TRANS_FLAG_RECURSEALL);
|
||||||
}
|
}
|
||||||
@ -149,7 +149,7 @@ int _alpm_remove_prepare(pmhandle_t *handle, alpm_list_t **data)
|
|||||||
if(!(trans->flags & PM_TRANS_FLAG_NODEPS)) {
|
if(!(trans->flags & PM_TRANS_FLAG_NODEPS)) {
|
||||||
EVENT(trans, PM_TRANS_EVT_CHECKDEPS_START, NULL, NULL);
|
EVENT(trans, PM_TRANS_EVT_CHECKDEPS_START, NULL, NULL);
|
||||||
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "looking for unsatisfied dependencies\n");
|
_alpm_log(handle, PM_LOG_DEBUG, "looking for unsatisfied dependencies\n");
|
||||||
lp = alpm_checkdeps(handle, _alpm_db_get_pkgcache(db), trans->remove, NULL, 1);
|
lp = alpm_checkdeps(handle, _alpm_db_get_pkgcache(db), trans->remove, NULL, 1);
|
||||||
if(lp != NULL) {
|
if(lp != NULL) {
|
||||||
|
|
||||||
@ -172,15 +172,15 @@ int _alpm_remove_prepare(pmhandle_t *handle, alpm_list_t **data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* re-order w.r.t. dependencies */
|
/* re-order w.r.t. dependencies */
|
||||||
_alpm_log(PM_LOG_DEBUG, "sorting by dependencies\n");
|
_alpm_log(handle, PM_LOG_DEBUG, "sorting by dependencies\n");
|
||||||
lp = _alpm_sortbydeps(trans->remove, 1);
|
lp = _alpm_sortbydeps(handle, trans->remove, 1);
|
||||||
/* free the old alltargs */
|
/* free the old alltargs */
|
||||||
alpm_list_free(trans->remove);
|
alpm_list_free(trans->remove);
|
||||||
trans->remove = lp;
|
trans->remove = lp;
|
||||||
|
|
||||||
/* -Rcs == -Rc then -Rs */
|
/* -Rcs == -Rc then -Rs */
|
||||||
if((trans->flags & PM_TRANS_FLAG_CASCADE) && (trans->flags & PM_TRANS_FLAG_RECURSE)) {
|
if((trans->flags & PM_TRANS_FLAG_CASCADE) && (trans->flags & PM_TRANS_FLAG_RECURSE)) {
|
||||||
_alpm_log(PM_LOG_DEBUG, "finding removable dependencies\n");
|
_alpm_log(handle, PM_LOG_DEBUG, "finding removable dependencies\n");
|
||||||
_alpm_recursedeps(db, trans->remove, trans->flags & PM_TRANS_FLAG_RECURSEALL);
|
_alpm_recursedeps(db, trans->remove, trans->flags & PM_TRANS_FLAG_RECURSEALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,12 +191,12 @@ int _alpm_remove_prepare(pmhandle_t *handle, alpm_list_t **data)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int can_remove_file(const char *root, const char *path,
|
static int can_remove_file(pmhandle_t *handle, const char *path,
|
||||||
alpm_list_t *skip)
|
alpm_list_t *skip)
|
||||||
{
|
{
|
||||||
char file[PATH_MAX];
|
char file[PATH_MAX];
|
||||||
|
|
||||||
snprintf(file, PATH_MAX, "%s%s", root, path);
|
snprintf(file, PATH_MAX, "%s%s", handle->root, path);
|
||||||
|
|
||||||
if(alpm_list_find_str(skip, file)) {
|
if(alpm_list_find_str(skip, file)) {
|
||||||
/* return success because we will never actually remove this file */
|
/* return success because we will never actually remove this file */
|
||||||
@ -208,7 +208,7 @@ static int can_remove_file(const char *root, const char *path,
|
|||||||
if(errno != EACCES && errno != ETXTBSY && access(file, F_OK) == 0) {
|
if(errno != EACCES && errno != ETXTBSY && access(file, F_OK) == 0) {
|
||||||
/* only return failure if the file ACTUALLY exists and we can't write to
|
/* only return failure if the file ACTUALLY exists and we can't write to
|
||||||
* it - ignore "chmod -w" simple permission failures */
|
* it - ignore "chmod -w" simple permission failures */
|
||||||
_alpm_log(PM_LOG_ERROR, _("cannot remove file '%s': %s\n"),
|
_alpm_log(handle, PM_LOG_ERROR, _("cannot remove file '%s': %s\n"),
|
||||||
file, strerror(errno));
|
file, strerror(errno));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -231,7 +231,7 @@ static void unlink_file(pmhandle_t *handle, pmpkg_t *info, char *filename,
|
|||||||
* see the big comment block in db_find_fileconflicts() for an
|
* see the big comment block in db_find_fileconflicts() for an
|
||||||
* explanation. */
|
* explanation. */
|
||||||
if(alpm_list_find_str(skip_remove, filename)) {
|
if(alpm_list_find_str(skip_remove, filename)) {
|
||||||
_alpm_log(PM_LOG_DEBUG, "%s is in skip_remove, skipping removal\n",
|
_alpm_log(handle, PM_LOG_DEBUG, "%s is in skip_remove, skipping removal\n",
|
||||||
file);
|
file);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -241,23 +241,23 @@ static void unlink_file(pmhandle_t *handle, pmpkg_t *info, char *filename,
|
|||||||
* filesystem, we want to work with the linked directory instead of the
|
* filesystem, we want to work with the linked directory instead of the
|
||||||
* actual symlink */
|
* actual symlink */
|
||||||
if(lstat(file, &buf)) {
|
if(lstat(file, &buf)) {
|
||||||
_alpm_log(PM_LOG_DEBUG, "file %s does not exist\n", file);
|
_alpm_log(handle, PM_LOG_DEBUG, "file %s does not exist\n", file);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(S_ISDIR(buf.st_mode)) {
|
if(S_ISDIR(buf.st_mode)) {
|
||||||
if(rmdir(file)) {
|
if(rmdir(file)) {
|
||||||
/* this is okay, other packages are probably using it (like /usr) */
|
/* this is okay, other packages are probably using it (like /usr) */
|
||||||
_alpm_log(PM_LOG_DEBUG, "keeping directory %s\n", file);
|
_alpm_log(handle, PM_LOG_DEBUG, "keeping directory %s\n", file);
|
||||||
} else {
|
} else {
|
||||||
_alpm_log(PM_LOG_DEBUG, "removing directory %s\n", file);
|
_alpm_log(handle, PM_LOG_DEBUG, "removing directory %s\n", file);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* if the file needs backup and has been modified, back it up to .pacsave */
|
/* if the file needs backup and has been modified, back it up to .pacsave */
|
||||||
char *pkghash = _alpm_needbackup(filename, alpm_pkg_get_backup(info));
|
char *pkghash = _alpm_needbackup(filename, alpm_pkg_get_backup(info));
|
||||||
if(pkghash) {
|
if(pkghash) {
|
||||||
if(nosave) {
|
if(nosave) {
|
||||||
_alpm_log(PM_LOG_DEBUG, "transaction is set to NOSAVE, not backing up '%s'\n", file);
|
_alpm_log(handle, PM_LOG_DEBUG, "transaction is set to NOSAVE, not backing up '%s'\n", file);
|
||||||
FREE(pkghash);
|
FREE(pkghash);
|
||||||
} else {
|
} else {
|
||||||
char *filehash = alpm_compute_md5sum(file);
|
char *filehash = alpm_compute_md5sum(file);
|
||||||
@ -268,17 +268,17 @@ static void unlink_file(pmhandle_t *handle, pmpkg_t *info, char *filename,
|
|||||||
char newpath[PATH_MAX];
|
char newpath[PATH_MAX];
|
||||||
snprintf(newpath, PATH_MAX, "%s.pacsave", file);
|
snprintf(newpath, PATH_MAX, "%s.pacsave", file);
|
||||||
rename(file, newpath);
|
rename(file, newpath);
|
||||||
_alpm_log(PM_LOG_WARNING, _("%s saved as %s\n"), file, newpath);
|
_alpm_log(handle, PM_LOG_WARNING, _("%s saved as %s\n"), file, newpath);
|
||||||
alpm_logaction(handle, "warning: %s saved as %s\n", file, newpath);
|
alpm_logaction(handle, "warning: %s saved as %s\n", file, newpath);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "unlinking %s\n", file);
|
_alpm_log(handle, PM_LOG_DEBUG, "unlinking %s\n", file);
|
||||||
|
|
||||||
if(unlink(file) == -1) {
|
if(unlink(file) == -1) {
|
||||||
_alpm_log(PM_LOG_ERROR, _("cannot remove file '%s': %s\n"),
|
_alpm_log(handle, PM_LOG_ERROR, _("cannot remove file '%s': %s\n"),
|
||||||
filename, strerror(errno));
|
filename, strerror(errno));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -293,7 +293,7 @@ int _alpm_upgraderemove_package(pmhandle_t *handle,
|
|||||||
alpm_list_t *files = alpm_pkg_get_files(oldpkg);
|
alpm_list_t *files = alpm_pkg_get_files(oldpkg);
|
||||||
const char *pkgname = alpm_pkg_get_name(oldpkg);
|
const char *pkgname = alpm_pkg_get_name(oldpkg);
|
||||||
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "removing old package first (%s-%s)\n",
|
_alpm_log(handle, PM_LOG_DEBUG, "removing old package first (%s-%s)\n",
|
||||||
oldpkg->name, oldpkg->version);
|
oldpkg->name, oldpkg->version);
|
||||||
|
|
||||||
if(handle->trans->flags & PM_TRANS_FLAG_DBONLY) {
|
if(handle->trans->flags & PM_TRANS_FLAG_DBONLY) {
|
||||||
@ -315,20 +315,20 @@ int _alpm_upgraderemove_package(pmhandle_t *handle,
|
|||||||
FREE(backup);
|
FREE(backup);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
_alpm_log(PM_LOG_DEBUG, "adding %s to the skip_remove array\n", backup);
|
_alpm_log(handle, PM_LOG_DEBUG, "adding %s to the skip_remove array\n", backup);
|
||||||
skip_remove = alpm_list_add(skip_remove, backup);
|
skip_remove = alpm_list_add(skip_remove, backup);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(lp = files; lp; lp = lp->next) {
|
for(lp = files; lp; lp = lp->next) {
|
||||||
if(!can_remove_file(handle->root, lp->data, skip_remove)) {
|
if(!can_remove_file(handle, lp->data, skip_remove)) {
|
||||||
_alpm_log(PM_LOG_DEBUG, "not removing package '%s', can't remove all files\n",
|
_alpm_log(handle, PM_LOG_DEBUG, "not removing package '%s', can't remove all files\n",
|
||||||
pkgname);
|
pkgname);
|
||||||
RET_ERR(handle, PM_ERR_PKG_CANT_REMOVE, -1);
|
RET_ERR(handle, PM_ERR_PKG_CANT_REMOVE, -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
filenum = alpm_list_count(files);
|
filenum = alpm_list_count(files);
|
||||||
_alpm_log(PM_LOG_DEBUG, "removing %ld files\n", (unsigned long)filenum);
|
_alpm_log(handle, PM_LOG_DEBUG, "removing %ld files\n", (unsigned long)filenum);
|
||||||
|
|
||||||
/* iterate through the list backwards, unlinking files */
|
/* iterate through the list backwards, unlinking files */
|
||||||
newfiles = alpm_list_reverse(files);
|
newfiles = alpm_list_reverse(files);
|
||||||
@ -340,15 +340,15 @@ int _alpm_upgraderemove_package(pmhandle_t *handle,
|
|||||||
|
|
||||||
db:
|
db:
|
||||||
/* remove the package from the database */
|
/* remove the package from the database */
|
||||||
_alpm_log(PM_LOG_DEBUG, "updating database\n");
|
_alpm_log(handle, PM_LOG_DEBUG, "updating database\n");
|
||||||
_alpm_log(PM_LOG_DEBUG, "removing database entry '%s'\n", pkgname);
|
_alpm_log(handle, PM_LOG_DEBUG, "removing database entry '%s'\n", pkgname);
|
||||||
if(_alpm_local_db_remove(handle->db_local, oldpkg) == -1) {
|
if(_alpm_local_db_remove(handle->db_local, oldpkg) == -1) {
|
||||||
_alpm_log(PM_LOG_ERROR, _("could not remove database entry %s-%s\n"),
|
_alpm_log(handle, PM_LOG_ERROR, _("could not remove database entry %s-%s\n"),
|
||||||
pkgname, alpm_pkg_get_version(oldpkg));
|
pkgname, alpm_pkg_get_version(oldpkg));
|
||||||
}
|
}
|
||||||
/* remove the package from the cache */
|
/* remove the package from the cache */
|
||||||
if(_alpm_db_remove_pkgfromcache(handle->db_local, oldpkg) == -1) {
|
if(_alpm_db_remove_pkgfromcache(handle->db_local, oldpkg) == -1) {
|
||||||
_alpm_log(PM_LOG_ERROR, _("could not remove entry '%s' from cache\n"),
|
_alpm_log(handle, PM_LOG_ERROR, _("could not remove entry '%s' from cache\n"),
|
||||||
pkgname);
|
pkgname);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -381,7 +381,7 @@ int _alpm_remove_packages(pmhandle_t *handle)
|
|||||||
_alpm_db_path(handle->db_local), pkgname, alpm_pkg_get_version(info));
|
_alpm_db_path(handle->db_local), pkgname, alpm_pkg_get_version(info));
|
||||||
|
|
||||||
EVENT(trans, PM_TRANS_EVT_REMOVE_START, info, NULL);
|
EVENT(trans, PM_TRANS_EVT_REMOVE_START, info, NULL);
|
||||||
_alpm_log(PM_LOG_DEBUG, "removing package %s-%s\n",
|
_alpm_log(handle, PM_LOG_DEBUG, "removing package %s-%s\n",
|
||||||
pkgname, alpm_pkg_get_version(info));
|
pkgname, alpm_pkg_get_version(info));
|
||||||
|
|
||||||
/* run the pre-remove scriptlet if it exists */
|
/* run the pre-remove scriptlet if it exists */
|
||||||
@ -396,15 +396,15 @@ int _alpm_remove_packages(pmhandle_t *handle)
|
|||||||
size_t filenum;
|
size_t filenum;
|
||||||
|
|
||||||
for(lp = files; lp; lp = lp->next) {
|
for(lp = files; lp; lp = lp->next) {
|
||||||
if(!can_remove_file(handle->root, lp->data, NULL)) {
|
if(!can_remove_file(handle, lp->data, NULL)) {
|
||||||
_alpm_log(PM_LOG_DEBUG, "not removing package '%s', can't remove all files\n",
|
_alpm_log(handle, PM_LOG_DEBUG, "not removing package '%s', can't remove all files\n",
|
||||||
pkgname);
|
pkgname);
|
||||||
RET_ERR(handle, PM_ERR_PKG_CANT_REMOVE, -1);
|
RET_ERR(handle, PM_ERR_PKG_CANT_REMOVE, -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
filenum = alpm_list_count(files);
|
filenum = alpm_list_count(files);
|
||||||
_alpm_log(PM_LOG_DEBUG, "removing %ld files\n", (unsigned long)filenum);
|
_alpm_log(handle, PM_LOG_DEBUG, "removing %ld files\n", (unsigned long)filenum);
|
||||||
|
|
||||||
/* init progress bar */
|
/* init progress bar */
|
||||||
PROGRESS(trans, PM_TRANS_PROGRESS_REMOVE_START, info->name, 0,
|
PROGRESS(trans, PM_TRANS_PROGRESS_REMOVE_START, info->name, 0,
|
||||||
@ -436,15 +436,15 @@ int _alpm_remove_packages(pmhandle_t *handle)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* remove the package from the database */
|
/* remove the package from the database */
|
||||||
_alpm_log(PM_LOG_DEBUG, "updating database\n");
|
_alpm_log(handle, PM_LOG_DEBUG, "updating database\n");
|
||||||
_alpm_log(PM_LOG_DEBUG, "removing database entry '%s'\n", pkgname);
|
_alpm_log(handle, PM_LOG_DEBUG, "removing database entry '%s'\n", pkgname);
|
||||||
if(_alpm_local_db_remove(handle->db_local, info) == -1) {
|
if(_alpm_local_db_remove(handle->db_local, info) == -1) {
|
||||||
_alpm_log(PM_LOG_ERROR, _("could not remove database entry %s-%s\n"),
|
_alpm_log(handle, PM_LOG_ERROR, _("could not remove database entry %s-%s\n"),
|
||||||
pkgname, alpm_pkg_get_version(info));
|
pkgname, alpm_pkg_get_version(info));
|
||||||
}
|
}
|
||||||
/* remove the package from the cache */
|
/* remove the package from the cache */
|
||||||
if(_alpm_db_remove_pkgfromcache(handle->db_local, info) == -1) {
|
if(_alpm_db_remove_pkgfromcache(handle->db_local, info) == -1) {
|
||||||
_alpm_log(PM_LOG_ERROR, _("could not remove entry '%s' from cache\n"),
|
_alpm_log(handle, PM_LOG_ERROR, _("could not remove entry '%s' from cache\n"),
|
||||||
pkgname);
|
pkgname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ static int gpgme_init(pmhandle_t *handle)
|
|||||||
/* calling gpgme_check_version() returns the current version and runs
|
/* calling gpgme_check_version() returns the current version and runs
|
||||||
* some internal library setup code */
|
* some internal library setup code */
|
||||||
version = gpgme_check_version(NULL);
|
version = gpgme_check_version(NULL);
|
||||||
_alpm_log(PM_LOG_DEBUG, "GPGME version: %s\n", version);
|
_alpm_log(handle, PM_LOG_DEBUG, "GPGME version: %s\n", version);
|
||||||
gpgme_set_locale(NULL, LC_CTYPE, setlocale(LC_CTYPE, NULL));
|
gpgme_set_locale(NULL, LC_CTYPE, setlocale(LC_CTYPE, NULL));
|
||||||
#ifdef LC_MESSAGES
|
#ifdef LC_MESSAGES
|
||||||
gpgme_set_locale(NULL, LC_MESSAGES, setlocale(LC_MESSAGES, NULL));
|
gpgme_set_locale(NULL, LC_MESSAGES, setlocale(LC_MESSAGES, NULL));
|
||||||
@ -147,14 +147,14 @@ static int gpgme_init(pmhandle_t *handle)
|
|||||||
CHECK_ERR();
|
CHECK_ERR();
|
||||||
err = gpgme_get_engine_info(&enginfo);
|
err = gpgme_get_engine_info(&enginfo);
|
||||||
CHECK_ERR();
|
CHECK_ERR();
|
||||||
_alpm_log(PM_LOG_DEBUG, "GPGME engine info: file=%s, home=%s\n",
|
_alpm_log(handle, PM_LOG_DEBUG, "GPGME engine info: file=%s, home=%s\n",
|
||||||
enginfo->file_name, enginfo->home_dir);
|
enginfo->file_name, enginfo->home_dir);
|
||||||
|
|
||||||
init = 1;
|
init = 1;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
_alpm_log(PM_LOG_ERROR, _("GPGME error: %s\n"), gpgme_strerror(err));
|
_alpm_log(handle, PM_LOG_ERROR, _("GPGME error: %s\n"), gpgme_strerror(err));
|
||||||
RET_ERR(handle, PM_ERR_GPGME, 1);
|
RET_ERR(handle, PM_ERR_GPGME, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,7 +234,7 @@ int _alpm_gpgme_checksig(pmhandle_t *handle, const char *path,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "checking signature for %s\n", path);
|
_alpm_log(handle, PM_LOG_DEBUG, "checking signature for %s\n", path);
|
||||||
|
|
||||||
memset(&ctx, 0, sizeof(ctx));
|
memset(&ctx, 0, sizeof(ctx));
|
||||||
memset(&sigdata, 0, sizeof(sigdata));
|
memset(&sigdata, 0, sizeof(sigdata));
|
||||||
@ -288,7 +288,7 @@ int _alpm_gpgme_checksig(pmhandle_t *handle, const char *path,
|
|||||||
count++;
|
count++;
|
||||||
gpgsig = gpgsig->next;
|
gpgsig = gpgsig->next;
|
||||||
}
|
}
|
||||||
_alpm_log(PM_LOG_ERROR, _("Unexpected number of signatures (%d)\n"),
|
_alpm_log(handle, PM_LOG_ERROR, _("Unexpected number of signatures (%d)\n"),
|
||||||
count);
|
count);
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto error;
|
goto error;
|
||||||
@ -297,42 +297,42 @@ int _alpm_gpgme_checksig(pmhandle_t *handle, const char *path,
|
|||||||
{
|
{
|
||||||
alpm_list_t *summary_list, *summary;
|
alpm_list_t *summary_list, *summary;
|
||||||
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "fingerprint: %s\n", gpgsig->fpr);
|
_alpm_log(handle, PM_LOG_DEBUG, "fingerprint: %s\n", gpgsig->fpr);
|
||||||
summary_list = gpgme_list_sigsum(gpgsig->summary);
|
summary_list = gpgme_list_sigsum(gpgsig->summary);
|
||||||
for(summary = summary_list; summary; summary = summary->next) {
|
for(summary = summary_list; summary; summary = summary->next) {
|
||||||
_alpm_log(PM_LOG_DEBUG, "summary: %s\n", (const char *)summary->data);
|
_alpm_log(handle, PM_LOG_DEBUG, "summary: %s\n", (const char *)summary->data);
|
||||||
}
|
}
|
||||||
alpm_list_free(summary_list);
|
alpm_list_free(summary_list);
|
||||||
_alpm_log(PM_LOG_DEBUG, "status: %s\n", gpgme_strerror(gpgsig->status));
|
_alpm_log(handle, PM_LOG_DEBUG, "status: %s\n", gpgme_strerror(gpgsig->status));
|
||||||
_alpm_log(PM_LOG_DEBUG, "timestamp: %lu\n", gpgsig->timestamp);
|
_alpm_log(handle, PM_LOG_DEBUG, "timestamp: %lu\n", gpgsig->timestamp);
|
||||||
_alpm_log(PM_LOG_DEBUG, "exp_timestamp: %lu\n", gpgsig->exp_timestamp);
|
_alpm_log(handle, PM_LOG_DEBUG, "exp_timestamp: %lu\n", gpgsig->exp_timestamp);
|
||||||
_alpm_log(PM_LOG_DEBUG, "validity: %s\n",
|
_alpm_log(handle, PM_LOG_DEBUG, "validity: %s\n",
|
||||||
gpgme_string_validity(gpgsig->validity));
|
gpgme_string_validity(gpgsig->validity));
|
||||||
_alpm_log(PM_LOG_DEBUG, "validity_reason: %s\n",
|
_alpm_log(handle, PM_LOG_DEBUG, "validity_reason: %s\n",
|
||||||
gpgme_strerror(gpgsig->validity_reason));
|
gpgme_strerror(gpgsig->validity_reason));
|
||||||
_alpm_log(PM_LOG_DEBUG, "pubkey algo: %s\n",
|
_alpm_log(handle, PM_LOG_DEBUG, "pubkey algo: %s\n",
|
||||||
gpgme_pubkey_algo_name(gpgsig->pubkey_algo));
|
gpgme_pubkey_algo_name(gpgsig->pubkey_algo));
|
||||||
_alpm_log(PM_LOG_DEBUG, "hash algo: %s\n",
|
_alpm_log(handle, PM_LOG_DEBUG, "hash algo: %s\n",
|
||||||
gpgme_hash_algo_name(gpgsig->hash_algo));
|
gpgme_hash_algo_name(gpgsig->hash_algo));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(gpgsig->summary & GPGME_SIGSUM_VALID) {
|
if(gpgsig->summary & GPGME_SIGSUM_VALID) {
|
||||||
/* good signature, continue */
|
/* good signature, continue */
|
||||||
_alpm_log(PM_LOG_DEBUG, _("File %s has a valid signature.\n"),
|
_alpm_log(handle, PM_LOG_DEBUG, _("File %s has a valid signature.\n"),
|
||||||
path);
|
path);
|
||||||
} else if(gpgsig->summary & GPGME_SIGSUM_GREEN) {
|
} else if(gpgsig->summary & GPGME_SIGSUM_GREEN) {
|
||||||
/* 'green' signature, not sure what to do here */
|
/* 'green' signature, not sure what to do here */
|
||||||
_alpm_log(PM_LOG_WARNING, _("File %s has a green signature.\n"),
|
_alpm_log(handle, PM_LOG_WARNING, _("File %s has a green signature.\n"),
|
||||||
path);
|
path);
|
||||||
} else if(gpgsig->summary & GPGME_SIGSUM_KEY_MISSING) {
|
} else if(gpgsig->summary & GPGME_SIGSUM_KEY_MISSING) {
|
||||||
handle->pm_errno = PM_ERR_SIG_UNKNOWN;
|
handle->pm_errno = PM_ERR_SIG_UNKNOWN;
|
||||||
_alpm_log(PM_LOG_WARNING, _("File %s has a signature from an unknown key.\n"),
|
_alpm_log(handle, PM_LOG_WARNING, _("File %s has a signature from an unknown key.\n"),
|
||||||
path);
|
path);
|
||||||
ret = -1;
|
ret = -1;
|
||||||
} else {
|
} else {
|
||||||
/* we'll capture everything else here */
|
/* we'll capture everything else here */
|
||||||
handle->pm_errno = PM_ERR_SIG_INVALID;
|
handle->pm_errno = PM_ERR_SIG_INVALID;
|
||||||
_alpm_log(PM_LOG_ERROR, _("File %s has an invalid signature.\n"),
|
_alpm_log(handle, PM_LOG_ERROR, _("File %s has an invalid signature.\n"),
|
||||||
path);
|
path);
|
||||||
ret = 1;
|
ret = 1;
|
||||||
}
|
}
|
||||||
@ -350,7 +350,7 @@ error:
|
|||||||
FREE(sigpath);
|
FREE(sigpath);
|
||||||
FREE(decoded_sigdata);
|
FREE(decoded_sigdata);
|
||||||
if(err != GPG_ERR_NO_ERROR) {
|
if(err != GPG_ERR_NO_ERROR) {
|
||||||
_alpm_log(PM_LOG_ERROR, _("GPGME error: %s\n"), gpgme_strerror(err));
|
_alpm_log(handle, PM_LOG_ERROR, _("GPGME error: %s\n"), gpgme_strerror(err));
|
||||||
RET_ERR(handle, PM_ERR_GPGME, -1);
|
RET_ERR(handle, PM_ERR_GPGME, -1);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
@ -371,7 +371,6 @@ int _alpm_gpgme_checksig(pmhandle_t *handle, const char *path,
|
|||||||
*/
|
*/
|
||||||
pgp_verify_t _alpm_db_get_sigverify_level(pmdb_t *db)
|
pgp_verify_t _alpm_db_get_sigverify_level(pmdb_t *db)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(db->pgp_verify != PM_PGP_VERIFY_UNKNOWN) {
|
if(db->pgp_verify != PM_PGP_VERIFY_UNKNOWN) {
|
||||||
return db->pgp_verify;
|
return db->pgp_verify;
|
||||||
} else {
|
} else {
|
||||||
|
@ -65,14 +65,14 @@ pmpkg_t SYMEXPORT *alpm_sync_newversion(pmpkg_t *pkg, alpm_list_t *dbs_sync)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(spkg == NULL) {
|
if(spkg == NULL) {
|
||||||
_alpm_log(PM_LOG_DEBUG, "'%s' not found in sync db => no upgrade\n",
|
_alpm_log(pkg->handle, PM_LOG_DEBUG, "'%s' not found in sync db => no upgrade\n",
|
||||||
alpm_pkg_get_name(pkg));
|
alpm_pkg_get_name(pkg));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* compare versions and see if spkg is an upgrade */
|
/* compare versions and see if spkg is an upgrade */
|
||||||
if(_alpm_pkg_compare_versions(spkg, pkg) > 0) {
|
if(_alpm_pkg_compare_versions(spkg, pkg) > 0) {
|
||||||
_alpm_log(PM_LOG_DEBUG, "new version of '%s' found (%s => %s)\n",
|
_alpm_log(pkg->handle, PM_LOG_DEBUG, "new version of '%s' found (%s => %s)\n",
|
||||||
alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg),
|
alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg),
|
||||||
alpm_pkg_get_version(spkg));
|
alpm_pkg_get_version(spkg));
|
||||||
return spkg;
|
return spkg;
|
||||||
@ -96,12 +96,12 @@ int SYMEXPORT alpm_sync_sysupgrade(pmhandle_t *handle, int enable_downgrade)
|
|||||||
ASSERT(trans != NULL, RET_ERR(handle, PM_ERR_TRANS_NULL, -1));
|
ASSERT(trans != NULL, RET_ERR(handle, PM_ERR_TRANS_NULL, -1));
|
||||||
ASSERT(trans->state == STATE_INITIALIZED, RET_ERR(handle, PM_ERR_TRANS_NOT_INITIALIZED, -1));
|
ASSERT(trans->state == STATE_INITIALIZED, RET_ERR(handle, PM_ERR_TRANS_NOT_INITIALIZED, -1));
|
||||||
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "checking for package upgrades\n");
|
_alpm_log(handle, PM_LOG_DEBUG, "checking for package upgrades\n");
|
||||||
for(i = _alpm_db_get_pkgcache(db_local); i; i = i->next) {
|
for(i = _alpm_db_get_pkgcache(db_local); i; i = i->next) {
|
||||||
pmpkg_t *lpkg = i->data;
|
pmpkg_t *lpkg = i->data;
|
||||||
|
|
||||||
if(_alpm_pkg_find(trans->add, lpkg->name)) {
|
if(_alpm_pkg_find(trans->add, lpkg->name)) {
|
||||||
_alpm_log(PM_LOG_DEBUG, "%s is already in the target list -- skipping\n", lpkg->name);
|
_alpm_log(handle, PM_LOG_DEBUG, "%s is already in the target list -- skipping\n", lpkg->name);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,15 +115,15 @@ int SYMEXPORT alpm_sync_sysupgrade(pmhandle_t *handle, int enable_downgrade)
|
|||||||
/* 1. literal was found in sdb */
|
/* 1. literal was found in sdb */
|
||||||
int cmp = _alpm_pkg_compare_versions(spkg, lpkg);
|
int cmp = _alpm_pkg_compare_versions(spkg, lpkg);
|
||||||
if(cmp > 0) {
|
if(cmp > 0) {
|
||||||
_alpm_log(PM_LOG_DEBUG, "new version of '%s' found (%s => %s)\n",
|
_alpm_log(handle, PM_LOG_DEBUG, "new version of '%s' found (%s => %s)\n",
|
||||||
lpkg->name, lpkg->version, spkg->version);
|
lpkg->name, lpkg->version, spkg->version);
|
||||||
/* check IgnorePkg/IgnoreGroup */
|
/* check IgnorePkg/IgnoreGroup */
|
||||||
if(_alpm_pkg_should_ignore(spkg)
|
if(_alpm_pkg_should_ignore(spkg)
|
||||||
|| _alpm_pkg_should_ignore(lpkg)) {
|
|| _alpm_pkg_should_ignore(lpkg)) {
|
||||||
_alpm_log(PM_LOG_WARNING, _("%s: ignoring package upgrade (%s => %s)\n"),
|
_alpm_log(handle, PM_LOG_WARNING, _("%s: ignoring package upgrade (%s => %s)\n"),
|
||||||
lpkg->name, lpkg->version, spkg->version);
|
lpkg->name, lpkg->version, spkg->version);
|
||||||
} else {
|
} else {
|
||||||
_alpm_log(PM_LOG_DEBUG, "adding package %s-%s to the transaction targets\n",
|
_alpm_log(handle, PM_LOG_DEBUG, "adding package %s-%s to the transaction targets\n",
|
||||||
spkg->name, spkg->version);
|
spkg->name, spkg->version);
|
||||||
trans->add = alpm_list_add(trans->add, spkg);
|
trans->add = alpm_list_add(trans->add, spkg);
|
||||||
}
|
}
|
||||||
@ -132,15 +132,15 @@ int SYMEXPORT alpm_sync_sysupgrade(pmhandle_t *handle, int enable_downgrade)
|
|||||||
/* check IgnorePkg/IgnoreGroup */
|
/* check IgnorePkg/IgnoreGroup */
|
||||||
if(_alpm_pkg_should_ignore(spkg)
|
if(_alpm_pkg_should_ignore(spkg)
|
||||||
|| _alpm_pkg_should_ignore(lpkg)) {
|
|| _alpm_pkg_should_ignore(lpkg)) {
|
||||||
_alpm_log(PM_LOG_WARNING, _("%s: ignoring package downgrade (%s => %s)\n"),
|
_alpm_log(handle, PM_LOG_WARNING, _("%s: ignoring package downgrade (%s => %s)\n"),
|
||||||
lpkg->name, lpkg->version, spkg->version);
|
lpkg->name, lpkg->version, spkg->version);
|
||||||
} else {
|
} else {
|
||||||
_alpm_log(PM_LOG_WARNING, _("%s: downgrading from version %s to version %s\n"),
|
_alpm_log(handle, PM_LOG_WARNING, _("%s: downgrading from version %s to version %s\n"),
|
||||||
lpkg->name, lpkg->version, spkg->version);
|
lpkg->name, lpkg->version, spkg->version);
|
||||||
trans->add = alpm_list_add(trans->add, spkg);
|
trans->add = alpm_list_add(trans->add, spkg);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_alpm_log(PM_LOG_WARNING, _("%s: local (%s) is newer than %s (%s)\n"),
|
_alpm_log(handle, PM_LOG_WARNING, _("%s: local (%s) is newer than %s (%s)\n"),
|
||||||
lpkg->name, lpkg->version, sdb->treename, spkg->version);
|
lpkg->name, lpkg->version, sdb->treename, spkg->version);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -156,7 +156,7 @@ int SYMEXPORT alpm_sync_sysupgrade(pmhandle_t *handle, int enable_downgrade)
|
|||||||
/* check IgnorePkg/IgnoreGroup */
|
/* check IgnorePkg/IgnoreGroup */
|
||||||
if(_alpm_pkg_should_ignore(spkg)
|
if(_alpm_pkg_should_ignore(spkg)
|
||||||
|| _alpm_pkg_should_ignore(lpkg)) {
|
|| _alpm_pkg_should_ignore(lpkg)) {
|
||||||
_alpm_log(PM_LOG_WARNING, _("ignoring package replacement (%s-%s => %s-%s)\n"),
|
_alpm_log(handle, PM_LOG_WARNING, _("ignoring package replacement (%s-%s => %s-%s)\n"),
|
||||||
lpkg->name, lpkg->version, spkg->name, spkg->version);
|
lpkg->name, lpkg->version, spkg->name, spkg->version);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -173,11 +173,11 @@ int SYMEXPORT alpm_sync_sysupgrade(pmhandle_t *handle, int enable_downgrade)
|
|||||||
if(tpkg) {
|
if(tpkg) {
|
||||||
/* sanity check, multiple repos can contain spkg->name */
|
/* sanity check, multiple repos can contain spkg->name */
|
||||||
if(tpkg->origin_data.db != sdb) {
|
if(tpkg->origin_data.db != sdb) {
|
||||||
_alpm_log(PM_LOG_WARNING, _("cannot replace %s by %s\n"),
|
_alpm_log(handle, PM_LOG_WARNING, _("cannot replace %s by %s\n"),
|
||||||
lpkg->name, spkg->name);
|
lpkg->name, spkg->name);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
_alpm_log(PM_LOG_DEBUG, "appending %s to the removes list of %s\n",
|
_alpm_log(handle, PM_LOG_DEBUG, "appending %s to the removes list of %s\n",
|
||||||
lpkg->name, tpkg->name);
|
lpkg->name, tpkg->name);
|
||||||
tpkg->removes = alpm_list_add(tpkg->removes, lpkg);
|
tpkg->removes = alpm_list_add(tpkg->removes, lpkg);
|
||||||
/* check the to-be-replaced package's reason field */
|
/* check the to-be-replaced package's reason field */
|
||||||
@ -189,7 +189,7 @@ int SYMEXPORT alpm_sync_sysupgrade(pmhandle_t *handle, int enable_downgrade)
|
|||||||
/* copy over reason */
|
/* copy over reason */
|
||||||
spkg->reason = alpm_pkg_get_reason(lpkg);
|
spkg->reason = alpm_pkg_get_reason(lpkg);
|
||||||
spkg->removes = alpm_list_add(NULL, lpkg);
|
spkg->removes = alpm_list_add(NULL, lpkg);
|
||||||
_alpm_log(PM_LOG_DEBUG, "adding package %s-%s to the transaction targets\n",
|
_alpm_log(handle, PM_LOG_DEBUG, "adding package %s-%s to the transaction targets\n",
|
||||||
spkg->name, spkg->version);
|
spkg->name, spkg->version);
|
||||||
trans->add = alpm_list_add(trans->add, spkg);
|
trans->add = alpm_list_add(trans->add, spkg);
|
||||||
}
|
}
|
||||||
@ -256,6 +256,7 @@ static int compute_download_size(pmpkg_t *newpkg)
|
|||||||
const char *fname;
|
const char *fname;
|
||||||
char *fpath;
|
char *fpath;
|
||||||
off_t size = 0;
|
off_t size = 0;
|
||||||
|
pmhandle_t *handle = newpkg->handle;
|
||||||
|
|
||||||
if(newpkg->origin != PKG_FROM_SYNCDB) {
|
if(newpkg->origin != PKG_FROM_SYNCDB) {
|
||||||
newpkg->infolevel |= INFRQ_DSIZE;
|
newpkg->infolevel |= INFRQ_DSIZE;
|
||||||
@ -264,13 +265,13 @@ static int compute_download_size(pmpkg_t *newpkg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
fname = alpm_pkg_get_filename(newpkg);
|
fname = alpm_pkg_get_filename(newpkg);
|
||||||
ASSERT(fname != NULL, RET_ERR(newpkg->handle, PM_ERR_PKG_INVALID_NAME, -1));
|
ASSERT(fname != NULL, RET_ERR(handle, PM_ERR_PKG_INVALID_NAME, -1));
|
||||||
fpath = _alpm_filecache_find(newpkg->handle, fname);
|
fpath = _alpm_filecache_find(handle, fname);
|
||||||
|
|
||||||
if(fpath) {
|
if(fpath) {
|
||||||
FREE(fpath);
|
FREE(fpath);
|
||||||
size = 0;
|
size = 0;
|
||||||
} else if(newpkg->handle->usedelta) {
|
} else if(handle->usedelta) {
|
||||||
off_t dltsize;
|
off_t dltsize;
|
||||||
off_t pkgsize = alpm_pkg_get_size(newpkg);
|
off_t pkgsize = alpm_pkg_get_size(newpkg);
|
||||||
|
|
||||||
@ -280,10 +281,10 @@ static int compute_download_size(pmpkg_t *newpkg)
|
|||||||
&newpkg->delta_path);
|
&newpkg->delta_path);
|
||||||
|
|
||||||
if(newpkg->delta_path && (dltsize < pkgsize * MAX_DELTA_RATIO)) {
|
if(newpkg->delta_path && (dltsize < pkgsize * MAX_DELTA_RATIO)) {
|
||||||
_alpm_log(PM_LOG_DEBUG, "using delta size\n");
|
_alpm_log(handle, PM_LOG_DEBUG, "using delta size\n");
|
||||||
size = dltsize;
|
size = dltsize;
|
||||||
} else {
|
} else {
|
||||||
_alpm_log(PM_LOG_DEBUG, "using package size\n");
|
_alpm_log(handle, PM_LOG_DEBUG, "using package size\n");
|
||||||
size = alpm_pkg_get_size(newpkg);
|
size = alpm_pkg_get_size(newpkg);
|
||||||
alpm_list_free(newpkg->delta_path);
|
alpm_list_free(newpkg->delta_path);
|
||||||
newpkg->delta_path = NULL;
|
newpkg->delta_path = NULL;
|
||||||
@ -292,7 +293,7 @@ static int compute_download_size(pmpkg_t *newpkg)
|
|||||||
size = alpm_pkg_get_size(newpkg);
|
size = alpm_pkg_get_size(newpkg);
|
||||||
}
|
}
|
||||||
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "setting download size %jd for pkg %s\n",
|
_alpm_log(handle, PM_LOG_DEBUG, "setting download size %jd for pkg %s\n",
|
||||||
(intmax_t)size, alpm_pkg_get_name(newpkg));
|
(intmax_t)size, alpm_pkg_get_name(newpkg));
|
||||||
|
|
||||||
newpkg->infolevel |= INFRQ_DSIZE;
|
newpkg->infolevel |= INFRQ_DSIZE;
|
||||||
@ -319,7 +320,7 @@ int _alpm_sync_prepare(pmhandle_t *handle, alpm_list_t **data)
|
|||||||
/* Build up list by repeatedly resolving each transaction package */
|
/* Build up list by repeatedly resolving each transaction package */
|
||||||
/* Resolve targets dependencies */
|
/* Resolve targets dependencies */
|
||||||
EVENT(trans, PM_TRANS_EVT_RESOLVEDEPS_START, NULL, NULL);
|
EVENT(trans, PM_TRANS_EVT_RESOLVEDEPS_START, NULL, NULL);
|
||||||
_alpm_log(PM_LOG_DEBUG, "resolving target's dependencies\n");
|
_alpm_log(handle, PM_LOG_DEBUG, "resolving target's dependencies\n");
|
||||||
|
|
||||||
/* build remove list for resolvedeps */
|
/* build remove list for resolvedeps */
|
||||||
for(i = trans->add; i; i = i->next) {
|
for(i = trans->add; i; i = i->next) {
|
||||||
@ -386,7 +387,7 @@ int _alpm_sync_prepare(pmhandle_t *handle, alpm_list_t **data)
|
|||||||
|
|
||||||
/* re-order w.r.t. dependencies */
|
/* re-order w.r.t. dependencies */
|
||||||
alpm_list_free(trans->add);
|
alpm_list_free(trans->add);
|
||||||
trans->add = _alpm_sortbydeps(resolved, 0);
|
trans->add = _alpm_sortbydeps(handle, resolved, 0);
|
||||||
alpm_list_free(resolved);
|
alpm_list_free(resolved);
|
||||||
|
|
||||||
EVENT(trans, PM_TRANS_EVT_RESOLVEDEPS_DONE, NULL, NULL);
|
EVENT(trans, PM_TRANS_EVT_RESOLVEDEPS_DONE, NULL, NULL);
|
||||||
@ -396,10 +397,10 @@ int _alpm_sync_prepare(pmhandle_t *handle, alpm_list_t **data)
|
|||||||
/* check for inter-conflicts and whatnot */
|
/* check for inter-conflicts and whatnot */
|
||||||
EVENT(trans, PM_TRANS_EVT_INTERCONFLICTS_START, NULL, NULL);
|
EVENT(trans, PM_TRANS_EVT_INTERCONFLICTS_START, NULL, NULL);
|
||||||
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "looking for conflicts\n");
|
_alpm_log(handle, PM_LOG_DEBUG, "looking for conflicts\n");
|
||||||
|
|
||||||
/* 1. check for conflicts in the target list */
|
/* 1. check for conflicts in the target list */
|
||||||
_alpm_log(PM_LOG_DEBUG, "check targets vs targets\n");
|
_alpm_log(handle, PM_LOG_DEBUG, "check targets vs targets\n");
|
||||||
deps = _alpm_innerconflicts(handle, trans->add);
|
deps = _alpm_innerconflicts(handle, trans->add);
|
||||||
|
|
||||||
for(i = deps; i; i = i->next) {
|
for(i = deps; i; i = i->next) {
|
||||||
@ -413,7 +414,7 @@ int _alpm_sync_prepare(pmhandle_t *handle, alpm_list_t **data)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "conflicting packages in the sync list: '%s' <-> '%s'\n",
|
_alpm_log(handle, PM_LOG_DEBUG, "conflicting packages in the sync list: '%s' <-> '%s'\n",
|
||||||
conflict->package1, conflict->package2);
|
conflict->package1, conflict->package2);
|
||||||
|
|
||||||
/* if sync1 provides sync2, we remove sync2 from the targets, and vice versa */
|
/* if sync1 provides sync2, we remove sync2 from the targets, and vice versa */
|
||||||
@ -426,7 +427,7 @@ int _alpm_sync_prepare(pmhandle_t *handle, alpm_list_t **data)
|
|||||||
rsync = sync1;
|
rsync = sync1;
|
||||||
sync = sync2;
|
sync = sync2;
|
||||||
} else {
|
} else {
|
||||||
_alpm_log(PM_LOG_ERROR, _("unresolvable package conflicts detected\n"));
|
_alpm_log(handle, PM_LOG_ERROR, _("unresolvable package conflicts detected\n"));
|
||||||
handle->pm_errno = PM_ERR_CONFLICTING_DEPS;
|
handle->pm_errno = PM_ERR_CONFLICTING_DEPS;
|
||||||
ret = -1;
|
ret = -1;
|
||||||
if(data) {
|
if(data) {
|
||||||
@ -445,7 +446,7 @@ int _alpm_sync_prepare(pmhandle_t *handle, alpm_list_t **data)
|
|||||||
_alpm_dep_free(dep2);
|
_alpm_dep_free(dep2);
|
||||||
|
|
||||||
/* Prints warning */
|
/* Prints warning */
|
||||||
_alpm_log(PM_LOG_WARNING,
|
_alpm_log(handle, PM_LOG_WARNING,
|
||||||
_("removing '%s' from target list because it conflicts with '%s'\n"),
|
_("removing '%s' from target list because it conflicts with '%s'\n"),
|
||||||
rsync->name, sync->name);
|
rsync->name, sync->name);
|
||||||
trans->add = alpm_list_remove(trans->add, rsync, _alpm_pkg_cmp, NULL);
|
trans->add = alpm_list_remove(trans->add, rsync, _alpm_pkg_cmp, NULL);
|
||||||
@ -458,7 +459,7 @@ int _alpm_sync_prepare(pmhandle_t *handle, alpm_list_t **data)
|
|||||||
deps = NULL;
|
deps = NULL;
|
||||||
|
|
||||||
/* 2. we check for target vs db conflicts (and resolve)*/
|
/* 2. we check for target vs db conflicts (and resolve)*/
|
||||||
_alpm_log(PM_LOG_DEBUG, "check targets vs db and db vs targets\n");
|
_alpm_log(handle, PM_LOG_DEBUG, "check targets vs db and db vs targets\n");
|
||||||
deps = _alpm_outerconflicts(handle->db_local, trans->add);
|
deps = _alpm_outerconflicts(handle->db_local, trans->add);
|
||||||
|
|
||||||
for(i = deps; i; i = i->next) {
|
for(i = deps; i; i = i->next) {
|
||||||
@ -477,7 +478,7 @@ int _alpm_sync_prepare(pmhandle_t *handle, alpm_list_t **data)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "package '%s' conflicts with '%s'\n",
|
_alpm_log(handle, PM_LOG_DEBUG, "package '%s' conflicts with '%s'\n",
|
||||||
conflict->package1, conflict->package2);
|
conflict->package1, conflict->package2);
|
||||||
|
|
||||||
pmpkg_t *sync = _alpm_pkg_find(trans->add, conflict->package1);
|
pmpkg_t *sync = _alpm_pkg_find(trans->add, conflict->package1);
|
||||||
@ -487,10 +488,10 @@ int _alpm_sync_prepare(pmhandle_t *handle, alpm_list_t **data)
|
|||||||
conflict->package2, conflict->reason, &doremove);
|
conflict->package2, conflict->reason, &doremove);
|
||||||
if(doremove) {
|
if(doremove) {
|
||||||
/* append to the removes list */
|
/* append to the removes list */
|
||||||
_alpm_log(PM_LOG_DEBUG, "electing '%s' for removal\n", conflict->package2);
|
_alpm_log(handle, PM_LOG_DEBUG, "electing '%s' for removal\n", conflict->package2);
|
||||||
sync->removes = alpm_list_add(sync->removes, local);
|
sync->removes = alpm_list_add(sync->removes, local);
|
||||||
} else { /* abort */
|
} else { /* abort */
|
||||||
_alpm_log(PM_LOG_ERROR, _("unresolvable package conflicts detected\n"));
|
_alpm_log(handle, PM_LOG_ERROR, _("unresolvable package conflicts detected\n"));
|
||||||
handle->pm_errno = PM_ERR_CONFLICTING_DEPS;
|
handle->pm_errno = PM_ERR_CONFLICTING_DEPS;
|
||||||
ret = -1;
|
ret = -1;
|
||||||
if(data) {
|
if(data) {
|
||||||
@ -515,14 +516,14 @@ int _alpm_sync_prepare(pmhandle_t *handle, alpm_list_t **data)
|
|||||||
for(j = spkg->removes; j; j = j->next) {
|
for(j = spkg->removes; j; j = j->next) {
|
||||||
pmpkg_t *rpkg = j->data;
|
pmpkg_t *rpkg = j->data;
|
||||||
if(!_alpm_pkg_find(trans->remove, rpkg->name)) {
|
if(!_alpm_pkg_find(trans->remove, rpkg->name)) {
|
||||||
_alpm_log(PM_LOG_DEBUG, "adding '%s' to remove list\n", rpkg->name);
|
_alpm_log(handle, PM_LOG_DEBUG, "adding '%s' to remove list\n", rpkg->name);
|
||||||
trans->remove = alpm_list_add(trans->remove, _alpm_pkg_dup(rpkg));
|
trans->remove = alpm_list_add(trans->remove, _alpm_pkg_dup(rpkg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!(trans->flags & PM_TRANS_FLAG_NODEPS)) {
|
if(!(trans->flags & PM_TRANS_FLAG_NODEPS)) {
|
||||||
_alpm_log(PM_LOG_DEBUG, "checking dependencies\n");
|
_alpm_log(handle, PM_LOG_DEBUG, "checking dependencies\n");
|
||||||
deps = alpm_checkdeps(handle, _alpm_db_get_pkgcache(handle->db_local),
|
deps = alpm_checkdeps(handle, _alpm_db_get_pkgcache(handle->db_local),
|
||||||
trans->remove, trans->add, 1);
|
trans->remove, trans->add, 1);
|
||||||
if(deps) {
|
if(deps) {
|
||||||
@ -625,7 +626,7 @@ static int apply_deltas(pmhandle_t *handle)
|
|||||||
snprintf(command, PATH_MAX, "xdelta3 -d -q -s %s %s %s", from, delta, to);
|
snprintf(command, PATH_MAX, "xdelta3 -d -q -s %s %s %s", from, delta, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "command: %s\n", command);
|
_alpm_log(handle, PM_LOG_DEBUG, "command: %s\n", command);
|
||||||
|
|
||||||
EVENT(trans, PM_TRANS_EVT_DELTA_PATCH_START, d->to, d->delta);
|
EVENT(trans, PM_TRANS_EVT_DELTA_PATCH_START, d->to, d->delta);
|
||||||
|
|
||||||
@ -810,7 +811,7 @@ static int download_files(pmhandle_t *handle, alpm_list_t **deltas)
|
|||||||
|
|
||||||
FREELIST(files);
|
FREELIST(files);
|
||||||
if(errors) {
|
if(errors) {
|
||||||
_alpm_log(PM_LOG_WARNING, _("failed to retrieve some files from %s\n"),
|
_alpm_log(handle, PM_LOG_WARNING, _("failed to retrieve some files from %s\n"),
|
||||||
current->treename);
|
current->treename);
|
||||||
if(handle->pm_errno == 0) {
|
if(handle->pm_errno == 0) {
|
||||||
handle->pm_errno = PM_ERR_RETRIEVE;
|
handle->pm_errno = PM_ERR_RETRIEVE;
|
||||||
@ -878,7 +879,9 @@ int _alpm_sync_commit(pmhandle_t *handle, alpm_list_t **data)
|
|||||||
|
|
||||||
/* load the package file and replace pkgcache entry with it in the target list */
|
/* load the package file and replace pkgcache entry with it in the target list */
|
||||||
/* TODO: alpm_pkg_get_db() will not work on this target anymore */
|
/* TODO: alpm_pkg_get_db() will not work on this target anymore */
|
||||||
_alpm_log(PM_LOG_DEBUG, "replacing pkgcache entry with package file for target %s\n", spkg->name);
|
_alpm_log(handle, PM_LOG_DEBUG,
|
||||||
|
"replacing pkgcache entry with package file for target %s\n",
|
||||||
|
spkg->name);
|
||||||
pmpkg_t *pkgfile =_alpm_pkg_load_internal(handle, filepath, 1, spkg->md5sum,
|
pmpkg_t *pkgfile =_alpm_pkg_load_internal(handle, filepath, 1, spkg->md5sum,
|
||||||
spkg->base64_sig, check_sig);
|
spkg->base64_sig, check_sig);
|
||||||
if(!pkgfile) {
|
if(!pkgfile) {
|
||||||
@ -914,7 +917,7 @@ int _alpm_sync_commit(pmhandle_t *handle, alpm_list_t **data)
|
|||||||
if(!(trans->flags & PM_TRANS_FLAG_FORCE)) {
|
if(!(trans->flags & PM_TRANS_FLAG_FORCE)) {
|
||||||
EVENT(trans, PM_TRANS_EVT_FILECONFLICTS_START, NULL, NULL);
|
EVENT(trans, PM_TRANS_EVT_FILECONFLICTS_START, NULL, NULL);
|
||||||
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "looking for file conflicts\n");
|
_alpm_log(handle, PM_LOG_DEBUG, "looking for file conflicts\n");
|
||||||
alpm_list_t *conflict = _alpm_db_find_fileconflicts(handle,
|
alpm_list_t *conflict = _alpm_db_find_fileconflicts(handle,
|
||||||
trans->add, trans->remove);
|
trans->add, trans->remove);
|
||||||
if(conflict) {
|
if(conflict) {
|
||||||
@ -934,9 +937,9 @@ int _alpm_sync_commit(pmhandle_t *handle, alpm_list_t **data)
|
|||||||
if(handle->checkspace) {
|
if(handle->checkspace) {
|
||||||
EVENT(trans, PM_TRANS_EVT_DISKSPACE_START, NULL, NULL);
|
EVENT(trans, PM_TRANS_EVT_DISKSPACE_START, NULL, NULL);
|
||||||
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "checking available disk space\n");
|
_alpm_log(handle, PM_LOG_DEBUG, "checking available disk space\n");
|
||||||
if(_alpm_check_diskspace(handle) == -1) {
|
if(_alpm_check_diskspace(handle) == -1) {
|
||||||
_alpm_log(PM_LOG_ERROR, "%s\n", _("not enough free disk space"));
|
_alpm_log(handle, PM_LOG_ERROR, "%s\n", _("not enough free disk space"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -945,18 +948,18 @@ int _alpm_sync_commit(pmhandle_t *handle, alpm_list_t **data)
|
|||||||
|
|
||||||
/* remove conflicting and to-be-replaced packages */
|
/* remove conflicting and to-be-replaced packages */
|
||||||
if(replaces) {
|
if(replaces) {
|
||||||
_alpm_log(PM_LOG_DEBUG, "removing conflicting and to-be-replaced packages\n");
|
_alpm_log(handle, PM_LOG_DEBUG, "removing conflicting and to-be-replaced packages\n");
|
||||||
/* we want the frontend to be aware of commit details */
|
/* we want the frontend to be aware of commit details */
|
||||||
if(_alpm_remove_packages(handle) == -1) {
|
if(_alpm_remove_packages(handle) == -1) {
|
||||||
_alpm_log(PM_LOG_ERROR, _("could not commit removal transaction\n"));
|
_alpm_log(handle, PM_LOG_ERROR, _("could not commit removal transaction\n"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* install targets */
|
/* install targets */
|
||||||
_alpm_log(PM_LOG_DEBUG, "installing packages\n");
|
_alpm_log(handle, PM_LOG_DEBUG, "installing packages\n");
|
||||||
if(_alpm_upgrade_packages(handle) == -1) {
|
if(_alpm_upgrade_packages(handle) == -1) {
|
||||||
_alpm_log(PM_LOG_ERROR, _("could not commit transaction\n"));
|
_alpm_log(handle, PM_LOG_ERROR, _("could not commit transaction\n"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ int SYMEXPORT alpm_trans_init(pmhandle_t *handle, pmtransflag_t flags,
|
|||||||
/* check database version */
|
/* check database version */
|
||||||
db_version = _alpm_db_version(handle->db_local);
|
db_version = _alpm_db_version(handle->db_local);
|
||||||
if(db_version < required_db_version) {
|
if(db_version < required_db_version) {
|
||||||
_alpm_log(PM_LOG_ERROR,
|
_alpm_log(handle, PM_LOG_ERROR,
|
||||||
_("%s database version is too old\n"), handle->db_local->treename);
|
_("%s database version is too old\n"), handle->db_local->treename);
|
||||||
remove_lock(handle);
|
remove_lock(handle);
|
||||||
_alpm_trans_free(trans);
|
_alpm_trans_free(trans);
|
||||||
@ -283,7 +283,7 @@ int SYMEXPORT alpm_trans_release(pmhandle_t *handle)
|
|||||||
/* unlock db */
|
/* unlock db */
|
||||||
if(!nolock_flag) {
|
if(!nolock_flag) {
|
||||||
if(remove_lock(handle)) {
|
if(remove_lock(handle)) {
|
||||||
_alpm_log(PM_LOG_WARNING, _("could not remove lock file %s\n"),
|
_alpm_log(handle, PM_LOG_WARNING, _("could not remove lock file %s\n"),
|
||||||
alpm_option_get_lockfile(handle));
|
alpm_option_get_lockfile(handle));
|
||||||
alpm_logaction(handle, "warning: could not remove lock file %s\n",
|
alpm_logaction(handle, "warning: could not remove lock file %s\n",
|
||||||
alpm_option_get_lockfile(handle));
|
alpm_option_get_lockfile(handle));
|
||||||
@ -350,7 +350,7 @@ int _alpm_runscriptlet(pmhandle_t *handle, const char *installfn,
|
|||||||
|
|
||||||
if(access(installfn, R_OK)) {
|
if(access(installfn, R_OK)) {
|
||||||
/* not found */
|
/* not found */
|
||||||
_alpm_log(PM_LOG_DEBUG, "scriptlet '%s' not found\n", installfn);
|
_alpm_log(handle, PM_LOG_DEBUG, "scriptlet '%s' not found\n", installfn);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -361,7 +361,7 @@ int _alpm_runscriptlet(pmhandle_t *handle, const char *installfn,
|
|||||||
}
|
}
|
||||||
snprintf(tmpdir, PATH_MAX, "%stmp/alpm_XXXXXX", handle->root);
|
snprintf(tmpdir, PATH_MAX, "%stmp/alpm_XXXXXX", handle->root);
|
||||||
if(mkdtemp(tmpdir) == NULL) {
|
if(mkdtemp(tmpdir) == NULL) {
|
||||||
_alpm_log(PM_LOG_ERROR, _("could not create temp directory\n"));
|
_alpm_log(handle, PM_LOG_ERROR, _("could not create temp directory\n"));
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
clean_tmpdir = 1;
|
clean_tmpdir = 1;
|
||||||
@ -375,7 +375,7 @@ int _alpm_runscriptlet(pmhandle_t *handle, const char *installfn,
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(_alpm_copyfile(installfn, scriptfn)) {
|
if(_alpm_copyfile(installfn, scriptfn)) {
|
||||||
_alpm_log(PM_LOG_ERROR, _("could not copy tempfile to %s (%s)\n"), scriptfn, strerror(errno));
|
_alpm_log(handle, PM_LOG_ERROR, _("could not copy tempfile to %s (%s)\n"), scriptfn, strerror(errno));
|
||||||
retval = 1;
|
retval = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -399,13 +399,13 @@ int _alpm_runscriptlet(pmhandle_t *handle, const char *installfn,
|
|||||||
scriptpath, script, ver);
|
scriptpath, script, ver);
|
||||||
}
|
}
|
||||||
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "executing \"%s\"\n", cmdline);
|
_alpm_log(handle, PM_LOG_DEBUG, "executing \"%s\"\n", cmdline);
|
||||||
|
|
||||||
retval = _alpm_run_chroot(handle, "/bin/sh", argv);
|
retval = _alpm_run_chroot(handle, "/bin/sh", argv);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if(clean_tmpdir && _alpm_rmrf(tmpdir)) {
|
if(clean_tmpdir && _alpm_rmrf(tmpdir)) {
|
||||||
_alpm_log(PM_LOG_WARNING, _("could not remove tmpdir %s\n"), tmpdir);
|
_alpm_log(handle, PM_LOG_WARNING, _("could not remove tmpdir %s\n"), tmpdir);
|
||||||
}
|
}
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
|
@ -262,7 +262,7 @@ int _alpm_unpack(pmhandle_t *handle, const char *archive, const char *prefix,
|
|||||||
|
|
||||||
if(archive_read_open_filename(_archive, archive,
|
if(archive_read_open_filename(_archive, archive,
|
||||||
ARCHIVE_DEFAULT_BYTES_PER_BLOCK) != ARCHIVE_OK) {
|
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));
|
archive_error_string(_archive));
|
||||||
RET_ERR(handle, PM_ERR_PKG_OPEN, 1);
|
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 */
|
/* save the cwd so we can restore it later */
|
||||||
if(getcwd(cwd, PATH_MAX) == NULL) {
|
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 {
|
} else {
|
||||||
restore_cwd = 1;
|
restore_cwd = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* just in case our cwd was removed in the upgrade operation */
|
/* just in case our cwd was removed in the upgrade operation */
|
||||||
if(chdir(prefix) != 0) {
|
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));
|
prefix, strerror(errno));
|
||||||
ret = 1;
|
ret = 1;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -313,7 +313,7 @@ int _alpm_unpack(pmhandle_t *handle, const char *archive, const char *prefix,
|
|||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} 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);
|
int readret = archive_read_extract(_archive, entry, 0);
|
||||||
if(readret == ARCHIVE_WARN) {
|
if(readret == ARCHIVE_WARN) {
|
||||||
/* operation succeeded but a non-critical error was encountered */
|
/* 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));
|
entryname, archive_error_string(_archive));
|
||||||
} else if(readret != ARCHIVE_OK) {
|
} 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));
|
entryname, archive_error_string(_archive));
|
||||||
ret = 1;
|
ret = 1;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -339,7 +339,7 @@ cleanup:
|
|||||||
umask(oldmask);
|
umask(oldmask);
|
||||||
archive_read_finish(_archive);
|
archive_read_finish(_archive);
|
||||||
if(restore_cwd && chdir(cwd) != 0) {
|
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));
|
cwd, strerror(errno));
|
||||||
}
|
}
|
||||||
return ret;
|
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 */
|
/* save the cwd so we can restore it later */
|
||||||
if(getcwd(cwd, PATH_MAX) == NULL) {
|
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 {
|
} else {
|
||||||
restore_cwd = 1;
|
restore_cwd = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* just in case our cwd was removed in the upgrade operation */
|
/* just in case our cwd was removed in the upgrade operation */
|
||||||
if(chdir(handle->root) != 0) {
|
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));
|
handle->root, strerror(errno));
|
||||||
goto cleanup;
|
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);
|
path, handle->root);
|
||||||
|
|
||||||
/* Flush open fds before fork() to avoid cloning buffers */
|
/* Flush open fds before fork() to avoid cloning buffers */
|
||||||
fflush(NULL);
|
fflush(NULL);
|
||||||
|
|
||||||
if(pipe(pipefd) == -1) {
|
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;
|
retval = 1;
|
||||||
goto cleanup;
|
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 */
|
/* fork- parent and child each have seperate code blocks below */
|
||||||
pid = fork();
|
pid = fork();
|
||||||
if(pid == -1) {
|
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;
|
retval = 1;
|
||||||
goto cleanup;
|
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) {
|
while(waitpid(pid, &status, 0) == -1) {
|
||||||
if(errno != EINTR) {
|
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;
|
retval = 1;
|
||||||
goto cleanup;
|
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 */
|
/* report error from above after the child has exited */
|
||||||
if(retval != 0) {
|
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;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
/* check the return status, make sure it is 0 (success) */
|
/* check the return status, make sure it is 0 (success) */
|
||||||
if(WIFEXITED(status)) {
|
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) {
|
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;
|
retval = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -530,7 +530,7 @@ int _alpm_run_chroot(pmhandle_t *handle, const char *path, char *const argv[])
|
|||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if(restore_cwd && chdir(cwd) != 0) {
|
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;
|
return retval;
|
||||||
@ -540,7 +540,7 @@ int _alpm_ldconfig(pmhandle_t *handle)
|
|||||||
{
|
{
|
||||||
char line[PATH_MAX];
|
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);
|
snprintf(line, PATH_MAX, "%setc/ld.so.conf", handle->root);
|
||||||
if(access(line, F_OK) == 0) {
|
if(access(line, F_OK) == 0) {
|
||||||
@ -579,7 +579,7 @@ char *_alpm_filecache_find(pmhandle_t *handle, const char *filename)
|
|||||||
filename);
|
filename);
|
||||||
if(stat(path, &buf) == 0 && S_ISREG(buf.st_mode)) {
|
if(stat(path, &buf) == 0 && S_ISREG(buf.st_mode)) {
|
||||||
retpath = strdup(path);
|
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;
|
return retpath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -603,17 +603,17 @@ const char *_alpm_filecache_setup(pmhandle_t *handle)
|
|||||||
cachedir = alpm_list_getdata(i);
|
cachedir = alpm_list_getdata(i);
|
||||||
if(stat(cachedir, &buf) != 0) {
|
if(stat(cachedir, &buf) != 0) {
|
||||||
/* cache directory does not exist.... try creating it */
|
/* 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);
|
cachedir);
|
||||||
if(_alpm_makepath(cachedir) == 0) {
|
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;
|
return cachedir;
|
||||||
}
|
}
|
||||||
} else if(S_ISDIR(buf.st_mode) && (buf.st_mode & S_IWUSR)) {
|
} 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;
|
return cachedir;
|
||||||
} else {
|
} 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/");
|
tmp = alpm_list_add(NULL, "/tmp/");
|
||||||
alpm_option_set_cachedirs(handle, tmp);
|
alpm_option_set_cachedirs(handle, tmp);
|
||||||
alpm_list_free(tmp);
|
alpm_list_free(tmp);
|
||||||
_alpm_log(PM_LOG_DEBUG, "using cachedir: %s\n", "/tmp/");
|
_alpm_log(handle, 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_WARNING, _("couldn't create package cache, using /tmp instead\n"));
|
||||||
return "/tmp/";
|
return "/tmp/";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -716,7 +716,6 @@ char SYMEXPORT *alpm_compute_md5sum(const char *filename)
|
|||||||
}
|
}
|
||||||
md5sum[32] = '\0';
|
md5sum[32] = '\0';
|
||||||
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "md5(%s) = %s\n", filename, md5sum);
|
|
||||||
return md5sum;
|
return md5sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@
|
|||||||
#define _(s) s
|
#define _(s) s
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ALLOC_FAIL(s) do { _alpm_log(PM_LOG_ERROR, _("alloc failure: could not allocate %zd bytes\n"), s); } while(0)
|
#define ALLOC_FAIL(s) do { fprintf(stderr, "alloc failure: could not allocate %zd bytes\n", s); } while(0)
|
||||||
|
|
||||||
#define MALLOC(p, s, action) do { p = calloc(1, s); if(p == NULL) { ALLOC_FAIL(s); action; } } while(0)
|
#define MALLOC(p, s, action) do { p = calloc(1, s); if(p == NULL) { ALLOC_FAIL(s); action; } } while(0)
|
||||||
#define CALLOC(p, l, s, action) do { p = calloc(l, s); if(p == NULL) { ALLOC_FAIL(s); action; } } while(0)
|
#define CALLOC(p, l, s, action) do { p = calloc(l, s); if(p == NULL) { ALLOC_FAIL(s); action; } } while(0)
|
||||||
@ -62,11 +62,11 @@
|
|||||||
#define ASSERT(cond, action) do { if(!(cond)) { action; } } while(0)
|
#define ASSERT(cond, action) do { if(!(cond)) { action; } } while(0)
|
||||||
|
|
||||||
#define RET_ERR_VOID(handle, err) do { (handle)->pm_errno = (err); \
|
#define RET_ERR_VOID(handle, err) do { (handle)->pm_errno = (err); \
|
||||||
_alpm_log(PM_LOG_DEBUG, "returning error %d from %s : %s\n", err, __func__, alpm_strerror(err)); \
|
_alpm_log(handle, PM_LOG_DEBUG, "returning error %d from %s : %s\n", err, __func__, alpm_strerror(err)); \
|
||||||
return; } while(0)
|
return; } while(0)
|
||||||
|
|
||||||
#define RET_ERR(handle, err, ret) do { (handle)->pm_errno = (err); \
|
#define RET_ERR(handle, err, ret) do { (handle)->pm_errno = (err); \
|
||||||
_alpm_log(PM_LOG_DEBUG, "returning error %d from %s : %s\n", err, __func__, alpm_strerror(err)); \
|
_alpm_log(handle, PM_LOG_DEBUG, "returning error %d from %s : %s\n", err, __func__, alpm_strerror(err)); \
|
||||||
return (ret); } while(0)
|
return (ret); } while(0)
|
||||||
|
|
||||||
#define DOUBLE_EQ(x, y) (fabs((x) - (y)) < DBL_EPSILON)
|
#define DOUBLE_EQ(x, y) (fabs((x) - (y)) < DBL_EPSILON)
|
||||||
|
Loading…
Reference in New Issue
Block a user