Commit Graph

1384 Commits

Author SHA1 Message Date
Alexander Larsson
ed192e1044 remote-ls: Add a smarter fallback for names if appstream is missing
Rather than just taking the last element of the name we also
look at known extensions like .Platform, .Sdk, .Debug, .Locale, etc.
2020-11-05 10:43:10 +01:00
Alexander Larsson
e1da8d9455 remote-ls: Use list_decomposed() 2020-11-05 10:43:10 +01:00
Alexander Larsson
a60e2cbe2d Remove some unused variables 2020-10-29 15:30:35 +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
f147df908a repo: Support indexed summaries in existing code and add new support
If indexes are available we now use those. Also we now allow listing
subsummaries and filtering by subset prefix.
2020-10-29 15:30:35 +01:00
Alexander Larsson
caa1c8c839 table printer: Add some helpers
Allow looking up pre-existing rows (by key) and appending to existing
cells.
2020-10-29 15:30:35 +01:00
Alexander Larsson
0221f5a1fa summaries: Ensure we can support non-default arches W/ indexed summaries
We need to load the ensure the right arch whenever we need it.

Also this restructures the RemoteState handling a bit in general so that
we avoid loading the same remote state multiple times when converting
partial refs to full refs.
2020-10-29 15:30:35 +01:00
Alexander Larsson
0d2cf085af Add option to disable generating summary index
This is mainly useful for the tests
2020-10-29 15:30:35 +01:00
Alexander Larsson
096daf91f2 summary: Implement a new, more efficient, summary format
This drops the deltas from the summary and uses the per-commit
metadata field to add the cache data to avoid the need for the separate
xa.cache and xa.sparse-cache indexes. This way we avoid repeating the
refs in multiple places.

Nothing uses this format yet, but we still pass make check if we enable
it.
2020-10-29 15:30:35 +01:00
Alexander Larsson
97fa217072 build-commit-from: Add --subset option
This sets the xa.subsets property on the commit, which we will later
use to create subsets of the repo.
2020-10-29 15:30:35 +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
Ryan Gonzalez
719eeee461 build-init/finish: Validate extension names
Otherwise, it becomes easy to accidentally create extensions with
invalid names. Ref #3887.
2020-10-08 09:46:49 +02:00
Ryan Gonzalez
9959fd80e9 repair: Add basic and "fancy" verify progress
This change makes repair print the current ref number being verified
and the total number, that way the user can observe the repair progress.
In addition, if fancy output is not disabled, the progress will be
cleanly printed on a single line.

On a dry run, this also will still print the delete messages without
actually performing the operations, to show what actions would be
taken on a non-dry-run.
2020-10-08 09:17:28 +02:00
Alexander Larsson
a5d86b8acb transaction: inject eol status to flatpak_dir_list_unused_refs()
This way we can get the proper eol status for the new to-be-installed
refs, rather than whatever was previously installed. This allows us to
detect when a runtime is updated and the new one is eol, and nothing
uses it, so it can be auto-uninstalled.
2020-10-08 09:14:51 +02:00
Alexander Larsson
05a7bda140 transaction: Simplify add_uninstall_unused_ops()
Rather than trying to figure out which runtimes are affected byt
the current setup of ops we run flatpak_dir_list_unused_refs() twice,
once with and once without the changes the transaction will cause.

Any unused refs after the transaction that were not unused before are
caused by the transaction and we start uninstall ops for those.

Also rename flatpak_dir_list_unused_refs_with_options() to
flatpak_dir_list_unused_refs() as it need not be so long.
2020-10-08 09:14:51 +02:00
Alexander Larsson
e83180e040 install: Add --no-auto-pin option
We want to use this for the test when we test the list unused refs
functions.
2020-10-08 09:14:51 +02:00
Phaedrus Leeds
7691fc77eb app: Remove EOL unused runtimes in update command
In case a runtime becomes unused and then later becomes End-Of-Life, it
is currently not removed. So this commit removes such runtimes in the
update command, as discussed in #2639. A unit test is included.

