126 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
Sebastian Wick
0450c16fdb cli-transaction: Do not double free transaction ops
The transaction ops are a g_autolist(FlatpakTransactionOperation) which
means the list gets freed automatically. Calling g_list_free_full
without clearing the variable to NULL results in a double-free.

Closes: https://github.com/flatpak/flatpak/issues/5763
Fixes: 6e3cc82a ("Fix memory leaks")
Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
2024-04-04 14:49:34 -03:00
Hubert Figuière
6e3cc82af3 Fix memory leaks
Build with address sanitizer and run the tests

Signed-off-by: Hubert Figuière <hub@figuiere.net>
2024-02-13 08:20:57 -06:00
Simon McVittie
ae2579637a app: Move terminal-related utility functions from common into app
These functions are to do with being an interactive, terminal-oriented
CLI/TUI, so it would be inappropriate for library code in libflatpak
to call them, and it would also be inappropriate for daemons like the
session and system helpers to call them.

In fact all calls to these were already isolated to app/, so we can
easily move the terminal-related utilities themselves into app/.

As well as shrinking libflatpak, this makes it obvious that the system
helper does not actually need to call flatpak_disable_fancy_output():
it does not link any code that would be affected by that API call.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-07-03 20:19:00 +02:00
Philip Withnall
9a2d0413f5 app: Port transaction subclasses to use add_rebase_and_uninstall()
This fixes the possible situation where an eol-rebase app can be
uninstalled and the new version not correctly installed (due to, for
example, the install op failing due to a lack of disk space).

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #3991
2023-03-30 14:54:18 +02:00
Simon McVittie
409e34187d cli-transaction: Escape any special characters in the EOL reason
CVE-2023-28101, GHSA-h43h-fwqx-mpp8

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-03-16 09:54:14 +00:00
Ryan Gonzalez
6cac99dafe Ensure special characters in permissions and metadata are escaped
This prevents someone from placing special characters in order to
manipulate the appearance of the permissions list.

CVE-2023-28101, GHSA-h43h-fwqx-mpp8

Signed-off-by: Ryan Gonzalez <ryan.gonzalez@collabora.com>
2023-03-16 09:54:14 +00:00
Simon McVittie
522a933bc9 app: Use g_info() for messages that will be shown by flatpak -v
This brings us one step closer to being able to stop using the flatpak2
log domain for messages that are exclusive to `flatpak -v -v`.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-12-15 16:45:35 +00: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
Phaedrus Leeds
cf8979b1b0 app: Un-split translatable strings again
As with the previous commits, try not to split translatable sentences.
See the discussion here about whether the "Warning: "/"Error: " prefix
should be separable:
https://github.com/flatpak/flatpak/pull/4963#discussion_r908326539

Also, don't translate the "(internal error..." message since internal
errors shouldn't be translated to make debugging easier.
2022-07-23 14:18:50 -05:00
Phaedrus Leeds
0465c464af app: Remove a duplicated else if block 2022-07-23 14:18:50 -05:00
Phaedrus Leeds
da5a38c17c app: Un-split some translatable strings
Also make them a bit prettier while we're here

Fixes https://github.com/flatpak/flatpak/issues/4877
2022-07-23 14:18:50 -05:00
Phaedrus Leeds
bf2a0cc2ec app: Un-split EOL translatable sentences
Fixes https://github.com/flatpak/flatpak/issues/4956
2022-07-23 14:18:50 -05:00
Phaedrus Leeds
bf99c266a8 app: Tweak messages about dependent apps
Use a "Info: " prefix which matches the message printed in
print_eol_info_message(). Also make the message accurately use either
the word "runtime" or "extension" as appropriate.
2022-07-21 14:32:45 -05:00
Phaedrus Leeds
ae0de69b17 app: Improve checking for dependent apps in EOL messages
flatpak_dir_list_app_refs_with_runtime_extension() only works when the
runtime extension it is passed and the apps it returns are both
installed. Sometimes a end-of-life message is printed for a runtime that
is not installed but is being installed by the current transaction, or a
runtime that is installed but one of the apps that needs it is being
installed by the current transaction. To cover these cases, check the
operations in the current transaction when building informational
messages about EOL runtimes.
2022-07-21 14:32:45 -05:00
Phaedrus Leeds
e739773056 app: List apps that use a runtime extension when it's EOL
Currently if a runtime extension, e.g.
org.freedesktop.Platform.html5-codecs//18.08 is used by a runtime
org.kde.Platform//5.12 which itself is used by one or more apps, when we
print a message to the user about html5-codecs being EOL, we don't find
any apps using it and don't print any. Fix this by including apps that
indirectly use a runtime extension in the "Applications using this
runtime:" list.

