Commit Graph

1611 Commits

Author SHA1 Message Date
Sebastian Wick
e4edecdef5 utils-http: Drop libsoup2 support in favor of libcurl
A few years ago there was a very painful attempt at porting from
libsoup2 to libsoup3. Flatpak libsoup3 support never landed and it seems
like a large amount of distros have switched over to libcurl instead.

This commit removes libsoup2 support completely instead of growing
libsoup3 support.

Closes #5915
Closes #4582
2025-11-20 17:40:57 +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
Emir SARI
944c0908e1 cli-transaction: improve i18n
- Make percent values translatable

  Various languages use different ways to format the percentage
  values[1], making it translatable will allow a more coherent way to
  display the information.

- Make remaining time abbreviation translatable

  Making this value translatable will allow languages to display the
  seconds abbreviation in their language. This is particulary an issue
  for Turkish, in which hours and seconds start with the same letter, so
  it's not possible to distinguish which is which. We use a second
  letter (sa, sn) to figure it out.

[1] https://en.wikipedia.org/wiki/Percent_sign#Form_and_spacing

Signed-off-by: Emir SARI <emir_sari@icloud.com>
2025-11-20 15:20:59 +00:00
Sebastian Wick
947d4a6ce4 flatpak: Enable progress escape sequence by default
In 4febfb59 ("flatpak: Disable progress escape sequence by default") the
escape sequence has been disabled by default, but we want to enable it
again for 1.18.
2025-11-18 01:19:36 +00:00
Sebastian Wick
8354ee56cf kill: Do not kill pid 0 and embrace races
There are a number of races, and failure conditions which can lead to a
pid of 0 being returned from flatpak_instance_get_child_pid. This would
lead to a whole bunch of things getting killed.

We will skip the instance in those cases now, and retry a few times. We
also notice when the instance just goes away by itself now.

This should make killing more robust, and especially not SIGKILL pid 0.
2025-10-31 12:04:55 +00:00
Georgia Garcia
f61d931da8 common: Fix running_under_sudo check by checking euid
Sudo can be used in several ways other than calling a command with the
root user. For example, one can use -u to run the command as the
specified user, or -g to specify a primary group to run the command
as.

Flatpak adds a check when --user is used to prevent an installation in
the root's directory, for example, but it does it by only checking if
sudo was used. As stated previously, it does not necessarily imply
root, so this patch explicitly checks if the command is being run with
the root user.

Fixes: https://github.com/flatpak/flatpak/issues/5979
Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>
2025-10-28 13:17:13 +00:00
Sebastian Wick
edac357aad builtins/install: Allow flatpak+https URIs in flatpak install --from
Those schemes are in use by flathub, usually to be handled by an app
store, but we can also handle it directly with `flatpak install`.

Base on an idea from user bbb651 in
https://github.com/flatpak/flatpak/pull/6259.
2025-10-28 12:55:59 +00:00
JakobDev
3544de6251 build-finish: Export AppStream external release metainfo
The appstream docs say:

  Release data may be present directly in a component metainfo file, but
  also optionally be split out into an external metadata file.

  The file must be installed as
  /usr/share/metainfo/releases/%{cid}.releases.xml, where cid is the
  component ID of the component the release information belongs to.

This change allows flatpak build-finish to export those external release
files.

Closes #6057
2025-10-28 10:22:45 +00:00
Sebastian Wick
3e9e68cc5d Support sideload repositories for OCI remotes
For OCI remotes, the existing sideload repository system doesn't
work: identity for OCI remotes is done by manifest digest (disguised
as a fake commit ID internally), instead of by ostree commit, so
we have no way of knowing whether a sideloaded image matches the
summary.

Allow specifying a new form of sideload repository with:

  --sideload-repo=oci:<path>

