Commit Graph

4295 Commits

Author SHA1 Message Date
Matthias Clasen
ebe1403cd8 build-commit-from: Shorten usage text
The usage text should really fit on one line.
Reword the blurb to make that true at least for English.
2018-10-17 17:54:03 -04:00
Matthias Clasen
a99502a620 build-init: Improve error handling
Don't segfault if DIRECTORY does not look like a local path.
2018-10-17 17:54:03 -04:00
Matthias Clasen
aacc649158 build-bundle: Improve error handling
Don't fail in obscure ways if commandline options don't
look like files.

Closes: #2191
2018-10-17 17:53:50 -04:00
Matthias Clasen
dcd912b463 Merge pull request #2249 from mwleeds/use-g-key-file-macro
dir: use G_KEY_FILE_DESKTOP_GROUP constant
2018-10-16 16:04:14 -07:00
Will Thompson
0d6b979212 dir: use G_KEY_FILE_DESKTOP_GROUP constant
This and all the other standard Desktop Entry Specification keys are
defined in gkeyfile.h. Who knew?
2018-10-16 14:40:55 -07:00
Matthias Clasen
fd60bfc96c Add a test for transaction with local install
Here we pass a file url instead of a remote name.

Closes: #2245
Approved by: alexlarsson
2018-10-15 13:39:36 +00:00
Matthias Clasen
a46527d9e1 transaction: Improve the docs
Explain that it is possible to install from a
local repo by passing the location.

Closes: #2245
Approved by: alexlarsson
2018-10-15 13:39:36 +00:00
Matthias Clasen
dc5d78fa33 Add more tests
The tests added here include checks for expected types in
the library (including enum types that are needed for
introspection), and for error handling around names.

Closes: #2245
Approved by: alexlarsson
2018-10-15 13:39:36 +00:00
Matthias Clasen
12b5c36ec9 Remove an unused function
There were no calls to flatpak_zero_mtime anywhere.

Closes: #2245
Approved by: alexlarsson
2018-10-15 13:39:36 +00:00
Matthias Clasen
2d331a84a3 ref: Remove some dead code
flatpak_decompose_ref guarantees that parts[0] is either
"app" or "runtime".

Closes: #2245
Approved by: alexlarsson
2018-10-15 13:39:36 +00:00
Matthias Clasen
2d70866fa8 transaction: Don't call g_object_ref on a GBytes
This won't go well.

Spotted while writing tests.

Closes: #2245
Approved by: alexlarsson
2018-10-15 13:39:36 +00:00
Matthias Clasen
acd8cfd6bb Add a test for bad remote names
These were not handled gracefully so far.

Closes: #2244
Approved by: alexlarsson
2018-10-15 06:51:58 +00:00
Matthias Clasen
8462a093e7 remote: Be robust against bad names
If we use a remote name containing questionable characters
such as newlines or '[', we will run into assertions in
GKeyFile. To avoid that, check that the group name we
pass is valid, and throw an error otherwise.

Found while writing tests.

Closes: #2244
Approved by: alexlarsson
2018-10-15 06:51:58 +00:00
Matthias Clasen
8f5c43a784 history: Always handle --columns=help
The test for --columns was failing in ci because flatpak
gets built without libsystemd there. Avoid this by always
handling --columns=help nicely, even if libsystemd is not
used.

Closes: #2244
Approved by: alexlarsson
2018-10-15 06:51:58 +00:00
Matthias Clasen
6d696b74f5 Test more overrides
Test some of the socket settings.

Closes: #2244
Approved by: alexlarsson
2018-10-15 06:51:58 +00:00
Matthias Clasen
5454707464 Add more tests
Test some more instlalation apis, and some error conditions.

Closes: #2244
Approved by: alexlarsson
2018-10-15 06:51:58 +00:00
Matthias Clasen
34851f99d6 Add some more tests
Test more options of build-update-repo.

Closes: #2244
Approved by: alexlarsson
2018-10-15 06:51:58 +00:00
Matthias Clasen
37f0284467 transaction: Add a missing error return
When trying to uninstall a non-installed app, we run
into an assertion, because the code forgets to return
after setting the expected error.

Found while writing tests.

Closes: #2244
Approved by: alexlarsson
2018-10-15 06:51:58 +00:00
Matthias Clasen
263a2e5663 Add some more basic tests
Some tests for commandline error handling.

Closes: #2244
Approved by: alexlarsson
2018-10-15 06:51:58 +00:00
Matthias Clasen
9f7ddaf678 Add a test for --columns=help
Check that this produces the expected output.

Closes: #2244
Approved by: alexlarsson
2018-10-15 06:51:58 +00:00
Matthias Clasen
4009466913 document-list: Handle --columns=help properly
In this case, the columns helper function returns an
empty array of columns. Exit cleanly without trying
to contact the documents service, in this case.

Found while writing tests.

