56 Commits

Author SHA1 Message Date
Sabri Ünal
fa4da960e1 typo: Fix URL usages
Url > URL
url > URL
2026-01-05 21:16:15 +05:30
JakobDev
1e52cc62e8 build-bundle: Add the runtime repo to OCI image metadata
At the moment the --runtime-repo flags of flatpak build-bundle export is
ignored when building an OCI image. So an Flatpak OCI registry which
wants to supports a .flatpakref file has no information about the
runtime repo. With this PR the runtime repo gets added as the
org.flatpak.runtime-repo label to the OCI image.

This is currently only metadata to be used by repositories and not
used by flatpak during install.
2025-12-03 14:53:46 +00:00
Owen W. Taylor
e6b584f85c flatpak-build-bundle: Add --oci-layer-compress=zstd
Add an option to build OCI bundles with zstd compressed layers.

gzip is kept as the default for maximum compatibility:

Ecosystem support:

 distribution/distribution: no explicit support, but works
 quay.io: sinc 2021
 Amazon ECR: supported
 pulp_container: since 2022
 flatpak: since first-OCI supporting version
 tardiff: since first version
2025-11-20 17:30:07 +00:00
Simon McVittie
06970e015f utils: Move more repository functionality into repo-utils
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-07-09 17:12:55 -03:00
Patrick Griffis
bb730ef8b8 Revert "Add support for files generated by appstreamcli compose (#5277)"
This reverts commit 88f7ecd000f84b75bd055ad6b6f92d7881e5e377.
2023-02-04 12:30:15 -06:00
Luna
88f7ecd000
Add support for files generated by appstreamcli compose (#5277)
Co-authored-by: Bartłomiej Piotrowski <b@bpiotrowski.pl>
Co-authored-by: Jamie Murphy <hello@itsjamie.dev>
2023-02-04 10:40:07 -06:00
Phaedrus Leeds
600e18567c Add a vim modeline and .editorconfig
To make indentation work with less effort. The modeline was copied from
libostree with minor modification and the .editorconfig from GLib.

The advantage of having both a modeline and an editorconfig is we can
work out of the box on more editor setups, and the modeline allows us to
specify the style with a lot more fine grained control.
2022-08-22 19:48:10 -07:00
Simon McVittie
c68f31d86a build: Consistently include libglnx header as "libglnx.h"
Recent Meson versions have warnings if you add the subprojects
directory as an include path, because the way Meson wants to consume
subprojects is by the subproject's build system producing a Meson
dependency object that encapsulates its include directory. Flatpak
doesn't have a Meson build system yet, but I'm working on that.

libglnx seems to be set up to have the libglnx directory be its include
path instead: for example, ostree (by the author of libglnx) already
uses "libglnx.h" or <libglnx.h> everywhere. Do the same here.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-04-11 10:32:34 +02:00
Alexander Larsson
e633fe0d81 Remove last uses of flatpak_decompose_ref() 2020-11-10 14:32:13 +01:00
Alexander Larsson
7483a98769 utils: Allow passing sizes to more utils
These now take (optional) string length args:
  flatpak_id_has_subref_suffix()
  flatpak_levenshtein_distance()
  flatpak_is_valid_name()
  flatpak_is_valid_branch()
2020-10-29 15:30:35 +01:00
Alexander Larsson
7fedf3578f OCI: Only use labels, never annotations
This is a slightly incompatible change, as we now only support
oci images generated with (what was before) build-export --oci-use-labels.
However, there are not a lot of OCI implementations in the wild, and
we can modify the ones in use to ensure there are labels (and
annotations if needed for older flatpak clients).

This also removes the --oci-use-label option from build-bundle --oci as
this is now the default.
2019-12-16 09:23:49 +01:00
Alexander Larsson
51fe0307ef OCI: Handle manifests without annotations in index.json
When we export a manifest to the index, always pass the ref we're
targeting instead of relying on the org.opencontainers.image.ref.name
annotation, because that may not be set if we're using labels instead.

This is no big deal, because we know what ref we're handling anyway.

Closes: #2978
Approved by: alexlarsson
2019-09-06 12:49:40 +00:00
Alexander Larsson
8f4082df6d build-bundle: Add --oci-use-labels switch
This allows the user to pick at runtime whether to use
annotations or labels as OCI metadata carrier. For historical
reasons annotations is the default, but some registries don't
support this and then you can use labels instead.

Closes: #2978
Approved by: alexlarsson
2019-09-06 12:49:40 +00:00
Alexander Larsson
be9961ecf6 oci: Always generate a history, quay needs this
Closes: #2978
Approved by: alexlarsson
2019-09-06 12:49:40 +00:00
Alexander Larsson
8416add254 Put annotations also in the labels
Closes: #2978
Approved by: alexlarsson
2019-09-06 12:49:40 +00:00
Alexander Larsson
af96ceb9eb OCI: Break out the annotation generation code into a helper
This doesn't change the behaviour, it just breaks out everything related
to flatpak-specific annotations into one place where it can be resued.

Closes: #2978
Approved by: alexlarsson
2019-09-06 12:49:40 +00:00
Matthew Leeds
5e65174e8d build-bundle: Fix resolving refs
Unfortunately in commit 253fcc6e3 I broke the build-bundle command so
that it is unable to resolve remote refs (as opposed to local ones).
This means in the normal case of building a bundle for an app installed
from a remote it fails:

$ flatpak build-bundle /var/lib/flatpak/repo gnome-calculator.flatpak org.gnome.Calculator stable
error: Refspec 'app/org.gnome.Calculator/x86_64/stable' not found

This is because flatpak_repo_resolve_rev() interprets a NULL remote name
to mean the ref is local (in refs/heads/) but in this case we just don't
know which remote it's from. This commit fixes the issue by using
ostree_repo_resolve_rev() directly which searches refs/heads/ and
refs/remotes/, and if that fails falling back to iterating over refs
returned by ostree_repo_list_collection_refs() to catch collection-refs
that may be in refs/mirrors/.

Also, add a unit test that fails without this patch.

Fixes https://github.com/flatpak/flatpak/issues/3026

Closes: #3032
Approved by: alexlarsson
2019-08-15 19:42:45 +00:00
Matthew Leeds
253fcc6e35 Made wider use of flatpak_repo_resolve_rev()
As described in the last commit message, it makes sense to move toward
using flatpak_repo_resolve_rev() rather than ostree_repo_resolve_rev()
for a few reasons:
1) It means we can use OSTREE_REPO_PULL_FLAGS_MIRROR which causes refs
to be pulled into repo/refs/mirrors/ rather than repo/refs/remotes/
which fixes a few edge cases of using collection IDs[1]
2) It falls back to using ostree_repo_resolve_rev() if
ostree_repo_resolve_collection_ref() fails so we can maintain backwards
compatibility for repo/refs/remotes/
3) It distinguishes between remote and local refs, and in the local case
uses OSTREE_REPO_RESOLVE_REV_EXT_LOCAL_ONLY and
ostree_repo_resolve_rev_ext() to make sure we don't for example
accidentally use a remote's repo metadata rather than the local repo's
metadata for the "flatpak repo" command.

