Commit Graph

293 Commits

Author SHA1 Message Date
Alexander Larsson
8570dcab85 run: Allow specifying an exact commit and runtime-commit
This also looks for removed but live deploys so that an app
can be re-started as long as it is live.
2018-04-04 17:25:59 +02: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
Nicholas Bishop
8e73047464 Fix a documentation comment typo 2018-03-20 19:19:06 -04:00
Kalev Lember
a9b6e31121 lib: Make gnome-software work with an empty /var/lib/flatpak
Similar to commit 6bb0196ffd that fixed
https://github.com/flatpak/flatpak/issues/113 for the flatpak CLI, this
fixes the library so that gnome-software works with an empty
/var/lib/flatpak.

Closes: #1368
Approved by: alexlarsson
2018-02-07 08:30:19 +00:00
Alexander Olofsson
3585651be7 Add semantic support for network installations
Closes: #1348
Approved by: alexlarsson
2018-02-06 09:19:34 +00:00
Philip Withnall
46db046b55 lib: Fix wording in a g_warning()
Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #1338
Approved by: mwleeds
2018-01-25 17:32:36 +00:00
Sam Spilsbury
31bd2912e1 lib: Document that flatpak_installation_update_fulls throws if up to date
This is not the ideal outcome, but it does avoid breaking
behaviour stability across versions.

Fixes #1336

Closes: #1337
Approved by: alexlarsson
2018-01-25 09:10:26 +00:00
Dan Nicholson
a5b5e742fd lib/installation: Fix install/update_full() subpaths annotation
Mark subpaths as a NULL terminated array. Without this the GIR makes
this a single utf8 parameter and bindings can't use it.

Closes: #1327
Approved by: cgwalters
2018-01-19 22:53:06 +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
Philip Withnall
3f7321292b lib/installation: Tidy up memory management in get_system_installations()
This introduces no functional changes, but makes it a bit more obvious
that we do temporarily have ownership of the FlatpakInstallation
instance.

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

Closes: #1138
Approved by: alexlarsson
2017-11-01 10:23:15 +00:00
Philip Withnall
b20818a624 lib/installation: Don’t error from flatpak_get_system_installations()
If a particular system installation is inaccessible (for example,
because it doesn’t currently exist, and we don’t have permissions to
create it), don’t error out of flatpak_get_system_installations().
Instead, do what the documentation says will happen, and ignore the
failure (emit a warning message about it).

The function continues to return an error if *no* installations could be
found.

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

Closes: #1138
Approved by: alexlarsson
2017-11-01 10:23:15 +00:00
Alexander Larsson
20162bb382 lib: Add api for getting and setting config options
This is primarily for setting the language atm

Closes: #1123
Approved by: alexlarsson
2017-10-20 20:06:38 +00:00
Philip Withnall
6e6354b877 lib/installation: Fix some typos in error message strings
Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #1070
Approved by: alexlarsson
2017-10-04 12:32:56 +00:00
Sam Spilsbury
88be75cbb3 lib: Add flatpak_installation_prune_local_repo
This is a method to explicitly prune the local repo, which
users might want to use if they had explicitly removed refs from
the underlying flatpak repo and want to ensure that the objects
referred to by those refs are cleared to save on disk space.

Closes: #1034
Approved by: alexlarsson
2017-09-28 15:39:05 +00:00
Sam Spilsbury
6236a60a1b lib: Add methods to clean up refs in the local repository
In some cases, a user might pull a ref into the local repository and
not deploy it by using FLATPAK_INSTALL_FLAGS_NO_DEPLOY. Later on, that
user might decide that they don't want to deploy the ref after all,
but there was no way to remove that ref from the local repository
in the public API, so it takes up disk space.

Add flatpak_installation_remove_local_ref_sync to remove a given
ref from the local repository if the ref is known and
flatpak_installation_cleanup_local_refs_sync to remove all undeployed
refs.

Fixes #1031

