Commit Graph

457 Commits

Author SHA1 Message Date
Matthias Clasen
caaeb53828 Merge pull request #3169 from smcv/nodist
build: Don't distribute flatpak-portal-dbus.c in tarballs
2019-10-11 08:44:22 -04:00
Simon McVittie
b64cad0f18 build: Don't distribute flatpak-portal-dbus.c in tarballs
Adding generated files to foo_SOURCES causes them to be distributed,
even if that was not intended. Use nodist_foo_SOURCES instead.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-10-11 10:22:08 +01:00
Simon McVittie
8fd5b14d08 build: Don't install test.portal as executable
There's no need for this file to be executable. If it was executed,
shells would typically try to execute it as a shell script (because it
isn't an ELF executable and doesn't start with #!), which isn't going
to work.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-10-11 10:17:52 +01:00
Matthias Clasen
11455525fb Merge pull request #3166 from pwithnall/3017-extension-ordering
transaction: Install extensions before apps
2019-10-10 08:46:43 -04:00
Philip Withnall
3acb4246bc transaction: Install extensions before apps
This ensures that when the operation to install the app completes, the
app is ready to run — rather than having to wait for subsequent
operations to install extensions which the app depends on (such as
content, or locales).

This fits in with the current ordering for *un*installing apps, where
the main app is uninstalled first, followed by its extensions.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://github.com/flatpak/flatpak/issues/3017
2019-10-10 13:22:48 +01:00
Philip Withnall
0975c65574 build: Fix the path to some installed-tests files
Files in the srcdir need to be explicitly prefixed as such in rule
commands. This fixes `make install` when installed-tests are enabled.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-10-10 11:56:28 +01:00
Alexander Larsson
0e51264788 tests: Use regular HTTPServer, not ThreadingHTTPServer
The later requires python 3.7
2019-10-09 14:25:44 +02:00
Alexander Larsson
227cde12ba tests: Redo httpd server setup
Rather than this weird shell loop with a timeout and polling we
move the httpd spawning entirely into the python code, and use
a pipe to synchronize the spawning. This way we can also use
the shell job control to properly clean up any running processes
from the test suite.

Additionally, this adds some (lame) support for token handling in the
test webserver, where you for any file foo can create a foo.need_token
containing a token that is needed for that file.
2019-10-09 14:25:44 +02:00
Umang Jain
11631f9514 transaction: Add getter for querying no-pull
As this is a required to deploy autoupdates downloaded in the
background, for clients like gnome-software.
2019-10-08 15:21:09 +05:30
Umang Jain
c7670e87d7 transaction: Add getter for querying no-deploy
FlatpakTransaction inherently doesn't differentiate between a
autoupdate and a regular update; both are
FLATPAK_TRANSACTION_OPERATION_UPDATE.

This getter can help differentiate between a regular update
and autoupdate in clients like gnome-software. Autoupdates
work in two separate transaction passes; first that runs with
"no-deploy" and the second pass that deploys all the downloaded
update (i.e. with "no-pull").
2019-10-08 15:21:03 +05:30
Alexander Larsson
2b6641575d tests: Convert all tests to python3
Python2 is pretty much dead, lets make us only use python3.
2019-10-07 11:38:24 +02:00
Philip Withnall
0e53094645 flatpak-appdata: Add support for extracting app content ratings
This will be used in upcoming commits to enforce parental controls on
app installations.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://github.com/flatpak/flatpak/pull/2797
2019-10-03 10:42:04 +02:00
Alexander Larsson
9e9c202afa Fix distcheck 2019-10-02 17:33:08 +02:00
Alexander Larsson
47d6ea12b5 tests: Remove leftover debug stuff 2019-10-02 16:53:58 +02:00
Alexander Larsson
4eb213a39a update-portal: Add tests with changed permission errors 2019-10-02 14:57:11 +02:00
Alexander Larsson
ade1b299e7 tests: Test masking in updates portal
If the app is masked it should neither report updates or update
itself. Test this.
2019-10-02 14:57:11 +02:00
Alexander Larsson
d942b47b64 tests: Remove some unused code in update-portal test 2019-10-02 14:57:11 +02:00
Alexander Larsson
714f13a6a0 tests: Test self-update via the update-portal
We test a successful update, a null update and a failed update.
2019-10-02 14:57:11 +02:00
Alexander Larsson
91d9fe9c60 tests: Add simple testing portal backend and wire it up to the tests
This only supports the AccessDialog call, and always just allows
everything. Still, it tests the entire codepath for authentication.
2019-10-02 14:57:11 +02:00
Alexander Larsson
c15c1946ff test: Add test for update-portal monitoring
We add socat to the test runtime, and then we use that to run a
test app outside the sandbox as if it was inside.

The testcase connects creates a monitor and ensure we properly get signals
for updates.
2019-10-02 14:57:11 +02:00
Alexander Larsson
8ab48d5198 tests: Fix whitespace in makefile 2019-10-02 14:57:11 +02:00
Alexander Larsson
8832e7c7d1 Make test output a bit less noicy
This gets rid of some unnecessary spew that happens in every
test run and just makes the logs harder to read.
2019-10-02 14:57:11 +02:00
Alexander Larsson
161a13951b Add flatpak install --or-update operation
This allows you to ensure that a particular app/runtime is installed
and with the latest version in a single operation, which is useful
for instance in automatic use, like CI systems.
2019-09-27 09:07:13 +02:00
Alexander Larsson
c719710907 tests: Some cosmetic fixes for the version check test
Closes: #3118
Approved by: alexlarsson
2019-09-19 16:17:34 +00:00
Philip Withnall
5236608d86 tests: Fix a warning about ignoring the return value of symlink()
Assert it was successful instead. This is probably pointless from the
point of view of testing things (why would symlink() ever realistically
fail but everything else succeed?), but it does shut up a compiler
warning, which gives us a better chance to spot legitimate warnings in
future.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #3116
Approved by: alexlarsson
2019-09-19 15:51:11 +00:00
Matthew Leeds
989b18bba8 Set a collection ID on FlatpakInstalledRef objects
Currently FlatpakInstalledRef objects are constructed without the
collection-id property set. This is a problem because in the USB app
update support in the Endless fork of GNOME Software, when we find a
FlatpakRemoteRef on a USB drive which matches the ref of a
FlatpakInstalledRef object, the collection IDs of the two objects must
also match, and currently the installed one has a NULL collection ID.

So get the collection ID on the relevant configured remote when
constructing a FlatpakInstalledRef. This should be good enough in most
cases but isn't perfect; see
https://github.com/flatpak/flatpak/issues/3103

Closes: #3114
Approved by: alexlarsson
2019-09-19 15:20:15 +00:00
Matthew Leeds
9c3b42d67e testlibrary: Fix type for FlatpakTransaction::add-new-remote @reason
Closes: #3066
Approved by: alexlarsson
2019-09-19 15:20:06 +00:00
Matthew Leeds
f374a80ed7 testlibrary: Fix a typo in a URL
Closes: #3066
Approved by: alexlarsson
2019-09-19 15:20:06 +00:00
Matthew Leeds
c29e686246 installation: Don't return an error checking for updates offline
In commit b8a3075d8 I changed a few places to check if the array
returned by ostree_repo_find_remotes_finish() is empty, which would mean
either none of the configured remotes (or P2P sources) provide the
requested refs, or the one(s) that do are offline. That was mostly
correct but in the case of
flatpak_installation_list_installed_refs_for_update() we don't want to
treat empty results as an error, because otherwise GNOME Software prints
an error message when offline: "No remotes found which provide these
refs: ...".

So this commit makes list_installed_refs_for_update() return an empty
array in case it can't find any updates (we don't distinguish "remotes
checked and provide no updates" from "remotes couldn't be reached").
This matches the behavior of the non-P2P code: the for loop above which
handles remotes without collection IDs prints a debug message if an
error is encountered.

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

Closes: #3066
Approved by: alexlarsson
2019-09-19 15:20:06 +00:00
Alexander Larsson
5026f01153 Support multiple versions in required-flatpak metadata key
Support a list of versions that are supported. This will be useful
for e.g. the extra_data for extensions once that is backported to
1.2, because that will require it to say that it is supported for
> 1.2.5 in the 1.2 series and > 1.4.2 otherwise.

Closes: #3112
Approved by: alexlarsson
2019-09-18 14:55:38 +00:00
Alexander Larsson
62117308c1 tests: Add test for required-flatpak versioning
This sets required-flatpak in the metadata to some different versions
and ensure we're properly able or not able to install it.

Additionally it uses some options with multiple versions. This is not
yet supported but I want to test the existing code and make sure it
properly falls back to just using the first element of the list.

Closes: #3112
Approved by: alexlarsson
2019-09-18 14:55:38 +00:00
Matthew Leeds
13279af129 Merge pull request #3058 from mazen-asef/add_default_languages_key
Add extra-languages config key
2019-09-13 13:19:08 -07:00
Mazen Asef
a0666034db app: Add new extra-languages key
If xa.languages is set, use these, and no others. Otherwise, take the union
of xa.extra-languages, and the system default locales for system repos;
xa.extra-languages for user repo and the langs based on the user's locale

Fixes https://github.com/flatpak/flatpak/issues/3043
2019-09-13 15:31:14 -03:00
Matthew Leeds
07ab6e3a7a tests: Fix whitespace and typo errors
Closes: #3065
Approved by: alexlarsson
2019-09-13 08:31:41 +00:00
Matthew Leeds
af4504c8d3 dir: Ignore trailing slash in remote URIs
Currently if you have a remote configured with the URL
"https://dl.flathub.org/repo/" (as you would if you use the flatpakrepo
file) and you use a flatpakref file which specifies the URL
"https://dl.flathub.org/repo", Flatpak tries to add a duplicate remote
because it doesn't see those URLs as equal. So ignore the trailing slash
when comparing remote URLs. OSTree works equally well with both kinds
(it uses g_build_filename()).

Flathub served flatpakref files with URLs missing a trailing slash until
this commit:
https://github.com/flathub/ansible-playbook/commit/b20694f09

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

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

Closes: #3065
Approved by: alexlarsson
2019-09-13 08:31:41 +00:00
Matthew Leeds
ea19e4e5a7 flatpak-remote: Enforce GPG verification when a collection ID is set
Currently the "test_remote()" test calls
flatpak_remote_set_gpg_verify (remote, FALSE) and disables GPG
verification on a remote while a collection ID is set on it, which
should not be possible. The remote-add command enforces that GPG
verification is used if a collection ID is set, but the library API does
not. This commit changes libflatpak to return an error when such an
invalidly configured remote is being committed to disk. Also, update the
unit test to check for the newly added error, and to unset the
collection ID before disabling GPG verification.

Later in the unit test, GPG verification is re-enabled on the remote,
but libflatpak erroneously sets gpg-verify-summary=true in addition to
gpg-verify=true (summary verification is supposed to be disabled when
collections are used, but the library doesn't notice the mistake since a
collection ID isn't set in the same transaction and was already set).

This fix addresses both issues.

Closes: #3095
Approved by: alexlarsson
2019-09-13 07:21:15 +00:00
Matthew Leeds
e2752abf28 tests: Add a test for uninstall --unused
Closes: #3067
Approved by: alexlarsson
2019-09-09 10:20:34 +00:00
Matthew Leeds
b3d77bec69 common: Make uninstalls robust to a missing remote
Currently if you delete a remote when it still has installed apps (using
--force), you're then unable to uninstall those orphaned apps (or
runtimes). This commit makes the uninstall operation succeed despite the
missing remote. Since we don't need a FlatpakRemoteState for an
uninstall operation, just avoid calling flatpak_ensure_remote_state().
Also, do some refactoring in flatpak_transaction_real_run() that should
improve readability and allows us to add a g_return_val_if_fail() in the
helper function, which ensures that only uninstall operations are
allowed to not have remote state.

This also includes a unit test for uninstalling with a missing remote.

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

Closes: #3067
Approved by: alexlarsson
2019-09-09 10:20:33 +00:00
Alexander Larsson
9ec61ae328 tests: Add tests for oci registries using labels instead of annotations
Closes: #2978
Approved by: alexlarsson
2019-09-06 12:49:40 +00:00
Debarshi Ray
e82efa8603 Trim unused shared library linkages from the session helper
The org.freedesktop.Flatpak user D-Bus service isn't just used by
flatpak(1) or applications running as Flatpaks. It's also used by
toolbox(1) for similar reasons:
 * To keep various configuration files inside the container
   synchronized with the host
 * To let the container request certain commands to be run on the host

The org.freedesktop.Flatpak D-Bus service itself doesn't need much in
the way of dependencies, but inherits a lot of unused shared library
linkages through the libflatpak-common.la convenience library. Removing
these unused shared libraries reduces the footprint of toolbox(1) for
those who care about such things. eg., Fedora CoreOS.

This commit brings down the number of shared libraries to 19 from 62.

Closes: #3052
Approved by: alexlarsson
2019-08-16 09:13:43 +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
9928ce757f libtest.sh: Delete unreachable exit command 2019-07-02 16:12:42 -07:00
Simon McVittie
423cb7d053 testlibrary: Remove unused variables
Detected by compiling with clang.

Signed-off-by: Simon McVittie <smcv@collabora.com>

Closes: #2951
Approved by: matthiasclasen
2019-06-10 15:59:33 +00:00
Alexander Larsson
b53f937d7e Fix installable tests when running on a tty
This sets FLATPAK_FANCY_OUTPUT=0 in most tests and then special cases
the test_fancy_output() test in case the installable tests are running
on an actual tty. This was causing failures because the added bold escapes
caused some test cases to not generate the expected output.

Closes: #2907
Approved by: alexlarsson
2019-05-16 15:24:47 +00:00
Alexander Larsson
4947fa6e44 fix distcheck: Pass -f to rm to avoid interactive prompt 2019-05-10 09:07:41 +02:00
Alexander Larsson
1b2207c64e tests: Fix distcheck (test.filter is in srcdir, not builddir) 2019-05-10 08:59:41 +02:00
Alexander Larsson
c01fdee171 lib Add flatpak_remote_new_from_file() to add remotes from flatpakrefs
Closes: #2888
Approved by: alexlarsson
2019-05-09 12:39:36 +00:00
Alexander Larsson
8d674234aa lib: Add flatpak_installation_add_remote
This is basically modify_remote, but it fails if the remote is
already configured instead of modifying it. Although it also
has a if_needed option, and if that is set it will silently complete
as a no-op (exept resetting filters).

Closes: #2888
Approved by: alexlarsson
2019-05-09 12:39:36 +00:00
Alexander Larsson
1313506449 tests: Add test for updating from oci remote (currently broken)
This is currently failing with:
  Can't pull from untrusted non-gpg verified remote

Closes: #2891
Approved by: alexlarsson
2019-05-09 12:22:44 +00:00
Alexander Larsson
08c544a3f0 tests/oci-registry-server.py: Delete old images for the tag when creating
Closes: #2891
Approved by: alexlarsson
2019-05-09 12:22:44 +00:00