Commit Graph

162 Commits (2618a19716856d2b107acc0b5b63838e1379ef45)

Author SHA1 Message Date
Alexander Larsson 95bab6cd91 common: Minor whitespace cleanup 2016-10-25 10:29:51 +02:00
Jan Jedelský 47e9283450 Add support for unmaintained extensions (#361)
See https://github.com/flatpak/flatpak/issues/167
2016-10-25 10:25:15 +02:00
Alexander Larsson 6f1709c849 install: Show entire ref in the multiple-branches error message 2016-10-24 15:34:59 +02:00
Alexander Larsson 32d5418605 Don't use the system-helper if disabled
I.e. if there is a system-installed helper, then we should not use
it if flatpak was built without the system helper.
2016-10-24 15:27:42 +02:00
Alexander Larsson 01a68e697b Work around ostree partial commit issue
This works around:
  https://github.com/ostreedev/ostree/issues/541

Which is causing us to not pull the entire set of objects, rather
stopping at the first object which is locally available. We fix
this by pulling twice in the subdirs != NULL case, which works
because the second time the new commit is marked partial and
we then pull the entire thing.
2016-10-24 14:36:19 +02:00
Alexander Larsson f673d544c9 Use ostree pull inherit-transation to make extra-data transactional
This means we will not end up with a partial download if something
goes wrong during the extra-data download, because we don't
commit the downloaded base files until everything is finished.

Note, this requires the latest ostree for this feature.
2016-10-24 14:36:19 +02:00
Alexander Larsson 87cc951f4a Use the new ostree argument to pull multiple subdirs in a singe pull 2016-10-24 14:36:19 +02:00
Alexander Larsson d7a102210f extra-data: After applying extra-data, export any exports 2016-10-21 08:57:42 +02:00
Alexander Larsson 906b3b5871 dir: When pulling/deploying an app, support xa.extra-data-sources
If the downloaded app has a "xa.extra-data-sources" property in
the commit, then we download these as part of the pull operation
and store the result in the commitmeta object in the repo.

Then during deploy we look at the xa.extra-data-sources properties
again and extract them from the commitmeta into /app/extra
in the app, and afterwards we run /app/bin/apply_extra in a minimal
sandbox that has read-write access to /app/extra, but nowhere else.

There are some complexities:

We need to re-verify when extracting, because the commitmeta is not
really signed, so we could have picked up random stuff there
from the upstream repo, or from an attacker misusing the system-helper
local install codepath.

When using the system-helper the pull will fail if the commitmeta
is to large, so we have some code in this case to manually transfer
the larger commitmeta on the side to the local-pull code.
2016-10-21 08:57:42 +02:00
Alexander Larsson 9a45517536 update: Make --commit=ID actually download that commit
Before it would fail if the commit wasn't accidentally locally.
2016-10-20 09:15:10 +02:00
Alexander Larsson 27654ceb2f FlatpakDir: Fix timeout of summary cache
There was a msec/usec mismatch in the code that made
the summary cache time out 1000 times to soon.
2016-10-19 18:39:11 +02:00
Alexander Larsson 89244ee71f system-helper: Add debug spew for all system helper calls
This helps when debugging failures.
2016-10-19 12:41:08 +02:00
Alexander Larsson 28261d839e update/install: Install/Update runtime dependencies as needed
When an application requires a runtime that is not installed, search
for it and prompt for permissions to install it. Also, update required
runtimes when the app is being updated.
2016-10-19 12:40:49 +02:00
Alexander Larsson b2af78fb6f remotes: Add no-use-for-deps property
If this is set for a remote we will never automatically look for
dependencies in it. This makes dependency search faster, as we
don't need to search in app-only remotes.
2016-10-19 11:34:22 +02:00
Alexander Larsson 94295873e9 Summary cache: Fix valgrind report
We need to use g_hash_table_replace() to avoid the old freed key being
left in the hashtable.
2016-10-19 11:34:22 +02:00
Alexander Larsson 3c2b8a92b1 FlatpakDir: Fix leak in fetch_remote_title/default_branch
We were not freeing the GVariant returned by g_variant_dict_end.
In fact, we don't need the GVariantDict at all.
2016-10-18 10:10:03 +02:00
Alexander Larsson cb744c2d13 tests: Fix assert comming from ostree
It seems that ostree_repo_remote_fetch_summary asserts if you
pass a NULL error, so lets not do that.
2016-10-18 10:09:09 +02:00
Alexander Larsson aa081420a4 Fix whitespace issues 2016-10-17 17:27:51 +02:00
Mario Sanchez Prada 7e5f2580a6 New internal API to update configuration of remotes from their summary file
The new function flatpak_dir_update_remote_configuration() can be called
to fetch the contents of the summary file from the remote's source location
and update the local configuration in the installation directory accordingly.

For now, only the xa.title and xa.default-branch configuration parameters
are supported, since those seem to be the only relevant ones at the moment.
2016-10-14 16:42:17 +01:00
Mario Sanchez Prada 44dcc77a18 Check and use the remote's default branch when installing flatpaks
If no branch is explicitly stated when installing a flatpak, and several
options (branches) are available for the same ID, we now check the remote's
default branch and use that one, if it's defined and available for the app.

https://github.com/flatpak/flatpak/issues/221
2016-10-14 16:42:17 +01:00
Mario Sanchez Prada 7ed464834f Refactor code for fetching the remote's title and the default branch 2016-10-14 16:23:15 +01:00
Mario Sanchez Prada c492def9a7 Fetch the default branch when adding a remote from its repo's summary file
Just like we do with the title, fetch the default-branch from the
repository's summary file and use that information when adding a
remote reference from the command line.

https://github.com/flatpak/flatpak/issues/221
2016-10-14 16:23:15 +01:00
Alexander Larsson a5d1f6331b install: Better not-found error message
This adds more details about what was not found
2016-10-14 13:25:58 +02:00
Alexander Larsson c23316cb5d Add FlatpakKinds flag and use instead of booleans 2016-10-14 11:20:53 +02:00
Alexander Larsson 5be7e4deb7 common: Remove unused variables 2016-10-06 12:31:54 +02:00
Alexander Larsson bef4de5308 Support default-branch setting in remote configuration
For now this is a purely client side setting which lets you store
the default branch to use for a remote. This is mostly meant to
be used for UI tools, although the CLI could also be made to use this.

You can set this manually in the CLI with --default-branch, or via a
flatpakrepo file (new key DefaultBranch).
2016-10-06 11:36:28 +02:00
Alexander Larsson 9e6421d0d9 common: Accept empty/no url in modify_remote
This means that the remote is there, but disabled.
This is needed for e.g. bundles without origin url, and when bundles
starting using this codepath this regressed like in:
 https://github.com/flatpak/flatpak/issues/314
2016-09-19 16:27:54 +02:00
Matthias Clasen 06c7aca9f9 Make flatpak_is_valid_branch set a GError
Return detailed information about the problem with the branch in
the GError. Update all callers.
2016-09-13 13:28:42 -04:00
Matthias Clasen b2b281e485 Make flatpak_is_valid_name set a GError
Return detailed information about the problem with the name in
the GError. Update all callers.
2016-09-12 23:25:54 -04:00
Alexander Larsson edac377e86 origin remotes: Store main ref
If you install an app via a bundle of a .flatpakref file then
the ref of the app is also saved with the remote metadata.
2016-09-12 11:58:22 +02:00
Alexander Larsson fba645a999 Remove unused local variables reported by clang 2016-09-12 11:11:35 +02:00
Alexander Larsson 3fafba8b1e Don't use deprecated ostree_repo_checkout_tree_at function
We now use the new (almost identical) ostree_repo_checkout_at.
2016-09-12 09:03:33 +02:00
Alexander Larsson 71500ae5ec Add support for .flatpakref files
These are similar to .flatpakrepo, but for a single app.

For example, if you have a file gedit.flatpakref with this:

[Flatpak Ref]
Title=GEdit
Name=org.gnome.gedit
Branch=stable
Url=http://sdk.gnome.org/repo-apps/
IsRuntime=False
GPGKey=mQENBFUUCGcBCAC/K9WeV4xCaKr3NKRqPXeY5mpaXAJyasLqCtrDx92WUgbu0voWrhohNAKpqizod2dvzc/XTxm3rHyIxmNfdhz1gaGhynU75Qw4aJVcly2eghTIl++gfDtOvrOZo/VuAq30f32dMIgHQdRwEpgCwz7WyjpqZYltPAEcCNL4MTChAfiHJeeiQ5ibystNBW8W6Ymf7sO4m4g5+/aOxI54oCOzD9TwBAe+yXcJJWtc2rAhMCjtyPJzxd0ZVXqIzCe1xRvJ6Rq7YCiMbiM2DQFWXKnmYQbj4TGNMnwNdAajCdrcBWEMSbzq7EzuThIJRd8Ky4BkEe1St6tuqwFaMZz+F9eXABEBAAG0KEdub21lIFNESyAzLjE2IDxnbm9tZS1vcy1saXN0QGdub21lLm9yZz6JATgEEwECACIFAlUUCGcCGwMGCwkIBwMCBhUIAgkKCwQWAgMBAh4BAheAAAoJEArkz6VV0VKBa5cH/0vXa31YgEjNk78gGFXqnQxdD1WYA87OYxDi189l4lA802EFTF4wCBuZyDOqdd5BhS3Ab0cR778DmZXRUP2gwe+1zTJypU2JMnDpkwJ4NK1VP6/tE4SAPrznBtmb76BKaWBqUfZ9Wq1zg3ugvqkZB/Exq+usypIOwQVp1KL58TrjBRda0HvRctzkNhr0qYAtkfLFe0GvksBp4vBm8uGwAx7fw/HbhIjQ9pekTwvB+5GwDPO/tSip/1bQfCS+XJB8Ffa04HYPLGedalnWBrwhYY+G/kn5Zh9L/AC8xeLwTJTHM212rBjPa9CWs9C6a57MSaeGIEHLC1hEyiJJ15w8jmY=

You can then install gedit with
  flatpak install --from gedit.flatpakref
2016-09-09 16:50:32 +02:00
Alexander Larsson 65a1ba186f bundles: Support updating from a bundle
Now:
 flatpak install --bundle $file
Will update the bundle if its already installed.
2016-09-09 14:54:38 +02:00
Alexander Larsson fbca999cc9 Create /app/(.updated|.removed) file after update/uninstall
This way running apps can easily detect this and restart themselves.
2016-09-06 09:16:04 +02:00
Alexander Larsson a788965eec Support FLATPAK_USER_DIR env var 2016-09-05 21:41:14 +02:00
Alexander Larsson b678431197 Treat remotes with empty url as disabled
This happens with e.g. remotes from a bundle with no origin.

Fixes https://github.com/flatpak/flatpak/issues/270
2016-08-29 12:03:33 +02:00
Alexander Larsson d637d471fb Fix double-free during install/update 2016-08-24 15:42:01 +02:00
Alexander Larsson 522ac5200b update: Disable update shortcut for local repos
These may not have up-to-date summaries
2016-08-23 14:33:48 +02:00
Alexander Larsson c17e073f81 update: Add early check for nop updates using cached summary
This makes flatpak update a lot faster.
2016-08-23 12:30:41 +02:00
Alexander Larsson 6578d37984 Drop libgsystem dependency 2016-08-22 16:00:33 +02:00
Alexander Larsson 540a3a49df Drop use of gs_file_open_in_tmpdir_at
We import a copy of this
2016-08-22 15:44:52 +02:00
Alexander Larsson c14fbc3efb Drop calls to gs_file_rename
We make an equivalent helper inline.
2016-08-22 15:28:17 +02:00
Alexander Larsson 289ae4474b Use glnx_gen_temp_name instead of gs_fileutil_gen_tmp_name
+      enter the commit message for your changes. Lines starting
2016-08-22 15:20:39 +02:00
Alexander Larsson be8dae4693 Convert to glxn_* console helpers instead of gs_* 2016-08-22 15:08:59 +02:00
Alexander Larsson fcffefee26 Replace openat() calls from libgsystem 2016-08-22 14:12:31 +02:00
Alexander Larsson 65f1cf993d Create and use flatpak_file_get_path_cached
This is simpler that the one in libgs, as well as lockless. Also, it
removes one more use of libgs.
2016-08-22 10:22:42 +02:00
Alexander Larsson 9c907c992d Replace gs_shutil_rm_rf with small helper wrapper over libglnx 2016-08-22 10:06:08 +02:00
Alexander Larsson e0bd22bfe8 Add flatpak_mkdir_p helper and use it
This replaces all current callers of gs_file_ensure_directory with
equivalent code.

Actually, two instances were calling gs_file_ensure_directory with
FALSE, i.e. error out on EEXIST, but those cases seem fine with the
do-nothing-if-exists semantics.
2016-08-22 09:29:24 +02:00
Matthias Clasen 1e7bd752bf Don't handle already-installed error too early
Leave this to the callers which may well print out a
different message depending on whether the update did
anything or not.
2016-08-04 18:41:01 -04:00
Matthias Clasen 75218c4a65 Fix license headers
We were referring to the nonexisting "version 2" of the
Lesser GPL. It should be "version 2.1".
2016-07-29 14:27:49 -04:00
Alexander Larsson 764cb91cbe Remove workaround for issue #144 now that ostree is fixed
The fix for this is in ostree 2016.7

https://github.com/flatpak/flatpak/issues/144
2016-07-29 01:20:40 +02:00
Matthias Clasen 8732c5a8fb Translate errors
These show up in the UI and often refer to (translated) parts of
the UI.
2016-07-23 14:37:02 -04:00
Cosimo Cecchi a8e3e1826f FlatpakDir: use correct function to free FlatpakContext refs
These are not keyfiles. This fixes a crash when launching applications
through gnome-sofware.
2016-07-14 17:26:02 -07:00
Alexander Larsson 51663de427 Remove unused variables 2016-07-01 14:45:53 +02:00
Alexander Larsson 4a40fece78 Add flatpak_dir_install_or_update
This is needed in the case where we can do any, such as when
installing related refs, which may be already installed.
2016-06-30 16:55:31 +02:00
Alexander Larsson 8293527dbd FlatpakDir: Add flatpak_dir_find_remote/local_related
This lets us find all the "related" refs to a ref in a particular
remote, or locally.  These are the things we should automatically
download or delete when installing/updating/uninstalling the ref.

The implementation currently looks at all the extensions handled by the
app/runtime. For debug extensions and extensions marked no-autodownload we
only consider them related if its already locally installed. For locale
extensions we always consider them related, but we only pull the current
locale data for it.
2016-06-30 16:55:26 +02:00
Alexander Larsson 9be05bc511 common: Remove unused functions 2016-06-29 16:43:02 +02:00
Simon McVittie ee99e8afff Add BWRAP and --with-system-bubblewrap configure arguments
This lets distributors share a system copy of bubblewrap (>= 0.1.0)
between Flatpak and any other projects that benefit from it, if they are
careful to keep new versions in sync. The default is still to use the
bundled submodule, ensuring compatibility and simplifying dependencies.

Enable $PATH search everywhere that runs bwrap, so that $BWRAP doesn't
necessarily need to be a fully-qualified path.

Signed-off-by: Simon McVittie <smcv@debian.org>
2016-06-26 11:09:03 +01:00
Alexander Larsson f9ce1b16ed Make finding refs handle multi-arch
If opt_arch is not specified:
 * find_xxx_refs now return refs for all supported arches
 * find_xxx_ref looks at each supported arch in prio order
2016-06-23 12:52:55 +02:00
Alexander Larsson 9915e3740b Disable static deltas for system-helper updates
Due to an issue with ostree (https://github.com/ostreedev/ostree/pull/362)
applying non-from-scratch deltas fail when using parent_repo such as
in the system-helper case. We fix this temporarily by disabling the
use of deltas for that case.
2016-06-23 12:16:02 +02:00
Alexander Larsson 34faddfa8f common: Make some internal functions static 2016-06-23 11:31:19 +02:00
Alexander Larsson cbe35fedbc system-helper: Correctly copy the system config when modifying a repo
We were accidentally using the passed in copy of the rest of the config
when we should be using the one we read.
2016-06-16 19:56:50 +02:00
Alexander Larsson 874fbbff34 Fix various leaks 2016-06-10 12:59:30 +02:00
Matthias Clasen 26b083333a Fix a case of NULL<>FALSE confusion
This causes a compiler warning.
2016-06-08 20:05:26 -04:00
Alexander Larsson 70093d426f lib: Fix crash on install/update due to uninitialized dir->repo 2016-06-08 13:49:01 +02:00
Alexander Larsson cfef57e343 Properly handle subpaths on update 2016-06-07 22:12:51 +02:00
Alexander Larsson 77f1d7660c Don't abort on errors when pruning
This could happen for local partial pulls, due to a bug in ostree
where it didn't create commitpartial state files during local pulls.
2016-06-07 22:12:51 +02:00
Alexander Larsson a0358c8785 Handle non-existing dirs when deploying a subpath 2016-06-03 18:03:23 +02:00
Alexander Larsson e769af8661 system-helper: Handle installing bundles 2016-06-03 16:04:10 +02:00
Alexander Larsson 8ef84cc3d1 Move shared bundle install code to flatpak_dir_install_bundle 2016-06-03 14:30:25 +02:00
Alexander Larsson 21ab14b19a Improve deployment of appstream data
This has several improvements:
 * Writes to a temporary location and renames at the end, so
   we never end up with partial checkouts.
 * Don't fsync each file during checkout, instead syncfs() at
   the end
 * Pre-create the target deployment directory so that we get the right
   permissions for it.
2016-06-03 14:30:25 +02:00
Alexander Larsson 13707f6b18 system-helper: Support directly pulling local remotes
For a local (file:// uri) remote, do an (untrusted) direct pull instead
of pulling into the users cached repo first. This way we do less copies,
as well as guaranteeing the source of the data. The later means its
mostly safe to also allow this for non-gpg signed remotes.
2016-06-02 15:30:08 +02:00
Sam Spilsbury 4fb1ae0b45 remote: Make the error message when summary_bytes == NULL more informative
It seems like one common user-error that could cause this is when
the remote URL was invalid.
2016-06-01 06:03:47 +00:00
Sam Spilsbury c533e1aee6 summary: Make flatpak_cache_dir_summary static void
This function always returned NULL, and the return value was never
checked.
2016-06-01 05:59:54 +00:00
Sam Spilsbury d9ec859878 summary: Don't cache summary if none was returned
ostree_repo_remote_fetch_summary can set out_summary to NULL but
still return TRUE according to the documentation, so don't assume
that *out_summary will always be set.
2016-06-01 05:58:21 +00:00
Alexander Larsson 733a28c9c4 Deply: Disable per-file fsync and do a single syncfs when deploy is done
This should perform a lot better
2016-05-31 14:41:04 +02:00
Alexander Larsson bd7cf1af93 install: Better check for pre-existing installation
We need an actual active installation, not just the base directory.

This caused a failure if the user had tried to install and app but the
installation failed. After that installation failed due to it claiming
to be installed, while uninstall failed due it it *not* being
installed.
2016-05-30 16:35:50 +02:00
Alexander Larsson 8533f06dc0 Add more completions 2016-05-30 14:54:22 +02:00
Alexander Larsson eeaa832095 Replace bash completion shell script with C-based version
This doesn't do everything yet, but its got the basics covered.
2016-05-27 16:30:13 +02:00
Josh Soref 56e61e6a4a spelling: deployments 2016-05-27 06:39:17 +00:00
Alexander Larsson 1d8408e381 uninstall: When uninstalling the current branch, make other version current (if any) 2016-05-26 20:03:51 +02:00
Alexander Larsson c48272c6db uninstall: Default to whatever branch is installed 2016-05-26 19:08:46 +02:00
Alexander Larsson bf294fb7c5 install: Be smarter about choosing the default branch name
We look for any matching ref on the remote and use that if there is a single match.
2016-05-26 19:06:51 +02:00
Alexander Larsson b85e7f0de7 Don't use a local child repo of the system one if root
This is unnecessary, and risks creating files as root in the users
home directory if run under sudo.
2016-05-24 09:55:50 +02:00
Alexander Larsson 910328e535 Support no-deploy and no-pull via system helper 2016-05-20 13:30:50 +02:00
Alexander Larsson b697a78dd3 system-helper: Support running unprivileged on session bus
This is only useful for testing.
2016-05-17 13:06:59 +02:00
Alexander Larsson 18992c2fa0 Look at FLATPAK_SYSTEM_DIR env var for default system dir
This is useful for testing
2016-05-17 11:55:41 +02:00
Alexander Larsson 251dcdb680 system-helper: Never use a system helper recursively 2016-05-17 11:54:44 +02:00
Alexander Larsson 90c909a932 Fix clang warnings 2016-05-13 16:26:47 +02:00
Alexander Larsson 1504f7bd7f system-helper: Support add/modify/delete of remotes 2016-05-13 16:23:43 +02:00
Alexander Larsson 2875cdead5 remote-delete: Move to FlatpakDir and add checks for installed refs
You can't remove a remote unless you --force or there are no installs
from it.
2016-05-13 14:17:46 +02:00
Alexander Larsson 753cdc97fd Fix typo: flatpak_dir_modify_remove -> flatpak_dir_modify_remote 2016-05-13 13:59:48 +02:00
Alexander Larsson 392f80a4aa FlatpakDir: Add in-memory summary cache
Remote summary files are cached for 5 minutes.
2016-05-13 13:15:45 +02:00
Alexander Larsson fa6e6c51ef Duplicate ostree_repo_remote_list_refs in FlatpakDir
This way we can later add a local summary cache to it.
2016-05-13 11:32:40 +02:00
Alexander Larsson 0098164cd6 Register dbus errors for FLATPAK_ERROR
This allows us to transparently pass them from the system helper.
2016-05-12 22:03:42 +02:00
Alexander Larsson 5407b8efc6 system-helper: Support uninstall 2016-05-12 21:23:36 +02:00
Alexander Larsson 3964504438 Fix triggers with installation dir on a symlink 2016-05-12 21:16:40 +02:00
Alexander Larsson fe0a1be5f8 common: Add flags for flatpak_dir_uninstall
This is better than a list of booleans.
2016-05-12 19:52:48 +02:00
Alexander Larsson c5e178f339 Use flatpak_dir_uninstall for app and lib 2016-05-12 17:18:14 +02:00