goto error;
}
while(!feof(fp)) {
- if(fgets(line, sizeof(line), fp) == NULL) {
- break;
- }
- _alpm_strtrim(line);
+ READ_NEXT();
if(strcmp(line, "%NAME%") == 0) {
- if(fgets(line, sizeof(line), fp) == NULL) {
- goto error;
- }
- if(strcmp(_alpm_strtrim(line), info->name) != 0) {
+ READ_NEXT();
+ 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);
}
} else if(strcmp(line, "%VERSION%") == 0) {
- if(fgets(line, sizeof(line), fp) == NULL) {
- goto error;
- }
- if(strcmp(_alpm_strtrim(line), info->version) != 0) {
+ READ_NEXT();
+ 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);
}
} else if(strcmp(line, "%DESC%") == 0) {
if(full) {
/* "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, _alpm_str_cmp);
+ newpkg->files = alpm_list_msort(newpkg->files, files_count,
+ _alpm_files_cmp);
newpkg->infolevel = INFRQ_ALL;
} else {
/* get rid of any partial filelist we may have collected, it is invalid */
char *line = _alpm_strtrim(buf.line);
if(strcmp(line, "%NAME%") == 0) {
- READ_NEXT(line);
+ READ_NEXT();
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);
}
} else if(strcmp(line, "%VERSION%") == 0) {
- READ_NEXT(line);
+ READ_NEXT();
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);
}
} else if(strcmp(line, "%FILENAME%") == 0) {
* here as we do when we actually extract files in add.c with our 12
* different cases. */
for(current = 0, i = upgrade; i; i = i->next, current++) {
- alpm_list_t *k, *tmpfiles;
- alpm_pkg_t *p1, *p2, *dbpkg;
- char path[PATH_MAX];
-
- p1 = i->data;
- if(!p1) {
- continue;
- }
+ alpm_pkg_t *p1 = i->data;
+ alpm_list_t *j, *tmpfiles;
+ alpm_pkg_t *dbpkg;
int percent = (current * 100) / numtargs;
- PROGRESS(trans, PM_TRANS_PROGRESS_CONFLICTS_START, "", percent,
+ PROGRESS(trans, ALPM_TRANS_PROGRESS_CONFLICTS_START, "", percent,
numtargs, current);
/* 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));
for(j = i->next; j; j = j->next) {
alpm_list_t *common_files;
continue;
}
- if(path[strlen(path) - 1] == '/') {
+ if(S_ISDIR(file->mode)) {
struct stat sbuf;
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;
}
stat(path, &sbuf);
/* Check remove list (will we remove the conflicting local file?) */
for(k = remove; k && !resolved_conflict; k = k->next) {
alpm_pkg_t *rempkg = k->data;
- if(alpm_list_find_str(alpm_pkg_get_files(rempkg), relative_path)) {
+ if(rempkg && _alpm_filelist_contains(alpm_pkg_get_files(rempkg),
+ relative_path)) {
- _alpm_log(handle, PM_LOG_DEBUG,
+ _alpm_log(handle, ALPM_LOG_DEBUG,
- "local file will be removed, not a conflict: %s\n",
- relative_path);
+ "local file will be removed, not a conflict: %s\n", path);
resolved_conflict = 1;
}
}
* by its new owner (whether the file is in backup array or not */
handle->trans->skip_remove =
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",
- filestr);
+ "file changed packages, adding to remove skiplist: %s\n", path);
resolved_conflict = 1;
}
}
if(!resolved_conflict && S_ISDIR(lsbuf.st_mode) && dbpkg) {
char *dir = malloc(strlen(filestr) + 2);
sprintf(dir, "%s/", filestr);
- if(alpm_list_find_str(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",
dir, dbpkg->name);
resolved_conflict = dir_belongsto_pkg(handle->root, filestr, dbpkg);
}
if(dbpkg) {
/* only freed if it was generated from filelist_operation() */
- FREELIST(tmpfiles);
+ alpm_list_free(tmpfiles);
}
}
- PROGRESS(trans, PM_TRANS_PROGRESS_CONFLICTS_START, "", 100,
+ PROGRESS(trans, ALPM_TRANS_PROGRESS_CONFLICTS_START, "", 100,
numtargs, current);
return conflicts;
/* a previous partial download exists, resume from end of file. */
open_mode = "ab";
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");
++ _alpm_log(handle, ALPM_LOG_DEBUG, "tempfile found, attempting continuation\n");
dlfile.initial_size = (double)st.st_size;
}
}
/* If we fail write permissions due to a read-only filesystem, abort.
* Assume all other possible failures are covered somewhere else */
- if(access(file, W_OK) == -1) {
- if(errno != EACCES && errno != ETXTBSY && access(file, F_OK) == 0) {
+ if(access(filepath, W_OK) == -1) {
+ if(errno != EACCES && errno != ETXTBSY && access(filepath, F_OK) == 0) {
/* only return failure if the file ACTUALLY exists and we can't write to
* 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"),
- file, strerror(errno));
+ filepath, strerror(errno));
return 0;
}
}
/* check the remove skip list before removing the file.
* see the big comment block in db_find_fileconflicts() for an
* explanation. */
- if(alpm_list_find_str(skip_remove, filename)) {
+ 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);
return;
}
}
} else {
/* if the file needs backup and has been modified, back it up to .pacsave */
- alpm_backup_t *backup = _alpm_needbackup(filename, alpm_pkg_get_backup(info));
+ alpm_backup_t *backup = _alpm_needbackup(fileobj->name, alpm_pkg_get_backup(info));
if(backup) {
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 {
char *filehash = alpm_compute_md5sum(file);
int cmp = filehash ? strcmp(filehash, backup->hash) : 0;
}
}
- _alpm_log(handle, PM_LOG_DEBUG, "unlinking %s\n", file);
+ _alpm_log(handle, ALPM_LOG_DEBUG, "unlinking %s\n", file);
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"),
- filename, strerror(errno));
+ file, strerror(errno));
}
}
}
for(b = alpm_pkg_get_backup(newpkg); b; b = b->next) {
const alpm_backup_t *backup = b->data;
/* safety check (fix the upgrade026 pactest) */
- if(!alpm_list_find_str(filelist, backup->name)) {
+ if(!_alpm_filelist_contains(filelist, backup->name)) {
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);
skip_remove = alpm_list_add(skip_remove, strdup(backup->name));
}
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 */
- newfiles = alpm_list_reverse(files);
- for(lp = newfiles; lp; lp = alpm_list_next(lp)) {
+ for(lp = alpm_list_last(files); lp; lp = alpm_list_previous(files, lp)) {
unlink_file(handle, oldpkg, lp->data, skip_remove, 0);
}
- alpm_list_free(newfiles);
FREELIST(skip_remove);
db:
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 *newfiles;
size_t filenum = 0;
for(lp = files; lp; lp = lp->next) {
pkg_count, (pkg_count - targcount + 1));
/* iterate through the list backwards, unlinking files */
- newfiles = alpm_list_reverse(files);
- for(lp = newfiles; lp; lp = alpm_list_next(lp)) {
+ for(lp = alpm_list_last(files); lp; lp = alpm_list_previous(files, lp)) {
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 */
percent = (position * 100) / filenum;
const char *pkgname = alpm_pkg_get_name(pkg);
for(i = alpm_pkg_get_files(pkg); i; i = alpm_list_next(i)) {
struct stat st;
- const char *path = alpm_list_getdata(i);
+ const alpm_file_t *file = alpm_list_getdata(i);
+ const char *path = file->name;
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;
}
strcpy(f + rootlen, path);