Closes: #2244
Approved by: alexlarsson
2018-10-15 06:51:58 +00:00
Matthias Clasen
2ce626b069 Add various new tests
Just driving up coverage incrementally, and finding
bugs along the way.

Closes: #2244
Approved by: alexlarsson
2018-10-15 06:51:58 +00:00
Matthew Leeds
ce78f52fcc common: Reload FlatpakRemoteState after changes
Some remote metadata can cause changes to the local configuration for a
remote, but Flatpak is not properly reloading the new config after
making changes. Specifically in flatpak_transaction_update_metadata() we
call flatpak_dir_update_remote_configuration() for each remote and then
try to reload the configuration by calling flatpak_dir_recreate_repo().
The problem is that while this reloads the config instance stored by the
repo member of the FlatpakDir, the FlatpakTransaction object still has
FlatpakRemoteState objects stored which were initialized from the old
config.

A consequence of this is that if a remote repository has the
"ostree.deploy-collection-id" key set in its metadata, the next
install/update operation from that remote will fail with the error
message "Can't pull from untrusted non-gpg verified remote", and then
subsequent operations will succeed. This is because during the first
operation Flatpak will add the collection ID to the local configuration
in flatpak_transaction_update_metadata() but then in
flatpak_dir_install() the outdated FlatpakRemoteState object will be
used which still has no collection ID.

So this commit frees all the stored FlatpakRemoteState objects on the
transaction, so they will be recreated when they're needed (based on the
new config).

Closes: #2243
Approved by: alexlarsson
2018-10-12 09:09:14 +00:00
Piotr Drąg
4d1cfc28fc Update POTFILES.in
Closes: #2238
Approved by: mwleeds
2018-10-12 07:33:08 +00:00
Matthias Clasen
4975840826 Add various new tests
Just driving up coverage incrementally, and finding
bugs along the way.

Closes: #2239
Approved by: alexlarsson
2018-10-12 07:23:45 +00:00
Matthias Clasen
fd282a1ab8 installation: Don't return freed memory
flatpak_installation_load_app_overrides was returning
freed memory. Oops.

Closes: #2239
Approved by: alexlarsson
2018-10-12 07:23:45 +00:00
Patrick Griffis
d6e51ede6d Implicity grant MPRIS2 permissions
This should be safe to expose without requiring everybody request
it.

Closes: #2226
Approved by: alexlarsson
2018-10-11 12:51:55 +00:00
Matthias Clasen
afc87ad1e5 Add a history command
The history command pulls the transaction log entries
out of the journal, and presents them nicely.

We use the sd-journal api for this, so we need to
link against libsystemd now, but we make the dependency
optional. If libsystemd is not available, the history
command will simply print an error.
2018-10-11 14:51:51 +02:00
Matthias Clasen
c672c55154 dir: Add logging
Write to the systemd journal for basic operations
that modify installations, such as pull, deploy,
uninstall.  Include some useful information as
separate fields, such as OPERATION, INSTALLATION,
REMOTE, REF, COMMIT.

We add the logging in the api layer that is used
by the system-helper as well, so that changes
from that side are logged as well.

All logs we write currently use the same message
ID, defined as FLATPAK_MESSAGE_ID in the headers,
for easy retrieval of messages.
2018-10-11 14:51:51 +02:00
Matthias Clasen
e9f2d11f4a dir: Return FALSE when setting an error
This is expected behavior.
2018-10-11 14:51:51 +02:00
Matthias Clasen
1134e28400 system helper: Set the source pid
We add the callers pid as OBJECT_PID to our journal
entries, which causes journald to add number of useful
fields, such as the user and binary on whose behalf we
are acting.
2018-10-11 14:51:51 +02:00
Matthias Clasen
596f0f68d5 dir: Add an api to set a source pid
This will be used by the system helper to indicate
what process it is acting on behalf of.
2018-10-11 14:51:51 +02:00
Piotr Drąg
76dd97e918 Update POTFILES.in
Closes: #2236
Approved by: mwleeds
2018-10-10 18:15:57 +00:00
Matthias Clasen
bde3a86333 Adapt tests to the previous commit
One of the transaction tests contains the situation
that was modified in the previous commit. Update it
to expect the new behavior. At the same time, add
some comments to the tests to guide the reader.
2018-10-10 19:26:58 +02:00
Matthias Clasen
00400803fa transaction: Error if asked to uninstall deps
If a transaction contains both an install for an app
and an uninstall for the runtime that it needs, error
out, since this is inconsistent.

Closes: #2196
2018-10-10 19:26:58 +02:00
Alexander Larsson
99fbbc25c6 build-finish: Inherit permissions from runtime by default
In version 0.99.1 (065053775b) flatpak
stopped inheriting permissions from the runtime, because that made
the story about application permissions way to complicated. What
we want is to have a static set of permissions for the app that
is frozen at install time.

