Commit Graph

204 Commits

Author SHA1 Message Date
Alexander Larsson
394130793c uninstall: Pick installation automatically
When uninstalling, if no specific installation was specified with e.g.
--user or --system, automatically chose any unique match, or error
out if there are multiple alternatives.

Fixes #1321
2018-04-04 17:25:20 +02:00
Matthew Leeds
e2c3157ea8 tests: Minor change to assertion ordering
Philip pointed out it's better to g_assert_no_error before g_assert_true
so the output shows the error message.

Closes: #1501
Approved by: pwithnall
2018-03-23 10:34:52 +00:00
Matthew Leeds
34c97c3d10 lib/remote: Make gpg-verify-summary dependent on collection-id
When a collection ID is set on a remote configuration,
gpg-verify-summary should be set to FALSE because flatpak uses signed
per-repo and per-commit metadata instead. The flatpak command line
already does this (use flatpak remote-modify --collection-id=... and
notice that gpg-verify-summary is then set to false). This commit
changes libflatpak to have the same behavior. Specifically, with a
collection ID set gpg-verify-summary is set to false and otherwise its
value matches that of gpg-verify. This commit also adds a test for this
in testlibrary.c.

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

Closes: #1501
Approved by: pwithnall
2018-03-23 10:34:52 +00:00
Alexander Larsson
f2a6c1db8d Remove document portal
This is now in xdg-desktop-portal. We keep a version of the document
portal dbus XML so that we avoid weird build dependencies.

Flatpak itself is technically not dependent on the document portal,
but it is very much recommended that you use it.

Closes: #1398
Approved by: alexlarsson
2018-02-09 09:23:26 +00:00
Philip Withnall
4ed08b24d1 tests: Fix failure with test-unsigned-summaries.sh
The test used to verify that metadata was coming from the
ostree-metadata ref rather than the summary file, by ensuring that
xa.title was set in one but not the other, by regenerating one
separately from the other. However, since the test was written, OSTree
has changed so that it now writes them both out, at the same time, with
no possibility of separating the two.

Trim down this test so it no longer tries to check the source of the
updated metadata, and instead just checks that it is updated.

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

Closes: #1201
Approved by: alexlarsson
2017-12-14 10:30:34 +00:00
Alexander Larsson
3ade86b292 install: Add --reinstall
If you're installing something and its already installed, we undeploy
the old install first before deploying the new. This makes it very
easy to switch an application from one remote to another, without
having to uninstall first, which is both painful and could cause
the download to be unnecessary large.

Closes: #1241
Approved by: alexlarsson
2017-12-14 09:04:38 +00:00
Matthew Leeds
b3828eea46 app: Make remote commands smarter wrt installations
Currently "flatpak remotes" shows remotes across user and system
installations, but other remote commands (remote-delete, remote-modify,
remote-ls, remote-info) only work on one installation: the system one
unless overridden using --user or --installation. This commit changes
each command to infer the correct installation by checking which has
the specified remote. In case multiple installations have remotes by
the same name, the user is prompted to decide which to use.

This commit also adds unit tests and updates the man pages for the
aforementioned commands.

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

Closes: #1205
Approved by: alexlarsson
2017-12-12 15:26:41 +00:00
Alexander Larsson
f61febd785 Drop OCI install tests
Its hard to test these since they rely on a registry to work.

Closes: #1171
Approved by: alexlarsson
2017-11-16 20:50:34 +00:00
Gunnar Andersson
98c21473fc Fix whitespace issues (remove TAB usage)
Signed-off-by: Gunnar Andersson <gandersson@genivi.org>

Closes: #1107
Approved by: mwleeds
2017-10-17 06:21:07 +00:00
Alexander Larsson
e7e1331653 Make tests work on debian
The regular ldconfig is some bash wrapper over /sbin/ldconfig.real
2017-10-09 15:45:25 +02:00
Alexander Larsson
f4de7fb4dd vlagrind suppression: Ignore FICLONE ioctl confusion 2017-10-05 10:34:48 +02:00
Valentin David
845a0b3bf7 Use ld.so.cache instead of LD_LIBRARY_PATH (when not building)
Instead of setting LD_LIBRARY_PATH to make the app load the right
libraries we run ldconfig to generate a ld.so.cache that we feed
to the sandbox as /etc/ld.so.cache. The cache itself is generated
by running ldconfig at run time, but for apps we cache the
result in $HOME/.var/app/$APPID/.ld.so/cache based on the
current app/runtime/extensions commit ids.

