Commit Graph

1514 Commits

Author SHA1 Message Date
Alexander Larsson
7dedbbb56b FlatpakDir: Break out the remote-config copy code into a helper
Closes: #2884
Approved by: alexlarsson
2019-05-08 08:13:52 +00:00
Alexander Larsson
6278420ba8 dir: Add flatpak_dir_compare_remote_filter and handle canonicalization
In general xa.filter being "" means don't filter, so that it can be
used to override-unset a previous filter. However, We canonicalize
to unset/NULL when comparing, returing, or setting the ostree config.

Closes: #2884
Approved by: alexlarsson
2019-05-08 08:13:52 +00:00
Alexander Larsson
e31023c32f Move flatpak_dir_parse_repofile to utils (and drop the unused dir)
Closes: #2884
Approved by: alexlarsson
2019-05-08 08:13:52 +00:00
Alexander Larsson
e1ffc0e730 flatpak_dir_parse_repofile: Handle version and comment/desc/etc keys
These were supported by remote-add, so should be supported here too.

Closes: #2884
Approved by: alexlarsson
2019-05-08 08:13:52 +00:00
Alexander Larsson
6ee61a29fd Remove support for /etc/flatpak/remotes.d config files
This kind of remotes don't work very well, because they are not modifiable
or removable and can cause conflicts with pre-existing remotes.

We instead want to switch to a way to define default remotes that
is applied to the regular ostree repo config, allowing later changes.

Closes: #2884
Approved by: alexlarsson
2019-05-08 08:13:52 +00:00
Matthias Clasen
74d83d8111 Move dconf utilities to flatpak-utils
This is in preparation for writing some unit tests
for these functions. Apparently they are not too
trivial to get them wrong.

Closes: #2880
Approved by: alexlarsson
2019-05-07 06:11:18 +00:00
Matthias Clasen
0a8de7d1bc fix a typo in path_is_similar
We were trying to check if path2 is longer,
but accidentally checked if it is empty.

Closes: #2880
Approved by: alexlarsson
2019-05-07 06:11:18 +00:00
Alexander Larsson
40cc39ebf6 add-remote: Support loading filter from .flatpakrepo file
This is kind of special as it handles non-existing filter keys
as "override to no filters" instead of "leave existing filters" whic
we do for other things. However, that matches how we want to use
.flatpakrepo files to override site-local filters.

Closes: #2869
Approved by: alexlarsson
2019-05-06 13:58:58 +00:00
Alexander Larsson
5f6f5f7178 appstream: Include checksum of filter in appstream checkout
If there is a filter for the remote, include the checksum of it
in the directory name for the deploy dir. This way we re-deploy the
appstream if the filter changes.

Closes: #2869
Approved by: alexlarsson
2019-05-06 13:58:58 +00:00
Alexander Larsson
bbd108ab80 FlatpakDir: Make empty xa.filter mean no filter
This is useful as it allows us to easily disable a filter via
the system helper.

Closes: #2869
Approved by: alexlarsson
2019-05-06 13:58:58 +00:00
Alexander Larsson
f82f0f397d flatpak-remote: Add api to get/set the filter path for a remote
Closes: #2869
Approved by: alexlarsson
2019-05-06 13:58:58 +00:00
Alexander Larsson
4f6428af83 appstream: Automatically rewrite appstream xml during deploy if filtering
This means only refs that are allowed will be visible in the deployed
appstream.

This sometimes means we have to uncompress the xml.gz before rewriting
and then re-compressing that.

As a result of this we now always end up with both the compressed and
the uncompressed xml file, whereas we before didn't get an uncompressed
one if the remote was using the old appstream format.

Closes: #2869
Approved by: alexlarsson
2019-05-06 13:58:58 +00:00
Alexander Larsson
5b7b77d922 dir: Apply ref filters in list_all_remote_refs() and lookup_ref()
Full names are:
 * flatpak_remote_state_lookup_ref()
 * flatpak_dir_list_all_remote_refs()

This should be enough to not get any stray refs, because due to the
complexities of p2p all accesses go via FlatpakRemoteState.

The one leftover to non-filtered stuff is the appstream file, a later
commit will handle that.

