summaryrefslogtreecommitdiff
path: root/src/libostree/ostree-repo-refs.c
Commit message (Collapse)AuthorAgeFilesLines
* Update FSF license notices to use URL instead of addressJoseph Marrero2021-12-071-3/+1
|
* refs: Make ostree_repo_resolve_rev{,_ext}() use (nullable)Colin Walters2021-02-191-2/+2
| | | | | | We have an `allow_noent` boolean that controls this, but were missing the `(nullable)` annotation, so the Rust bindings panic when the ref doesn't exist instead of being `Option<GString>`.
* lib/repo: Create repo directories as 0775Jonathan Lebon2020-02-181-1/+1
| | | | | | | | | | | | | For repo structure directories like `objects`, `refs`, etc... we should be more permissive and let the system's `umask` narrow down the permission bits as wanted. This came up in a context where we want to be able to have read/write access on an OSTree repo on NFS from two separate OpenShift apps by using supplemental groups[1] so we don't require SCCs for running as the same UID (supplemental groups are part of the default restricted SCC). [1] https://docs.openshift.com/container-platform/3.11/install_config/persistent_storage/persistent_storage_nfs.html#nfs-supplemental-groups
* lib: add minimum version to various symbols based on libostree-released.symFelix Krull2019-05-191-0/+4
| | | | | Closes: #1861 Approved by: cgwalters
* lib/repo-refs: Allow resolving local collection-refsMatthew Leeds2019-04-151-4/+24
| | | | | | | | | | | | | Currently for a "normal" refspec you can choose to use ostree_repo_resolve_rev_ext() instead of ostree_repo_resolve_rev() if you only want to look at local refs (in refs/heads/) not remote ones. This commit provides the analogous functionality for ostree_repo_resolve_collection_ref() by adding a flag OSTREE_REPO_RESOLVE_REV_EXT_LOCAL_ONLY and implementing it. This will be used by Flatpak. Closes: #1825 Approved by: jlebon
* lib/repo-refs: Add a flag to exclude listing from refs/mirrorsMatthew Leeds2019-04-151-5/+10
| | | | | | | | | | | | | | | | | | | | | | | Currently the flag OSTREE_REPO_LIST_REFS_EXT_EXCLUDE_REMOTES for ostree_repo_list_collection_refs() means that refs in refs/remotes/ should be excluded but refs in refs/mirrors/ should still be checked, in addition to refs/heads/ which is always checked. However in some situations you want to exclude both remote and mirrored refs and only check local "owned" ones. So this commit adds a new flag OSTREE_REPO_LIST_REFS_EXT_EXCLUDE_MIRRORS which lets you exclude refs/mirrors/ from the listing. This way we can avoid breaking API but still allow the listing of local collection-refs. The impetus for this change is that I'm changing Flatpak to make more use of refs/mirrors, and we need a way to specify that a collection-ref is local when using ostree_repo_resolve_collection_ref() in, for example, the implementation of the repo command. The subsequent commit will make the changes needed there. Closes: #1825 Approved by: jlebon
* lib/repo-refs: Fix resolving collection-refsMatthew Leeds2019-04-151-12/+18
| | | | | | | | | | | | | | | | | | | | My last commit "lib/repo-refs: Resolve collection-refs in-memory and in parent repos" changed ostree_repo_resolve_collection_ref() to check the in-memory set of refs *after* failing to find the ref on disk but that's not what we want. We want to use the in-memory set of refs first, because those are the most up to date commits, and then fall back to the on-disk repo and finally fall back to checking any parent repo. This commit makes such a change to the order of operations, which is consistent with how ostree_repo_resolve_rev() works. Aside from this change being logical, it also fixes some unit test failures on an unmerged branch of flatpak: https://github.com/flatpak/flatpak/pull/2705 Also, tweak the comments here. Closes: #1825 Approved by: jlebon
* lib/repo-refs: Resolve collection-refs in-memory and in parent reposMatthew Leeds2019-02-181-2/+25
| | | | | | | | | | | | | | | | | | | | | Currently the behavior of ostree_repo_resolve_rev() is that it tries to resolve a ref to a commit by checking the refs/ directories, but also by checking for in-memory ref-checksum pairs which are part of an in-progress transaction and also by checking the parent repo if one exists. Currently ostree_repo_resolve_collection_ref() only checks the refs/ directories, so this commit makes its behavior analagous since it is the analagous API which supports collection-refs. The impetus for this was that currently Flatpak uses ostree_repo_resolve_rev() to load a commit after doing a P2P pull in flatpak_dir_do_resolve_p2p_refs(), but that assumes the ref came from the same remote that originally provided it, which might not be the case if more than one remote has the same collection ID configured. And changing Flatpak to use ostree_repo_resolve_collection_ref() doesn't work without this patch. Closes: #1821 Approved by: pwithnall
* Fix a small leak in ostree_repo_remote_list_collection_refsMatthias Clasen2018-12-201-1/+1
| | | | | | | | | g_variant_iter_loop would free the value for us, but not if we're returning from the middle of the loop body. Closes: #1788 Approved by: cgwalters
* Fix leak in ostree_repo_list_collection_refsAlexander Larsson2018-08-131-1/+2
| | | | | | | | We need to have the g_auto(GLnxDirFdIterator) inside the loop, or we don't correctly clean up when iterating several times. Closes: #1700 Approved by: cgwalters
* lib/refs: Use GLNX_HASH_TABLE_FOREACH_KV helperJonathan Lebon2018-08-011-8/+1
| | | | | Closes: #1693 Approved by: mwleeds
* config: Add a core/change-update-summary optionMatthew Leeds2018-07-301-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commits adds and implements a boolean repo config option called "change-update-summary" which updates the summary file every time a ref changes (additions, updates, and deletions). The main impetus for this feature is that the `ostree create-usb` and `flatpak create-usb` commands depend on the repo summary being up to date. On the command line you can work around this by asking the user to run `ostree summary --update` but in the case of GNOME Software calling out to `flatpak create-usb` this wouldn't work because it's running as a user and the repo is owned by root. That strategy also means flatpak can't update the repo metadata refs for fear of invalidating the summary. Another use case for this relates to LAN updates. Specifically, the component of eos-updater that generates DNS-SD records advertising ostree refs depends on the repo summary being up to date. Since ostree_repo_regenerate_summary() now takes an exclusive lock, this should be safe to enable. However it's not enabled by default because of the performance cost, and because it's more useful on clients than servers (which likely have another mechanism for updating the summary). Fixes https://github.com/ostreedev/ostree/issues/1664 Closes: #1681 Approved by: jlebon
* ostree_repo_resolve_rev: Resolve refs set in the transactionAlexander Larsson2018-06-141-1/+22
| | | | | | | This allows you to get at the current commit for a ref pending in the transaction. Closes: #1624 Approved by: cgwalters
* Make P2P API public (no longer experimental)Matthew Leeds2018-06-041-7/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently the API that allows P2P operations (e.g. pulling an ostree ref from a LAN or USB source) is hidden behind the configure flag --enable-experimental-api. This commit makes the API public and makes that flag essentially a no-op (leaving it in place in case we want to use it again in the future). The P2P API has been tested over the last several months and proven to work. This means that since we're no longer using the "experimental" feature flag, P2P builds of Flatpak will fail when using versions of OSTree from this commit onwards, until Flatpak is patched in the near future. If you want to build Flatpak < 0.11.8 with P2P enabled and link against OSTree 2018.6, you'll have to patch Flatpak. However, since Flatpak won't yet have a hard dependency on OSTree 2018.6, it needs a new way to determine if the P2P API in OSTree is available, so this commit adds a "p2p" feature flag. This way the feature set is more semantically correct than if we had continued to use the "experimental" feature flag. In addition to making the P2P API public, this commit makes the P2P unit tests run by default, removes the f27-experimental CI instance that's no longer needed, changes a few man pages to reflect the changes, and updates the bash completion script to accept the new commands and options. Closes: #1596 Approved by: cgwalters
* lib/core: Support <remote>: syntax when listing refsJonathan Lebon2018-03-161-2/+18
| | | | | | | | | Allow users to pass `<remote>:` to list all refs we have locally belonging to `<remote>`. Also (re-)allow the similar `<remote>:.` syntax for backwards compatibility with flatpak. Closes: #1500 Approved by: cgwalters
* repo/refs: Clean up error prefixingColin Walters2018-03-061-12/+7
| | | | | | | | | | | | Add some "function global" prefixing in line with what we do in other places now, and drop the "manual filename" prefixing that is no longer necessary since https://github.com/GNOME/libglnx/commit/23f7df15006f14ddc3bc2ddee690f7f8604c3ebe Closes: https://github.com/ostreedev/ostree/issues/1467 Closes: #1485 Approved by: jlebon
* Add SPDX-License-Identifier to source filesMarcus Folkesson2018-01-301-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | SPDX License List is a list of (common) open source licenses that can be referred to by a “short identifier”. It has several advantages compared to the common "license header texts" usually found in source files. Some of the advantages: * It is precise; there is no ambiguity due to variations in license header text * It is language neutral * It is easy to machine process * It is concise * It is simple and can be used without much cost in interpreted environments like java Script, etc. * An SPDX license identifier is immutable. * It provides simple guidance for developers who want to make sure the license for their code is respected See http://spdx.org for further reading. Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com> Closes: #1439 Approved by: cgwalters
* lib/repo: Clarify documentation for ostree_repo_list_refs{,_ext}()Philip Withnall2017-12-141-5/+11
| | | | | | | | | | | | Try and clarify what happens with the prefixes, and that they always return refspecs. I’m still not 100% sure this is right. Signed-off-by: Philip Withnall <withnall@endlessm.com> Closes: #1347 Approved by: cgwalters
* lib/repo: Add (transfer) annotations to various GHashTable argumentsPhilip Withnall2017-11-141-5/+10
| | | | | | | | | | | | | | | | | | | | | By default, unless it’s const, an (out) GHashTable will be assumed to be (transfer full). That means the binding needs to free all the items in the hash table, plus the table itself. However, all the GHashTables we use have free functions set already, so freeing the hash table will free its items. This results in a double-free. Fix that by ensuring we annotate such (out) hash tables as (transfer container). Also annotate some other hash tables as (transfer none) where appropriate, for clarity. This fixes OSTree.Repo.list_collection_refs() in the Python bindings. Signed-off-by: Philip Withnall <withnall@endlessm.com> Closes: #1341 Approved by: dbnicholson
* Disallow refs starting with a non-letter or digitColin Walters2017-10-181-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | Change the regexp for validating refs to require at least one letter or digit before allowing the other special chars in the set `[.-_]`. Names that start with `.` are traditionally Unix hidden files; let's ignore them under the assumption they're metadata for some other tool, and we don't want to potentially conflict with the special `.` and `..` Unix directory entries. Further, names starting with `-` are problematic for Unix cmdline option processing; there's no good reason to support that. Finally, disallow `_` just on general principle - it's simpler to say that ref identifiers must start with a letter or digit. We also ignore any existing files (that might be previously created refs) that start with `.` in the `refs/` directory - there's a Red Hat tool for content management that injects `.rsync` files, which is why this patch was first written. V1: Update to ban all refs starting with a non-letter/digit, and also add another call to `ostree_validate_rev` in the pull code. Closes: https://github.com/ostreedev/ostree/issues/1285 Closes: #1286 Approved by: jlebon
* tree-wide: Update to new libglnx fd APIsColin Walters2017-10-111-12/+12
| | | | | | | | | | | | | | | | | | | This ends up a lot better IMO. This commit is *mostly* just `s/glnx_close_fd/glnx_autofd`, but there's also a number of hunks like: ``` - if (self->sysroot_fd != -1) - { - (void) close (self->sysroot_fd); - self->sysroot_fd = -1; - } + glnx_close_fd (&self->sysroot_fd); ``` Update submodule: libglnx Closes: #1259 Approved by: jlebon
* lib/repo-refs: Add first version of ostree_repo_resolve_collection_ref()Philip Withnall2017-09-271-0/+63
| | | | | | | | | | | | | This is a parallel for ostree_repo_resolve_rev_ext() which works on collection–refs. At the moment, the implementation is simple and uses ostree_repo_list_collection_refs(). In future, it could be rewritten to check the checksum directly rather than enumerating all potentially-relevant checksums. Signed-off-by: Philip Withnall <withnall@endlessm.com> Closes: #1182 Approved by: cgwalters
* tree-wide: Remove Emacs modelinesColin Walters2017-09-211-2/+1
| | | | | | | | | We added a `.dir-locals.el` in commit: 9a77017d87b74c5e2895cdd64ad098018929403f There's no need to have it per-file, with that people might think to add other editors, which is the wrong direction. Closes: #1206 Approved by: jlebon
* tree-wide: Some glnx_fstatat_allow_noent() portingColin Walters2017-09-191-9/+4
| | | | | | | The new API is definitely nicer. Closes: #1180 Approved by: jlebon
* tree-wide: Use helpers for unlinkat()Colin Walters2017-09-071-5/+2
| | | | | | | | | | | | We have `ot_ensure_unlinked_at()` for the "ignore ENOENT" case, and `glnx_unlinkat()` otherwise. Port all in-tree callers to one or the other as appropriate. Just noticed an unprefixed error in the refs case and decided to do a tree-wide check. Closes: #1142 Approved by: jlebon
* lib/repo-refs: Fix typos in last commitMatthew Leeds2017-08-251-2/+2
| | | | | | | | This fixes a whitespace error and a mistake that made it into the last commit, 7ed881baa, at the last minute. Closes: #1112 Approved by: cgwalters
* lib/repo-refs: Include remote refs when using collectionsMatthew Leeds2017-08-241-54/+96
| | | | | | | | | | | | | | | | | | | | | | When working with collections it can be useful to see remote refs rather than just local and mirrored ones. This commit changes the "ostree refs -c" output to include remote refs, and includes remote refs with collection IDs in summary file generation as well. The former behavior is consistent with how "ostree refs" works, and the latter behavior is useful in facilitating P2P updates even when mirrors haven't been configured. To accomplish this, OstreeRepoListRefsExtFlags was extended with an EXCLUDE_REMOTES flag. This was done rather than an INCLUDE_REMOTES flag so that existing calls to ostree_repo_list_refs_ext continue to have the same behavior. This flag was added to ostree_repo_list_collection_refs (which is an experimental API break). Also, add unit tests for the "refs -c" and summary file behavior, and update relevant tests. Closes: #1069 Approved by: cgwalters
* lib/repo-refs: Add ostree_repo_remote_list_collection_refs() APIPhilip Withnall2017-08-081-0/+120
| | | | | | | | | | | | | | | | This parallels ostree_repo_remote_list_refs(), but returns a map of OstreeCollectionRef → checksum, and includes refs from collection IDs other than the remote repository’s main collection ID. Use this in OstreeRepoFinderConfig to ensure that refs are matched against even if they’re stored in the repository summary file’s collection map, rather than its main ref map. This fixes false negatives when searching for refs in some situations. Signed-off-by: Philip Withnall <withnall@endlessm.com> Closes: #1058 Approved by: cgwalters
* lib/repo: Add API to create and list ref aliasesColin Walters2017-08-021-16/+87
| | | | | | | | | | | | | | | | | | | There are multiple use cases where we'd like to alias refs. First, having a "stable" alias which gets swapped across major versions: https://pagure.io/atomic-wg/issue/228 Another case is when a ref is obsoleted; <https://pagure.io/atomic-wg/issue/303> This second one could be done with endoflife rebase, but I think this case is better on the server side, as we might later change our minds and do actual releases there. I initially just added some test cases for symlinks in the `refs/heads` dir to ensure this actually works (and it did), but I think it's worth having APIs. Closes: #1033 Approved by: jlebon
* lib/refs: Add runtime error checking for collection ID validityPhilip Withnall2017-06-261-2/+10
| | | | | | | | | | | Instead of treating it as a programming error — given that it’s user input, that’s not really appropriate. This modifies write_ref() and list_collection_refs() to implement validation. Signed-off-by: Philip Withnall <withnall@endlessm.com> Closes: #924 Approved by: cgwalters
* lib/refs: Add methods for setting/listing collection–refsPhilip Withnall2017-06-261-25/+188
| | | | | | | | | | | | | These are tuples of (collection ID, ref name) which are a globally-unique form of local ref. They use OstreeCollectionRef as an identifier, and hence need to be accessed using new API, as the existing API uses string identifiers and sometimes accepts refspecs. Remote names are not supported as part an OstreeCollectionRef. Signed-off-by: Philip Withnall <withnall@endlessm.com> Closes: #924 Approved by: cgwalters
* repo/refs: Convert to new code styleColin Walters2017-03-231-184/+100
| | | | | | | | | | I happened to be reading this one recently for a reason I forget, and it's a relatively easy conversion. Also one not conflicting with any outstanding patches. Closes: #752 Approved by: jlebon
* refs: resolve conflict between local/remote reposYu Qi Zhang2016-06-231-22/+62
| | | | | | | | | | | | | | | | | | | Add the functionality to use the same name for refs in local and remote repos. This helps users keep track of local refs of remote origin, much like local and remote git branches. Previously, when a local ref is specified, resolve_refspec would fall back to searching through remote repos if the ref is not found locally. This function now takes an extra flag to specify whether it should search through remote repos. Additionally, ostree_repo_resove_rev_ext was added to call resolve_refspec with fallback_remote being false, so refs --create would no longer complain when trying to create a local ref of the same name as a remote one. Fix remote repo parsing not being handled correctly on refs --create. Closes: #363 Approved by: jlebon
* refs: Fix a logic errorMathnerd3142016-06-221-7/+12
| | | | | | | I encountered the Opening remotes/ dir error with some broken pull code, and this fixes it. Closes: #358 Approved by: cgwalters
* core: Use OSTREE_SHA256_STRING_LEN instead of 64Mathnerd3142016-06-221-3/+3
| | | | | Closes: #359 Approved by: cgwalters
* refs: allow overwrite of empty foldersYu Qi Zhang2016-06-211-2/+39
| | | | | | | | | | | | | | | | We noticed that once a ref folder is created, there is no existing command that can remove it. For example, once "foo/bar" is created, even if the user deletes foo or all the refs under foo, the folder will persist. Now when the user attempts to create a ref "foo" either through commit or refs --create, if a folder "foo" exists but is empty of refs, the folder is removed and the new ref "foo" is created. New unit tests in tests-ref.sh verify this functionality. Closes: #354 Approved by: cgwalters
* refs: Add g_prefix_error around opendir for easier debuggingColin Walters2016-04-141-3/+12
| | | | | | | | | | | Addresses: https://github.com/projectatomic/rpm-ostree/issues/264 We should consider moving this down into `glnx_opendirat`, but for now a quick fix. Closes: #255 Approved by: jlebon
* libotutil: new function ot_openat_ignore_enoentGiuseppe Scrivano2016-03-151-29/+5
| | | | | | Refactor some common code Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
* ostree-repo: new public function `ostree_repo_list_refs_ext`Giuseppe Scrivano2016-03-021-20/+59
| | | | | | | | It accepts a `flags` argument to control its behavior. Differently from `ostree_repo_list_refs`, the `refspec_prefix` is not removed from the results. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
* repo: Port -refs.c to openat()Colin Walters2016-01-281-93/+152
| | | | | | | | I'd like to incrementally convert all of `ostree-repo*.c` to fd-relative usage, so that we can sanely introduce `ostree_repo_new_at()` which doesn't involve GFile. This one is medium risk, but passes the test suite.
* refs: Add a missing `goto out` for error handlingColin Walters2016-01-261-0/+2
| | | | If the `refs/remotes` directory doesn't exist, we'd trip an assertion.
* repo: Validate checksums have correct lengthMatthew Barnes2015-11-171-2/+7
| | | | | | | | | ostree_checksum_bytes_peek() can return NULL if the checksum has an incorrect length (most likely from disk corruption) but most callers are not prepared to handle this and would likely crash. Use ostree_checksum_bytes_peek_validate() instead, which sets a GError on an invalid checksum.
* libostree: new API ostree_repo_remote_list_refsGiuseppe Scrivano2015-07-241-0/+75
| | | | | | | The new API permits to query a remote repository summary file and retrieve the list of available refs. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
* repo: Bump mtime any time we write a refColin Walters2015-05-141-0/+3
| | | | | | | | | | | | | | External daemons like rpm-ostree want push notification any time a change is made by an external entity. inotify provides notification, but a problem is there's no easy way to monitor all of the refs. In the past, there has been discussion of opt-in recursive timestamps: https://lkml.org/lkml/2013/4/5/307 But in today's world, let's just bump the mtime on the repo itself, as a central inotify point. Closes: https://github.com/GNOME/ostree/pull/111
* Use g_autoptr(GVariant) instead of gs_unref_variantMatthew Barnes2015-05-061-1/+1
|
* Use g_autoptr(GHashTable) instead of gs_unref_hashtableMatthew Barnes2015-05-061-2/+2
|
* Use g_autoptr() for GIO object typesMatthew Barnes2015-05-061-8/+8
| | | | | GLib 2.44 supplies all the necessary autocleanup macros for GIO types, and libglnx backports the relevant macros for ostree.
* Use g_autofree instead of gs_freeMatthew Barnes2015-05-061-12/+12
|
* repo: Add a private helper to replace a file, honoring fsync policyColin Walters2015-04-131-3/+2
| | | | Extracted from discussion in https://github.com/GNOME/ostree/pull/83
* refs: Use *at for writes, honor repo fsync flagColin Walters2015-04-131-43/+51
| | | | | | | | | | | | | I was looking at https://bugzilla.gnome.org/show_bug.cgi?id=738954 which wants us to ensure we chown() the refs. As part of that, I did a generic conversion to use `*at()` (which naturally gives us more low level control so we can call `fchown` etc. This patch also sneaks in a change to respect the repo's `disable_fsync` flag - if fsync is not set, then we never `fdatasync()` (unlike the `g_file_replace_contents()` default. Also unlike it, if fsync is enabled, we *always* sync even if the file didn't exist.