We also unset LD_LIBRARY_PATH, to ensure any host-side value
does not mess with the sandbox.

The default ld.so.conf we set (if the runtime has none, or an empty
one) is:

 include /run/flatpak/ld.so.conf.d/*.conf
 include /app/etc/ld.so.conf
 /app/lib

Additionally all the extension points that have add_ld_path set gets a
ld.so.conf snippet in /run/flatpak/ld.so.conf.d.

This allows applications and extensions to install their own paths if
needed, and if the runtime wants more location they can install a
custom ld.so.conf that includes the above.

In the flatpak build case we still use LD_LIBRARY_PATH like before,
because there is no good key (like the commit ids) for keeping the
cache up-to-date. Also, the behaviour is different when building an
app for instance. If /app/lib is not in LD_LIBRARY_PATH then the
sandbox-wide /etc/ld.so.cache must be updated for a newly installed
library to work, but the sandbox is not allowed to update
/etc/ld.so.cache.

This code was originally written by Valentin David <valentin.david@gmail.com>
with changes by Alexander Larsson <alexl@redhat.com>.

Closes: #1073
Approved by: alexlarsson
2017-10-04 10:27:14 +00:00
Alexander Larsson
237d91e1da Bump version to 0.9.98.1 2017-09-26 22:25:10 +02:00
Simon McVittie
f8e5c200bc tests: Use a more realistic bwrap invocation to check for support
The kernel used on some autobuilders for the Debian PA-RISC port
can do "bwrap --ro-bind / / /bin/true", but not the bwrap invocations
made during the actual testing, which fail with "Creating new namespace
failed: Invalid argument". Make the trial bwrap invocation more like
what Flatpak actually does, so that these tests will hopefully be
skipped on such kernels.

Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=876743
Signed-off-by: Simon McVittie <smcv@debian.org>
2017-09-26 10:41:49 +02:00
Alexander Larsson
5158a622f6 Fix OCI tests by exporting FLATPAK_ENABLE_EXPERIMENTAL_OCI=1 2017-09-22 11:48:06 +02:00
Simon McVittie
22f05803b9 Skip system-mode tests (only) if /var/tmp doesn't support xattrs
This partially reverts commit a53a752a35.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2017-08-31 16:22:18 +02:00
Simon McVittie
e65bcc9fcc Bring back skip_without_user_xattrs helper function
We'll need this to be able to skip system-mode tests without xattrs.
This partially reverts commit a53a752a35.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2017-08-31 16:22:18 +02:00
Simon McVittie
6e46dc8076 Revert "tests: Don't force use of /var/tmp"
This reverts commit 0648452fca.
Unfortunately, it appears we still need xattrs on the system cache.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2017-08-31 16:22:18 +02:00
Simon McVittie
2cfeef6bcc Put FLATPAK_SYSTEM_CACHE_DIR alongside other test data
This makes it easier to reason about. In the absence of
FLATPAK_SYSTEM_CACHE_DIR, it would use /var/tmp even during tests that
prefer /tmp.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2017-08-31 16:22:18 +02:00
Simon McVittie
0648452fca tests: Don't force use of /var/tmp
Now that we don't need user xattrs, a tmpfs is good enough.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2017-08-31 13:35:54 +02:00
Simon McVittie
a53a752a35 tests: Don't require user xattrs
Since Flatpak 0.9.6, we use libostree in bare-user-only mode, which
does not rely on xattrs.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2017-08-31 13:35:54 +02:00
Simon McVittie
86fd56dce0 Improve test diagnostics
- Replace `if (g_test_verbose ()) g_print("...\n")` with
  `g_test_message ("...")`, which prints the message if the test is
  either verbose or in TAP mode. Otherwise, post-mortem debugging
  of failing tests on an autobuilder is very difficult.
  In some cases, since commit f1dbe9bc "tests: Print spawned program
  argv in testlibrary" we already had the g_test_message(), but
  still had the redundant g_print() too.

- Factor out running a subprocess into a helper function to reduce
  duplication.

- Capture invoked subprocesses' stderr and stdout where possible, so we
  can log it as diagnostics. Again, this should make it easier to carry
  out post-mortem debugging based on autobuilder logs.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2017-08-30 15:45:11 +02:00
Alexander Larsson
52bd146561 Remove flatpak-builder from flatpak repo
This is now in a separate flatpak-builder repo
2017-08-25 11:10:50 +02:00
Philip Withnall
15df314ca4 lib/remote: Add implementation of flatpak_remote_get_remote_type()
This is declared in the header file, but was never actually implemented.
Oops.

If anybody is hit by this issue, they can work around it by using
g_object_get() to get the FlatpakRemote:type property, which this is the
getter for.

Add it to the tests as well, so it gets exercised.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-23 16:59:11 +01:00
Philip Withnall
bcaec00e7a tests: Increase timeout values in testlibrary
1s is apparently not enough to install the test application on my
machine.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall
f1dbe9bc50 tests: Print spawned program argv in testlibrary
This makes debugging failures a little easier.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall
1932c66e0f tests: Drop use of GMainLoop in testlibrary
Use g_main_context_iteration() manually in a loop instead; this makes
the termination conditions more obvious. This does not change the
behaviour of the test.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall
9989188a1e tests: Add support for collection IDs to test-repo.sh
This adds variable support for collection IDs: they can either be
enabled on the server, on the server and client, or not at all. If
enabled on the server, apps and runtimes are built with collection IDs
and the repository has one set. If enabled on the client, the remote
config is added to the local repository with a collection ID and GPG
verification enabled. They are controlled with
USE_COLLECTIONS_IN_{SERVER,CLIENT}={yes,no}.

These variables are used in the new wrapper tests,
test-repo-collections.sh and test-repo-collections-server-only.sh.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall
19dbbd5f8c tests: Use AM_TESTS_ENVIRONMENT rather than TESTS_ENVIRONMENT
The latter is reserved for the user to set in their environment. The
former is what the makefile is supposed to set.

See
https://www.gnu.org/software/automake/manual/html_node/Scripts_002dbased-Testsuites.html.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall
642a5a81a1 lib/remote: Add getter/setter for collection IDs
This isn’t really used internally, but will be used by gnome-software
for when it configures new flatpak remotes.

This is new public API, but is only declared if compiling with
--enable-p2p.

Includes some basic smoketests.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall
e5e52b4b79 common/utils: Allow collection-id to be updated from repo config
In order to provide a transition path for repositories to add collection
IDs to themselves and propagate those collection IDs to clients’ remote
configurations, add another repo config key which controls whether the
repository’s collection ID is published. If xa.collection-id is set in
the repo’s published metadata, the client will update its configuration
to the given ID — but only if no ID is set already. This is a one-time
transition to prevent malicious repositories from remotely changing the
user’s configuration to associate their remote with a well-known
collection ID they don’t own.

Add a test for this.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall
4cb47a2112 tests: Add a test for unsigned summary support
This relies on peer to peer support also being enabled; the test is
skipped otherwise.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall
4c395cec13 lib/ref: Add collection ID support to FlatpakRef
This adds a new collection-id property which is only enabled if
FLATPAK_ENABLE_P2P is defined. The internal machinery for handling it is
always enabled, to reduce the amount of #ifdef spam.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall
f47a696392 build: Add AM_* variables to all per-target special variables
For example, add $(AM_CFLAGS) to mumble_CFLAGS. Since $(WARN_CFLAGS) is
only added to $(AM_CFLAGS), this fixes the lack of inclusion of the
compiler warning flags in the compilation of half of flatpak.

Note that $(AM_*) variables are only used by automake if a more specific
(per-target) special variable is not defined instead. So if you define
mumble_CFLAGS, AM_CFLAGS will not be used for that target unless
explicitly included in mumble_CFLAGS.

See
https://www.gnu.org/software/automake/manual/html_node/Flag-Variables-Ordering.html.

Do the same for $(AM_LIBADD), $(AM_LDFLAGS), etc. These are not
currently defined, but it’s good practice to include them in
mumble_LIBADD (etc.) just in case they’re defined in future. Hopefully
their inclusions will be cargo-culted to any new targets which are
added, retaining full coverage of the code base.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-07-06 15:05:58 +01:00
Philip Withnall
95c3c942d3 tests: Move printf format string into printf() call to silence warning
Clang otherwise complains about the printf() format string not being a
string literal, which is a bit pants.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-07-06 15:05:58 +01:00
Simon McVittie
5de225e615 tests: Isolate tests from real home directory more thoroughly
The library test previously used the real ~/.cache, while the
library test and the shell-script tests would use the real ~/.config
to look up the XDG user-dirs.dirs. Other home-directory-related code
might have used the real $HOME.

As a general rule, build-time tests should not affect the real home
directory. Debian autobuilders run as a user whose home directory
does not exist, in order to catch packages whose build process could
affect or be affected by the contents of the home directory. This
caused testlibrary to fail when it tried to create that nonexistent
directory, which I think happened while trying to create ~/.cache.

Signed-off-by: Simon McVittie <smcv@debian.org>
2017-07-04 11:32:45 +01:00
Philip Chimento
86bc5f39be builder: Use build-args during cleanup
Any build-args specified in the manifest should be used during the
cleanup and platform-cleanup stages. This is because if you are using
QEMU to build for another architecture, for example, you need to pass
--bind-mount in the build-args, and the bind mount also needs to be
present while running cleanup commands.
2017-06-30 10:23:52 +02:00
Philip Withnall
5a0e10969f tests: Add base-64 GPG keys to libtest declarations
These will be useful in upcoming tests, as they are in the right format
to be substituted into a .flatpakref file.

Generated using `gpg2 --homedir test-keyring --armor --export
${FL_GPG_ID}`, then stripping the packet header and removing line
breaks.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-06-30 10:17:34 +02:00
Philip Withnall
0062cf69c0 tests: Add TEST_SKIP_CLEANUP env var for skipping test cleanup
This mirrors the same environment variable in OSTree’s unit tests, which
keeps the temporary directory around after tests have completed (or
failed) so the developer can examine it.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-06-30 10:17:34 +02:00
Alexander Larsson
7ef78c8e2b tests: Increase timeouts waiting for file notification
For whatever reason .5 seconds was not enough time for me
to get a file notification message, so increase it to 1 sec.
2017-06-19 19:41:32 +02:00
Alexander Larsson
0bbb8354dc tests: Add tests for no world writable dirs & no setuid files 2017-06-19 19:41:00 +02:00
Alexander Larsson
bc7ebd20e2 builder: Allow .pyc files without .py
This is common for binary-only releases, for example as described
in:
https://lists.freedesktop.org/archives/flatpak/2017-June/000697.html
2017-06-13 11:17:06 +02:00
Matthias Clasen
27761c17d6 Merge pull request #835 from smcv/generated-dbus
Don't distribute gdbus-codegen-generated source in tarballs
2017-06-06 16:06:37 -04:00
Simon McVittie
37e52409aa Don't distribute gdbus-codegen-generated source in tarballs 2017-06-05 21:53:17 +01:00
Simon McVittie
7612232ab8 testlibrary: Call g_assert_no_error first
Failing tests produce much clearer diagnostics this way round.

Signed-off-by: Simon McVittie <smcv@debian.org>
2017-06-05 21:48:59 +01:00
Alexander Larsson
d2c51a8553 Fix installation of test-keyring2 2017-05-23 14:32:46 +02:00
Alexander Larsson
6fb15f4f76 Dist test-keyring2 dir 2017-05-23 12:08:23 +02:00
Alexander Larsson
dac242fb49 Remove unused variables 2017-05-22 13:40:11 +02:00
Alexander Larsson
6ce8521b64 document-portal: Add AddFull() operation
This allows you to add multiple paths at the same time, plus
grant an app access to it, plus it returns the fuse mount path.

This allows you to avoid a lot of roundtrip in common cases.
2017-05-19 17:01:46 +02:00
Alexander Larsson
c35bce077f remote-add: Use the new system-helper for initial metadata update
This removes some duplicated code, and also follows the new
redirect-url property on initial add.

This also means we're requiring gpg signatures to be correct
on remote-add, so fix up the tests
2017-05-11 11:20:39 +02:00