However, inheriting permissions from the runtime makes a lot of sense
as certain permissions are required from the runtime, in particular this
is used by the kde runtime to read the kdeglobals file, etc.

So, to combine the best of the two worlds, we now do inherit permissions,
but at build-time (and you can disable it if you want). This way
kde apps don't have to repeat themselves, but we still get static
application permissions.

Closes: #2230
Approved by: alexlarsson
2018-10-10 15:40:58 +00:00
Matthias Clasen
e5d74a7d74 docs: Fix alphabetic ordering of commands
The permissions were misplaced.

Closes: #2218
Approved by: alexlarsson
2018-10-10 15:26:23 +00:00
Alexander Larsson
0b6844f39e sandbox: Expose /etc/timezone
This exposes a /etc/timezone with the current timezone, as per the old
debian spec: https://wiki.debian.org/TimeZoneChanges

In case we're using the session-helper this will be extracted from
the host config and applied whenever that changes.

Normally timezone info is specified by /etc/localtime being a symlink
into the locale data, and you can look at the symlink value itself.
However, in the sandbox we can't update a symlink in /etc at runtime,
nor can we make it of the canonical form as that would point into the
runtime. This is why /etc/timezone is used.

This fixes https://github.com/flatpak/flatpak/issues/2190

Closes: #2214
Approved by: alexlarsson
2018-10-10 15:12:21 +00:00
Alexander Larsson
6dec266189 utils: Add flatpak_get_timezone()
This extracts the timezone from the symlink in /etc/localtime as
specified in e.g.
  https://www.freedesktop.org/software/systemd/man/localtime.html

If this doesn't exist, or is not a symlink, then it uses the old
debian /etc/timezone as specified in
  https://wiki.debian.org/TimeZoneChanges

If nothing else works it falls back to UTC.

Closes: #2214
Approved by: alexlarsson
2018-10-10 15:12:21 +00:00
Matthias Clasen
24141bd093 Remove --show-columns leftovers
When I decided to add --columns without --show-columns,
I remove the option everywhere. Almost. These are the
leftovers I forgot.

Closes: #2227
Approved by: alexlarsson
2018-10-10 14:56:57 +00:00
Matthias Clasen
03f6b1fcd2 Some test setup fixes
Actually set XDG_RUNTIME_DIR. And assert that the
paths are as we want them to be, from glib's view.

Closes: #2235
Approved by: alexlarsson
2018-10-10 14:42:32 +00:00
Matthew Leeds
6b4402b60e common: Don't seg fault if a ref doesn't exist
Currently, if flatpak_installed_ref_get_latest_commit() returns NULL
(which means the ref doesn't exist in the local repo) we assume any
remote commit could be an update in
flatpak_installation_list_installed_refs_for_update() when a collection
ID is not configured on the remote. When a collection ID is configured,
if get_latest_commit() returns NULL it causes a crash in
ostree_repo_load_commit(). So this commit prevents the crash and makes
the behavior in the post-collection-id world consistent with the
behavior in the pre-collection-id world.

It's difficult to write a test for this that's not contrived, without
knowing what circumstances led to the disappearance of the ref from the
repo.

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

Closes: #2229
Approved by: alexlarsson
2018-10-10 13:54:23 +00:00
Alexander Larsson
41a8b94e9b coverage: Don't do parallell make check
This is running into some kind of timeout for me.

Closes: #2232
Approved by: alexlarsson
2018-10-10 10:42:45 +00:00
Matthias Clasen
e9ffa9dda6 remote-ls: Show runtimes
Add a runtime column that shows the runtime an application
is using, and add an --app-runtime option to allow filtering
by the used runtime.

Closes: #2224
Approved by: alexlarsson
2018-10-10 10:29:08 +00:00
Matthias Clasen
3a01ca36cf config: Parse languages better
Do some actual checking on the value to prevent nonsense
from getting into the config.
2018-10-10 12:21:33 +02:00
Matthias Clasen
0febda1e6f list: Spell out subpaths
This is useful information when debugging language-related
issues.
2018-10-10 12:21:33 +02:00
Matthias Clasen
10d6330eca tests: Check that updating subpaths works
This test updates an runtime to the same commit, just
changing the subpaths, and makes sure that works as
expected.
2018-10-10 12:21:15 +02:00
Matthias Clasen
ca4d4a9c3b Add a second language to the test app
This will let us test subpaths better.
2018-10-10 12:21:15 +02:00
Matthias Clasen
c8db26cc35 Make the test app not hang
We want an app that keeps running for some of the
library tests, but other tests expect it to return
right away. Make this opt-in.
2018-10-10 12:21:15 +02:00
Matthias Clasen
d4df921940 Modify the instance test
Avoid the initial sleep statement, and instead poll
for the child pid.

We also need the test app to stick around and not
exit right away, so change it to exec a shell.
2018-10-10 12:21:15 +02:00