Closes: #1034
Approved by: alexlarsson
2017-09-28 15:39:05 +00:00
Sam Spilsbury
cdbfb001df lib: Fix copy-paste errors in documentation
Closes: #1034
Approved by: alexlarsson
2017-09-28 15:39:05 +00:00
Alexander Larsson
8677420e07 Fix since 0.9.12.12 (to be 0.9.13) 2017-09-20 09:07:51 +02:00
Sam Spilsbury
5ecfd0ca66 lib: Add support for FLATPAK_INSTALL_FLAGS_NO_DEPLOY / NO_PULL
We have the same flags for flatpak_installation_update and we use
flatpak_dir_install from within FlatpakInstallation but always set
the no_pull/no_deploy flags to FALSE. Previously, passing
FLATPAK_INSTALL_FLAGS_NO_PULL and FLATPAK_INSTALL_FLAGS_NO_DEPLOY
wouldn't do anything because of that.

This has the unfortunate side effect of always returning an error
when FLATPAK_INSTALL_FLAGS_NO_DEPLOY is passed, because
flatpak_installation_install_full tries to get a FlatpakInstalledRef
for the flatpak when it is installed, but obviously it can't do that
since installing an app in an undeployed state doesn't "install" it
so much as just cloning it to the local repository.

As a result, when FLATPAK_INSTALL_FLAGS_NO_PULL is passed, the
FLATPAK_ERROR_ONLY_PULLED Will be set and the caller must respond
accordingly.
2017-09-20 09:07:18 +02:00
Alexander Larsson
2d0ceef446 flatpak_installed_ref_load_metadata: Find correct deploy directory
We're scoping the deploy directory by the subpaths these days, so
we need to take that into account when finding the metadata file.

Fixes https://github.com/flatpak/flatpak/issues/1014
2017-09-15 16:02: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
00e5a0d325 lib/remote: Add documentation for the class properties
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-23 16:55:02 +01:00
Philip Withnall
6321bc9c93 lib: Make P2P API unconditionally public
Rather than a lot of #ifdef mess in the public headers, Alex would
prefer that the P2P API is made unconditionally public. This assumes
that they are unlikely to change in future. If they do, we just make
them return NULL or break API and drop them.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall
7b13ff2880 lib/remote: Handle clearing a collection ID in FlatpakRemote
Squash "" to NULL.

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
550ebcc4f9 lib/remote: Add enum GType for FlatpakRemoteType
This will only be built when configured with P2P support. We can’t use
glib-mkenums here, as it doesn’t know about the #ifdef
FLATPAK_ENABLE_P2P which surrounds the enum definition. By manually
writing the get_type() function, we can surround it by #ifdefs as
appropriate.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall
c4819af5a0 common: Support collection IDs for related refs and extensions
Add support for collection IDs to the code which finds and pulls
related refs and other extensions.

Currently, related refs must have the same collection ID as the parent
ref — this is the most likely scenario anyway. In future, it should be
possible to extend the code to support pulling related refs from other
collections.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall
ae7d960372 common: Support collection IDs in flatpak{ref,repo} and bundle files
These are loaded from the ref/repo/bundle metadata and added to the new
remote configuration.

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
68ab12fce1 lib: List dynamic remotes in flatpak_installation_list_remotes()
Also expose a new flatpak_remote_get_remote_type() API so that users can
query what type of remote something is — whether it’s a USB or LAN
remote, or something statically configured.

Make this all conditional on compiling with --enable-p2p.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall
30a5cf8136 common: Support collections in check_for_updates() and forward the results
Search for updates on peer to peer sources as well as the internet in
check_for_updates(), and pass the resulting OstreeRepoFinderResult array
to the pull() calls, so a consistent set of checksums are pulled.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Matthias Clasen
ed08538f92 Merge pull request #900 from pwithnall/lan-and-usb-preparation
LAN/USB preparation refactoring
2017-07-08 20:54:28 -04:00
Matthias Clasen
2d5a8ba86b Merge pull request #909 from matthiasclasen/install-flags
Check the right flags
2017-07-08 18:19:14 -04:00
Matthias Clasen
75f93606c3 Check the right flags
flatpak_installation_install_full takes FlatpakInstallFlags,
but it was checking for a FlatpakUpdateFlags field.
2017-07-07 20:20:56 -04:00
Matthias Clasen
854cb841df Fix a typo in the docs 2017-07-07 20:17:32 -04:00
Philip Withnall
81301f0ef4 general: Remove trailing \n from GLib log messages
The GLib logging framework automatically appends a \n to messages, so it
doesn’t need to be added by callers.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-07-07 17:18:24 +01: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
Emmanuele Bassi
4aa4f91a1f Add nullable annotations for progress callbacks
The progress callback arguments in the Flatpak.Installation installation
and update methods are nullable, so we should annotate them as such.
2017-06-30 10:32:14 +02:00
Alexander Larsson
e47a726061 lib: Fix update checking
There was a typo in 44cf5076
2017-05-22 15:28:53 +02:00
Alexander Larsson
1ecbf0666c lib: Add flatpak_installation_update_appstream_full_sync with progress 2017-05-22 13:32:58 +02:00
Alexander Larsson
644bb1cd41 common: Break out the flatpak progress calculator to a helper method. 2017-05-10 17:24:48 +02:00
Alexander Larsson
44cf5076fa update: Split update into check_for_update and update
This way we can avoid printing "updating foo" for every
app even if there is no update.
2017-05-09 14:08:27 +02:00
Joaquim Rocha
de2c6cc85b Add the possibility of installing/updating without static deltas
Sometimes we need to pull a commit without using static deltas to e.g.
make sure that an app with a corrupted commit can still be updated by
pulling the new commit in full.

This option has been added to the FlatpakUpdateFlags,
FlatpakInstallFlags, as well as a parameter for the CLI.
2017-05-02 15:05:48 +02:00
Georges Basile Stavracas Neto
0007edb7bd Ensure commits are available when checking for extra-data
After the introduction of linear progress reports based on
heuristics, Flatpak still couldn't make precise reports for
the extra-data field is contained in the commits. When we
were setting extra-data up, Flatpak didn't have the commits,
so it always failed.

Fix that by downloading the commits first, and then setting
up the extra-data fields.

flatpak/flatpak#609
2017-04-27 17:21:29 +02:00
Simon McVittie
646b4c468b Use correct format string for guint64 on 32-bit
Signed-off-by: Simon McVittie <smcv@debian.org>
2017-04-04 12:17:28 +02:00
Colin Walters
2618a19716 Import ostree's compiler warnings, fix up callers
In ostree I maintain what I consider a "baseline" set of compiler
warnings that should *always* be fatal for a modern C project.

I noticed while working on a previous patch that a `-Werror=format`
warning wasn't fatal.

There are a few that are really, really important like
`-Werror=missing-prototypes`. I also take some like `-Werror=misleading-indentation`
which already caught some bugs.  See also https://lwn.net/Articles/678019/
2017-03-27 10:42:36 +02:00
Georges Basile Stavracas Neto
556782ac06 Fix comment 2017-03-08 15:42:44 +01:00
Georges Basile Stavracas Neto
d74956c23a Improve progress calculation
When calculating the progress of a flatpak installation,
it considers the extra-data and OSTree pull as different
operations and that makes the progress to go back and
forth between 0% and 100%.

Consumers of this API, like GNOME Software, end up having
a bad experience reporting the progress of a Flatpak app
instalation.

Fix that by using a set of heuristics to improve the process,
splitting the operation in parts that can be tracked (or at
least estimated).
2017-03-08 15:37:28 +01:00
Richard Hughes
d2307ca8b1 Don't include newlines in error messages 2017-02-24 17:03:03 +00:00
Richard Hughes
6125dabf58 Return the container from flatpak_get_system_installations()
This matches what other functions in libflatpak do, and also fixes a memory
leak in the error path.
2017-02-23 17:26:45 +01:00
Mario Sanchez Prada
2e1740297c Report progress for extra data downloads, as we do for OSTree pulls
Otherwise, clients such as GNOME Software won't be able to report
any progress once the flatpak application has been downloaded and
we enter the stage to download the extra data.
2017-02-14 09:00:57 +01:00