Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions doc/pacsync.pod
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ Set an alternate installation root.

Set an alternate system root. See L<pacutils-sysroot(7)>.

=item B<--arch>=F<arch>

set an alternate architecture.

=item B<--debug>

Display additional debugging information.
Expand Down
4 changes: 4 additions & 0 deletions doc/pactrans.pod
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ Set an alternate sync database extension.

Set an alternate database path.

=item B<--arch>=F<arch>

set an alternate architecture.

=item B<--logfile>=F<path>

Set an alternate log file path.
Expand Down
9 changes: 6 additions & 3 deletions lib/pacutils/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ void pu_config_free(pu_config_t *config) {
free(config);
}

static int _pu_subst_server_vars(pu_config_t *config) {
int pu_config_subst_server_vars(pu_config_t *config) {
alpm_list_t *r;
for (r = config->repos; r; r = r->next) {
pu_repo_t *repo = r->data;
Expand Down Expand Up @@ -550,8 +550,6 @@ int pu_config_resolve(pu_config_t *config) {
#undef SETBOOL
#undef SETDEFAULT

if (_pu_subst_server_vars(config) != 0) { return -1; }

return 0;
}

Expand Down Expand Up @@ -977,3 +975,8 @@ void pu_config_reader_free(pu_config_reader_t *reader) {
pu_config_reader_free(reader->_parent);
free(reader);
}

pu_config_t *pu_config_add_architecture(pu_config_t *dest, char *arch) {
dest->architectures = alpm_list_add(dest->architectures, strdup(arch));
return dest;
}
4 changes: 4 additions & 0 deletions lib/pacutils/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ int pu_config_resolve(pu_config_t *config);
int pu_config_resolve_sysroot(pu_config_t *config, const char *sysroot);
void pu_config_free(pu_config_t *config);

int pu_config_subst_server_vars(pu_config_t *config);

alpm_handle_t *pu_initialize_handle_from_config(pu_config_t *config);

pu_config_reader_t *pu_config_reader_new_sysroot(pu_config_t *config,
Expand All @@ -170,4 +172,6 @@ pu_config_reader_t *pu_config_reader_finit(pu_config_t *config, FILE *stream);
int pu_config_reader_next(pu_config_reader_t *reader);
void pu_config_reader_free(pu_config_reader_t *reader);

int pu_config_add_architecture(pu_config_t *dest, char *arch);

#endif /* PACUTILS_CONFIG_H */
18 changes: 15 additions & 3 deletions src/pacconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ pu_config_t *parse_opts(int argc, char **argv) {
while ((c = getopt_long(argc, argv, short_opts, long_opts, NULL)) != -1) {
switch (c) {
case FLAG_ARCH:
alpm_list_append_strdup(&config->architectures, optarg);
pu_config_add_architecture(config, optarg);
break;
case FLAG_CONFIG:
config_file = optarg;
Expand Down Expand Up @@ -156,11 +156,23 @@ pu_config_t *parse_opts(int argc, char **argv) {
}
}

pu_config_t *res;
if (raw) {
return pu_ui_config_parse_sysroot(config, config_file, sysroot);
res = pu_ui_config_parse_sysroot(config, config_file, sysroot);
} else {
return pu_ui_config_load_sysroot(config, config_file, sysroot);
res = pu_ui_config_load_sysroot(config, config_file, sysroot);
}

if (!res) {
return NULL;
}

if (pu_config_subst_server_vars(config) != 0) {
fputs("error: substituting repo server values failed", stderr);
return NULL;
}

return config;
}

void list_repos(void) {
Expand Down
11 changes: 11 additions & 0 deletions src/pacsync.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ enum longopt_flags {
FLAG_LOGFILE,
FLAG_SYSROOT,
FLAG_VERSION,
FLAG_ARCH,
};

#define hputs(msg) fputs(msg"\n", stream);
Expand All @@ -59,6 +60,7 @@ void usage(int ret) {
hputs(" --dbext=<ext> set an alternate sync database extension");
hputs(" --dbpath=<path> set an alternate database location");
hputs(" --sysroot=<path> set an alternate system root");
hputs(" --arch=<arch> set an alternate architecture");
hputs(" --force sync repos even if already up-to-date");
hputs(" --debug enable extra debugging messages");
hputs(" --logfile=<path> set an alternate log file");
Expand All @@ -82,6 +84,7 @@ pu_config_t *parse_opts(int argc, char **argv) {
{ "debug", no_argument, NULL, FLAG_DEBUG },
{ "no-timeout", no_argument, NULL, FLAG_NOTIMEOUT },
{ "sysroot", required_argument, NULL, FLAG_SYSROOT },
{ "arch", required_argument, NULL, FLAG_ARCH },
{ "force", no_argument, &force, 1 },
{ "updated", no_argument, &ret_updated, 1 },
{ "help", no_argument, NULL, FLAG_HELP },
Expand Down Expand Up @@ -110,6 +113,9 @@ pu_config_t *parse_opts(int argc, char **argv) {
free(config->dbpath);
config->dbpath = strdup(optarg);
break;
case FLAG_ARCH:
pu_config_add_architecture(config, optarg);
break;
case FLAG_DEBUG:
log_level |= ALPM_LOG_DEBUG;
log_level |= ALPM_LOG_FUNCTION;
Expand Down Expand Up @@ -141,6 +147,11 @@ pu_config_t *parse_opts(int argc, char **argv) {
return NULL;
}

if (pu_config_subst_server_vars(config) != 0) {
fputs("error: substituting repo server values failed", stderr);
return NULL;
}

return config;
}

Expand Down
6 changes: 6 additions & 0 deletions src/pactrans.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ enum longopt_flags {
FLAG_USE_DEFAULT_PROVIDER,
FLAG_VERSION,
FLAG_YOLO,
FLAG_ARCH,
};

enum replacement_disposition {
Expand Down Expand Up @@ -149,6 +150,7 @@ void usage(int ret) {
hputs(" --dbsync update sync databases prior to the transaction");
hputs(" --dbext=<ext> set an alternate sync database extension");
hputs(" --dbpath=<path> set an alternate database location");
hputs(" --arch=<arch> set an alternate architecture");
hputs(" --debug enable extra debugging messages");
hputs(" --no-timeout disable low speed timeouts for downloads");
hputs(" --hookdir=<path> add additional user hook directory");
Expand Down Expand Up @@ -270,6 +272,7 @@ pu_config_t *parse_opts(int argc, char **argv) {
{ "dbext", required_argument, NULL, FLAG_DBEXT },
{ "dbpath", required_argument, NULL, FLAG_DBPATH },
{ "dbsync", no_argument, NULL, FLAG_DBSYNC },
{ "arch", required_argument, NULL, FLAG_ARCH },
{ "debug", optional_argument, NULL, FLAG_DEBUG },
{ "hookdir", required_argument, NULL, FLAG_HOOKDIR },
{ "logfile", required_argument, NULL, FLAG_LOGFILE },
Expand Down Expand Up @@ -383,6 +386,9 @@ pu_config_t *parse_opts(int argc, char **argv) {
case FLAG_DBSYNC:
dbsync = 1;
break;
case FLAG_ARCH:
pu_config_add_architecture(config, optarg);
break;
case FLAG_DEBUG:
log_level |= ALPM_LOG_DEBUG;
log_level |= ALPM_LOG_FUNCTION;
Expand Down