In a later commit we can re-use the helper function added here to add a
confirmation dialog if the user tries to remove a runtime extension
that's being used; currently we just let them remove it.

This is limited to only looking in the current flatpak installation, so
a per-user app using a system-wide runtime extension would not be found.

This is implemented using in-memory caches because otherwise it is
horribly slow; see
https://github.com/flatpak/flatpak/pull/4835#discussion_r876425289

Helps: #3531
2022-07-21 14:32:45 -05:00
Phaedrus Leeds
f8d24a9b1e app: Use bold app ID for permissions heading 2022-06-15 16:44:17 -07:00
Phaedrus Leeds
1f7ff92c51 app: Improve end-of-life info message
I think the "app//branch" syntax is pretty ugly, and maybe not all users
understand it.

Helps: #3531
2022-06-15 16:44:17 -07:00
Phaedrus Leeds
4869437880 app: Fix typo in debug message 2022-06-15 16:44:17 -07:00
Phaedrus Leeds
388c23cfc5 Make test suite logs prettier
This fixes a few issues with the unit test logs that make them ugly:
1. Currently some lines of output from a command will appear after the
   line from xtrace which has the next command, since the command was
   printing to stdout and xtrace uses stderr. E.g. "Installation complete."
   will appear after "+ flatpak --user install -y ..." but it is from the
   previous install command.
2. Lines of output have many spaces after them to pad them to the table
   width but this is not needed for non-fancy output.
3. Lines of output are mixed with output from httpd since they don't end
   with a newline character, e.g. "Installing… ▊
   4%127.0.0.1 - - [16/Nov/2021 00:18:24] "GET /..."
2021-11-16 11:00:34 -08:00
Phaedrus Leeds
3aa9a7f3a1 app: Fix behavior when installing end-of-life-rebased ref
Currently if the user specifies a ref to install that has been renamed
via the end-of-life-rebased mechanism, for example "flatpak install
com.visualstudio.code.oss", Flatpak erroneously tries to install both
the old and new versions of the app. This happens because the code
handling end-of-life-rebase conditions is written assuming the rebased
app is being updated rather than installed for the first time.

Specifically, in FlatpakCliTransaction and FlatpakQuietTransaction, in
end_of_lifed_with_rebase(), we treat a failure of
flatpak_transaction_add_uninstall() as fatal and return FALSE from the
signal handler, which means that the install operation that triggered
the signal will not be skipped (see the docs for
FlatpakTransaction::end-of-lifed-with-rebase).

So, instead check for the FLATPAK_ERROR_NOT_INSTALLED error code and
ignore it, so that the installation of the old version of the renamed
app will be properly cancelled.

Fixes https://github.com/flatpak/flatpak/issues/3754
2021-11-15 11:13:51 +01:00
Phaedrus Leeds
86d6918a11 app: Don't use carriage return for non-fancy output
flatpak_fancy_output() determines whether the output we write is
intended for e.g. a tty or e.g. a log file, the latter being "not
fancy". Currently we write carriage return characters in the not fancy
case, but change that to new lines, which are interpreted correctly by
editors such as vim (whereas a carriage return shows up as ^M since it
is not the correct newline character on Unixy operating systems).
2021-11-15 09:57:09 +01:00
Alexander Larsson
515ae5e5df CLI: List arch if it is not the primary arch (even if unique)
Currenly we only list arch in the list of things to install from a
transaction if not all the refs are the same arch. It makes more sense
to show the arch even if its unique if they are not the primary arch.
2021-05-19 09:54:59 +02:00
Simon McVittie
c2490aad12 app: Use autocleanup for FlatpakTablePrinter
Fixes: https://github.com/flatpak/flatpak/issues/4223
Fixes: https://github.com/flatpak/flatpak/issues/4224
2021-04-16 14:51:47 +02:00
Phaedrus Leeds
2a8602ed88 app: Swap order of rebase/uninstall calls
In case the second of these two fails, the first will still have been
added to the transaction. And since it's better to install the renamed
app but not uninstall the old one, than to uninstall the old one but not
install the new one, swap the order.

See also https://github.com/flatpak/flatpak/issues/3991
2020-12-09 09:03:31 +01:00
Alexander Larsson
c4d2d6f0a9 cli: Show branch in eol messages 2020-11-16 11:23:10 +01:00
Alexander Larsson
7eb5f4ddc8 cli-transaction: Better handling of EOL refs
We remember what action we took for EOLs, and for sub-refs (ie .Locale)
we reuse that.

