Commit Graph

1627 Commits

Author SHA1 Message Date
Debarshi Ray
48e7bf32ec builtins-utils: Remove unused function
Fallout from 0221f5a1fa
2026-03-12 19:20:55 +05:30
Debarshi Ray
d7f83c0db1 document-unexport: Fix a -Wanalyzer-null-dereference warning
OpenScanHub [1] triggered this and flagged it as CWE-476 [2]:
  app/flatpak-builtins-document-unexport.c:90:7:
      warning[-Wanalyzer-null-dereference]: dereference of NULL ‘doc_id’
  app/flatpak-builtins-document-unexport.c:48:1: enter_function: entry
      to ‘flatpak_builtin_document_unexport’
  app/flatpak-builtins-document-unexport.c:56:20: release_memory:
      ‘doc_id’ is NULL
  app/flatpak-builtins-document-unexport.c:61:6: branch_false: following
      ‘false’ branch...
  app/flatpak-builtins-document-unexport.c:66:7: branch_false: ...to
      here
  app/flatpak-builtins-document-unexport.c:66:6: branch_false: following
      ‘false’ branch...
  app/flatpak-builtins-document-unexport.c:69:6: branch_false: ...to
      here
  app/flatpak-builtins-document-unexport.c:69:6: branch_false: following
      ‘false’ branch...
  app/flatpak-builtins-document-unexport.c:72:3: branch_false: ...to
      here
  app/flatpak-builtins-document-unexport.c:75:6: branch_false: following
      ‘false’ branch...
  app/flatpak-builtins-document-unexport.c:78:15: branch_false: ...to
      here
  app/flatpak-builtins-document-unexport.c:82:6: branch_false: following
      ‘false’ branch...
  app/flatpak-builtins-document-unexport.c:85:7: branch_false: ...to
      here
  app/flatpak-builtins-document-unexport.c:85:6: branch_true: following
      ‘true’ branch...
  app/flatpak-builtins-document-unexport.c:86:14: call_function: inlined
      call to ‘g_strdup_inline’ from ‘flatpak_builtin_document_unexport’
  app/flatpak-builtins-document-unexport.c:90:7: release_memory:
      ‘doc_id’ is NULL
  app/flatpak-builtins-document-unexport.c:90:7: danger: dereference of
      NULL ‘doc_id’
  #   88|       return FALSE;
  #   89|
  #   90|->   if (strcmp (doc_id, "") == 0)
  #   91|       {
  #   92|         g_print (_("Not exported\n"));

Add an assertion to express that 'doc_id' can't be NULL unless there's a
programmer error.

Spotted by Siteshwar Vashisht.

[1] https://openscanhub.dev/

[2] https://cwe.mitre.org/data/definitions/476.html
2026-03-11 22:31:49 +00:00
bbhtt
50d9a2f735 builtins-update: Respect opt_noninteractive in update_appstream()
Use opt_noninteractive instead of hardcoded values so AppStream
refresh is quiet only when --noninteractive is specified. This allows
to show a better messsage instead of repeating and makes the errors
visible as well.

Related: #5716
2026-03-02 16:42:31 +00:00
matt
f256990331 builtins-update: Show a better message when there are no refs to update
Replace the "Nothing to do" message with "Nothing to update." when no
refs have updates available which is slightly clearer.

Fixes: #5716

Co-authored-by: Patrick <github.calorie764@passmail.net>
Co-authored-by: bbhtt <bbhtt.zn0i8@slmail.me>
2026-03-02 16:42:31 +00:00
Qiheng He
b37f739721 main: Default to text auth on WSL
Since this bug can be reproduced on Ubuntu, Debian, and Fedora, we should set `FLATPAK_FORCE_TEXT_AUTH=1` for all WSL users instead of ignoring its existence. After all, the so-called `graphical prompt` in the flatpak documentation seems to be something unique to GNOME. `WSL_DISTRO_NAME` and `WSL_INTEROP` are both located at https://github.com/microsoft/WSL/blob/master/src/linux/init/util.h .
2026-02-07 15:17:33 +05:30
Reilly Brogan
9380e0c66c fix: Build with glibc 2.43
Several glibc functions now return a const pointer if the input is a const pointer and a non-const pointer if the input is non-const, causing a build failure.

