Skip to content

Commit fbb7b52

Browse files
committed
lib: extend struct xbps_file to include a flag for conf files
1 parent 70480d2 commit fbb7b52

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

include/xbps_api_impl.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,17 @@
5959
#define __arraycount(x) (sizeof(x) / sizeof(*x))
6060
#endif
6161

62+
enum xbps_file_flag {
63+
XBPS_FILE_CONF = 1 << 0,
64+
XBPS_FILE_ALTERNATIVE = 1 << 1,
65+
};
66+
6267
struct xbps_file {
68+
char *path;
69+
uint64_t size;
70+
enum xbps_file_flag flags;
6371
char *sha256;
72+
const char *target;
6473
};
6574

6675
/**

lib/transaction_files.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ struct item {
4848
struct xbps_file file;
4949
const char *pkgname;
5050
const char *pkgver;
51-
const char *target;
52-
uint64_t size;
5351
enum type type;
5452
/* index is the index of the package update/install/removal in the transaction
5553
* and is used to decide which package should remove the given file or dir */
@@ -358,16 +356,16 @@ collect_obsoletes(struct xbps_handle *xhp)
358356
xhp->rootdir, item->file+1);
359357
file = path;
360358
}
361-
lnk = xbps_symlink_target(xhp, file, item->old.target);
359+
lnk = xbps_symlink_target(xhp, file, item->old.file.target);
362360
if (lnk == NULL) {
363361
xbps_dbg_printf("[obsoletes] %s "
364362
"symlink_target: %s\n", item->file+1, strerror(errno));
365363
continue;
366364
}
367-
if (strcmp(lnk, item->old.target) != 0) {
365+
if (strcmp(lnk, item->old.file.target) != 0) {
368366
xbps_dbg_printf("[obsoletes] %s: skipping modified"
369367
" symlink (stored `%s' current `%s'): %s\n",
370-
item->old.pkgname, item->old.target, lnk, item->file+1);
368+
item->old.pkgname, item->old.file.target, lnk, item->file+1);
371369
free(lnk);
372370
continue;
373371
}
@@ -520,32 +518,36 @@ collect_file(struct xbps_handle *xhp, const char *file, size_t size,
520518
item->old.pkgname = pkgname;
521519
item->old.pkgver = pkgver;
522520
item->old.type = type;
523-
item->old.size = size;
521+
item->old.file.size = size;
524522
item->old.index = idx;
525523
item->old.preserve = preserve;
526524
item->old.update = update;
527525
item->old.removepkg = removepkg;
528-
item->old.target = target;
526+
item->old.file.target = target;
529527
if (sha256) {
530528
item->old.file.sha256 = strdup(sha256);
531529
if (!item->old.file.sha256)
532530
return errno;
533531
}
532+
if (type == TYPE_CONFFILE)
533+
item->old.file.flags |= XBPS_FILE_CONF;
534534
} else {
535535
item->new.pkgname = pkgname;
536536
item->new.pkgver = pkgver;
537537
item->new.type = type;
538-
item->new.size = size;
538+
item->new.file.size = size;
539539
item->new.index = idx;
540540
item->new.preserve = preserve;
541541
item->new.update = update;
542542
item->new.removepkg = removepkg;
543-
item->new.target = target;
543+
item->new.file.target = target;
544544
if (sha256) {
545545
item->new.file.sha256 = strdup(sha256);
546546
if (!item->new.file.sha256)
547547
return errno;
548548
}
549+
if (type == TYPE_CONFFILE)
550+
item->new.file.flags |= XBPS_FILE_CONF;
549551
}
550552
if (item->old.type && item->new.type) {
551553
/*

0 commit comments

Comments
 (0)