The desired use case for this is preinstalling Flatpaks during OS
install, and for this, binding the entire repository to a single
collection ID is both inconvenient and not useful, so OCI sideload
repostories don't have a defined collection ID - they just apply to
all OCI remotes. (And, because of this, they are restricted to
the command line.)
2025-10-24 16:27:33 +00:00
Sebastian Wick
f7671ebbc9 dir: Support sideloading from OCI repos/archives
This is implemented in a straightforward way by adding GFile
*sideload_path, FlatpakImageSource *image_source.
2025-10-24 16:27:33 +00:00
Sebastian Wick
0a3c2452c0 flatpak-build: Drop host permissions by default
For some reason, flatpak build always had host permissions set by
default. There really isn't a good reason for this. The build should be
isolated from the host as much as possible by default.
2025-10-13 19:24:50 +00:00
bbhtt
0bf531f44a dir: Add basic OS info to Flatpak-Os-Info header when pulling objects
Fixes https://github.com/flatpak/flatpak/issues/5549
2025-10-13 18:52:55 +00:00
Sebastian Wick
a92c5f686e context: Support condtional permissions for socket and devices
This uses the new FlatpakPermissions API to support the new
commandline options --socket-if= and --device-if=.
2025-10-13 18:31:33 +00:00
Adian Kozlica
4f8b935567 feat: json support for table printer 2025-10-13 13:53:15 +00:00
Sebastian Wick
f760f1b539 run: Add --clear-env option for clearing the outside environment 2025-10-09 18:02:50 +00:00
Kalev Lember
d10e11482d Add initial support for preinstalling flatpaks
This adds new FlatpakTransaction API, and a new top level CLI command to
preinstall flatpaks, that is to install flatpaks that are considered
part of the operating system.

A new drop-in directory /etc/flatpak/preinstall.d/ allows configuring
what apps should be preinstalled, and a new flatpak preinstall command
installs and removes apps based on the current configuration.

A drop-in loupe.preinstall file can look something like this:

[Flatpak Preinstall org.gnome.Loupe]
Branch=stable
IsRuntime=false

The corresponding API is flatpak_transaction_add_sync_preinstalled()
which can be implemented by GUI clients to drive the actual installs
on system startup.

Resolves: https://github.com/flatpak/flatpak/issues/5579
Co-authored-by: Sebastian Wick <sebastian.wick@redhat.com>
2025-08-26 11:51:07 +00:00
Owen W. Taylor
609f0ce0a1 common: Move delta_url into the FlatpakImageSource
Instead of passing the delta URL along with the image source, when
we create an image source for a remote registry, if we find a delta
URL in the metadata, set it on the FlatpakImageSource for later use.

Centralize duplicated code for creating an image source for a remote
repository based on a summary lookup into one place.
2025-08-25 15:56:20 +00:00
Owen W. Taylor
a460dd5069 image-source: Support oci-archive: image sources
Add support for `oci-archive:` image sources by temporarily
unpacking the archive using libarchive.

Co-authored-by: Sebastian Wick <sebastian.wick@redhat.com>
2025-08-25 15:56:20 +00:00
Owen W. Taylor
eee21d5a27 builtins/install: Allow direct installation from OCI images
Similar to bundle installs, add:

 flatpak install [--image] docker://registry.example.com/image:latest
 flatpak install [--image] oci:/path/to/image

These is useful for testing purposes and in certain cases when installing
Flatpaks on disconnected systems.
2025-08-25 15:56:20 +00:00
Sebastian Wick
ee9d25dfe2 builtins/install: Create install transaction in common function 2025-08-25 15:56:20 +00:00
Owen W. Taylor
5950438ca7 image-source: Replace flatpak_oci_parse_commit_labels with getters
Instead of having one function with a pile of out arguments in
arbitrary order, add getters to FlatpakImageSource.
2025-08-25 15:56:20 +00:00
Owen W. Taylor
59ad08e78c image-source: Refactor - add FlatpakImageSource type
To avoid passing around combinations of a FlaptakOciRegistry with
repository and digest, add a FlatpakImageSource type.

