Skip to content

Commit

Permalink
Rename component get_releases to indicate that releases my not be loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
ximion committed Sep 20, 2023
1 parent 51f14eb commit bc76ecb
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 30 deletions.
2 changes: 1 addition & 1 deletion compose/asc-compose.c
Original file line number Diff line number Diff line change
Expand Up @@ -1276,7 +1276,7 @@ asc_compose_finalize_components (AscCompose *compose, AscResult *cres)

/* strip out release artifacts unless we were told to propagate them */
if (!as_flags_contains (priv->flags, ASC_COMPOSE_FLAG_PROPAGATE_ARTIFACTS)) {
AsReleases *releases = as_component_get_releases (cpt);
AsReleases *releases = as_component_get_releases_plain (cpt);
for (guint j = 0; j < as_releases_len (releases); j++) {
AsRelease *rel = as_releases_index (releases, j);
g_ptr_array_set_size (as_release_get_artifacts (rel), 0);
Expand Down
2 changes: 1 addition & 1 deletion compose/asc-utils-metainfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ asc_process_metainfo_releases (AscResult *cres,
{
g_autoptr(GError) local_error = NULL;
g_autoptr(GBytes) relmd_bytes = NULL;
AsReleases *releases = as_component_get_releases (cpt);
AsReleases *releases = as_component_get_releases_plain (cpt);

/* download external release metadata or fetch local release data */
if (as_releases_get_kind (releases) == AS_RELEASES_KIND_EXTERNAL) {
Expand Down
4 changes: 2 additions & 2 deletions docs/API-TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ libappstream API break for the AppStream 1.0 release.

## TODO

* Drop all bytes+length uses in public API and use GBytes instead if a function takes byte arrays

* Make AsComponentBox/AsReleases available for the Qt bindings

* Sort out the various markup-to-text conversion functions, make some of them public API and maybe rewrite some
Expand Down Expand Up @@ -54,3 +52,5 @@ libappstream API break for the AppStream 1.0 release.
* Create new AsReleaseData/AsReleases to hold external release information

* Make AsMetadata use AsReleases

* Drop all bytes+length uses in public API and use GBytes instead if a function takes byte arrays
4 changes: 2 additions & 2 deletions qt/component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -515,11 +515,11 @@ void AppStream::Component::addScreenshot(const AppStream::Screenshot &screenshot
as_component_add_screenshot(m_cpt, screenshot.asScreenshot());
}

QList<Release> Component::releases() const
QList<Release> Component::releasesPlain() const
{
QList<Release> res;

auto rels = as_component_get_releases(m_cpt);
auto rels = as_component_get_releases_plain(m_cpt);
res.reserve(as_releases_len(rels));
for (uint i = 0; i < as_releases_len(rels); i++) {
auto rel = as_releases_index(rels, i);
Expand Down
2 changes: 1 addition & 1 deletion qt/component.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ class APPSTREAMQT_EXPORT Component
QList<AppStream::Screenshot> screenshots() const;
void addScreenshot(const AppStream::Screenshot &screenshot);

QList<AppStream::Release> releases() const;
QList<AppStream::Release> releasesPlain() const;
void addRelease(const AppStream::Release &release);

bool hasBundle() const;
Expand Down
4 changes: 2 additions & 2 deletions src/as-component.c
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ as_component_add_screenshot (AsComponent *cpt, AsScreenshot *sshot)
}

/**
* as_component_get_releases:
* as_component_get_releases_plain:
* @cpt: a #AsComponent instance.
*
* Get release information for this component,
Expand All @@ -637,7 +637,7 @@ as_component_add_screenshot (AsComponent *cpt, AsScreenshot *sshot)
* Returns: (transfer none): Release information as #AsReleases
**/
AsReleases *
as_component_get_releases (AsComponent *cpt)
as_component_get_releases_plain (AsComponent *cpt)
{
AsComponentPrivate *priv = GET_PRIVATE (cpt);
return priv->releases;
Expand Down
2 changes: 1 addition & 1 deletion src/as-component.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ const gchar *as_component_get_url (AsComponent *cpt, AsUrlKind url_kind);
void as_component_add_url (AsComponent *cpt, AsUrlKind url_kind, const gchar *url);

AsReleases *as_component_load_releases (AsComponent *cpt, gboolean allow_net, GError **error);
AsReleases *as_component_get_releases (AsComponent *cpt);
AsReleases *as_component_get_releases_plain (AsComponent *cpt);
void as_component_set_releases (AsComponent *cpt, AsReleases *releases);
void as_component_add_release (AsComponent *cpt, AsRelease *release);

Expand Down
2 changes: 1 addition & 1 deletion src/as-icon-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ G_BEGIN_DECLS
gboolean as_icon_load_from_xml (AsIcon *icon, AsContext *ctx, xmlNode *node, GError **error);
void as_icon_to_xml_node (AsIcon *icon, AsContext *ctx, xmlNode *root);

/* NOTE: For YAML, icons are loaded in AsComponent, because the YAML makes this the better option. */
/* NOTE: For YAML, icons are loaded in AsComponent, due to how YAML is structured. */

#pragma GCC visibility pop
G_END_DECLS
Expand Down
6 changes: 3 additions & 3 deletions src/as-validator.c
Original file line number Diff line number Diff line change
Expand Up @@ -2505,7 +2505,7 @@ as_validator_check_releases (AsValidator *validator, xmlNode *node, AsFormatStyl
rel_pair->bytes,
rel_pair->fname,
mode);
as_releases_load_from_bytes (as_component_get_releases (priv->current_cpt),
as_releases_load_from_bytes (as_component_get_releases_plain (priv->current_cpt),
rel_pair->bytes,
NULL);
}
Expand Down Expand Up @@ -3315,8 +3315,8 @@ as_validator_validate_component_node (AsValidator *validator, AsContext *ctx, xm
}

/* validate releases */
if (!as_releases_is_empty (as_component_get_releases (cpt))) {
AsReleases *releases = as_component_get_releases (cpt);
if (!as_releases_is_empty (as_component_get_releases_plain (cpt))) {
AsReleases *releases = as_component_get_releases_plain (cpt);
AsRelease *release_prev = as_releases_index (releases, 0);

for (guint i = 1; i < as_releases_len (releases); i++) {
Expand Down
2 changes: 1 addition & 1 deletion tests/test-pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ test_pool_read (void)
g_assert_nonnull (bundle);
g_assert_cmpstr (as_bundle_get_id (bundle), ==, "neverball-1.6.0");

rels = as_component_get_releases (cpt_a);
rels = as_component_get_releases_plain (cpt_a);
g_assert_cmpint (as_releases_len (rels), ==, 2);

rel = as_releases_index (rels, 0);
Expand Down
8 changes: 4 additions & 4 deletions tests/test-xmldata.c
Original file line number Diff line number Diff line change
Expand Up @@ -1882,12 +1882,12 @@ test_xml_read_releases (void)
cpt = as_xml_test_read_data (xmldata_releases, AS_FORMAT_STYLE_METAINFO);
g_assert_cmpstr (as_component_get_id (cpt), ==, "org.example.ReleaseTest");

g_assert_cmpint (as_releases_len (as_component_get_releases (cpt)), ==, 1);
g_assert_cmpint (as_releases_get_kind (as_component_get_releases (cpt)),
g_assert_cmpint (as_releases_len (as_component_get_releases_plain (cpt)), ==, 1);
g_assert_cmpint (as_releases_get_kind (as_component_get_releases_plain (cpt)),
==,
AS_RELEASES_KIND_EMBEDDED);

rel = as_releases_index (as_component_get_releases (cpt), 0);
rel = as_releases_index (as_component_get_releases_plain (cpt), 0);
g_assert_cmpint (as_release_get_kind (rel), ==, AS_RELEASE_KIND_STABLE);
g_assert_cmpstr (as_release_get_version (rel), ==, "1.2");

Expand Down Expand Up @@ -2215,7 +2215,7 @@ test_xml_rw_external_releases (void)
g_assert_error (error, AS_UTILS_ERROR, AS_UTILS_ERROR_FAILED);
g_clear_error (&error);
g_assert_null (releases);
releases = as_component_get_releases (cpt);
releases = as_component_get_releases_plain (cpt);
g_assert_nonnull (releases);
g_assert_cmpint (as_releases_len (releases), ==, 0);

Expand Down
4 changes: 2 additions & 2 deletions tests/test-yamldata.c
Original file line number Diff line number Diff line change
Expand Up @@ -1732,9 +1732,9 @@ test_yaml_read_releases (void)
cpt = as_yaml_test_read_data (yamldata_releases_field, NULL);
g_assert_cmpstr (as_component_get_id (cpt), ==, "org.example.ReleasesTest");

g_assert_cmpint (as_releases_len (as_component_get_releases (cpt)), ==, 2);
g_assert_cmpint (as_releases_len (as_component_get_releases_plain (cpt)), ==, 2);

rel = as_releases_index (as_component_get_releases (cpt), 0);
rel = as_releases_index (as_component_get_releases_plain (cpt), 0);
g_assert_cmpint (as_release_get_kind (rel), ==, AS_RELEASE_KIND_STABLE);
g_assert_cmpstr (as_release_get_version (rel), ==, "1.2");

Expand Down
20 changes: 11 additions & 9 deletions tools/ascli-actions-misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ ascli_news_to_metainfo (const gchar *news_fname,
}

cpt = as_metadata_get_component (metad);
cpt_releases = as_component_get_releases (cpt);
cpt_releases = as_component_get_releases_plain (cpt);

/* remove all existing releases, we only include data from the specified file */
as_releases_clear (cpt_releases);
Expand Down Expand Up @@ -497,10 +497,11 @@ ascli_metainfo_to_news (const gchar *mi_fname, const gchar *news_fname, const gc
return 3;
}

as_releases_to_news_data (as_releases_get_entries (as_component_get_releases (cpt)),
format_kind,
&news_data,
&error);
as_releases_to_news_data (
as_releases_get_entries (as_component_get_releases_plain (cpt)),
format_kind,
&news_data,
&error);
if (error != NULL) {
g_printerr ("%s\n", error->message);
return 1;
Expand All @@ -509,10 +510,11 @@ ascli_metainfo_to_news (const gchar *mi_fname, const gchar *news_fname, const gc
g_print ("%s\n", news_data);
return 0;
} else {
as_releases_to_news_file (as_releases_get_entries (as_component_get_releases (cpt)),
news_fname,
format_kind,
&error);
as_releases_to_news_file (
as_releases_get_entries (as_component_get_releases_plain (cpt)),
news_fname,
format_kind,
&error);
if (error != NULL) {
g_printerr ("%s\n", error->message);
return 1;
Expand Down

2 comments on commit bc76ecb

@usta
Copy link

@usta usta commented on bc76ecb Sep 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ximion After this commit Appstream compile is problem for my system
I'm getting error like :

[1/5] /home/kde-dev/kde/build/appstream/tools/appstreamcli news-to-metainfo --limit=6 ../../src/appstream/data/../NEWS ../../src/appstream/data/org.freedesktop.appstream.cli.metainfo.xml data/nol10n_withrelinfo_org.freedesktop.appstream.cli.metainfo.xml
FAILED: data/nol10n_withrelinfo_org.freedesktop.appstream.cli.metainfo.xml 
/home/kde-dev/kde/build/appstream/tools/appstreamcli news-to-metainfo --limit=6 ../../src/appstream/data/../NEWS ../../src/appstream/data/org.freedesktop.appstream.cli.metainfo.xml data/nol10n_withrelinfo_org.freedesktop.appstream.cli.metainfo.xml
/home/kde-dev/kde/build/appstream/tools/appstreamcli: symbol lookup error: /home/kde-dev/kde/build/appstream/tools/appstreamcli: undefined symbol: as_component_get_releases_plain
[2/5] /usr/bin/meson --internal symbolextractor /home/kde-dev/kde/build/appstream qt/libAppStreamQt.so.1.0.0 qt/libAppStreamQt.so.1.0.0 qt/libAppStreamQt.so.1.0.0.p/libAppStreamQt.so.1.0.0.symbols 
[3/5] /usr/bin/g-ir-compiler src/AppStream-1.0.gir --output src/AppStream-1.0.typelib --includedir=/usr/share/gir-1.0
ninja: build stopped: subcommand failed.

@ximion
Copy link
Owner Author

@ximion ximion commented on bc76ecb Sep 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The in-development Git version explicitly breaks API, so don't use it if you don't want to test software with the new API!

That said, this compile error looks very odd, it looks like it is correctly invoking the built appstreamcli, but that is for some reason loading the wrong libappstream. You can try a ninja clean or meson setup --wipe to see if that resolves the problem.

Please sign in to comment.