Also, we show if eol:ed refs are pinned (as that makes them not be
auto-uninstalled), and we list the apps that use the eol:ed runtime
ref.

Example run:
```
Looking for updates…
Info: (pinned) org.gnome.Sdk.Compat.i386 is end-of-life, with reason:
   The GNOME 3.34 runtime is no longer supported as of 14th August 2020. Please ask your application developer to migrate to a supported platform.
Info: org.gnome.Platform is end-of-life, with reason:
   The GNOME 3.32 runtime is no longer supported as of 11th March 2020. Please ask your application developer to migrate to a supported platform.
Applications using this runtime:
   org.gnome.HexGL
```
2020-11-16 11:23:10 +01:00
Alexander Larsson
3d8c04db50 CliTransaction: Use the FlatpakDecomposed from the transaction
There is no need to re-split the ref.
2020-11-10 14:32:13 +01:00
Alexander Larsson
8dc9318346 CliTransaction: Only print "partial" in the actual partial case
We used to match the ref id with .Locale and print "partial" in the
transaction status, but that is not right. Sometimes we do other refs
partially and sometimes locales are not partial. We now use the status
of the subpaths to do the right thing here.
2020-11-10 14:32:13 +01:00
Alexander Larsson
aec1f62f8f CLI: Ask for transaction confirmation before authentication
If possible, ask for confirmation of the entire transaction before
starting to do the per-ref authentication. We do this by splitting
the current "ready" callback into two parts, one in ready-pre-auth
and the rest in ready.

There is some complexity added because if we do any authentication
between the two signals we can't back-patch the transaction list we
already printed. To handle this we detect this case and re-print the
table if this happens.
2020-10-09 16:57:57 +02:00
Alexander Larsson
b5a9903efc cli: Automatically install authenticator as needed 2020-06-22 10:51:36 +02:00
Alexander Larsson
bfa3b15435 Transaction: Add "previous-error" option to basic auth error
Also, send this for the oci authenticator.
2020-06-09 14:52:00 +02:00
Alexander Larsson
0978826c2e Add and use per-transaction no-interaction option
This is useful if to avoid changing the no-interaction of the whole
FlatpakInstallation. Also, having this per transaction lets us
clean up the code in FlatpakQuietTransaction a bit.
2020-06-09 10:38:25 +02:00
Léo Stefanesco
66dfb63075 Fix segfault when reporting error during install
flatpak_dir_install was returning FALSE but leaving error to NULL, which
would crash when printing the error.

Fixes #3646
2020-06-05 17:02:45 +02:00
Abderrahim Kitouni
a18db1d646 cli-transaction: properly format '1.0 kB'
it's irritating to have it this way when everything else uses a comma as
a decimal separator

use the same trick for the total too
2020-03-26 21:24:47 +01:00
Matthew Leeds
bbd4ee68b4 app: Don't print "< 0 bytes"
Don't imply a download or install uses a negative number of bytes.
2020-02-12 16:45:41 +01:00
Alexander Larsson
e645424e69 Cli-transaction: Fix leak
We didn't free the table printer used.
2019-12-17 14:55:13 +01:00
Alexander Larsson
e08cee0e82 authenticator: Use g_app_info_launch_default_for_uri() to launch browser
This way we get the system default. We still respect BROWSER if set
which is useful for e.g. the tests or scripts.
2019-12-12 14:27:59 +01:00
Alexander Larsson
474b0573e3 authentication: Remove accidental leftover debug spew 2019-12-12 14:27:59 +01:00
Alexander Larsson
38c86bdf0f Authenticator: Add extra a{sv} args for future use
These are not used atm, but make the APIs future proof.
2019-12-12 14:27:59 +01:00
Alexander Larsson
1ec4232fd5 CLI: Handle basic auth in transactions 2019-12-12 12:16:53 +01:00
Philip Chimento
923beec024 Change "update-frequency" to "update-interval"
An event happens more often as its frequency gets higher, so these
values were confusing me.

Rename the constants to include their unit (ms) as well, to avoid
confusion.

Anything that affects public API (such as
flatpak_transaction_progress_set_update_frequency()) or libostree's
options passed to ostree_repo_pull_with_options(), is left as is.
2019-12-06 13:26:49 -08:00
Matthias Clasen
653fce251f cli: Don't use \r in plain output
These show up as ^M in test logs, and that is irritating.
Just use \n when producing plain output.

Closes: https://github.com/flatpak/flatpak/issues/3226
2019-12-04 13:30:13 +01:00