Closes: #2869
Approved by: alexlarsson
2019-05-06 13:58:58 +00:00
Alexander Larsson
4ba18ec160 FlatpakRemoteState: Include the active filter in the state
Closes: #2869
Approved by: alexlarsson
2019-05-06 13:58:58 +00:00
Alexander Larsson
41018724b1 FlatpakDir: Read the xa.filter per-remote config option
If this is set to a pathname in the configuration of a remote we load
that file and keep track of it as a filter. No filter is actually applied
yet though.

There is two levels of caching, consecutive lookups of the filter
with less than 500msec between use the previous value. Once its more
that that we stat() the file and compare the mtime, reloading the file
if the mtime changes. We also directly reload the file if the pathname
changes.

Closes: #2869
Approved by: alexlarsson
2019-05-06 13:58:58 +00:00
Alexander Larsson
d45c98c0bd utils: Add flatpak_appstream_xml_filter
This applies a ref filter to an appstreaml xml file

Closes: #2869
Approved by: alexlarsson
2019-05-06 13:58:58 +00:00
Alexander Larsson
4b39b5c9c0 utils: Add utils to parse and apply ref filter globs
Filters are specified as a list of
op glob

where op can be allow or deny, and the blogs are partial refs
where * means anything in this part of the ref, and non-specified
trailing parts of the ref matches anything.

By default everything is allowed, but if you specify some
deny rules all that they match is denied, except if there is
an specific allow rule.

Internally this takes all the allow and deny globs and convert
them into two combined regular expressions.

