Skip to content

Commit

Permalink
Merge pull request #227 from sgallagher/nsvca
Browse files Browse the repository at this point in the history
Fix lookups of streams to include architecture
  • Loading branch information
sgallagher authored Mar 11, 2019
2 parents 1cb879b + 645e79b commit 2753081
Show file tree
Hide file tree
Showing 16 changed files with 498 additions and 56 deletions.
45 changes: 45 additions & 0 deletions modulemd/v2/include/modulemd-2.0/modulemd-module-stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include <glib-object.h>
#include <glib/gstdio.h>

#include "modulemd-deprecated.h"

G_BEGIN_DECLS

/**
Expand Down Expand Up @@ -344,6 +346,32 @@ const gchar *
modulemd_module_stream_get_context (ModulemdModuleStream *self);


/**
* modulemd_module_stream_set_arch:
* @self: (in): This #ModulemdModuleStream.
* @arch: (in) (nullable): Module architecture.
* Indicates to which processor architecture this ModulemdModuleStream applies.
*
* Since: 2.2
*/
void
modulemd_module_stream_set_arch (ModulemdModuleStream *self,
const gchar *arch);


/**
* modulemd_module_stream_get_arch:
* @self: (in): This #ModulemdModuleStream.
*
* Returns: (transfer none): Module architecture.
* Indicates to which processor architecture this ModulemdModuleStream applies.
*
* Since: 2.2
*/
const gchar *
modulemd_module_stream_get_arch (ModulemdModuleStream *self);


/**
* modulemd_module_stream_get_nsvc_as_string: (rename-to modulemd_module_stream_get_nsvc)
* @self: (in): This #ModulemdModuleStream.
Expand All @@ -352,11 +380,28 @@ modulemd_module_stream_get_context (ModulemdModuleStream *self);
* module stream. NULL if module name or stream stream is unknown.
*
* Since: 2.0
* Deprecated: 2.2
*/
MMD_DEPRECATED_FOR (modulemd_module_stream_get_NSVCA_as_string)
gchar *
modulemd_module_stream_get_nsvc_as_string (ModulemdModuleStream *self);


/**
* modulemd_module_stream_get_NSVCA_as_string: (rename-to modulemd_module_stream_get_NSVCA)
* @self: (in): This #ModulemdModuleStream.
*
* Returns: (transfer full): The NSVCA of this module stream. The returned
* format is described
* [here](https://docs.fedoraproject.org/en-US/modularity/architecture/consuming/naming-policy/#_forms).
* NULL if module name or stream stream is unknown.
*
* Since: 2.2
*/
gchar *
modulemd_module_stream_get_NSVCA_as_string (ModulemdModuleStream *self);


/**
* modulemd_module_stream_depends_on_stream:
* @self: (not nullable): This #ModulemdModuleStream.
Expand Down
31 changes: 31 additions & 0 deletions modulemd/v2/include/modulemd-2.0/modulemd-module.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include <glib-object.h>
#include "modulemd-defaults.h"
#include "modulemd-deprecated.h"
#include "modulemd-module-stream.h"

G_BEGIN_DECLS
Expand Down Expand Up @@ -109,14 +110,44 @@ modulemd_module_get_streams_by_stream_name_as_list (ModulemdModule *self,
* Returns: (transfer none): The requested stream object or NULL if no match was found.
*
* Since: 2.0
* Deprecated: 2.2
*/
MMD_DEPRECATED_FOR (modulemd_module_get_stream_by_NSVCA)
ModulemdModuleStream *
modulemd_module_get_stream_by_NSVC (ModulemdModule *self,
const gchar *stream_name,
const guint64 version,
const gchar *context);


/**
* modulemd_module_get_stream_by_NSVCA:
* @self: This #ModulemdModule object
* @stream_name: The name of the stream to retrieve
* @version: The version of the stream to retrieve. If set to zero, the version
* is not included in the search.
* @context: (nullable): The context of the stream to retrieve. If NULL, the
* context is not included in the search.
* @arch: (nullable): The processor architecture of the stream to retrieve. If
* NULL, the architecture is not included in the search.
* @error: (out): A #GError indicating the reason this function failed to
* retrieve exactly one #ModulemdModuleStream.
*
* Returns: (transfer none): The requested stream object. NULL and sets @error
* appropriately if the provided information is not sufficient to return
* exactly one #ModulemdModuleStream result.
*
* Since: 2.2
*/
ModulemdModuleStream *
modulemd_module_get_stream_by_NSVCA (ModulemdModule *self,
const gchar *stream_name,
const guint64 version,
const gchar *context,
const gchar *arch,
GError **error);


/**
* modulemd_module_get_defaults:
* @self: This #ModulemdModule object
Expand Down
7 changes: 7 additions & 0 deletions modulemd/v2/include/modulemd-2.0/private/gi-binding-renames.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ modulemd_module_get_streams_by_stream_name (ModulemdModule *self,
gchar *
modulemd_module_stream_get_nsvc (ModulemdModuleStream *self);


/**
* modulemd_module_stream_get_NSVCA: (skip)
*/
gchar *
modulemd_module_stream_get_NSVCA (ModulemdModuleStream *self);

