Skip to content

Commit

Permalink
lib: extend struct xbps_file to include a flag for conf files
Browse files Browse the repository at this point in the history
  • Loading branch information
Duncaen committed Jan 11, 2024
1 parent 70480d2 commit fbb7b52
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
9 changes: 9 additions & 0 deletions include/xbps_api_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,17 @@
#define __arraycount(x) (sizeof(x) / sizeof(*x))
#endif

enum xbps_file_flag {
XBPS_FILE_CONF = 1 << 0,
XBPS_FILE_ALTERNATIVE = 1 << 1,
};

struct xbps_file {
char *path;
uint64_t size;
enum xbps_file_flag flags;
char *sha256;
const char *target;
};

/**
Expand Down
20 changes: 11 additions & 9 deletions lib/transaction_files.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ struct item {
struct xbps_file file;
const char *pkgname;
const char *pkgver;
const char *target;
uint64_t size;
enum type type;
/* index is the index of the package update/install/removal in the transaction
* and is used to decide which package should remove the given file or dir */
Expand Down Expand Up @@ -358,16 +356,16 @@ collect_obsoletes(struct xbps_handle *xhp)
xhp->rootdir, item->file+1);
file = path;
}
lnk = xbps_symlink_target(xhp, file, item->old.target);
lnk = xbps_symlink_target(xhp, file, item->old.file.target);
if (lnk == NULL) {
xbps_dbg_printf("[obsoletes] %s "
"symlink_target: %s\n", item->file+1, strerror(errno));
continue;
}
if (strcmp(lnk, item->old.target) != 0) {
if (strcmp(lnk, item->old.file.target) != 0) {
xbps_dbg_printf("[obsoletes] %s: skipping modified"
" symlink (stored `%s' current `%s'): %s\n",
item->old.pkgname, item->old.target, lnk, item->file+1);
item->old.pkgname, item->old.file.target, lnk, item->file+1);
free(lnk);
continue;
}
Expand Down Expand Up @@ -520,32 +518,36 @@ collect_file(struct xbps_handle *xhp, const char *file, size_t size,
item->old.pkgname = pkgname;
item->old.pkgver = pkgver;
item->old.type = type;
item->old.size = size;
item->old.file.size = size;
item->old.index = idx;
item->old.preserve = preserve;
item->old.update = update;
item->old.removepkg = removepkg;
item->old.target = target;
item->old.file.target = target;
if (sha256) {
item->old.file.sha256 = strdup(sha256);
if (!item->old.file.sha256)
return errno;
}
if (type == TYPE_CONFFILE)
item->old.file.flags |= XBPS_FILE_CONF;
} else {
item->new.pkgname = pkgname;
item->new.pkgver = pkgver;
item->new.type = type;
item->new.size = size;
item->new.file.size = size;
item->new.index = idx;
item->new.preserve = preserve;
item->new.update = update;
item->new.removepkg = removepkg;
item->new.target = target;
item->new.file.target = target;
if (sha256) {
item->new.file.sha256 = strdup(sha256);
if (!item->new.file.sha256)
return errno;
}
if (type == TYPE_CONFFILE)
item->new.file.flags |= XBPS_FILE_CONF;
}
if (item->old.type && item->new.type) {
/*
Expand Down

0 comments on commit fbb7b52

Please sign in to comment.