Skip to content

Commit 97e2b77

Browse files
committed
lib: add xbps flag to enable using staged remote repositories
1 parent f07d967 commit 97e2b77

File tree

5 files changed

+30
-4
lines changed

5 files changed

+30
-4
lines changed

data/xbps.d.5

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ example:
121121
.El
122122
.It Sy rootdir=path
123123
Sets the default root directory.
124+
.It Sy staged=true|false
125+
Enables or disables the use of staged packages in remote repositories.
124126
.It Sy syslog=true|false
125127
Enables or disables syslog logging. Enabled by default.
126128
.It Sy virtualpkg=[vpkgname|vpkgver]:pkgname

include/xbps.h.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,13 @@
244244
*/
245245
#define XBPS_FLAG_KEEP_CONFIG 0x00010000
246246

247+
/**
248+
* @def XBPS_FLAG_USE_STAGE
249+
* Use the staging repository if available.
250+
* Must be set through the xbps_handle::flags member.
251+
*/
252+
#define XBPS_FLAG_USE_STAGE 0x00020000
253+
247254
/**
248255
* @def XBPS_FETCH_CACHECONN
249256
* Default (global) limit of cached connections used in libfetch.

lib/conf.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ enum {
210210
KEY_PRESERVE,
211211
KEY_REPOSITORY,
212212
KEY_ROOTDIR,
213+
KEY_STAGING,
213214
KEY_SYSLOG,
214215
KEY_VIRTUALPKG,
215216
KEY_KEEPCONF,
@@ -230,6 +231,7 @@ static const struct key {
230231
{ "preserve", 8, KEY_PRESERVE },
231232
{ "repository", 10, KEY_REPOSITORY },
232233
{ "rootdir", 7, KEY_ROOTDIR },
234+
{ "staging", 7, KEY_STAGING },
233235
{ "syslog", 6, KEY_SYSLOG },
234236
{ "virtualpkg", 10, KEY_VIRTUALPKG },
235237
};
@@ -390,6 +392,15 @@ parse_file(struct xbps_handle *xhp, const char *path, bool nested)
390392
xbps_dbg_printf("%s: native architecture set to %s\n", path,
391393
val);
392394
break;
395+
case KEY_STAGING:
396+
if (strcasecmp(val, "true") == 0) {
397+
xhp->flags |= XBPS_FLAG_USE_STAGE;
398+
xbps_dbg_printf("%s: repository stage enabled\n", path);
399+
} else {
400+
xhp->flags &= ~XBPS_FLAG_USE_STAGE;
401+
xbps_dbg_printf("%s: repository stage disabled\n", path);
402+
}
403+
break;
393404
case KEY_SYSLOG:
394405
if (strcasecmp(val, "true") == 0) {
395406
xhp->flags &= ~XBPS_FLAG_DISABLE_SYSLOG;

lib/initend.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,14 @@ xbps_init(struct xbps_handle *xhp)
164164
xhp->flags |= XBPS_FLAG_DISABLE_SYSLOG;
165165
}
166166

167+
p = getenv("XBPS_STAGING");
168+
if (p) {
169+
if (strcasecmp(p, "true") == 0)
170+
xhp->flags &= ~XBPS_FLAG_USE_STAGE;
171+
else if (strcasecmp(p, "false") == 0)
172+
xhp->flags |= XBPS_FLAG_USE_STAGE;
173+
}
174+
167175
if (xhp->flags & XBPS_FLAG_DEBUG) {
168176
const char *repodir;
169177
for (unsigned int i = 0; i < xbps_array_count(xhp->repositories); i++) {

lib/repo.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -508,15 +508,13 @@ xbps_repo_open(struct xbps_handle *xhp, const char *url)
508508
return NULL;
509509
}
510510

511-
if (repo->is_remote || xbps_dictionary_count(repo->stage) == 0) {
511+
if (xbps_dictionary_count(repo->stage) == 0 ||
512+
(repo->is_remote && !(xhp->flags & XBPS_FLAG_USE_STAGE))) {
512513
repo->idx = repo->index;
513514
xbps_object_retain(repo->idx);
514515
return repo;
515516
}
516517

517-
/*
518-
* Load and merge staging repository if the repository is local.
519-
*/
520518
r = repo_merge_stage(repo);
521519
if (r < 0) {
522520
xbps_error_printf(

0 commit comments

Comments
 (0)