/**
* modulemd_module_stream_v1_get_module_component_names: (skip)
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ struct _ModulemdModuleStreamV1
GObject parent_instance;

/* Properties */
gchar *arch;
ModulemdBuildopts *buildopts;
gchar *community;
gchar *description;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ struct _ModulemdModuleStreamV2
GObject parent_instance;

/* Properties */
gchar *arch;
ModulemdBuildopts *buildopts;
gchar *community;
gchar *description;
Expand Down
4 changes: 3 additions & 1 deletion modulemd/v2/include/modulemd-2.0/private/modulemd-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ enum ModulemdError
{
MODULEMD_ERROR_UPGRADE,
MODULEMD_ERROR_VALIDATE,
MODULEMD_ERROR_FILE_ACCESS
MODULEMD_ERROR_FILE_ACCESS,
MODULEMD_ERROR_NO_MATCHES,
MODULEMD_ERROR_TOO_MANY_MATCHES
};

typedef struct _modulemd_tracer
Expand Down
10 changes: 5 additions & 5 deletions modulemd/v2/modulemd-module-index.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,13 +349,13 @@ dump_translations (ModulemdModule *module,


static gint
compare_stream_SVC (gconstpointer a, gconstpointer b)
compare_stream_SVCA (gconstpointer a, gconstpointer b)
{
ModulemdModuleStream *a_ = *(ModulemdModuleStream **)a;
ModulemdModuleStream *b_ = *(ModulemdModuleStream **)b;
g_autofree gchar *a_nsvc = modulemd_module_stream_get_nsvc_as_string (a_);
g_autofree gchar *b_nsvc = modulemd_module_stream_get_nsvc_as_string (b_);
return g_strcmp0 (a_nsvc, b_nsvc);
g_autofree gchar *a_nsvca = modulemd_module_stream_get_NSVCA_as_string (a_);
g_autofree gchar *b_nsvca = modulemd_module_stream_get_NSVCA_as_string (b_);
return g_strcmp0 (a_nsvca, b_nsvca);
}


Expand All @@ -370,7 +370,7 @@ dump_streams (ModulemdModule *module, yaml_emitter_t *emitter, GError **error)
/*
* Make sure we get a stable sorting by sorting just before dumping.
*/
g_ptr_array_sort (streams, compare_stream_SVC);
g_ptr_array_sort (streams, compare_stream_SVCA);

for (i = 0; i < streams->len; i++)
{
Expand Down
6 changes: 2 additions & 4 deletions modulemd/v2/modulemd-module-stream-v1.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ modulemd_module_stream_v1_finalize (GObject *object)
ModulemdModuleStreamV1 *self = MODULEMD_MODULE_STREAM_V1 (object);

/* Properties */
g_clear_pointer (&self->arch, g_free);
g_clear_object (&self->buildopts);
g_clear_pointer (&self->community, g_free);
g_clear_pointer (&self->description, g_free);
Expand Down Expand Up @@ -119,8 +118,7 @@ modulemd_module_stream_v1_set_arch (ModulemdModuleStreamV1 *self,
{
g_return_if_fail (MODULEMD_IS_MODULE_STREAM_V1 (self));

g_clear_pointer (&self->arch, g_free);
self->arch = g_strdup (arch);
modulemd_module_stream_set_arch (MODULEMD_MODULE_STREAM (self), arch);

g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ARCH]);
}
Expand All @@ -131,7 +129,7 @@ modulemd_module_stream_v1_get_arch (ModulemdModuleStreamV1 *self)
{
g_return_val_if_fail (MODULEMD_IS_MODULE_STREAM_V1 (self), NULL);

return self->arch;
return modulemd_module_stream_get_arch (MODULEMD_MODULE_STREAM (self));
}


Expand Down
6 changes: 2 additions & 4 deletions modulemd/v2/modulemd-module-stream-v2.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ modulemd_module_stream_v2_finalize (GObject *object)
ModulemdModuleStreamV2 *self = MODULEMD_MODULE_STREAM_V2 (object);

/* Properties */
g_clear_pointer (&self->arch, g_free);
g_clear_object (&self->buildopts);
g_clear_pointer (&self->community, g_free);
g_clear_pointer (&self->description, g_free);
Expand Down Expand Up @@ -115,8 +114,7 @@ modulemd_module_stream_v2_set_arch (ModulemdModuleStreamV2 *self,
{
g_return_if_fail (MODULEMD_IS_MODULE_STREAM_V2 (self));

g_clear_pointer (&self->arch, g_free);
self->arch = g_strdup (arch);
modulemd_module_stream_set_arch (MODULEMD_MODULE_STREAM (self), arch);

g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ARCH]);
}
Expand All @@ -127,7 +125,7 @@ modulemd_module_stream_v2_get_arch (ModulemdModuleStreamV2 *self)
{
g_return_val_if_fail (MODULEMD_IS_MODULE_STREAM_V2 (self), NULL);

return self->arch;
return modulemd_module_stream_get_arch (MODULEMD_MODULE_STREAM (self));
}


Expand Down
Loading

0 comments on commit 2753081

Please sign in to comment.