1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-08-13 17:03:46 -04:00

Merge remote-tracking branch 'allan/ALPM'

Conflicts:
	lib/libalpm/be_local.c
	lib/libalpm/be_package.c
	lib/libalpm/conflict.c
	lib/libalpm/diskspace.c
	lib/libalpm/dload.c
	lib/libalpm/remove.c
This commit is contained in:
Dan McGee 2011-07-03 14:44:57 -05:00
commit 1ce7f39ad7
35 changed files with 977 additions and 977 deletions

View File

@ -58,20 +58,20 @@ int SYMEXPORT alpm_add_pkg(alpm_handle_t *handle, alpm_pkg_t *pkg)
/* Sanity checks */ /* Sanity checks */
CHECK_HANDLE(handle, return -1); CHECK_HANDLE(handle, return -1);
ASSERT(pkg != NULL, RET_ERR(handle, PM_ERR_WRONG_ARGS, -1)); ASSERT(pkg != NULL, RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1));
ASSERT(handle == pkg->handle, RET_ERR(handle, PM_ERR_WRONG_ARGS, -1)); ASSERT(handle == pkg->handle, RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1));
trans = handle->trans; trans = handle->trans;
ASSERT(trans != NULL, RET_ERR(handle, PM_ERR_TRANS_NULL, -1)); ASSERT(trans != NULL, RET_ERR(handle, ALPM_ERR_TRANS_NULL, -1));
ASSERT(trans->state == STATE_INITIALIZED, ASSERT(trans->state == STATE_INITIALIZED,
RET_ERR(handle, PM_ERR_TRANS_NOT_INITIALIZED, -1)); RET_ERR(handle, ALPM_ERR_TRANS_NOT_INITIALIZED, -1));
pkgname = pkg->name; pkgname = pkg->name;
pkgver = pkg->version; pkgver = pkg->version;
_alpm_log(handle, PM_LOG_DEBUG, "adding package '%s'\n", pkgname); _alpm_log(handle, ALPM_LOG_DEBUG, "adding package '%s'\n", pkgname);
if(_alpm_pkg_find(trans->add, pkgname)) { if(_alpm_pkg_find(trans->add, pkgname)) {
RET_ERR(handle, PM_ERR_TRANS_DUP_TARGET, -1); RET_ERR(handle, ALPM_ERR_TRANS_DUP_TARGET, -1);
} }
local = _alpm_db_get_pkgfromcache(handle->db_local, pkgname); local = _alpm_db_get_pkgfromcache(handle->db_local, pkgname);
@ -81,25 +81,25 @@ int SYMEXPORT alpm_add_pkg(alpm_handle_t *handle, alpm_pkg_t *pkg)
int cmp = _alpm_pkg_compare_versions(pkg, local); int cmp = _alpm_pkg_compare_versions(pkg, local);
if(cmp == 0) { if(cmp == 0) {
if(trans->flags & PM_TRANS_FLAG_NEEDED) { if(trans->flags & ALPM_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(handle, PM_LOG_WARNING, _("%s-%s is up to date -- skipping\n"), _alpm_log(handle, ALPM_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 & ALPM_TRANS_FLAG_DOWNLOADONLY)) {
_alpm_log(handle, PM_LOG_WARNING, _("%s-%s is up to date -- reinstalling\n"), _alpm_log(handle, ALPM_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(handle, PM_LOG_WARNING, _("downgrading package %s (%s => %s)\n"), _alpm_log(handle, ALPM_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 = ALPM_PKG_REASON_EXPLICIT;
_alpm_log(handle, PM_LOG_DEBUG, "adding package %s-%s to the transaction add list\n", _alpm_log(handle, ALPM_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(alpm_handle_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(handle, PM_LOG_WARNING, _("warning given when extracting %s (%s)\n"), _alpm_log(handle, ALPM_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(handle, PM_LOG_ERROR, _("could not extract %s (%s)\n"), _alpm_log(handle, ALPM_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(alpm_handle_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(handle, PM_LOG_DEBUG, "skipping extraction of '%s'\n", entryname); _alpm_log(handle, ALPM_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(alpm_handle_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(handle, PM_LOG_DEBUG, "%s is in NoExtract, skipping extraction\n", _alpm_log(handle, ALPM_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(alpm_handle_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(handle, PM_LOG_WARNING, _("directory permissions differ on %s\n" _alpm_log(handle, ALPM_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(handle, PM_LOG_DEBUG, "extract: skipping dir extraction of %s\n", _alpm_log(handle, ALPM_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(handle, PM_LOG_ERROR, _("extract: not overwriting dir with file %s\n"), _alpm_log(handle, ALPM_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(alpm_handle_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(handle, PM_LOG_DEBUG, "extract: skipping symlink overwrite of %s\n", _alpm_log(handle, ALPM_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(handle, PM_LOG_ERROR, _("extract: symlink %s does not point to dir\n"), _alpm_log(handle, ALPM_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(handle, PM_LOG_DEBUG, "extract: overwriting file with dir %s\n", _alpm_log(handle, ALPM_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: */
@ -278,7 +278,7 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive,
/* we need access to the original entryname later after calls to /* we need access to the original entryname later after calls to
* archive_entry_set_pathname(), so we need to dupe it and free() later */ * archive_entry_set_pathname(), so we need to dupe it and free() later */
STRDUP(entryname_orig, entryname, RET_ERR(handle, PM_ERR_MEMORY, -1)); STRDUP(entryname_orig, entryname, RET_ERR(handle, ALPM_ERR_MEMORY, -1));
if(needbackup) { if(needbackup) {
char checkfile[PATH_MAX]; char checkfile[PATH_MAX];
@ -305,15 +305,15 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive,
if(!backup->name || strcmp(backup->name, entryname_orig) != 0) { if(!backup->name || strcmp(backup->name, entryname_orig) != 0) {
continue; continue;
} }
STRDUP(newhash, hash_pkg, RET_ERR(handle, PM_ERR_MEMORY, -1)); STRDUP(newhash, hash_pkg, RET_ERR(handle, ALPM_ERR_MEMORY, -1));
FREE(backup->hash); FREE(backup->hash);
backup->hash = newhash; backup->hash = newhash;
} }
_alpm_log(handle, PM_LOG_DEBUG, "checking hashes for %s\n", entryname_orig); _alpm_log(handle, ALPM_LOG_DEBUG, "checking hashes for %s\n", entryname_orig);
_alpm_log(handle, PM_LOG_DEBUG, "current: %s\n", hash_local); _alpm_log(handle, ALPM_LOG_DEBUG, "current: %s\n", hash_local);
_alpm_log(handle, PM_LOG_DEBUG, "new: %s\n", hash_pkg); _alpm_log(handle, ALPM_LOG_DEBUG, "new: %s\n", hash_pkg);
_alpm_log(handle, PM_LOG_DEBUG, "original: %s\n", hash_orig); _alpm_log(handle, ALPM_LOG_DEBUG, "original: %s\n", hash_orig);
if(!oldpkg) { if(!oldpkg) {
if(hash_local && hash_pkg && strcmp(hash_local, hash_pkg) != 0) { if(hash_local && hash_pkg && strcmp(hash_local, hash_pkg) != 0) {
@ -324,7 +324,7 @@ static int extract_single_file(alpm_handle_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(handle, PM_LOG_ERROR, _("could not rename %s to %s (%s)\n"), _alpm_log(handle, ALPM_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));
@ -332,13 +332,13 @@ static int extract_single_file(alpm_handle_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(handle, PM_LOG_ERROR, _("could not rename %s to %s (%s)\n"), _alpm_log(handle, ALPM_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(handle, PM_LOG_WARNING, _("%s saved as %s\n"), filename, newpath); _alpm_log(handle, ALPM_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);
} }
} }
@ -352,11 +352,11 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive,
if(hash_local && strcmp(hash_orig, hash_local) == 0) { if(hash_local && strcmp(hash_orig, hash_local) == 0) {
/* installed file has NOT been changed by user */ /* installed file has NOT been changed by user */
if(hash_pkg && strcmp(hash_orig, hash_pkg) != 0) { if(hash_pkg && strcmp(hash_orig, hash_pkg) != 0) {
_alpm_log(handle, PM_LOG_DEBUG, "action: installing new file: %s\n", _alpm_log(handle, ALPM_LOG_DEBUG, "action: installing new file: %s\n",
entryname_orig); entryname_orig);
if(rename(checkfile, filename)) { if(rename(checkfile, filename)) {
_alpm_log(handle, PM_LOG_ERROR, _("could not rename %s to %s (%s)\n"), _alpm_log(handle, ALPM_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));
@ -365,33 +365,33 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive,
} else { } else {
/* no sense in installing the same file twice, install /* no sense in installing the same file twice, install
* ONLY if the original and package hashes differ */ * ONLY if the original and package hashes differ */
_alpm_log(handle, PM_LOG_DEBUG, "action: leaving existing file in place\n"); _alpm_log(handle, ALPM_LOG_DEBUG, "action: leaving existing file in place\n");
unlink(checkfile); unlink(checkfile);
} }
} else if(hash_pkg && strcmp(hash_orig, hash_pkg) == 0) { } else if(hash_pkg && 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(handle, PM_LOG_DEBUG, "action: leaving existing file in place\n"); _alpm_log(handle, ALPM_LOG_DEBUG, "action: leaving existing file in place\n");
unlink(checkfile); unlink(checkfile);
} else if(hash_local && hash_pkg && strcmp(hash_local, hash_pkg) == 0) { } else if(hash_local && hash_pkg && 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(handle, PM_LOG_DEBUG, "action: leaving existing file in place\n"); _alpm_log(handle, ALPM_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(handle, PM_LOG_DEBUG, "action: keeping current file and installing" _alpm_log(handle, ALPM_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(handle, PM_LOG_ERROR, _("could not install %s as %s (%s)\n"), _alpm_log(handle, ALPM_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(handle, PM_LOG_WARNING, _("%s installed as %s\n"), _alpm_log(handle, ALPM_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);
@ -407,15 +407,15 @@ static int extract_single_file(alpm_handle_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(handle, PM_LOG_DEBUG, "%s is in NoUpgrade -- skipping\n", filename); _alpm_log(handle, ALPM_LOG_DEBUG, "%s is in NoUpgrade -- skipping\n", filename);
_alpm_log(handle, PM_LOG_WARNING, _("extracting %s as %s.pacnew\n"), filename, filename); _alpm_log(handle, ALPM_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(handle, PM_LOG_DEBUG, "extracting %s\n", filename); _alpm_log(handle, ALPM_LOG_DEBUG, "extracting %s\n", filename);
} }
if(handle->trans->flags & PM_TRANS_FLAG_FORCE) { if(handle->trans->flags & ALPM_TRANS_FLAG_FORCE) {
/* if FORCE was used, unlink() each file (whether it's there /* if FORCE was used, unlink() each file (whether it's there
* or not) before extracting. This prevents the old "Text file busy" * or not) before extracting. This prevents the old "Text file busy"
* error that crops up if forcing a glibc or pacman upgrade. */ * error that crops up if forcing a glibc or pacman upgrade. */
@ -437,7 +437,7 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive,
if(!backup->name || strcmp(backup->name, entryname_orig) != 0) { if(!backup->name || strcmp(backup->name, entryname_orig) != 0) {
continue; continue;
} }
_alpm_log(handle, PM_LOG_DEBUG, "appending backup entry for %s\n", entryname_orig); _alpm_log(handle, ALPM_LOG_DEBUG, "appending backup entry for %s\n", entryname_orig);
newhash = alpm_compute_md5sum(filename); newhash = alpm_compute_md5sum(filename);
FREE(backup->hash); FREE(backup->hash);
backup->hash = newhash; backup->hash = newhash;
@ -471,43 +471,43 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
/* we'll need to save some record for backup checks later */ /* we'll need to save some record for backup checks later */
oldpkg = _alpm_pkg_dup(local); oldpkg = _alpm_pkg_dup(local);
EVENT(trans, PM_TRANS_EVT_UPGRADE_START, newpkg, oldpkg); EVENT(trans, ALPM_TRANS_EVT_UPGRADE_START, newpkg, oldpkg);
_alpm_log(handle, PM_LOG_DEBUG, "upgrading package %s-%s\n", _alpm_log(handle, ALPM_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 */
newpkg->reason = alpm_pkg_get_reason(oldpkg); newpkg->reason = alpm_pkg_get_reason(oldpkg);
/* pre_upgrade scriptlet */ /* pre_upgrade scriptlet */
if(alpm_pkg_has_scriptlet(newpkg) && !(trans->flags & PM_TRANS_FLAG_NOSCRIPTLET)) { if(alpm_pkg_has_scriptlet(newpkg) && !(trans->flags & ALPM_TRANS_FLAG_NOSCRIPTLET)) {
_alpm_runscriptlet(handle, newpkg->origin_data.file, _alpm_runscriptlet(handle, newpkg->origin_data.file,
"pre_upgrade", newpkg->version, oldpkg->version); "pre_upgrade", newpkg->version, oldpkg->version);
} }
} else { } else {
is_upgrade = 0; is_upgrade = 0;
EVENT(trans, PM_TRANS_EVT_ADD_START, newpkg, NULL); EVENT(trans, ALPM_TRANS_EVT_ADD_START, newpkg, NULL);
_alpm_log(handle, PM_LOG_DEBUG, "adding package %s-%s\n", _alpm_log(handle, ALPM_LOG_DEBUG, "adding package %s-%s\n",
newpkg->name, newpkg->version); newpkg->name, newpkg->version);
/* pre_install scriptlet */ /* pre_install scriptlet */
if(alpm_pkg_has_scriptlet(newpkg) && !(trans->flags & PM_TRANS_FLAG_NOSCRIPTLET)) { if(alpm_pkg_has_scriptlet(newpkg) && !(trans->flags & ALPM_TRANS_FLAG_NOSCRIPTLET)) {
_alpm_runscriptlet(handle, newpkg->origin_data.file, _alpm_runscriptlet(handle, newpkg->origin_data.file,
"pre_install", newpkg->version, NULL); "pre_install", newpkg->version, NULL);
} }
} }
/* we override any pre-set reason if we have alldeps or allexplicit set */ /* we override any pre-set reason if we have alldeps or allexplicit set */
if(trans->flags & PM_TRANS_FLAG_ALLDEPS) { if(trans->flags & ALPM_TRANS_FLAG_ALLDEPS) {
newpkg->reason = PM_PKG_REASON_DEPEND; newpkg->reason = ALPM_PKG_REASON_DEPEND;
} else if(trans->flags & PM_TRANS_FLAG_ALLEXPLICIT) { } else if(trans->flags & ALPM_TRANS_FLAG_ALLEXPLICIT) {
newpkg->reason = PM_PKG_REASON_EXPLICIT; newpkg->reason = ALPM_PKG_REASON_EXPLICIT;
} }
if(oldpkg) { if(oldpkg) {
/* set up fake remove transaction */ /* set up fake remove transaction */
if(_alpm_upgraderemove_package(handle, oldpkg, newpkg) == -1) { if(_alpm_upgraderemove_package(handle, oldpkg, newpkg) == -1) {
handle->pm_errno = PM_ERR_TRANS_ABORT; handle->pm_errno = ALPM_ERR_TRANS_ABORT;
ret = -1; ret = -1;
goto cleanup; goto cleanup;
} }
@ -518,21 +518,21 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
if(_alpm_local_db_prepare(db, newpkg)) { if(_alpm_local_db_prepare(db, newpkg)) {
alpm_logaction(handle, "error: could not create database entry %s-%s\n", alpm_logaction(handle, "error: could not create 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));
handle->pm_errno = PM_ERR_DB_WRITE; handle->pm_errno = ALPM_ERR_DB_WRITE;
ret = -1; ret = -1;
goto cleanup; goto cleanup;
} }
if(!(trans->flags & PM_TRANS_FLAG_DBONLY)) { if(!(trans->flags & ALPM_TRANS_FLAG_DBONLY)) {
struct archive *archive; struct archive *archive;
struct archive_entry *entry; struct archive_entry *entry;
char cwd[PATH_MAX] = ""; char cwd[PATH_MAX] = "";
int restore_cwd = 0; int restore_cwd = 0;
_alpm_log(handle, PM_LOG_DEBUG, "extracting files\n"); _alpm_log(handle, ALPM_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 = ALPM_ERR_LIBARCHIVE;
ret = -1; ret = -1;
goto cleanup; goto cleanup;
} }
@ -540,24 +540,24 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_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(handle, PM_LOG_DEBUG, "archive: %s\n", newpkg->origin_data.file); _alpm_log(handle, ALPM_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 = ALPM_ERR_PKG_OPEN;
ret = -1; ret = -1;
goto cleanup; goto cleanup;
} }
/* 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(handle, PM_LOG_ERROR, _("could not get current working directory\n")); _alpm_log(handle, ALPM_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(handle->root) != 0) { if(chdir(handle->root) != 0) {
_alpm_log(handle, PM_LOG_ERROR, _("could not change directory to %s (%s)\n"), _alpm_log(handle, ALPM_LOG_ERROR, _("could not change directory to %s (%s)\n"),
handle->root, strerror(errno)); handle->root, strerror(errno));
ret = -1; ret = -1;
goto cleanup; goto cleanup;
@ -565,10 +565,10 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
/* call PROGRESS once with 0 percent, as we sort-of skip that here */ /* call PROGRESS once with 0 percent, as we sort-of skip that here */
if(is_upgrade) { if(is_upgrade) {
PROGRESS(trans, PM_TRANS_PROGRESS_UPGRADE_START, PROGRESS(trans, ALPM_TRANS_PROGRESS_UPGRADE_START,
alpm_pkg_get_name(newpkg), 0, pkg_count, pkg_current); alpm_pkg_get_name(newpkg), 0, pkg_count, pkg_current);
} else { } else {
PROGRESS(trans, PM_TRANS_PROGRESS_ADD_START, PROGRESS(trans, ALPM_TRANS_PROGRESS_ADD_START,
alpm_pkg_get_name(newpkg), 0, pkg_count, pkg_current); alpm_pkg_get_name(newpkg), 0, pkg_count, pkg_current);
} }
@ -581,7 +581,7 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_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(handle, PM_LOG_DEBUG, "decompression progress: " _alpm_log(handle, ALPM_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) {
@ -592,11 +592,11 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
} }
if(is_upgrade) { if(is_upgrade) {
PROGRESS(trans, PM_TRANS_PROGRESS_UPGRADE_START, PROGRESS(trans, ALPM_TRANS_PROGRESS_UPGRADE_START,
alpm_pkg_get_name(newpkg), percent, pkg_count, alpm_pkg_get_name(newpkg), percent, pkg_count,
pkg_current); pkg_current);
} else { } else {
PROGRESS(trans, PM_TRANS_PROGRESS_ADD_START, PROGRESS(trans, ALPM_TRANS_PROGRESS_ADD_START,
alpm_pkg_get_name(newpkg), percent, pkg_count, alpm_pkg_get_name(newpkg), percent, pkg_count,
pkg_current); pkg_current);
} }
@ -608,18 +608,18 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_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(handle, PM_LOG_ERROR, _("could not change directory to %s (%s)\n"), cwd, strerror(errno)); _alpm_log(handle, ALPM_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(handle, PM_LOG_ERROR, _("problem occurred while upgrading %s\n"), _alpm_log(handle, ALPM_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(handle, PM_LOG_ERROR, _("problem occurred while installing %s\n"), _alpm_log(handle, ALPM_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);
@ -630,35 +630,35 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
/* make an install date (in UTC) */ /* make an install date (in UTC) */
newpkg->installdate = time(NULL); newpkg->installdate = time(NULL);
_alpm_log(handle, PM_LOG_DEBUG, "updating database\n"); _alpm_log(handle, ALPM_LOG_DEBUG, "updating database\n");
_alpm_log(handle, PM_LOG_DEBUG, "adding database entry '%s'\n", newpkg->name); _alpm_log(handle, ALPM_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(handle, PM_LOG_ERROR, _("could not update database entry %s-%s\n"), _alpm_log(handle, ALPM_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));
handle->pm_errno = PM_ERR_DB_WRITE; handle->pm_errno = ALPM_ERR_DB_WRITE;
ret = -1; ret = -1;
goto cleanup; goto cleanup;
} }
if(_alpm_db_add_pkgincache(db, newpkg) == -1) { if(_alpm_db_add_pkgincache(db, newpkg) == -1) {
_alpm_log(handle, PM_LOG_ERROR, _("could not add entry '%s' in cache\n"), _alpm_log(handle, ALPM_LOG_ERROR, _("could not add entry '%s' in cache\n"),
alpm_pkg_get_name(newpkg)); alpm_pkg_get_name(newpkg));
} }
if(is_upgrade) { if(is_upgrade) {
PROGRESS(trans, PM_TRANS_PROGRESS_UPGRADE_START, PROGRESS(trans, ALPM_TRANS_PROGRESS_UPGRADE_START,
alpm_pkg_get_name(newpkg), 100, pkg_count, pkg_current); alpm_pkg_get_name(newpkg), 100, pkg_count, pkg_current);
} else { } else {
PROGRESS(trans, PM_TRANS_PROGRESS_ADD_START, PROGRESS(trans, ALPM_TRANS_PROGRESS_ADD_START,
alpm_pkg_get_name(newpkg), 100, pkg_count, pkg_current); alpm_pkg_get_name(newpkg), 100, pkg_count, pkg_current);
} }
/* run the post-install script if it exists */ /* run the post-install script if it exists */
if(alpm_pkg_has_scriptlet(newpkg) if(alpm_pkg_has_scriptlet(newpkg)
&& !(trans->flags & PM_TRANS_FLAG_NOSCRIPTLET)) { && !(trans->flags & ALPM_TRANS_FLAG_NOSCRIPTLET)) {
if(is_upgrade) { if(is_upgrade) {
_alpm_runscriptlet(handle, scriptlet, "post_upgrade", _alpm_runscriptlet(handle, scriptlet, "post_upgrade",
alpm_pkg_get_version(newpkg), alpm_pkg_get_version(newpkg),
@ -670,9 +670,9 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
} }
if(is_upgrade) { if(is_upgrade) {
EVENT(trans, PM_TRANS_EVT_UPGRADE_DONE, newpkg, oldpkg); EVENT(trans, ALPM_TRANS_EVT_UPGRADE_DONE, newpkg, oldpkg);
} else { } else {
EVENT(trans, PM_TRANS_EVT_ADD_DONE, newpkg, oldpkg); EVENT(trans, ALPM_TRANS_EVT_ADD_DONE, newpkg, oldpkg);
} }
cleanup: cleanup:
@ -705,7 +705,7 @@ int _alpm_upgrade_packages(alpm_handle_t *handle)
if(commit_single_pkg(handle, newpkg, pkg_current, pkg_count)) { if(commit_single_pkg(handle, newpkg, pkg_current, pkg_count)) {
/* something screwed up on the commit, abort the trans */ /* something screwed up on the commit, abort the trans */
trans->state = STATE_INTERRUPTED; trans->state = STATE_INTERRUPTED;
handle->pm_errno = PM_ERR_TRANS_ABORT; handle->pm_errno = ALPM_ERR_TRANS_ABORT;
/* running ldconfig at this point could possibly screw system */ /* running ldconfig at this point could possibly screw system */
skip_ldconfig = 1; skip_ldconfig = 1;
ret = -1; ret = -1;

View File

@ -55,7 +55,7 @@ alpm_handle_t SYMEXPORT *alpm_initialize(const char *root, const char *dbpath,
alpm_handle_t *myhandle = _alpm_handle_new(); alpm_handle_t *myhandle = _alpm_handle_new();
if(myhandle == NULL) { if(myhandle == NULL) {
myerr = PM_ERR_MEMORY; myerr = ALPM_ERR_MEMORY;
goto cleanup; goto cleanup;
} }
if((myerr = _alpm_set_directory_option(root, &(myhandle->root), 1))) { if((myerr = _alpm_set_directory_option(root, &(myhandle->root), 1))) {

View File

@ -55,25 +55,25 @@ extern "C" {
*/ */
typedef enum _alpm_pkgreason_t { typedef enum _alpm_pkgreason_t {
/** Explicitly requested by the user. */ /** Explicitly requested by the user. */
PM_PKG_REASON_EXPLICIT = 0, ALPM_PKG_REASON_EXPLICIT = 0,
/** Installed as a dependency for another package. */ /** Installed as a dependency for another package. */
PM_PKG_REASON_DEPEND = 1 ALPM_PKG_REASON_DEPEND = 1
} alpm_pkgreason_t; } alpm_pkgreason_t;
/** Types of version constraints in dependency specs. */ /** Types of version constraints in dependency specs. */
typedef enum _alpm_depmod_t { typedef enum _alpm_depmod_t {
/** No version constraint */ /** No version constraint */
PM_DEP_MOD_ANY = 1, ALPM_DEP_MOD_ANY = 1,
/** Test version equality (package=x.y.z) */ /** Test version equality (package=x.y.z) */
PM_DEP_MOD_EQ, ALPM_DEP_MOD_EQ,
/** Test for at least a version (package>=x.y.z) */ /** Test for at least a version (package>=x.y.z) */
PM_DEP_MOD_GE, ALPM_DEP_MOD_GE,
/** Test for at most a version (package<=x.y.z) */ /** Test for at most a version (package<=x.y.z) */
PM_DEP_MOD_LE, ALPM_DEP_MOD_LE,
/** Test for greater than some version (package>x.y.z) */ /** Test for greater than some version (package>x.y.z) */
PM_DEP_MOD_GT, ALPM_DEP_MOD_GT,
/** Test for less than some version (package<x.y.z) */ /** Test for less than some version (package<x.y.z) */
PM_DEP_MOD_LT ALPM_DEP_MOD_LT
} alpm_depmod_t; } alpm_depmod_t;
/** /**
@ -82,8 +82,8 @@ typedef enum _alpm_depmod_t {
* another target in the transaction. * another target in the transaction.
*/ */
typedef enum _alpm_fileconflicttype_t { typedef enum _alpm_fileconflicttype_t {
PM_FILECONFLICT_TARGET = 1, ALPM_FILECONFLICT_TARGET = 1,
PM_FILECONFLICT_FILESYSTEM ALPM_FILECONFLICT_FILESYSTEM
} alpm_fileconflicttype_t; } alpm_fileconflicttype_t;
/** /**
@ -181,10 +181,10 @@ typedef struct _alpm_backup_t {
* Logging Levels * Logging Levels
*/ */
typedef enum _alpm_loglevel_t { typedef enum _alpm_loglevel_t {
PM_LOG_ERROR = 1, ALPM_LOG_ERROR = 1,
PM_LOG_WARNING = (1 << 1), ALPM_LOG_WARNING = (1 << 1),
PM_LOG_DEBUG = (1 << 2), ALPM_LOG_DEBUG = (1 << 2),
PM_LOG_FUNCTION = (1 << 3) ALPM_LOG_FUNCTION = (1 << 3)
} alpm_loglevel_t; } alpm_loglevel_t;
typedef void (*alpm_cb_log)(alpm_loglevel_t, const char *, va_list); typedef void (*alpm_cb_log)(alpm_loglevel_t, const char *, va_list);
@ -739,39 +739,39 @@ alpm_pkg_t *alpm_sync_newversion(alpm_pkg_t *pkg, alpm_list_t *dbs_sync);
/** Transaction flags */ /** Transaction flags */
typedef enum _alpm_transflag_t { typedef enum _alpm_transflag_t {
/** Ignore dependency checks. */ /** Ignore dependency checks. */
PM_TRANS_FLAG_NODEPS = 1, ALPM_TRANS_FLAG_NODEPS = 1,
/** Ignore file conflicts and overwrite files. */ /** Ignore file conflicts and overwrite files. */
PM_TRANS_FLAG_FORCE = (1 << 1), ALPM_TRANS_FLAG_FORCE = (1 << 1),
/** Delete files even if they are tagged as backup. */ /** Delete files even if they are tagged as backup. */
PM_TRANS_FLAG_NOSAVE = (1 << 2), ALPM_TRANS_FLAG_NOSAVE = (1 << 2),
/** Ignore version numbers when checking dependencies. */ /** Ignore version numbers when checking dependencies. */
PM_TRANS_FLAG_NODEPVERSION = (1 << 3), ALPM_TRANS_FLAG_NODEPVERSION = (1 << 3),
/** Remove also any packages depending on a package being removed. */ /** Remove also any packages depending on a package being removed. */
PM_TRANS_FLAG_CASCADE = (1 << 4), ALPM_TRANS_FLAG_CASCADE = (1 << 4),
/** Remove packages and their unneeded deps (not explicitly installed). */ /** Remove packages and their unneeded deps (not explicitly installed). */
PM_TRANS_FLAG_RECURSE = (1 << 5), ALPM_TRANS_FLAG_RECURSE = (1 << 5),
/** Modify database but do not commit changes to the filesystem. */ /** Modify database but do not commit changes to the filesystem. */
PM_TRANS_FLAG_DBONLY = (1 << 6), ALPM_TRANS_FLAG_DBONLY = (1 << 6),
/* (1 << 7) flag can go here */ /* (1 << 7) flag can go here */
/** Use PM_PKG_REASON_DEPEND when installing packages. */ /** Use ALPM_PKG_REASON_DEPEND when installing packages. */
PM_TRANS_FLAG_ALLDEPS = (1 << 8), ALPM_TRANS_FLAG_ALLDEPS = (1 << 8),
/** Only download packages and do not actually install. */ /** Only download packages and do not actually install. */
PM_TRANS_FLAG_DOWNLOADONLY = (1 << 9), ALPM_TRANS_FLAG_DOWNLOADONLY = (1 << 9),
/** Do not execute install scriptlets after installing. */ /** Do not execute install scriptlets after installing. */
PM_TRANS_FLAG_NOSCRIPTLET = (1 << 10), ALPM_TRANS_FLAG_NOSCRIPTLET = (1 << 10),
/** Ignore dependency conflicts. */ /** Ignore dependency conflicts. */
PM_TRANS_FLAG_NOCONFLICTS = (1 << 11), ALPM_TRANS_FLAG_NOCONFLICTS = (1 << 11),
/* (1 << 12) flag can go here */ /* (1 << 12) flag can go here */
/** Do not install a package if it is already installed and up to date. */ /** Do not install a package if it is already installed and up to date. */
PM_TRANS_FLAG_NEEDED = (1 << 13), ALPM_TRANS_FLAG_NEEDED = (1 << 13),
/** Use PM_PKG_REASON_EXPLICIT when installing packages. */ /** Use ALPM_PKG_REASON_EXPLICIT when installing packages. */
PM_TRANS_FLAG_ALLEXPLICIT = (1 << 14), ALPM_TRANS_FLAG_ALLEXPLICIT = (1 << 14),
/** Do not remove a package if it is needed by another one. */ /** Do not remove a package if it is needed by another one. */
PM_TRANS_FLAG_UNNEEDED = (1 << 15), ALPM_TRANS_FLAG_UNNEEDED = (1 << 15),
/** Remove also explicitly installed unneeded deps (use with PM_TRANS_FLAG_RECURSE). */ /** Remove also explicitly installed unneeded deps (use with ALPM_TRANS_FLAG_RECURSE). */
PM_TRANS_FLAG_RECURSEALL = (1 << 16), ALPM_TRANS_FLAG_RECURSEALL = (1 << 16),
/** Do not lock the database during the operation. */ /** Do not lock the database during the operation. */
PM_TRANS_FLAG_NOLOCK = (1 << 17) ALPM_TRANS_FLAG_NOLOCK = (1 << 17)
} alpm_transflag_t; } alpm_transflag_t;
/** Transaction events. /** Transaction events.
@ -779,100 +779,100 @@ typedef enum _alpm_transflag_t {
*/ */
typedef enum _alpm_transevt_t { typedef enum _alpm_transevt_t {
/** Dependencies will be computed for a package. */ /** Dependencies will be computed for a package. */
PM_TRANS_EVT_CHECKDEPS_START = 1, ALPM_TRANS_EVT_CHECKDEPS_START = 1,
/** Dependencies were computed for a package. */ /** Dependencies were computed for a package. */
PM_TRANS_EVT_CHECKDEPS_DONE, ALPM_TRANS_EVT_CHECKDEPS_DONE,
/** File conflicts will be computed for a package. */ /** File conflicts will be computed for a package. */
PM_TRANS_EVT_FILECONFLICTS_START, ALPM_TRANS_EVT_FILECONFLICTS_START,
/** File conflicts were computed for a package. */ /** File conflicts were computed for a package. */
PM_TRANS_EVT_FILECONFLICTS_DONE, ALPM_TRANS_EVT_FILECONFLICTS_DONE,
/** Dependencies will be resolved for target package. */ /** Dependencies will be resolved for target package. */
PM_TRANS_EVT_RESOLVEDEPS_START, ALPM_TRANS_EVT_RESOLVEDEPS_START,
/** Dependencies were resolved for target package. */ /** Dependencies were resolved for target package. */
PM_TRANS_EVT_RESOLVEDEPS_DONE, ALPM_TRANS_EVT_RESOLVEDEPS_DONE,
/** Inter-conflicts will be checked for target package. */ /** Inter-conflicts will be checked for target package. */
PM_TRANS_EVT_INTERCONFLICTS_START, ALPM_TRANS_EVT_INTERCONFLICTS_START,
/** Inter-conflicts were checked for target package. */ /** Inter-conflicts were checked for target package. */
PM_TRANS_EVT_INTERCONFLICTS_DONE, ALPM_TRANS_EVT_INTERCONFLICTS_DONE,
/** Package will be installed. /** Package will be installed.
* A pointer to the target package is passed to the callback. * A pointer to the target package is passed to the callback.
*/ */
PM_TRANS_EVT_ADD_START, ALPM_TRANS_EVT_ADD_START,
/** Package was installed. /** Package was installed.
* A pointer to the new package is passed to the callback. * A pointer to the new package is passed to the callback.
*/ */
PM_TRANS_EVT_ADD_DONE, ALPM_TRANS_EVT_ADD_DONE,
/** Package will be removed. /** Package will be removed.
* A pointer to the target package is passed to the callback. * A pointer to the target package is passed to the callback.
*/ */
PM_TRANS_EVT_REMOVE_START, ALPM_TRANS_EVT_REMOVE_START,
/** Package was removed. /** Package was removed.
* A pointer to the removed package is passed to the callback. * A pointer to the removed package is passed to the callback.
*/ */
PM_TRANS_EVT_REMOVE_DONE, ALPM_TRANS_EVT_REMOVE_DONE,
/** Package will be upgraded. /** Package will be upgraded.
* A pointer to the upgraded package is passed to the callback. * A pointer to the upgraded package is passed to the callback.
*/ */
PM_TRANS_EVT_UPGRADE_START, ALPM_TRANS_EVT_UPGRADE_START,
/** Package was upgraded. /** Package was upgraded.
* A pointer to the new package, and a pointer to the old package is passed * A pointer to the new package, and a pointer to the old package is passed
* to the callback, respectively. * to the callback, respectively.
*/ */
PM_TRANS_EVT_UPGRADE_DONE, ALPM_TRANS_EVT_UPGRADE_DONE,
/** Target package's integrity will be checked. */ /** Target package's integrity will be checked. */
PM_TRANS_EVT_INTEGRITY_START, ALPM_TRANS_EVT_INTEGRITY_START,
/** Target package's integrity was checked. */ /** Target package's integrity was checked. */
PM_TRANS_EVT_INTEGRITY_DONE, ALPM_TRANS_EVT_INTEGRITY_DONE,
/** Target deltas's integrity will be checked. */ /** Target deltas's integrity will be checked. */
PM_TRANS_EVT_DELTA_INTEGRITY_START, ALPM_TRANS_EVT_DELTA_INTEGRITY_START,
/** Target delta's integrity was checked. */ /** Target delta's integrity was checked. */
PM_TRANS_EVT_DELTA_INTEGRITY_DONE, ALPM_TRANS_EVT_DELTA_INTEGRITY_DONE,
/** Deltas will be applied to packages. */ /** Deltas will be applied to packages. */
PM_TRANS_EVT_DELTA_PATCHES_START, ALPM_TRANS_EVT_DELTA_PATCHES_START,
/** Deltas were applied to packages. */ /** Deltas were applied to packages. */
PM_TRANS_EVT_DELTA_PATCHES_DONE, ALPM_TRANS_EVT_DELTA_PATCHES_DONE,
/** Delta patch will be applied to target package. /** Delta patch will be applied to target package.
* The filename of the package and the filename of the patch is passed to the * The filename of the package and the filename of the patch is passed to the
* callback. * callback.
*/ */
PM_TRANS_EVT_DELTA_PATCH_START, ALPM_TRANS_EVT_DELTA_PATCH_START,
/** Delta patch was applied to target package. */ /** Delta patch was applied to target package. */
PM_TRANS_EVT_DELTA_PATCH_DONE, ALPM_TRANS_EVT_DELTA_PATCH_DONE,
/** Delta patch failed to apply to target package. */ /** Delta patch failed to apply to target package. */
PM_TRANS_EVT_DELTA_PATCH_FAILED, ALPM_TRANS_EVT_DELTA_PATCH_FAILED,
/** Scriptlet has printed information. /** Scriptlet has printed information.
* A line of text is passed to the callback. * A line of text is passed to the callback.
*/ */
PM_TRANS_EVT_SCRIPTLET_INFO, ALPM_TRANS_EVT_SCRIPTLET_INFO,
/** Files will be downloaded from a repository. /** Files will be downloaded from a repository.
* The repository's tree name is passed to the callback. * The repository's tree name is passed to the callback.
*/ */
PM_TRANS_EVT_RETRIEVE_START, ALPM_TRANS_EVT_RETRIEVE_START,
/** Disk space usage will be computed for a package */ /** Disk space usage will be computed for a package */
PM_TRANS_EVT_DISKSPACE_START, ALPM_TRANS_EVT_DISKSPACE_START,
/** Disk space usage was computed for a package */ /** Disk space usage was computed for a package */
PM_TRANS_EVT_DISKSPACE_DONE, ALPM_TRANS_EVT_DISKSPACE_DONE,
} alpm_transevt_t; } alpm_transevt_t;
/** Transaction Conversations (ie, questions) */ /** Transaction Conversations (ie, questions) */
typedef enum _alpm_transconv_t { typedef enum _alpm_transconv_t {
PM_TRANS_CONV_INSTALL_IGNOREPKG = 1, ALPM_TRANS_CONV_INSTALL_IGNOREPKG = 1,
PM_TRANS_CONV_REPLACE_PKG = (1 << 1), ALPM_TRANS_CONV_REPLACE_PKG = (1 << 1),
PM_TRANS_CONV_CONFLICT_PKG = (1 << 2), ALPM_TRANS_CONV_CONFLICT_PKG = (1 << 2),
PM_TRANS_CONV_CORRUPTED_PKG = (1 << 3), ALPM_TRANS_CONV_CORRUPTED_PKG = (1 << 3),
PM_TRANS_CONV_LOCAL_NEWER = (1 << 4), ALPM_TRANS_CONV_LOCAL_NEWER = (1 << 4),
PM_TRANS_CONV_REMOVE_PKGS = (1 << 5), ALPM_TRANS_CONV_REMOVE_PKGS = (1 << 5),
PM_TRANS_CONV_SELECT_PROVIDER = (1 << 6), ALPM_TRANS_CONV_SELECT_PROVIDER = (1 << 6),
} alpm_transconv_t; } alpm_transconv_t;
/** Transaction Progress */ /** Transaction Progress */
typedef enum _alpm_transprog_t { typedef enum _alpm_transprog_t {
PM_TRANS_PROGRESS_ADD_START, ALPM_TRANS_PROGRESS_ADD_START,
PM_TRANS_PROGRESS_UPGRADE_START, ALPM_TRANS_PROGRESS_UPGRADE_START,
PM_TRANS_PROGRESS_REMOVE_START, ALPM_TRANS_PROGRESS_REMOVE_START,
PM_TRANS_PROGRESS_CONFLICTS_START, ALPM_TRANS_PROGRESS_CONFLICTS_START,
PM_TRANS_PROGRESS_DISKSPACE_START, ALPM_TRANS_PROGRESS_DISKSPACE_START,
PM_TRANS_PROGRESS_INTEGRITY_START, ALPM_TRANS_PROGRESS_INTEGRITY_START,
} alpm_transprog_t; } alpm_transprog_t;
/** Transaction Event callback */ /** Transaction Event callback */
@ -1007,67 +1007,67 @@ char *alpm_compute_md5sum(const char *name);
* @{ * @{
*/ */
enum _alpm_errno_t { enum _alpm_errno_t {
PM_ERR_MEMORY = 1, ALPM_ERR_MEMORY = 1,
PM_ERR_SYSTEM, ALPM_ERR_SYSTEM,
PM_ERR_BADPERMS, ALPM_ERR_BADPERMS,
PM_ERR_NOT_A_FILE, ALPM_ERR_NOT_A_FILE,
PM_ERR_NOT_A_DIR, ALPM_ERR_NOT_A_DIR,
PM_ERR_WRONG_ARGS, ALPM_ERR_WRONG_ARGS,
PM_ERR_DISK_SPACE, ALPM_ERR_DISK_SPACE,
/* Interface */ /* Interface */
PM_ERR_HANDLE_NULL, ALPM_ERR_HANDLE_NULL,
PM_ERR_HANDLE_NOT_NULL, ALPM_ERR_HANDLE_NOT_NULL,
PM_ERR_HANDLE_LOCK, ALPM_ERR_HANDLE_LOCK,
/* Databases */ /* Databases */
PM_ERR_DB_OPEN, ALPM_ERR_DB_OPEN,
PM_ERR_DB_CREATE, ALPM_ERR_DB_CREATE,
PM_ERR_DB_NULL, ALPM_ERR_DB_NULL,
PM_ERR_DB_NOT_NULL, ALPM_ERR_DB_NOT_NULL,
PM_ERR_DB_NOT_FOUND, ALPM_ERR_DB_NOT_FOUND,
PM_ERR_DB_INVALID, ALPM_ERR_DB_INVALID,
PM_ERR_DB_VERSION, ALPM_ERR_DB_VERSION,
PM_ERR_DB_WRITE, ALPM_ERR_DB_WRITE,
PM_ERR_DB_REMOVE, ALPM_ERR_DB_REMOVE,
/* Servers */ /* Servers */
PM_ERR_SERVER_BAD_URL, ALPM_ERR_SERVER_BAD_URL,
PM_ERR_SERVER_NONE, ALPM_ERR_SERVER_NONE,
/* Transactions */ /* Transactions */
PM_ERR_TRANS_NOT_NULL, ALPM_ERR_TRANS_NOT_NULL,
PM_ERR_TRANS_NULL, ALPM_ERR_TRANS_NULL,
PM_ERR_TRANS_DUP_TARGET, ALPM_ERR_TRANS_DUP_TARGET,
PM_ERR_TRANS_NOT_INITIALIZED, ALPM_ERR_TRANS_NOT_INITIALIZED,
PM_ERR_TRANS_NOT_PREPARED, ALPM_ERR_TRANS_NOT_PREPARED,
PM_ERR_TRANS_ABORT, ALPM_ERR_TRANS_ABORT,
PM_ERR_TRANS_TYPE, ALPM_ERR_TRANS_TYPE,
PM_ERR_TRANS_NOT_LOCKED, ALPM_ERR_TRANS_NOT_LOCKED,
/* Packages */ /* Packages */
PM_ERR_PKG_NOT_FOUND, ALPM_ERR_PKG_NOT_FOUND,
PM_ERR_PKG_IGNORED, ALPM_ERR_PKG_IGNORED,
PM_ERR_PKG_INVALID, ALPM_ERR_PKG_INVALID,
PM_ERR_PKG_OPEN, ALPM_ERR_PKG_OPEN,
PM_ERR_PKG_CANT_REMOVE, ALPM_ERR_PKG_CANT_REMOVE,
PM_ERR_PKG_INVALID_NAME, ALPM_ERR_PKG_INVALID_NAME,
PM_ERR_PKG_INVALID_ARCH, ALPM_ERR_PKG_INVALID_ARCH,
PM_ERR_PKG_REPO_NOT_FOUND, ALPM_ERR_PKG_REPO_NOT_FOUND,
/* Signatures */ /* Signatures */
PM_ERR_SIG_MISSINGDIR, ALPM_ERR_SIG_MISSINGDIR,
PM_ERR_SIG_INVALID, ALPM_ERR_SIG_INVALID,
PM_ERR_SIG_UNKNOWN, ALPM_ERR_SIG_UNKNOWN,
/* Deltas */ /* Deltas */
PM_ERR_DLT_INVALID, ALPM_ERR_DLT_INVALID,
PM_ERR_DLT_PATCHFAILED, ALPM_ERR_DLT_PATCHFAILED,
/* Dependencies */ /* Dependencies */
PM_ERR_UNSATISFIED_DEPS, ALPM_ERR_UNSATISFIED_DEPS,
PM_ERR_CONFLICTING_DEPS, ALPM_ERR_CONFLICTING_DEPS,
PM_ERR_FILE_CONFLICTS, ALPM_ERR_FILE_CONFLICTS,
/* Misc */ /* Misc */
PM_ERR_RETRIEVE, ALPM_ERR_RETRIEVE,
PM_ERR_INVALID_REGEX, ALPM_ERR_INVALID_REGEX,
/* External library errors */ /* External library errors */
PM_ERR_LIBARCHIVE, ALPM_ERR_LIBARCHIVE,
PM_ERR_LIBCURL, ALPM_ERR_LIBCURL,
PM_ERR_EXTERNAL_DOWNLOAD, ALPM_ERR_EXTERNAL_DOWNLOAD,
PM_ERR_GPGME ALPM_ERR_GPGME
}; };
/** Returns the current error code from the handle. */ /** Returns the current error code from the handle. */

View File

@ -280,15 +280,15 @@ static int checkdbdir(alpm_db_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(db->handle, PM_LOG_DEBUG, "database dir '%s' does not exist, creating it\n", _alpm_log(db->handle, ALPM_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, ALPM_ERR_SYSTEM, -1);
} }
} else if(!S_ISDIR(buf.st_mode)) { } else if(!S_ISDIR(buf.st_mode)) {
_alpm_log(db->handle, PM_LOG_WARNING, _("removing invalid database: %s\n"), path); _alpm_log(db->handle, ALPM_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, ALPM_ERR_SYSTEM, -1);
} }
} }
return 0; return 0;
@ -328,7 +328,7 @@ static int local_db_validate(alpm_db_t *db)
dbpath = _alpm_db_path(db); dbpath = _alpm_db_path(db);
if(dbpath == NULL) { if(dbpath == NULL) {
RET_ERR(db->handle, PM_ERR_DB_OPEN, -1); RET_ERR(db->handle, ALPM_ERR_DB_OPEN, -1);
} }
dbdir = opendir(dbpath); dbdir = opendir(dbpath);
if(dbdir == NULL) { if(dbdir == NULL) {
@ -337,7 +337,7 @@ static int local_db_validate(alpm_db_t *db)
db->status |= DB_STATUS_VALID; db->status |= DB_STATUS_VALID;
return 0; return 0;
} else { } else {
RET_ERR(db->handle, PM_ERR_DB_OPEN, -1); RET_ERR(db->handle, ALPM_ERR_DB_OPEN, -1);
} }
} }
@ -355,7 +355,7 @@ static int local_db_validate(alpm_db_t *db)
snprintf(path, PATH_MAX, "%s%s/depends", dbpath, name); snprintf(path, PATH_MAX, "%s%s/depends", dbpath, name);
if(access(path, F_OK) == 0) { if(access(path, F_OK) == 0) {
/* we found a depends file- bail */ /* we found a depends file- bail */
db->handle->pm_errno = PM_ERR_DB_VERSION; db->handle->pm_errno = ALPM_ERR_DB_VERSION;
goto done; goto done;
} }
} }
@ -392,10 +392,10 @@ static int local_db_populate(alpm_db_t *db)
/* no database existing yet is not an error */ /* no database existing yet is not an error */
return 0; return 0;
} }
RET_ERR(db->handle, PM_ERR_DB_OPEN, -1); RET_ERR(db->handle, ALPM_ERR_DB_OPEN, -1);
} }
if(fstat(dirfd(dbdir), &buf) != 0) { if(fstat(dirfd(dbdir), &buf) != 0) {
RET_ERR(db->handle, PM_ERR_DB_OPEN, -1); RET_ERR(db->handle, ALPM_ERR_DB_OPEN, -1);
} }
if(buf.st_nlink >= 2) { if(buf.st_nlink >= 2) {
est_count = buf.st_nlink; est_count = buf.st_nlink;
@ -419,7 +419,7 @@ static int local_db_populate(alpm_db_t *db)
db->pkgcache = _alpm_pkghash_create(est_count * 2); db->pkgcache = _alpm_pkghash_create(est_count * 2);
if(db->pkgcache == NULL){ if(db->pkgcache == NULL){
closedir(dbdir); closedir(dbdir);
RET_ERR(db->handle, PM_ERR_MEMORY, -1); RET_ERR(db->handle, ALPM_ERR_MEMORY, -1);
} }
while((ent = readdir(dbdir)) != NULL) { while((ent = readdir(dbdir)) != NULL) {
@ -437,12 +437,12 @@ static int local_db_populate(alpm_db_t *db)
pkg = _alpm_pkg_new(); pkg = _alpm_pkg_new();
if(pkg == NULL) { if(pkg == NULL) {
closedir(dbdir); closedir(dbdir);
RET_ERR(db->handle, PM_ERR_MEMORY, -1); RET_ERR(db->handle, ALPM_ERR_MEMORY, -1);
} }
/* split the db entry name */ /* split the db entry name */
if(_alpm_splitname(name, &(pkg->name), &(pkg->version), if(_alpm_splitname(name, &(pkg->name), &(pkg->version),
&(pkg->name_hash)) != 0) { &(pkg->name_hash)) != 0) {
_alpm_log(db->handle, PM_LOG_ERROR, _("invalid name for database entry '%s'\n"), _alpm_log(db->handle, ALPM_LOG_ERROR, _("invalid name for database entry '%s'\n"),
name); name);
_alpm_pkg_free(pkg); _alpm_pkg_free(pkg);
continue; continue;
@ -450,7 +450,7 @@ static int local_db_populate(alpm_db_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(db->handle, PM_LOG_ERROR, _("duplicated database entry '%s'\n"), pkg->name); _alpm_log(db->handle, ALPM_LOG_ERROR, _("duplicated database entry '%s'\n"), pkg->name);
_alpm_pkg_free(pkg); _alpm_pkg_free(pkg);
continue; continue;
} }
@ -462,13 +462,13 @@ static int local_db_populate(alpm_db_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(local_db_read(pkg, INFRQ_BASE) == -1) { if(local_db_read(pkg, INFRQ_BASE) == -1) {
_alpm_log(db->handle, PM_LOG_ERROR, _("corrupted database entry '%s'\n"), name); _alpm_log(db->handle, ALPM_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(db->handle, PM_LOG_FUNCTION, "adding '%s' to package cache for db '%s'\n", _alpm_log(db->handle, ALPM_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++;
@ -478,7 +478,7 @@ static int local_db_populate(alpm_db_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(db->handle, PM_LOG_DEBUG, "added %d packages to package cache for db '%s'\n", _alpm_log(db->handle, ALPM_LOG_DEBUG, "added %d packages to package cache for db '%s'\n",
count, db->treename); count, db->treename);
return count; return count;
@ -493,7 +493,7 @@ static char *get_pkgpath(alpm_db_t *db, alpm_pkg_t *info)
dbpath = _alpm_db_path(db); dbpath = _alpm_db_path(db);
len = strlen(dbpath) + strlen(info->name) + strlen(info->version) + 3; len = strlen(dbpath) + strlen(info->name) + strlen(info->version) + 3;
MALLOC(pkgpath, len, RET_ERR(db->handle, PM_ERR_MEMORY, NULL)); MALLOC(pkgpath, len, RET_ERR(db->handle, ALPM_ERR_MEMORY, NULL));
sprintf(pkgpath, "%s%s-%s/", dbpath, info->name, info->version); sprintf(pkgpath, "%s%s-%s/", dbpath, info->name, info->version);
return pkgpath; return pkgpath;
} }
@ -533,7 +533,7 @@ static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_t inforeq)
/* already loaded all of this info, do nothing */ /* already loaded all of this info, do nothing */
return 0; return 0;
} }
_alpm_log(db->handle, PM_LOG_FUNCTION, "loading package data for %s : level=0x%x\n", _alpm_log(db->handle, ALPM_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 */
@ -543,7 +543,7 @@ static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_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(db->handle, PM_LOG_DEBUG, "cannot find '%s-%s' in db '%s'\n", _alpm_log(db->handle, ALPM_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;
} }
@ -552,7 +552,7 @@ static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_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(db->handle, PM_LOG_ERROR, _("could not open file %s: %s\n"), path, strerror(errno)); _alpm_log(db->handle, ALPM_LOG_ERROR, _("could not open file %s: %s\n"), path, strerror(errno));
goto error; goto error;
} }
while(!feof(fp)) { while(!feof(fp)) {
@ -560,13 +560,13 @@ static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_t inforeq)
if(strcmp(line, "%NAME%") == 0) { if(strcmp(line, "%NAME%") == 0) {
READ_NEXT(); READ_NEXT();
if(strcmp(line, info->name) != 0) { if(strcmp(line, info->name) != 0) {
_alpm_log(db->handle, PM_LOG_ERROR, _("%s database is inconsistent: name " _alpm_log(db->handle, ALPM_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) {
READ_NEXT(); READ_NEXT();
if(strcmp(line, info->version) != 0) { if(strcmp(line, info->version) != 0) {
_alpm_log(db->handle, PM_LOG_ERROR, _("%s database is inconsistent: version " _alpm_log(db->handle, ALPM_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) {
@ -625,7 +625,7 @@ static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_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(db->handle, PM_LOG_ERROR, _("could not open file %s: %s\n"), path, strerror(errno)); _alpm_log(db->handle, ALPM_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)) {
@ -689,7 +689,7 @@ int _alpm_local_db_prepare(alpm_db_t *db, alpm_pkg_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(db->handle, PM_LOG_ERROR, _("could not create directory %s: %s\n"), _alpm_log(db->handle, ALPM_LOG_ERROR, _("could not create directory %s: %s\n"),
pkgpath, strerror(errno)); pkgpath, strerror(errno));
} }
@ -723,11 +723,11 @@ int _alpm_local_db_write(alpm_db_t *db, alpm_pkg_t *info, alpm_dbinfrq_t inforeq
/* DESC */ /* DESC */
if(inforeq & INFRQ_DESC) { if(inforeq & INFRQ_DESC) {
_alpm_log(db->handle, PM_LOG_DEBUG, "writing %s-%s DESC information back to db\n", _alpm_log(db->handle, ALPM_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(db->handle, PM_LOG_ERROR, _("could not open file %s: %s\n"), _alpm_log(db->handle, ALPM_LOG_ERROR, _("could not open file %s: %s\n"),
path, strerror(errno)); path, strerror(errno));
retval = -1; retval = -1;
goto cleanup; goto cleanup;
@ -825,11 +825,11 @@ int _alpm_local_db_write(alpm_db_t *db, alpm_pkg_t *info, alpm_dbinfrq_t inforeq
/* FILES */ /* FILES */
if(inforeq & INFRQ_FILES) { if(inforeq & INFRQ_FILES) {
_alpm_log(db->handle, PM_LOG_DEBUG, "writing %s-%s FILES information back to db\n", _alpm_log(db->handle, ALPM_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(db->handle, PM_LOG_ERROR, _("could not open file %s: %s\n"), _alpm_log(db->handle, ALPM_LOG_ERROR, _("could not open file %s: %s\n"),
path, strerror(errno)); path, strerror(errno));
retval = -1; retval = -1;
goto cleanup; goto cleanup;
@ -893,11 +893,11 @@ alpm_db_t *_alpm_db_register_local(alpm_handle_t *handle)
{ {
alpm_db_t *db; alpm_db_t *db;
_alpm_log(handle, PM_LOG_DEBUG, "registering local database\n"); _alpm_log(handle, ALPM_LOG_DEBUG, "registering local database\n");
db = _alpm_db_new("local", 1); db = _alpm_db_new("local", 1);
if(db == NULL) { if(db == NULL) {
handle->pm_errno = PM_ERR_DB_CREATE; handle->pm_errno = ALPM_ERR_DB_CREATE;
return NULL; return NULL;
} }
db->ops = &local_db_ops; db->ops = &local_db_ops;

View File

@ -52,7 +52,7 @@ static void *_package_changelog_open(alpm_pkg_t *pkg)
const char *pkgfile = pkg->origin_data.file; const char *pkgfile = pkg->origin_data.file;
if((archive = archive_read_new()) == NULL) { if((archive = archive_read_new()) == NULL) {
RET_ERR(pkg->handle, PM_ERR_LIBARCHIVE, NULL); RET_ERR(pkg->handle, ALPM_ERR_LIBARCHIVE, NULL);
} }
archive_read_support_compression_all(archive); archive_read_support_compression_all(archive);
@ -60,7 +60,7 @@ static void *_package_changelog_open(alpm_pkg_t *pkg)
if(archive_read_open_filename(archive, pkgfile, if(archive_read_open_filename(archive, pkgfile,
ARCHIVE_DEFAULT_BYTES_PER_BLOCK) != ARCHIVE_OK) { ARCHIVE_DEFAULT_BYTES_PER_BLOCK) != ARCHIVE_OK) {
RET_ERR(pkg->handle, PM_ERR_PKG_OPEN, NULL); RET_ERR(pkg->handle, ALPM_ERR_PKG_OPEN, NULL);
} }
while(archive_read_next_header(archive, &entry) == ARCHIVE_OK) { while(archive_read_next_header(archive, &entry) == ARCHIVE_OK) {
@ -92,7 +92,7 @@ static size_t _package_changelog_read(void *ptr, size_t size,
ssize_t sret = archive_read_data((struct archive *)fp, ptr, size); ssize_t sret = archive_read_data((struct archive *)fp, ptr, size);
/* Report error (negative values) */ /* Report error (negative values) */
if(sret < 0) { if(sret < 0) {
RET_ERR(pkg->handle, PM_ERR_LIBARCHIVE, 0); RET_ERR(pkg->handle, ALPM_ERR_LIBARCHIVE, 0);
} else { } else {
return (size_t)sret; return (size_t)sret;
} }
@ -158,7 +158,7 @@ static int parse_descfile(alpm_handle_t *handle, struct archive *a, alpm_pkg_t *
ptr = line; ptr = line;
key = strsep(&ptr, "="); key = strsep(&ptr, "=");
if(key == NULL || ptr == NULL) { if(key == NULL || ptr == NULL) {
_alpm_log(handle, PM_LOG_DEBUG, "%s: syntax error in description file line %d\n", _alpm_log(handle, ALPM_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);
@ -209,14 +209,14 @@ static int parse_descfile(alpm_handle_t *handle, struct archive *a, alpm_pkg_t *
} else if(strcmp(key, "makepkgopt") == 0) { } else if(strcmp(key, "makepkgopt") == 0) {
/* not used atm */ /* not used atm */
} else { } else {
_alpm_log(handle, PM_LOG_DEBUG, "%s: unknown key '%s' in description file line %d\n", _alpm_log(handle, ALPM_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(handle, PM_LOG_DEBUG, "error parsing package descfile\n"); _alpm_log(handle, ALPM_LOG_DEBUG, "error parsing package descfile\n");
return -1; return -1;
} }
@ -244,47 +244,47 @@ alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle, const char *pkgfile,
size_t files_count = 0; size_t files_count = 0;
if(pkgfile == NULL || strlen(pkgfile) == 0) { if(pkgfile == NULL || strlen(pkgfile) == 0) {
RET_ERR(handle, PM_ERR_WRONG_ARGS, NULL); RET_ERR(handle, ALPM_ERR_WRONG_ARGS, NULL);
} }
/* attempt to stat the package file, ensure it exists */ /* attempt to stat the package file, ensure it exists */
if(stat(pkgfile, &st) == 0) { if(stat(pkgfile, &st) == 0) {
newpkg = _alpm_pkg_new(); newpkg = _alpm_pkg_new();
if(newpkg == NULL) { if(newpkg == NULL) {
RET_ERR(handle, PM_ERR_MEMORY, NULL); RET_ERR(handle, ALPM_ERR_MEMORY, NULL);
} }
newpkg->filename = strdup(pkgfile); newpkg->filename = strdup(pkgfile);
newpkg->size = st.st_size; newpkg->size = st.st_size;
} else { } else {
/* couldn't stat the pkgfile, return an error */ /* couldn't stat the pkgfile, return an error */
RET_ERR(handle, PM_ERR_PKG_OPEN, NULL); RET_ERR(handle, ALPM_ERR_PKG_OPEN, NULL);
} }
/* first steps- validate the package file */ /* first steps- validate the package file */
_alpm_log(handle, PM_LOG_DEBUG, "md5sum: %s\n", md5sum); _alpm_log(handle, ALPM_LOG_DEBUG, "md5sum: %s\n", md5sum);
if(md5sum) { if(md5sum) {
_alpm_log(handle, PM_LOG_DEBUG, "checking md5sum for %s\n", pkgfile); _alpm_log(handle, ALPM_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, ALPM_ERR_PKG_INVALID, NULL);
} }
} }
_alpm_log(handle, PM_LOG_DEBUG, "base64_sig: %s\n", base64_sig); _alpm_log(handle, ALPM_LOG_DEBUG, "base64_sig: %s\n", base64_sig);
if(check_sig != PM_PGP_VERIFY_NEVER) { if(check_sig != PM_PGP_VERIFY_NEVER) {
_alpm_log(handle, PM_LOG_DEBUG, "checking signature for %s\n", pkgfile); _alpm_log(handle, ALPM_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)) {
alpm_pkg_free(newpkg); alpm_pkg_free(newpkg);
RET_ERR(handle, PM_ERR_SIG_INVALID, NULL); RET_ERR(handle, ALPM_ERR_SIG_INVALID, NULL);
} }
} }
/* next- try to create an archive object to read in the package */ /* next- try to create an archive object to read in the package */
if((archive = archive_read_new()) == NULL) { if((archive = archive_read_new()) == NULL) {
alpm_pkg_free(newpkg); alpm_pkg_free(newpkg);
RET_ERR(handle, PM_ERR_LIBARCHIVE, NULL); RET_ERR(handle, ALPM_ERR_LIBARCHIVE, NULL);
} }
archive_read_support_compression_all(archive); archive_read_support_compression_all(archive);
@ -293,10 +293,10 @@ alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle, const char *pkgfile,
if(archive_read_open_filename(archive, pkgfile, if(archive_read_open_filename(archive, pkgfile,
ARCHIVE_DEFAULT_BYTES_PER_BLOCK) != ARCHIVE_OK) { ARCHIVE_DEFAULT_BYTES_PER_BLOCK) != ARCHIVE_OK) {
alpm_pkg_free(newpkg); alpm_pkg_free(newpkg);
RET_ERR(handle, PM_ERR_PKG_OPEN, NULL); RET_ERR(handle, ALPM_ERR_PKG_OPEN, NULL);
} }
_alpm_log(handle, PM_LOG_DEBUG, "starting package load for %s\n", pkgfile); _alpm_log(handle, ALPM_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
@ -307,16 +307,16 @@ alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_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(handle, archive, newpkg) != 0) { if(parse_descfile(handle, archive, newpkg) != 0) {
_alpm_log(handle, PM_LOG_ERROR, _("could not parse package description file in %s\n"), _alpm_log(handle, ALPM_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(handle, PM_LOG_ERROR, _("missing package name in %s\n"), pkgfile); _alpm_log(handle, ALPM_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(handle, PM_LOG_ERROR, _("missing package version in %s\n"), pkgfile); _alpm_log(handle, ALPM_LOG_ERROR, _("missing package version in %s\n"), pkgfile);
goto pkg_invalid; goto pkg_invalid;
} }
config = 1; config = 1;
@ -338,9 +338,9 @@ alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle, const char *pkgfile,
} }
if(archive_read_data_skip(archive)) { if(archive_read_data_skip(archive)) {
_alpm_log(handle, PM_LOG_ERROR, _("error while reading package %s: %s\n"), _alpm_log(handle, ALPM_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 = ALPM_ERR_LIBARCHIVE;
goto error; goto error;
} }
@ -351,14 +351,14 @@ alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_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(handle, PM_LOG_ERROR, _("error while reading package %s: %s\n"), _alpm_log(handle, ALPM_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 = ALPM_ERR_LIBARCHIVE;
goto error; goto error;
} }
if(!config) { if(!config) {
_alpm_log(handle, PM_LOG_ERROR, _("missing package metadata in %s\n"), pkgfile); _alpm_log(handle, ALPM_LOG_ERROR, _("missing package metadata in %s\n"), pkgfile);
goto pkg_invalid; goto pkg_invalid;
} }
@ -372,7 +372,7 @@ alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_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(handle, PM_LOG_DEBUG, "sorting package filelist for %s\n", pkgfile); _alpm_log(handle, ALPM_LOG_DEBUG, "sorting package filelist for %s\n", pkgfile);
newpkg->files = alpm_list_msort(newpkg->files, files_count, newpkg->files = alpm_list_msort(newpkg->files, files_count,
_alpm_files_cmp); _alpm_files_cmp);
newpkg->infolevel = INFRQ_ALL; newpkg->infolevel = INFRQ_ALL;
@ -387,7 +387,7 @@ alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle, const char *pkgfile,
return newpkg; return newpkg;
pkg_invalid: pkg_invalid:
handle->pm_errno = PM_ERR_PKG_INVALID; handle->pm_errno = ALPM_ERR_PKG_INVALID;
error: error:
_alpm_pkg_free(newpkg); _alpm_pkg_free(newpkg);
archive_read_finish(archive); archive_read_finish(archive);
@ -399,7 +399,7 @@ int SYMEXPORT alpm_pkg_load(alpm_handle_t *handle, const char *filename, int ful
pgp_verify_t check_sig, alpm_pkg_t **pkg) pgp_verify_t check_sig, alpm_pkg_t **pkg)
{ {
CHECK_HANDLE(handle, return -1); CHECK_HANDLE(handle, return -1);
ASSERT(pkg != NULL, RET_ERR(handle, PM_ERR_WRONG_ARGS, -1)); ASSERT(pkg != NULL, RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1));
*pkg = _alpm_pkg_load_internal(handle, filename, full, NULL, NULL, check_sig); *pkg = _alpm_pkg_load_internal(handle, filename, full, NULL, NULL, check_sig);
if(*pkg == NULL) { if(*pkg == NULL) {

View File

@ -46,21 +46,21 @@ static char *get_sync_dir(alpm_handle_t *handle)
char *syncpath; char *syncpath;
struct stat buf; struct stat buf;
MALLOC(syncpath, len, RET_ERR(handle, PM_ERR_MEMORY, NULL)); MALLOC(syncpath, len, RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
sprintf(syncpath, "%s%s", dbpath, "sync/"); sprintf(syncpath, "%s%s", dbpath, "sync/");
if(stat(syncpath, &buf) != 0) { if(stat(syncpath, &buf) != 0) {
_alpm_log(handle, PM_LOG_DEBUG, "database dir '%s' does not exist, creating it\n", _alpm_log(handle, ALPM_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, NULL); RET_ERR(handle, ALPM_ERR_SYSTEM, NULL);
} }
} else if(!S_ISDIR(buf.st_mode)) { } else if(!S_ISDIR(buf.st_mode)) {
_alpm_log(handle, PM_LOG_WARNING, _("removing invalid file: %s\n"), syncpath); _alpm_log(handle, ALPM_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, NULL); RET_ERR(handle, ALPM_ERR_SYSTEM, NULL);
} }
} }
@ -93,12 +93,12 @@ static int sync_db_validate(alpm_db_t *db)
return 0; return 0;
} }
_alpm_log(db->handle, PM_LOG_DEBUG, "checking signature for %s\n", _alpm_log(db->handle, ALPM_LOG_DEBUG, "checking signature for %s\n",
db->treename); db->treename);
ret = _alpm_gpgme_checksig(db->handle, dbpath, NULL); ret = _alpm_gpgme_checksig(db->handle, dbpath, NULL);
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)) {
RET_ERR(db->handle, PM_ERR_SIG_INVALID, -1); RET_ERR(db->handle, ALPM_ERR_SIG_INVALID, -1);
} }
} }
@ -155,8 +155,8 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
ASSERT(db != NULL, return -1); ASSERT(db != NULL, return -1);
handle = db->handle; handle = db->handle;
handle->pm_errno = 0; handle->pm_errno = 0;
ASSERT(db != handle->db_local, RET_ERR(handle, PM_ERR_WRONG_ARGS, -1)); ASSERT(db != handle->db_local, RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1));
ASSERT(db->servers != NULL, RET_ERR(handle, PM_ERR_SERVER_NONE, -1)); ASSERT(db->servers != NULL, RET_ERR(handle, ALPM_ERR_SERVER_NONE, -1));
syncpath = get_sync_dir(handle); syncpath = get_sync_dir(handle);
if(!syncpath) { if(!syncpath) {
@ -170,7 +170,7 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
/* attempt to grab a lock */ /* attempt to grab a lock */
if(_alpm_handle_lock(handle)) { if(_alpm_handle_lock(handle)) {
RET_ERR(handle, PM_ERR_HANDLE_LOCK, -1); RET_ERR(handle, ALPM_ERR_HANDLE_LOCK, -1);
} }
for(i = db->servers; i; i = i->next) { for(i = db->servers; i; i = i->next) {
@ -181,7 +181,7 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
/* print server + filename into a buffer (leave space for .sig) */ /* print server + filename into a buffer (leave space for .sig) */
len = strlen(server) + strlen(db->treename) + 9; len = strlen(server) + strlen(db->treename) + 9;
CALLOC(fileurl, len, sizeof(char), RET_ERR(handle, PM_ERR_MEMORY, -1)); CALLOC(fileurl, len, sizeof(char), RET_ERR(handle, ALPM_ERR_MEMORY, -1));
snprintf(fileurl, len, "%s/%s.db", server, db->treename); snprintf(fileurl, len, "%s/%s.db", server, db->treename);
ret = _alpm_download(handle, fileurl, syncpath, force, 0, 0); ret = _alpm_download(handle, fileurl, syncpath, force, 0, 0);
@ -218,7 +218,7 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_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(handle, PM_LOG_DEBUG, "failed to sync db: %s\n", _alpm_log(handle, ALPM_LOG_DEBUG, "failed to sync db: %s\n",
alpm_strerror(handle->pm_errno)); alpm_strerror(handle->pm_errno));
goto cleanup; goto cleanup;
} }
@ -235,7 +235,7 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
cleanup: cleanup:
if(_alpm_handle_unlock(handle)) { if(_alpm_handle_unlock(handle)) {
_alpm_log(handle, PM_LOG_WARNING, _("could not remove lock file %s\n"), _alpm_log(handle, ALPM_LOG_WARNING, _("could not remove lock file %s\n"),
alpm_option_get_lockfile(handle)); alpm_option_get_lockfile(handle));
} }
free(syncpath); free(syncpath);
@ -264,7 +264,7 @@ static alpm_pkg_t *load_pkg_for_entry(alpm_db_t *db, const char *entryname,
} }
} }
if(_alpm_splitname(entryname, &pkgname, &pkgver, &pkgname_hash) != 0) { if(_alpm_splitname(entryname, &pkgname, &pkgver, &pkgname_hash) != 0) {
_alpm_log(db->handle, PM_LOG_ERROR, _alpm_log(db->handle, ALPM_LOG_ERROR,
_("invalid name for database entry '%s'\n"), entryname); _("invalid name for database entry '%s'\n"), entryname);
return NULL; return NULL;
} }
@ -277,7 +277,7 @@ static alpm_pkg_t *load_pkg_for_entry(alpm_db_t *db, const char *entryname,
if(pkg == NULL) { if(pkg == NULL) {
pkg = _alpm_pkg_new(); pkg = _alpm_pkg_new();
if(pkg == NULL) { if(pkg == NULL) {
RET_ERR(db->handle, PM_ERR_MEMORY, NULL); RET_ERR(db->handle, ALPM_ERR_MEMORY, NULL);
} }
pkg->name = pkgname; pkg->name = pkgname;
@ -290,7 +290,7 @@ static alpm_pkg_t *load_pkg_for_entry(alpm_db_t *db, const char *entryname,
pkg->handle = db->handle; pkg->handle = db->handle;
/* add to the collection */ /* add to the collection */
_alpm_log(db->handle, PM_LOG_FUNCTION, "adding '%s' to package cache for db '%s'\n", _alpm_log(db->handle, ALPM_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);
} else { } else {
@ -371,7 +371,7 @@ static int sync_db_populate(alpm_db_t *db)
alpm_pkg_t *pkg = NULL; alpm_pkg_t *pkg = NULL;
if((archive = archive_read_new()) == NULL) { if((archive = archive_read_new()) == NULL) {
RET_ERR(db->handle, PM_ERR_LIBARCHIVE, -1); RET_ERR(db->handle, ALPM_ERR_LIBARCHIVE, -1);
} }
archive_read_support_compression_all(archive); archive_read_support_compression_all(archive);
@ -383,24 +383,24 @@ static int sync_db_populate(alpm_db_t *db)
return -1; return -1;
} }
_alpm_log(db->handle, PM_LOG_DEBUG, "opening database archive %s\n", dbpath); _alpm_log(db->handle, ALPM_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(db->handle, PM_LOG_ERROR, _("could not open file %s: %s\n"), dbpath, _alpm_log(db->handle, ALPM_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, ALPM_ERR_DB_OPEN, -1);
} }
if(stat(dbpath, &buf) != 0) { if(stat(dbpath, &buf) != 0) {
RET_ERR(db->handle, PM_ERR_DB_OPEN, -1); RET_ERR(db->handle, ALPM_ERR_DB_OPEN, -1);
} }
est_count = estimate_package_count(&buf, archive); est_count = estimate_package_count(&buf, archive);
/* initialize hash at 66% full */ /* initialize hash at 66% full */
db->pkgcache = _alpm_pkghash_create(est_count * 3 / 2); db->pkgcache = _alpm_pkghash_create(est_count * 3 / 2);
if(db->pkgcache == NULL) { if(db->pkgcache == NULL) {
RET_ERR(db->handle, PM_ERR_MEMORY, -1); RET_ERR(db->handle, ALPM_ERR_MEMORY, -1);
} }
while(archive_read_next_header(archive, &entry) == ARCHIVE_OK) { while(archive_read_next_header(archive, &entry) == ARCHIVE_OK) {
@ -413,7 +413,7 @@ static int sync_db_populate(alpm_db_t *db)
} 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(db->handle, PM_LOG_ERROR, _alpm_log(db->handle, ALPM_LOG_ERROR,
_("could not parse package description file '%s' from db '%s'\n"), _("could not parse package description file '%s' from db '%s'\n"),
archive_entry_pathname(entry), db->treename); archive_entry_pathname(entry), db->treename);
continue; continue;
@ -427,7 +427,7 @@ static int sync_db_populate(alpm_db_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(db->handle, PM_LOG_DEBUG, "added %d packages to package cache for db '%s'\n", _alpm_log(db->handle, ALPM_LOG_DEBUG, "added %d packages to package cache for db '%s'\n",
count, db->treename); count, db->treename);
return count; return count;
@ -460,12 +460,12 @@ static int sync_db_read(alpm_db_t *db, struct archive *archive,
entryname = archive_entry_pathname(entry); entryname = archive_entry_pathname(entry);
if(entryname == NULL) { if(entryname == NULL) {
_alpm_log(db->handle, PM_LOG_DEBUG, _alpm_log(db->handle, ALPM_LOG_DEBUG,
"invalid archive entry provided to _alpm_sync_db_read, skipping\n"); "invalid archive entry provided to _alpm_sync_db_read, skipping\n");
return -1; return -1;
} }
_alpm_log(db->handle, PM_LOG_FUNCTION, "loading package data from archive entry %s\n", _alpm_log(db->handle, ALPM_LOG_FUNCTION, "loading package data from archive entry %s\n",
entryname); entryname);
memset(&buf, 0, sizeof(buf)); memset(&buf, 0, sizeof(buf));
@ -475,7 +475,7 @@ static int sync_db_read(alpm_db_t *db, struct archive *archive,
pkg = load_pkg_for_entry(db, entryname, &filename, *likely_pkg); pkg = load_pkg_for_entry(db, entryname, &filename, *likely_pkg);
if(pkg == NULL) { if(pkg == NULL) {
_alpm_log(db->handle, PM_LOG_DEBUG, _alpm_log(db->handle, ALPM_LOG_DEBUG,
"entry %s could not be loaded into %s sync database", "entry %s could not be loaded into %s sync database",
entryname, db->treename); entryname, db->treename);
return -1; return -1;
@ -490,13 +490,13 @@ static int sync_db_read(alpm_db_t *db, struct archive *archive,
if(strcmp(line, "%NAME%") == 0) { if(strcmp(line, "%NAME%") == 0) {
READ_NEXT(); READ_NEXT();
if(strcmp(line, pkg->name) != 0) { if(strcmp(line, pkg->name) != 0) {
_alpm_log(db->handle, PM_LOG_ERROR, _("%s database is inconsistent: name " _alpm_log(db->handle, ALPM_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(); READ_NEXT();
if(strcmp(line, pkg->version) != 0) { if(strcmp(line, pkg->version) != 0) {
_alpm_log(db->handle, PM_LOG_ERROR, _("%s database is inconsistent: version " _alpm_log(db->handle, ALPM_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) {
@ -569,13 +569,13 @@ static int sync_db_read(alpm_db_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(db->handle, PM_LOG_DEBUG, "unknown database file: %s\n", filename); _alpm_log(db->handle, ALPM_LOG_DEBUG, "unknown database file: %s\n", filename);
} }
return 0; return 0;
error: error:
_alpm_log(db->handle, PM_LOG_DEBUG, "error parsing database file: %s\n", filename); _alpm_log(db->handle, ALPM_LOG_DEBUG, "error parsing database file: %s\n", filename);
return -1; return -1;
} }
@ -590,11 +590,11 @@ alpm_db_t *_alpm_db_register_sync(alpm_handle_t *handle, const char *treename,
{ {
alpm_db_t *db; alpm_db_t *db;
_alpm_log(handle, PM_LOG_DEBUG, "registering sync database '%s'\n", treename); _alpm_log(handle, ALPM_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) {
RET_ERR(handle, PM_ERR_DB_CREATE, NULL); RET_ERR(handle, ALPM_ERR_DB_CREATE, NULL);
} }
db->ops = &sync_db_ops; db->ops = &sync_db_ops;
db->handle = handle; db->handle = handle;

View File

@ -108,7 +108,7 @@ static int add_conflict(alpm_handle_t *handle, alpm_list_t **baddeps,
if(!conflict) { if(!conflict) {
return -1; return -1;
} }
_alpm_log(handle, PM_LOG_DEBUG, "package %s conflicts with %s (by %s)\n", _alpm_log(handle, ALPM_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);
@ -175,7 +175,7 @@ alpm_list_t *_alpm_innerconflicts(alpm_handle_t *handle, alpm_list_t *packages)
{ {
alpm_list_t *baddeps = NULL; alpm_list_t *baddeps = NULL;
_alpm_log(handle, PM_LOG_DEBUG, "check targets vs targets\n"); _alpm_log(handle, ALPM_LOG_DEBUG, "check targets vs targets\n");
check_conflict(handle, packages, packages, &baddeps, 0); check_conflict(handle, packages, packages, &baddeps, 0);
return baddeps; return baddeps;
@ -197,9 +197,9 @@ alpm_list_t *_alpm_outerconflicts(alpm_db_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(db->handle, PM_LOG_DEBUG, "check targets vs db\n"); _alpm_log(db->handle, ALPM_LOG_DEBUG, "check targets vs db\n");
check_conflict(db->handle, packages, dblist, &baddeps, 1); check_conflict(db->handle, packages, dblist, &baddeps, 1);
_alpm_log(db->handle, PM_LOG_DEBUG, "check db vs targets\n"); _alpm_log(db->handle, ALPM_LOG_DEBUG, "check db vs targets\n");
check_conflict(db->handle, dblist, packages, &baddeps, -1); check_conflict(db->handle, dblist, packages, &baddeps, -1);
alpm_list_free(dblist); alpm_list_free(dblist);
@ -281,7 +281,7 @@ static alpm_list_t *filelist_operation(alpm_list_t *filesA, alpm_list_t *filesB,
} }
/* Adds alpm_fileconflict_t to a conflicts list. Pass the conflicts list, type /* Adds alpm_fileconflict_t to a conflicts list. Pass the conflicts list, type
* (either PM_FILECONFLICT_TARGET or PM_FILECONFLICT_FILESYSTEM), a file * (either ALPM_FILECONFLICT_TARGET or ALPM_FILECONFLICT_FILESYSTEM), a file
* string, and either two package names or one package name and NULL. This is * string, and either two package names or one package name and NULL. This is
* a wrapper for former functionality that was done inline. * a wrapper for former functionality that was done inline.
*/ */
@ -302,13 +302,13 @@ static alpm_list_t *add_fileconflict(alpm_handle_t *handle,
} }
conflicts = alpm_list_add(conflicts, conflict); conflicts = alpm_list_add(conflicts, conflict);
_alpm_log(handle, PM_LOG_DEBUG, "found file conflict %s, packages %s and %s\n", _alpm_log(handle, ALPM_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;
error: error:
RET_ERR(handle, PM_ERR_MEMORY, conflicts); RET_ERR(handle, ALPM_ERR_MEMORY, conflicts);
} }
void _alpm_fileconflict_free(alpm_fileconflict_t *conflict) void _alpm_fileconflict_free(alpm_fileconflict_t *conflict)
@ -404,10 +404,10 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
alpm_pkg_t *dbpkg; alpm_pkg_t *dbpkg;
int percent = (current * 100) / numtargs; int percent = (current * 100) / numtargs;
PROGRESS(trans, PM_TRANS_PROGRESS_CONFLICTS_START, "", percent, PROGRESS(trans, ALPM_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(handle, PM_LOG_DEBUG, "searching for file conflicts: %s\n", _alpm_log(handle, ALPM_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) {
alpm_list_t *common_files; alpm_list_t *common_files;
@ -421,9 +421,9 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
for(k = common_files; k; k = k->next) { for(k = common_files; 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(handle, conflicts, conflicts = add_fileconflict(handle, conflicts,
PM_FILECONFLICT_TARGET, path, ALPM_FILECONFLICT_TARGET, path,
alpm_pkg_get_name(p1), alpm_pkg_get_name(p2)); alpm_pkg_get_name(p1), alpm_pkg_get_name(p2));
if(handle->pm_errno == PM_ERR_MEMORY) { if(handle->pm_errno == ALPM_ERR_MEMORY) {
FREELIST(conflicts); FREELIST(conflicts);
FREELIST(common_files); FREELIST(common_files);
return NULL; return NULL;
@ -434,7 +434,7 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
} }
/* CHECK 2: check every target against the filesystem */ /* CHECK 2: check every target against the filesystem */
_alpm_log(handle, PM_LOG_DEBUG, "searching for filesystem conflicts: %s\n", _alpm_log(handle, ALPM_LOG_DEBUG, "searching for filesystem conflicts: %s\n",
p1->name); p1->name);
dbpkg = _alpm_db_get_pkgfromcache(handle->db_local, p1->name); dbpkg = _alpm_db_get_pkgfromcache(handle->db_local, p1->name);
@ -472,12 +472,12 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
if(S_ISDIR(file->mode)) { if(S_ISDIR(file->mode)) {
struct stat sbuf; struct stat sbuf;
if(S_ISDIR(lsbuf.st_mode)) { if(S_ISDIR(lsbuf.st_mode)) {
_alpm_log(handle, PM_LOG_DEBUG, "%s is a directory, not a conflict\n", path); _alpm_log(handle, ALPM_LOG_DEBUG, "%s is a directory, not a conflict\n", path);
continue; continue;
} }
stat(path, &sbuf); stat(path, &sbuf);
if(S_ISLNK(lsbuf.st_mode) && S_ISDIR(sbuf.st_mode)) { if(S_ISLNK(lsbuf.st_mode) && S_ISDIR(sbuf.st_mode)) {
_alpm_log(handle, PM_LOG_DEBUG, _alpm_log(handle, ALPM_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;
} }
@ -487,7 +487,7 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
path[strlen(path) - 1] = '\0'; path[strlen(path) - 1] = '\0';
} }
_alpm_log(handle, PM_LOG_DEBUG, "checking possible conflict: %s\n", path); _alpm_log(handle, ALPM_LOG_DEBUG, "checking possible conflict: %s\n", path);
relative_path = path + strlen(handle->root); relative_path = path + strlen(handle->root);
/* Check remove list (will we remove the conflicting local file?) */ /* Check remove list (will we remove the conflicting local file?) */
@ -495,7 +495,7 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
alpm_pkg_t *rempkg = k->data; alpm_pkg_t *rempkg = k->data;
if(rempkg && _alpm_filelist_contains(alpm_pkg_get_files(rempkg), if(rempkg && _alpm_filelist_contains(alpm_pkg_get_files(rempkg),
relative_path)) { relative_path)) {
_alpm_log(handle, PM_LOG_DEBUG, _alpm_log(handle, ALPM_LOG_DEBUG,
"local file will be removed, not a conflict: %s\n", path); "local file will be removed, not a conflict: %s\n", path);
resolved_conflict = 1; resolved_conflict = 1;
} }
@ -516,7 +516,7 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_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(handle, PM_LOG_DEBUG, _alpm_log(handle, ALPM_LOG_DEBUG,
"file changed packages, adding to remove skiplist: %s\n", path); "file changed packages, adding to remove skiplist: %s\n", path);
resolved_conflict = 1; resolved_conflict = 1;
} }
@ -527,7 +527,7 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
char *dir = malloc(strlen(filestr) + 2); char *dir = malloc(strlen(filestr) + 2);
sprintf(dir, "%s/", filestr); sprintf(dir, "%s/", filestr);
if(_alpm_filelist_contains(alpm_pkg_get_files(dbpkg), dir)) { if(_alpm_filelist_contains(alpm_pkg_get_files(dbpkg), dir)) {
_alpm_log(handle, PM_LOG_DEBUG, _alpm_log(handle, ALPM_LOG_DEBUG,
"check if all files in %s belongs to %s\n", "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);
@ -551,8 +551,8 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
if(!resolved_conflict) { if(!resolved_conflict) {
conflicts = add_fileconflict(handle, conflicts, conflicts = add_fileconflict(handle, conflicts,
PM_FILECONFLICT_FILESYSTEM, path, p1->name, NULL); ALPM_FILECONFLICT_FILESYSTEM, path, p1->name, NULL);
if(handle->pm_errno == PM_ERR_MEMORY) { if(handle->pm_errno == ALPM_ERR_MEMORY) {
FREELIST(conflicts); FREELIST(conflicts);
if(dbpkg) { if(dbpkg) {
/* only freed if it was generated from filelist_operation() */ /* only freed if it was generated from filelist_operation() */
@ -567,7 +567,7 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
alpm_list_free(tmpfiles); alpm_list_free(tmpfiles);
} }
} }
PROGRESS(trans, PM_TRANS_PROGRESS_CONFLICTS_START, "", 100, PROGRESS(trans, ALPM_TRANS_PROGRESS_CONFLICTS_START, "", 100,
numtargs, current); numtargs, current);
return conflicts; return conflicts;

View File

@ -51,9 +51,9 @@ alpm_db_t SYMEXPORT *alpm_db_register_sync(alpm_handle_t *handle, const char *tr
/* Sanity checks */ /* Sanity checks */
CHECK_HANDLE(handle, return NULL); CHECK_HANDLE(handle, return NULL);
ASSERT(treename != NULL && strlen(treename) != 0, ASSERT(treename != NULL && strlen(treename) != 0,
RET_ERR(handle, PM_ERR_WRONG_ARGS, NULL)); RET_ERR(handle, ALPM_ERR_WRONG_ARGS, NULL));
/* Do not register a database if a transaction is on-going */ /* Do not register a database if a transaction is on-going */
ASSERT(handle->trans == NULL, RET_ERR(handle, PM_ERR_TRANS_NOT_NULL, NULL)); ASSERT(handle->trans == NULL, RET_ERR(handle, ALPM_ERR_TRANS_NOT_NULL, NULL));
return _alpm_db_register_sync(handle, treename, check_sig); return _alpm_db_register_sync(handle, treename, check_sig);
} }
@ -65,7 +65,7 @@ void _alpm_db_unregister(alpm_db_t *db)
return; return;
} }
_alpm_log(db->handle, PM_LOG_DEBUG, "unregistering database '%s'\n", db->treename); _alpm_log(db->handle, ALPM_LOG_DEBUG, "unregistering database '%s'\n", db->treename);
_alpm_db_free(db); _alpm_db_free(db);
} }
@ -78,7 +78,7 @@ int SYMEXPORT alpm_db_unregister_all(alpm_handle_t *handle)
/* Sanity checks */ /* Sanity checks */
CHECK_HANDLE(handle, return -1); CHECK_HANDLE(handle, return -1);
/* Do not unregister a database if a transaction is on-going */ /* Do not unregister a database if a transaction is on-going */
ASSERT(handle->trans == NULL, RET_ERR(handle, PM_ERR_TRANS_NOT_NULL, -1)); ASSERT(handle->trans == NULL, RET_ERR(handle, ALPM_ERR_TRANS_NOT_NULL, -1));
/* unregister all sync dbs */ /* unregister all sync dbs */
for(i = handle->dbs_sync; i; i = i->next) { for(i = handle->dbs_sync; i; i = i->next) {
@ -101,7 +101,7 @@ int SYMEXPORT alpm_db_unregister(alpm_db_t *db)
/* Do not unregister a database if a transaction is on-going */ /* Do not unregister a database if a transaction is on-going */
handle = db->handle; handle = db->handle;
handle->pm_errno = 0; handle->pm_errno = 0;
ASSERT(handle->trans == NULL, RET_ERR(handle, PM_ERR_TRANS_NOT_NULL, -1)); ASSERT(handle->trans == NULL, RET_ERR(handle, ALPM_ERR_TRANS_NOT_NULL, -1));
if(db == handle->db_local) { if(db == handle->db_local) {
handle->db_local = NULL; handle->db_local = NULL;
@ -120,7 +120,7 @@ int SYMEXPORT alpm_db_unregister(alpm_db_t *db)
} }
if(!found) { if(!found) {
RET_ERR(handle, PM_ERR_DB_NOT_FOUND, -1); RET_ERR(handle, ALPM_ERR_DB_NOT_FOUND, -1);
} }
db->ops->unregister(db); db->ops->unregister(db);
@ -168,14 +168,14 @@ int SYMEXPORT alpm_db_add_server(alpm_db_t *db, const char *url)
/* Sanity checks */ /* Sanity checks */
ASSERT(db != NULL, return -1); ASSERT(db != NULL, return -1);
db->handle->pm_errno = 0; db->handle->pm_errno = 0;
ASSERT(url != NULL && strlen(url) != 0, RET_ERR(db->handle, PM_ERR_WRONG_ARGS, -1)); ASSERT(url != NULL && strlen(url) != 0, RET_ERR(db->handle, ALPM_ERR_WRONG_ARGS, -1));
newurl = sanitize_url(url); newurl = sanitize_url(url);
if(!newurl) { if(!newurl) {
return -1; return -1;
} }
db->servers = alpm_list_add(db->servers, newurl); db->servers = alpm_list_add(db->servers, newurl);
_alpm_log(db->handle, PM_LOG_DEBUG, "adding new server URL to database '%s': %s\n", _alpm_log(db->handle, ALPM_LOG_DEBUG, "adding new server URL to database '%s': %s\n",
db->treename, newurl); db->treename, newurl);
return 0; return 0;
@ -194,7 +194,7 @@ int SYMEXPORT alpm_db_remove_server(alpm_db_t *db, const char *url)
/* Sanity checks */ /* Sanity checks */
ASSERT(db != NULL, return -1); ASSERT(db != NULL, return -1);
db->handle->pm_errno = 0; db->handle->pm_errno = 0;
ASSERT(url != NULL && strlen(url) != 0, RET_ERR(db->handle, PM_ERR_WRONG_ARGS, -1)); ASSERT(url != NULL && strlen(url) != 0, RET_ERR(db->handle, ALPM_ERR_WRONG_ARGS, -1));
newurl = sanitize_url(url); newurl = sanitize_url(url);
if(!newurl) { if(!newurl) {
@ -203,7 +203,7 @@ int SYMEXPORT alpm_db_remove_server(alpm_db_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(db->handle, PM_LOG_DEBUG, "removed server URL from database '%s': %s\n", _alpm_log(db->handle, ALPM_LOG_DEBUG, "removed server URL from database '%s': %s\n",
db->treename, newurl); db->treename, newurl);
free(vdata); free(vdata);
return 0; return 0;
@ -244,7 +244,7 @@ alpm_pkg_t SYMEXPORT *alpm_db_get_pkg(alpm_db_t *db, const char *name)
ASSERT(db != NULL, return NULL); ASSERT(db != NULL, return NULL);
db->handle->pm_errno = 0; db->handle->pm_errno = 0;
ASSERT(name != NULL && strlen(name) != 0, ASSERT(name != NULL && strlen(name) != 0,
RET_ERR(db->handle, PM_ERR_WRONG_ARGS, NULL)); RET_ERR(db->handle, ALPM_ERR_WRONG_ARGS, NULL));
return _alpm_db_get_pkgfromcache(db, name); return _alpm_db_get_pkgfromcache(db, name);
} }
@ -263,7 +263,7 @@ alpm_group_t SYMEXPORT *alpm_db_readgroup(alpm_db_t *db, const char *name)
ASSERT(db != NULL, return NULL); ASSERT(db != NULL, return NULL);
db->handle->pm_errno = 0; db->handle->pm_errno = 0;
ASSERT(name != NULL && strlen(name) != 0, ASSERT(name != NULL && strlen(name) != 0,
RET_ERR(db->handle, PM_ERR_WRONG_ARGS, NULL)); RET_ERR(db->handle, ALPM_ERR_WRONG_ARGS, NULL));
return _alpm_db_get_groupfromcache(db, name); return _alpm_db_get_groupfromcache(db, name);
} }
@ -292,14 +292,14 @@ int SYMEXPORT alpm_db_set_pkgreason(alpm_db_t *db, const char *name, alpm_pkgrea
ASSERT(db != NULL, return -1); ASSERT(db != NULL, return -1);
db->handle->pm_errno = 0; db->handle->pm_errno = 0;
/* TODO assert db == db_local ? shouldn't need a db param at all here... */ /* TODO assert db == db_local ? shouldn't need a db param at all here... */
ASSERT(name != NULL, RET_ERR(db->handle, PM_ERR_WRONG_ARGS, -1)); ASSERT(name != NULL, RET_ERR(db->handle, ALPM_ERR_WRONG_ARGS, -1));
alpm_pkg_t *pkg = _alpm_db_get_pkgfromcache(db, name); alpm_pkg_t *pkg = _alpm_db_get_pkgfromcache(db, name);
if(pkg == NULL) { if(pkg == NULL) {
RET_ERR(db->handle, PM_ERR_PKG_NOT_FOUND, -1); RET_ERR(db->handle, ALPM_ERR_PKG_NOT_FOUND, -1);
} }
_alpm_log(db->handle, PM_LOG_DEBUG, "setting install reason %u for %s/%s\n", reason, db->treename, name); _alpm_log(db->handle, ALPM_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;
@ -308,7 +308,7 @@ int SYMEXPORT alpm_db_set_pkgreason(alpm_db_t *db, const char *name, alpm_pkgrea
pkg->reason = reason; pkg->reason = reason;
/* write DESC */ /* write DESC */
if(_alpm_local_db_write(db, pkg, INFRQ_DESC)) { if(_alpm_local_db_write(db, pkg, INFRQ_DESC)) {
RET_ERR(db->handle, PM_ERR_DB_WRITE, -1); RET_ERR(db->handle, ALPM_ERR_DB_WRITE, -1);
} }
return 0; return 0;
@ -352,21 +352,21 @@ const char *_alpm_db_path(alpm_db_t *db)
dbpath = alpm_option_get_dbpath(db->handle); dbpath = alpm_option_get_dbpath(db->handle);
if(!dbpath) { if(!dbpath) {
_alpm_log(db->handle, PM_LOG_ERROR, _("database path is undefined\n")); _alpm_log(db->handle, ALPM_LOG_ERROR, _("database path is undefined\n"));
RET_ERR(db->handle, PM_ERR_DB_OPEN, NULL); RET_ERR(db->handle, ALPM_ERR_DB_OPEN, NULL);
} }
if(db->is_local) { if(db->is_local) {
pathsize = strlen(dbpath) + strlen(db->treename) + 2; pathsize = strlen(dbpath) + strlen(db->treename) + 2;
CALLOC(db->_path, 1, pathsize, RET_ERR(db->handle, PM_ERR_MEMORY, NULL)); CALLOC(db->_path, 1, pathsize, RET_ERR(db->handle, ALPM_ERR_MEMORY, NULL));
sprintf(db->_path, "%s%s/", dbpath, db->treename); sprintf(db->_path, "%s%s/", dbpath, db->treename);
} else { } else {
pathsize = strlen(dbpath) + 5 + strlen(db->treename) + 4; pathsize = strlen(dbpath) + 5 + strlen(db->treename) + 4;
CALLOC(db->_path, 1, pathsize, RET_ERR(db->handle, PM_ERR_MEMORY, NULL)); CALLOC(db->_path, 1, pathsize, RET_ERR(db->handle, ALPM_ERR_MEMORY, NULL));
/* 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(db->handle, PM_LOG_DEBUG, "database path for tree %s set to %s\n", _alpm_log(db->handle, ALPM_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;
@ -381,7 +381,7 @@ char *_alpm_db_sig_path(alpm_db_t *db)
return NULL; return NULL;
} }
len = strlen(dbfile) + strlen(".sig") + 1; len = strlen(dbfile) + strlen(".sig") + 1;
CALLOC(sigpath, len, sizeof(char), RET_ERR(db->handle, PM_ERR_MEMORY, NULL)); CALLOC(sigpath, len, sizeof(char), RET_ERR(db->handle, ALPM_ERR_MEMORY, NULL));
sprintf(sigpath, "%s.sig", dbfile); sprintf(sigpath, "%s.sig", dbfile);
return sigpath; return sigpath;
} }
@ -409,10 +409,10 @@ alpm_list_t *_alpm_db_search(alpm_db_t *db, const alpm_list_t *needles)
} }
ret = NULL; ret = NULL;
targ = i->data; targ = i->data;
_alpm_log(db->handle, PM_LOG_DEBUG, "searching for target '%s'\n", targ); _alpm_log(db->handle, ALPM_LOG_DEBUG, "searching for target '%s'\n", targ);
if(regcomp(&reg, targ, REG_EXTENDED | REG_NOSUB | REG_ICASE | REG_NEWLINE) != 0) { if(regcomp(&reg, targ, REG_EXTENDED | REG_NOSUB | REG_ICASE | REG_NEWLINE) != 0) {
RET_ERR(db->handle, PM_ERR_INVALID_REGEX, NULL); RET_ERR(db->handle, ALPM_ERR_INVALID_REGEX, NULL);
} }
for(j = list; j; j = j->next) { for(j = list; j; j = j->next) {
@ -451,7 +451,7 @@ alpm_list_t *_alpm_db_search(alpm_db_t *db, const alpm_list_t *needles)
} }
if(matched != NULL) { if(matched != NULL) {
_alpm_log(db->handle, PM_LOG_DEBUG, " search target '%s' matched '%s'\n", _alpm_log(db->handle, ALPM_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 +474,10 @@ static int load_pkgcache(alpm_db_t *db)
{ {
_alpm_db_free_pkgcache(db); _alpm_db_free_pkgcache(db);
_alpm_log(db->handle, PM_LOG_DEBUG, "loading package cache for repository '%s'\n", _alpm_log(db->handle, ALPM_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(db->handle, PM_LOG_DEBUG, _alpm_log(db->handle, ALPM_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 +492,7 @@ void _alpm_db_free_pkgcache(alpm_db_t *db)
return; return;
} }
_alpm_log(db->handle, PM_LOG_DEBUG, _alpm_log(db->handle, ALPM_LOG_DEBUG,
"freeing package cache for repository '%s'\n", db->treename); "freeing package cache for repository '%s'\n", db->treename);
alpm_list_free_inner(_alpm_db_get_pkgcache(db), alpm_list_free_inner(_alpm_db_get_pkgcache(db),
@ -510,7 +510,7 @@ alpm_pkghash_t *_alpm_db_get_pkgcache_hash(alpm_db_t *db)
} }
if(!(db->status & DB_STATUS_VALID)) { if(!(db->status & DB_STATUS_VALID)) {
RET_ERR(db->handle, PM_ERR_DB_INVALID, NULL); RET_ERR(db->handle, ALPM_ERR_DB_INVALID, NULL);
} }
if(!(db->status & DB_STATUS_PKGCACHE)) { if(!(db->status & DB_STATUS_PKGCACHE)) {
@ -545,7 +545,7 @@ int _alpm_db_add_pkgincache(alpm_db_t *db, alpm_pkg_t *pkg)
return -1; return -1;
} }
_alpm_log(db->handle, PM_LOG_DEBUG, "adding entry '%s' in '%s' cache\n", _alpm_log(db->handle, ALPM_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);
@ -562,13 +562,13 @@ int _alpm_db_remove_pkgfromcache(alpm_db_t *db, alpm_pkg_t *pkg)
return -1; return -1;
} }
_alpm_log(db->handle, PM_LOG_DEBUG, "removing entry '%s' from '%s' cache\n", _alpm_log(db->handle, ALPM_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(db->handle, PM_LOG_DEBUG, "cannot remove entry '%s' from '%s' cache: not found\n", _alpm_log(db->handle, ALPM_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;
} }
@ -604,7 +604,7 @@ static int load_grpcache(alpm_db_t *db)
return -1; return -1;
} }
_alpm_log(db->handle, PM_LOG_DEBUG, "loading group cache for repository '%s'\n", _alpm_log(db->handle, ALPM_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) {
@ -654,7 +654,7 @@ void _alpm_db_free_groupcache(alpm_db_t *db)
return; return;
} }
_alpm_log(db->handle, PM_LOG_DEBUG, _alpm_log(db->handle, ALPM_LOG_DEBUG,
"freeing group cache for repository '%s'\n", db->treename); "freeing group cache for repository '%s'\n", db->treename);
for(lg = db->grpcache; lg; lg = lg->next) { for(lg = db->grpcache; lg; lg = lg->next) {
@ -672,7 +672,7 @@ alpm_list_t *_alpm_db_get_groupcache(alpm_db_t *db)
} }
if(!(db->status & DB_STATUS_VALID)) { if(!(db->status & DB_STATUS_VALID)) {
RET_ERR(db->handle, PM_ERR_DB_INVALID, NULL); RET_ERR(db->handle, ALPM_ERR_DB_INVALID, NULL);
} }
if(!(db->status & DB_STATUS_GRPCACHE)) { if(!(db->status & DB_STATUS_GRPCACHE)) {

View File

@ -198,14 +198,14 @@ off_t _alpm_shortest_delta_path(alpm_handle_t *handle, alpm_list_t *deltas,
return bestsize; return bestsize;
} }
_alpm_log(handle, PM_LOG_DEBUG, "started delta shortest-path search for '%s'\n", to); _alpm_log(handle, ALPM_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(handle, PM_LOG_DEBUG, "delta shortest-path search complete : '%jd'\n", (intmax_t)bestsize); _alpm_log(handle, ALPM_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);

View File

@ -138,7 +138,7 @@ alpm_list_t *_alpm_sortbydeps(alpm_handle_t *handle,
return NULL; return NULL;
} }
_alpm_log(handle, PM_LOG_DEBUG, "started sorting dependencies\n"); _alpm_log(handle, ALPM_LOG_DEBUG, "started sorting dependencies\n");
vertices = dep_graph_init(targets); vertices = dep_graph_init(targets);
@ -161,13 +161,13 @@ alpm_list_t *_alpm_sortbydeps(alpm_handle_t *handle,
alpm_pkg_t *childpkg = nextchild->data; alpm_pkg_t *childpkg = nextchild->data;
const char *message; const char *message;
_alpm_log(handle, PM_LOG_WARNING, _("dependency cycle detected:\n")); _alpm_log(handle, ALPM_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(handle, PM_LOG_WARNING, message, vertexpkg->name, childpkg->name); _alpm_log(handle, ALPM_LOG_WARNING, message, vertexpkg->name, childpkg->name);
} }
} }
if(!found) { if(!found) {
@ -186,7 +186,7 @@ alpm_list_t *_alpm_sortbydeps(alpm_handle_t *handle,
} }
} }
_alpm_log(handle, PM_LOG_DEBUG, "sorting dependencies finished\n"); _alpm_log(handle, ALPM_LOG_DEBUG, "sorting dependencies finished\n");
if(reverse) { if(reverse) {
/* reverse the order */ /* reverse the order */
@ -205,7 +205,7 @@ alpm_list_t *_alpm_sortbydeps(alpm_handle_t *handle,
static int no_dep_version(alpm_handle_t *handle) static int no_dep_version(alpm_handle_t *handle)
{ {
int flags = alpm_trans_get_flags(handle); int flags = alpm_trans_get_flags(handle);
return flags != -1 && (flags & PM_TRANS_FLAG_NODEPVERSION); return flags != -1 && (flags & ALPM_TRANS_FLAG_NODEPVERSION);
} }
static alpm_depend_t *filtered_depend(alpm_depend_t *dep, int nodepversion) static alpm_depend_t *filtered_depend(alpm_depend_t *dep, int nodepversion)
@ -213,7 +213,7 @@ static alpm_depend_t *filtered_depend(alpm_depend_t *dep, int nodepversion)
if(nodepversion) { if(nodepversion) {
alpm_depend_t *newdep = _alpm_dep_dup(dep); alpm_depend_t *newdep = _alpm_dep_dup(dep);
ASSERT(newdep, return dep); ASSERT(newdep, return dep);
newdep->mod = PM_DEP_MOD_ANY; newdep->mod = ALPM_DEP_MOD_ANY;
dep = newdep; dep = newdep;
} }
return dep; return dep;
@ -289,7 +289,7 @@ alpm_list_t SYMEXPORT *alpm_checkdeps(alpm_handle_t *handle, alpm_list_t *pkglis
/* 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) {
alpm_pkg_t *tp = i->data; alpm_pkg_t *tp = i->data;
_alpm_log(handle, PM_LOG_DEBUG, "checkdeps: package %s-%s\n", _alpm_log(handle, ALPM_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) {
@ -302,7 +302,7 @@ alpm_list_t SYMEXPORT *alpm_checkdeps(alpm_handle_t *handle, alpm_list_t *pkglis
/* Unsatisfied dependency in the upgrade list */ /* Unsatisfied dependency in the upgrade list */
alpm_depmissing_t *miss; alpm_depmissing_t *miss;
char *missdepstring = alpm_dep_compute_string(depend); char *missdepstring = alpm_dep_compute_string(depend);
_alpm_log(handle, PM_LOG_DEBUG, "checkdeps: missing dependency '%s' for package '%s'\n", _alpm_log(handle, ALPM_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);
@ -329,7 +329,7 @@ alpm_list_t SYMEXPORT *alpm_checkdeps(alpm_handle_t *handle, alpm_list_t *pkglis
!find_dep_satisfier(dblist, depend)) { !find_dep_satisfier(dblist, depend)) {
alpm_depmissing_t *miss; alpm_depmissing_t *miss;
char *missdepstring = alpm_dep_compute_string(depend); char *missdepstring = alpm_dep_compute_string(depend);
_alpm_log(handle, PM_LOG_DEBUG, "checkdeps: transaction would break '%s' dependency of '%s'\n", _alpm_log(handle, ALPM_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));
@ -351,16 +351,16 @@ static int dep_vercmp(const char *version1, alpm_depmod_t mod,
{ {
int equal = 0; int equal = 0;
if(mod == PM_DEP_MOD_ANY) { if(mod == ALPM_DEP_MOD_ANY) {
equal = 1; equal = 1;
} else { } else {
int cmp = alpm_pkg_vercmp(version1, version2); int cmp = alpm_pkg_vercmp(version1, version2);
switch(mod) { switch(mod) {
case PM_DEP_MOD_EQ: equal = (cmp == 0); break; case ALPM_DEP_MOD_EQ: equal = (cmp == 0); break;
case PM_DEP_MOD_GE: equal = (cmp >= 0); break; case ALPM_DEP_MOD_GE: equal = (cmp >= 0); break;
case PM_DEP_MOD_LE: equal = (cmp <= 0); break; case ALPM_DEP_MOD_LE: equal = (cmp <= 0); break;
case PM_DEP_MOD_LT: equal = (cmp < 0); break; case ALPM_DEP_MOD_LT: equal = (cmp < 0); break;
case PM_DEP_MOD_GT: equal = (cmp > 0); break; case ALPM_DEP_MOD_GT: equal = (cmp > 0); break;
default: equal = 1; break; default: equal = 1; break;
} }
} }
@ -390,7 +390,7 @@ int _alpm_depcmp(alpm_pkg_t *pkg, alpm_depend_t *dep)
const char *provver = strchr(provision, '='); const char *provver = strchr(provision, '=');
if(provver == NULL) { /* no provision version */ if(provver == NULL) { /* no provision version */
satisfy = (dep->mod == PM_DEP_MOD_ANY satisfy = (dep->mod == ALPM_DEP_MOD_ANY
&& strcmp(provision, dep->name) == 0); && strcmp(provision, dep->name) == 0);
} else { } else {
/* This is a bit tricker than the old code for performance reasons. To /* This is a bit tricker than the old code for performance reasons. To
@ -423,24 +423,24 @@ alpm_depend_t *_alpm_splitdep(const char *depstring)
/* Find a version comparator if one exists. If it does, set the type and /* Find a version comparator if one exists. If it does, set the type and
* increment the ptr accordingly so we can copy the right strings. */ * increment the ptr accordingly so we can copy the right strings. */
if((ptr = strstr(depstring, ">="))) { if((ptr = strstr(depstring, ">="))) {
depend->mod = PM_DEP_MOD_GE; depend->mod = ALPM_DEP_MOD_GE;
version = ptr + 2; version = ptr + 2;
} else if((ptr = strstr(depstring, "<="))) { } else if((ptr = strstr(depstring, "<="))) {
depend->mod = PM_DEP_MOD_LE; depend->mod = ALPM_DEP_MOD_LE;
version = ptr + 2; version = ptr + 2;
} else if((ptr = strstr(depstring, "="))) { } else if((ptr = strstr(depstring, "="))) {
/* Note: we must do =,<,> checks after <=, >= checks */ /* Note: we must do =,<,> checks after <=, >= checks */
depend->mod = PM_DEP_MOD_EQ; depend->mod = ALPM_DEP_MOD_EQ;
version = ptr + 1; version = ptr + 1;
} else if((ptr = strstr(depstring, "<"))) { } else if((ptr = strstr(depstring, "<"))) {
depend->mod = PM_DEP_MOD_LT; depend->mod = ALPM_DEP_MOD_LT;
version = ptr + 1; version = ptr + 1;
} else if((ptr = strstr(depstring, ">"))) { } else if((ptr = strstr(depstring, ">"))) {
depend->mod = PM_DEP_MOD_GT; depend->mod = ALPM_DEP_MOD_GT;
version = ptr + 1; version = ptr + 1;
} else { } else {
/* no version specified, leave version and ptr NULL */ /* no version specified, leave version and ptr NULL */
depend->mod = PM_DEP_MOD_ANY; depend->mod = ALPM_DEP_MOD_ANY;
} }
/* copy the right parts to the right places */ /* copy the right parts to the right places */
@ -481,8 +481,8 @@ static int can_remove_package(alpm_db_t *db, alpm_pkg_t *pkg, alpm_list_t *targe
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) == ALPM_PKG_REASON_EXPLICIT) {
_alpm_log(db->handle, PM_LOG_DEBUG, "excluding %s -- explicitly installed\n", _alpm_log(db->handle, ALPM_LOG_DEBUG, "excluding %s -- explicitly installed\n",
alpm_pkg_get_name(pkg)); alpm_pkg_get_name(pkg));
return 0; return 0;
} }
@ -530,7 +530,7 @@ void _alpm_recursedeps(alpm_db_t *db, alpm_list_t *targs, int include_explicit)
alpm_pkg_t *deppkg = j->data; alpm_pkg_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(db->handle, PM_LOG_DEBUG, "adding '%s' to the targets\n", _alpm_log(db->handle, ALPM_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));
@ -568,10 +568,10 @@ static alpm_pkg_t *resolvedep(alpm_handle_t *handle, alpm_depend_t *dep,
if(_alpm_pkg_should_ignore(handle, pkg)) { if(_alpm_pkg_should_ignore(handle, pkg)) {
int install = 0; int install = 0;
if(prompt) { if(prompt) {
QUESTION(handle->trans, PM_TRANS_CONV_INSTALL_IGNOREPKG, pkg, QUESTION(handle->trans, ALPM_TRANS_CONV_INSTALL_IGNOREPKG, pkg,
NULL, NULL, &install); NULL, NULL, &install);
} else { } else {
_alpm_log(handle, PM_LOG_WARNING, _("ignoring package %s-%s\n"), pkg->name, pkg->version); _alpm_log(handle, ALPM_LOG_WARNING, _("ignoring package %s-%s\n"), pkg->name, pkg->version);
} }
if(!install) { if(!install) {
ignored = 1; ignored = 1;
@ -590,17 +590,17 @@ static alpm_pkg_t *resolvedep(alpm_handle_t *handle, alpm_depend_t *dep,
if(_alpm_pkg_should_ignore(handle, pkg)) { if(_alpm_pkg_should_ignore(handle, pkg)) {
int install = 0; int install = 0;
if(prompt) { if(prompt) {
QUESTION(handle->trans, PM_TRANS_CONV_INSTALL_IGNOREPKG, QUESTION(handle->trans, ALPM_TRANS_CONV_INSTALL_IGNOREPKG,
pkg, NULL, NULL, &install); pkg, NULL, NULL, &install);
} else { } else {
_alpm_log(handle, PM_LOG_WARNING, _("ignoring package %s-%s\n"), pkg->name, pkg->version); _alpm_log(handle, ALPM_LOG_WARNING, _("ignoring package %s-%s\n"), pkg->name, pkg->version);
} }
if(!install) { if(!install) {
ignored = 1; ignored = 1;
continue; continue;
} }
} }
_alpm_log(handle, PM_LOG_DEBUG, "provider found (%s provides %s)\n", _alpm_log(handle, ALPM_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 */
@ -622,7 +622,7 @@ static alpm_pkg_t *resolvedep(alpm_handle_t *handle, alpm_depend_t *dep,
int index = 0; int index = 0;
if(count > 1) { if(count > 1) {
/* if there is more than one provider, we ask the user */ /* if there is more than one provider, we ask the user */
QUESTION(handle->trans, PM_TRANS_CONV_SELECT_PROVIDER, QUESTION(handle->trans, ALPM_TRANS_CONV_SELECT_PROVIDER,
providers, dep, NULL, &index); providers, dep, NULL, &index);
} }
if(index >= 0 && index < count) { if(index >= 0 && index < count) {
@ -635,9 +635,9 @@ static alpm_pkg_t *resolvedep(alpm_handle_t *handle, alpm_depend_t *dep,
} }
if(ignored) { /* resolvedeps will override these */ if(ignored) { /* resolvedeps will override these */
handle->pm_errno = PM_ERR_PKG_IGNORED; handle->pm_errno = ALPM_ERR_PKG_IGNORED;
} else { } else {
handle->pm_errno = PM_ERR_PKG_NOT_FOUND; handle->pm_errno = ALPM_ERR_PKG_NOT_FOUND;
} }
return NULL; return NULL;
} }
@ -658,7 +658,7 @@ alpm_pkg_t SYMEXPORT *alpm_find_dbs_satisfier(alpm_handle_t *handle,
alpm_pkg_t *pkg; alpm_pkg_t *pkg;
CHECK_HANDLE(handle, return NULL); CHECK_HANDLE(handle, return NULL);
ASSERT(dbs, RET_ERR(handle, PM_ERR_WRONG_ARGS, NULL)); ASSERT(dbs, RET_ERR(handle, ALPM_ERR_WRONG_ARGS, NULL));
dep = _alpm_splitdep(depstring); dep = _alpm_splitdep(depstring);
ASSERT(dep, return NULL); ASSERT(dep, return NULL);
@ -708,7 +708,7 @@ int _alpm_resolvedeps(alpm_handle_t *handle, alpm_list_t *localpkgs, alpm_pkg_t
on that list */ on that list */
*packages = alpm_list_add(*packages, pkg); *packages = alpm_list_add(*packages, pkg);
_alpm_log(handle, PM_LOG_DEBUG, "started resolving dependencies\n"); _alpm_log(handle, ALPM_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) {
alpm_pkg_t *tpkg = i->data; alpm_pkg_t *tpkg = i->data;
targ = alpm_list_add(NULL, tpkg); targ = alpm_list_add(NULL, tpkg);
@ -732,9 +732,9 @@ int _alpm_resolvedeps(alpm_handle_t *handle, alpm_list_t *localpkgs, alpm_pkg_t
spkg = resolvedep(handle, missdep, handle->dbs_sync, *packages, 0); spkg = resolvedep(handle, missdep, handle->dbs_sync, *packages, 0);
} }
if(!spkg) { if(!spkg) {
handle->pm_errno = PM_ERR_UNSATISFIED_DEPS; handle->pm_errno = ALPM_ERR_UNSATISFIED_DEPS;
char *missdepstring = alpm_dep_compute_string(missdep); char *missdepstring = alpm_dep_compute_string(missdep);
_alpm_log(handle, PM_LOG_WARNING, _alpm_log(handle, ALPM_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);
@ -743,7 +743,7 @@ int _alpm_resolvedeps(alpm_handle_t *handle, alpm_list_t *localpkgs, alpm_pkg_t
} }
ret = -1; ret = -1;
} else { } else {
_alpm_log(handle, PM_LOG_DEBUG, "pulling dependency %s (needed by %s)\n", _alpm_log(handle, ALPM_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);
@ -758,7 +758,7 @@ int _alpm_resolvedeps(alpm_handle_t *handle, alpm_list_t *localpkgs, alpm_pkg_t
} else { } else {
alpm_list_free(packages_copy); alpm_list_free(packages_copy);
} }
_alpm_log(handle, PM_LOG_DEBUG, "finished resolving dependencies\n"); _alpm_log(handle, ALPM_LOG_DEBUG, "finished resolving dependencies\n");
return ret; return ret;
} }
@ -782,22 +782,22 @@ char SYMEXPORT *alpm_dep_compute_string(const alpm_depend_t *dep)
} }
switch(dep->mod) { switch(dep->mod) {
case PM_DEP_MOD_ANY: case ALPM_DEP_MOD_ANY:
opr = ""; opr = "";
break; break;
case PM_DEP_MOD_GE: case ALPM_DEP_MOD_GE:
opr = ">="; opr = ">=";
break; break;
case PM_DEP_MOD_LE: case ALPM_DEP_MOD_LE:
opr = "<="; opr = "<=";
break; break;
case PM_DEP_MOD_EQ: case ALPM_DEP_MOD_EQ:
opr = "="; opr = "=";
break; break;
case PM_DEP_MOD_LT: case ALPM_DEP_MOD_LT:
opr = "<"; opr = "<";
break; break;
case PM_DEP_MOD_GT: case ALPM_DEP_MOD_GT:
opr = ">"; opr = ">";
break; break;
default: default:
@ -805,14 +805,14 @@ char SYMEXPORT *alpm_dep_compute_string(const alpm_depend_t *dep)
break; break;
} }
if(dep->mod != PM_DEP_MOD_ANY && dep->version) { if(dep->mod != ALPM_DEP_MOD_ANY && dep->version) {
ver = dep->version; ver = dep->version;
} else { } else {
ver = ""; ver = "";
} }
/* we can always compute len and print the string like this because opr /* we can always compute len and print the string like this because opr
* and ver will be empty when PM_DEP_MOD_ANY is the depend type. the * and ver will be empty when ALPM_DEP_MOD_ANY is the depend type. the
* reassignments above also ensure we do not do a strlen(NULL). */ * reassignments above also ensure we do not do a strlen(NULL). */
len = strlen(name) + strlen(opr) + strlen(ver) + 1; len = strlen(name) + strlen(opr) + strlen(ver) + 1;
MALLOC(str, len, return NULL); MALLOC(str, len, return NULL);

View File

@ -73,17 +73,17 @@ static alpm_list_t *mount_point_list(alpm_handle_t *handle)
while((mnt = getmntent(fp))) { while((mnt = getmntent(fp))) {
if(!mnt) { if(!mnt) {
_alpm_log(handle, PM_LOG_WARNING, _("could not get filesystem information\n")); _alpm_log(handle, ALPM_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(handle, PM_LOG_WARNING, _alpm_log(handle, ALPM_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;
} }
CALLOC(mp, 1, sizeof(alpm_mountpoint_t), RET_ERR(handle, PM_ERR_MEMORY, NULL)); CALLOC(mp, 1, sizeof(alpm_mountpoint_t), RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
mp->mount_dir = strdup(mnt->mnt_dir); mp->mount_dir = strdup(mnt->mnt_dir);
mp->mount_dir_len = strlen(mp->mount_dir); mp->mount_dir_len = strlen(mp->mount_dir);
memcpy(&(mp->fsp), &fsp, sizeof(struct statvfs)); memcpy(&(mp->fsp), &fsp, sizeof(struct statvfs));
@ -104,7 +104,7 @@ static alpm_list_t *mount_point_list(alpm_handle_t *handle)
} }
for(; entries-- > 0; fsp++) { for(; entries-- > 0; fsp++) {
CALLOC(mp, 1, sizeof(alpm_mountpoint_t), RET_ERR(PM_ERR_MEMORY, NULL)); CALLOC(mp, 1, sizeof(alpm_mountpoint_t), RET_ERR(ALPM_ERR_MEMORY, NULL));
mp->mount_dir = strdup(fsp->f_mntonname); mp->mount_dir = strdup(fsp->f_mntonname);
mp->mount_dir_len = strlen(mp->mount_dir); mp->mount_dir_len = strlen(mp->mount_dir);
memcpy(&(mp->fsp), fsp, sizeof(FSSTATSTYPE)); memcpy(&(mp->fsp), fsp, sizeof(FSSTATSTYPE));
@ -122,7 +122,7 @@ static alpm_list_t *mount_point_list(alpm_handle_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(handle, PM_LOG_DEBUG, "mountpoint: %s\n", mp->mount_dir); _alpm_log(handle, ALPM_LOG_DEBUG, "mountpoint: %s\n", mp->mount_dir);
} }
return mount_points; return mount_points;
} }
@ -168,7 +168,7 @@ static int calculate_removed_size(alpm_handle_t *handle,
mp = match_mount_point(mount_points, path); mp = match_mount_point(mount_points, path);
if(mp == NULL) { if(mp == NULL) {
_alpm_log(handle, PM_LOG_WARNING, _alpm_log(handle, ALPM_LOG_WARNING,
_("could not determine mount point for file %s\n"), filename); _("could not determine mount point for file %s\n"), filename);
continue; continue;
} }
@ -210,7 +210,7 @@ static int calculate_installed_size(alpm_handle_t *handle,
mp = match_mount_point(mount_points, path); mp = match_mount_point(mount_points, path);
if(mp == NULL) { if(mp == NULL) {
_alpm_log(handle, PM_LOG_WARNING, _alpm_log(handle, ALPM_LOG_WARNING,
_("could not determine mount point for file %s\n"), filename); _("could not determine mount point for file %s\n"), filename);
continue; continue;
} }
@ -236,12 +236,12 @@ int _alpm_check_diskspace(alpm_handle_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(handle, PM_LOG_ERROR, _("could not determine filesystem mount points\n")); _alpm_log(handle, ALPM_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(handle, PM_LOG_ERROR, _("could not determine root mount point %s\n"), _alpm_log(handle, ALPM_LOG_ERROR, _("could not determine root mount point %s\n"),
handle->root); handle->root);
return -1; return -1;
} }
@ -252,7 +252,7 @@ int _alpm_check_diskspace(alpm_handle_t *handle)
for(targ = trans->remove; targ; targ = targ->next, current++) { for(targ = trans->remove; targ; targ = targ->next, current++) {
alpm_pkg_t *local_pkg; alpm_pkg_t *local_pkg;
int percent = (current * 100) / numtargs; int percent = (current * 100) / numtargs;
PROGRESS(trans, PM_TRANS_PROGRESS_DISKSPACE_START, "", percent, PROGRESS(trans, ALPM_TRANS_PROGRESS_DISKSPACE_START, "", percent,
numtargs, current); numtargs, current);
local_pkg = targ->data; local_pkg = targ->data;
@ -263,7 +263,7 @@ int _alpm_check_diskspace(alpm_handle_t *handle)
for(targ = trans->add; targ; targ = targ->next, current++) { for(targ = trans->add; targ; targ = targ->next, current++) {
alpm_pkg_t *pkg, *local_pkg; alpm_pkg_t *pkg, *local_pkg;
int percent = (current * 100) / numtargs; int percent = (current * 100) / numtargs;
PROGRESS(trans, PM_TRANS_PROGRESS_DISKSPACE_START, "", percent, PROGRESS(trans, ALPM_TRANS_PROGRESS_DISKSPACE_START, "", percent,
numtargs, current); numtargs, current);
pkg = targ->data; pkg = targ->data;
@ -282,13 +282,13 @@ int _alpm_check_diskspace(alpm_handle_t *handle)
} }
} }
PROGRESS(trans, PM_TRANS_PROGRESS_DISKSPACE_START, "", 100, PROGRESS(trans, ALPM_TRANS_PROGRESS_DISKSPACE_START, "", 100,
numtargs, current); numtargs, current);
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(handle, PM_LOG_ERROR, _("Partition %s is mounted read only\n"), _alpm_log(handle, ALPM_LOG_ERROR, _("Partition %s is mounted read only\n"),
data->mount_dir); data->mount_dir);
error = 1; error = 1;
} else if(data->used & USED_INSTALL) { } else if(data->used & USED_INSTALL) {
@ -297,12 +297,12 @@ int _alpm_check_diskspace(alpm_handle_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(handle, PM_LOG_DEBUG, "partition %s, needed %ld, cushion %ld, free %ld\n", _alpm_log(handle, ALPM_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(handle, PM_LOG_ERROR, _("Partition %s too full: %ld blocks needed, %ld blocks free\n"), _alpm_log(handle, ALPM_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);
error = 1; error = 1;
@ -317,7 +317,7 @@ int _alpm_check_diskspace(alpm_handle_t *handle)
FREELIST(mount_points); FREELIST(mount_points);
if(error) { if(error) {
RET_ERR(handle, PM_ERR_DISK_SPACE, -1); RET_ERR(handle, ALPM_ERR_DISK_SPACE, -1);
} }
return 0; return 0;

View File

@ -171,8 +171,8 @@ static int curl_download_internal(alpm_handle_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(handle, PM_LOG_ERROR, _("url '%s' is invalid\n"), url); _alpm_log(handle, ALPM_LOG_ERROR, _("url '%s' is invalid\n"), url);
RET_ERR(handle, PM_ERR_SERVER_BAD_URL, -1); RET_ERR(handle, ALPM_ERR_SERVER_BAD_URL, -1);
} }
destfile = get_fullpath(localpath, dlfile.filename, ""); destfile = get_fullpath(localpath, dlfile.filename, "");
@ -211,7 +211,7 @@ static int curl_download_internal(alpm_handle_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(handle, PM_LOG_DEBUG, "tempfile found, attempting continuation\n"); _alpm_log(handle, ALPM_LOG_DEBUG, "tempfile found, attempting continuation\n");
dlfile.initial_size = (double)st.st_size; dlfile.initial_size = (double)st.st_size;
} }
@ -248,11 +248,11 @@ static int curl_download_internal(alpm_handle_t *handle,
goto cleanup; goto cleanup;
} 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 = ALPM_ERR_LIBCURL;
_alpm_log(handle, PM_LOG_ERROR, _("failed retrieving file '%s' from %s : %s\n"), _alpm_log(handle, ALPM_LOG_ERROR, _("failed retrieving file '%s' from %s : %s\n"),
dlfile.filename, hostname, error_buffer); dlfile.filename, hostname, error_buffer);
} else { } else {
_alpm_log(handle, PM_LOG_DEBUG, "failed retrieving file '%s' from %s : %s\n", _alpm_log(handle, ALPM_LOG_DEBUG, "failed retrieving file '%s' from %s : %s\n",
dlfile.filename, hostname, error_buffer); dlfile.filename, hostname, error_buffer);
} }
unlink(tempfile); unlink(tempfile);
@ -278,8 +278,8 @@ static int curl_download_internal(alpm_handle_t *handle,
* as actually being transferred during curl_easy_perform() */ * as actually being transferred during curl_easy_perform() */
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 = ALPM_ERR_RETRIEVE;
_alpm_log(handle, PM_LOG_ERROR, _("%s appears to be truncated: %jd/%jd bytes\n"), _alpm_log(handle, ALPM_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;
} }
@ -329,12 +329,12 @@ int _alpm_download(alpm_handle_t *handle, const char *url, const char *localpath
return curl_download_internal(handle, url, localpath, return curl_download_internal(handle, url, localpath,
force, allow_resume, errors_ok); force, allow_resume, errors_ok);
#else #else
RET_ERR(handle, PM_ERR_EXTERNAL_DOWNLOAD, -1); RET_ERR(handle, ALPM_ERR_EXTERNAL_DOWNLOAD, -1);
#endif #endif
} else { } else {
int ret = handle->fetchcb(url, localpath, force); int ret = handle->fetchcb(url, localpath, force);
if(ret == -1 && !errors_ok) { if(ret == -1 && !errors_ok) {
RET_ERR(handle, PM_ERR_EXTERNAL_DOWNLOAD, -1); RET_ERR(handle, ALPM_ERR_EXTERNAL_DOWNLOAD, -1);
} }
return ret; return ret;
} }
@ -357,10 +357,10 @@ char SYMEXPORT *alpm_fetch_pkgurl(alpm_handle_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(handle, PM_LOG_WARNING, _("failed to download %s\n"), url); _alpm_log(handle, ALPM_LOG_WARNING, _("failed to download %s\n"), url);
return NULL; return NULL;
} }
_alpm_log(handle, PM_LOG_DEBUG, "successfully downloaded %s\n", url); _alpm_log(handle, ALPM_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 ||
@ -370,16 +370,16 @@ char SYMEXPORT *alpm_fetch_pkgurl(alpm_handle_t *handle, const char *url)
int errors_ok = (handle->sigverify == PM_PGP_VERIFY_OPTIONAL); int errors_ok = (handle->sigverify == PM_PGP_VERIFY_OPTIONAL);
len = strlen(url) + 5; len = strlen(url) + 5;
CALLOC(sig_url, len, sizeof(char), RET_ERR(handle, PM_ERR_MEMORY, NULL)); CALLOC(sig_url, len, sizeof(char), RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
snprintf(sig_url, len, "%s.sig", url); snprintf(sig_url, len, "%s.sig", 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(handle, PM_LOG_WARNING, _("failed to download %s\n"), sig_url); _alpm_log(handle, ALPM_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(handle, PM_LOG_DEBUG, "successfully downloaded %s\n", sig_url); _alpm_log(handle, ALPM_LOG_DEBUG, "successfully downloaded %s\n", sig_url);
} }
FREE(sig_url); FREE(sig_url);
} }

View File

@ -38,120 +38,120 @@ const char SYMEXPORT *alpm_strerror(enum _alpm_errno_t err)
{ {
switch(err) { switch(err) {
/* System */ /* System */
case PM_ERR_MEMORY: case ALPM_ERR_MEMORY:
return _("out of memory!"); return _("out of memory!");
case PM_ERR_SYSTEM: case ALPM_ERR_SYSTEM:
return _("unexpected system error"); return _("unexpected system error");
case PM_ERR_BADPERMS: case ALPM_ERR_BADPERMS:
return _("insufficient privileges"); return _("insufficient privileges");
case PM_ERR_NOT_A_FILE: case ALPM_ERR_NOT_A_FILE:
return _("could not find or read file"); return _("could not find or read file");
case PM_ERR_NOT_A_DIR: case ALPM_ERR_NOT_A_DIR:
return _("could not find or read directory"); return _("could not find or read directory");
case PM_ERR_WRONG_ARGS: case ALPM_ERR_WRONG_ARGS:
return _("wrong or NULL argument passed"); return _("wrong or NULL argument passed");
case PM_ERR_DISK_SPACE: case ALPM_ERR_DISK_SPACE:
return _("not enough free disk space"); return _("not enough free disk space");
/* Interface */ /* Interface */
case PM_ERR_HANDLE_NULL: case ALPM_ERR_HANDLE_NULL:
return _("library not initialized"); return _("library not initialized");
case PM_ERR_HANDLE_NOT_NULL: case ALPM_ERR_HANDLE_NOT_NULL:
return _("library already initialized"); return _("library already initialized");
case PM_ERR_HANDLE_LOCK: case ALPM_ERR_HANDLE_LOCK:
return _("unable to lock database"); return _("unable to lock database");
/* Databases */ /* Databases */
case PM_ERR_DB_OPEN: case ALPM_ERR_DB_OPEN:
return _("could not open database"); return _("could not open database");
case PM_ERR_DB_CREATE: case ALPM_ERR_DB_CREATE:
return _("could not create database"); return _("could not create database");
case PM_ERR_DB_NULL: case ALPM_ERR_DB_NULL:
return _("database not initialized"); return _("database not initialized");
case PM_ERR_DB_NOT_NULL: case ALPM_ERR_DB_NOT_NULL:
return _("database already registered"); return _("database already registered");
case PM_ERR_DB_NOT_FOUND: case ALPM_ERR_DB_NOT_FOUND:
return _("could not find database"); return _("could not find database");
case PM_ERR_DB_INVALID: case ALPM_ERR_DB_INVALID:
return _("invalid or corrupted database"); return _("invalid or corrupted database");
case PM_ERR_DB_VERSION: case ALPM_ERR_DB_VERSION:
return _("database is incorrect version"); return _("database is incorrect version");
case PM_ERR_DB_WRITE: case ALPM_ERR_DB_WRITE:
return _("could not update database"); return _("could not update database");
case PM_ERR_DB_REMOVE: case ALPM_ERR_DB_REMOVE:
return _("could not remove database entry"); return _("could not remove database entry");
/* Servers */ /* Servers */
case PM_ERR_SERVER_BAD_URL: case ALPM_ERR_SERVER_BAD_URL:
return _("invalid url for server"); return _("invalid url for server");
case PM_ERR_SERVER_NONE: case ALPM_ERR_SERVER_NONE:
return _("no servers configured for repository"); return _("no servers configured for repository");
/* Transactions */ /* Transactions */
case PM_ERR_TRANS_NOT_NULL: case ALPM_ERR_TRANS_NOT_NULL:
return _("transaction already initialized"); return _("transaction already initialized");
case PM_ERR_TRANS_NULL: case ALPM_ERR_TRANS_NULL:
return _("transaction not initialized"); return _("transaction not initialized");
case PM_ERR_TRANS_DUP_TARGET: case ALPM_ERR_TRANS_DUP_TARGET:
return _("duplicate target"); return _("duplicate target");
case PM_ERR_TRANS_NOT_INITIALIZED: case ALPM_ERR_TRANS_NOT_INITIALIZED:
return _("transaction not initialized"); return _("transaction not initialized");
case PM_ERR_TRANS_NOT_PREPARED: case ALPM_ERR_TRANS_NOT_PREPARED:
return _("transaction not prepared"); return _("transaction not prepared");
case PM_ERR_TRANS_ABORT: case ALPM_ERR_TRANS_ABORT:
return _("transaction aborted"); return _("transaction aborted");
case PM_ERR_TRANS_TYPE: case ALPM_ERR_TRANS_TYPE:
return _("operation not compatible with the transaction type"); return _("operation not compatible with the transaction type");
case PM_ERR_TRANS_NOT_LOCKED: case ALPM_ERR_TRANS_NOT_LOCKED:
return _("transaction commit attempt when database is not locked"); return _("transaction commit attempt when database is not locked");
/* Packages */ /* Packages */
case PM_ERR_PKG_NOT_FOUND: case ALPM_ERR_PKG_NOT_FOUND:
return _("could not find or read package"); return _("could not find or read package");
case PM_ERR_PKG_IGNORED: case ALPM_ERR_PKG_IGNORED:
return _("operation cancelled due to ignorepkg"); return _("operation cancelled due to ignorepkg");
case PM_ERR_PKG_INVALID: case ALPM_ERR_PKG_INVALID:
return _("invalid or corrupted package"); return _("invalid or corrupted package");
case PM_ERR_PKG_OPEN: case ALPM_ERR_PKG_OPEN:
return _("cannot open package file"); return _("cannot open package file");
case PM_ERR_PKG_CANT_REMOVE: case ALPM_ERR_PKG_CANT_REMOVE:
return _("cannot remove all files for package"); return _("cannot remove all files for package");
case PM_ERR_PKG_INVALID_NAME: case ALPM_ERR_PKG_INVALID_NAME:
return _("package filename is not valid"); return _("package filename is not valid");
case PM_ERR_PKG_INVALID_ARCH: case ALPM_ERR_PKG_INVALID_ARCH:
return _("package architecture is not valid"); return _("package architecture is not valid");
case PM_ERR_PKG_REPO_NOT_FOUND: case ALPM_ERR_PKG_REPO_NOT_FOUND:
return _("could not find repository for target"); return _("could not find repository for target");
/* Signatures */ /* Signatures */
case PM_ERR_SIG_MISSINGDIR: case ALPM_ERR_SIG_MISSINGDIR:
return _("signature directory not configured correctly"); return _("signature directory not configured correctly");
case PM_ERR_SIG_INVALID: case ALPM_ERR_SIG_INVALID:
return _("invalid PGP signature"); return _("invalid PGP signature");
case PM_ERR_SIG_UNKNOWN: case ALPM_ERR_SIG_UNKNOWN:
return _("unknown PGP signature"); return _("unknown PGP signature");
/* Deltas */ /* Deltas */
case PM_ERR_DLT_INVALID: case ALPM_ERR_DLT_INVALID:
return _("invalid or corrupted delta"); return _("invalid or corrupted delta");
case PM_ERR_DLT_PATCHFAILED: case ALPM_ERR_DLT_PATCHFAILED:
return _("delta patch failed"); return _("delta patch failed");
/* Dependencies */ /* Dependencies */
case PM_ERR_UNSATISFIED_DEPS: case ALPM_ERR_UNSATISFIED_DEPS:
return _("could not satisfy dependencies"); return _("could not satisfy dependencies");
case PM_ERR_CONFLICTING_DEPS: case ALPM_ERR_CONFLICTING_DEPS:
return _("conflicting dependencies"); return _("conflicting dependencies");
case PM_ERR_FILE_CONFLICTS: case ALPM_ERR_FILE_CONFLICTS:
return _("conflicting files"); return _("conflicting files");
/* Miscellaenous */ /* Miscellaenous */
case PM_ERR_RETRIEVE: case ALPM_ERR_RETRIEVE:
return _("failed to retrieve some files"); return _("failed to retrieve some files");
case PM_ERR_INVALID_REGEX: case ALPM_ERR_INVALID_REGEX:
return _("invalid regular expression"); return _("invalid regular expression");
/* Errors from external libraries- our own wrapper error */ /* Errors from external libraries- our own wrapper error */
case PM_ERR_LIBARCHIVE: case ALPM_ERR_LIBARCHIVE:
/* it would be nice to use archive_error_string() here, but that /* it would be nice to use archive_error_string() here, but that
* requires the archive struct, so we can't. Just use a generic * requires the archive struct, so we can't. Just use a generic
* error string instead. */ * error string instead. */
return _("libarchive error"); return _("libarchive error");
case PM_ERR_LIBCURL: case ALPM_ERR_LIBCURL:
return _("download library error"); return _("download library error");
case PM_ERR_GPGME: case ALPM_ERR_GPGME:
return _("gpgme error"); return _("gpgme error");
case PM_ERR_EXTERNAL_DOWNLOAD: case ALPM_ERR_EXTERNAL_DOWNLOAD:
return _("error invoking external downloader"); return _("error invoking external downloader");
/* Unknown error! */ /* Unknown error! */
default: default:

View File

@ -312,16 +312,16 @@ enum _alpm_errno_t _alpm_set_directory_option(const char *value,
path = value; path = value;
if(!path) { if(!path) {
return PM_ERR_WRONG_ARGS; return ALPM_ERR_WRONG_ARGS;
} }
if(must_exist) { if(must_exist) {
if(stat(path, &st) == -1 || !S_ISDIR(st.st_mode)) { if(stat(path, &st) == -1 || !S_ISDIR(st.st_mode)) {
return PM_ERR_NOT_A_DIR; return ALPM_ERR_NOT_A_DIR;
} }
CALLOC(real, PATH_MAX, sizeof(char), return PM_ERR_MEMORY); CALLOC(real, PATH_MAX, sizeof(char), return ALPM_ERR_MEMORY);
if(!realpath(path, real)) { if(!realpath(path, real)) {
free(real); free(real);
return PM_ERR_NOT_A_DIR; return ALPM_ERR_NOT_A_DIR;
} }
path = real; path = real;
} }
@ -331,7 +331,7 @@ enum _alpm_errno_t _alpm_set_directory_option(const char *value,
} }
*storage = canonicalize_path(path); *storage = canonicalize_path(path);
if(!*storage) { if(!*storage) {
return PM_ERR_MEMORY; return ALPM_ERR_MEMORY;
} }
free(real); free(real);
return 0; return 0;
@ -342,16 +342,16 @@ int SYMEXPORT alpm_option_add_cachedir(alpm_handle_t *handle, const char *cached
char *newcachedir; char *newcachedir;
CHECK_HANDLE(handle, return -1); CHECK_HANDLE(handle, return -1);
ASSERT(cachedir != NULL, RET_ERR(handle, PM_ERR_WRONG_ARGS, -1)); ASSERT(cachedir != NULL, RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1));
/* don't stat the cachedir yet, as it may not even be needed. we can /* don't stat the cachedir yet, as it may not even be needed. we can
* fail later if it is needed and the path is invalid. */ * fail later if it is needed and the path is invalid. */
newcachedir = canonicalize_path(cachedir); newcachedir = canonicalize_path(cachedir);
if(!newcachedir) { if(!newcachedir) {
RET_ERR(handle, PM_ERR_MEMORY, -1); RET_ERR(handle, ALPM_ERR_MEMORY, -1);
} }
handle->cachedirs = alpm_list_add(handle->cachedirs, newcachedir); handle->cachedirs = alpm_list_add(handle->cachedirs, newcachedir);
_alpm_log(handle, PM_LOG_DEBUG, "option 'cachedir' = %s\n", newcachedir); _alpm_log(handle, ALPM_LOG_DEBUG, "option 'cachedir' = %s\n", newcachedir);
return 0; return 0;
} }
@ -376,11 +376,11 @@ int SYMEXPORT alpm_option_remove_cachedir(alpm_handle_t *handle, const char *cac
char *vdata = NULL; char *vdata = NULL;
char *newcachedir; char *newcachedir;
CHECK_HANDLE(handle, return -1); CHECK_HANDLE(handle, return -1);
ASSERT(cachedir != NULL, RET_ERR(handle, PM_ERR_WRONG_ARGS, -1)); ASSERT(cachedir != NULL, RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1));
newcachedir = canonicalize_path(cachedir); newcachedir = canonicalize_path(cachedir);
if(!newcachedir) { if(!newcachedir) {
RET_ERR(handle, PM_ERR_MEMORY, -1); RET_ERR(handle, ALPM_ERR_MEMORY, -1);
} }
handle->cachedirs = alpm_list_remove_str(handle->cachedirs, newcachedir, &vdata); handle->cachedirs = alpm_list_remove_str(handle->cachedirs, newcachedir, &vdata);
FREE(newcachedir); FREE(newcachedir);
@ -397,7 +397,7 @@ int SYMEXPORT alpm_option_set_logfile(alpm_handle_t *handle, const char *logfile
CHECK_HANDLE(handle, return -1); CHECK_HANDLE(handle, return -1);
if(!logfile) { if(!logfile) {
handle->pm_errno = PM_ERR_WRONG_ARGS; handle->pm_errno = ALPM_ERR_WRONG_ARGS;
return -1; return -1;
} }
@ -412,7 +412,7 @@ int SYMEXPORT alpm_option_set_logfile(alpm_handle_t *handle, const char *logfile
fclose(handle->logstream); fclose(handle->logstream);
handle->logstream = NULL; handle->logstream = NULL;
} }
_alpm_log(handle, PM_LOG_DEBUG, "option 'logfile' = %s\n", handle->logfile); _alpm_log(handle, ALPM_LOG_DEBUG, "option 'logfile' = %s\n", handle->logfile);
return 0; return 0;
} }
@ -420,7 +420,7 @@ int SYMEXPORT alpm_option_set_gpgdir(alpm_handle_t *handle, const char *gpgdir)
{ {
CHECK_HANDLE(handle, return -1); CHECK_HANDLE(handle, return -1);
if(!gpgdir) { if(!gpgdir) {
handle->pm_errno = PM_ERR_WRONG_ARGS; handle->pm_errno = ALPM_ERR_WRONG_ARGS;
return -1; return -1;
} }
@ -429,7 +429,7 @@ int SYMEXPORT alpm_option_set_gpgdir(alpm_handle_t *handle, const char *gpgdir)
} }
handle->gpgdir = strdup(gpgdir); handle->gpgdir = strdup(gpgdir);
_alpm_log(handle, PM_LOG_DEBUG, "option 'gpgdir' = %s\n", handle->gpgdir); _alpm_log(handle, ALPM_LOG_DEBUG, "option 'gpgdir' = %s\n", handle->gpgdir);
return 0; return 0;
} }
@ -577,7 +577,7 @@ int SYMEXPORT alpm_option_set_checkspace(alpm_handle_t *handle, int checkspace)
int SYMEXPORT alpm_option_set_default_sigverify(alpm_handle_t *handle, pgp_verify_t level) int SYMEXPORT alpm_option_set_default_sigverify(alpm_handle_t *handle, pgp_verify_t level)
{ {
CHECK_HANDLE(handle, return -1); CHECK_HANDLE(handle, return -1);
ASSERT(level != PM_PGP_VERIFY_UNKNOWN, RET_ERR(handle, PM_ERR_WRONG_ARGS, -1)); ASSERT(level != PM_PGP_VERIFY_UNKNOWN, RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1));
handle->sigverify = level; handle->sigverify = level;
return 0; return 0;
} }

View File

@ -53,11 +53,11 @@ int SYMEXPORT alpm_logaction(alpm_handle_t *handle, const char *fmt, ...)
/* if we couldn't open it, we have an issue */ /* if we couldn't open it, we have an issue */
if(handle->logstream == NULL) { if(handle->logstream == NULL) {
if(errno == EACCES) { if(errno == EACCES) {
handle->pm_errno = PM_ERR_BADPERMS; handle->pm_errno = ALPM_ERR_BADPERMS;
} else if(errno == ENOENT) { } else if(errno == ENOENT) {
handle->pm_errno = PM_ERR_NOT_A_DIR; handle->pm_errno = ALPM_ERR_NOT_A_DIR;
} else { } else {
handle->pm_errno = PM_ERR_SYSTEM; handle->pm_errno = ALPM_ERR_SYSTEM;
} }
return -1; return -1;
} }

View File

@ -65,7 +65,7 @@ int SYMEXPORT alpm_pkg_checkmd5sum(alpm_pkg_t *pkg)
pkg->handle->pm_errno = 0; pkg->handle->pm_errno = 0;
/* We only inspect packages from sync repositories */ /* We only inspect packages from sync repositories */
ASSERT(pkg->origin == PKG_FROM_SYNCDB, ASSERT(pkg->origin == PKG_FROM_SYNCDB,
RET_ERR(pkg->handle, PM_ERR_WRONG_ARGS, -1)); RET_ERR(pkg->handle, ALPM_ERR_WRONG_ARGS, -1));
fpath = _alpm_filecache_find(pkg->handle, alpm_pkg_get_filename(pkg)); fpath = _alpm_filecache_find(pkg->handle, alpm_pkg_get_filename(pkg));
@ -74,7 +74,7 @@ int SYMEXPORT alpm_pkg_checkmd5sum(alpm_pkg_t *pkg)
if(retval == 0) { if(retval == 0) {
return 0; return 0;
} else if(retval == 1) { } else if(retval == 1) {
pkg->handle->pm_errno = PM_ERR_PKG_INVALID; pkg->handle->pm_errno = ALPM_ERR_PKG_INVALID;
retval = -1; retval = -1;
} }

View File

@ -52,20 +52,20 @@ int SYMEXPORT alpm_remove_pkg(alpm_handle_t *handle, alpm_pkg_t *pkg)
/* Sanity checks */ /* Sanity checks */
CHECK_HANDLE(handle, return -1); CHECK_HANDLE(handle, return -1);
ASSERT(pkg != NULL, RET_ERR(handle, PM_ERR_WRONG_ARGS, -1)); ASSERT(pkg != NULL, RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1));
ASSERT(handle == pkg->handle, RET_ERR(handle, PM_ERR_WRONG_ARGS, -1)); ASSERT(handle == pkg->handle, RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1));
trans = handle->trans; trans = handle->trans;
ASSERT(trans != NULL, RET_ERR(handle, PM_ERR_TRANS_NULL, -1)); ASSERT(trans != NULL, RET_ERR(handle, ALPM_ERR_TRANS_NULL, -1));
ASSERT(trans->state == STATE_INITIALIZED, ASSERT(trans->state == STATE_INITIALIZED,
RET_ERR(handle, PM_ERR_TRANS_NOT_INITIALIZED, -1)); RET_ERR(handle, ALPM_ERR_TRANS_NOT_INITIALIZED, -1));
pkgname = pkg->name; pkgname = pkg->name;
if(_alpm_pkg_find(trans->remove, pkgname)) { if(_alpm_pkg_find(trans->remove, pkgname)) {
RET_ERR(handle, PM_ERR_TRANS_DUP_TARGET, -1); RET_ERR(handle, ALPM_ERR_TRANS_DUP_TARGET, -1);
} }
_alpm_log(handle, PM_LOG_DEBUG, "adding package %s to the transaction remove list\n", _alpm_log(handle, ALPM_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;
@ -82,12 +82,12 @@ static void remove_prepare_cascade(alpm_handle_t *handle, alpm_list_t *lp)
alpm_pkg_t *info = _alpm_db_get_pkgfromcache(handle->db_local, miss->target); alpm_pkg_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(handle, PM_LOG_DEBUG, "pulling %s in target list\n", _alpm_log(handle, ALPM_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(handle, PM_LOG_ERROR, _("could not find %s in database -- skipping\n"), _alpm_log(handle, ALPM_LOG_ERROR, _("could not find %s in database -- skipping\n"),
miss->target); miss->target);
} }
} }
@ -116,7 +116,7 @@ static void remove_prepare_keep_needed(alpm_handle_t *handle, alpm_list_t *lp)
&vpkg); &vpkg);
pkg = vpkg; pkg = vpkg;
if(pkg) { if(pkg) {
_alpm_log(handle, PM_LOG_WARNING, _("removing %s from target list\n"), _alpm_log(handle, ALPM_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,22 +141,22 @@ int _alpm_remove_prepare(alpm_handle_t *handle, alpm_list_t **data)
alpm_trans_t *trans = handle->trans; alpm_trans_t *trans = handle->trans;
alpm_db_t *db = handle->db_local; alpm_db_t *db = handle->db_local;
if((trans->flags & PM_TRANS_FLAG_RECURSE) && !(trans->flags & PM_TRANS_FLAG_CASCADE)) { if((trans->flags & ALPM_TRANS_FLAG_RECURSE) && !(trans->flags & ALPM_TRANS_FLAG_CASCADE)) {
_alpm_log(handle, PM_LOG_DEBUG, "finding removable dependencies\n"); _alpm_log(handle, ALPM_LOG_DEBUG, "finding removable dependencies\n");
_alpm_recursedeps(db, trans->remove, _alpm_recursedeps(db, trans->remove,
trans->flags & PM_TRANS_FLAG_RECURSEALL); trans->flags & ALPM_TRANS_FLAG_RECURSEALL);
} }
if(!(trans->flags & PM_TRANS_FLAG_NODEPS)) { if(!(trans->flags & ALPM_TRANS_FLAG_NODEPS)) {
EVENT(trans, PM_TRANS_EVT_CHECKDEPS_START, NULL, NULL); EVENT(trans, ALPM_TRANS_EVT_CHECKDEPS_START, NULL, NULL);
_alpm_log(handle, PM_LOG_DEBUG, "looking for unsatisfied dependencies\n"); _alpm_log(handle, ALPM_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) {
if(trans->flags & PM_TRANS_FLAG_CASCADE) { if(trans->flags & ALPM_TRANS_FLAG_CASCADE) {
remove_prepare_cascade(handle, lp); remove_prepare_cascade(handle, lp);
} else if(trans->flags & PM_TRANS_FLAG_UNNEEDED) { } else if(trans->flags & ALPM_TRANS_FLAG_UNNEEDED) {
/* Remove needed packages (which would break dependencies) /* Remove needed packages (which would break dependencies)
* from target list */ * from target list */
remove_prepare_keep_needed(handle, lp); remove_prepare_keep_needed(handle, lp);
@ -167,26 +167,26 @@ int _alpm_remove_prepare(alpm_handle_t *handle, alpm_list_t **data)
alpm_list_free_inner(lp, (alpm_list_fn_free)_alpm_depmiss_free); alpm_list_free_inner(lp, (alpm_list_fn_free)_alpm_depmiss_free);
alpm_list_free(lp); alpm_list_free(lp);
} }
RET_ERR(handle, PM_ERR_UNSATISFIED_DEPS, -1); RET_ERR(handle, ALPM_ERR_UNSATISFIED_DEPS, -1);
} }
} }
} }
/* re-order w.r.t. dependencies */ /* re-order w.r.t. dependencies */
_alpm_log(handle, PM_LOG_DEBUG, "sorting by dependencies\n"); _alpm_log(handle, ALPM_LOG_DEBUG, "sorting by dependencies\n");
lp = _alpm_sortbydeps(handle, 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 & ALPM_TRANS_FLAG_CASCADE) && (trans->flags & ALPM_TRANS_FLAG_RECURSE)) {
_alpm_log(handle, PM_LOG_DEBUG, "finding removable dependencies\n"); _alpm_log(handle, ALPM_LOG_DEBUG, "finding removable dependencies\n");
_alpm_recursedeps(db, trans->remove, trans->flags & PM_TRANS_FLAG_RECURSEALL); _alpm_recursedeps(db, trans->remove, trans->flags & ALPM_TRANS_FLAG_RECURSEALL);
} }
if(!(trans->flags & PM_TRANS_FLAG_NODEPS)) { if(!(trans->flags & ALPM_TRANS_FLAG_NODEPS)) {
EVENT(trans, PM_TRANS_EVT_CHECKDEPS_DONE, NULL, NULL); EVENT(trans, ALPM_TRANS_EVT_CHECKDEPS_DONE, NULL, NULL);
} }
return 0; return 0;
@ -209,7 +209,7 @@ static int can_remove_file(alpm_handle_t *handle, const alpm_file_t *file,
if(errno != EACCES && errno != ETXTBSY && access(filepath, F_OK) == 0) { if(errno != EACCES && errno != ETXTBSY && access(filepath, 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(handle, PM_LOG_ERROR, _("cannot remove file '%s': %s\n"), _alpm_log(handle, ALPM_LOG_ERROR, _("cannot remove file '%s': %s\n"),
filepath, strerror(errno)); filepath, strerror(errno));
return 0; return 0;
} }
@ -232,7 +232,7 @@ static void unlink_file(alpm_handle_t *handle, alpm_pkg_t *info,
* 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, fileobj->name)) { if(alpm_list_find_str(skip_remove, fileobj->name)) {
_alpm_log(handle, PM_LOG_DEBUG, "%s is in skip_remove, skipping removal\n", _alpm_log(handle, ALPM_LOG_DEBUG, "%s is in skip_remove, skipping removal\n",
file); file);
return; return;
} }
@ -242,23 +242,23 @@ static void unlink_file(alpm_handle_t *handle, alpm_pkg_t *info,
* 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(handle, PM_LOG_DEBUG, "file %s does not exist\n", file); _alpm_log(handle, ALPM_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(handle, PM_LOG_DEBUG, "keeping directory %s\n", file); _alpm_log(handle, ALPM_LOG_DEBUG, "keeping directory %s\n", file);
} else { } else {
_alpm_log(handle, PM_LOG_DEBUG, "removing directory %s\n", file); _alpm_log(handle, ALPM_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 */
alpm_backup_t *backup = _alpm_needbackup(fileobj->name, alpm_pkg_get_backup(info)); alpm_backup_t *backup = _alpm_needbackup(fileobj->name, alpm_pkg_get_backup(info));
if(backup) { if(backup) {
if(nosave) { if(nosave) {
_alpm_log(handle, PM_LOG_DEBUG, "transaction is set to NOSAVE, not backing up '%s'\n", file); _alpm_log(handle, ALPM_LOG_DEBUG, "transaction is set to NOSAVE, not backing up '%s'\n", file);
} else { } else {
char *filehash = alpm_compute_md5sum(file); char *filehash = alpm_compute_md5sum(file);
int cmp = filehash ? strcmp(filehash, backup->hash) : 0; int cmp = filehash ? strcmp(filehash, backup->hash) : 0;
@ -267,17 +267,17 @@ static void unlink_file(alpm_handle_t *handle, alpm_pkg_t *info,
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(handle, PM_LOG_WARNING, _("%s saved as %s\n"), file, newpath); _alpm_log(handle, ALPM_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(handle, PM_LOG_DEBUG, "unlinking %s\n", file); _alpm_log(handle, ALPM_LOG_DEBUG, "unlinking %s\n", file);
if(unlink(file) == -1) { if(unlink(file) == -1) {
_alpm_log(handle, PM_LOG_ERROR, _("cannot remove file '%s': %s\n"), _alpm_log(handle, ALPM_LOG_ERROR, _("cannot remove file '%s': %s\n"),
file, strerror(errno)); file, strerror(errno));
} }
} }
@ -291,10 +291,10 @@ int _alpm_upgraderemove_package(alpm_handle_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(handle, PM_LOG_DEBUG, "removing old package first (%s-%s)\n", _alpm_log(handle, ALPM_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 & ALPM_TRANS_FLAG_DBONLY) {
goto db; goto db;
} }
@ -312,21 +312,21 @@ int _alpm_upgraderemove_package(alpm_handle_t *handle,
if(!_alpm_filelist_contains(filelist, backup->name)) { if(!_alpm_filelist_contains(filelist, backup->name)) {
continue; continue;
} }
_alpm_log(handle, PM_LOG_DEBUG, "adding %s to the skip_remove array\n", _alpm_log(handle, ALPM_LOG_DEBUG, "adding %s to the skip_remove array\n",
backup->name); backup->name);
skip_remove = alpm_list_add(skip_remove, strdup(backup->name)); skip_remove = alpm_list_add(skip_remove, strdup(backup->name));
} }
for(lp = files; lp; lp = lp->next) { for(lp = files; lp; lp = lp->next) {
if(!can_remove_file(handle, lp->data, skip_remove)) { if(!can_remove_file(handle, lp->data, skip_remove)) {
_alpm_log(handle, PM_LOG_DEBUG, _alpm_log(handle, ALPM_LOG_DEBUG,
"not removing package '%s', can't remove all files\n", pkgname); "not removing package '%s', can't remove all files\n", pkgname);
RET_ERR(handle, PM_ERR_PKG_CANT_REMOVE, -1); RET_ERR(handle, ALPM_ERR_PKG_CANT_REMOVE, -1);
} }
filenum++; filenum++;
} }
_alpm_log(handle, PM_LOG_DEBUG, "removing %ld files\n", (unsigned long)filenum); _alpm_log(handle, ALPM_LOG_DEBUG, "removing %ld files\n", (unsigned long)filenum);
/* iterate through the list backwards, unlinking files */ /* iterate through the list backwards, unlinking files */
for(lp = alpm_list_last(files); lp; lp = alpm_list_previous(files, lp)) { for(lp = alpm_list_last(files); lp; lp = alpm_list_previous(files, lp)) {
@ -336,15 +336,15 @@ int _alpm_upgraderemove_package(alpm_handle_t *handle,
db: db:
/* remove the package from the database */ /* remove the package from the database */
_alpm_log(handle, PM_LOG_DEBUG, "updating database\n"); _alpm_log(handle, ALPM_LOG_DEBUG, "updating database\n");
_alpm_log(handle, PM_LOG_DEBUG, "removing database entry '%s'\n", pkgname); _alpm_log(handle, ALPM_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(handle, PM_LOG_ERROR, _("could not remove database entry %s-%s\n"), _alpm_log(handle, ALPM_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(handle, PM_LOG_ERROR, _("could not remove entry '%s' from cache\n"), _alpm_log(handle, ALPM_LOG_ERROR, _("could not remove entry '%s' from cache\n"),
pkgname); pkgname);
} }
@ -376,72 +376,72 @@ int _alpm_remove_packages(alpm_handle_t *handle)
snprintf(scriptlet, PATH_MAX, "%s%s-%s/install", snprintf(scriptlet, PATH_MAX, "%s%s-%s/install",
_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, ALPM_TRANS_EVT_REMOVE_START, info, NULL);
_alpm_log(handle, PM_LOG_DEBUG, "removing package %s-%s\n", _alpm_log(handle, ALPM_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 */
if(alpm_pkg_has_scriptlet(info) && !(trans->flags & PM_TRANS_FLAG_NOSCRIPTLET)) { if(alpm_pkg_has_scriptlet(info) && !(trans->flags & ALPM_TRANS_FLAG_NOSCRIPTLET)) {
_alpm_runscriptlet(handle, scriptlet, "pre_remove", _alpm_runscriptlet(handle, scriptlet, "pre_remove",
alpm_pkg_get_version(info), NULL); alpm_pkg_get_version(info), NULL);
} }
if(!(trans->flags & PM_TRANS_FLAG_DBONLY)) { if(!(trans->flags & ALPM_TRANS_FLAG_DBONLY)) {
alpm_list_t *files = alpm_pkg_get_files(info); alpm_list_t *files = alpm_pkg_get_files(info);
size_t filenum = 0; size_t filenum = 0;
for(lp = files; lp; lp = lp->next) { for(lp = files; lp; lp = lp->next) {
if(!can_remove_file(handle, lp->data, NULL)) { if(!can_remove_file(handle, lp->data, NULL)) {
_alpm_log(handle, PM_LOG_DEBUG, "not removing package '%s', can't remove all files\n", _alpm_log(handle, ALPM_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, ALPM_ERR_PKG_CANT_REMOVE, -1);
} }
filenum++; filenum++;
} }
_alpm_log(handle, PM_LOG_DEBUG, "removing %ld files\n", (unsigned long)filenum); _alpm_log(handle, ALPM_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, ALPM_TRANS_PROGRESS_REMOVE_START, info->name, 0,
pkg_count, (pkg_count - targcount + 1)); pkg_count, (pkg_count - targcount + 1));
/* iterate through the list backwards, unlinking files */ /* iterate through the list backwards, unlinking files */
for(lp = alpm_list_last(files); lp; lp = alpm_list_previous(files, lp)) { for(lp = alpm_list_last(files); lp; lp = alpm_list_previous(files, lp)) {
int percent; int percent;
unlink_file(handle, info, lp->data, NULL, trans->flags & PM_TRANS_FLAG_NOSAVE); unlink_file(handle, info, lp->data, NULL, trans->flags & ALPM_TRANS_FLAG_NOSAVE);
/* update progress bar after each file */ /* update progress bar after each file */
percent = (position * 100) / filenum; percent = (position * 100) / filenum;
PROGRESS(trans, PM_TRANS_PROGRESS_REMOVE_START, info->name, PROGRESS(trans, ALPM_TRANS_PROGRESS_REMOVE_START, info->name,
percent, pkg_count, (pkg_count - targcount + 1)); percent, pkg_count, (pkg_count - targcount + 1));
position++; position++;
} }
} }
/* set progress to 100% after we finish unlinking files */ /* set progress to 100% after we finish unlinking files */
PROGRESS(trans, PM_TRANS_PROGRESS_REMOVE_START, pkgname, 100, PROGRESS(trans, ALPM_TRANS_PROGRESS_REMOVE_START, pkgname, 100,
pkg_count, (pkg_count - targcount + 1)); pkg_count, (pkg_count - targcount + 1));
/* run the post-remove script if it exists */ /* run the post-remove script if it exists */
if(alpm_pkg_has_scriptlet(info) && !(trans->flags & PM_TRANS_FLAG_NOSCRIPTLET)) { if(alpm_pkg_has_scriptlet(info) && !(trans->flags & ALPM_TRANS_FLAG_NOSCRIPTLET)) {
_alpm_runscriptlet(handle, scriptlet, "post_remove", _alpm_runscriptlet(handle, scriptlet, "post_remove",
alpm_pkg_get_version(info), NULL); alpm_pkg_get_version(info), NULL);
} }
/* remove the package from the database */ /* remove the package from the database */
_alpm_log(handle, PM_LOG_DEBUG, "updating database\n"); _alpm_log(handle, ALPM_LOG_DEBUG, "updating database\n");
_alpm_log(handle, PM_LOG_DEBUG, "removing database entry '%s'\n", pkgname); _alpm_log(handle, ALPM_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(handle, PM_LOG_ERROR, _("could not remove database entry %s-%s\n"), _alpm_log(handle, ALPM_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(handle, PM_LOG_ERROR, _("could not remove entry '%s' from cache\n"), _alpm_log(handle, ALPM_LOG_ERROR, _("could not remove entry '%s' from cache\n"),
pkgname); pkgname);
} }
EVENT(trans, PM_TRANS_EVT_REMOVE_DONE, info, NULL); EVENT(trans, ALPM_TRANS_EVT_REMOVE_DONE, info, NULL);
} }
/* run ldconfig if it exists */ /* run ldconfig if it exists */

View File

@ -118,13 +118,13 @@ static int init_gpgme(alpm_handle_t *handle)
sigdir = alpm_option_get_gpgdir(handle); sigdir = alpm_option_get_gpgdir(handle);
if(!sigdir) { if(!sigdir) {
RET_ERR(handle, PM_ERR_SIG_MISSINGDIR, 1); RET_ERR(handle, ALPM_ERR_SIG_MISSINGDIR, 1);
} }
/* 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(handle, PM_LOG_DEBUG, "GPGME version: %s\n", version); _alpm_log(handle, ALPM_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));
@ -146,15 +146,15 @@ static int init_gpgme(alpm_handle_t *handle)
CHECK_ERR(); CHECK_ERR();
err = gpgme_get_engine_info(&enginfo); err = gpgme_get_engine_info(&enginfo);
CHECK_ERR(); CHECK_ERR();
_alpm_log(handle, PM_LOG_DEBUG, "GPGME engine info: file=%s, home=%s\n", _alpm_log(handle, ALPM_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(handle, PM_LOG_ERROR, _("GPGME error: %s\n"), gpgme_strerror(err)); _alpm_log(handle, ALPM_LOG_ERROR, _("GPGME error: %s\n"), gpgme_strerror(err));
RET_ERR(handle, PM_ERR_GPGME, 1); RET_ERR(handle, ALPM_ERR_GPGME, 1);
} }
/** /**
@ -219,17 +219,17 @@ int _alpm_gpgme_checksig(alpm_handle_t *handle, const char *path,
FILE *file = NULL, *sigfile = NULL; FILE *file = NULL, *sigfile = NULL;
if(!path || access(path, R_OK) != 0) { if(!path || access(path, R_OK) != 0) {
RET_ERR(handle, PM_ERR_NOT_A_FILE, -1); RET_ERR(handle, ALPM_ERR_NOT_A_FILE, -1);
} }
if(!base64_sig) { if(!base64_sig) {
size_t len = strlen(path) + 5; size_t len = strlen(path) + 5;
CALLOC(sigpath, len, sizeof(char), RET_ERR(handle, PM_ERR_MEMORY, -1)); CALLOC(sigpath, len, sizeof(char), RET_ERR(handle, ALPM_ERR_MEMORY, -1));
snprintf(sigpath, len, "%s.sig", path); snprintf(sigpath, len, "%s.sig", path);
if(!access(sigpath, R_OK) == 0) { if(!access(sigpath, R_OK) == 0) {
FREE(sigpath); FREE(sigpath);
RET_ERR(handle, PM_ERR_SIG_UNKNOWN, -1); RET_ERR(handle, ALPM_ERR_SIG_UNKNOWN, -1);
} }
} }
@ -238,7 +238,7 @@ int _alpm_gpgme_checksig(alpm_handle_t *handle, const char *path,
return -1; return -1;
} }
_alpm_log(handle, PM_LOG_DEBUG, "checking signature for %s\n", path); _alpm_log(handle, ALPM_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));
@ -250,7 +250,7 @@ int _alpm_gpgme_checksig(alpm_handle_t *handle, const char *path,
/* create our necessary data objects to verify the signature */ /* create our necessary data objects to verify the signature */
file = fopen(path, "rb"); file = fopen(path, "rb");
if(file == NULL) { if(file == NULL) {
handle->pm_errno = PM_ERR_NOT_A_FILE; handle->pm_errno = ALPM_ERR_NOT_A_FILE;
ret = -1; ret = -1;
goto error; goto error;
} }
@ -273,7 +273,7 @@ int _alpm_gpgme_checksig(alpm_handle_t *handle, const char *path,
/* file-based, it is on disk */ /* file-based, it is on disk */
sigfile = fopen(sigpath, "rb"); sigfile = fopen(sigpath, "rb");
if(sigfile == NULL) { if(sigfile == NULL) {
handle->pm_errno = PM_ERR_NOT_A_FILE; handle->pm_errno = ALPM_ERR_NOT_A_FILE;
ret = -1; ret = -1;
goto error; goto error;
} }
@ -287,7 +287,7 @@ int _alpm_gpgme_checksig(alpm_handle_t *handle, const char *path,
result = gpgme_op_verify_result(ctx); result = gpgme_op_verify_result(ctx);
gpgsig = result->signatures; gpgsig = result->signatures;
if(!gpgsig) { if(!gpgsig) {
_alpm_log(handle, PM_LOG_DEBUG, "no signatures returned\n"); _alpm_log(handle, ALPM_LOG_DEBUG, "no signatures returned\n");
ret = -1; ret = -1;
goto error; goto error;
} }
@ -295,16 +295,16 @@ int _alpm_gpgme_checksig(alpm_handle_t *handle, const char *path,
while(gpgsig) { while(gpgsig) {
alpm_list_t *summary_list, *summary; alpm_list_t *summary_list, *summary;
_alpm_log(handle, PM_LOG_DEBUG, "fingerprint: %s\n", gpgsig->fpr); _alpm_log(handle, ALPM_LOG_DEBUG, "fingerprint: %s\n", gpgsig->fpr);
summary_list = list_sigsum(gpgsig->summary); summary_list = list_sigsum(gpgsig->summary);
for(summary = summary_list; summary; summary = summary->next) { for(summary = summary_list; summary; summary = summary->next) {
_alpm_log(handle, PM_LOG_DEBUG, "summary: %s\n", (const char *)summary->data); _alpm_log(handle, ALPM_LOG_DEBUG, "summary: %s\n", (const char *)summary->data);
} }
alpm_list_free(summary_list); alpm_list_free(summary_list);
_alpm_log(handle, PM_LOG_DEBUG, "status: %s\n", gpgme_strerror(gpgsig->status)); _alpm_log(handle, ALPM_LOG_DEBUG, "status: %s\n", gpgme_strerror(gpgsig->status));
_alpm_log(handle, PM_LOG_DEBUG, "timestamp: %lu\n", gpgsig->timestamp); _alpm_log(handle, ALPM_LOG_DEBUG, "timestamp: %lu\n", gpgsig->timestamp);
_alpm_log(handle, PM_LOG_DEBUG, "exp_timestamp: %lu\n", gpgsig->exp_timestamp); _alpm_log(handle, ALPM_LOG_DEBUG, "exp_timestamp: %lu\n", gpgsig->exp_timestamp);
_alpm_log(handle, PM_LOG_DEBUG, "validity: %s; reason: %s\n", _alpm_log(handle, ALPM_LOG_DEBUG, "validity: %s; reason: %s\n",
string_validity(gpgsig->validity), string_validity(gpgsig->validity),
gpgme_strerror(gpgsig->validity_reason)); gpgme_strerror(gpgsig->validity_reason));
@ -313,23 +313,23 @@ int _alpm_gpgme_checksig(alpm_handle_t *handle, const char *path,
* worst case wins out. */ * worst case wins out. */
if(gpgsig->summary & GPGME_SIGSUM_VALID) { if(gpgsig->summary & GPGME_SIGSUM_VALID) {
/* definite good signature */ /* definite good signature */
_alpm_log(handle, PM_LOG_DEBUG, "result: valid signature\n"); _alpm_log(handle, ALPM_LOG_DEBUG, "result: valid signature\n");
} else if(gpgsig->summary & GPGME_SIGSUM_GREEN) { } else if(gpgsig->summary & GPGME_SIGSUM_GREEN) {
/* good signature */ /* good signature */
_alpm_log(handle, PM_LOG_DEBUG, "result: green signature\n"); _alpm_log(handle, ALPM_LOG_DEBUG, "result: green signature\n");
} else if(gpgsig->summary & GPGME_SIGSUM_RED) { } else if(gpgsig->summary & GPGME_SIGSUM_RED) {
/* definite bad signature, error */ /* definite bad signature, error */
_alpm_log(handle, PM_LOG_DEBUG, "result: red signature\n"); _alpm_log(handle, ALPM_LOG_DEBUG, "result: red signature\n");
handle->pm_errno = PM_ERR_SIG_INVALID; handle->pm_errno = ALPM_ERR_SIG_INVALID;
ret = 1; ret = 1;
} else if(gpgsig->summary & GPGME_SIGSUM_KEY_MISSING) { } else if(gpgsig->summary & GPGME_SIGSUM_KEY_MISSING) {
_alpm_log(handle, PM_LOG_DEBUG, "result: signature from unknown key\n"); _alpm_log(handle, ALPM_LOG_DEBUG, "result: signature from unknown key\n");
handle->pm_errno = PM_ERR_SIG_UNKNOWN; handle->pm_errno = ALPM_ERR_SIG_UNKNOWN;
ret = 1; ret = 1;
} else { } else {
/* we'll capture everything else here */ /* we'll capture everything else here */
_alpm_log(handle, PM_LOG_DEBUG, "result: invalid signature\n"); _alpm_log(handle, ALPM_LOG_DEBUG, "result: invalid signature\n");
handle->pm_errno = PM_ERR_SIG_INVALID; handle->pm_errno = ALPM_ERR_SIG_INVALID;
ret = 1; ret = 1;
} }
@ -349,8 +349,8 @@ 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(handle, PM_LOG_ERROR, _("GPGME error: %s\n"), gpgme_strerror(err)); _alpm_log(handle, ALPM_LOG_ERROR, _("GPGME error: %s\n"), gpgme_strerror(err));
RET_ERR(handle, PM_ERR_GPGME, -1); RET_ERR(handle, ALPM_ERR_GPGME, -1);
} }
return ret; return ret;
} }

View File

@ -66,14 +66,14 @@ alpm_pkg_t SYMEXPORT *alpm_sync_newversion(alpm_pkg_t *pkg, alpm_list_t *dbs_syn
} }
if(spkg == NULL) { if(spkg == NULL) {
_alpm_log(pkg->handle, PM_LOG_DEBUG, "'%s' not found in sync db => no upgrade\n", _alpm_log(pkg->handle, ALPM_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(pkg->handle, PM_LOG_DEBUG, "new version of '%s' found (%s => %s)\n", _alpm_log(pkg->handle, ALPM_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;
@ -94,15 +94,15 @@ int SYMEXPORT alpm_sync_sysupgrade(alpm_handle_t *handle, int enable_downgrade)
trans = handle->trans; trans = handle->trans;
db_local = handle->db_local; db_local = handle->db_local;
dbs_sync = handle->dbs_sync; dbs_sync = handle->dbs_sync;
ASSERT(trans != NULL, RET_ERR(handle, PM_ERR_TRANS_NULL, -1)); ASSERT(trans != NULL, RET_ERR(handle, ALPM_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, ALPM_ERR_TRANS_NOT_INITIALIZED, -1));
_alpm_log(handle, PM_LOG_DEBUG, "checking for package upgrades\n"); _alpm_log(handle, ALPM_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) {
alpm_pkg_t *lpkg = i->data; alpm_pkg_t *lpkg = i->data;
if(_alpm_pkg_find(trans->add, lpkg->name)) { if(_alpm_pkg_find(trans->add, lpkg->name)) {
_alpm_log(handle, PM_LOG_DEBUG, "%s is already in the target list -- skipping\n", lpkg->name); _alpm_log(handle, ALPM_LOG_DEBUG, "%s is already in the target list -- skipping\n", lpkg->name);
continue; continue;
} }
@ -116,15 +116,15 @@ int SYMEXPORT alpm_sync_sysupgrade(alpm_handle_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(handle, PM_LOG_DEBUG, "new version of '%s' found (%s => %s)\n", _alpm_log(handle, ALPM_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(handle, spkg) if(_alpm_pkg_should_ignore(handle, spkg)
|| _alpm_pkg_should_ignore(handle, lpkg)) { || _alpm_pkg_should_ignore(handle, lpkg)) {
_alpm_log(handle, PM_LOG_WARNING, _("%s: ignoring package upgrade (%s => %s)\n"), _alpm_log(handle, ALPM_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(handle, PM_LOG_DEBUG, "adding package %s-%s to the transaction targets\n", _alpm_log(handle, ALPM_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);
} }
@ -133,15 +133,15 @@ int SYMEXPORT alpm_sync_sysupgrade(alpm_handle_t *handle, int enable_downgrade)
/* check IgnorePkg/IgnoreGroup */ /* check IgnorePkg/IgnoreGroup */
if(_alpm_pkg_should_ignore(handle, spkg) if(_alpm_pkg_should_ignore(handle, spkg)
|| _alpm_pkg_should_ignore(handle, lpkg)) { || _alpm_pkg_should_ignore(handle, lpkg)) {
_alpm_log(handle, PM_LOG_WARNING, _("%s: ignoring package downgrade (%s => %s)\n"), _alpm_log(handle, ALPM_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(handle, PM_LOG_WARNING, _("%s: downgrading from version %s to version %s\n"), _alpm_log(handle, ALPM_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(handle, PM_LOG_WARNING, _("%s: local (%s) is newer than %s (%s)\n"), _alpm_log(handle, ALPM_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);
} }
} }
@ -157,13 +157,13 @@ int SYMEXPORT alpm_sync_sysupgrade(alpm_handle_t *handle, int enable_downgrade)
/* check IgnorePkg/IgnoreGroup */ /* check IgnorePkg/IgnoreGroup */
if(_alpm_pkg_should_ignore(handle, spkg) if(_alpm_pkg_should_ignore(handle, spkg)
|| _alpm_pkg_should_ignore(handle, lpkg)) { || _alpm_pkg_should_ignore(handle, lpkg)) {
_alpm_log(handle, PM_LOG_WARNING, _("ignoring package replacement (%s-%s => %s-%s)\n"), _alpm_log(handle, ALPM_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;
} }
int doreplace = 0; int doreplace = 0;
QUESTION(trans, PM_TRANS_CONV_REPLACE_PKG, lpkg, spkg, sdb->treename, &doreplace); QUESTION(trans, ALPM_TRANS_CONV_REPLACE_PKG, lpkg, spkg, sdb->treename, &doreplace);
if(!doreplace) { if(!doreplace) {
continue; continue;
} }
@ -174,23 +174,23 @@ int SYMEXPORT alpm_sync_sysupgrade(alpm_handle_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(handle, PM_LOG_WARNING, _("cannot replace %s by %s\n"), _alpm_log(handle, ALPM_LOG_WARNING, _("cannot replace %s by %s\n"),
lpkg->name, spkg->name); lpkg->name, spkg->name);
continue; continue;
} }
_alpm_log(handle, PM_LOG_DEBUG, "appending %s to the removes list of %s\n", _alpm_log(handle, ALPM_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 */
if(alpm_pkg_get_reason(lpkg) == PM_PKG_REASON_EXPLICIT) { if(alpm_pkg_get_reason(lpkg) == ALPM_PKG_REASON_EXPLICIT) {
tpkg->reason = PM_PKG_REASON_EXPLICIT; tpkg->reason = ALPM_PKG_REASON_EXPLICIT;
} }
} else { } else {
/* add spkg to the target list */ /* add spkg to the target list */
/* 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(handle, PM_LOG_DEBUG, "adding package %s-%s to the transaction targets\n", _alpm_log(handle, ALPM_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);
} }
@ -234,7 +234,7 @@ alpm_list_t SYMEXPORT *alpm_find_group_pkgs(alpm_list_t *dbs,
if(_alpm_pkg_should_ignore(db->handle, pkg)) { if(_alpm_pkg_should_ignore(db->handle, pkg)) {
ignorelist = alpm_list_add(ignorelist, pkg); ignorelist = alpm_list_add(ignorelist, pkg);
int install = 0; int install = 0;
QUESTION(db->handle->trans, PM_TRANS_CONV_INSTALL_IGNOREPKG, pkg, QUESTION(db->handle->trans, ALPM_TRANS_CONV_INSTALL_IGNOREPKG, pkg,
NULL, NULL, &install); NULL, NULL, &install);
if(!install) if(!install)
continue; continue;
@ -266,7 +266,7 @@ static int compute_download_size(alpm_pkg_t *newpkg)
} }
fname = alpm_pkg_get_filename(newpkg); fname = alpm_pkg_get_filename(newpkg);
ASSERT(fname != NULL, RET_ERR(handle, PM_ERR_PKG_INVALID_NAME, -1)); ASSERT(fname != NULL, RET_ERR(handle, ALPM_ERR_PKG_INVALID_NAME, -1));
fpath = _alpm_filecache_find(handle, fname); fpath = _alpm_filecache_find(handle, fname);
if(fpath) { if(fpath) {
@ -282,10 +282,10 @@ static int compute_download_size(alpm_pkg_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(handle, PM_LOG_DEBUG, "using delta size\n"); _alpm_log(handle, ALPM_LOG_DEBUG, "using delta size\n");
size = dltsize; size = dltsize;
} else { } else {
_alpm_log(handle, PM_LOG_DEBUG, "using package size\n"); _alpm_log(handle, ALPM_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;
@ -294,7 +294,7 @@ static int compute_download_size(alpm_pkg_t *newpkg)
size = alpm_pkg_get_size(newpkg); size = alpm_pkg_get_size(newpkg);
} }
_alpm_log(handle, PM_LOG_DEBUG, "setting download size %jd for pkg %s\n", _alpm_log(handle, ALPM_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;
@ -315,13 +315,13 @@ int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data)
*data = NULL; *data = NULL;
} }
if(!(trans->flags & PM_TRANS_FLAG_NODEPS)) { if(!(trans->flags & ALPM_TRANS_FLAG_NODEPS)) {
alpm_list_t *resolved = NULL; /* target list after resolvedeps */ alpm_list_t *resolved = NULL; /* target list after resolvedeps */
/* 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, ALPM_TRANS_EVT_RESOLVEDEPS_START, NULL, NULL);
_alpm_log(handle, PM_LOG_DEBUG, "resolving target's dependencies\n"); _alpm_log(handle, ALPM_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) {
@ -353,7 +353,7 @@ int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data)
see if they'd like to ignore them rather than failing the sync */ see if they'd like to ignore them rather than failing the sync */
if(unresolvable != NULL) { if(unresolvable != NULL) {
int remove_unresolvable = 0; int remove_unresolvable = 0;
QUESTION(trans, PM_TRANS_CONV_REMOVE_PKGS, unresolvable, QUESTION(trans, ALPM_TRANS_CONV_REMOVE_PKGS, unresolvable,
NULL, NULL, &remove_unresolvable); NULL, NULL, &remove_unresolvable);
if(remove_unresolvable) { if(remove_unresolvable) {
/* User wants to remove the unresolvable packages from the /* User wants to remove the unresolvable packages from the
@ -378,7 +378,7 @@ int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data)
for(i = resolved; i; i = i->next) { for(i = resolved; i; i = i->next) {
alpm_pkg_t *pkg = i->data; alpm_pkg_t *pkg = i->data;
if(!_alpm_pkg_find(trans->add, pkg->name)) { if(!_alpm_pkg_find(trans->add, pkg->name)) {
pkg->reason = PM_PKG_REASON_DEPEND; pkg->reason = ALPM_PKG_REASON_DEPEND;
} }
} }
@ -391,17 +391,17 @@ int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data)
trans->add = _alpm_sortbydeps(handle, 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, ALPM_TRANS_EVT_RESOLVEDEPS_DONE, NULL, NULL);
} }
if(!(trans->flags & PM_TRANS_FLAG_NOCONFLICTS)) { if(!(trans->flags & ALPM_TRANS_FLAG_NOCONFLICTS)) {
/* check for inter-conflicts and whatnot */ /* check for inter-conflicts and whatnot */
EVENT(trans, PM_TRANS_EVT_INTERCONFLICTS_START, NULL, NULL); EVENT(trans, ALPM_TRANS_EVT_INTERCONFLICTS_START, NULL, NULL);
_alpm_log(handle, PM_LOG_DEBUG, "looking for conflicts\n"); _alpm_log(handle, ALPM_LOG_DEBUG, "looking for conflicts\n");
/* 1. check for conflicts in the target list */ /* 1. check for conflicts in the target list */
_alpm_log(handle, PM_LOG_DEBUG, "check targets vs targets\n"); _alpm_log(handle, ALPM_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) {
@ -415,7 +415,7 @@ int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data)
continue; continue;
} }
_alpm_log(handle, PM_LOG_DEBUG, "conflicting packages in the sync list: '%s' <-> '%s'\n", _alpm_log(handle, ALPM_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 */
@ -428,8 +428,8 @@ int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data)
rsync = sync1; rsync = sync1;
sync = sync2; sync = sync2;
} else { } else {
_alpm_log(handle, PM_LOG_ERROR, _("unresolvable package conflicts detected\n")); _alpm_log(handle, ALPM_LOG_ERROR, _("unresolvable package conflicts detected\n"));
handle->pm_errno = PM_ERR_CONFLICTING_DEPS; handle->pm_errno = ALPM_ERR_CONFLICTING_DEPS;
ret = -1; ret = -1;
if(data) { if(data) {
alpm_conflict_t *newconflict = _alpm_conflict_dup(conflict); alpm_conflict_t *newconflict = _alpm_conflict_dup(conflict);
@ -447,7 +447,7 @@ int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data)
_alpm_dep_free(dep2); _alpm_dep_free(dep2);
/* Prints warning */ /* Prints warning */
_alpm_log(handle, PM_LOG_WARNING, _alpm_log(handle, ALPM_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);
@ -460,7 +460,7 @@ int _alpm_sync_prepare(alpm_handle_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(handle, PM_LOG_DEBUG, "check targets vs db and db vs targets\n"); _alpm_log(handle, ALPM_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) {
@ -479,21 +479,21 @@ int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data)
continue; continue;
} }
_alpm_log(handle, PM_LOG_DEBUG, "package '%s' conflicts with '%s'\n", _alpm_log(handle, ALPM_LOG_DEBUG, "package '%s' conflicts with '%s'\n",
conflict->package1, conflict->package2); conflict->package1, conflict->package2);
alpm_pkg_t *sync = _alpm_pkg_find(trans->add, conflict->package1); alpm_pkg_t *sync = _alpm_pkg_find(trans->add, conflict->package1);
alpm_pkg_t *local = _alpm_db_get_pkgfromcache(handle->db_local, conflict->package2); alpm_pkg_t *local = _alpm_db_get_pkgfromcache(handle->db_local, conflict->package2);
int doremove = 0; int doremove = 0;
QUESTION(trans, PM_TRANS_CONV_CONFLICT_PKG, conflict->package1, QUESTION(trans, ALPM_TRANS_CONV_CONFLICT_PKG, conflict->package1,
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(handle, PM_LOG_DEBUG, "electing '%s' for removal\n", conflict->package2); _alpm_log(handle, ALPM_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(handle, PM_LOG_ERROR, _("unresolvable package conflicts detected\n")); _alpm_log(handle, ALPM_LOG_ERROR, _("unresolvable package conflicts detected\n"));
handle->pm_errno = PM_ERR_CONFLICTING_DEPS; handle->pm_errno = ALPM_ERR_CONFLICTING_DEPS;
ret = -1; ret = -1;
if(data) { if(data) {
alpm_conflict_t *newconflict = _alpm_conflict_dup(conflict); alpm_conflict_t *newconflict = _alpm_conflict_dup(conflict);
@ -506,7 +506,7 @@ int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data)
goto cleanup; goto cleanup;
} }
} }
EVENT(trans, PM_TRANS_EVT_INTERCONFLICTS_DONE, NULL, NULL); EVENT(trans, ALPM_TRANS_EVT_INTERCONFLICTS_DONE, NULL, NULL);
alpm_list_free_inner(deps, (alpm_list_fn_free)_alpm_conflict_free); alpm_list_free_inner(deps, (alpm_list_fn_free)_alpm_conflict_free);
alpm_list_free(deps); alpm_list_free(deps);
} }
@ -517,18 +517,18 @@ int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data)
for(j = spkg->removes; j; j = j->next) { for(j = spkg->removes; j; j = j->next) {
alpm_pkg_t *rpkg = j->data; alpm_pkg_t *rpkg = j->data;
if(!_alpm_pkg_find(trans->remove, rpkg->name)) { if(!_alpm_pkg_find(trans->remove, rpkg->name)) {
_alpm_log(handle, PM_LOG_DEBUG, "adding '%s' to remove list\n", rpkg->name); _alpm_log(handle, ALPM_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 & ALPM_TRANS_FLAG_NODEPS)) {
_alpm_log(handle, PM_LOG_DEBUG, "checking dependencies\n"); _alpm_log(handle, ALPM_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) {
handle->pm_errno = PM_ERR_UNSATISFIED_DEPS; handle->pm_errno = ALPM_ERR_UNSATISFIED_DEPS;
ret = -1; ret = -1;
if(data) { if(data) {
*data = deps; *data = deps;
@ -612,11 +612,11 @@ static int apply_deltas(alpm_handle_t *handle)
} else { } else {
/* len = cachedir len + from len + '/' + null */ /* len = cachedir len + from len + '/' + null */
len = strlen(cachedir) + strlen(d->from) + 2; len = strlen(cachedir) + strlen(d->from) + 2;
CALLOC(from, len, sizeof(char), RET_ERR(handle, PM_ERR_MEMORY, 1)); CALLOC(from, len, sizeof(char), RET_ERR(handle, ALPM_ERR_MEMORY, 1));
snprintf(from, len, "%s/%s", cachedir, d->from); snprintf(from, len, "%s/%s", cachedir, d->from);
} }
len = strlen(cachedir) + strlen(d->to) + 2; len = strlen(cachedir) + strlen(d->to) + 2;
CALLOC(to, len, sizeof(char), RET_ERR(handle, PM_ERR_MEMORY, 1)); CALLOC(to, len, sizeof(char), RET_ERR(handle, ALPM_ERR_MEMORY, 1));
snprintf(to, len, "%s/%s", cachedir, d->to); snprintf(to, len, "%s/%s", cachedir, d->to);
/* build the patch command */ /* build the patch command */
@ -627,13 +627,13 @@ static int apply_deltas(alpm_handle_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(handle, PM_LOG_DEBUG, "command: %s\n", command); _alpm_log(handle, ALPM_LOG_DEBUG, "command: %s\n", command);
EVENT(trans, PM_TRANS_EVT_DELTA_PATCH_START, d->to, d->delta); EVENT(trans, ALPM_TRANS_EVT_DELTA_PATCH_START, d->to, d->delta);
int retval = system(command); int retval = system(command);
if(retval == 0) { if(retval == 0) {
EVENT(trans, PM_TRANS_EVT_DELTA_PATCH_DONE, NULL, NULL); EVENT(trans, ALPM_TRANS_EVT_DELTA_PATCH_DONE, NULL, NULL);
/* delete the delta file */ /* delete the delta file */
unlink(delta); unlink(delta);
@ -651,8 +651,8 @@ static int apply_deltas(alpm_handle_t *handle)
if(retval != 0) { if(retval != 0) {
/* one delta failed for this package, cancel the remaining ones */ /* one delta failed for this package, cancel the remaining ones */
EVENT(trans, PM_TRANS_EVT_DELTA_PATCH_FAILED, NULL, NULL); EVENT(trans, ALPM_TRANS_EVT_DELTA_PATCH_FAILED, NULL, NULL);
handle->pm_errno = PM_ERR_DLT_PATCHFAILED; handle->pm_errno = ALPM_ERR_DLT_PATCHFAILED;
ret = 1; ret = 1;
break; break;
} }
@ -679,7 +679,7 @@ static int test_md5sum(alpm_trans_t *trans, const char *filepath,
int ret = _alpm_test_md5sum(filepath, md5sum); int ret = _alpm_test_md5sum(filepath, md5sum);
if(ret == 1) { if(ret == 1) {
int doremove = 0; int doremove = 0;
QUESTION(trans, PM_TRANS_CONV_CORRUPTED_PKG, (char *)filepath, QUESTION(trans, ALPM_TRANS_CONV_CORRUPTED_PKG, (char *)filepath,
NULL, NULL, &doremove); NULL, NULL, &doremove);
if(doremove) { if(doremove) {
unlink(filepath); unlink(filepath);
@ -701,7 +701,7 @@ static int validate_deltas(alpm_handle_t *handle, alpm_list_t *deltas,
} }
/* Check integrity of deltas */ /* Check integrity of deltas */
EVENT(trans, PM_TRANS_EVT_DELTA_INTEGRITY_START, NULL, NULL); EVENT(trans, ALPM_TRANS_EVT_DELTA_INTEGRITY_START, NULL, NULL);
for(i = deltas; i; i = i->next) { for(i = deltas; i; i = i->next) {
alpm_delta_t *d = alpm_list_getdata(i); alpm_delta_t *d = alpm_list_getdata(i);
@ -714,15 +714,15 @@ static int validate_deltas(alpm_handle_t *handle, alpm_list_t *deltas,
FREE(filepath); FREE(filepath);
} }
if(errors) { if(errors) {
handle->pm_errno = PM_ERR_DLT_INVALID; handle->pm_errno = ALPM_ERR_DLT_INVALID;
return -1; return -1;
} }
EVENT(trans, PM_TRANS_EVT_DELTA_INTEGRITY_DONE, NULL, NULL); EVENT(trans, ALPM_TRANS_EVT_DELTA_INTEGRITY_DONE, NULL, NULL);
/* Use the deltas to generate the packages */ /* Use the deltas to generate the packages */
EVENT(trans, PM_TRANS_EVT_DELTA_PATCHES_START, NULL, NULL); EVENT(trans, ALPM_TRANS_EVT_DELTA_PATCHES_START, NULL, NULL);
ret = apply_deltas(handle); ret = apply_deltas(handle);
EVENT(trans, PM_TRANS_EVT_DELTA_PATCHES_DONE, NULL, NULL); EVENT(trans, ALPM_TRANS_EVT_DELTA_PATCHES_DONE, NULL, NULL);
return ret; return ret;
} }
@ -760,7 +760,7 @@ static int download_files(alpm_handle_t *handle, alpm_list_t **deltas)
const char *fname = NULL; const char *fname = NULL;
fname = alpm_pkg_get_filename(spkg); fname = alpm_pkg_get_filename(spkg);
ASSERT(fname != NULL, RET_ERR(handle, PM_ERR_PKG_INVALID_NAME, -1)); ASSERT(fname != NULL, RET_ERR(handle, ALPM_ERR_PKG_INVALID_NAME, -1));
alpm_list_t *delta_path = spkg->delta_path; alpm_list_t *delta_path = spkg->delta_path;
if(delta_path) { if(delta_path) {
/* using deltas */ /* using deltas */
@ -782,7 +782,7 @@ static int download_files(alpm_handle_t *handle, alpm_list_t **deltas)
} }
if(files) { if(files) {
EVENT(handle->trans, PM_TRANS_EVT_RETRIEVE_START, current->treename, NULL); EVENT(handle->trans, ALPM_TRANS_EVT_RETRIEVE_START, current->treename, NULL);
for(j = files; j; j = j->next) { for(j = files; j; j = j->next) {
const char *filename = j->data; const char *filename = j->data;
alpm_list_t *server; alpm_list_t *server;
@ -794,7 +794,7 @@ static int download_files(alpm_handle_t *handle, alpm_list_t **deltas)
/* print server + filename into a buffer */ /* print server + filename into a buffer */
len = strlen(server_url) + strlen(filename) + 2; len = strlen(server_url) + strlen(filename) + 2;
CALLOC(fileurl, len, sizeof(char), RET_ERR(handle, PM_ERR_MEMORY, -1)); CALLOC(fileurl, len, sizeof(char), RET_ERR(handle, ALPM_ERR_MEMORY, -1));
snprintf(fileurl, len, "%s/%s", server_url, filename); snprintf(fileurl, len, "%s/%s", server_url, filename);
ret = _alpm_download(handle, fileurl, cachedir, 0, 1, 0); ret = _alpm_download(handle, fileurl, cachedir, 0, 1, 0);
@ -810,10 +810,10 @@ static int download_files(alpm_handle_t *handle, alpm_list_t **deltas)
FREELIST(files); FREELIST(files);
if(errors) { if(errors) {
_alpm_log(handle, PM_LOG_WARNING, _("failed to retrieve some files from %s\n"), _alpm_log(handle, ALPM_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 = ALPM_ERR_RETRIEVE;
} }
return -1; return -1;
} }
@ -854,7 +854,7 @@ int _alpm_sync_commit(alpm_handle_t *handle, alpm_list_t **data)
/* Check integrity of packages */ /* Check integrity of packages */
numtargs = alpm_list_count(trans->add); numtargs = alpm_list_count(trans->add);
EVENT(trans, PM_TRANS_EVT_INTEGRITY_START, NULL, NULL); EVENT(trans, ALPM_TRANS_EVT_INTEGRITY_START, NULL, NULL);
errors = 0; errors = 0;
@ -865,7 +865,7 @@ int _alpm_sync_commit(alpm_handle_t *handle, alpm_list_t **data)
char *filepath; char *filepath;
pgp_verify_t check_sig; pgp_verify_t check_sig;
PROGRESS(trans, PM_TRANS_PROGRESS_INTEGRITY_START, "", percent, PROGRESS(trans, ALPM_TRANS_PROGRESS_INTEGRITY_START, "", percent,
numtargs, current); numtargs, current);
if(spkg->origin == PKG_FROM_FILE) { if(spkg->origin == PKG_FROM_FILE) {
continue; /* pkg_load() has been already called, this package is valid */ continue; /* pkg_load() has been already called, this package is valid */
@ -878,7 +878,7 @@ int _alpm_sync_commit(alpm_handle_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(handle, PM_LOG_DEBUG, _alpm_log(handle, ALPM_LOG_DEBUG,
"replacing pkgcache entry with package file for target %s\n", "replacing pkgcache entry with package file for target %s\n",
spkg->name); spkg->name);
alpm_pkg_t *pkgfile =_alpm_pkg_load_internal(handle, filepath, 1, spkg->md5sum, alpm_pkg_t *pkgfile =_alpm_pkg_load_internal(handle, filepath, 1, spkg->md5sum,
@ -895,16 +895,16 @@ int _alpm_sync_commit(alpm_handle_t *handle, alpm_list_t **data)
_alpm_pkg_free_trans(spkg); /* spkg has been removed from the target list */ _alpm_pkg_free_trans(spkg); /* spkg has been removed from the target list */
} }
PROGRESS(trans, PM_TRANS_PROGRESS_INTEGRITY_START, "", 100, PROGRESS(trans, ALPM_TRANS_PROGRESS_INTEGRITY_START, "", 100,
numtargs, current); numtargs, current);
EVENT(trans, PM_TRANS_EVT_INTEGRITY_DONE, NULL, NULL); EVENT(trans, ALPM_TRANS_EVT_INTEGRITY_DONE, NULL, NULL);
if(errors) { if(errors) {
RET_ERR(handle, PM_ERR_PKG_INVALID, -1); RET_ERR(handle, ALPM_ERR_PKG_INVALID, -1);
} }
if(trans->flags & PM_TRANS_FLAG_DOWNLOADONLY) { if(trans->flags & ALPM_TRANS_FLAG_DOWNLOADONLY) {
return 0; return 0;
} }
@ -913,10 +913,10 @@ int _alpm_sync_commit(alpm_handle_t *handle, alpm_list_t **data)
replaces = alpm_list_count(trans->remove); replaces = alpm_list_count(trans->remove);
/* fileconflict check */ /* fileconflict check */
if(!(trans->flags & PM_TRANS_FLAG_FORCE)) { if(!(trans->flags & ALPM_TRANS_FLAG_FORCE)) {
EVENT(trans, PM_TRANS_EVT_FILECONFLICTS_START, NULL, NULL); EVENT(trans, ALPM_TRANS_EVT_FILECONFLICTS_START, NULL, NULL);
_alpm_log(handle, PM_LOG_DEBUG, "looking for file conflicts\n"); _alpm_log(handle, ALPM_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) {
@ -926,39 +926,39 @@ int _alpm_sync_commit(alpm_handle_t *handle, alpm_list_t **data)
alpm_list_free_inner(conflict, (alpm_list_fn_free)_alpm_fileconflict_free); alpm_list_free_inner(conflict, (alpm_list_fn_free)_alpm_fileconflict_free);
alpm_list_free(conflict); alpm_list_free(conflict);
} }
RET_ERR(handle, PM_ERR_FILE_CONFLICTS, -1); RET_ERR(handle, ALPM_ERR_FILE_CONFLICTS, -1);
} }
EVENT(trans, PM_TRANS_EVT_FILECONFLICTS_DONE, NULL, NULL); EVENT(trans, ALPM_TRANS_EVT_FILECONFLICTS_DONE, NULL, NULL);
} }
/* check available disk space */ /* check available disk space */
if(handle->checkspace) { if(handle->checkspace) {
EVENT(trans, PM_TRANS_EVT_DISKSPACE_START, NULL, NULL); EVENT(trans, ALPM_TRANS_EVT_DISKSPACE_START, NULL, NULL);
_alpm_log(handle, PM_LOG_DEBUG, "checking available disk space\n"); _alpm_log(handle, ALPM_LOG_DEBUG, "checking available disk space\n");
if(_alpm_check_diskspace(handle) == -1) { if(_alpm_check_diskspace(handle) == -1) {
_alpm_log(handle, PM_LOG_ERROR, "%s\n", _("not enough free disk space")); _alpm_log(handle, ALPM_LOG_ERROR, "%s\n", _("not enough free disk space"));
return -1; return -1;
} }
EVENT(trans, PM_TRANS_EVT_DISKSPACE_DONE, NULL, NULL); EVENT(trans, ALPM_TRANS_EVT_DISKSPACE_DONE, NULL, NULL);
} }
/* remove conflicting and to-be-replaced packages */ /* remove conflicting and to-be-replaced packages */
if(replaces) { if(replaces) {
_alpm_log(handle, PM_LOG_DEBUG, "removing conflicting and to-be-replaced packages\n"); _alpm_log(handle, ALPM_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(handle, PM_LOG_ERROR, _("could not commit removal transaction\n")); _alpm_log(handle, ALPM_LOG_ERROR, _("could not commit removal transaction\n"));
return -1; return -1;
} }
} }
/* install targets */ /* install targets */
_alpm_log(handle, PM_LOG_DEBUG, "installing packages\n"); _alpm_log(handle, ALPM_LOG_DEBUG, "installing packages\n");
if(_alpm_upgrade_packages(handle) == -1) { if(_alpm_upgrade_packages(handle) == -1) {
_alpm_log(handle, PM_LOG_ERROR, _("could not commit transaction\n")); _alpm_log(handle, ALPM_LOG_ERROR, _("could not commit transaction\n"));
return -1; return -1;
} }

View File

@ -57,23 +57,23 @@ int SYMEXPORT alpm_trans_init(alpm_handle_t *handle, alpm_transflag_t flags,
/* Sanity checks */ /* Sanity checks */
CHECK_HANDLE(handle, return -1); CHECK_HANDLE(handle, return -1);
ASSERT(handle->trans == NULL, RET_ERR(handle, PM_ERR_TRANS_NOT_NULL, -1)); ASSERT(handle->trans == NULL, RET_ERR(handle, ALPM_ERR_TRANS_NOT_NULL, -1));
for(i = handle->dbs_sync; i; i = i->next) { for(i = handle->dbs_sync; i; i = i->next) {
const alpm_db_t *db = i->data; const alpm_db_t *db = i->data;
if(!(db->status & DB_STATUS_VALID)) { if(!(db->status & DB_STATUS_VALID)) {
RET_ERR(handle, PM_ERR_DB_INVALID, -1); RET_ERR(handle, ALPM_ERR_DB_INVALID, -1);
} }
} }
/* lock db */ /* lock db */
if(!(flags & PM_TRANS_FLAG_NOLOCK)) { if(!(flags & ALPM_TRANS_FLAG_NOLOCK)) {
if(_alpm_handle_lock(handle)) { if(_alpm_handle_lock(handle)) {
RET_ERR(handle, PM_ERR_HANDLE_LOCK, -1); RET_ERR(handle, ALPM_ERR_HANDLE_LOCK, -1);
} }
} }
CALLOC(trans, 1, sizeof(alpm_trans_t), RET_ERR(handle, PM_ERR_MEMORY, -1)); CALLOC(trans, 1, sizeof(alpm_trans_t), RET_ERR(handle, ALPM_ERR_MEMORY, -1));
trans->flags = flags; trans->flags = flags;
trans->cb_event = event; trans->cb_event = event;
trans->cb_conv = conv; trans->cb_conv = conv;
@ -102,7 +102,7 @@ static alpm_list_t *check_arch(alpm_handle_t *handle, alpm_list_t *pkgs)
const char *pkgname = alpm_pkg_get_name(pkg); const char *pkgname = alpm_pkg_get_name(pkg);
const char *pkgver = alpm_pkg_get_version(pkg); const char *pkgver = alpm_pkg_get_version(pkg);
size_t len = strlen(pkgname) + strlen(pkgver) + strlen(pkgarch) + 3; size_t len = strlen(pkgname) + strlen(pkgver) + strlen(pkgarch) + 3;
MALLOC(string, len, RET_ERR(handle, PM_ERR_MEMORY, invalid)); MALLOC(string, len, RET_ERR(handle, ALPM_ERR_MEMORY, invalid));
sprintf(string, "%s-%s-%s", pkgname, pkgver, pkgarch); sprintf(string, "%s-%s-%s", pkgname, pkgver, pkgarch);
invalid = alpm_list_add(invalid, string); invalid = alpm_list_add(invalid, string);
} }
@ -117,12 +117,12 @@ int SYMEXPORT alpm_trans_prepare(alpm_handle_t *handle, alpm_list_t **data)
/* Sanity checks */ /* Sanity checks */
CHECK_HANDLE(handle, return -1); CHECK_HANDLE(handle, return -1);
ASSERT(data != NULL, RET_ERR(handle, PM_ERR_WRONG_ARGS, -1)); ASSERT(data != NULL, RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1));
trans = handle->trans; trans = handle->trans;
ASSERT(trans != NULL, RET_ERR(handle, PM_ERR_TRANS_NULL, -1)); ASSERT(trans != NULL, RET_ERR(handle, ALPM_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, ALPM_ERR_TRANS_NOT_INITIALIZED, -1));
/* If there's nothing to do, return without complaining */ /* If there's nothing to do, return without complaining */
if(trans->add == NULL && trans->remove == NULL) { if(trans->add == NULL && trans->remove == NULL) {
@ -134,7 +134,7 @@ int SYMEXPORT alpm_trans_prepare(alpm_handle_t *handle, alpm_list_t **data)
if(data) { if(data) {
*data = invalid; *data = invalid;
} }
RET_ERR(handle, PM_ERR_PKG_INVALID_ARCH, -1); RET_ERR(handle, ALPM_ERR_PKG_INVALID_ARCH, -1);
} }
if(trans->add == NULL) { if(trans->add == NULL) {
@ -164,10 +164,10 @@ int SYMEXPORT alpm_trans_commit(alpm_handle_t *handle, alpm_list_t **data)
trans = handle->trans; trans = handle->trans;
ASSERT(trans != NULL, RET_ERR(handle, PM_ERR_TRANS_NULL, -1)); ASSERT(trans != NULL, RET_ERR(handle, ALPM_ERR_TRANS_NULL, -1));
ASSERT(trans->state == STATE_PREPARED, RET_ERR(handle, PM_ERR_TRANS_NOT_PREPARED, -1)); ASSERT(trans->state == STATE_PREPARED, RET_ERR(handle, ALPM_ERR_TRANS_NOT_PREPARED, -1));
ASSERT(!(trans->flags & PM_TRANS_FLAG_NOLOCK), RET_ERR(handle, PM_ERR_TRANS_NOT_LOCKED, -1)); ASSERT(!(trans->flags & ALPM_TRANS_FLAG_NOLOCK), RET_ERR(handle, ALPM_ERR_TRANS_NOT_LOCKED, -1));
/* If there's nothing to do, return without complaining */ /* If there's nothing to do, return without complaining */
if(trans->add == NULL && trans->remove == NULL) { if(trans->add == NULL && trans->remove == NULL) {
@ -202,9 +202,9 @@ int SYMEXPORT alpm_trans_interrupt(alpm_handle_t *handle)
CHECK_HANDLE(handle, return -1); CHECK_HANDLE(handle, return -1);
trans = handle->trans; trans = handle->trans;
ASSERT(trans != NULL, RET_ERR(handle, PM_ERR_TRANS_NULL, -1)); ASSERT(trans != NULL, RET_ERR(handle, ALPM_ERR_TRANS_NULL, -1));
ASSERT(trans->state == STATE_COMMITING || trans->state == STATE_INTERRUPTED, ASSERT(trans->state == STATE_COMMITING || trans->state == STATE_INTERRUPTED,
RET_ERR(handle, PM_ERR_TRANS_TYPE, -1)); RET_ERR(handle, ALPM_ERR_TRANS_TYPE, -1));
trans->state = STATE_INTERRUPTED; trans->state = STATE_INTERRUPTED;
@ -220,10 +220,10 @@ int SYMEXPORT alpm_trans_release(alpm_handle_t *handle)
CHECK_HANDLE(handle, return -1); CHECK_HANDLE(handle, return -1);
trans = handle->trans; trans = handle->trans;
ASSERT(trans != NULL, RET_ERR(handle, PM_ERR_TRANS_NULL, -1)); ASSERT(trans != NULL, RET_ERR(handle, ALPM_ERR_TRANS_NULL, -1));
ASSERT(trans->state != STATE_IDLE, RET_ERR(handle, PM_ERR_TRANS_NULL, -1)); ASSERT(trans->state != STATE_IDLE, RET_ERR(handle, ALPM_ERR_TRANS_NULL, -1));
int nolock_flag = trans->flags & PM_TRANS_FLAG_NOLOCK; int nolock_flag = trans->flags & ALPM_TRANS_FLAG_NOLOCK;
_alpm_trans_free(trans); _alpm_trans_free(trans);
handle->trans = NULL; handle->trans = NULL;
@ -231,7 +231,7 @@ int SYMEXPORT alpm_trans_release(alpm_handle_t *handle)
/* unlock db */ /* unlock db */
if(!nolock_flag) { if(!nolock_flag) {
if(_alpm_handle_unlock(handle)) { if(_alpm_handle_unlock(handle)) {
_alpm_log(handle, PM_LOG_WARNING, _("could not remove lock file %s\n"), _alpm_log(handle, ALPM_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));
@ -298,7 +298,7 @@ int _alpm_runscriptlet(alpm_handle_t *handle, const char *installfn,
if(access(installfn, R_OK)) { if(access(installfn, R_OK)) {
/* not found */ /* not found */
_alpm_log(handle, PM_LOG_DEBUG, "scriptlet '%s' not found\n", installfn); _alpm_log(handle, ALPM_LOG_DEBUG, "scriptlet '%s' not found\n", installfn);
return 0; return 0;
} }
@ -309,7 +309,7 @@ int _alpm_runscriptlet(alpm_handle_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(handle, PM_LOG_ERROR, _("could not create temp directory\n")); _alpm_log(handle, ALPM_LOG_ERROR, _("could not create temp directory\n"));
return 1; return 1;
} else { } else {
clean_tmpdir = 1; clean_tmpdir = 1;
@ -323,7 +323,7 @@ int _alpm_runscriptlet(alpm_handle_t *handle, const char *installfn,
} }
} else { } else {
if(_alpm_copyfile(installfn, scriptfn)) { if(_alpm_copyfile(installfn, scriptfn)) {
_alpm_log(handle, PM_LOG_ERROR, _("could not copy tempfile to %s (%s)\n"), scriptfn, strerror(errno)); _alpm_log(handle, ALPM_LOG_ERROR, _("could not copy tempfile to %s (%s)\n"), scriptfn, strerror(errno));
retval = 1; retval = 1;
} }
} }
@ -347,13 +347,13 @@ int _alpm_runscriptlet(alpm_handle_t *handle, const char *installfn,
scriptpath, script, ver); scriptpath, script, ver);
} }
_alpm_log(handle, PM_LOG_DEBUG, "executing \"%s\"\n", cmdline); _alpm_log(handle, ALPM_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(handle, PM_LOG_WARNING, _("could not remove tmpdir %s\n"), tmpdir); _alpm_log(handle, ALPM_LOG_WARNING, _("could not remove tmpdir %s\n"), tmpdir);
} }
return retval; return retval;
@ -363,7 +363,7 @@ alpm_transflag_t SYMEXPORT alpm_trans_get_flags(alpm_handle_t *handle)
{ {
/* Sanity checks */ /* Sanity checks */
CHECK_HANDLE(handle, return -1); CHECK_HANDLE(handle, return -1);
ASSERT(handle->trans != NULL, RET_ERR(handle, PM_ERR_TRANS_NULL, -1)); ASSERT(handle->trans != NULL, RET_ERR(handle, ALPM_ERR_TRANS_NULL, -1));
return handle->trans->flags; return handle->trans->flags;
} }
@ -372,7 +372,7 @@ alpm_list_t SYMEXPORT *alpm_trans_get_add(alpm_handle_t *handle)
{ {
/* Sanity checks */ /* Sanity checks */
CHECK_HANDLE(handle, return NULL); CHECK_HANDLE(handle, return NULL);
ASSERT(handle->trans != NULL, RET_ERR(handle, PM_ERR_TRANS_NULL, NULL)); ASSERT(handle->trans != NULL, RET_ERR(handle, ALPM_ERR_TRANS_NULL, NULL));
return handle->trans->add; return handle->trans->add;
} }
@ -381,7 +381,7 @@ alpm_list_t SYMEXPORT *alpm_trans_get_remove(alpm_handle_t *handle)
{ {
/* Sanity checks */ /* Sanity checks */
CHECK_HANDLE(handle, return NULL); CHECK_HANDLE(handle, return NULL);
ASSERT(handle->trans != NULL, RET_ERR(handle, PM_ERR_TRANS_NULL, NULL)); ASSERT(handle->trans != NULL, RET_ERR(handle, ALPM_ERR_TRANS_NULL, NULL));
return handle->trans->remove; return handle->trans->remove;
} }

View File

@ -254,7 +254,7 @@ int _alpm_unpack(alpm_handle_t *handle, const char *archive, const char *prefix,
int restore_cwd = 0; int restore_cwd = 0;
if((_archive = archive_read_new()) == NULL) { if((_archive = archive_read_new()) == NULL) {
RET_ERR(handle, PM_ERR_LIBARCHIVE, 1); RET_ERR(handle, ALPM_ERR_LIBARCHIVE, 1);
} }
archive_read_support_compression_all(_archive); archive_read_support_compression_all(_archive);
@ -262,23 +262,23 @@ int _alpm_unpack(alpm_handle_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(handle, PM_LOG_ERROR, _("could not open file %s: %s\n"), archive, _alpm_log(handle, ALPM_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, ALPM_ERR_PKG_OPEN, 1);
} }
oldmask = umask(0022); oldmask = umask(0022);
/* 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(handle, PM_LOG_ERROR, _("could not get current working directory\n")); _alpm_log(handle, ALPM_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(handle, PM_LOG_ERROR, _("could not change directory to %s (%s)\n"), _alpm_log(handle, ALPM_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(alpm_handle_t *handle, const char *archive, const char *prefix,
} }
continue; continue;
} else { } else {
_alpm_log(handle, PM_LOG_DEBUG, "extracting: %s\n", entryname); _alpm_log(handle, ALPM_LOG_DEBUG, "extracting: %s\n", entryname);
} }
} }
@ -321,10 +321,10 @@ int _alpm_unpack(alpm_handle_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(handle, PM_LOG_WARNING, _("warning given when extracting %s (%s)\n"), _alpm_log(handle, ALPM_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(handle, PM_LOG_ERROR, _("could not extract %s (%s)\n"), _alpm_log(handle, ALPM_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(handle, PM_LOG_ERROR, _("could not change directory to %s (%s)\n"), _alpm_log(handle, ALPM_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(alpm_handle_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(handle, PM_LOG_ERROR, _("could not get current working directory\n")); _alpm_log(handle, ALPM_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(handle, PM_LOG_ERROR, _("could not change directory to %s (%s)\n"), _alpm_log(handle, ALPM_LOG_ERROR, _("could not change directory to %s (%s)\n"),
handle->root, strerror(errno)); handle->root, strerror(errno));
goto cleanup; goto cleanup;
} }
_alpm_log(handle, PM_LOG_DEBUG, "executing \"%s\" under chroot \"%s\"\n", _alpm_log(handle, ALPM_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(handle, PM_LOG_ERROR, _("could not create pipe (%s)\n"), strerror(errno)); _alpm_log(handle, ALPM_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(alpm_handle_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(handle, PM_LOG_ERROR, _("could not fork a new process (%s)\n"), strerror(errno)); _alpm_log(handle, ALPM_LOG_ERROR, _("could not fork a new process (%s)\n"), strerror(errno));
retval = 1; retval = 1;
goto cleanup; goto cleanup;
} }
@ -500,14 +500,14 @@ int _alpm_run_chroot(alpm_handle_t *handle, const char *path, char *const argv[]
if(fgets(line, PATH_MAX, pipe_file) == NULL) if(fgets(line, PATH_MAX, pipe_file) == NULL)
break; break;
alpm_logaction(handle, "%s", line); alpm_logaction(handle, "%s", line);
EVENT(handle->trans, PM_TRANS_EVT_SCRIPTLET_INFO, line, NULL); EVENT(handle->trans, ALPM_TRANS_EVT_SCRIPTLET_INFO, line, NULL);
} }
fclose(pipe_file); fclose(pipe_file);
} }
while(waitpid(pid, &status, 0) == -1) { while(waitpid(pid, &status, 0) == -1) {
if(errno != EINTR) { if(errno != EINTR) {
_alpm_log(handle, PM_LOG_ERROR, _("call to waitpid failed (%s)\n"), strerror(errno)); _alpm_log(handle, ALPM_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(alpm_handle_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(handle, PM_LOG_ERROR, _("could not open pipe (%s)\n"), strerror(errno)); _alpm_log(handle, ALPM_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(handle, PM_LOG_DEBUG, "call to waitpid succeeded\n"); _alpm_log(handle, ALPM_LOG_DEBUG, "call to waitpid succeeded\n");
if(WEXITSTATUS(status) != 0) { if(WEXITSTATUS(status) != 0) {
_alpm_log(handle, PM_LOG_ERROR, _("command failed to execute correctly\n")); _alpm_log(handle, ALPM_LOG_ERROR, _("command failed to execute correctly\n"));
retval = 1; retval = 1;
} }
} }
@ -530,7 +530,7 @@ int _alpm_run_chroot(alpm_handle_t *handle, const char *path, char *const argv[]
cleanup: cleanup:
if(restore_cwd && chdir(cwd) != 0) { if(restore_cwd && chdir(cwd) != 0) {
_alpm_log(handle, PM_LOG_ERROR, _("could not change directory to %s (%s)\n"), cwd, strerror(errno)); _alpm_log(handle, ALPM_LOG_ERROR, _("could not change directory to %s (%s)\n"), cwd, strerror(errno));
} }
return retval; return retval;
@ -540,7 +540,7 @@ int _alpm_ldconfig(alpm_handle_t *handle)
{ {
char line[PATH_MAX]; char line[PATH_MAX];
_alpm_log(handle, PM_LOG_DEBUG, "running ldconfig\n"); _alpm_log(handle, ALPM_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(alpm_handle_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(handle, PM_LOG_DEBUG, "found cached pkg: %s\n", retpath); _alpm_log(handle, ALPM_LOG_DEBUG, "found cached pkg: %s\n", retpath);
return retpath; return retpath;
} }
} }
@ -603,17 +603,17 @@ const char *_alpm_filecache_setup(alpm_handle_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(handle, PM_LOG_WARNING, _("no %s cache exists, creating...\n"), _alpm_log(handle, ALPM_LOG_WARNING, _("no %s cache exists, creating...\n"),
cachedir); cachedir);
if(_alpm_makepath(cachedir) == 0) { if(_alpm_makepath(cachedir) == 0) {
_alpm_log(handle, PM_LOG_DEBUG, "using cachedir: %s\n", cachedir); _alpm_log(handle, ALPM_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(handle, PM_LOG_DEBUG, "using cachedir: %s\n", cachedir); _alpm_log(handle, ALPM_LOG_DEBUG, "using cachedir: %s\n", cachedir);
return cachedir; return cachedir;
} else { } else {
_alpm_log(handle, PM_LOG_DEBUG, "skipping cachedir: %s\n", cachedir); _alpm_log(handle, ALPM_LOG_DEBUG, "skipping cachedir: %s\n", cachedir);
} }
} }
@ -621,8 +621,8 @@ const char *_alpm_filecache_setup(alpm_handle_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(handle, PM_LOG_DEBUG, "using cachedir: %s\n", "/tmp/"); _alpm_log(handle, ALPM_LOG_DEBUG, "using cachedir: %s\n", "/tmp/");
_alpm_log(handle, PM_LOG_WARNING, _("couldn't create package cache, using /tmp instead\n")); _alpm_log(handle, ALPM_LOG_WARNING, _("couldn't create package cache, using /tmp instead\n"));
return "/tmp/"; return "/tmp/";
} }

View File

@ -62,12 +62,12 @@
#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 { \ #define RET_ERR_VOID(handle, err) do { \
_alpm_log(handle, PM_LOG_DEBUG, "returning error %d from %s : %s\n", err, __func__, alpm_strerror(err)); \ _alpm_log(handle, ALPM_LOG_DEBUG, "returning error %d from %s : %s\n", err, __func__, alpm_strerror(err)); \
(handle)->pm_errno = (err); \ (handle)->pm_errno = (err); \
return; } while(0) return; } while(0)
#define RET_ERR(handle, err, ret) do { \ #define RET_ERR(handle, err, ret) do { \
_alpm_log(handle, PM_LOG_DEBUG, "returning error %d from %s : %s\n", err, __func__, alpm_strerror(err)); \ _alpm_log(handle, ALPM_LOG_DEBUG, "returning error %d from %s : %s\n", err, __func__, alpm_strerror(err)); \
(handle)->pm_errno = (err); \ (handle)->pm_errno = (err); \
return (ret); } while(0) return (ret); } while(0)

View File

@ -156,93 +156,93 @@ static void fill_progress(const int bar_percent, const int disp_percent,
void cb_trans_evt(alpm_transevt_t event, void *data1, void *data2) void cb_trans_evt(alpm_transevt_t event, void *data1, void *data2)
{ {
switch(event) { switch(event) {
case PM_TRANS_EVT_CHECKDEPS_START: case ALPM_TRANS_EVT_CHECKDEPS_START:
printf(_("checking dependencies...\n")); printf(_("checking dependencies...\n"));
break; break;
case PM_TRANS_EVT_FILECONFLICTS_START: case ALPM_TRANS_EVT_FILECONFLICTS_START:
if(config->noprogressbar) { if(config->noprogressbar) {
printf(_("checking for file conflicts...\n")); printf(_("checking for file conflicts...\n"));
} }
break; break;
case PM_TRANS_EVT_RESOLVEDEPS_START: case ALPM_TRANS_EVT_RESOLVEDEPS_START:
printf(_("resolving dependencies...\n")); printf(_("resolving dependencies...\n"));
break; break;
case PM_TRANS_EVT_INTERCONFLICTS_START: case ALPM_TRANS_EVT_INTERCONFLICTS_START:
printf(_("looking for inter-conflicts...\n")); printf(_("looking for inter-conflicts...\n"));
break; break;
case PM_TRANS_EVT_ADD_START: case ALPM_TRANS_EVT_ADD_START:
if(config->noprogressbar) { if(config->noprogressbar) {
printf(_("installing %s...\n"), alpm_pkg_get_name(data1)); printf(_("installing %s...\n"), alpm_pkg_get_name(data1));
} }
break; break;
case PM_TRANS_EVT_ADD_DONE: case ALPM_TRANS_EVT_ADD_DONE:
alpm_logaction(config->handle, "installed %s (%s)\n", alpm_logaction(config->handle, "installed %s (%s)\n",
alpm_pkg_get_name(data1), alpm_pkg_get_name(data1),
alpm_pkg_get_version(data1)); alpm_pkg_get_version(data1));
display_optdepends(data1); display_optdepends(data1);
break; break;
case PM_TRANS_EVT_REMOVE_START: case ALPM_TRANS_EVT_REMOVE_START:
if(config->noprogressbar) { if(config->noprogressbar) {
printf(_("removing %s...\n"), alpm_pkg_get_name(data1)); printf(_("removing %s...\n"), alpm_pkg_get_name(data1));
} }
break; break;
case PM_TRANS_EVT_REMOVE_DONE: case ALPM_TRANS_EVT_REMOVE_DONE:
alpm_logaction(config->handle, "removed %s (%s)\n", alpm_logaction(config->handle, "removed %s (%s)\n",
alpm_pkg_get_name(data1), alpm_pkg_get_name(data1),
alpm_pkg_get_version(data1)); alpm_pkg_get_version(data1));
break; break;
case PM_TRANS_EVT_UPGRADE_START: case ALPM_TRANS_EVT_UPGRADE_START:
if(config->noprogressbar) { if(config->noprogressbar) {
printf(_("upgrading %s...\n"), alpm_pkg_get_name(data1)); printf(_("upgrading %s...\n"), alpm_pkg_get_name(data1));
} }
break; break;
case PM_TRANS_EVT_UPGRADE_DONE: case ALPM_TRANS_EVT_UPGRADE_DONE:
alpm_logaction(config->handle, "upgraded %s (%s -> %s)\n", alpm_logaction(config->handle, "upgraded %s (%s -> %s)\n",
(char *)alpm_pkg_get_name(data1), (char *)alpm_pkg_get_name(data1),
(char *)alpm_pkg_get_version(data2), (char *)alpm_pkg_get_version(data2),
(char *)alpm_pkg_get_version(data1)); (char *)alpm_pkg_get_version(data1));
display_new_optdepends(data2,data1); display_new_optdepends(data2,data1);
break; break;
case PM_TRANS_EVT_INTEGRITY_START: case ALPM_TRANS_EVT_INTEGRITY_START:
if(config->noprogressbar) { if(config->noprogressbar) {
printf(_("checking package integrity...\n")); printf(_("checking package integrity...\n"));
} }
break; break;
case PM_TRANS_EVT_DELTA_INTEGRITY_START: case ALPM_TRANS_EVT_DELTA_INTEGRITY_START:
printf(_("checking delta integrity...\n")); printf(_("checking delta integrity...\n"));
break; break;
case PM_TRANS_EVT_DELTA_PATCHES_START: case ALPM_TRANS_EVT_DELTA_PATCHES_START:
printf(_("applying deltas...\n")); printf(_("applying deltas...\n"));
break; break;
case PM_TRANS_EVT_DELTA_PATCH_START: case ALPM_TRANS_EVT_DELTA_PATCH_START:
printf(_("generating %s with %s... "), (char *)data1, (char *)data2); printf(_("generating %s with %s... "), (char *)data1, (char *)data2);
break; break;
case PM_TRANS_EVT_DELTA_PATCH_DONE: case ALPM_TRANS_EVT_DELTA_PATCH_DONE:
printf(_("success!\n")); printf(_("success!\n"));
break; break;
case PM_TRANS_EVT_DELTA_PATCH_FAILED: case ALPM_TRANS_EVT_DELTA_PATCH_FAILED:
printf(_("failed.\n")); printf(_("failed.\n"));
break; break;
case PM_TRANS_EVT_SCRIPTLET_INFO: case ALPM_TRANS_EVT_SCRIPTLET_INFO:
printf("%s", (char *)data1); printf("%s", (char *)data1);
break; break;
case PM_TRANS_EVT_RETRIEVE_START: case ALPM_TRANS_EVT_RETRIEVE_START:
printf(_(":: Retrieving packages from %s...\n"), (char *)data1); printf(_(":: Retrieving packages from %s...\n"), (char *)data1);
break; break;
case PM_TRANS_EVT_DISKSPACE_START: case ALPM_TRANS_EVT_DISKSPACE_START:
if(config->noprogressbar) { if(config->noprogressbar) {
printf(_("checking available disk space...\n")); printf(_("checking available disk space...\n"));
} }
break; break;
/* all the simple done events, with fallthrough for each */ /* all the simple done events, with fallthrough for each */
case PM_TRANS_EVT_FILECONFLICTS_DONE: case ALPM_TRANS_EVT_FILECONFLICTS_DONE:
case PM_TRANS_EVT_CHECKDEPS_DONE: case ALPM_TRANS_EVT_CHECKDEPS_DONE:
case PM_TRANS_EVT_RESOLVEDEPS_DONE: case ALPM_TRANS_EVT_RESOLVEDEPS_DONE:
case PM_TRANS_EVT_INTERCONFLICTS_DONE: case ALPM_TRANS_EVT_INTERCONFLICTS_DONE:
case PM_TRANS_EVT_INTEGRITY_DONE: case ALPM_TRANS_EVT_INTEGRITY_DONE:
case PM_TRANS_EVT_DELTA_INTEGRITY_DONE: case ALPM_TRANS_EVT_DELTA_INTEGRITY_DONE:
case PM_TRANS_EVT_DELTA_PATCHES_DONE: case ALPM_TRANS_EVT_DELTA_PATCHES_DONE:
case PM_TRANS_EVT_DISKSPACE_DONE: case ALPM_TRANS_EVT_DISKSPACE_DONE:
/* nothing */ /* nothing */
break; break;
} }
@ -255,7 +255,7 @@ void cb_trans_conv(alpm_transconv_t event, void *data1, void *data2,
void *data3, int *response) void *data3, int *response)
{ {
switch(event) { switch(event) {
case PM_TRANS_CONV_INSTALL_IGNOREPKG: case ALPM_TRANS_CONV_INSTALL_IGNOREPKG:
if(!config->op_s_downloadonly) { if(!config->op_s_downloadonly) {
*response = yesno(_(":: %s is in IgnorePkg/IgnoreGroup. Install anyway?"), *response = yesno(_(":: %s is in IgnorePkg/IgnoreGroup. Install anyway?"),
alpm_pkg_get_name(data1)); alpm_pkg_get_name(data1));
@ -263,13 +263,13 @@ void cb_trans_conv(alpm_transconv_t event, void *data1, void *data2,
*response = 1; *response = 1;
} }
break; break;
case PM_TRANS_CONV_REPLACE_PKG: case ALPM_TRANS_CONV_REPLACE_PKG:
*response = yesno(_(":: Replace %s with %s/%s?"), *response = yesno(_(":: Replace %s with %s/%s?"),
alpm_pkg_get_name(data1), alpm_pkg_get_name(data1),
(char *)data3, (char *)data3,
alpm_pkg_get_name(data2)); alpm_pkg_get_name(data2));
break; break;
case PM_TRANS_CONV_CONFLICT_PKG: case ALPM_TRANS_CONV_CONFLICT_PKG:
/* data parameters: target package, local package, conflict (strings) */ /* data parameters: target package, local package, conflict (strings) */
/* print conflict only if it contains new information */ /* print conflict only if it contains new information */
if(strcmp(data1, data3) == 0 || strcmp(data2, data3) == 0) { if(strcmp(data1, data3) == 0 || strcmp(data2, data3) == 0) {
@ -285,7 +285,7 @@ void cb_trans_conv(alpm_transconv_t event, void *data1, void *data2,
(char *)data2); (char *)data2);
} }
break; break;
case PM_TRANS_CONV_REMOVE_PKGS: case ALPM_TRANS_CONV_REMOVE_PKGS:
{ {
alpm_list_t *unresolved = (alpm_list_t *) data1; alpm_list_t *unresolved = (alpm_list_t *) data1;
alpm_list_t *namelist = NULL, *i; alpm_list_t *namelist = NULL, *i;
@ -308,7 +308,7 @@ void cb_trans_conv(alpm_transconv_t event, void *data1, void *data2,
alpm_list_free(namelist); alpm_list_free(namelist);
} }
break; break;
case PM_TRANS_CONV_SELECT_PROVIDER: case ALPM_TRANS_CONV_SELECT_PROVIDER:
{ {
alpm_list_t *providers = (alpm_list_t *)data1; alpm_list_t *providers = (alpm_list_t *)data1;
int count = alpm_list_count(providers); int count = alpm_list_count(providers);
@ -320,7 +320,7 @@ void cb_trans_conv(alpm_transconv_t event, void *data1, void *data2,
*response = select_question(count); *response = select_question(count);
} }
break; break;
case PM_TRANS_CONV_LOCAL_NEWER: case ALPM_TRANS_CONV_LOCAL_NEWER:
if(!config->op_s_downloadonly) { if(!config->op_s_downloadonly) {
*response = yesno(_(":: %s-%s: local version is newer. Upgrade anyway?"), *response = yesno(_(":: %s-%s: local version is newer. Upgrade anyway?"),
alpm_pkg_get_name(data1), alpm_pkg_get_name(data1),
@ -329,7 +329,7 @@ void cb_trans_conv(alpm_transconv_t event, void *data1, void *data2,
*response = 1; *response = 1;
} }
break; break;
case PM_TRANS_CONV_CORRUPTED_PKG: case ALPM_TRANS_CONV_CORRUPTED_PKG:
*response = yesno(_(":: File %s is corrupted. Do you want to delete it?"), *response = yesno(_(":: File %s is corrupted. Do you want to delete it?"),
(char *)data1); (char *)data1);
break; break;
@ -381,22 +381,22 @@ void cb_trans_progress(alpm_transprog_t event, const char *pkgname, int percent,
/* set text of message to display */ /* set text of message to display */
switch (event) { switch (event) {
case PM_TRANS_PROGRESS_ADD_START: case ALPM_TRANS_PROGRESS_ADD_START:
opr = _("installing"); opr = _("installing");
break; break;
case PM_TRANS_PROGRESS_UPGRADE_START: case ALPM_TRANS_PROGRESS_UPGRADE_START:
opr = _("upgrading"); opr = _("upgrading");
break; break;
case PM_TRANS_PROGRESS_REMOVE_START: case ALPM_TRANS_PROGRESS_REMOVE_START:
opr = _("removing"); opr = _("removing");
break; break;
case PM_TRANS_PROGRESS_CONFLICTS_START: case ALPM_TRANS_PROGRESS_CONFLICTS_START:
opr = _("checking for file conflicts"); opr = _("checking for file conflicts");
break; break;
case PM_TRANS_PROGRESS_DISKSPACE_START: case ALPM_TRANS_PROGRESS_DISKSPACE_START:
opr = _("checking available disk space"); opr = _("checking available disk space");
break; break;
case PM_TRANS_PROGRESS_INTEGRITY_START: case ALPM_TRANS_PROGRESS_INTEGRITY_START:
opr = _("checking package integrity"); opr = _("checking package integrity");
break; break;
default: default:

View File

@ -43,14 +43,14 @@ config_t *config_new(void)
{ {
config_t *newconfig = calloc(1, sizeof(config_t)); config_t *newconfig = calloc(1, sizeof(config_t));
if(!newconfig) { if(!newconfig) {
pm_fprintf(stderr, PM_LOG_ERROR, pm_fprintf(stderr, ALPM_LOG_ERROR,
_("malloc failure: could not allocate %zd bytes\n"), _("malloc failure: could not allocate %zd bytes\n"),
sizeof(config_t)); sizeof(config_t));
return NULL; return NULL;
} }
/* defaults which may get overridden later */ /* defaults which may get overridden later */
newconfig->op = PM_OP_MAIN; newconfig->op = PM_OP_MAIN;
newconfig->logmask = PM_LOG_ERROR | PM_LOG_WARNING; newconfig->logmask = ALPM_LOG_ERROR | ALPM_LOG_WARNING;
newconfig->configfile = strdup(CONFFILE); newconfig->configfile = strdup(CONFFILE);
newconfig->sigverify = PM_PGP_VERIFY_UNKNOWN; newconfig->sigverify = PM_PGP_VERIFY_UNKNOWN;
@ -159,27 +159,27 @@ static int download_with_xfercommand(const char *url, const char *localpath,
/* 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) {
pm_printf(PM_LOG_ERROR, _("could not get current working directory\n")); pm_printf(ALPM_LOG_ERROR, _("could not get current working directory\n"));
} else { } else {
restore_cwd = 1; restore_cwd = 1;
} }
/* cwd to the download directory */ /* cwd to the download directory */
if(chdir(localpath)) { if(chdir(localpath)) {
pm_printf(PM_LOG_WARNING, _("could not chdir to download directory %s\n"), localpath); pm_printf(ALPM_LOG_WARNING, _("could not chdir to download directory %s\n"), localpath);
ret = -1; ret = -1;
goto cleanup; goto cleanup;
} }
/* execute the parsed command via /bin/sh -c */ /* execute the parsed command via /bin/sh -c */
pm_printf(PM_LOG_DEBUG, "running command: %s\n", parsedcmd); pm_printf(ALPM_LOG_DEBUG, "running command: %s\n", parsedcmd);
retval = system(parsedcmd); retval = system(parsedcmd);
if(retval == -1) { if(retval == -1) {
pm_printf(PM_LOG_WARNING, _("running XferCommand: fork failed!\n")); pm_printf(ALPM_LOG_WARNING, _("running XferCommand: fork failed!\n"));
ret = -1; ret = -1;
} else if(retval != 0) { } else if(retval != 0) {
/* download failed */ /* download failed */
pm_printf(PM_LOG_DEBUG, "XferCommand command returned non-zero status " pm_printf(ALPM_LOG_DEBUG, "XferCommand command returned non-zero status "
"code (%d)\n", retval); "code (%d)\n", retval);
ret = -1; ret = -1;
} else { } else {
@ -193,7 +193,7 @@ static int download_with_xfercommand(const char *url, const char *localpath,
cleanup: cleanup:
/* 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) {
pm_printf(PM_LOG_ERROR, _("could not change directory to %s (%s)\n"), pm_printf(ALPM_LOG_ERROR, _("could not change directory to %s (%s)\n"),
cwd, strerror(errno)); cwd, strerror(errno));
} }
@ -218,7 +218,7 @@ int config_set_arch(const char *arch)
} else { } else {
config->arch = strdup(arch); config->arch = strdup(arch);
} }
pm_printf(PM_LOG_DEBUG, "config: arch: %s\n", config->arch); pm_printf(ALPM_LOG_DEBUG, "config: arch: %s\n", config->arch);
return 0; return 0;
} }
@ -234,7 +234,7 @@ static pgp_verify_t option_verifysig(const char *value)
} else { } else {
level = PM_PGP_VERIFY_UNKNOWN; level = PM_PGP_VERIFY_UNKNOWN;
} }
pm_printf(PM_LOG_DEBUG, "config: VerifySig = %s (%d)\n", value, level); pm_printf(ALPM_LOG_DEBUG, "config: VerifySig = %s (%d)\n", value, level);
return level; return level;
} }
@ -247,7 +247,7 @@ static int process_cleanmethods(alpm_list_t *values) {
} else if(strcmp(value, "KeepCurrent") == 0) { } else if(strcmp(value, "KeepCurrent") == 0) {
config->cleanmethod |= PM_CLEAN_KEEPCUR; config->cleanmethod |= PM_CLEAN_KEEPCUR;
} else { } else {
pm_printf(PM_LOG_ERROR, _("invalid value for 'CleanMethod' : '%s'\n"), pm_printf(ALPM_LOG_ERROR, _("invalid value for 'CleanMethod' : '%s'\n"),
value); value);
return 1; return 1;
} }
@ -270,12 +270,12 @@ static void setrepeatingoption(char *ptr, const char *option,
while((q = strchr(ptr, ' '))) { while((q = strchr(ptr, ' '))) {
*q = '\0'; *q = '\0';
*list = alpm_list_add(*list, strdup(ptr)); *list = alpm_list_add(*list, strdup(ptr));
pm_printf(PM_LOG_DEBUG, "config: %s: %s\n", option, ptr); pm_printf(ALPM_LOG_DEBUG, "config: %s: %s\n", option, ptr);
ptr = q; ptr = q;
ptr++; ptr++;
} }
*list = alpm_list_add(*list, strdup(ptr)); *list = alpm_list_add(*list, strdup(ptr));
pm_printf(PM_LOG_DEBUG, "config: %s: %s\n", option, ptr); pm_printf(ALPM_LOG_DEBUG, "config: %s: %s\n", option, ptr);
} }
static int _parse_options(const char *key, char *value, static int _parse_options(const char *key, char *value,
@ -285,23 +285,23 @@ static int _parse_options(const char *key, char *value,
/* options without settings */ /* options without settings */
if(strcmp(key, "UseSyslog") == 0) { if(strcmp(key, "UseSyslog") == 0) {
config->usesyslog = 1; config->usesyslog = 1;
pm_printf(PM_LOG_DEBUG, "config: usesyslog\n"); pm_printf(ALPM_LOG_DEBUG, "config: usesyslog\n");
} else if(strcmp(key, "ILoveCandy") == 0) { } else if(strcmp(key, "ILoveCandy") == 0) {
config->chomp = 1; config->chomp = 1;
pm_printf(PM_LOG_DEBUG, "config: chomp\n"); pm_printf(ALPM_LOG_DEBUG, "config: chomp\n");
} else if(strcmp(key, "VerbosePkgLists") == 0) { } else if(strcmp(key, "VerbosePkgLists") == 0) {
config->verbosepkglists = 1; config->verbosepkglists = 1;
pm_printf(PM_LOG_DEBUG, "config: verbosepkglists\n"); pm_printf(ALPM_LOG_DEBUG, "config: verbosepkglists\n");
} else if(strcmp(key, "UseDelta") == 0) { } else if(strcmp(key, "UseDelta") == 0) {
config->usedelta = 1; config->usedelta = 1;
pm_printf(PM_LOG_DEBUG, "config: usedelta\n"); pm_printf(ALPM_LOG_DEBUG, "config: usedelta\n");
} else if(strcmp(key, "TotalDownload") == 0) { } else if(strcmp(key, "TotalDownload") == 0) {
config->totaldownload = 1; config->totaldownload = 1;
pm_printf(PM_LOG_DEBUG, "config: totaldownload\n"); pm_printf(ALPM_LOG_DEBUG, "config: totaldownload\n");
} else if(strcmp(key, "CheckSpace") == 0) { } else if(strcmp(key, "CheckSpace") == 0) {
config->checkspace = 1; config->checkspace = 1;
} else { } else {
pm_printf(PM_LOG_WARNING, pm_printf(ALPM_LOG_WARNING,
_("config file %s, line %d: directive '%s' in section '%s' not recognized.\n"), _("config file %s, line %d: directive '%s' in section '%s' not recognized.\n"),
file, linenum, key, "options"); file, linenum, key, "options");
} }
@ -329,27 +329,27 @@ static int _parse_options(const char *key, char *value,
/* don't overwrite a path specified on the command line */ /* don't overwrite a path specified on the command line */
if(!config->dbpath) { if(!config->dbpath) {
config->dbpath = strdup(value); config->dbpath = strdup(value);
pm_printf(PM_LOG_DEBUG, "config: dbpath: %s\n", value); pm_printf(ALPM_LOG_DEBUG, "config: dbpath: %s\n", value);
} }
} else if(strcmp(key, "RootDir") == 0) { } else if(strcmp(key, "RootDir") == 0) {
/* don't overwrite a path specified on the command line */ /* don't overwrite a path specified on the command line */
if(!config->rootdir) { if(!config->rootdir) {
config->rootdir = strdup(value); config->rootdir = strdup(value);
pm_printf(PM_LOG_DEBUG, "config: rootdir: %s\n", value); pm_printf(ALPM_LOG_DEBUG, "config: rootdir: %s\n", value);
} }
} else if(strcmp(key, "GPGDir") == 0) { } else if(strcmp(key, "GPGDir") == 0) {
if(!config->gpgdir) { if(!config->gpgdir) {
config->gpgdir = strdup(value); config->gpgdir = strdup(value);
pm_printf(PM_LOG_DEBUG, "config: gpgdir: %s\n", value); pm_printf(ALPM_LOG_DEBUG, "config: gpgdir: %s\n", value);
} }
} else if(strcmp(key, "LogFile") == 0) { } else if(strcmp(key, "LogFile") == 0) {
if(!config->logfile) { if(!config->logfile) {
config->logfile = strdup(value); config->logfile = strdup(value);
pm_printf(PM_LOG_DEBUG, "config: logfile: %s\n", value); pm_printf(ALPM_LOG_DEBUG, "config: logfile: %s\n", value);
} }
} else if(strcmp(key, "XferCommand") == 0) { } else if(strcmp(key, "XferCommand") == 0) {
config->xfercommand = strdup(value); config->xfercommand = strdup(value);
pm_printf(PM_LOG_DEBUG, "config: xfercommand: %s\n", value); pm_printf(ALPM_LOG_DEBUG, "config: xfercommand: %s\n", value);
} else if(strcmp(key, "CleanMethod") == 0) { } else if(strcmp(key, "CleanMethod") == 0) {
alpm_list_t *methods = NULL; alpm_list_t *methods = NULL;
setrepeatingoption(value, "CleanMethod", &methods); setrepeatingoption(value, "CleanMethod", &methods);
@ -363,13 +363,13 @@ static int _parse_options(const char *key, char *value,
if(level != PM_PGP_VERIFY_UNKNOWN) { if(level != PM_PGP_VERIFY_UNKNOWN) {
config->sigverify = level; config->sigverify = level;
} else { } else {
pm_printf(PM_LOG_ERROR, pm_printf(ALPM_LOG_ERROR,
_("config file %s, line %d: directive '%s' has invalid value '%s'\n"), _("config file %s, line %d: directive '%s' has invalid value '%s'\n"),
file, linenum, key, value); file, linenum, key, value);
return 1; return 1;
} }
} else { } else {
pm_printf(PM_LOG_WARNING, pm_printf(ALPM_LOG_WARNING,
_("config file %s, line %d: directive '%s' in section '%s' not recognized.\n"), _("config file %s, line %d: directive '%s' in section '%s' not recognized.\n"),
file, linenum, key, "options"); file, linenum, key, "options");
} }
@ -392,7 +392,7 @@ static int _add_mirror(alpm_db_t *db, char *value)
} else { } else {
if(strstr(temp, "$arch")) { if(strstr(temp, "$arch")) {
free(temp); free(temp);
pm_printf(PM_LOG_ERROR, _("The mirror '%s' contains the $arch" pm_printf(ALPM_LOG_ERROR, _("The mirror '%s' contains the $arch"
" variable, but no Architecture is defined.\n"), value); " variable, but no Architecture is defined.\n"), value);
return 1; return 1;
} }
@ -401,7 +401,7 @@ static int _add_mirror(alpm_db_t *db, char *value)
if(alpm_db_add_server(db, server) != 0) { if(alpm_db_add_server(db, server) != 0) {
/* pm_errno is set by alpm_db_setserver */ /* pm_errno is set by alpm_db_setserver */
pm_printf(PM_LOG_ERROR, _("could not add server URL to database '%s': %s (%s)\n"), pm_printf(ALPM_LOG_ERROR, _("could not add server URL to database '%s': %s (%s)\n"),
dbname, server, alpm_strerror(alpm_errno(config->handle))); dbname, server, alpm_strerror(alpm_errno(config->handle)));
free(server); free(server);
return 1; return 1;
@ -423,7 +423,7 @@ static int setup_libalpm(void)
enum _alpm_errno_t err; enum _alpm_errno_t err;
alpm_handle_t *handle; alpm_handle_t *handle;
pm_printf(PM_LOG_DEBUG, "setup_libalpm called\n"); pm_printf(ALPM_LOG_DEBUG, "setup_libalpm called\n");
/* Configure root path first. If it is set and dbpath/logfile were not /* Configure root path first. If it is set and dbpath/logfile were not
* set, then set those as well to reside under the root. */ * set, then set those as well to reside under the root. */
@ -447,10 +447,10 @@ static int setup_libalpm(void)
/* initialize library */ /* initialize library */
handle = alpm_initialize(config->rootdir, config->dbpath, &err); handle = alpm_initialize(config->rootdir, config->dbpath, &err);
if(!handle) { if(!handle) {
pm_printf(PM_LOG_ERROR, _("failed to initialize alpm library (%s)\n"), pm_printf(ALPM_LOG_ERROR, _("failed to initialize alpm library (%s)\n"),
alpm_strerror(err)); alpm_strerror(err));
if(err == PM_ERR_DB_VERSION) { if(err == ALPM_ERR_DB_VERSION) {
pm_printf(PM_LOG_ERROR, _(" try running pacman-db-upgrade\n")); pm_printf(ALPM_LOG_ERROR, _(" try running pacman-db-upgrade\n"));
} }
return -1; return -1;
} }
@ -462,7 +462,7 @@ static int setup_libalpm(void)
config->logfile = config->logfile ? config->logfile : strdup(LOGFILE); config->logfile = config->logfile ? config->logfile : strdup(LOGFILE);
ret = alpm_option_set_logfile(handle, config->logfile); ret = alpm_option_set_logfile(handle, config->logfile);
if(ret != 0) { if(ret != 0) {
pm_printf(PM_LOG_ERROR, _("problem setting logfile '%s' (%s)\n"), pm_printf(ALPM_LOG_ERROR, _("problem setting logfile '%s' (%s)\n"),
config->logfile, alpm_strerror(alpm_errno(handle))); config->logfile, alpm_strerror(alpm_errno(handle)));
return ret; return ret;
} }
@ -472,7 +472,7 @@ static int setup_libalpm(void)
config->gpgdir = config->gpgdir ? config->gpgdir : strdup(GPGDIR); config->gpgdir = config->gpgdir ? config->gpgdir : strdup(GPGDIR);
ret = alpm_option_set_gpgdir(handle, config->gpgdir); ret = alpm_option_set_gpgdir(handle, config->gpgdir);
if(ret != 0) { if(ret != 0) {
pm_printf(PM_LOG_ERROR, _("problem setting gpgdir '%s' (%s)\n"), pm_printf(ALPM_LOG_ERROR, _("problem setting gpgdir '%s' (%s)\n"),
config->gpgdir, alpm_strerror(alpm_errno(handle))); config->gpgdir, alpm_strerror(alpm_errno(handle)));
return ret; return ret;
} }
@ -537,7 +537,7 @@ static int finish_section(struct section_t *section, int parse_options)
alpm_list_t *i; alpm_list_t *i;
alpm_db_t *db; alpm_db_t *db;
pm_printf(PM_LOG_DEBUG, "config: finish section '%s'\n", section->name); pm_printf(ALPM_LOG_DEBUG, "config: finish section '%s'\n", section->name);
/* parsing options (or nothing)- nothing to do except free the pieces */ /* parsing options (or nothing)- nothing to do except free the pieces */
if(!section->name || parse_options || section->is_options) { if(!section->name || parse_options || section->is_options) {
@ -547,7 +547,7 @@ static int finish_section(struct section_t *section, int parse_options)
/* if we are not looking at options sections only, register a db */ /* if we are not looking at options sections only, register a db */
db = alpm_db_register_sync(config->handle, section->name, section->sigverify); db = alpm_db_register_sync(config->handle, section->name, section->sigverify);
if(db == NULL) { if(db == NULL) {
pm_printf(PM_LOG_ERROR, _("could not register '%s' database (%s)\n"), pm_printf(ALPM_LOG_ERROR, _("could not register '%s' database (%s)\n"),
section->name, alpm_strerror(alpm_errno(config->handle))); section->name, alpm_strerror(alpm_errno(config->handle)));
ret = 1; ret = 1;
goto cleanup; goto cleanup;
@ -556,7 +556,7 @@ static int finish_section(struct section_t *section, int parse_options)
for(i = section->servers; i; i = alpm_list_next(i)) { for(i = section->servers; i; i = alpm_list_next(i)) {
char *value = alpm_list_getdata(i); char *value = alpm_list_getdata(i);
if(_add_mirror(db, value) != 0) { if(_add_mirror(db, value) != 0) {
pm_printf(PM_LOG_ERROR, pm_printf(ALPM_LOG_ERROR,
_("could not add mirror '%s' to database '%s' (%s)\n"), _("could not add mirror '%s' to database '%s' (%s)\n"),
value, section->name, alpm_strerror(alpm_errno(config->handle))); value, section->name, alpm_strerror(alpm_errno(config->handle)));
ret = 1; ret = 1;
@ -595,16 +595,16 @@ static int _parseconfig(const char *file, struct section_t *section,
const int max_depth = 10; const int max_depth = 10;
if(depth >= max_depth) { if(depth >= max_depth) {
pm_printf(PM_LOG_ERROR, pm_printf(ALPM_LOG_ERROR,
_("config parsing exceeded max recursion depth of %d.\n"), max_depth); _("config parsing exceeded max recursion depth of %d.\n"), max_depth);
ret = 1; ret = 1;
goto cleanup; goto cleanup;
} }
pm_printf(PM_LOG_DEBUG, "config: attempting to read file %s\n", file); pm_printf(ALPM_LOG_DEBUG, "config: attempting to read file %s\n", file);
fp = fopen(file, "r"); fp = fopen(file, "r");
if(fp == NULL) { if(fp == NULL) {
pm_printf(PM_LOG_ERROR, _("config file %s could not be read.\n"), file); pm_printf(ALPM_LOG_ERROR, _("config file %s could not be read.\n"), file);
ret = 1; ret = 1;
goto cleanup; goto cleanup;
} }
@ -629,7 +629,7 @@ static int _parseconfig(const char *file, struct section_t *section,
char *name; char *name;
/* only possibility here is a line == '[]' */ /* only possibility here is a line == '[]' */
if(line_len <= 2) { if(line_len <= 2) {
pm_printf(PM_LOG_ERROR, _("config file %s, line %d: bad section name.\n"), pm_printf(ALPM_LOG_ERROR, _("config file %s, line %d: bad section name.\n"),
file, linenum); file, linenum);
ret = 1; ret = 1;
goto cleanup; goto cleanup;
@ -642,7 +642,7 @@ static int _parseconfig(const char *file, struct section_t *section,
ret = 1; ret = 1;
goto cleanup; goto cleanup;
} }
pm_printf(PM_LOG_DEBUG, "config: new section '%s'\n", name); pm_printf(ALPM_LOG_DEBUG, "config: new section '%s'\n", name);
section->name = name; section->name = name;
section->is_options = (strcmp(name, "options") == 0); section->is_options = (strcmp(name, "options") == 0);
continue; continue;
@ -657,14 +657,14 @@ static int _parseconfig(const char *file, struct section_t *section,
strtrim(value); strtrim(value);
if(key == NULL) { if(key == NULL) {
pm_printf(PM_LOG_ERROR, _("config file %s, line %d: syntax error in config file- missing key.\n"), pm_printf(ALPM_LOG_ERROR, _("config file %s, line %d: syntax error in config file- missing key.\n"),
file, linenum); file, linenum);
ret = 1; ret = 1;
goto cleanup; goto cleanup;
} }
/* For each directive, compare to the camelcase string. */ /* For each directive, compare to the camelcase string. */
if(section->name == NULL) { if(section->name == NULL) {
pm_printf(PM_LOG_ERROR, _("config file %s, line %d: All directives must belong to a section.\n"), pm_printf(ALPM_LOG_ERROR, _("config file %s, line %d: All directives must belong to a section.\n"),
file, linenum); file, linenum);
ret = 1; ret = 1;
goto cleanup; goto cleanup;
@ -676,7 +676,7 @@ static int _parseconfig(const char *file, struct section_t *section,
size_t gindex; size_t gindex;
if(value == NULL) { if(value == NULL) {
pm_printf(PM_LOG_ERROR, _("config file %s, line %d: directive '%s' needs a value\n"), pm_printf(ALPM_LOG_ERROR, _("config file %s, line %d: directive '%s' needs a value\n"),
file, linenum, key); file, linenum, key);
ret = 1; ret = 1;
goto cleanup; goto cleanup;
@ -685,23 +685,23 @@ static int _parseconfig(const char *file, struct section_t *section,
globret = glob(value, GLOB_NOCHECK, NULL, &globbuf); globret = glob(value, GLOB_NOCHECK, NULL, &globbuf);
switch(globret) { switch(globret) {
case GLOB_NOSPACE: case GLOB_NOSPACE:
pm_printf(PM_LOG_DEBUG, pm_printf(ALPM_LOG_DEBUG,
"config file %s, line %d: include globbing out of space\n", "config file %s, line %d: include globbing out of space\n",
file, linenum); file, linenum);
break; break;
case GLOB_ABORTED: case GLOB_ABORTED:
pm_printf(PM_LOG_DEBUG, pm_printf(ALPM_LOG_DEBUG,
"config file %s, line %d: include globbing read error for %s\n", "config file %s, line %d: include globbing read error for %s\n",
file, linenum, value); file, linenum, value);
break; break;
case GLOB_NOMATCH: case GLOB_NOMATCH:
pm_printf(PM_LOG_DEBUG, pm_printf(ALPM_LOG_DEBUG,
"config file %s, line %d: no include found for %s\n", "config file %s, line %d: no include found for %s\n",
file, linenum, value); file, linenum, value);
break; break;
default: default:
for(gindex = 0; gindex < globbuf.gl_pathc; gindex++) { for(gindex = 0; gindex < globbuf.gl_pathc; gindex++) {
pm_printf(PM_LOG_DEBUG, "config file %s, line %d: including %s\n", pm_printf(ALPM_LOG_DEBUG, "config file %s, line %d: including %s\n",
file, linenum, globbuf.gl_pathv[gindex]); file, linenum, globbuf.gl_pathv[gindex]);
_parseconfig(globbuf.gl_pathv[gindex], section, parse_options, depth + 1); _parseconfig(globbuf.gl_pathv[gindex], section, parse_options, depth + 1);
} }
@ -719,7 +719,7 @@ static int _parseconfig(const char *file, struct section_t *section,
/* ... or in a repo section */ /* ... or in a repo section */
if(strcmp(key, "Server") == 0) { if(strcmp(key, "Server") == 0) {
if(value == NULL) { if(value == NULL) {
pm_printf(PM_LOG_ERROR, _("config file %s, line %d: directive '%s' needs a value\n"), pm_printf(ALPM_LOG_ERROR, _("config file %s, line %d: directive '%s' needs a value\n"),
file, linenum, key); file, linenum, key);
ret = 1; ret = 1;
goto cleanup; goto cleanup;
@ -730,14 +730,14 @@ static int _parseconfig(const char *file, struct section_t *section,
if(level != PM_PGP_VERIFY_UNKNOWN) { if(level != PM_PGP_VERIFY_UNKNOWN) {
section->sigverify = level; section->sigverify = level;
} else { } else {
pm_printf(PM_LOG_ERROR, pm_printf(ALPM_LOG_ERROR,
_("config file %s, line %d: directive '%s' has invalid value '%s'\n"), _("config file %s, line %d: directive '%s' has invalid value '%s'\n"),
file, linenum, key, value); file, linenum, key, value);
ret = 1; ret = 1;
goto cleanup; goto cleanup;
} }
} else { } else {
pm_printf(PM_LOG_WARNING, pm_printf(ALPM_LOG_WARNING,
_("config file %s, line %d: directive '%s' in section '%s' not recognized.\n"), _("config file %s, line %d: directive '%s' in section '%s' not recognized.\n"),
file, linenum, key, section->name); file, linenum, key, section->name);
} }
@ -750,7 +750,7 @@ static int _parseconfig(const char *file, struct section_t *section,
cleanup: cleanup:
fclose(fp); fclose(fp);
pm_printf(PM_LOG_DEBUG, "config: finished parsing %s\n", file); pm_printf(ALPM_LOG_DEBUG, "config: finished parsing %s\n", file);
return ret; return ret;
} }
@ -768,7 +768,7 @@ int parseconfig(const char *file)
* Next, we go back and parse everything but [options]. */ * Next, we go back and parse everything but [options]. */
/* call the real parseconfig function with a null section & db argument */ /* call the real parseconfig function with a null section & db argument */
pm_printf(PM_LOG_DEBUG, "parseconfig: options pass\n"); pm_printf(ALPM_LOG_DEBUG, "parseconfig: options pass\n");
if((ret = _parseconfig(file, &section, 1, 0))) { if((ret = _parseconfig(file, &section, 1, 0))) {
return ret; return ret;
} }
@ -776,7 +776,7 @@ int parseconfig(const char *file)
return ret; return ret;
} }
/* second pass, repo section parsing */ /* second pass, repo section parsing */
pm_printf(PM_LOG_DEBUG, "parseconfig: repo pass\n"); pm_printf(ALPM_LOG_DEBUG, "parseconfig: repo pass\n");
return _parseconfig(file, &section, 0, 0); return _parseconfig(file, &section, 0, 0);
} }

View File

@ -45,16 +45,16 @@ int pacman_database(alpm_list_t *targets)
alpm_pkgreason_t reason; alpm_pkgreason_t reason;
if(targets == NULL) { if(targets == NULL) {
pm_printf(PM_LOG_ERROR, _("no targets specified (use -h for help)\n")); pm_printf(ALPM_LOG_ERROR, _("no targets specified (use -h for help)\n"));
return 1; return 1;
} }
if(config->flags & PM_TRANS_FLAG_ALLDEPS) { /* --asdeps */ if(config->flags & ALPM_TRANS_FLAG_ALLDEPS) { /* --asdeps */
reason = PM_PKG_REASON_DEPEND; reason = ALPM_PKG_REASON_DEPEND;
} else if(config->flags & PM_TRANS_FLAG_ALLEXPLICIT) { /* --asexplicit */ } else if(config->flags & ALPM_TRANS_FLAG_ALLEXPLICIT) { /* --asexplicit */
reason = PM_PKG_REASON_EXPLICIT; reason = ALPM_PKG_REASON_EXPLICIT;
} else { } else {
pm_printf(PM_LOG_ERROR, _("no install reason specified (use -h for help)\n")); pm_printf(ALPM_LOG_ERROR, _("no install reason specified (use -h for help)\n"));
return 1; return 1;
} }
@ -67,11 +67,11 @@ int pacman_database(alpm_list_t *targets)
for(i = targets; i; i = alpm_list_next(i)) { for(i = targets; i; i = alpm_list_next(i)) {
char *pkgname = i->data; char *pkgname = i->data;
if(alpm_db_set_pkgreason(db_local, pkgname, reason) == -1) { if(alpm_db_set_pkgreason(db_local, pkgname, reason) == -1) {
pm_printf(PM_LOG_ERROR, _("could not set install reason for package %s (%s)\n"), pm_printf(ALPM_LOG_ERROR, _("could not set install reason for package %s (%s)\n"),
pkgname, alpm_strerror(alpm_errno(config->handle))); pkgname, alpm_strerror(alpm_errno(config->handle)));
retval = 1; retval = 1;
} else { } else {
if(reason == PM_PKG_REASON_DEPEND) { if(reason == ALPM_PKG_REASON_DEPEND) {
printf(_("%s: install reason has been set to 'installed as dependency'\n"), pkgname); printf(_("%s: install reason has been set to 'installed as dependency'\n"), pkgname);
} else { } else {
printf(_("%s: install reason has been set to 'explicitly installed'\n"), pkgname); printf(_("%s: install reason has been set to 'explicitly installed'\n"), pkgname);

View File

@ -70,10 +70,10 @@ void dump_pkg_full(alpm_pkg_t *pkg, enum pkg_from from, int extra)
} }
switch((long)alpm_pkg_get_reason(pkg)) { switch((long)alpm_pkg_get_reason(pkg)) {
case PM_PKG_REASON_EXPLICIT: case ALPM_PKG_REASON_EXPLICIT:
reason = _("Explicitly installed"); reason = _("Explicitly installed");
break; break;
case PM_PKG_REASON_DEPEND: case ALPM_PKG_REASON_DEPEND:
reason = _("Installed as a dependency for another package"); reason = _("Installed as a dependency for another package");
break; break;
default: default:
@ -163,7 +163,7 @@ static const char *get_backup_file_status(const char *root,
char *md5sum = alpm_compute_md5sum(path); char *md5sum = alpm_compute_md5sum(path);
if(md5sum == NULL) { if(md5sum == NULL) {
pm_fprintf(stderr, PM_LOG_ERROR, pm_fprintf(stderr, ALPM_LOG_ERROR,
_("could not calculate checksums for %s\n"), path); _("could not calculate checksums for %s\n"), path);
return NULL; return NULL;
} }
@ -244,7 +244,7 @@ void dump_pkg_changelog(alpm_pkg_t *pkg)
void *fp = NULL; void *fp = NULL;
if((fp = alpm_pkg_changelog_open(pkg)) == NULL) { if((fp = alpm_pkg_changelog_open(pkg)) == NULL) {
pm_fprintf(stderr, PM_LOG_ERROR, _("no changelog available for '%s'.\n"), pm_fprintf(stderr, ALPM_LOG_ERROR, _("no changelog available for '%s'.\n"),
alpm_pkg_get_name(pkg)); alpm_pkg_get_name(pkg));
return; return;
} else { } else {

View File

@ -264,7 +264,7 @@ static void setuseragent(void)
static void cleanup(int ret) { static void cleanup(int ret) {
/* free alpm library resources */ /* free alpm library resources */
if(config->handle && alpm_release(config->handle) == -1) { if(config->handle && alpm_release(config->handle) == -1) {
pm_printf(PM_LOG_ERROR, "error releasing alpm library\n"); pm_printf(ALPM_LOG_ERROR, "error releasing alpm library\n");
} }
/* free memory */ /* free memory */
@ -408,17 +408,17 @@ static int parsearg_global(int opt)
unsigned short debug = (unsigned short)atoi(optarg); unsigned short debug = (unsigned short)atoi(optarg);
switch(debug) { switch(debug) {
case 2: case 2:
config->logmask |= PM_LOG_FUNCTION; /* fall through */ config->logmask |= ALPM_LOG_FUNCTION; /* fall through */
case 1: case 1:
config->logmask |= PM_LOG_DEBUG; config->logmask |= ALPM_LOG_DEBUG;
break; break;
default: default:
pm_printf(PM_LOG_ERROR, _("'%s' is not a valid debug level\n"), pm_printf(ALPM_LOG_ERROR, _("'%s' is not a valid debug level\n"),
optarg); optarg);
return 1; return 1;
} }
} else { } else {
config->logmask |= PM_LOG_DEBUG; config->logmask |= ALPM_LOG_DEBUG;
} }
/* progress bars get wonky with debug on, shut them off */ /* progress bars get wonky with debug on, shut them off */
config->noprogressbar = 1; config->noprogressbar = 1;
@ -445,8 +445,8 @@ static int parsearg_global(int opt)
static int parsearg_database(int opt) static int parsearg_database(int opt)
{ {
switch(opt) { switch(opt) {
case OP_ASDEPS: config->flags |= PM_TRANS_FLAG_ALLDEPS; break; case OP_ASDEPS: config->flags |= ALPM_TRANS_FLAG_ALLDEPS; break;
case OP_ASEXPLICIT: config->flags |= PM_TRANS_FLAG_ALLEXPLICIT; break; case OP_ASEXPLICIT: config->flags |= ALPM_TRANS_FLAG_ALLEXPLICIT; break;
default: return 1; default: return 1;
} }
return 0; return 0;
@ -479,15 +479,15 @@ static int parsearg_trans(int opt)
{ {
switch(opt) { switch(opt) {
case 'd': case 'd':
if(config->flags & PM_TRANS_FLAG_NODEPVERSION) { if(config->flags & ALPM_TRANS_FLAG_NODEPVERSION) {
config->flags |= PM_TRANS_FLAG_NODEPS; config->flags |= ALPM_TRANS_FLAG_NODEPS;
} else { } else {
config->flags |= PM_TRANS_FLAG_NODEPVERSION; config->flags |= ALPM_TRANS_FLAG_NODEPVERSION;
} }
break; break;
case 'k': config->flags |= PM_TRANS_FLAG_DBONLY; break; case 'k': config->flags |= ALPM_TRANS_FLAG_DBONLY; break;
case OP_NOPROGRESSBAR: config->noprogressbar = 1; break; case OP_NOPROGRESSBAR: config->noprogressbar = 1; break;
case OP_NOSCRIPTLET: config->flags |= PM_TRANS_FLAG_NOSCRIPTLET; break; case OP_NOSCRIPTLET: config->flags |= ALPM_TRANS_FLAG_NOSCRIPTLET; break;
case 'p': config->print = 1; break; case 'p': config->print = 1; break;
case OP_PRINTFORMAT: case OP_PRINTFORMAT:
check_optarg(); check_optarg();
@ -503,16 +503,16 @@ static int parsearg_remove(int opt)
if(parsearg_trans(opt) == 0) if(parsearg_trans(opt) == 0)
return 0; return 0;
switch(opt) { switch(opt) {
case 'c': config->flags |= PM_TRANS_FLAG_CASCADE; break; case 'c': config->flags |= ALPM_TRANS_FLAG_CASCADE; break;
case 'n': config->flags |= PM_TRANS_FLAG_NOSAVE; break; case 'n': config->flags |= ALPM_TRANS_FLAG_NOSAVE; break;
case 's': case 's':
if(config->flags & PM_TRANS_FLAG_RECURSE) { if(config->flags & ALPM_TRANS_FLAG_RECURSE) {
config->flags |= PM_TRANS_FLAG_RECURSEALL; config->flags |= ALPM_TRANS_FLAG_RECURSEALL;
} else { } else {
config->flags |= PM_TRANS_FLAG_RECURSE; config->flags |= ALPM_TRANS_FLAG_RECURSE;
} }
break; break;
case 'u': config->flags |= PM_TRANS_FLAG_UNNEEDED; break; case 'u': config->flags |= ALPM_TRANS_FLAG_UNNEEDED; break;
default: return 1; default: return 1;
} }
return 0; return 0;
@ -524,9 +524,9 @@ static int parsearg_upgrade(int opt)
if(parsearg_trans(opt) == 0) if(parsearg_trans(opt) == 0)
return 0; return 0;
switch(opt) { switch(opt) {
case 'f': config->flags |= PM_TRANS_FLAG_FORCE; break; case 'f': config->flags |= ALPM_TRANS_FLAG_FORCE; break;
case OP_ASDEPS: config->flags |= PM_TRANS_FLAG_ALLDEPS; break; case OP_ASDEPS: config->flags |= ALPM_TRANS_FLAG_ALLDEPS; break;
case OP_ASEXPLICIT: config->flags |= PM_TRANS_FLAG_ALLEXPLICIT; break; case OP_ASEXPLICIT: config->flags |= ALPM_TRANS_FLAG_ALLEXPLICIT; break;
case OP_IGNORE: case OP_IGNORE:
parsearg_util_addlist(&(config->ignorepkg)); parsearg_util_addlist(&(config->ignorepkg));
break; break;
@ -543,7 +543,7 @@ static int parsearg_sync(int opt)
if(parsearg_upgrade(opt) == 0) if(parsearg_upgrade(opt) == 0)
return 0; return 0;
switch(opt) { switch(opt) {
case OP_NEEDED: config->flags |= PM_TRANS_FLAG_NEEDED; break; case OP_NEEDED: config->flags |= ALPM_TRANS_FLAG_NEEDED; break;
case 'c': (config->op_s_clean)++; break; case 'c': (config->op_s_clean)++; break;
case 'g': (config->group)++; break; case 'g': (config->group)++; break;
case 'i': (config->op_s_info)++; break; case 'i': (config->op_s_info)++; break;
@ -553,8 +553,8 @@ static int parsearg_sync(int opt)
case 'u': (config->op_s_upgrade)++; break; case 'u': (config->op_s_upgrade)++; break;
case 'w': case 'w':
config->op_s_downloadonly = 1; config->op_s_downloadonly = 1;
config->flags |= PM_TRANS_FLAG_DOWNLOADONLY; config->flags |= ALPM_TRANS_FLAG_DOWNLOADONLY;
config->flags |= PM_TRANS_FLAG_NOCONFLICTS; config->flags |= ALPM_TRANS_FLAG_NOCONFLICTS;
break; break;
case 'y': (config->op_s_sync)++; break; case 'y': (config->op_s_sync)++; break;
default: return 1; default: return 1;
@ -645,7 +645,7 @@ static int parseargs(int argc, char *argv[])
} }
if(config->op == 0) { if(config->op == 0) {
pm_printf(PM_LOG_ERROR, _("only one operation may be used at a time\n")); pm_printf(ALPM_LOG_ERROR, _("only one operation may be used at a time\n"));
return 1; return 1;
} }
if(config->help) { if(config->help) {
@ -701,7 +701,7 @@ static int parseargs(int argc, char *argv[])
result = parsearg_global(opt); result = parsearg_global(opt);
if(result != 0) { if(result != 0) {
/* global option parsing failed, abort */ /* global option parsing failed, abort */
pm_printf(PM_LOG_ERROR, _("invalid option\n")); pm_printf(ALPM_LOG_ERROR, _("invalid option\n"));
return result; return result;
} }
} }
@ -833,7 +833,7 @@ int main(int argc, char *argv[])
} }
/* check for buffer overflow */ /* check for buffer overflow */
if(i >= PATH_MAX) { if(i >= PATH_MAX) {
pm_printf(PM_LOG_ERROR, _("buffer overflow detected in arg parsing\n")); pm_printf(ALPM_LOG_ERROR, _("buffer overflow detected in arg parsing\n"));
cleanup(EXIT_FAILURE); cleanup(EXIT_FAILURE);
} }
@ -843,7 +843,7 @@ int main(int argc, char *argv[])
pm_targets = alpm_list_add(pm_targets, strdup(line)); pm_targets = alpm_list_add(pm_targets, strdup(line));
} }
if(!freopen(ctermid(NULL), "r", stdin)) { if(!freopen(ctermid(NULL), "r", stdin)) {
pm_printf(PM_LOG_ERROR, _("failed to reopen stdin for reading: (%s)\n"), pm_printf(ALPM_LOG_ERROR, _("failed to reopen stdin for reading: (%s)\n"),
strerror(errno)); strerror(errno));
} }
} }
@ -862,16 +862,16 @@ int main(int argc, char *argv[])
/* set up the print operations */ /* set up the print operations */
if(config->print && !config->op_s_clean) { if(config->print && !config->op_s_clean) {
config->noconfirm = 1; config->noconfirm = 1;
config->flags |= PM_TRANS_FLAG_NOCONFLICTS; config->flags |= ALPM_TRANS_FLAG_NOCONFLICTS;
config->flags |= PM_TRANS_FLAG_NOLOCK; config->flags |= ALPM_TRANS_FLAG_NOLOCK;
/* Display only errors */ /* Display only errors */
config->logmask &= ~PM_LOG_WARNING; config->logmask &= ~ALPM_LOG_WARNING;
} }
#if defined(HAVE_GETEUID) && !defined(CYGWIN) #if defined(HAVE_GETEUID) && !defined(CYGWIN)
/* check if we have sufficient permission for the requested operation */ /* check if we have sufficient permission for the requested operation */
if(myuid > 0 && needs_root()) { if(myuid > 0 && needs_root()) {
pm_printf(PM_LOG_ERROR, _("you cannot perform this operation unless you are root.\n")); pm_printf(ALPM_LOG_ERROR, _("you cannot perform this operation unless you are root.\n"));
cleanup(EXIT_FAILURE); cleanup(EXIT_FAILURE);
} }
#endif #endif
@ -918,7 +918,7 @@ int main(int argc, char *argv[])
ret = pacman_deptest(pm_targets); ret = pacman_deptest(pm_targets);
break; break;
default: default:
pm_printf(PM_LOG_ERROR, _("no operation specified (use -h for help)\n")); pm_printf(ALPM_LOG_ERROR, _("no operation specified (use -h for help)\n"));
ret = EXIT_FAILURE; ret = EXIT_FAILURE;
} }

View File

@ -117,7 +117,7 @@ static int query_fileowner(alpm_list_t *targets)
/* This code is here for safety only */ /* This code is here for safety only */
if(targets == NULL) { if(targets == NULL) {
pm_fprintf(stderr, PM_LOG_ERROR, _("no file was specified for --owns\n")); pm_fprintf(stderr, ALPM_LOG_ERROR, _("no file was specified for --owns\n"));
return 1; return 1;
} }
@ -144,14 +144,14 @@ static int query_fileowner(alpm_list_t *targets)
/* if it is not a path but a program name, then check in PATH */ /* if it is not a path but a program name, then check in PATH */
if(strchr(filename, '/') == NULL) { if(strchr(filename, '/') == NULL) {
if(search_path(&filename, &buf) == -1) { if(search_path(&filename, &buf) == -1) {
pm_fprintf(stderr, PM_LOG_ERROR, _("failed to find '%s' in PATH: %s\n"), pm_fprintf(stderr, ALPM_LOG_ERROR, _("failed to find '%s' in PATH: %s\n"),
filename, strerror(errno)); filename, strerror(errno));
ret++; ret++;
free(filename); free(filename);
continue; continue;
} }
} else { } else {
pm_fprintf(stderr, PM_LOG_ERROR, _("failed to read file '%s': %s\n"), pm_fprintf(stderr, ALPM_LOG_ERROR, _("failed to read file '%s': %s\n"),
filename, strerror(errno)); filename, strerror(errno));
ret++; ret++;
free(filename); free(filename);
@ -160,7 +160,7 @@ static int query_fileowner(alpm_list_t *targets)
} }
if(S_ISDIR(buf.st_mode)) { if(S_ISDIR(buf.st_mode)) {
pm_fprintf(stderr, PM_LOG_ERROR, pm_fprintf(stderr, ALPM_LOG_ERROR,
_("cannot determine ownership of directory '%s'\n"), filename); _("cannot determine ownership of directory '%s'\n"), filename);
ret++; ret++;
free(filename); free(filename);
@ -176,7 +176,7 @@ static int query_fileowner(alpm_list_t *targets)
rpath = resolve_path(dname); rpath = resolve_path(dname);
if(!rpath) { if(!rpath) {
pm_fprintf(stderr, PM_LOG_ERROR, _("cannot determine real path for '%s': %s\n"), pm_fprintf(stderr, ALPM_LOG_ERROR, _("cannot determine real path for '%s': %s\n"),
filename, strerror(errno)); filename, strerror(errno));
free(filename); free(filename);
free(dname); free(dname);
@ -209,7 +209,7 @@ static int query_fileowner(alpm_list_t *targets)
} }
if(strlen(pkgfile) > max_length) { if(strlen(pkgfile) > max_length) {
pm_fprintf(stderr, PM_LOG_ERROR, _("path too long: %s%s\n"), root, pkgfile); pm_fprintf(stderr, ALPM_LOG_ERROR, _("path too long: %s%s\n"), root, pkgfile);
} }
/* concatenate our file and the root path */ /* concatenate our file and the root path */
strcpy(append, pkgfile); strcpy(append, pkgfile);
@ -226,7 +226,7 @@ static int query_fileowner(alpm_list_t *targets)
} }
} }
if(!found) { if(!found) {
pm_fprintf(stderr, PM_LOG_ERROR, _("No package owns %s\n"), filename); pm_fprintf(stderr, ALPM_LOG_ERROR, _("No package owns %s\n"), filename);
ret++; ret++;
} }
free(filename); free(filename);
@ -328,7 +328,7 @@ static int query_group(alpm_list_t *targets)
} }
} }
} else { } else {
pm_fprintf(stderr, PM_LOG_ERROR, _("group \"%s\" was not found\n"), grpname); pm_fprintf(stderr, ALPM_LOG_ERROR, _("group \"%s\" was not found\n"), grpname);
ret++; ret++;
} }
} }
@ -371,12 +371,12 @@ static int filter(alpm_pkg_t *pkg)
{ {
/* check if this package was explicitly installed */ /* check if this package was explicitly installed */
if(config->op_q_explicit && if(config->op_q_explicit &&
alpm_pkg_get_reason(pkg) != PM_PKG_REASON_EXPLICIT) { alpm_pkg_get_reason(pkg) != ALPM_PKG_REASON_EXPLICIT) {
return 0; return 0;
} }
/* check if this package was installed as a dependency */ /* check if this package was installed as a dependency */
if(config->op_q_deps && if(config->op_q_deps &&
alpm_pkg_get_reason(pkg) != PM_PKG_REASON_DEPEND) { alpm_pkg_get_reason(pkg) != ALPM_PKG_REASON_DEPEND) {
return 0; return 0;
} }
/* check if this pkg isn't in a sync DB */ /* check if this pkg isn't in a sync DB */
@ -409,7 +409,7 @@ static int check(alpm_pkg_t *pkg)
rootlen = strlen(root); rootlen = strlen(root);
if(rootlen + 1 > PATH_MAX) { if(rootlen + 1 > PATH_MAX) {
/* we are in trouble here */ /* we are in trouble here */
pm_fprintf(stderr, PM_LOG_ERROR, _("path too long: %s%s\n"), root, ""); pm_fprintf(stderr, ALPM_LOG_ERROR, _("path too long: %s%s\n"), root, "");
return 1; return 1;
} }
strcpy(f, root); strcpy(f, root);
@ -421,7 +421,7 @@ static int check(alpm_pkg_t *pkg)
const char *path = file->name; const char *path = file->name;
if(rootlen + 1 + strlen(path) > PATH_MAX) { if(rootlen + 1 + strlen(path) > PATH_MAX) {
pm_fprintf(stderr, PM_LOG_WARNING, _("path too long: %s%s\n"), root, path); pm_fprintf(stderr, ALPM_LOG_WARNING, _("path too long: %s%s\n"), root, path);
continue; continue;
} }
strcpy(f + rootlen, path); strcpy(f + rootlen, path);
@ -431,7 +431,7 @@ static int check(alpm_pkg_t *pkg)
if(config->quiet) { if(config->quiet) {
printf("%s %s\n", pkgname, f); printf("%s %s\n", pkgname, f);
} else { } else {
pm_printf(PM_LOG_WARNING, "%s: %s (%s)\n", pm_printf(ALPM_LOG_WARNING, "%s: %s (%s)\n",
pkgname, f, strerror(errno)); pkgname, f, strerror(errno));
} }
errors++; errors++;
@ -505,7 +505,7 @@ int pacman_query(alpm_list_t *targets)
/* ensure we have at least one valid sync db set up */ /* ensure we have at least one valid sync db set up */
alpm_list_t *sync_dbs = alpm_option_get_syncdbs(config->handle); alpm_list_t *sync_dbs = alpm_option_get_syncdbs(config->handle);
if(sync_dbs == NULL) { if(sync_dbs == NULL) {
pm_printf(PM_LOG_ERROR, _("no usable package repositories configured.\n")); pm_printf(ALPM_LOG_ERROR, _("no usable package repositories configured.\n"));
return 1; return 1;
} }
} }
@ -517,7 +517,7 @@ int pacman_query(alpm_list_t *targets)
* invalid: isfile, owns */ * invalid: isfile, owns */
if(targets == NULL) { if(targets == NULL) {
if(config->op_q_isfile || config->op_q_owns) { if(config->op_q_isfile || config->op_q_owns) {
pm_printf(PM_LOG_ERROR, _("no targets specified (use -h for help)\n")); pm_printf(ALPM_LOG_ERROR, _("no targets specified (use -h for help)\n"));
return 1; return 1;
} }
@ -557,7 +557,7 @@ int pacman_query(alpm_list_t *targets)
} }
if(pkg == NULL) { if(pkg == NULL) {
pm_fprintf(stderr, PM_LOG_ERROR, _("package \"%s\" not found\n"), strname); pm_fprintf(stderr, ALPM_LOG_ERROR, _("package \"%s\" not found\n"), strname);
ret = 1; ret = 1;
continue; continue;
} }

View File

@ -39,7 +39,7 @@ static int remove_target(const char *target)
if((info = alpm_db_get_pkg(db_local, target)) != NULL) { if((info = alpm_db_get_pkg(db_local, target)) != NULL) {
if(alpm_remove_pkg(config->handle, info) == -1) { if(alpm_remove_pkg(config->handle, info) == -1) {
pm_fprintf(stderr, PM_LOG_ERROR, "'%s': %s\n", target, pm_fprintf(stderr, ALPM_LOG_ERROR, "'%s': %s\n", target,
alpm_strerror(alpm_errno(config->handle))); alpm_strerror(alpm_errno(config->handle)));
return -1; return -1;
} }
@ -49,13 +49,13 @@ static int remove_target(const char *target)
/* fallback to group */ /* fallback to group */
alpm_group_t *grp = alpm_db_readgroup(db_local, target); alpm_group_t *grp = alpm_db_readgroup(db_local, target);
if(grp == NULL) { if(grp == NULL) {
pm_fprintf(stderr, PM_LOG_ERROR, "'%s': target not found\n", target); pm_fprintf(stderr, ALPM_LOG_ERROR, "'%s': target not found\n", target);
return -1; return -1;
} }
for(p = grp->packages; p; p = alpm_list_next(p)) { for(p = grp->packages; p; p = alpm_list_next(p)) {
alpm_pkg_t *pkg = alpm_list_getdata(p); alpm_pkg_t *pkg = alpm_list_getdata(p);
if(alpm_remove_pkg(config->handle, pkg) == -1) { if(alpm_remove_pkg(config->handle, pkg) == -1) {
pm_fprintf(stderr, PM_LOG_ERROR, "'%s': %s\n", target, pm_fprintf(stderr, ALPM_LOG_ERROR, "'%s': %s\n", target,
alpm_strerror(alpm_errno(config->handle))); alpm_strerror(alpm_errno(config->handle)));
return -1; return -1;
} }
@ -76,7 +76,7 @@ int pacman_remove(alpm_list_t *targets)
alpm_list_t *i, *data = NULL; alpm_list_t *i, *data = NULL;
if(targets == NULL) { if(targets == NULL) {
pm_printf(PM_LOG_ERROR, _("no targets specified (use -h for help)\n")); pm_printf(ALPM_LOG_ERROR, _("no targets specified (use -h for help)\n"));
return 1; return 1;
} }
@ -103,16 +103,16 @@ int pacman_remove(alpm_list_t *targets)
/* Step 2: prepare the transaction based on its type, targets and flags */ /* Step 2: prepare the transaction based on its type, targets and flags */
if(alpm_trans_prepare(config->handle, &data) == -1) { if(alpm_trans_prepare(config->handle, &data) == -1) {
enum _alpm_errno_t err = alpm_errno(config->handle); enum _alpm_errno_t err = alpm_errno(config->handle);
pm_fprintf(stderr, PM_LOG_ERROR, _("failed to prepare transaction (%s)\n"), pm_fprintf(stderr, ALPM_LOG_ERROR, _("failed to prepare transaction (%s)\n"),
alpm_strerror(err)); alpm_strerror(err));
switch(err) { switch(err) {
case PM_ERR_PKG_INVALID_ARCH: case ALPM_ERR_PKG_INVALID_ARCH:
for(i = data; i; i = alpm_list_next(i)) { for(i = data; i; i = alpm_list_next(i)) {
char *pkg = alpm_list_getdata(i); char *pkg = alpm_list_getdata(i);
printf(_(":: package %s does not have a valid architecture\n"), pkg); printf(_(":: package %s does not have a valid architecture\n"), pkg);
} }
break; break;
case PM_ERR_UNSATISFIED_DEPS: case ALPM_ERR_UNSATISFIED_DEPS:
for(i = data; i; i = alpm_list_next(i)) { for(i = data; i; i = alpm_list_next(i)) {
alpm_depmissing_t *miss = alpm_list_getdata(i); alpm_depmissing_t *miss = alpm_list_getdata(i);
char *depstring = alpm_dep_compute_string(miss->depend); char *depstring = alpm_dep_compute_string(miss->depend);
@ -133,7 +133,7 @@ int pacman_remove(alpm_list_t *targets)
for(i = alpm_trans_get_remove(config->handle); i; i = alpm_list_next(i)) { for(i = alpm_trans_get_remove(config->handle); i; i = alpm_list_next(i)) {
alpm_pkg_t *pkg = alpm_list_getdata(i); alpm_pkg_t *pkg = alpm_list_getdata(i);
if(alpm_list_find_str(config->holdpkg, alpm_pkg_get_name(pkg))) { if(alpm_list_find_str(config->holdpkg, alpm_pkg_get_name(pkg))) {
pm_printf(PM_LOG_WARNING, _("%s is designated as a HoldPkg.\n"), pm_printf(ALPM_LOG_WARNING, _("%s is designated as a HoldPkg.\n"),
alpm_pkg_get_name(pkg)); alpm_pkg_get_name(pkg));
holdpkg = 1; holdpkg = 1;
} }
@ -164,7 +164,7 @@ int pacman_remove(alpm_list_t *targets)
} }
if(alpm_trans_commit(config->handle, &data) == -1) { if(alpm_trans_commit(config->handle, &data) == -1) {
pm_fprintf(stderr, PM_LOG_ERROR, _("failed to commit transaction (%s)\n"), pm_fprintf(stderr, ALPM_LOG_ERROR, _("failed to commit transaction (%s)\n"),
alpm_strerror(alpm_errno(config->handle))); alpm_strerror(alpm_errno(config->handle)));
retval = 1; retval = 1;
} }

View File

@ -47,7 +47,7 @@ static int sync_cleandb(const char *dbpath, int keep_used)
dir = opendir(dbpath); dir = opendir(dbpath);
if(dir == NULL) { if(dir == NULL) {
pm_fprintf(stderr, PM_LOG_ERROR, _("could not access database directory\n")); pm_fprintf(stderr, ALPM_LOG_ERROR, _("could not access database directory\n"));
return 1; return 1;
} }
@ -82,7 +82,7 @@ static int sync_cleandb(const char *dbpath, int keep_used)
len = strlen(path); len = strlen(path);
if(S_ISDIR(buf.st_mode) || strcmp(path + len - 3, ".db") != 0) { if(S_ISDIR(buf.st_mode) || strcmp(path + len - 3, ".db") != 0) {
if(rmrf(path)) { if(rmrf(path)) {
pm_fprintf(stderr, PM_LOG_ERROR, pm_fprintf(stderr, ALPM_LOG_ERROR,
_("could not remove %s\n"), path); _("could not remove %s\n"), path);
closedir(dir); closedir(dir);
return 1; return 1;
@ -108,7 +108,7 @@ static int sync_cleandb(const char *dbpath, int keep_used)
} }
if(rmrf(path)) { if(rmrf(path)) {
pm_fprintf(stderr, PM_LOG_ERROR, pm_fprintf(stderr, ALPM_LOG_ERROR,
_("could not remove %s\n"), path); _("could not remove %s\n"), path);
closedir(dir); closedir(dir);
return 1; return 1;
@ -184,7 +184,7 @@ static int sync_cleancache(int level)
struct dirent *ent; struct dirent *ent;
if(dir == NULL) { if(dir == NULL) {
pm_fprintf(stderr, PM_LOG_ERROR, pm_fprintf(stderr, ALPM_LOG_ERROR,
_("could not access cache directory %s\n"), cachedir); _("could not access cache directory %s\n"), cachedir);
ret++; ret++;
continue; continue;
@ -240,7 +240,7 @@ static int sync_cleancache(int level)
if(pkg != NULL && alpm_pkg_vercmp(local_version, if(pkg != NULL && alpm_pkg_vercmp(local_version,
alpm_pkg_get_version(pkg)) == 0) { alpm_pkg_get_version(pkg)) == 0) {
/* package was found in local DB and version matches, keep it */ /* package was found in local DB and version matches, keep it */
pm_printf(PM_LOG_DEBUG, "pkg %s-%s found in local db\n", pm_printf(ALPM_LOG_DEBUG, "pkg %s-%s found in local db\n",
local_name, local_version); local_name, local_version);
delete = 0; delete = 0;
} }
@ -254,7 +254,7 @@ static int sync_cleancache(int level)
if(pkg != NULL && alpm_pkg_vercmp(local_version, if(pkg != NULL && alpm_pkg_vercmp(local_version,
alpm_pkg_get_version(pkg)) == 0) { alpm_pkg_get_version(pkg)) == 0) {
/* package was found in a sync DB and version matches, keep it */ /* package was found in a sync DB and version matches, keep it */
pm_printf(PM_LOG_DEBUG, "pkg %s-%s found in sync db\n", pm_printf(ALPM_LOG_DEBUG, "pkg %s-%s found in sync db\n",
local_name, local_version); local_name, local_version);
delete = 0; delete = 0;
} }
@ -288,7 +288,7 @@ static int sync_synctree(int level, alpm_list_t *syncs)
ret = alpm_db_update((level < 2 ? 0 : 1), db); ret = alpm_db_update((level < 2 ? 0 : 1), db);
if(ret < 0) { if(ret < 0) {
pm_fprintf(stderr, PM_LOG_ERROR, _("failed to update %s (%s)\n"), pm_fprintf(stderr, ALPM_LOG_ERROR, _("failed to update %s (%s)\n"),
alpm_db_get_name(db), alpm_strerror(alpm_errno(config->handle))); alpm_db_get_name(db), alpm_strerror(alpm_errno(config->handle)));
} else if(ret == 1) { } else if(ret == 1) {
printf(_(" %s is up to date\n"), alpm_db_get_name(db)); printf(_(" %s is up to date\n"), alpm_db_get_name(db));
@ -303,7 +303,7 @@ static int sync_synctree(int level, alpm_list_t *syncs)
* expected * expected
*/ */
if(!success) { if(!success) {
pm_fprintf(stderr, PM_LOG_ERROR, _("failed to synchronize any databases\n")); pm_fprintf(stderr, ALPM_LOG_ERROR, _("failed to synchronize any databases\n"));
} }
return (success > 0); return (success > 0);
} }
@ -465,7 +465,7 @@ static int sync_info(alpm_list_t *syncs, alpm_list_t *targets)
} }
if(!db) { if(!db) {
pm_fprintf(stderr, PM_LOG_ERROR, pm_fprintf(stderr, ALPM_LOG_ERROR,
_("repository '%s' does not exist\n"), repo); _("repository '%s' does not exist\n"), repo);
return 1; return 1;
} }
@ -481,7 +481,7 @@ static int sync_info(alpm_list_t *syncs, alpm_list_t *targets)
} }
if(!foundpkg) { if(!foundpkg) {
pm_fprintf(stderr, PM_LOG_ERROR, pm_fprintf(stderr, ALPM_LOG_ERROR,
_("package '%s' was not found in repository '%s'\n"), pkgstr, repo); _("package '%s' was not found in repository '%s'\n"), pkgstr, repo);
ret++; ret++;
} }
@ -502,7 +502,7 @@ static int sync_info(alpm_list_t *syncs, alpm_list_t *targets)
} }
} }
if(!foundpkg) { if(!foundpkg) {
pm_fprintf(stderr, PM_LOG_ERROR, pm_fprintf(stderr, ALPM_LOG_ERROR,
_("package '%s' was not found\n"), pkgstr); _("package '%s' was not found\n"), pkgstr);
ret++; ret++;
} }
@ -542,7 +542,7 @@ static int sync_list(alpm_list_t *syncs, alpm_list_t *targets)
} }
if(db == NULL) { if(db == NULL) {
pm_fprintf(stderr, PM_LOG_ERROR, pm_fprintf(stderr, ALPM_LOG_ERROR,
_("repository \"%s\" was not found.\n"),repo); _("repository \"%s\" was not found.\n"),repo);
alpm_list_free(ls); alpm_list_free(ls);
return 1; return 1;
@ -616,13 +616,13 @@ static int process_pkg(alpm_pkg_t *pkg)
if(ret == -1) { if(ret == -1) {
enum _alpm_errno_t err = alpm_errno(config->handle); enum _alpm_errno_t err = alpm_errno(config->handle);
if(err == PM_ERR_TRANS_DUP_TARGET if(err == ALPM_ERR_TRANS_DUP_TARGET
|| err == PM_ERR_PKG_IGNORED) { || err == ALPM_ERR_PKG_IGNORED) {
/* just skip duplicate or ignored targets */ /* just skip duplicate or ignored targets */
pm_printf(PM_LOG_WARNING, _("skipping target: %s\n"), alpm_pkg_get_name(pkg)); pm_printf(ALPM_LOG_WARNING, _("skipping target: %s\n"), alpm_pkg_get_name(pkg));
return 0; return 0;
} else { } else {
pm_fprintf(stderr, PM_LOG_ERROR, "'%s': %s\n", alpm_pkg_get_name(pkg), pm_fprintf(stderr, ALPM_LOG_ERROR, "'%s': %s\n", alpm_pkg_get_name(pkg),
alpm_strerror(err)); alpm_strerror(err));
return 1; return 1;
} }
@ -638,7 +638,7 @@ static int process_group(alpm_list_t *dbs, char *group)
int count = alpm_list_count(pkgs); int count = alpm_list_count(pkgs);
if(!count) { if(!count) {
pm_fprintf(stderr, PM_LOG_ERROR, _("target not found: %s\n"), group); pm_fprintf(stderr, ALPM_LOG_ERROR, _("target not found: %s\n"), group);
return 1; return 1;
} }
@ -681,8 +681,8 @@ static int process_targname(alpm_list_t *dblist, char *targname)
alpm_pkg_t *pkg = alpm_find_dbs_satisfier(config->handle, dblist, targname); alpm_pkg_t *pkg = alpm_find_dbs_satisfier(config->handle, dblist, targname);
/* #FS#23342 - skip ignored packages when user says no */ /* #FS#23342 - skip ignored packages when user says no */
if(alpm_errno(config->handle) == PM_ERR_PKG_IGNORED) { if(alpm_errno(config->handle) == ALPM_ERR_PKG_IGNORED) {
pm_printf(PM_LOG_WARNING, _("skipping target: %s\n"), targname); pm_printf(ALPM_LOG_WARNING, _("skipping target: %s\n"), targname);
/* TODO how to do this, we shouldn't be fucking with it from the frontend */ /* TODO how to do this, we shouldn't be fucking with it from the frontend */
/* pm_errno = 0; */ /* pm_errno = 0; */
return 0; return 0;
@ -712,7 +712,7 @@ static int process_target(char *target)
dbname = targstring; dbname = targstring;
db = get_db(dbname); db = get_db(dbname);
if(!db) { if(!db) {
pm_fprintf(stderr, PM_LOG_ERROR, _("database not found: %s\n"), pm_fprintf(stderr, ALPM_LOG_ERROR, _("database not found: %s\n"),
dbname); dbname);
ret = 1; ret = 1;
goto cleanup; goto cleanup;
@ -755,7 +755,7 @@ static int sync_trans(alpm_list_t *targets)
printf(_(":: Starting full system upgrade...\n")); printf(_(":: Starting full system upgrade...\n"));
alpm_logaction(config->handle, "starting full system upgrade\n"); alpm_logaction(config->handle, "starting full system upgrade\n");
if(alpm_sync_sysupgrade(config->handle, config->op_s_upgrade >= 2) == -1) { if(alpm_sync_sysupgrade(config->handle, config->op_s_upgrade >= 2) == -1) {
pm_fprintf(stderr, PM_LOG_ERROR, "%s\n", alpm_strerror(alpm_errno(config->handle))); pm_fprintf(stderr, ALPM_LOG_ERROR, "%s\n", alpm_strerror(alpm_errno(config->handle)));
retval = 1; retval = 1;
goto cleanup; goto cleanup;
} }
@ -764,16 +764,16 @@ static int sync_trans(alpm_list_t *targets)
/* Step 2: "compute" the transaction based on targets and flags */ /* Step 2: "compute" the transaction based on targets and flags */
if(alpm_trans_prepare(config->handle, &data) == -1) { if(alpm_trans_prepare(config->handle, &data) == -1) {
enum _alpm_errno_t err = alpm_errno(config->handle); enum _alpm_errno_t err = alpm_errno(config->handle);
pm_fprintf(stderr, PM_LOG_ERROR, _("failed to prepare transaction (%s)\n"), pm_fprintf(stderr, ALPM_LOG_ERROR, _("failed to prepare transaction (%s)\n"),
alpm_strerror(err)); alpm_strerror(err));
switch(err) { switch(err) {
case PM_ERR_PKG_INVALID_ARCH: case ALPM_ERR_PKG_INVALID_ARCH:
for(i = data; i; i = alpm_list_next(i)) { for(i = data; i; i = alpm_list_next(i)) {
char *pkg = alpm_list_getdata(i); char *pkg = alpm_list_getdata(i);
printf(_(":: package %s does not have a valid architecture\n"), pkg); printf(_(":: package %s does not have a valid architecture\n"), pkg);
} }
break; break;
case PM_ERR_UNSATISFIED_DEPS: case ALPM_ERR_UNSATISFIED_DEPS:
for(i = data; i; i = alpm_list_next(i)) { for(i = data; i; i = alpm_list_next(i)) {
alpm_depmissing_t *miss = alpm_list_getdata(i); alpm_depmissing_t *miss = alpm_list_getdata(i);
char *depstring = alpm_dep_compute_string(miss->depend); char *depstring = alpm_dep_compute_string(miss->depend);
@ -781,7 +781,7 @@ static int sync_trans(alpm_list_t *targets)
free(depstring); free(depstring);
} }
break; break;
case PM_ERR_CONFLICTING_DEPS: case ALPM_ERR_CONFLICTING_DEPS:
for(i = data; i; i = alpm_list_next(i)) { for(i = data; i; i = alpm_list_next(i)) {
alpm_conflict_t *conflict = alpm_list_getdata(i); alpm_conflict_t *conflict = alpm_list_getdata(i);
/* only print reason if it contains new information */ /* only print reason if it contains new information */
@ -831,26 +831,26 @@ static int sync_trans(alpm_list_t *targets)
if(alpm_trans_commit(config->handle, &data) == -1) { if(alpm_trans_commit(config->handle, &data) == -1) {
enum _alpm_errno_t err = alpm_errno(config->handle); enum _alpm_errno_t err = alpm_errno(config->handle);
pm_fprintf(stderr, PM_LOG_ERROR, _("failed to commit transaction (%s)\n"), pm_fprintf(stderr, ALPM_LOG_ERROR, _("failed to commit transaction (%s)\n"),
alpm_strerror(err)); alpm_strerror(err));
switch(err) { switch(err) {
case PM_ERR_FILE_CONFLICTS: case ALPM_ERR_FILE_CONFLICTS:
for(i = data; i; i = alpm_list_next(i)) { for(i = data; i; i = alpm_list_next(i)) {
alpm_fileconflict_t *conflict = alpm_list_getdata(i); alpm_fileconflict_t *conflict = alpm_list_getdata(i);
switch(conflict->type) { switch(conflict->type) {
case PM_FILECONFLICT_TARGET: case ALPM_FILECONFLICT_TARGET:
printf(_("%s exists in both '%s' and '%s'\n"), printf(_("%s exists in both '%s' and '%s'\n"),
conflict->file, conflict->target, conflict->ctarget); conflict->file, conflict->target, conflict->ctarget);
break; break;
case PM_FILECONFLICT_FILESYSTEM: case ALPM_FILECONFLICT_FILESYSTEM:
printf(_("%s: %s exists in filesystem\n"), printf(_("%s: %s exists in filesystem\n"),
conflict->target, conflict->file); conflict->target, conflict->file);
break; break;
} }
} }
break; break;
case PM_ERR_PKG_INVALID: case ALPM_ERR_PKG_INVALID:
case PM_ERR_DLT_INVALID: case ALPM_ERR_DLT_INVALID:
for(i = data; i; i = alpm_list_next(i)) { for(i = data; i; i = alpm_list_next(i)) {
char *filename = alpm_list_getdata(i); char *filename = alpm_list_getdata(i);
printf(_("%s is invalid or corrupted\n"), filename); printf(_("%s is invalid or corrupted\n"), filename);
@ -903,7 +903,7 @@ int pacman_sync(alpm_list_t *targets)
/* ensure we have at least one valid sync db set up */ /* ensure we have at least one valid sync db set up */
sync_dbs = alpm_option_get_syncdbs(config->handle); sync_dbs = alpm_option_get_syncdbs(config->handle);
if(sync_dbs == NULL) { if(sync_dbs == NULL) {
pm_printf(PM_LOG_ERROR, _("no usable package repositories configured.\n")); pm_printf(ALPM_LOG_ERROR, _("no usable package repositories configured.\n"));
return 1; return 1;
} }
@ -944,13 +944,13 @@ int pacman_sync(alpm_list_t *targets)
} else { } else {
/* don't proceed here unless we have an operation that doesn't require a /* don't proceed here unless we have an operation that doesn't require a
* target list */ * target list */
pm_printf(PM_LOG_ERROR, _("no targets specified (use -h for help)\n")); pm_printf(ALPM_LOG_ERROR, _("no targets specified (use -h for help)\n"));
return 1; return 1;
} }
} }
alpm_list_t *targs = alpm_list_strdup(targets); alpm_list_t *targs = alpm_list_strdup(targets);
if(!(config->flags & PM_TRANS_FLAG_DOWNLOADONLY) && !config->print) { if(!(config->flags & ALPM_TRANS_FLAG_DOWNLOADONLY) && !config->print) {
/* check for newer versions of packages to be upgraded first */ /* check for newer versions of packages to be upgraded first */
alpm_list_t *packages = syncfirst(); alpm_list_t *packages = syncfirst();
if(packages) { if(packages) {
@ -971,7 +971,7 @@ int pacman_sync(alpm_list_t *targets)
} }
printf("\n"); printf("\n");
} else { } else {
pm_printf(PM_LOG_DEBUG, "skipping SyncFirst dialog\n"); pm_printf(ALPM_LOG_DEBUG, "skipping SyncFirst dialog\n");
FREELIST(packages); FREELIST(packages);
} }
} }

View File

@ -46,7 +46,7 @@ int pacman_upgrade(alpm_list_t *targets)
int retval = 0; int retval = 0;
if(targets == NULL) { if(targets == NULL) {
pm_printf(PM_LOG_ERROR, _("no targets specified (use -h for help)\n")); pm_printf(ALPM_LOG_ERROR, _("no targets specified (use -h for help)\n"));
return 1; return 1;
} }
@ -56,7 +56,7 @@ int pacman_upgrade(alpm_list_t *targets)
if(strstr(i->data, "://")) { if(strstr(i->data, "://")) {
char *str = alpm_fetch_pkgurl(config->handle, i->data); char *str = alpm_fetch_pkgurl(config->handle, i->data);
if(str == NULL) { if(str == NULL) {
pm_fprintf(stderr, PM_LOG_ERROR, "'%s': %s\n", pm_fprintf(stderr, ALPM_LOG_ERROR, "'%s': %s\n",
(char *)i->data, alpm_strerror(alpm_errno(config->handle))); (char *)i->data, alpm_strerror(alpm_errno(config->handle)));
return 1; return 1;
} else { } else {
@ -77,13 +77,13 @@ int pacman_upgrade(alpm_list_t *targets)
alpm_pkg_t *pkg; alpm_pkg_t *pkg;
if(alpm_pkg_load(config->handle, targ, 1, check_sig, &pkg) != 0) { if(alpm_pkg_load(config->handle, targ, 1, check_sig, &pkg) != 0) {
pm_fprintf(stderr, PM_LOG_ERROR, "'%s': %s\n", pm_fprintf(stderr, ALPM_LOG_ERROR, "'%s': %s\n",
targ, alpm_strerror(alpm_errno(config->handle))); targ, alpm_strerror(alpm_errno(config->handle)));
trans_release(); trans_release();
return 1; return 1;
} }
if(alpm_add_pkg(config->handle, pkg) == -1) { if(alpm_add_pkg(config->handle, pkg) == -1) {
pm_fprintf(stderr, PM_LOG_ERROR, "'%s': %s\n", pm_fprintf(stderr, ALPM_LOG_ERROR, "'%s': %s\n",
targ, alpm_strerror(alpm_errno(config->handle))); targ, alpm_strerror(alpm_errno(config->handle)));
alpm_pkg_free(pkg); alpm_pkg_free(pkg);
trans_release(); trans_release();
@ -95,16 +95,16 @@ int pacman_upgrade(alpm_list_t *targets)
/* TODO: No, compute nothing. This is stupid. */ /* TODO: No, compute nothing. This is stupid. */
if(alpm_trans_prepare(config->handle, &data) == -1) { if(alpm_trans_prepare(config->handle, &data) == -1) {
enum _alpm_errno_t err = alpm_errno(config->handle); enum _alpm_errno_t err = alpm_errno(config->handle);
pm_fprintf(stderr, PM_LOG_ERROR, _("failed to prepare transaction (%s)\n"), pm_fprintf(stderr, ALPM_LOG_ERROR, _("failed to prepare transaction (%s)\n"),
alpm_strerror(err)); alpm_strerror(err));
switch(err) { switch(err) {
case PM_ERR_PKG_INVALID_ARCH: case ALPM_ERR_PKG_INVALID_ARCH:
for(i = data; i; i = alpm_list_next(i)) { for(i = data; i; i = alpm_list_next(i)) {
char *pkg = alpm_list_getdata(i); char *pkg = alpm_list_getdata(i);
printf(_(":: package %s does not have a valid architecture\n"), pkg); printf(_(":: package %s does not have a valid architecture\n"), pkg);
} }
break; break;
case PM_ERR_UNSATISFIED_DEPS: case ALPM_ERR_UNSATISFIED_DEPS:
for(i = data; i; i = alpm_list_next(i)) { for(i = data; i; i = alpm_list_next(i)) {
alpm_depmissing_t *miss = alpm_list_getdata(i); alpm_depmissing_t *miss = alpm_list_getdata(i);
char *depstring = alpm_dep_compute_string(miss->depend); char *depstring = alpm_dep_compute_string(miss->depend);
@ -116,7 +116,7 @@ int pacman_upgrade(alpm_list_t *targets)
free(depstring); free(depstring);
} }
break; break;
case PM_ERR_CONFLICTING_DEPS: case ALPM_ERR_CONFLICTING_DEPS:
for(i = data; i; i = alpm_list_next(i)) { for(i = data; i; i = alpm_list_next(i)) {
alpm_conflict_t *conflict = alpm_list_getdata(i); alpm_conflict_t *conflict = alpm_list_getdata(i);
if(strcmp(conflict->package1, conflict->reason) == 0 || if(strcmp(conflict->package1, conflict->reason) == 0 ||
@ -163,26 +163,26 @@ int pacman_upgrade(alpm_list_t *targets)
if(alpm_trans_commit(config->handle, &data) == -1) { if(alpm_trans_commit(config->handle, &data) == -1) {
enum _alpm_errno_t err = alpm_errno(config->handle); enum _alpm_errno_t err = alpm_errno(config->handle);
pm_fprintf(stderr, PM_LOG_ERROR, _("failed to commit transaction (%s)\n"), pm_fprintf(stderr, ALPM_LOG_ERROR, _("failed to commit transaction (%s)\n"),
alpm_strerror(err)); alpm_strerror(err));
switch(err) { switch(err) {
case PM_ERR_FILE_CONFLICTS: case ALPM_ERR_FILE_CONFLICTS:
for(i = data; i; i = alpm_list_next(i)) { for(i = data; i; i = alpm_list_next(i)) {
alpm_fileconflict_t *conflict = alpm_list_getdata(i); alpm_fileconflict_t *conflict = alpm_list_getdata(i);
switch(conflict->type) { switch(conflict->type) {
case PM_FILECONFLICT_TARGET: case ALPM_FILECONFLICT_TARGET:
printf(_("%s exists in both '%s' and '%s'\n"), printf(_("%s exists in both '%s' and '%s'\n"),
conflict->file, conflict->target, conflict->ctarget); conflict->file, conflict->target, conflict->ctarget);
break; break;
case PM_FILECONFLICT_FILESYSTEM: case ALPM_FILECONFLICT_FILESYSTEM:
printf(_("%s: %s exists in filesystem\n"), printf(_("%s: %s exists in filesystem\n"),
conflict->target, conflict->file); conflict->target, conflict->file);
break; break;
} }
} }
break; break;
case PM_ERR_PKG_INVALID: case ALPM_ERR_PKG_INVALID:
case PM_ERR_DLT_INVALID: case ALPM_ERR_DLT_INVALID:
for(i = data; i; i = alpm_list_next(i)) { for(i = data; i; i = alpm_list_next(i)) {
char *filename = alpm_list_getdata(i); char *filename = alpm_list_getdata(i);
printf(_("%s is invalid or corrupted\n"), filename); printf(_("%s is invalid or corrupted\n"), filename);

View File

@ -61,9 +61,9 @@ int trans_init(alpm_transflag_t flags)
if(ret == -1) { if(ret == -1) {
enum _alpm_errno_t err = alpm_errno(config->handle); enum _alpm_errno_t err = alpm_errno(config->handle);
pm_fprintf(stderr, PM_LOG_ERROR, _("failed to init transaction (%s)\n"), pm_fprintf(stderr, ALPM_LOG_ERROR, _("failed to init transaction (%s)\n"),
alpm_strerror(err)); alpm_strerror(err));
if(err == PM_ERR_HANDLE_LOCK) { if(err == ALPM_ERR_HANDLE_LOCK) {
fprintf(stderr, _(" if you're sure a package manager is not already\n" fprintf(stderr, _(" if you're sure a package manager is not already\n"
" running, you can remove %s\n"), " running, you can remove %s\n"),
alpm_option_get_lockfile(config->handle)); alpm_option_get_lockfile(config->handle));
@ -77,7 +77,7 @@ int trans_init(alpm_transflag_t flags)
int trans_release(void) int trans_release(void)
{ {
if(alpm_trans_release(config->handle) == -1) { if(alpm_trans_release(config->handle) == -1) {
pm_fprintf(stderr, PM_LOG_ERROR, _("failed to release transaction (%s)\n"), pm_fprintf(stderr, ALPM_LOG_ERROR, _("failed to release transaction (%s)\n"),
alpm_strerror(alpm_errno(config->handle))); alpm_strerror(alpm_errno(config->handle)));
return -1; return -1;
} }
@ -749,7 +749,7 @@ void display_targets(const alpm_list_t *pkgs, int install)
if(install) { if(install) {
size = humanize_size(dlsize, 'M', 1, &label); size = humanize_size(dlsize, 'M', 1, &label);
printf(_("Total Download Size: %.2f %s\n"), size, label); printf(_("Total Download Size: %.2f %s\n"), size, label);
if(!(config->flags & PM_TRANS_FLAG_DOWNLOADONLY)) { if(!(config->flags & ALPM_TRANS_FLAG_DOWNLOADONLY)) {
size = humanize_size(isize, 'M', 1, &label); size = humanize_size(isize, 'M', 1, &label);
printf(_("Total Installed Size: %.2f %s\n"), size, label); printf(_("Total Installed Size: %.2f %s\n"), size, label);
/* only show this net value if different from raw installed size */ /* only show this net value if different from raw installed size */
@ -1228,7 +1228,7 @@ int pm_asprintf(char **string, const char *format, ...)
/* print the message using va_arg list */ /* print the message using va_arg list */
va_start(args, format); va_start(args, format);
if(vasprintf(string, format, args) == -1) { if(vasprintf(string, format, args) == -1) {
pm_fprintf(stderr, PM_LOG_ERROR, _("failed to allocate string\n")); pm_fprintf(stderr, ALPM_LOG_ERROR, _("failed to allocate string\n"));
ret = -1; ret = -1;
} }
va_end(args); va_end(args);
@ -1251,16 +1251,16 @@ int pm_vasprintf(char **string, alpm_loglevel_t level, const char *format, va_li
/* print a prefix to the message */ /* print a prefix to the message */
switch(level) { switch(level) {
case PM_LOG_ERROR: case ALPM_LOG_ERROR:
pm_asprintf(string, _("error: %s"), msg); pm_asprintf(string, _("error: %s"), msg);
break; break;
case PM_LOG_WARNING: case ALPM_LOG_WARNING:
pm_asprintf(string, _("warning: %s"), msg); pm_asprintf(string, _("warning: %s"), msg);
break; break;
case PM_LOG_DEBUG: case ALPM_LOG_DEBUG:
pm_asprintf(string, "debug: %s", msg); pm_asprintf(string, "debug: %s", msg);
break; break;
case PM_LOG_FUNCTION: case ALPM_LOG_FUNCTION:
pm_asprintf(string, "function: %s", msg); pm_asprintf(string, "function: %s", msg);
break; break;
default: default:
@ -1283,7 +1283,7 @@ int pm_vfprintf(FILE *stream, alpm_loglevel_t level, const char *format, va_list
#if defined(PACMAN_DEBUG) #if defined(PACMAN_DEBUG)
/* If debug is on, we'll timestamp the output */ /* If debug is on, we'll timestamp the output */
if(config->logmask & PM_LOG_DEBUG) { if(config->logmask & ALPM_LOG_DEBUG) {
time_t t; time_t t;
struct tm *tmp; struct tm *tmp;
char timestr[10] = {0}; char timestr[10] = {0};
@ -1299,16 +1299,16 @@ int pm_vfprintf(FILE *stream, alpm_loglevel_t level, const char *format, va_list
/* print a prefix to the message */ /* print a prefix to the message */
switch(level) { switch(level) {
case PM_LOG_ERROR: case ALPM_LOG_ERROR:
fprintf(stream, _("error: ")); fprintf(stream, _("error: "));
break; break;
case PM_LOG_WARNING: case ALPM_LOG_WARNING:
fprintf(stream, _("warning: ")); fprintf(stream, _("warning: "));
break; break;
case PM_LOG_DEBUG: case ALPM_LOG_DEBUG:
fprintf(stream, "debug: "); fprintf(stream, "debug: ");
break; break;
case PM_LOG_FUNCTION: case ALPM_LOG_FUNCTION:
fprintf(stream, "function: "); fprintf(stream, "function: ");
break; break;
default: default:

View File

@ -43,9 +43,9 @@ static void output_cb(alpm_loglevel_t level, const char *fmt, va_list args)
{ {
if(strlen(fmt)) { if(strlen(fmt)) {
switch(level) { switch(level) {
case PM_LOG_ERROR: printf("error: "); break; case ALPM_LOG_ERROR: printf("error: "); break;
case PM_LOG_WARNING: printf("warning: "); break; case ALPM_LOG_WARNING: printf("warning: "); break;
//case PM_LOG_DEBUG: printf("debug: "); break; //case ALPM_LOG_DEBUG: printf("debug: "); break;
default: return; default: return;
} }
vprintf(fmt, args); vprintf(fmt, args);

View File

@ -45,8 +45,8 @@ static void output_cb(alpm_loglevel_t level, const char *fmt, va_list args)
{ {
if(strlen(fmt)) { if(strlen(fmt)) {
switch(level) { switch(level) {
case PM_LOG_ERROR: printf("error: "); break; case ALPM_LOG_ERROR: printf("error: "); break;
case PM_LOG_WARNING: printf("warning: "); break; case ALPM_LOG_WARNING: printf("warning: "); break;
default: return; default: return;
} }
vprintf(fmt, args); vprintf(fmt, args);

View File

@ -30,8 +30,8 @@ static void output_cb(alpm_loglevel_t level, const char *fmt, va_list args)
return; return;
} }
switch(level) { switch(level) {
case PM_LOG_ERROR: printf("error: "); break; case ALPM_LOG_ERROR: printf("error: "); break;
case PM_LOG_WARNING: printf("warning: "); break; case ALPM_LOG_WARNING: printf("warning: "); break;
default: return; /* skip other messages */ default: return; /* skip other messages */
} }
vprintf(fmt, args); vprintf(fmt, args);
@ -62,11 +62,11 @@ int main(int argc, char *argv[])
|| pkg == NULL) { || pkg == NULL) {
err = alpm_errno(handle); err = alpm_errno(handle);
switch(err) { switch(err) {
case PM_ERR_PKG_OPEN: case ALPM_ERR_PKG_OPEN:
printf("Cannot open the given file.\n"); printf("Cannot open the given file.\n");
break; break;
case PM_ERR_LIBARCHIVE: case ALPM_ERR_LIBARCHIVE:
case PM_ERR_PKG_INVALID: case ALPM_ERR_PKG_INVALID:
printf("Package is invalid.\n"); printf("Package is invalid.\n");
break; break;
default: default: