if (!PyArg_ParseTuple(args, "zsz", &namespace, &key, &value))
return NULL;
- int r = pakfire_parser_set(self->parser, namespace, key, value);
+ int r = pakfire_parser_set(self->parser, namespace, key, value, 0);
if (r) {
PyErr_SetFromErrno(PyExc_OSError);
return NULL;
}
// Set BUILDROOT
- pakfire_parser_set(makefile, NULL, "BUILDROOT", buildroot_rel);
+ pakfire_parser_set(makefile, NULL, "BUILDROOT", buildroot_rel, 0);
// Run through all build stages
for (const char** stage = stages; *stage; stage++) {
int r;
// Set epoch
- pakfire_parser_set(parser, NULL, "epoch", "0");
+ pakfire_parser_set(parser, NULL, "epoch", "0", 0);
// Set vendor
- pakfire_parser_set(parser, NULL, "vendor", "%{DISTRO_VENDOR}");
+ pakfire_parser_set(parser, NULL, "vendor", "%{DISTRO_VENDOR}", 0);
// Set DISTRO_NAME
const char* name = pakfire_get_distro_name(pakfire);
if (name)
- pakfire_parser_set(parser, NULL, "DISTRO_NAME", name);
+ pakfire_parser_set(parser, NULL, "DISTRO_NAME", name, 0);
// Set DISTRO_SNAME
const char* id = pakfire_get_distro_id(pakfire);
if (id)
- pakfire_parser_set(parser, NULL, "DISTRO_SNAME", name);
+ pakfire_parser_set(parser, NULL, "DISTRO_SNAME", name, 0);
// Set DISTRO_RELEASE
const char* version_id = pakfire_get_distro_version_id(pakfire);
if (version_id)
- pakfire_parser_set(parser, NULL, "DISTRO_RELEASE", version_id);
+ pakfire_parser_set(parser, NULL, "DISTRO_RELEASE", version_id, 0);
// Set DISTRO_DISTTAG
if (id && version_id) {
pakfire_string_format(buffer, "%s%s", id, version_id);
- pakfire_parser_set(parser, NULL, "DISTRO_DISTTAG", buffer);
+ pakfire_parser_set(parser, NULL, "DISTRO_DISTTAG", buffer, 0);
}
// Set DISTRO_VENDOR
const char* vendor = pakfire_get_distro_vendor(pakfire);
if (vendor)
- pakfire_parser_set(parser, NULL, "DISTRO_VENDOR", vendor);
+ pakfire_parser_set(parser, NULL, "DISTRO_VENDOR", vendor, 0);
// Set DISTRO_ARCH
const char* arch = pakfire_get_arch(pakfire);
if (arch) {
- pakfire_parser_set(parser, NULL, "DISTRO_ARCH", arch);
+ pakfire_parser_set(parser, NULL, "DISTRO_ARCH", arch, 0);
const char* platform = pakfire_arch_platform(arch);
if (platform)
- pakfire_parser_set(parser, NULL, "DISTRO_PLATFORM", platform);
+ pakfire_parser_set(parser, NULL, "DISTRO_PLATFORM", platform, 0);
if (vendor) {
// Set DISTRO_MACHINE
r = pakfire_arch_machine(buffer, arch, vendor);
if (!r)
- pakfire_parser_set(parser, NULL, "DISTRO_MACHINE", buffer);
+ pakfire_parser_set(parser, NULL, "DISTRO_MACHINE", buffer, 0);
// Set DISTRO_BUILDTARGET
r = pakfire_arch_buildtarget(buffer, arch, vendor);
if (!r)
- pakfire_parser_set(parser, NULL, "DISTRO_BUILDTARGET", buffer);
+ pakfire_parser_set(parser, NULL, "DISTRO_BUILDTARGET", buffer, 0);
}
}
if (dirname) {
const char* root = pakfire_get_path(pakfire);
- pakfire_parser_set(parser, NULL, "BASEDIR", pakfire_path_relpath(root, dirname));
+ pakfire_parser_set(parser, NULL, "BASEDIR",
+ pakfire_path_relpath(root, dirname), 0);
free(dirname);
}
}
// The architecture is always "src"
- r = pakfire_parser_set(makefile, NULL, "arch", "src");
+ r = pakfire_parser_set(makefile, NULL, "arch", "src", 0);
if (r)
goto ERROR;
PakfireParser pakfire_parser_get_parent(PakfireParser parser);
int pakfire_parser_set(PakfireParser parser,
- const char* namespace, const char* name, const char* value);
+ const char* namespace, const char* name, const char* value, int flags);
int pakfire_parser_append(PakfireParser parser,
const char* namespace, const char* name, const char* value);
}
PAKFIRE_EXPORT int pakfire_parser_set(PakfireParser parser,
- const char* namespace, const char* name, const char* value) {
+ const char* namespace, const char* name, const char* value, int flags) {
if (!name)
return -EINVAL;
else
d->value = NULL;
+ // Update flags
+ if (flags)
+ d->flags = flags;
+
DEBUG(parser->pakfire, "%p: Updated declaration: %s.%s = %s\n",
parser, d->namespace, d->name, d->value);
if (value)
d->value = strdup(value);
+ // Import flags
+ d->flags = flags;
+
DEBUG(parser->pakfire, "%p: New declaration: %s.%s = %s\n",
parser, d->namespace, d->name, d->value);
if (declaration->flags & PAKFIRE_PARSER_DECLARATION_APPEND)
return pakfire_parser_append(parser, declaration->namespace, declaration->name, declaration->value);
- return pakfire_parser_set(parser, declaration->namespace, declaration->name, declaration->value);
+ return pakfire_parser_set(parser, declaration->namespace,
+ declaration->name, declaration->value, declaration->flags);
}
static const char* pakfire_parser_find_template(PakfireParser parser,
// Set the new value when there is no old one
if (!old_value)
- return pakfire_parser_set(parser, namespace, name, value);
+ return pakfire_parser_set(parser, namespace, name, value, 0);
// Concat value
int r = asprintf(&buffer, "%s %s", old_value, value);
return r;
// Set the new value
- r = pakfire_parser_set(parser, namespace, name, buffer);
+ r = pakfire_parser_set(parser, namespace, name, buffer, 0);
free(buffer);
return r;
else
pakfire_string_set(namespace, "");
- int r = pakfire_parser_set(parser1, namespace, d->name, d->value);
+ int r = pakfire_parser_set(parser1, namespace, d->name, d->value, d->flags);
if (r)
return r;
}
int r = pakfire_string_partition($1, ":", &key, &value);
if (r == 0) {
if (strcmp("package", key) == 0) {
- pakfire_parser_set($$, NULL, "name", value);
+ pakfire_parser_set($$, NULL, "name", value, 0);
}
if (key)
pakfire_parser_set_namespace($$, $1);
// Set the name (because we cannot have empty parsers)
- pakfire_parser_set($$, NULL, "name", value);
+ pakfire_parser_set($$, NULL, "name", value, 0);
// Handle all other cases
} else {
- pakfire_parser_set($$, NULL, key, value);
+ pakfire_parser_set($$, NULL, key, value, 0);
}
if (key)
ASSERT(parser);
// Set some architecture
- pakfire_parser_set(parser, NULL, "DISTRO_ARCH", "x86_64");
+ pakfire_parser_set(parser, NULL, "DISTRO_ARCH", "x86_64", 0);
// Load macros
int r = load_macros(parser);
ASSERT(!value);
// Set a value
- int r = pakfire_parser_set(parser, NULL, "a", "a");
+ int r = pakfire_parser_set(parser, NULL, "a", "a", 0);
ASSERT(r == 0);
// Retrieve the value again
pakfire_parser_merge(parser, subparser);
// Set a variable
- r = pakfire_parser_set(parser, NULL, "c", "%{b}");
+ r = pakfire_parser_set(parser, NULL, "c", "%{b}", 0);
ASSERT(r == 0);
// Get the value of c
PAKFIRE_PARSER_FLAGS_EXPAND_COMMANDS);
ASSERT(parser);
- ASSERT(pakfire_parser_set(parser, NULL, "command", command) == 0);
+ ASSERT(pakfire_parser_set(parser, NULL, "command", command, 0) == 0);
// Retrieve the expanded value
char* value = pakfire_parser_get(parser, NULL, "command");