I am planning to propose to use the FlatpakTransaction API added here in
gnome-software, so that users don't have to use the CLI at all for
runtimes to be cleaned up. KDE Discover already removes unused runtimes
periodically.
2020-10-08 09:14:51 +02:00
Alexander Larsson
aa55d0088f uninstall: Use flatpak_dir_list_unused_refs_with_options()
No need to use the FlatpakInstallation version, because we just
needs the refs as strings, not FlatpakInstalledRef:s
2020-10-08 09:14:51 +02:00
Phaedrus Leeds
55f6abe578 Avoid string duplication in FlatpakRef
Allocate a full ref string once per object rather than once per call.
This is similar to what we do in flatpak_dir_get_name_cached().
2020-10-02 15:30:58 +02:00
Phaedrus Leeds
d7c481aff8 build-commit-from: Fix whitespace 2020-09-15 08:58:49 +02:00
Phaedrus Leeds
baa5ba2e8d remote-info: Remove duplicate warning 2020-09-15 08:58:49 +02:00
Phaedrus Leeds
08f692962e Avoid shadowing local variables
Avoid shadowing variables that are already declared in a previous scope,
and make such occurrences compile-time errors. These are not functional
changes.

In a few places do related code cleanup.

A similar ostree PR is here:
https://github.com/ostreedev/ostree/pull/2195
2020-09-15 08:58:49 +02:00
Phaedrus Leeds
d7cca22d7c info: Only load from specified installation
flatpak_find_deploy_for_ref() will look for a deploy across all
installations, but we want to use the user-specified one, e.g. user if
--user was passed.

Pointed out here:
https://github.com/flatpak/flatpak/pull/3853#discussion_r487711857
2020-09-15 08:58:49 +02:00
Tomasz Kontusz
e39b94b26c Fix DBUS_*_BUS_ADDRESS in flatpak enter
Fixes #3820.
2020-09-04 18:27:21 +02:00
Phaedrus Leeds
47c88706e0 app: Make mask and pin output more machine readable
This way we can use "wc -l" in the tests to check how many masks/pins
there are.
2020-08-31 16:29:03 +02:00
Phaedrus Leeds
097faa8411 uninstall: Note pinned runtimes in --unused output
When "flatpak uninstall --unused" is run, we don't remove unused
runtimes that are pinned. List them in the output so the user knows they
are being left installed.

This commit also adds new library API,
flatpak_installation_list_pinned_refs().
2020-08-31 16:29:03 +02:00
Phaedrus Leeds
7cd1990196 Automatically pin explicitly installed runtimes
If a runtime is installed explicitly rather than as a dependency, pin it
so it doesn't get automatically removed when unused runtimes are being
removed. We do this because the runtime might be installed for
development or other uses.

This commit also rearranges some code in the mask and pin commands, and
adds a unit test.
2020-08-31 16:29:03 +02:00
Phaedrus Leeds
2325b81401 Minor fixes for mask command 2020-08-31 16:29:03 +02:00
Matthew Leeds
d2d5397cc1 Add pin command to keep unused runtimes
As discussed here [1], we want a way to mark runtimes to be kept even
when they are unused by any apps and we are removing such runtimes.
Currently this is a command that can be run manually; a subsequent
commit will pin runtimes automatically if they are installed
independently of any app.

A unit test is included.

[1] https://github.com/flatpak/flatpak/issues/2639#issuecomment-662311756
2020-08-31 16:29:03 +02:00
Alexander Larsson
dfb36db79d run: Fix --no-session-bus
This fixes #3636
2020-07-03 09:36:23 +02:00
Léo Stefanesco
5efdea3b61 Fix flatpak enter when there is no middle user ns 2020-06-22 11:00:11 +02:00
Alexander Larsson
b5a9903efc cli: Automatically install authenticator as needed 2020-06-22 10:51:36 +02:00
Matthew Leeds
bd04b09f9b create-usb: Include partial commits
Commits 32194f2d2 and b8d2196c2 made create-usb detect partially
installed commits and omit them except when --allow-partial is specified
(and in the case of extensions of related refs omit them
unconditionally). The reasoning was that if on the other computer using
the USB for an installation you need a different subpath of a commit
(such as a different language of a locale extension), the installation
will fail. But in most real world cases the users on both ends will
speak the same language so it will not often be an issue.  Also, if you
are offline and have only your own language's subpaths for your locale
extensions, it makes sense to put them on the USB because you have no
way to get the full locale extension and the receiver probably wants the
same subpath as you.