Some examples:
 * - match anything
 app/* - match all apps
 runtime/* - match all runtimes
 app/*/x86_64 - match all x86-64 apps
 app/org.gnome.*/*/stable - match all stable gnome apps
 org.gnome.frogr* - match frogr and extensions

This means you can do a both whitelisting:
 deny *
 allow org.the.good.app*
Or blacklisting:
 deny org.the.bad.app*

Closes: #2869
Approved by: alexlarsson
2019-05-06 13:58:58 +00:00
Simon McVittie
e0a149858f Don't leak dbus_session_socket from flatpak_run_add_session_dbus_args
The function was already leaking the result of
extract_unix_path_from_dbus_address() in the case where that call
succeeded. Since commit 0e545799 it would also leak the result of
g_build_filename in the case where it checked $XDG_RUNTIME_DIR/bus.

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

Closes: #2877
Approved by: matthiasclasen
2019-05-03 15:02:57 +00:00
Simon McVittie
e360005d8b Check for missing sentinels in NULL-terminated varargs
Signed-off-by: Simon McVittie <smcv@collabora.com>

Closes: #2876
Approved by: matthiasclasen
2019-05-02 16:58:36 +00:00
Simon McVittie
0e5457995a run: Make D-Bus session bus default to $XDG_RUNTIME_DIR/bus
This matches what's now implemented in libdbus, GDBus and sd-bus.
If $DBUS_SESSION_BUS_ADDRESS is unset, check whether $XDG_RUNTIME_DIR/bus
is a socket owned by Flatpak's uid; if it is, use it.

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

Closes: #2874
Approved by: alexlarsson
2019-05-02 06:51:10 +00:00
Simon McVittie
62629b44b8 app, common: Use glnx_readlinkat_malloc()
readlink() and readlinkat() have weird semantics (they return the
number of bytes they would have written if there was enough space,
even if that's larger than the buffer), but glnx_readlinkat_malloc()
takes care to do the right thing in all situations.

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

Closes: #2873
Approved by: matthiasclasen
2019-05-01 16:39:18 +00:00
Alexander Larsson
ad11954bf7 lib: Add a flag-using _full version of list/fetch_remote_ref
This adds the flag FLATPAK_QUERY_FLAGS_ONLY_CACHED to use the new
code for this.

Closes: #2859
Approved by: alexlarsson
2019-04-26 08:00:27 +00:00
Alexander Larsson
aa24754aa0 FlatpakError: Add more dbus error names
Closes: #2859
Approved by: alexlarsson
2019-04-26 08:00:27 +00:00
Alexander Larsson
6088c7d0a1 dir: Add support for getting remote state using only caches
If only_cached is TRUE we never do any network i/o, instead
returning ERROR_NOT_CACHED if this is necessary.

Closes: #2859
Approved by: alexlarsson
2019-04-26 08:00:27 +00:00
Alexander Larsson
cf42364e23 dir: Keep track of the cache dir in FlatpakDir
We will need this later

Closes: #2859
Approved by: alexlarsson
2019-04-26 08:00:27 +00:00
Alexander Larsson
68d06f7896 api docs: Mention the umask(022) workaround.
There is no great place for this, but the transaction api is
the primary place affected by this problem so I put the note there.

Closes: #2856
Approved by: alexlarsson
2019-04-25 07:13:58 +00:00
Alexander Larsson
9c2176e824 dir: Only reuse system cache dirs with permissions 0755
We need this to ensure that the dir can be shared with the new
system-helper flatpak user. Old dirs can happen to get less
permissions if there was a umask set when it was created.

Closes: #2856
Approved by: alexlarsson
2019-04-25 07:13:58 +00:00
Matthew Leeds
bd18eab6ce create-usb: Delete local repo summary if it exists
Old versions of the create-usb command created a summary file in the
local repo being pulled from (e.g. /var/lib/flatpak/repo) but this
summary generation turned out not to be necessary and was removed. So
any computer which used the create-usb command before commit 7c5751a4f
will have a leftover /var/lib/flatpak/repo/summary file which becomes
outdated as apps are updated and installed. This causes problems for the
next invocation of (a recent version of) the create-usb command which
will use the outdated summary during the pull and fail with an error
message like:

error: Importing 3b1293596e9aa67f6fd0daeae477cb94603a4e8ca9e825f446d3dd04a2b5d5ec.commit:
fstatat(3b/1293596e9aa67f6fd0daeae477cb94603a4e8ca9e825f446d3dd04a2b5d5ec.commit): No such file or directory

So this commit makes the create-usb command delete the summary if it
exists before pulling onto the repo on the USB drive. This means USB
copies will work again for any users that used the USB app copy feature
in Endless OS 3.4.7.

Closes: #2854
Approved by: alexlarsson
2019-04-24 13:28:21 +00:00
Matthias Clasen
f28e62add1 oci: Handle cancellations for appstream
When an appstream update is cancelled while downloading
icons, properly fail. Otherwise, the next update attempt
will see an up-to-date timestamp, think everyhing is ok
and not download the missing icons.

Closes: https://github.com/flatpak/flatpak/issues/2835

Closes: #2836
Approved by: alexlarsson
2019-04-23 07:37:10 +00:00
David Hewitt
d0842a1e4c flatpak_installation_update_appstream: mark arch as nullable
Closes: #2826
Approved by: matthiasclasen
2019-04-15 03:23:29 +00:00
Alexander Larsson
f9bf5fb5f9 utils: Add backport of g_clear_handle_id to pre 2.56 glib 2019-04-12 14:32:06 +02:00
Umang Jain
e17b2635d6 run: Support migration from old app-ids to new app-id
flatpak run checks if there is any previous-ids for the app and
sees if there is a corresponding app-dir in ~/.var/app/ .
If so, it renames that app-dir to the new app-id and provides
a symlink from old app-id dir to new app-id dir, and exposes
these symlinks to the sandbox. The symlink is needed because even
though the XDG_DATA_DIR and other environment variables are set
to the new ID by flatpak run, the app itself could've stored
(eg in GSettings, or other files) paths which contained the old ID.

https://phabricator.endlessm.com/T23532

Closes: #2775
Approved by: alexlarsson
2019-04-12 08:59:35 +00:00
Umang Jain
3c55320539 context: Add support forexposing extra app id dirs
This will be used to export old app id dirs after a rebase.

Closes: #2775
Approved by: alexlarsson
2019-04-12 08:59:35 +00:00
Ryan Gonzalez
7185a00c85 transaction: Add end-of-lifed-with-rebase signal and add_rebase()
end-of-lifed-with-rebase runs earlier in the transaction system than end-of-lifed, meaning it can modify the transaction for rebasing.
The new flatpak_transaction_add_rebase() function can then be used to apply the rebase if wanted.

Closes: #2775
Approved by: alexlarsson
2019-04-12 08:59:35 +00:00
Alexander Larsson
6059a1ae3a transaction: Loop resolve until no longer necessary
With the new eol signal the list of ops can change during a resolve
operation, in which case we need to loop until things are stable.

Closes: #2775
Approved by: alexlarsson
2019-04-12 08:59:35 +00:00
Will Thompson
a9462d80c8 dir: add previous-ids to exported .desktop files when deploying
When migrating an installed app from eos-apps to Flathub, it may have
had a different app ID (com.example.App) in eos-apps to the Flathub ID
(net.example.app). The migration logic arranges for previous-ids to be
set in the deploy file, and flatpak-dir.c preserves this across app
updates.

A user may have the app on their desktop or pinned to the taskbar under
its old ID, and the Shell uses X-Flatpak-RenamedFrom to update these to
the new ID. The migration logic arranges for the old ID to be added to
X-Flatpak-RenamedFrom at migration time; we need to also preserve this
across app updates.

Note that the Flathub version of the app may well have its own entries
in X-Flatpak-RenamedFrom. It is unlikely that these will overlap with
ours, but for neatness we take care to avoid adding duplicates.

https://phabricator.endlessm.com/T23845

Rebase 1.1.3 (T25194): Fix some minor merge conflicts

Closes: #2775
Approved by: alexlarsson
2019-04-12 08:59:35 +00:00
Alexander Larsson
6f1243190f dir: Add and track previous ids in the deply data
Nothing sets this yet, but when it does it gets inherited across
updates, etc.

Closes: #2775
Approved by: alexlarsson
2019-04-12 08:59:35 +00:00
Alexander Larsson
6d757f865e dir: Tweak flatpak_ensure_data_dir() function
Instead of returning the data dir it now takes it as an argument
This will help us later avoid recomputing it.

Closes: #2775
Approved by: alexlarsson
2019-04-12 08:59:35 +00:00
Alexander Larsson
3607e8f7f7 utils: Add flatpak_has_name_prefix helper
Closes: #2775
Approved by: alexlarsson
2019-04-12 08:59:35 +00:00
Ryan Gonzalez
89a6782c55 utils: Add flatpak_strv_merge
Closes: #2775
Approved by: alexlarsson
2019-04-12 08:59:35 +00:00
Valentin David
8ce289b4c3 Add support for PCSC socket
Closes: #2778
Approved by: alexlarsson
2019-04-12 06:37:44 +00:00
Matthias Clasen
67b8d19f93 Write out negative D-Bus policy entries
Write out =none lines for D-Bus policy entries.

Closes: #2818
Approved by: alexlarsson
2019-04-12 06:31:05 +00:00
Matthias Clasen
44c540a1c4 Allow overriding bus names to none
flatpak override could set a bus name policy to
talk or own, but not to none. Fix this oversight.

Closes: https://github.com/flatpak/flatpak/issues/2722

Closes: #2818
Approved by: alexlarsson
2019-04-12 06:31:05 +00:00
Alexander Larsson
386e3d4799 When updating a remote, import new values for comment/description/homepage/icon
Closes: #2814
Approved by: alexlarsson
2019-04-10 14:34:32 +00:00
Alexander Larsson
4c9cc48572 build-update: Inject comment/description/homepage/icon into the summary file
This is the same that we do for the title, and will allow clients to
updating its copy of the fields.

Closes: #2814
Approved by: alexlarsson
2019-04-10 14:34:32 +00:00
Alexander Larsson
889e3b862a build-update-repo: Support setting comment/description/homepage/icon
This just sets the option in the "flatpak" group, similar to how
the title works. Nothing uses this yet.

Closes: #2814
Approved by: alexlarsson
2019-04-10 14:34:32 +00:00
Matthias Clasen
f3ca031d00 Add FlatpakRemote api for flatpakrepo fields
This makes the new flatpakrepo fields available
to users of libflatpak.

Closes: #2812
Approved by: alexlarsson
2019-04-10 11:57:16 +00:00
Matthias Clasen
3761aa5576 dir: Add private api for flatpakrepo fields
These will be used in the following commits.

Closes: #2812
Approved by: alexlarsson
2019-04-10 11:57:15 +00:00
Umang Jain
081c3400b4 utils: Add backported version of g_hash_table_steal_extended
Closes: #2657
Approved by: alexlarsson
2019-04-09 09:18:15 +00:00
Umang Jain
a9cee021b5 dir: Integrate revokefs-fuse for flatpak updates codepath
Closes: #2657
Approved by: alexlarsson
2019-04-09 09:18:15 +00:00