core: Add runtime ostree_check_version()

[Previously](https://github.com/ostreedev/ostree/pull/728) we added compile-time
checking for versions, but there are use cases for runtime checking as well,
because in a number of API calls we use `GVariant` as an API extension
mechanism.

Closes: #735
Approved by: jlebon
This commit is contained in:
Colin Walters 2017-03-13 09:45:51 -04:00 committed by Atomic Bot
parent b825aac0ea
commit 46001f4a5b
4 changed files with 20 additions and 5 deletions

View File

@ -133,6 +133,7 @@ ostree_validate_structureof_dirtree
ostree_validate_structureof_dirmeta ostree_validate_structureof_dirmeta
ostree_commit_get_parent ostree_commit_get_parent
ostree_commit_get_timestamp ostree_commit_get_timestamp
ostree_check_version
</SECTION> </SECTION>
<SECTION> <SECTION>

View File

@ -386,12 +386,10 @@ global:
* NOTE NOTE NOTE * NOTE NOTE NOTE
*/ */
/* Stub section for new version, uncomment when the first symbol is added LIBOSTREE_2017.4 {
LIBOSTREE_2017.$NEWVERSION {
global: global:
someostree_symbol_deleteme; ostree_check_version;
} LIBOSTREE_2017.2; } LIBOSTREE_2017.3;
*/
/* Stub section for the stable release *after* this development one; don't /* Stub section for the stable release *after* this development one; don't
* edit this other than to update the last number. This is just a copy/paste * edit this other than to update the last number. This is just a copy/paste

View File

@ -2153,3 +2153,16 @@ _ostree_get_default_sysroot_path (void)
return default_sysroot_path; return default_sysroot_path;
} }
/**
* ostree_check_version:
* @required_year: Major/year required
* @required_release: Release version required
*
* Returns: %TRUE if current libostree has at least the requested version, %FALSE otherwise
*/
gboolean
ostree_check_version (guint required_year, guint required_release)
{
return OSTREE_CHECK_VERSION(required_year, required_release);
}

View File

@ -399,4 +399,7 @@ gchar * ostree_commit_get_parent (GVariant *commit_variant);
_OSTREE_PUBLIC _OSTREE_PUBLIC
guint64 ostree_commit_get_timestamp (GVariant *commit_variant); guint64 ostree_commit_get_timestamp (GVariant *commit_variant);
_OSTREE_PUBLIC
gboolean ostree_check_version (guint required_year, guint required_release);
G_END_DECLS G_END_DECLS