Skip to content

Commit 2dedfd1

Browse files
committed
lib: extend struct xbps_file to include a flag for conf files
1 parent f231641 commit 2dedfd1

2 files changed

Lines changed: 20 additions & 9 deletions

File tree

include/xbps_api_impl.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,17 @@
5454

5555
struct archive_entry;
5656

57+
enum xbps_file_flag {
58+
XBPS_FILE_CONF = 1 << 0,
59+
XBPS_FILE_ALTERNATIVE = 1 << 1,
60+
};
61+
5762
struct xbps_file {
63+
char *path;
64+
uint64_t size;
65+
enum xbps_file_flag flags;
5866
char *sha256;
67+
const char *target;
5968
};
6069

6170
/**

lib/transaction_files.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ struct item {
5151
struct xbps_file file;
5252
const char *pkgname;
5353
const char *pkgver;
54-
const char *target;
55-
uint64_t size;
5654
enum type type;
5755
/* index is the index of the package update/install/removal in the transaction
5856
* and is used to decide which package should remove the given file or dir */
@@ -361,16 +359,16 @@ collect_obsoletes(struct xbps_handle *xhp)
361359
xhp->rootdir, item->file+1);
362360
file = path;
363361
}
364-
lnk = xbps_symlink_target(xhp, file, item->old.target);
362+
lnk = xbps_symlink_target(xhp, file, item->old.file.target);
365363
if (lnk == NULL) {
366364
xbps_dbg_printf("[obsoletes] %s "
367365
"symlink_target: %s\n", item->file+1, strerror(errno));
368366
continue;
369367
}
370-
if (strcmp(lnk, item->old.target) != 0) {
368+
if (strcmp(lnk, item->old.file.target) != 0) {
371369
xbps_dbg_printf("[obsoletes] %s: skipping modified"
372370
" symlink (stored `%s' current `%s'): %s\n",
373-
item->old.pkgname, item->old.target, lnk, item->file+1);
371+
item->old.pkgname, item->old.file.target, lnk, item->file+1);
374372
free(lnk);
375373
continue;
376374
}
@@ -523,32 +521,36 @@ collect_file(struct xbps_handle *xhp, const char *file, size_t size,
523521
item->old.pkgname = pkgname;
524522
item->old.pkgver = pkgver;
525523
item->old.type = type;
526-
item->old.size = size;
524+
item->old.file.size = size;
527525
item->old.index = idx;
528526
item->old.preserve = preserve;
529527
item->old.update = update;
530528
item->old.removepkg = removepkg;
531-
item->old.target = target;
529+
item->old.file.target = target;
532530
if (sha256) {
533531
item->old.file.sha256 = strdup(sha256);
534532
if (!item->old.file.sha256)
535533
return errno;
536534
}
535+
if (type == TYPE_CONFFILE)
536+
item->old.file.flags |= XBPS_FILE_CONF;
537537
} else {
538538
item->new.pkgname = pkgname;
539539
item->new.pkgver = pkgver;
540540
item->new.type = type;
541-
item->new.size = size;
541+
item->new.file.size = size;
542542
item->new.index = idx;
543543
item->new.preserve = preserve;
544544
item->new.update = update;
545545
item->new.removepkg = removepkg;
546-
item->new.target = target;
546+
item->new.file.target = target;
547547
if (sha256) {
548548
item->new.file.sha256 = strdup(sha256);
549549
if (!item->new.file.sha256)
550550
return errno;
551551
}
552+
if (type == TYPE_CONFFILE)
553+
item->new.file.flags |= XBPS_FILE_CONF;
552554
}
553555
if (item->old.type && item->new.type) {
554556
/*

0 commit comments

Comments
 (0)