This also reduces duplicated code where every place that did
this independently retrieved the repository and image config.
2025-08-25 15:56:20 +00:00
Johannes Maibaum
054f4f4a7b flatpak-build: Add empty /run/host/font-dirs.xml
flatpak run writes /run/host/font-dirs.xml, but flatpak build so far
didn't.  This resulted in fontconfig writing:

Fontconfig error: Cannot load config file "/run/host/font-dirs.xml": No such file: /run/host/font-dirs.xml

to the stderr of all processes utilizing fontconfig and run during
flatpak build, as /run/host/font-dirs.xml is included via
/etc/fonts/50-flatpak.conf. This could cause issues for tests run during
building an application, for example.

Closes #6137
2025-08-20 18:24:33 +00:00
yu shuoqi
51452a7bf5 list, uninstall: Add simple output to two commands
Closes: https://github.com/flatpak/flatpak/issues/6197
2025-08-06 11:14:44 +00:00
Chris Williams
8f87b6ea08 permission-reset: Avoid setting unchanged table entries
This reduces the best case (no-op) execution time from ~900 ms to <100
ms on my system.

Closes #5772
2025-02-21 19:14:01 -06:00
Chris Williams
9a61ba7f7d uninstall: Skip in-use runtime check with --unused
confirm_runtime_removal() doesn't know about autoprune-unless
extensions, so it prompts unnecessarily when they're removed by
`flatpak uninstall --unused`. To avoid this, we can simply skip it and
trust flatpak_dir_list_unused_refs().

Closes #5712
Helps #2718
2025-02-21 19:12:46 -06:00
Bartłomiej Piotrowski
050f6e35fe prune: Skip calculating potential freed space in the dry run 2025-02-11 13:00:24 +01:00
Chris Williams
97c922f430 cli-transaction: Don't print fatal transaction error twice
Just clear the line and let the error be printed once in main().

Closes #3400
2025-02-10 14:12:20 -06:00
Chris Williams
402b13e32a search: Enable completion of command-specific options 2025-02-10 14:10:22 -06:00
Christian Hergert
6445ebdb24 tty-utils: use ANSI_ST to terminate OSC sequence
The VTE project has requested that we terminate our OSC sequence with
ANSI_ST rather than \007 (BEL) and may enforce this in the near future.
2025-02-07 11:06:53 -06:00
Georges Basile Stavracas Neto
4febfb5973 flatpak: Disable progress escape sequence by default
And add the FLATPAK_TTY_PROGRESS env var to re-enable it.

This seems to only be supported by recent versions of terminal emulators
which will cause problems with shipping Flatpak on older distros.

Closes https://github.com/flatpak/flatpak/issues/6052
2025-01-09 17:22:19 +01:00
Will Thompson
2eb4819240 Fix "end of line" typo in internal #defines
The ostree and Flatpak APIs both refer to "end of life", but
this internal #define (though not the data stored in the cache)
refer to "end of line".

Fix this.
2025-01-09 17:00:07 +01:00
Christian Hergert
a1bfc19d49 flatpak: emit progress escape sequence
Following on systemd adopting the progress OSC that ConEmu and Windows
Terminal use, this exports the progress percentage to the terminal
emulator.

VTE also has support for this in the upcoming 0.80 release and is used
by Ptyxis to display progress in the tab widget.
2024-12-15 02:39:23 +01:00
Maximiliano Sandoval
dc2ce2cb0b app: Check for component name when searching
We add the component name as part of the fallback search.

Before this patch, queries as

    flatpak search Element

or

    flatpak search d-spy

return no results even though the search term coincides with the
application name.
2024-10-17 18:20:07 -05:00
Hubert Figuière
1beff8e577 flatpak-cli-transaction: show the USB portal permissions
Signed-off-by: Hubert Figuière <hub@figuiere.net>
2024-10-16 14:11:56 -03:00
Simon McVittie
3498ecf9ab app, common, tests: Avoid deprecated g_qsort_with_data()
For historical reasons g_qsort_with_data() "only" works with up to 2**31
items, so it won't necessarily work for pathologically large arrays
and therefore is deprecated.