So this commit changes every instance of ostree_repo_resolve_rev() in
the codebase to flatpak_repo_resolve_rev().

[1] https://github.com/flatpak/flatpak/issues/1832

Closes: #2705
Approved by: alexlarsson
2019-05-09 09:12:26 +00:00
Matthew Leeds
e8816b7663 Remove extra newlines in variable definiton blocks
Uncrustify has an option "nl_func_var_def_blk" which is supposed to
ensure there's a newline character between the block of variable
definitions and the rest of the function body, but it gets confused and
thinks that the first instance of "g_autoptr" or "g_auto" being used on
a variable is the start of the function body. So this commit removes
those extra newline characters and removes that option in uncrustify.cfg
so they don't get re-added the next time uncrustify is run.

Here's the command I used:

perl -0777 -i -pe 's/\n(\n\s*g_auto\()/\1/g' `git ls-tree --name-only
-r HEAD | grep \\\.[ch]$ | grep -v common/valgrind-private.h |
grep -v app/flatpak-polkit-agent-text-listener\\\.[ch]`

I ran it again with "g_autoptr" in place of "g_auto", and made a few
manual edits to add back the newline when the g_auto* was in the middle
of a function body rather than at the top.

Closes: #2715
Approved by: matthiasclasen
2019-02-25 18:12:30 +00:00
Matthias Clasen
d3488af5c7 build-bundle: Reorder options
This is purely cosmetic, but it just does not make
sense to have the --oci option show up in the middle
of gpg-related options.