The way "flatpak create-usb" is most often used in Endless is via
gnome-software which calls it under the hood. So while we could have it
pass --allow-partial that would not accomplish much; it doesn't solve
the problems above.

For the online case we may want to attempt to download the full locale
extensions before copying to the USB, but that is for a later commit.

Fixes https://github.com/flatpak/flatpak/issues/3491
2020-06-15 10:08:34 +02:00
Matthew Leeds
0552c4cbe4 create-usb: Add missing --allow-partial check
We were checking for --allow-partial in the other two places we handle
partial commits but not here.
2020-06-15 10:08:34 +02:00
Alexander Larsson
03e858a59e remote-info: Use right subject when listing --log 2020-06-10 15:18:12 +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
Ryan Gonzalez
c690eb90e4 portal: Add SpawnStarted and notify-start
These can be used to monitor when a spawned child process has fully
started and to get its relative PID.
2020-06-09 13:51:02 +02:00
Ryan Gonzalez
f687f6b2eb run: Add --instance-id-fd 2020-06-09 13:51:02 +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
Bartłomiej Piotrowski
6d9f9273c8 remote-add: Add --no-follow-redirect 2020-06-08 12:13:20 +02:00
Bartłomiej Piotrowski
5a82a599b1 remote-modify: Add --follow-redirect and --no-follow-redirect 2020-06-08 12:13:20 +02:00
Bartłomiej Piotrowski
2fe18ed560 remote-modify: Set url-is-set to true when changing URL
Assume that if user explicitly modifies the URL, they want to keep
using that URL instead of having it overwritten by xa.redirect-url.
2020-06-08 12:13:20 +02:00
Léo Stefanesco
3ab3f62f58 Fix flatpak enter being multi-threaded and failing
flatpak enter must not be multi-threaded because it calls setns. This
was causing a problem because g_vfs_get_default spawns threads in some
environments.
2020-06-08 09:14:21 +02:00
Matthew Leeds
4117fe0955 Merge pull request #3616 from refi64/remote-add-seg
remote-add: Don't make the repo existence optional
2020-06-05 13:25:10 -07: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
Alexander Larsson
b042abc71c oci: Handle io.github.containers.DeltaUrl in index
If the magical io.github.containers.DeltaUrl label is set in the
index, then try to download this to use as the delta manifest for the
image. This allows servers to store deltas outside the registry
itself. The label is propagated to the xa.delta-url metadata in the
generated "fake summary" for the remote, and read back on pull.

Note that the delta manifest layers descriptor will need to have a
"urls" key where it references the blobs if the blobs are also not
stored on the registry.

If the specified manifest doesn't exist or doesn't apply to the target
image we fall back to resolving via the _deltaindex tag.
2020-06-05 09:35:30 +02:00
Alexander Larsson
47daa077c2 OCI: Support (and use) alternative urls specified in OCI descriptors 2020-06-05 09:35:30 +02:00
Alexander Larsson
0fce4c6d7f oci: Pass FlatpakPullFlags to pull_from_oci()
We want to handle FLATPAK_PULL_FLAGS_NO_STATIC_DELTAS
2020-06-05 09:35:30 +02:00
Alexander Larsson
7820057336 Add content_type output to flatpak_load_uri()
We want this to get the oci mimetypes
2020-06-05 09:35:30 +02:00
Ryan Gonzalez
381f751f0a remote-add: Don't make the repo existence optional
A repository needs to exist for a remote to be written inside,
otherwise the OstreeRepo instance will be NULL and a crash will
occur once the instance is accessed.

Fixes #3612.
2020-05-13 12:24:11 -05:00