One advantage of g_qsort_with_data() and its replacement g_sort_array()
is that GLib guarantees that they are a stable sort (will not permute
items that already compare equal), which is not a guarantee for glibc's
qsort() and qsort_r(). However, I don't think it's actually relevant
whether we are doing a stable sort in any of these places: most of the
time we are sorting an array of unique items (often the keys of a hash
table, which are necessarily unique), therefore the compare function
will not compare equal in any case.

Another advantage of the GLib functions is that they are portable,
unlike qsort_r(). However, Flatpak is Linux-only, so we can freely use
useful functions like qsort_r().

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-10-15 13:53:07 +01:00
Cajus Pollmeier
fb37012475 Add support for KDE search completion
KDE krunner supports DBus plugins that allow search completion
comparable to the already supported gnome-shell searchprovider.

Exporting the contents of the runner directory enables us to enable
search results from within flatpack applications.
2024-10-07 09:31:47 -05:00
Kalev Lember
dce9ccb3d7 builtin-utils: Remove dead code branch and simplify
Commit f268f4a870 that changed
flatpak_resolve_matching_remotes() to automatically pick the remote if
it's the only matching one, missed an opportunity to clean up the rest
of the function.

Now that `remote_dir_pairs->len == 1` is handled as a first case, we can
drop the old, dead code that handled it differently, and simplify the
nested conditionals.
2024-09-05 16:54:49 -03:00
Simon McVittie
5d62a6d80b utils: Add flatpak_is_debugging()
This can be used to disable code paths that assemble relatively
"expensive" debug information when debugging is not enabled.
It's activated by `flatpak -v -v`.

With a sufficiently modern GLib version, it also activates for
`G_MESSAGES_DEBUG=all` or `G_MESSAGES_DEBUG=flatpak`.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-08-23 08:39:00 -03:00
Simon McVittie
fc1b32e97b table-printer: Slightly increase const-correctness
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-08-22 15:17:13 -03:00
Simon McVittie
f7003e00c0 complete: Slightly increase const-correctness
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-08-22 15:17:13 -03:00
Simon McVittie
97cddd6e48 utils: Move more repository functionality to repo-utils
This further reduces circular dependencies: utils no longer has a
circular dependency with repo-utils or xml-utils.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-07-09 17:12:55 -03: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
Simon McVittie
c98a7c024f utils: Move OstreeRepo configuration accessors to a new translation unit
This is a step towards removing the libostree dependency from
flatpak-utils, which should be one of the lowest-level components.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-07-09 17:12:55 -03:00
Simon McVittie
14db9d48cf common: Break out the parts of flatpak-utils that deal with FlatpakDir
This breaks the circular dependency between flatpak-utils and flatpak-dir.
There is still a circular dependency between flatpak-dir and
flatpak-dir-utils, but I don't want to make flatpak-dir even larger.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-07-09 17:12:55 -03:00
Simon McVittie
3c82620bab repo-utils: New header for some implementation details of a repository
This will reduce circular dependencies involving FlatpakDir.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-07-09 17:12:55 -03:00
Hubert Figuière
92d7f9ec49 flatpak-permissions: Fix a memory leak
This occur by just running flatpak permission <SOME APP>

Signed-off-by: Hubert Figuière <hub@figuiere.net>
2024-06-27 20:55:50 -04:00
Hubert Figuière
ef575a40da Fix a memory leak in flatpak-update
Close https://github.com/flatpak/flatpak/issues/5816

Signed-off-by: Hubert Figuière <hub@figuiere.net>
2024-05-23 22:47:04 -05:00
Simon McVittie
6e81bc6f28 common: Move functions for dealing with AppStream XML to their own file
This seems like an obvious set of functionality to be grouped together
in service of the wider goal of making flatpak-utils smaller and more
manageable.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-05-03 13:21:29 +01:00
Simon McVittie
a01371ce02 common: Move flatpak_context_get_allowed_exports to FlatpakContext
This allows us to break a circular dependency between utils and context.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-05-03 13:21:29 +01:00