Closes: #2528
Approved by: mwleeds
2019-01-03 22:22:48 +00:00
Matthias Clasen
aacc649158 build-bundle: Improve error handling
Don't fail in obscure ways if commandline options don't
look like files.

Closes: #2191
2018-10-17 17:53:50 -04:00
Owen W. Taylor
4dfa7721bb Remove unused etag functionality
Checking the registry against a previous etag is now handled inside
flatpak_cache_http_uri(), so remove the etag parameters that were
previously passed around in various places for simplicity.

Closes: #1910
Approved by: alexlarsson
2018-08-09 12:49:35 +00:00
Alexander Larsson
3f4518b15c Run uncrustify
Closes: #1870
Approved by: alexlarsson
2018-07-08 10:05:37 +00:00
Owen W. Taylor
8f73dbd32d Include appstream and icons in OCI bundles as annotations
Include annotations:

 org.freedesktop.appstream.appdata
 org.freedesktop.appstream.icon-{64,128}

into OCI bundles. This not only makes the bundle self-describing, but also
if the bundle is imported into a registry, it becomes possible to browse
the registry and recreate an appstream by only retrieving the annotations
for relevant images, without having to download the actual images.

The icon annotations are formatted as data: URI's with base64 data. The idea
is that a server-side process to collect annotations could extract the icons
to separate storage and rewrite the URI's to remote URL's.

