1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469
|
/*
* This file is part of libmodulemd
* Copyright (C) 2017-2020 Stephen Gallagher
*
* Fedora-License-Identifier: MIT
* SPDX-2.0-License-Identifier: MIT
* SPDX-3.0-License-Identifier: MIT
*
* This program is free software.
* For more information on the license, see COPYING.
* For more information on free software, see <https://www.gnu.org/philosophy/free-sw.en.html>.
*/
#pragma once
#include "modulemd-module-index.h"
#include "modulemd-module-stream.h"
#include "modulemd-translation-entry.h"
#include "modulemd-translation.h"
#include "private/modulemd-module-stream-v1-private.h"
#include "private/modulemd-module-stream-v2-private.h"
#include "private/modulemd-yaml.h"
#include <glib-object.h>
G_BEGIN_DECLS
/**
* SECTION: modulemd-module-stream-private
* @title: Modulemd.ModuleStream (Private)
* @stability: private
* @short_description: #ModulemdModuleStream methods that should only be used
* by internal consumers.
*/
/**
* modulemd_module_stream_set_module_name:
* @self: (in): This #ModulemdModuleStream object.
* @module_name: The module name this object represents.
*
* Since: 2.0
*/
void
modulemd_module_stream_set_module_name (ModulemdModuleStream *self,
const gchar *module_name);
/**
* modulemd_module_stream_set_stream_name:
* @self: (in): This #ModulemdModuleStream object.
* @stream_name: The stream name this object represents.
*
* Since: 2.0
*/
void
modulemd_module_stream_set_stream_name (ModulemdModuleStream *self,
const gchar *stream_name);
/**
* modulemd_module_stream_associate_translation:
* @self: (in): This #ModulemdModuleStream object.
* @translation: (in): The #ModulemdTranslation information to associate with
* this object.
*
* Since: 2.0
*/
void
modulemd_module_stream_associate_translation (
ModulemdModuleStream *self, ModulemdTranslation *translation);
/**
* modulemd_module_stream_get_translation:
* @self: (in): This #ModulemdModuleStream object.
*
* Returns: The #ModulemdTranslation information to associated with this object.
*
* Since: 2.0
*/
ModulemdTranslation *
modulemd_module_stream_get_translation (ModulemdModuleStream *self);
/**
* modulemd_module_stream_get_translation_entry:
* @self: (in): This #ModulemdModuleStream object.
* @locale: The locale of the translation to retrieve.
*
* Returns: (transfer none): The module stream #ModulemdTranslationEntry for
* the requested locale, or NULL if the locale was unknown.
*
* Since: 2.0
*/
ModulemdTranslationEntry *
modulemd_module_stream_get_translation_entry (ModulemdModuleStream *self,
const gchar *locale);
/**
* modulemd_module_stream_validate_components:
* @components: (in): A #GHashTable of #ModulemdComponent objects.
* @error: (out): A #GError that will return the reason for a validation error.
*
* Verifies that each of the #ModulemdComponent objects in @components
* validates correctly via modulemd_component_validate(), verifies that any
* buildafter components are also present in @components, and verifies that
* buildorder and buildafter aren't mixed.
*
* Returns: TRUE if the component objects passed validation. FALSE and sets
* @error appropriately if validation fails.
*
* Since: 2.0
*/
gboolean
modulemd_module_stream_validate_components (GHashTable *components,
GError **error);
/**
* modulemd_module_stream_validate_component_rpm_arches:
* @components: (in): A #GHashTable of #ModulemdComponent objects.
* @module_arches: (in): A #GStrv list of arches for which to build the module.
* @error: (out): A #GError that will return the reason for a validation error.
*
* Verifies that for each of the #ModulemdComponent RPM objects in @components,
* any arches specified must be a subset of @module_arches. If @module_arches
* is empty, all arches are allowed.
*
* Returns: TRUE if the component objects passed validation. FALSE and sets
* @error appropriately if validation fails.
*
* Since: 2.9
*/
gboolean
modulemd_module_stream_validate_component_rpm_arches (GHashTable *components,
GStrv module_arches,
GError **error);
/* Some macros used for copy operations */
/**
* STREAM_UPGRADE_IF_SET_FULL:
* @oldversion: The stream version of @src. Must be literal "v1" or "v2"
* without the quotes.
* @newversion: The stream version of @dest. Must be literal "v1" or "v2"
* without the quotes.
* @dest: (out): A #ModulemdModuleStreamV1 or #ModulemdModuleStreamV2 object
* that is the destination to which @property is to be copied.
* @src: (in): A #ModulemdModuleStreamV1 or #ModulemdModuleStreamV2 object that
* is the source from which @property is to be copied.
* @property: The name of the property to copy. Must be the literal property
* name, in lower case, without quotes.
* @locale...: (in): An optional locale that can be provided when @property has
* possible translations.
*
* DIRECT USE OF THIS MACRO SHOULD BE AVOIDED. This is the internal
* implementation for %STREAM_COPY_IF_SET, %STREAM_UPGRADE_IF_SET,
* %STREAM_COPY_IF_SET_WITH_LOCALE, and %STREAM_UPGRADE_IF_SET_WITH_LOCALE
* which should be used instead.
*
* This is a helper macro to simplify the coding when copying/upgrading
* properties between #ModulemdModuleStreamV1 and #ModulemdModuleStreamV2
* objects.
*
* Does nothing if the @src @property is NULL.
*
* Since: 2.0
*/
#define STREAM_UPGRADE_IF_SET_FULL( \
oldversion, newversion, dest, src, property, locale...) \
do \
{ \
if (modulemd_module_stream_##oldversion##_get_##property ( \
src, ##locale) != NULL) \
modulemd_module_stream_##newversion##_set_##property ( \
dest, \
modulemd_module_stream_##oldversion##_get_##property (src, \
##locale)); \
} \
while (0)
/**
* STREAM_COPY_IF_SET:
* @version: The stream version being copied. Must be literal "v1" or "v2"
* without the quotes.
* @dest: (out): A #ModulemdModuleStreamV1 or #ModulemdModuleStreamV2 object
* that is the destination to which @property is to be copied.
* @src: (in): A #ModulemdModuleStreamV1 or #ModulemdModuleStreamV2 object that
* is the source from which @property is to be copied.
* @property: The name of the property to copy. Must be the literal property
* name, in lower case, without quotes.
*
* This is a convenience macro to simplify the coding when copying properties
* between #ModulemdModuleStream objects when both @src and @dest are the same
* version.
*
* Does nothing if the @src @property is NULL.
*
* Since: 2.0
*/
#define STREAM_COPY_IF_SET(version, dest, src, property) \
STREAM_UPGRADE_IF_SET_FULL (version, version, dest, src, property)
/**
* STREAM_UPGRADE_IF_SET:
* @oldversion: The stream version of @src. Must be literal "v1" or "v2"
* without the quotes.
* @newversion: The stream version of @dest. Must be literal "v1" or "v2"
* without the quotes.
* @dest: (out): A #ModulemdModuleStreamV1 or #ModulemdModuleStreamV2 object
* that is the destination to which @property is to be copied.
* @src: (in): A #ModulemdModuleStreamV1 or #ModulemdModuleStreamV2 object that
* is the source from which @property is to be copied.
* @property: The name of the property to copy. Must be the literal property
* name, in lower case, without quotes.
*
* This is a convenience macro to simplify the coding when copying properties
* between #ModulemdModuleStreamV1 and #ModulemdModuleStreamV2 objects when
* @src and @dest are different versions.
*
* Does nothing if the @src @property is NULL.
*
* Since: 2.0
*/
#define STREAM_UPGRADE_IF_SET(oldversion, newversion, dest, src, property) \
STREAM_UPGRADE_IF_SET_FULL (oldversion, newversion, dest, src, property)
/**
* STREAM_COPY_IF_SET_WITH_LOCALE:
* @version: The stream version being copied. Must be literal "v1" or "v2"
* without the quotes.
* @dest: (out): A #ModulemdModuleStreamV1 or #ModulemdModuleStreamV2 object
* that is the destination to which @property is to be copied.
* @src: (in): A #ModulemdModuleStreamV1 or #ModulemdModuleStreamV2 object that
* is the source from which @property is to be copied.
* @property: The name of the property to copy. Must be the literal property
* name, in lower case, without quotes.
*
* This is a convenience macro to simplify the coding when copying properties
* between #ModulemdModuleStreamV1 and #ModulemdModuleStreamV2 objects when
* both @src and @dest are the same version and @property has possible
* translations. Only the untranslated (`"C"` locale) version of @property will
* be copied.
*
* Does nothing if the @src @property is NULL.
*
* Since: 2.0
*/
#define STREAM_COPY_IF_SET_WITH_LOCALE(version, dest, src, property) \
STREAM_UPGRADE_IF_SET_FULL (version, version, dest, src, property, "C")
/**
* STREAM_UPGRADE_IF_SET_WITH_LOCALE:
* @oldversion: The stream version of @src. Must be literal "v1" or "v2"
* without the quotes.
* @newversion: The stream version of @dest. Must be literal "v1" or "v2"
* without the quotes.
* @dest: (out): A #ModulemdModuleStreamV1 or #ModulemdModuleStreamV2 object
* that is the destination to which @property is to be copied.
* @src: (in): A #ModulemdModuleStreamV1 or #ModulemdModuleStreamV2 object that
* is the source from which @property is to be copied.
* @property: The name of the property to copy. Must be the literal property
* name, in lower case, without quotes.
*
* This is a convenience macro to simply the coding when copying properties
* between #ModulemdModuleStreamV1 and #ModulemdModuleStreamV2 objects when
* @src and @dest are different versions and @property has possible
* translations. Only the untranslated (`"C"` locale) version of @property will
* be copied.
*
* Does nothing if the @src @property is NULL.
*
* Since: 2.0
*/
#define STREAM_UPGRADE_IF_SET_WITH_LOCALE( \
oldversion, newversion, dest, src, property) \
STREAM_UPGRADE_IF_SET_FULL (oldversion, newversion, dest, src, property, "C")
/**
* STREAM_REPLACE_HASHTABLE:
* @version: The stream version being replaced. Must be literal "v1" or "v2"
* without the quotes.
* @dest: (out): A #ModulemdModuleStreamV1 or #ModulemdModuleStreamV2 object
* that is the destination at which @property is being replaced.
* @src: (in): A #ModulemdModuleStreamV1 or #ModulemdModuleStreamV2 object that
* is the source from which @property is being replaced.
* @property: The name of the #GHashTable property to replace. Must be the
* literal property name, in lower case, without quotes.
*
* This is a convenience macro to simply the coding when replacing #GHashTable
* properties of #ModulemdModuleStreamV1 and #ModulemdModuleStreamV2 objects
* when both @src and @dest are the same version.
*
* Since: 2.0
*/
#define STREAM_REPLACE_HASHTABLE(version, dest, src, property) \
do \
{ \
modulemd_module_stream_##version##_replace_##property (dest, \
src->property); \
} \
while (0)
/**
* COPY_HASHTABLE_BY_VALUE_ADDER:
* @dest: (out): A #ModulemdModuleStreamV1 or #ModulemdModuleStreamV2 object
* that is the destination to which @property is to be copied.
* @src: (in): A #ModulemdModuleStreamV1 or #ModulemdModuleStreamV2 object that
* is the source from which @property is to be copied.
* @property: The name of the #GHashTable property to copy. Must be the literal
* property name, in lower case, without quotes.
* @adder: (in): A pointer to a method of @dest that supports add-on property
* values.
*
* This is a convenience macro to simply the coding when copying #GHashTable
* properties between #ModulemdModuleStreamV1 and #ModulemdModuleStreamV2
* objects when the property is set by using add-on values.
*
* Since: 2.0
*/
#define COPY_HASHTABLE_BY_VALUE_ADDER(dest, src, property, adder) \
do \
{ \
GHashTableIter iter; \
gpointer value; \
g_hash_table_iter_init (&iter, src->property); \
while (g_hash_table_iter_next (&iter, NULL, &value)) \
{ \
adder (dest, value); \
} \
} \
while (0)
/**
* modulemd_module_stream_emit_yaml_base:
* @self: This #ModulemdModuleStream object.
* @emitter: (inout): A libyaml emitter object positioned where a Module Stream
* document belongs in the YAML document.
* @error: (out): A #GError that will return the reason for an emission or
* validation error.
*
* Emit the common non-version specific YAML components for the Module Stream
* document.
*
* Returns: TRUE if the #ModulemdModuleStream components were emitted
* successfully. FALSE and sets @error appropriately if the YAML could not be
* emitted.
*
* Since: 2.0
*/
gboolean
modulemd_module_stream_emit_yaml_base (ModulemdModuleStream *self,
yaml_emitter_t *emitter,
GError **error);
/**
* modulemd_module_stream_includes_nevra:
* @self: This #ModulemdModuleStream object.
* @nevra_pattern: (not nullable): A [glob](https://www.mankier.com/3/glob)
* pattern to match against the NEVRA strings of the rpm artifacts in @self.
*
* Returns: TRUE if this stream includes at least one RPM artifact that
* matches @nevra_pattern. FALSE otherwise.
*
* Since: 2.9
*/
gboolean
modulemd_module_stream_includes_nevra (ModulemdModuleStream *self,
const gchar *nevra_pattern);
/**
* modulemd_module_stream_set_autogen_module_name:
* @self: (in): A pointer to a #ModulemdModuleStream object
* @id: (in): An unsigned integer to be used as a unique identifier if a module
* name is generated.
*
* If @self already has a module name set, this function does nothing.
* Otherwise, a module name will be generated and set for @self.
*
* Since: 2.10
*/
void
modulemd_module_stream_set_autogen_module_name (ModulemdModuleStream *self,
guint id);
/**
* modulemd_module_stream_set_autogen_stream_name:
* @self: (in): A pointer to a #ModulemdModuleStream object
* @id: (in): An unsigned integer to be used as a unique identifier if a stream
* name is generated.
*
* If @self already has a stream name set, this function does nothing.
* Otherwise, a stream name will be generated and set for @self.
*
* Since: 2.10
*/
void
modulemd_module_stream_set_autogen_stream_name (ModulemdModuleStream *self,
guint id);
/**
* modulemd_module_stream_is_autogen_module_name:
* @self: (in): A pointer to a #ModulemdModuleStream object
*
* Returns: TRUE if @self has a module name that matches the format used if
* modulemd_module_stream_set_autogen_module_name() created the name.
* Otherwise FALSE.
*
* Since: 2.10
*/
gboolean
modulemd_module_stream_is_autogen_module_name (ModulemdModuleStream *self);
/**
* modulemd_module_stream_is_autogen_stream_name:
* @self: (in): A pointer to a #ModulemdModuleStream object
*
* Returns: TRUE if @self has a stream name that matches the format used if
* modulemd_module_stream_set_autogen_stream_name() created the name.
* Otherwise FALSE.
*
* Since: 2.10
*/
gboolean
modulemd_module_stream_is_autogen_stream_name (ModulemdModuleStream *self);
/**
* modulemd_module_stream_clear_autogen_module_name:
* @self: (in): A pointer to a #ModulemdModuleStream object
*
* Clears @self's module name if it matches the format used if
* modulemd_module_stream_set_autogen_module_name() created the name, else
* does nothing.
*
* Since: 2.10
*/
void
modulemd_module_stream_clear_autogen_module_name (ModulemdModuleStream *self);
/**
* modulemd_module_stream_clear_autogen_stream_name:
* @self: (in): A pointer to a #ModulemdModuleStream object
*
* Clears @self's stream name if it matches the format used if
* modulemd_module_stream_set_autogen_stream_name() created the name, else
* does nothing.
*
* Since: 2.10
*/
void
modulemd_module_stream_clear_autogen_stream_name (ModulemdModuleStream *self);
/**
* modulemd_module_stream_upgrade_v1_to_v2:
* @from (in): A #ModulemdModuleStreamV1 object.
* @error: (out): A #GError that will return the reason for an upgrade error.
*
* Return an upgraded copy of this object. Does not modify the original.
*
* Returns: (transfer full): A newly-allocated #ModulemdModuleStreamV2 copy of
* @from upgraded to V2. Returns NULL and sets @error appropriately if the
* upgrade could not be completed automatically.
*
* Since: 2.11
*/
ModulemdModuleStream *
modulemd_module_stream_upgrade_v1_to_v2 (ModulemdModuleStream *from);
G_END_DECLS
|