Fix this by declaring the output pointers as const if they are never modified and for the lone failure where the output is modified instead make the input non-const.
2026-02-02 18:54:08 +05:30
rezky_nightky
bb54916814 fix: cross typos, detail below
What I did
Repository rules / “don’t edit” areas
From CONTRIBUTING.md and subprojects/README.md, subprojects/ contains vendored/submodule/copylib code (bubblewrap, libglnx, dbus-proxy, variant-schema-compiler). I treated subprojects/ as third-party and excluded it from typo fixing.

You already skip po/ (translations) and node_modules/, and I kept those exclusions.

Typos fixed (project-owned files only)
I ran codespell with write mode and exclusions, and fixed the reported typos across:

NEWS
app/…
common/…
doc/…
tests/…
session-helper/…
portal/…
data/…
Then I handled the remaining items individually:

NEWS: thse -> these
common/flatpak-utils-private.h: Thse -> These
app/flatpak-polkit-agent-text-listener.c: identies -> identities
tests/test-auth.sh: Propertly -> Properly
tests/testlibrary.c: remore -> remote
common/flatpak-transaction.c: improved wording to avoid the xwindows typo (X11 window ID)
Added .codespellrc
Created .codespellrc:

skip: node_modules,po,subprojects
ignore-regex: .*(ratatui|Affinitized|affinitized).*
ignore-words-list: nd,ot,THUR,IST,fo,hel,bu
(these were confirmed as legitimate tokens/abbreviations/namespace prefix/test strings in this repo, so they should not be “fixed”)
Verification:

codespell --config .codespellrc . now exits clean.

Signed-off-by: rezky_nightky <with.rezky@gmail.com>
2026-01-21 17:58:19 +00:00
vgdaut
d38343194b install, uninstall: Fail if non-interactive and multiple refs, remotes or installations match 2026-01-15 17:45:39 +00:00
Christian Hergert
c896faae19 app: be selective about when to map font-dirs.xml
If the command calling `flatpak build` has already specified a
font-dirs.xml to map, then mapping in again may break (as exemplified in
Builder and Foundry).

This checks to see if an argument has already been mapped in before doing
so and resolves the issue with Builder/Foundry.

Follow-up to !6138

Fixes: GNOME/gnome-builder#2387
2026-01-13 16:34:55 +00:00
Sabri Ünal
fa4da960e1 typo: Fix URL usages
Url > URL
url > URL
2026-01-05 21:16:15 +05:30
Sabri Ünal
10cf402ea2 i18n: Update two strings
In the following usages, the "Install:" and "Download:" strings were used as a short form
of the "Download Size" and "Installed Size", which makes translation tricky.

Therefore, using the normal forms will be good from the translation side.
2026-01-05 13:51:30 +00:00
Sabri Ünal
5136ef48f8 i18n: Add comments for translators
The string "download" can be both a noun and a verb.

Here, "download" is used as a noun.
2026-01-02 14:37:29 +00:00
Sebastian Wick
6667e1d361 context: Use the new permission system for shares and features
This gives us conditionals for shares and features. So far we have no
use case for this, but the system already exists, it makes the code
simpler, and when we need this in the future, we don't have to wait for
it to roll out.
2025-12-08 19:33:09 +00:00
Owen W. Taylor
404aa33ce1 common: Check signatures when installing OCI images
Co-authored-by: Sebastian Wick <sebastian.wick@redhat.com>
2025-12-08 19:09:56 +00:00
Owen W. Taylor
841f33e451 app: Add a "signature lookaside" repository configuration
Allow specifying a lookside URL for downloading signatures for
an OCI remote. This can be specified:

 In a .repofile with the SignatureLookaside key
 As the --signature-lookaside option to remote-add/remote-modify
2025-12-08 19:09:56 +00:00
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
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