Closes: #1834
Approved by: alexlarsson
2018-06-29 08:43:31 +00:00
Alexander Larsson
491d174879 Make p2p build non-optional
Closes: #1800
Approved by: alexlarsson
2018-06-19 18:10:56 +00:00
Alexander Larsson
960d20448c common: Rename all private headers to *-private.h
This is the start of the merging of lib/* into common/*

Closes: #1706
Approved by: alexlarsson
2018-05-24 11:59:52 +00:00
Matthew Leeds
f110da0019 app: Fix a typo 2018-05-15 21:07:16 -07:00
Alexander Larsson
7fd085acd7 appstream: Generate appstream2/$arch branches with uncompressed xml
These delta better, and the files will be downloaded as compressed
.filez objects anyway.

Closes: #1585
Approved by: alexlarsson
2018-04-20 10:10:33 +00:00
Patrick Griffis
00e13ff0bd build-bundle: Add --from-commit option
This allows building smaller bundles that are deltas
from a specific commit.

Closes: #1394
Approved by: alexlarsson
2018-02-12 14:48:08 +00:00
Alexander Larsson
d6ea398dd5 Remove GPG signatures handling for OCI images
This is not really standardized for now, and most registries
depend on TLS security instead.

Closes: #1171
Approved by: alexlarsson
2017-11-16 20:50:34 +00:00
Alexander Larsson
0b34a4ef6f OCI: Set arch when exporting oci bundle 2017-09-25 15:47:51 +02:00
Matthew Leeds
037a13cde0 completion: Make filename completions smarter
Many flatpak commands only work on *.flatpak or *.flatpakref files, so
the bash auto completion showing every file is distracting and
unnecessary. This commit makes flatpak only show relevant files when
possible by using the "-G globpattern" compgen option.
2017-09-12 16:14:43 +02:00
Philip Withnall
ae7d960372 common: Support collection IDs in flatpak{ref,repo} and bundle files
These are loaded from the ref/repo/bundle metadata and added to the new
remote configuration.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Alexander Larsson
68035c1e4e OCI: Support signing build-bundld --oci output 2017-03-29 17:14:36 +02:00
Colin Walters
64fd2c2a8d Bump libglnx, use new glnx_throw(), fix callers
One benefit here becomes immediately obvious - `flatpak_fail()` was lacking
`G_GNUC_PRINTF` which meant we missed a lot of type checking. Fix up the
callers.
2017-03-27 10:42:36 +02:00
Alexander Larsson
49b5304589 Update OCI support to latest version of spec
This is a major change in the OCI support, as the format of the OCI image
registries changed. Instead of now having a "ref" file for each image
in the repo it has a single index json file, where the ref name is now
a per-image annotation.

This allows us to support OCI much better, as we can now use the actual
flatpak ref as the OCI ref name, and we can find all the flatpak refs
in a remote.

So, with this you can just use:
 flatpak remote-add --oci remote-name URL

and then you can use the regular flatpak operations on the remote.
2017-03-13 14:31:36 +01:00
Alexander Larsson
2f50ad43cc build-bundle: Allow specifying a full ref
This is useful in some cases.
2017-03-13 14:31:24 +01:00
Alexander Larsson
f20e5f7823 bundles: Support dependencies and runtime-repo
If the bundle contains an origin link we can now install related
things from it, such as locale data.

You can also build the bundle with --runtime-repo=URL, where the url
points to a flatpakrepo file for a repo with runtimes. This works
similar to the RuntimeRepo= feature in flatpakref files.
2016-12-20 16:27:57 +01:00
Alexander Larsson
7267669ee1 build-bundle: Fix leaks 2016-12-19 11:16:17 +01:00
Alexander Larsson
9ddc4aca48 Support flatpak install --oci to install apps from OCI 2016-12-12 16:22:16 +01:00
Alexander Larsson
4672bc835e Update build-bundle --oci to use the new shared OCI support 2016-12-08 17:43:06 +01:00
Alexander Larsson
3896c8d683 Support relative pathnames in various --gpg=FILE commandline options
We juse use g_file_new_for_commandline_arg instead of g_file_new_for_path.
This is somewhat related to https://github.com/flatpak/flatpak/issues/401
but doesn't actually handle the specific case of tilde.
2016-11-15 10:44:26 +01:00
Alexander Larsson
6e31932221 OCI: Generate an oci image dir structure instead of a runtime 2016-10-31 20:11:14 +01:00
Alexander Larsson
f0380434e1 Remove check for OstreeRepoExportArchiveOptions.path_prefix
We now hard-depend on a recent enough ostree that has this.
2016-10-28 11:02:40 +02:00
Matthias Clasen
34e7158faf Warn about extra arguments in flatpak build-bundle 2016-09-27 14:30:11 +02:00
Matthias Clasen
06c7aca9f9 Make flatpak_is_valid_branch set a GError
Return detailed information about the problem with the branch in
the GError. Update all callers.
2016-09-13 13:28:42 -04:00
Matthias Clasen
b2b281e485 Make flatpak_is_valid_name set a GError
Return detailed information about the problem with the name in
the GError. Update all callers.
2016-09-12 23:25:54 -04:00
Alexander Larsson
6578d37984 Drop libgsystem dependency 2016-08-22 16:00:33 +02:00
Alexander Larsson
65f1cf993d Create and use flatpak_file_get_path_cached
This is simpler that the one in libgs, as well as lockless. Also, it
removes one more use of libgs.
2016-08-22 10:22:42 +02:00
Matthias Clasen
75218c4a65 Fix license headers
We were referring to the nonexisting "version 2" of the
Lesser GPL. It should be "version 2.1".
2016-07-29 14:27:49 -04:00