New upstream version 2018.8

This commit is contained in:
Simon McVittie 2018-08-23 13:14:03 +01:00
commit 119b14e21d
26 changed files with 538 additions and 133 deletions

View File

@ -134,6 +134,7 @@ _installed_or_uninstalled_test_scripts = \
tests/test-repo-finder-mount-integration.sh \ tests/test-repo-finder-mount-integration.sh \
tests/test-summary-collections.sh \ tests/test-summary-collections.sh \
tests/test-pull-collections.sh \ tests/test-pull-collections.sh \
tests/test-config.sh \
$(NULL) $(NULL)
experimental_test_scripts = \ experimental_test_scripts = \
@ -360,7 +361,8 @@ EXTRA_DIST += \
$(NULL) $(NULL)
tests/libreaddir-rand.so: Makefile tests/libreaddir-rand.so: Makefile
$(AM_V_GEN) ln -fns ../.libs/libreaddir-rand.so tests mkdir -p tests/
$(AM_V_GEN) ln -fns ../.libs/libreaddir-rand.so tests/
ALL_LOCAL_RULES += tests/libreaddir-rand.so ALL_LOCAL_RULES += tests/libreaddir-rand.so
CLEANFILES += tests/libreaddir-rand.so tests/ostree-symlink-stamp \ CLEANFILES += tests/libreaddir-rand.so tests/ostree-symlink-stamp \
tests/ostree-prepare-root-symlink-stamp tests/ostree-remount-symlink-stamp \ tests/ostree-prepare-root-symlink-stamp tests/ostree-remount-symlink-stamp \

View File

@ -1737,9 +1737,9 @@ am__EXEEXT_23 = tests/test-basic.sh tests/test-basic-user.sh \
tests/test-remote-add-collections.sh \ tests/test-remote-add-collections.sh \
tests/test-repo-finder-mount-integration.sh \ tests/test-repo-finder-mount-integration.sh \
tests/test-summary-collections.sh \ tests/test-summary-collections.sh \
tests/test-pull-collections.sh $(am__EXEEXT_2) \ tests/test-pull-collections.sh tests/test-config.sh \
$(am__EXEEXT_20) $(am__append_67) $(am__append_70) \ $(am__EXEEXT_2) $(am__EXEEXT_20) $(am__append_67) \
$(am__EXEEXT_22) $(am__append_70) $(am__EXEEXT_22)
@ENABLE_INSTALLED_TESTS_EXCLUSIVE_FALSE@am__EXEEXT_24 = \ @ENABLE_INSTALLED_TESTS_EXCLUSIVE_FALSE@am__EXEEXT_24 = \
@ENABLE_INSTALLED_TESTS_EXCLUSIVE_FALSE@ $(am__EXEEXT_23) @ENABLE_INSTALLED_TESTS_EXCLUSIVE_FALSE@ $(am__EXEEXT_23)
am__EXEEXT_25 = $(am__EXEEXT_2) $(am__EXEEXT_24) am__EXEEXT_25 = $(am__EXEEXT_2) $(am__EXEEXT_24)
@ -2597,8 +2597,9 @@ _installed_or_uninstalled_test_scripts = tests/test-basic.sh \
tests/test-remote-add-collections.sh \ tests/test-remote-add-collections.sh \
tests/test-repo-finder-mount-integration.sh \ tests/test-repo-finder-mount-integration.sh \
tests/test-summary-collections.sh \ tests/test-summary-collections.sh \
tests/test-pull-collections.sh $(NULL) $(am__append_65) \ tests/test-pull-collections.sh tests/test-config.sh $(NULL) \
$(am__append_67) $(am__append_70) $(am__append_71) $(am__append_65) $(am__append_67) $(am__append_70) \
$(am__append_71)
experimental_test_scripts = \ experimental_test_scripts = \
$(NULL) $(NULL)
@ -7944,6 +7945,13 @@ tests/test-pull-collections.sh.log: tests/test-pull-collections.sh
--log-file $$b.log --trs-file $$b.trs \ --log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT) "$$tst" $(AM_TESTS_FD_REDIRECT)
tests/test-config.sh.log: tests/test-config.sh
@p='tests/test-config.sh'; \
b='tests/test-config.sh'; \
$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
tests/test-rofiles-fuse.sh.log: tests/test-rofiles-fuse.sh tests/test-rofiles-fuse.sh.log: tests/test-rofiles-fuse.sh
@p='tests/test-rofiles-fuse.sh'; \ @p='tests/test-rofiles-fuse.sh'; \
b='tests/test-rofiles-fuse.sh'; \ b='tests/test-rofiles-fuse.sh'; \
@ -8575,7 +8583,8 @@ src/ostree/parse-datetime.c: src/ostree/parse-datetime.y Makefile
@BUILDOPT_USE_STATIC_COMPILER_TRUE@ $(STATIC_COMPILER) -o $@ -static $(top_srcdir)/src/switchroot/ostree-prepare-root.c $(ostree_prepare_root_CPPFLAGS) $(AM_CFLAGS) $(DEFAULT_INCLUDES) @BUILDOPT_USE_STATIC_COMPILER_TRUE@ $(STATIC_COMPILER) -o $@ -static $(top_srcdir)/src/switchroot/ostree-prepare-root.c $(ostree_prepare_root_CPPFLAGS) $(AM_CFLAGS) $(DEFAULT_INCLUDES)
tests/libreaddir-rand.so: Makefile tests/libreaddir-rand.so: Makefile
$(AM_V_GEN) ln -fns ../.libs/libreaddir-rand.so tests mkdir -p tests/
$(AM_V_GEN) ln -fns ../.libs/libreaddir-rand.so tests/
tests/%-symlink-stamp: % Makefile tests/%-symlink-stamp: % Makefile
$(AM_V_GEN) set -e; \ $(AM_V_GEN) set -e; \

View File

@ -2644,10 +2644,7 @@ ostree_repo_write_config (<em class="parameter"><code><a class="link" href="ostr
<em class="parameter"><code><span class="type">GKeyFile</span> *new_config</code></em>, <em class="parameter"><code><span class="type">GKeyFile</span> *new_config</code></em>,
<em class="parameter"><code><span class="type">GError</span> **error</code></em>);</pre> <em class="parameter"><code><span class="type">GError</span> **error</code></em>);</pre>
<p>Save <em class="parameter"><code>new_config</code></em> <p>Save <em class="parameter"><code>new_config</code></em>
in place of this repository's config file. Note in place of this repository's config file.</p>
that <em class="parameter"><code>new_config</code></em>
should not be modified after - this function
simply adds a reference.</p>
<div class="refsect3"> <div class="refsect3">
<a name="ostree-repo-write-config.parameters"></a><h4>Parameters</h4> <a name="ostree-repo-write-config.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0"> <div class="informaltable"><table class="informaltable" width="100%" border="0">
@ -2664,7 +2661,7 @@ simply adds a reference.</p>
</tr> </tr>
<tr> <tr>
<td class="parameter_name"><p>new_config</p></td> <td class="parameter_name"><p>new_config</p></td>
<td class="parameter_description"><p>Overwrite the config file with this data. Do not change later!</p></td> <td class="parameter_description"><p>Overwrite the config file with this data</p></td>
<td class="parameter_annotations"> </td> <td class="parameter_annotations"> </td>
</tr> </tr>
<tr> <tr>
@ -7693,14 +7690,15 @@ describes the available branches and other metadata.</p>
regular, setting the <code class="literal">ostree.summary.expires</code> key in <em class="parameter"><code>additional_metadata</code></em> regular, setting the <code class="literal">ostree.summary.expires</code> key in <em class="parameter"><code>additional_metadata</code></em>
will aid clients in working out when to check for updates.</p> will aid clients in working out when to check for updates.</p>
<p>It is regenerated automatically after a commit if <p>It is regenerated automatically after any ref is
<code class="literal">core/commit-update-summary</code> is set.</p> added, removed, or updated if <code class="literal">core/auto-update-summary</code> is set.</p>
<p>If the <code class="literal">core/collection-id</code> key is set in the configuration, it will be <p>If the <code class="literal">core/collection-id</code> key is set in the configuration, it will be
included as <code class="literal">OSTREE_SUMMARY_COLLECTION_ID</code> in the summary file. Refs that included as <code class="literal">OSTREE_SUMMARY_COLLECTION_ID</code> in the summary file. Refs that
have associated collection IDs will be included in the generated summary have associated collection IDs will be included in the generated summary
file, listed under the <code class="literal">OSTREE_SUMMARY_COLLECTION_MAP</code> key. Collection IDs file, listed under the <code class="literal">OSTREE_SUMMARY_COLLECTION_MAP</code> key. Collection IDs
and refs in <code class="literal">OSTREE_SUMMARY_COLLECTION_MAP</code> are guaranteed to be in and refs in <code class="literal">OSTREE_SUMMARY_COLLECTION_MAP</code> are guaranteed to be in
lexicographic order.</p> lexicographic order.</p>
<p>Locking: exclusive</p>
<div class="refsect3"> <div class="refsect3">
<a name="ostree-repo-regenerate-summary.parameters"></a><h4>Parameters</h4> <a name="ostree-repo-regenerate-summary.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0"> <div class="informaltable"><table class="informaltable" width="100%" border="0">

View File

@ -398,6 +398,7 @@ _ostree_config() {
" "
local options_with_args=" local options_with_args="
--group
--repo --repo
" "

24
configure vendored
View File

@ -1,6 +1,6 @@
#! /bin/sh #! /bin/sh
# Guess values for system-dependent variables and create Makefiles. # Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for libostree 2018.7. # Generated by GNU Autoconf 2.69 for libostree 2018.8.
# #
# Report bugs to <walters@verbum.org>. # Report bugs to <walters@verbum.org>.
# #
@ -590,8 +590,8 @@ MAKEFLAGS=
# Identity of this package. # Identity of this package.
PACKAGE_NAME='libostree' PACKAGE_NAME='libostree'
PACKAGE_TARNAME='libostree' PACKAGE_TARNAME='libostree'
PACKAGE_VERSION='2018.7' PACKAGE_VERSION='2018.8'
PACKAGE_STRING='libostree 2018.7' PACKAGE_STRING='libostree 2018.8'
PACKAGE_BUGREPORT='walters@verbum.org' PACKAGE_BUGREPORT='walters@verbum.org'
PACKAGE_URL='' PACKAGE_URL=''
@ -1547,7 +1547,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing. # Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh. # This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF cat <<_ACEOF
\`configure' configures libostree 2018.7 to adapt to many kinds of systems. \`configure' configures libostree 2018.8 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]... Usage: $0 [OPTION]... [VAR=VALUE]...
@ -1617,7 +1617,7 @@ fi
if test -n "$ac_init_help"; then if test -n "$ac_init_help"; then
case $ac_init_help in case $ac_init_help in
short | recursive ) echo "Configuration of libostree 2018.7:";; short | recursive ) echo "Configuration of libostree 2018.8:";;
esac esac
cat <<\_ACEOF cat <<\_ACEOF
@ -1864,7 +1864,7 @@ fi
test -n "$ac_init_help" && exit $ac_status test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then if $ac_init_version; then
cat <<\_ACEOF cat <<\_ACEOF
libostree configure 2018.7 libostree configure 2018.8
generated by GNU Autoconf 2.69 generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc. Copyright (C) 2012 Free Software Foundation, Inc.
@ -2336,7 +2336,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake. running configure, to aid debugging if configure makes a mistake.
It was created by libostree $as_me 2018.7, which was It was created by libostree $as_me 2018.8, which was
generated by GNU Autoconf 2.69. Invocation command line was generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@ $ $0 $@
@ -3204,7 +3204,7 @@ fi
# Define the identity of the package. # Define the identity of the package.
PACKAGE='libostree' PACKAGE='libostree'
VERSION='2018.7' VERSION='2018.8'
# Some tools Automake needs. # Some tools Automake needs.
@ -5938,9 +5938,9 @@ test -n "$YACC" || YACC="yacc"
YEAR_VERSION=2018 YEAR_VERSION=2018
RELEASE_VERSION=7 RELEASE_VERSION=8
PACKAGE_VERSION=2018.7 PACKAGE_VERSION=2018.8
if echo "$CFLAGS" | grep -q -E -e '-Werror($| )'; then : if echo "$CFLAGS" | grep -q -E -e '-Werror($| )'; then :
@ -18623,7 +18623,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their # report actual input values of CONFIG_FILES etc. instead of their
# values after options handling. # values after options handling.
ac_log=" ac_log="
This file was extended by libostree $as_me 2018.7, which was This file was extended by libostree $as_me 2018.8, which was
generated by GNU Autoconf 2.69. Invocation command line was generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES CONFIG_FILES = $CONFIG_FILES
@ -18689,7 +18689,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\ ac_cs_version="\\
libostree config.status 2018.7 libostree config.status 2018.8
configured by $0, generated by GNU Autoconf 2.69, configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\" with options \\"\$ac_cs_config\\"

View File

@ -4,7 +4,7 @@ dnl update libostree-released.sym from libostree-devel.sym, and update the check
dnl in test-symbols.sh, and also set is_release_build=yes below. Then make dnl in test-symbols.sh, and also set is_release_build=yes below. Then make
dnl another post-release commit to bump the version, and set is_release_build=no. dnl another post-release commit to bump the version, and set is_release_build=no.
m4_define([year_version], [2018]) m4_define([year_version], [2018])
m4_define([release_version], [7]) m4_define([release_version], [8])
m4_define([package_version], [year_version.release_version]) m4_define([package_version], [year_version.release_version])
AC_INIT([libostree], [package_version], [walters@verbum.org]) AC_INIT([libostree], [package_version], [walters@verbum.org])
is_release_build=yes is_release_build=yes

View File

@ -53,9 +53,15 @@ Boston, MA 02111-1307, USA.
<cmdsynopsis> <cmdsynopsis>
<command>ostree config get</command> <arg choice="req">SECTIONNAME.KEYNAME</arg> <command>ostree config get</command> <arg choice="req">SECTIONNAME.KEYNAME</arg>
</cmdsynopsis> </cmdsynopsis>
<cmdsynopsis>
<command>ostree config get</command> <arg choice="req"> --group=GROUPNAME</arg> <arg choice="req"> KEYNAME</arg>
</cmdsynopsis>
<cmdsynopsis> <cmdsynopsis>
<command>ostree config set</command> <arg choice="req">SECTIONNAME.KEYNAME</arg> <arg choice="req">VALUE</arg> <command>ostree config set</command> <arg choice="req">SECTIONNAME.KEYNAME</arg> <arg choice="req">VALUE</arg>
</cmdsynopsis> </cmdsynopsis>
<cmdsynopsis>
<command>ostree config set</command> <arg choice="req"> --group=GROUPNAME</arg> <arg choice="req"> KEYNAME</arg> <arg choice="req">VALUE</arg>
</cmdsynopsis>
</refsynopsisdiv> </refsynopsisdiv>
<refsect1> <refsect1>
@ -70,5 +76,6 @@ Boston, MA 02111-1307, USA.
<title>Example</title> <title>Example</title>
<para><command>$ ostree config get core.mode</command></para> <para><command>$ ostree config get core.mode</command></para>
<para>bare</para> <para>bare</para>
<para><command>$ ostree config set --group='remote "myremote"' url http://example.com/repo</command></para>
</refsect1> </refsect1>
</refentry> </refentry>

View File

@ -87,10 +87,20 @@ Boston, MA 02111-1307, USA.
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><varname>commit-update-summary</varname></term> <term><varname>auto-update-summary</varname></term>
<listitem><para>Boolean value controlling whether or not to <listitem><para>Boolean value controlling whether or not to
automatically update the summary file after a commit. Defaults automatically update the summary file after any ref is added,
to <literal>false</literal>.</para></listitem> removed, or updated. Other modifications which may render a
summary file stale (like static deltas, or collection IDs) do
not currently trigger an auto-update.
</para></listitem>
</varlistentry>
<varlistentry>
<term><varname>commit-update-summary</varname></term>
<listitem><para>This option is deprecated. Use
<literal>auto-update-summary</literal> instead, for which this
option is now an alias.</para></listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
@ -119,21 +129,36 @@ Boston, MA 02111-1307, USA.
<varlistentry> <varlistentry>
<term><varname>min-free-space-percent</varname></term> <term><varname>min-free-space-percent</varname></term>
<listitem><para>Integer percentage value (0-99) that specifies a minimum <listitem>
percentage of total space (in blocks) in the underlying filesystem to <para>
keep free. The default value is 3.</para> Integer percentage value (0-99) that specifies a minimum percentage
<para>In case this option is co-existing with min-free-space-size (see below), of total space (in blocks) in the underlying filesystem to keep
it would be ignored and min-free-space-size check would be enforced instead. free. The default value is 3, which is enforced when neither this
</para></listitem> option nor <varname>min-free-space-size</varname> are set.
</para>
<para>
If <varname>min-free-space-size</varname> is set to a non-zero
value, <varname>min-free-space-percent</varname> is ignored.
</para>
</listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><varname>min-free-space-size</varname></term> <term><varname>min-free-space-size</varname></term>
<listitem><para>Value (in MB, GB or TB) that specifies a minimum space in the <listitem>
underlying filesystem to keep free. Also, note that min-free-space-percent <para>
and min-free-space-size are mutually exclusive. Examples of acceptable values: Value (in power-of-2 MB, GB or TB) that specifies a minimum space
500MB, 1GB etc. The default value is 0MB, which disables this check. in the underlying filesystem to keep free. Examples of acceptable
</para></listitem> values: <literal>500MB</literal> (524 288 000 bytes),
<literal>1GB</literal> (1 073 741 824 bytes),
<literal>1TB</literal> (1 099 511 627 776 bytes).
</para>
<para>
If this option is set to a non-zero value, and
<varname>min-free-space-percent</varname> is also set, this option
takes priority.
</para>
</listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>

View File

@ -31,6 +31,7 @@ Before=systemd-tmpfiles-setup.service
[Service] [Service]
Type=oneshot Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/lib/ostree/ostree-remount ExecStart=/usr/lib/ostree/ostree-remount
StandardInput=null StandardInput=null
StandardOutput=syslog StandardOutput=syslog

View File

@ -18,6 +18,8 @@
***/ ***/
/* Add new symbols here. Release commits should copy this section into -released.sym. */ /* Add new symbols here. Release commits should copy this section into -released.sym. */
LIBOSTREE_2018.9 {
} LIBOSTREE_2018.7;
/* Stub section for the stable release *after* this development one; don't /* Stub section for the stable release *after* this development one; don't
* edit this other than to update the last number. This is just a copy/paste * edit this other than to update the last number. This is just a copy/paste

View File

@ -534,6 +534,8 @@ global:
ostree_mutable_tree_check_error; ostree_mutable_tree_check_error;
} LIBOSTREE_2018.6; } LIBOSTREE_2018.6;
/* No new symbols in 2018.8 */
/* NOTE: Only add more content here in release commits! See the /* NOTE: Only add more content here in release commits! See the
* comments at the top of this file. * comments at the top of this file.
*/ */

View File

@ -445,10 +445,10 @@ throw_min_free_space_error (OstreeRepo *self,
else else
err_msg = "would be exceeded"; err_msg = "would be exceeded";
if (self->min_free_space_percent > 0) if (self->min_free_space_mb > 0)
return glnx_throw (error, "min-free-space-percent '%u%%' %s", self->min_free_space_percent, err_msg);
else
return glnx_throw (error, "min-free-space-size %" G_GUINT64_FORMAT "MB %s", self->min_free_space_mb, err_msg); return glnx_throw (error, "min-free-space-size %" G_GUINT64_FORMAT "MB %s", self->min_free_space_mb, err_msg);
else
return glnx_throw (error, "min-free-space-percent '%u%%' %s", self->min_free_space_percent, err_msg);
} }
typedef struct { typedef struct {
@ -1295,6 +1295,7 @@ write_metadata_object (OstreeRepo *self,
char actual_checksum[OSTREE_SHA256_STRING_LEN+1]; char actual_checksum[OSTREE_SHA256_STRING_LEN+1];
if (is_tombstone) if (is_tombstone)
{ {
g_assert (expected_checksum != NULL);
memcpy (actual_checksum, expected_checksum, sizeof (actual_checksum)); memcpy (actual_checksum, expected_checksum, sizeof (actual_checksum));
} }
else else
@ -2194,11 +2195,19 @@ ostree_repo_commit_transaction (OstreeRepo *self,
if (self->txn.refs) if (self->txn.refs)
if (!_ostree_repo_update_refs (self, self->txn.refs, cancellable, error)) if (!_ostree_repo_update_refs (self, self->txn.refs, cancellable, error))
return FALSE; return FALSE;
g_clear_pointer (&self->txn.refs, g_hash_table_destroy);
if (self->txn.collection_refs) if (self->txn.collection_refs)
if (!_ostree_repo_update_collection_refs (self, self->txn.collection_refs, cancellable, error)) if (!_ostree_repo_update_collection_refs (self, self->txn.collection_refs, cancellable, error))
return FALSE; return FALSE;
/* Update the summary if auto-update-summary is set, because doing so was
* delayed for each ref change during the transaction.
*/
if ((self->txn.refs || self->txn.collection_refs) &&
!_ostree_repo_maybe_regenerate_summary (self, cancellable, error))
return FALSE;
g_clear_pointer (&self->txn.refs, g_hash_table_destroy);
g_clear_pointer (&self->txn.collection_refs, g_hash_table_destroy); g_clear_pointer (&self->txn.collection_refs, g_hash_table_destroy);
self->in_transaction = FALSE; self->in_transaction = FALSE;
@ -3309,6 +3318,7 @@ write_dir_entry_to_mtree_internal (OstreeRepo *self,
} }
else else
{ {
g_assert (dfd_iter != NULL);
g_auto(GLnxDirFdIterator) child_dfd_iter = { 0, }; g_auto(GLnxDirFdIterator) child_dfd_iter = { 0, };
if (!glnx_dirfd_iterator_init_at (dfd_iter->fd, name, FALSE, &child_dfd_iter, error)) if (!glnx_dirfd_iterator_init_at (dfd_iter->fd, name, FALSE, &child_dfd_iter, error))

View File

@ -61,7 +61,8 @@ G_BEGIN_DECLS
#define OSTREE_COMMIT_TIMESTAMP "ostree.commit.timestamp" #define OSTREE_COMMIT_TIMESTAMP "ostree.commit.timestamp"
typedef enum { typedef enum {
OSTREE_REPO_TEST_ERROR_PRE_COMMIT = (1 << 0) OSTREE_REPO_TEST_ERROR_PRE_COMMIT = (1 << 0),
OSTREE_REPO_TEST_ERROR_INVALID_CACHE = (1 << 1),
} OstreeRepoTestErrorFlags; } OstreeRepoTestErrorFlags;
struct OstreeRepoCommitModifier { struct OstreeRepoCommitModifier {
@ -437,6 +438,11 @@ _ostree_repo_get_remote_inherited (OstreeRepo *self,
const char *name, const char *name,
GError **error); GError **error);
gboolean
_ostree_repo_maybe_regenerate_summary (OstreeRepo *self,
GCancellable *cancellable,
GError **error);
/* Locking APIs are currently private. /* Locking APIs are currently private.
* See https://github.com/ostreedev/ostree/pull/1555 * See https://github.com/ostreedev/ostree/pull/1555
*/ */

View File

@ -2486,7 +2486,10 @@ process_one_static_delta (OtPullData *pull_data,
OSTREE_STATIC_DELTA_OPEN_FLAGS_SKIP_CHECKSUM, OSTREE_STATIC_DELTA_OPEN_FLAGS_SKIP_CHECKSUM,
NULL, &inline_delta_part, NULL, &inline_delta_part,
cancellable, error)) cancellable, error))
return FALSE; {
fetch_static_delta_data_free (fetch_data);
return FALSE;
}
_ostree_static_delta_part_execute_async (pull_data->repo, _ostree_static_delta_part_execute_async (pull_data->repo,
fetch_data->objects, fetch_data->objects,
@ -3345,6 +3348,19 @@ initiate_request (OtPullData *pull_data,
return TRUE; return TRUE;
} }
/* If doing a delta from a ref, look up the from-revision, since we need it
* on most paths below. */
if (ref != NULL)
{
g_autofree char *refspec = NULL;
if (pull_data->remote_name != NULL)
refspec = g_strdup_printf ("%s:%s", pull_data->remote_name, ref->ref_name);
if (!ostree_repo_resolve_rev (pull_data->repo,
refspec ?: ref->ref_name, TRUE,
&delta_from_revision, error))
return FALSE;
}
/* If we have a summary, we can use the newer logic */ /* If we have a summary, we can use the newer logic */
if (pull_data->summary) if (pull_data->summary)
{ {
@ -3372,7 +3388,16 @@ initiate_request (OtPullData *pull_data,
enqueue_one_static_delta_superblock_request (pull_data, deltares.from_revision, to_revision, ref); enqueue_one_static_delta_superblock_request (pull_data, deltares.from_revision, to_revision, ref);
break; break;
case DELTA_SEARCH_RESULT_SCRATCH: case DELTA_SEARCH_RESULT_SCRATCH:
enqueue_one_static_delta_superblock_request (pull_data, NULL, to_revision, ref); {
/* If a from-scratch delta is available, we dont want to use it if
* the ref already exists locally, since we are likely only a few
* commits out of date; so doing an object pull is likely more
* bandwidth efficient. */
if (delta_from_revision != NULL)
queue_scan_one_metadata_object (pull_data, to_revision, OSTREE_OBJECT_TYPE_COMMIT, NULL, 0, ref);
else
enqueue_one_static_delta_superblock_request (pull_data, NULL, to_revision, ref);
}
break; break;
case DELTA_SEARCH_RESULT_UNCHANGED: case DELTA_SEARCH_RESULT_UNCHANGED:
{ {
@ -3392,13 +3417,6 @@ initiate_request (OtPullData *pull_data,
{ {
/* Are we doing a delta via a ref? In that case we can fall back to the older /* Are we doing a delta via a ref? In that case we can fall back to the older
* logic of just using the current tip of the ref as a delta FROM source. */ * logic of just using the current tip of the ref as a delta FROM source. */
g_autofree char *refspec = NULL;
if (pull_data->remote_name != NULL)
refspec = g_strdup_printf ("%s:%s", pull_data->remote_name, ref->ref_name);
if (!ostree_repo_resolve_rev (pull_data->repo,
refspec ?: ref->ref_name, TRUE,
&delta_from_revision, error))
return FALSE;
/* Determine whether the from revision we have is partial; this /* Determine whether the from revision we have is partial; this
* can happen if e.g. one uses `ostree pull --commit-metadata-only`. * can happen if e.g. one uses `ostree pull --commit-metadata-only`.
@ -3983,7 +4001,10 @@ ostree_repo_pull_with_options (OstreeRepo *self,
goto out; goto out;
if (bytes_summary) if (bytes_summary)
summary_from_cache = TRUE; {
g_debug ("Loaded %s summary from cache", remote_name_or_baseurl);
summary_from_cache = TRUE;
}
if (!pull_data->summary && !bytes_summary) if (!pull_data->summary && !bytes_summary)
{ {
@ -4021,12 +4042,53 @@ ostree_repo_pull_with_options (OstreeRepo *self,
if (pull_data->gpg_verify_summary && bytes_summary && bytes_sig) if (pull_data->gpg_verify_summary && bytes_summary && bytes_sig)
{ {
g_autoptr(OstreeGpgVerifyResult) result = NULL; g_autoptr(OstreeGpgVerifyResult) result = NULL;
g_autoptr(GError) temp_error = NULL;
result = ostree_repo_verify_summary (self, pull_data->remote_name, result = ostree_repo_verify_summary (self, pull_data->remote_name,
bytes_summary, bytes_sig, bytes_summary, bytes_sig,
cancellable, error); cancellable, &temp_error);
if (!ostree_gpg_verify_result_require_valid_signature (result, error)) if (!ostree_gpg_verify_result_require_valid_signature (result, &temp_error))
goto out; {
if (summary_from_cache)
{
/* The cached summary doesn't match, fetch a new one and verify again */
if ((self->test_error_flags & OSTREE_REPO_TEST_ERROR_INVALID_CACHE) > 0)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
"Remote %s cached summary invalid and "
"OSTREE_REPO_TEST_ERROR_INVALID_CACHE specified",
pull_data->remote_name);
goto out;
}
else
g_debug ("Remote %s cached summary invalid, pulling new version",
pull_data->remote_name);
summary_from_cache = FALSE;
g_clear_pointer (&bytes_summary, (GDestroyNotify)g_bytes_unref);
if (!_ostree_fetcher_mirrored_request_to_membuf (pull_data->fetcher,
pull_data->meta_mirrorlist,
"summary",
OSTREE_FETCHER_REQUEST_OPTIONAL_CONTENT,
pull_data->n_network_retries,
&bytes_summary,
OSTREE_MAX_METADATA_SIZE,
cancellable, error))
goto out;
g_autoptr(OstreeGpgVerifyResult) retry =
ostree_repo_verify_summary (self, pull_data->remote_name,
bytes_summary, bytes_sig,
cancellable, error);
if (!ostree_gpg_verify_result_require_valid_signature (retry, error))
goto out;
}
else
{
g_propagate_error (error, g_steal_pointer (&temp_error));
goto out;
}
}
} }
if (bytes_summary) if (bytes_summary)
@ -4131,7 +4193,6 @@ ostree_repo_pull_with_options (OstreeRepo *self,
{ {
const char *delta; const char *delta;
g_autoptr(GVariant) csum_v = NULL; g_autoptr(GVariant) csum_v = NULL;
guchar *csum_data = g_malloc (OSTREE_SHA256_DIGEST_LEN);
g_autoptr(GVariant) ref = g_variant_get_child_value (deltas, i); g_autoptr(GVariant) ref = g_variant_get_child_value (deltas, i);
g_variant_get_child (ref, 0, "&s", &delta); g_variant_get_child (ref, 0, "&s", &delta);
@ -4140,6 +4201,7 @@ ostree_repo_pull_with_options (OstreeRepo *self,
if (!validate_variant_is_csum (csum_v, error)) if (!validate_variant_is_csum (csum_v, error))
goto out; goto out;
guchar *csum_data = g_malloc (OSTREE_SHA256_DIGEST_LEN);
memcpy (csum_data, ostree_checksum_bytes_peek (csum_v), 32); memcpy (csum_data, ostree_checksum_bytes_peek (csum_v), 32);
g_hash_table_insert (pull_data->summary_deltas_checksums, g_hash_table_insert (pull_data->summary_deltas_checksums,
g_strdup (delta), g_strdup (delta),
@ -5255,8 +5317,9 @@ find_remotes_cb (GObject *obj,
summary_bytes, FALSE); summary_bytes, FALSE);
/* Check the summarys additional metadata and set up @commit_metadata /* Check the summarys additional metadata and set up @commit_metadata
* and @refs_and_remotes_table with all the refs listed in the summary * and @refs_and_remotes_table with the refs listed in the summary file,
* file which intersect with @refs. */ * filtered by the keyring associated with this result and the
* intersection with @refs. */
additional_metadata_v = g_variant_get_child_value (summary_v, 1); additional_metadata_v = g_variant_get_child_value (summary_v, 1);
if (g_variant_lookup (additional_metadata_v, OSTREE_SUMMARY_COLLECTION_ID, "s", &summary_collection_id)) if (g_variant_lookup (additional_metadata_v, OSTREE_SUMMARY_COLLECTION_ID, "s", &summary_collection_id))
@ -5277,6 +5340,13 @@ find_remotes_cb (GObject *obj,
while (summary_collection_map != NULL && while (summary_collection_map != NULL &&
g_variant_iter_loop (summary_collection_map, "{s@a(s(taya{sv}))}", &summary_collection_id, &summary_refs)) g_variant_iter_loop (summary_collection_map, "{s@a(s(taya{sv}))}", &summary_collection_id, &summary_refs))
{ {
/* Exclude refs that don't use the associated keyring if this is a
* dynamic remote, by comparing against the collection ID of the
* remote this one inherits from */
if (result->remote->refspec_name != NULL &&
!check_remote_matches_collection_id (self, result->remote->refspec_name, summary_collection_id))
continue;
if (!find_remotes_process_refs (self, refs, result, i, summary_collection_id, summary_refs, if (!find_remotes_process_refs (self, refs, result, i, summary_collection_id, summary_refs,
commit_metadatas, refs_and_remotes_table)) commit_metadatas, refs_and_remotes_table))
{ {
@ -5656,7 +5726,7 @@ copy_option (GVariantDict *master_options,
{ {
g_autoptr(GVariant) option_v = g_variant_dict_lookup_value (master_options, key, expected_type); g_autoptr(GVariant) option_v = g_variant_dict_lookup_value (master_options, key, expected_type);
if (option_v != NULL) if (option_v != NULL)
g_variant_dict_insert_value (slave_options, key, g_steal_pointer (&option_v)); g_variant_dict_insert_value (slave_options, key, option_v);
} }
/** /**

View File

@ -1144,6 +1144,11 @@ _ostree_repo_write_ref (OstreeRepo *self,
if (!_ostree_repo_update_mtime (self, error)) if (!_ostree_repo_update_mtime (self, error))
return FALSE; return FALSE;
/* Update the summary after updating the mtime so the summary doesn't look
* out of date */
if (!self->in_transaction && !_ostree_repo_maybe_regenerate_summary (self, cancellable, error))
return FALSE;
return TRUE; return TRUE;
} }
@ -1153,17 +1158,10 @@ _ostree_repo_update_refs (OstreeRepo *self,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
GHashTableIter hash_iter; GLNX_HASH_TABLE_FOREACH_KV (refs, const char*, refspec, const char*, rev)
gpointer key, value;
g_hash_table_iter_init (&hash_iter, refs);
while (g_hash_table_iter_next (&hash_iter, &key, &value))
{ {
const char *refspec = key;
const char *rev = value;
g_autofree char *remote = NULL; g_autofree char *remote = NULL;
g_autofree char *ref_name = NULL; g_autofree char *ref_name = NULL;
if (!ostree_parse_refspec (refspec, &remote, &ref_name, error)) if (!ostree_parse_refspec (refspec, &remote, &ref_name, error))
return FALSE; return FALSE;
@ -1253,7 +1251,6 @@ ostree_repo_list_collection_refs (OstreeRepo *self,
(GDestroyNotify) ostree_collection_ref_free, (GDestroyNotify) ostree_collection_ref_free,
g_free); g_free);
g_auto(GLnxDirFdIterator) dfd_iter = { 0, };
g_autoptr(GString) base_path = g_string_new (""); g_autoptr(GString) base_path = g_string_new ("");
const gchar *main_collection_id = ostree_repo_get_collection_id (self); const gchar *main_collection_id = ostree_repo_get_collection_id (self);
@ -1279,6 +1276,8 @@ ostree_repo_list_collection_refs (OstreeRepo *self,
{ {
const char *refs_dir = *iter; const char *refs_dir = *iter;
gboolean refs_dir_exists = FALSE; gboolean refs_dir_exists = FALSE;
g_auto(GLnxDirFdIterator) dfd_iter = { 0, };
if (!ot_dfd_iter_init_allow_noent (self->repo_dir_fd, refs_dir, if (!ot_dfd_iter_init_allow_noent (self->repo_dir_fd, refs_dir,
&dfd_iter, &refs_dir_exists, error)) &dfd_iter, &refs_dir_exists, error))
return FALSE; return FALSE;

View File

@ -313,14 +313,13 @@ finish_part (OstreeStaticDeltaBuilder *builder, GError **error)
static OstreeStaticDeltaPartBuilder * static OstreeStaticDeltaPartBuilder *
allocate_part (OstreeStaticDeltaBuilder *builder, GError **error) allocate_part (OstreeStaticDeltaBuilder *builder, GError **error)
{ {
OstreeStaticDeltaPartBuilder *part = g_new0 (OstreeStaticDeltaPartBuilder, 1);
if (builder->parts->len > 0) if (builder->parts->len > 0)
{ {
if (!finish_part (builder, error)) if (!finish_part (builder, error))
return NULL; return NULL;
} }
OstreeStaticDeltaPartBuilder *part = g_new0 (OstreeStaticDeltaPartBuilder, 1);
part->objects = g_ptr_array_new_with_free_func ((GDestroyNotify)g_variant_unref); part->objects = g_ptr_array_new_with_free_func ((GDestroyNotify)g_variant_unref);
part->payload = g_string_new (NULL); part->payload = g_string_new (NULL);
part->operations = g_string_new (NULL); part->operations = g_string_new (NULL);
@ -1522,7 +1521,7 @@ ostree_repo_static_delta_generate (OstreeRepo *self,
goto out; goto out;
} }
g_variant_builder_add_value (part_headers, g_variant_ref (part_builder->header)); g_variant_builder_add_value (part_headers, part_builder->header);
total_compressed_size += part_builder->compressed_size; total_compressed_size += part_builder->compressed_size;
total_uncompressed_size += part_builder->uncompressed_size; total_uncompressed_size += part_builder->uncompressed_size;

View File

@ -1187,6 +1187,7 @@ ostree_repo_init (OstreeRepo *self)
static gsize gpgme_initialized; static gsize gpgme_initialized;
const GDebugKey test_error_keys[] = { const GDebugKey test_error_keys[] = {
{ "pre-commit", OSTREE_REPO_TEST_ERROR_PRE_COMMIT }, { "pre-commit", OSTREE_REPO_TEST_ERROR_PRE_COMMIT },
{ "invalid-cache", OSTREE_REPO_TEST_ERROR_INVALID_CACHE },
}; };
if (g_once_init_enter (&gpgme_initialized)) if (g_once_init_enter (&gpgme_initialized))
@ -1440,12 +1441,10 @@ ostree_repo_copy_config (OstreeRepo *self)
/** /**
* ostree_repo_write_config: * ostree_repo_write_config:
* @self: Repo * @self: Repo
* @new_config: Overwrite the config file with this data. Do not change later! * @new_config: Overwrite the config file with this data
* @error: a #GError * @error: a #GError
* *
* Save @new_config in place of this repository's config file. Note * Save @new_config in place of this repository's config file.
* that @new_config should not be modified after - this function
* simply adds a reference.
*/ */
gboolean gboolean
ostree_repo_write_config (OstreeRepo *self, ostree_repo_write_config (OstreeRepo *self,
@ -4611,8 +4610,9 @@ ostree_repo_pull_default_console_progress_changed (OstreeAsyncProgress *progress
if (bytes_sec > 0) if (bytes_sec > 0)
{ {
/* MAX(0, value) here just to be defensive */ guint64 est_time_remaining = 0;
guint64 est_time_remaining = MAX(0, (total_delta_part_size - fetched_delta_part_size)) / bytes_sec; if (total_delta_part_size > fetched_delta_part_size)
est_time_remaining = (total_delta_part_size - fetched_delta_part_size) / bytes_sec;
g_autofree char *formatted_est_time_remaining = _formatted_time_remaining_from_seconds (est_time_remaining); g_autofree char *formatted_est_time_remaining = _formatted_time_remaining_from_seconds (est_time_remaining);
/* No space between %s and remaining, since formatted_est_time_remaining has a trailing space */ /* No space between %s and remaining, since formatted_est_time_remaining has a trailing space */
g_string_append_printf (buf, "Receiving delta parts: %u/%u %s/%s %s/s %sremaining", g_string_append_printf (buf, "Receiving delta parts: %u/%u %s/%s %s/s %sremaining",
@ -4891,7 +4891,7 @@ ostree_repo_add_gpg_signature_summary (OstreeRepo *self,
g_autoptr(GVariant) metadata = NULL; g_autoptr(GVariant) metadata = NULL;
if (!ot_openat_ignore_enoent (self->repo_dir_fd, "summary.sig", &fd, error)) if (!ot_openat_ignore_enoent (self->repo_dir_fd, "summary.sig", &fd, error))
return FALSE; return FALSE;
if (fd != -1) if (fd >= 0)
{ {
if (!ot_variant_read_fd (fd, 0, G_VARIANT_TYPE (OSTREE_SUMMARY_SIG_GVARIANT_STRING), if (!ot_variant_read_fd (fd, 0, G_VARIANT_TYPE (OSTREE_SUMMARY_SIG_GVARIANT_STRING),
FALSE, &metadata, error)) FALSE, &metadata, error))
@ -5384,8 +5384,8 @@ summary_add_ref_entry (OstreeRepo *self,
* regular, setting the `ostree.summary.expires` key in @additional_metadata * regular, setting the `ostree.summary.expires` key in @additional_metadata
* will aid clients in working out when to check for updates. * will aid clients in working out when to check for updates.
* *
* It is regenerated automatically after a commit if * It is regenerated automatically after any ref is
* `core/commit-update-summary` is set. * added, removed, or updated if `core/auto-update-summary` is set.
* *
* If the `core/collection-id` key is set in the configuration, it will be * If the `core/collection-id` key is set in the configuration, it will be
* included as %OSTREE_SUMMARY_COLLECTION_ID in the summary file. Refs that * included as %OSTREE_SUMMARY_COLLECTION_ID in the summary file. Refs that
@ -5393,6 +5393,8 @@ summary_add_ref_entry (OstreeRepo *self,
* file, listed under the %OSTREE_SUMMARY_COLLECTION_MAP key. Collection IDs * file, listed under the %OSTREE_SUMMARY_COLLECTION_MAP key. Collection IDs
* and refs in %OSTREE_SUMMARY_COLLECTION_MAP are guaranteed to be in * and refs in %OSTREE_SUMMARY_COLLECTION_MAP are guaranteed to be in
* lexicographic order. * lexicographic order.
*
* Locking: exclusive
*/ */
gboolean gboolean
ostree_repo_regenerate_summary (OstreeRepo *self, ostree_repo_regenerate_summary (OstreeRepo *self,
@ -5400,6 +5402,18 @@ ostree_repo_regenerate_summary (OstreeRepo *self,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
/* Take an exclusive lock. This makes sure the commits and deltas don't get
* deleted while generating the summary. It also means we can be sure refs
* won't be created/updated/deleted during the operation, without having to
* add exclusive locks to those operations which would prevent concurrent
* commits from working.
*/
g_autoptr(OstreeRepoAutoLock) lock = NULL;
lock = _ostree_repo_auto_lock_push (self, OSTREE_REPO_LOCK_EXCLUSIVE,
cancellable, error);
if (!lock)
return FALSE;
g_auto(GVariantDict) additional_metadata_builder = OT_VARIANT_BUILDER_INITIALIZER; g_auto(GVariantDict) additional_metadata_builder = OT_VARIANT_BUILDER_INITIALIZER;
g_variant_dict_init (&additional_metadata_builder, additional_metadata); g_variant_dict_init (&additional_metadata_builder, additional_metadata);
g_autoptr(GVariantBuilder) refs_builder = g_variant_builder_new (G_VARIANT_TYPE ("a(s(taya{sv}))")); g_autoptr(GVariantBuilder) refs_builder = g_variant_builder_new (G_VARIANT_TYPE ("a(s(taya{sv}))"));
@ -5577,6 +5591,37 @@ ostree_repo_regenerate_summary (OstreeRepo *self,
return TRUE; return TRUE;
} }
/* Regenerate the summary if `core/auto-update-summary` is set. We default to FALSE for
* this setting because OSTree supports multiple processes committing to the same repo (but
* different refs) concurrently, and in fact gnome-continuous actually does this. In that
* context it's best to update the summary explicitly once at the end of multiple
* transactions instead of automatically here. `auto-update-summary` only updates
* atomically within a transaction. */
gboolean
_ostree_repo_maybe_regenerate_summary (OstreeRepo *self,
GCancellable *cancellable,
GError **error)
{
gboolean auto_update_summary;
if (!ot_keyfile_get_boolean_with_default (self->config, "core",
"auto-update-summary", FALSE,
&auto_update_summary, error))
return FALSE;
/* Deprecated alias for `auto-update-summary`. */
gboolean commit_update_summary;
if (!ot_keyfile_get_boolean_with_default (self->config, "core",
"commit-update-summary", FALSE,
&commit_update_summary, error))
return FALSE;
if ((auto_update_summary || commit_update_summary) &&
!ostree_repo_regenerate_summary (self, NULL, cancellable, error))
return FALSE;
return TRUE;
}
gboolean gboolean
_ostree_repo_is_locked_tmpdir (const char *filename) _ostree_repo_is_locked_tmpdir (const char *filename)
{ {

View File

@ -43,7 +43,7 @@
* *
* Since: 2017.4 * Since: 2017.4
*/ */
#define OSTREE_RELEASE_VERSION (7) #define OSTREE_RELEASE_VERSION (8)
/** /**
* OSTREE_VERSION * OSTREE_VERSION
@ -52,7 +52,7 @@
* *
* Since: 2017.4 * Since: 2017.4
*/ */
#define OSTREE_VERSION (2018.7) #define OSTREE_VERSION (2018.8)
/** /**
* OSTREE_VERSION_S: * OSTREE_VERSION_S:
@ -62,7 +62,7 @@
* *
* Since: 2017.4 * Since: 2017.4
*/ */
#define OSTREE_VERSION_S "2018.7" #define OSTREE_VERSION_S "2018.8"
#define OSTREE_ENCODE_VERSION(year,release) \ #define OSTREE_ENCODE_VERSION(year,release) \
((year) << 16 | (release)) ((year) << 16 | (release))

View File

@ -262,10 +262,8 @@ data_read_cb (void *handle, void *buffer, size_t size)
g_return_val_if_fail (G_IS_INPUT_STREAM (input_stream), -1); g_return_val_if_fail (G_IS_INPUT_STREAM (input_stream), -1);
g_input_stream_read_all (input_stream, buffer, size, if (!g_input_stream_read_all (input_stream, buffer, size,
&bytes_read, NULL, &local_error); &bytes_read, NULL, &local_error))
if (local_error != NULL)
{ {
set_errno_from_gio_error (local_error); set_errno_from_gio_error (local_error);
g_clear_error (&local_error); g_clear_error (&local_error);
@ -287,7 +285,7 @@ data_write_cb (void *handle, const void *buffer, size_t size)
if (g_output_stream_write_all (output_stream, buffer, size, if (g_output_stream_write_all (output_stream, buffer, size,
&bytes_written, NULL, &local_error)) &bytes_written, NULL, &local_error))
{ {
g_output_stream_flush (output_stream, NULL, &local_error); (void)g_output_stream_flush (output_stream, NULL, &local_error);
} }
if (local_error != NULL) if (local_error != NULL)

View File

@ -752,7 +752,6 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
if (!skip_commit) if (!skip_commit)
{ {
gboolean update_summary;
guint64 timestamp; guint64 timestamp;
if (!opt_no_bindings) if (!opt_no_bindings)
@ -823,22 +822,6 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
if (!ostree_repo_commit_transaction (repo, &stats, cancellable, error)) if (!ostree_repo_commit_transaction (repo, &stats, cancellable, error))
goto out; goto out;
/* The default for this option is FALSE, even for archive repos,
* because ostree supports multiple processes committing to the same
* repo (but different refs) concurrently, and in fact gnome-continuous
* actually does this. In that context it's best to update the summary
* explicitly instead of automatically here. */
if (!ot_keyfile_get_boolean_with_default (ostree_repo_get_config (repo), "core",
"commit-update-summary", FALSE,
&update_summary, error))
goto out;
if (update_summary && !ostree_repo_regenerate_summary (repo,
NULL,
cancellable,
error))
goto out;
} }
else else
{ {

View File

@ -28,12 +28,15 @@
#include "ostree.h" #include "ostree.h"
#include "otutil.h" #include "otutil.h"
static char* opt_group;
/* ATTENTION: /* ATTENTION:
* Please remember to update the bash-completion script (bash/ostree) and * Please remember to update the bash-completion script (bash/ostree) and
* man page (man/ostree-config.xml) when changing the option list. * man page (man/ostree-config.xml) when changing the option list.
*/ */
static GOptionEntry options[] = { static GOptionEntry options[] = {
{ "group", 0, 0, G_OPTION_ARG_STRING, &opt_group , "Group name", NULL },
{ NULL } { NULL }
}; };
@ -44,7 +47,7 @@ split_key_string (const char *k,
GError **error) GError **error)
{ {
const char *dot = strchr (k, '.'); const char *dot = strchr (k, '.');
if (!dot) if (!dot)
{ {
return glnx_throw (error, return glnx_throw (error,
@ -85,18 +88,31 @@ ostree_builtin_config (int argc, char **argv, OstreeCommandInvocation *invocatio
if (!strcmp (op, "set")) if (!strcmp (op, "set"))
{ {
if (argc < 4) if (opt_group)
{ {
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, if (argc < 4)
"KEY and VALUE must be specified"); {
goto out; g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
"GROUP name, KEY and VALUE must be specified");
goto out;
}
section = g_strdup(opt_group);
key = g_strdup(argv[2]);
value = argv[3];
}
else
{
if (argc < 4)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
"KEY and VALUE must be specified");
goto out;
}
section_key = argv[2];
value = argv[3];
if(!split_key_string (section_key, &section, &key, error))
goto out;
} }
section_key = argv[2];
value = argv[3];
if (!split_key_string (section_key, &section, &key, error))
goto out;
config = ostree_repo_copy_config (repo); config = ostree_repo_copy_config (repo);
g_key_file_set_string (config, section, key, value); g_key_file_set_string (config, section, key, value);
@ -108,17 +124,29 @@ ostree_builtin_config (int argc, char **argv, OstreeCommandInvocation *invocatio
{ {
GKeyFile *readonly_config = NULL; GKeyFile *readonly_config = NULL;
g_autofree char *value = NULL; g_autofree char *value = NULL;
if (argc < 3) if (opt_group)
{ {
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, if (argc < 3)
"KEY must be specified"); {
goto out; g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
"Group name and key must be specified");
goto out;
}
section = g_strdup(opt_group);
key = g_strdup(argv[2]);
}
else
{
if(argc < 3)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
"KEY must be specified");
goto out;
}
section_key = argv[2];
if (!split_key_string (section_key, &section, &key, error))
goto out;
} }
section_key = argv[2];
if (!split_key_string (section_key, &section, &key, error))
goto out;
readonly_config = ostree_repo_get_config (repo); readonly_config = ostree_repo_get_config (repo);
value = g_key_file_get_string (readonly_config, section, key, error); value = g_key_file_get_string (readonly_config, section, key, error);
@ -133,7 +161,7 @@ ostree_builtin_config (int argc, char **argv, OstreeCommandInvocation *invocatio
"Unknown operation %s", op); "Unknown operation %s", op);
goto out; goto out;
} }
ret = TRUE; ret = TRUE;
out: out:
if (config) if (config)

View File

@ -293,7 +293,7 @@ ostree_builtin_refs (int argc, char **argv, OstreeCommandInvocation *invocation,
else if (opt_create) else if (opt_create)
{ {
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
"You must specify an existing ref when creating a new ref"); "You must specify a revision when creating a new ref");
goto out; goto out;
} }

View File

@ -29,6 +29,7 @@ echo "1..4"
setup_test_repository "bare" setup_test_repository "bare"
echo "ok setup" echo "ok setup"
# Check that without commit-update-summary set, creating a commit doesn't update the summary
mkdir test mkdir test
echo hello > test/a echo hello > test/a
@ -47,6 +48,7 @@ echo "ok commit 2"
assert_streq "$OLD_MD5" "$(md5sum repo/summary)" assert_streq "$OLD_MD5" "$(md5sum repo/summary)"
# Check that with commit-update-summary set, creating a commit updates the summary
$OSTREE --repo=repo config set core.commit-update-summary true $OSTREE --repo=repo config set core.commit-update-summary true
echo hello3 > test/a echo hello3 > test/a
@ -56,7 +58,46 @@ echo "ok commit 3"
assert_not_streq "$OLD_MD5" "$(md5sum repo/summary)" assert_not_streq "$OLD_MD5" "$(md5sum repo/summary)"
$OSTREE --repo=repo config set core.commit-update-summary false
# Check that summary --update deletes the .sig file # Check that summary --update deletes the .sig file
touch repo/summary.sig touch repo/summary.sig
$OSTREE summary --update $OSTREE summary --update
assert_not_has_file repo/summary.sig assert_not_has_file repo/summary.sig
# Check that without auto-update-summary set, adding, changing, or deleting a ref doesn't update the summary
$OSTREE summary --update
OLD_MD5=$(md5sum repo/summary)
$OSTREE commit -b test2 -s "A commit" test
assert_streq "$OLD_MD5" "$(md5sum repo/summary)"
$OSTREE reset test test^
assert_streq "$OLD_MD5" "$(md5sum repo/summary)"
$OSTREE refs --delete test
assert_streq "$OLD_MD5" "$(md5sum repo/summary)"
# Check that with auto-update-summary set, adding, changing, or deleting a ref updates the summary
$OSTREE --repo=repo config set core.auto-update-summary true
$OSTREE summary --update
OLD_MD5=$(md5sum repo/summary)
echo hello > test/a
$OSTREE commit -b test -s "A commit" test
echo hello2 > test/a
$OSTREE commit -b test -s "Another commit" test
assert_not_streq "$OLD_MD5" "$(md5sum repo/summary)"
OLD_MD5=$(md5sum repo/summary)
$OSTREE reset test test^
assert_not_streq "$OLD_MD5" "$(md5sum repo/summary)"
OLD_MD5=$(md5sum repo/summary)
$OSTREE refs --delete test
assert_not_streq "$OLD_MD5" "$(md5sum repo/summary)"

55
tests/test-config.sh Executable file
View File

@ -0,0 +1,55 @@
#!/bin/bash
#
# Copyright (C) 2018 Sinny Kumari <skumari@redhat.com>
#
# SPDX-License-Identifier: LGPL-2.0+
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
set -euo pipefail
. $(dirname $0)/libtest.sh
echo '1..2'
ostree_repo_init repo
${CMD_PREFIX} ostree remote add --repo=repo --set=xa.title=Flathub --set=xa.title-is-set=true flathub https://dl.flathub.org/repo/
${CMD_PREFIX} ostree remote add --repo=repo org.mozilla.FirefoxRepo http://example.com/ostree/repo/
${CMD_PREFIX} ostree config --repo=repo get core.mode > list.txt
${CMD_PREFIX} ostree config --repo=repo get --group=core repo_version >> list.txt
${CMD_PREFIX} ostree config --repo=repo get --group='remote "flathub"' 'xa.title' >> list.txt
${CMD_PREFIX} ostree config --repo=repo get --group='remote "flathub"' 'xa.title-is-set' >> list.txt
${CMD_PREFIX} ostree config --repo=repo get --group='remote "org.mozilla.FirefoxRepo"' url >> list.txt
${CMD_PREFIX} cat list.txt
assert_file_has_content list.txt "bare"
assert_file_has_content list.txt "1"
assert_file_has_content list.txt "Flathub"
assert_file_has_content list.txt "true"
assert_file_has_content list.txt "http://example.com/ostree/repo/"
echo "ok config get"
${CMD_PREFIX} ostree config --repo=repo set core.mode bare-user-only
${CMD_PREFIX} ostree config --repo=repo set --group='remote "flathub"' 'xa.title' 'Nightly Flathub'
${CMD_PREFIX} ostree config --repo=repo set --group='remote "flathub"' 'xa.title-is-set' 'false'
${CMD_PREFIX} ostree config --repo=repo set --group='remote "org.mozilla.FirefoxRepo"' url http://example.com/ostree/
assert_file_has_content repo/config "bare-user-only"
assert_file_has_content repo/config "Nightly Flathub"
assert_file_has_content repo/config "false"
assert_file_has_content repo/config "http://example.com/ostree/"
echo "ok config set"

View File

@ -23,7 +23,7 @@ set -euo pipefail
. $(dirname $0)/libtest.sh . $(dirname $0)/libtest.sh
echo "1..7" echo "1..10"
COMMIT_SIGN="--gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_1}" COMMIT_SIGN="--gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_1}"
setup_fake_remote_repo1 "archive" "${COMMIT_SIGN}" setup_fake_remote_repo1 "archive" "${COMMIT_SIGN}"
@ -151,4 +151,128 @@ grep static-deltas summary.txt > static-deltas.txt
assert_file_has_content static-deltas.txt \ assert_file_has_content static-deltas.txt \
$(${OSTREE} --repo=repo rev-parse origin:main) $(${OSTREE} --repo=repo rev-parse origin:main)
## Tests for handling of cached summaries while racing with remote summary updates
# Make 2 different but valid summary/signature pairs to test races with
${OSTREE} --repo=${test_tmpdir}/ostree-srv/gnomerepo summary -u ${COMMIT_SIGN}
cp ${test_tmpdir}/ostree-srv/gnomerepo/summary{,.1}
cp ${test_tmpdir}/ostree-srv/gnomerepo/summary.sig{,.1}
mkdir ${test_tmpdir}/ostree-srv/even-another-files
cd ${test_tmpdir}/ostree-srv/even-another-files
echo 'hello world even another object' > even-another-hello-world
${OSTREE} --repo=${test_tmpdir}/ostree-srv/gnomerepo commit ${COMMIT_SIGN} -b even-another -s "A commit" -m "Another Commit body"
${OSTREE} --repo=${test_tmpdir}/ostree-srv/gnomerepo summary -u ${COMMIT_SIGN}
cp ${test_tmpdir}/ostree-srv/gnomerepo/summary{,.2}
cp ${test_tmpdir}/ostree-srv/gnomerepo/summary.sig{,.2}
cd ${test_tmpdir}
# Reset to the old valid summary and pull to cache it
cp ${test_tmpdir}/ostree-srv/gnomerepo/summary{.1,}
cp ${test_tmpdir}/ostree-srv/gnomerepo/summary.sig{.1,}
repo_reinit
${OSTREE} --repo=repo pull origin main
assert_has_file repo/tmp/cache/summaries/origin
assert_has_file repo/tmp/cache/summaries/origin.sig
cmp repo/tmp/cache/summaries/origin ${test_tmpdir}/ostree-srv/gnomerepo/summary.1 >&2
cmp repo/tmp/cache/summaries/origin.sig ${test_tmpdir}/ostree-srv/gnomerepo/summary.sig.1 >&2
# Simulate a pull race where the client gets the old summary and the new
# summary signature since it was generated on the server between the
# requests
cp ${test_tmpdir}/ostree-srv/gnomerepo/summary.sig{.2,}
if ${OSTREE} --repo=repo pull origin main 2>err.txt; then
assert_not_reached "Successful pull with old summary"
fi
assert_file_has_content err.txt "none are in trusted keyring"
assert_has_file repo/tmp/cache/summaries/origin
assert_has_file repo/tmp/cache/summaries/origin.sig
cmp repo/tmp/cache/summaries/origin ${test_tmpdir}/ostree-srv/gnomerepo/summary.1 >&2
cmp repo/tmp/cache/summaries/origin.sig ${test_tmpdir}/ostree-srv/gnomerepo/summary.sig.1 >&2
# Publish correct summary and check that subsequent pull succeeds
cp ${test_tmpdir}/ostree-srv/gnomerepo/summary{.2,}
${OSTREE} --repo=repo pull origin main
assert_has_file repo/tmp/cache/summaries/origin
assert_has_file repo/tmp/cache/summaries/origin.sig
cmp repo/tmp/cache/summaries/origin ${test_tmpdir}/ostree-srv/gnomerepo/summary.2 >&2
cmp repo/tmp/cache/summaries/origin.sig ${test_tmpdir}/ostree-srv/gnomerepo/summary.sig.2 >&2
echo "ok pull with signed summary remote old summary"
# Reset to the old valid summary and pull to cache it
cp ${test_tmpdir}/ostree-srv/gnomerepo/summary{.1,}
cp ${test_tmpdir}/ostree-srv/gnomerepo/summary.sig{.1,}
repo_reinit
${OSTREE} --repo=repo pull origin main
assert_has_file repo/tmp/cache/summaries/origin
assert_has_file repo/tmp/cache/summaries/origin.sig
cmp repo/tmp/cache/summaries/origin ${test_tmpdir}/ostree-srv/gnomerepo/summary.1 >&2
cmp repo/tmp/cache/summaries/origin.sig ${test_tmpdir}/ostree-srv/gnomerepo/summary.sig.1 >&2
# Simulate a pull race where the client gets the new summary and the old
# summary signature. This is unlikely to happen except if the web server
# is caching the old signature. This should succeed because the cached
# old summary is used.
cp ${test_tmpdir}/ostree-srv/gnomerepo/summary{.2,}
${OSTREE} --repo=repo pull origin main
assert_has_file repo/tmp/cache/summaries/origin
assert_has_file repo/tmp/cache/summaries/origin.sig
cmp repo/tmp/cache/summaries/origin ${test_tmpdir}/ostree-srv/gnomerepo/summary.1 >&2
cmp repo/tmp/cache/summaries/origin.sig ${test_tmpdir}/ostree-srv/gnomerepo/summary.sig.1 >&2
# Publish correct signature and check that subsequent pull succeeds
cp ${test_tmpdir}/ostree-srv/gnomerepo/summary.sig{.2,}
${OSTREE} --repo=repo pull origin main
assert_has_file repo/tmp/cache/summaries/origin
assert_has_file repo/tmp/cache/summaries/origin.sig
cmp repo/tmp/cache/summaries/origin ${test_tmpdir}/ostree-srv/gnomerepo/summary.2 >&2
cmp repo/tmp/cache/summaries/origin.sig ${test_tmpdir}/ostree-srv/gnomerepo/summary.sig.2 >&2
echo "ok pull with signed summary remote old summary signature"
# Reset to the old valid summary and pull to cache it
cp ${test_tmpdir}/ostree-srv/gnomerepo/summary{.1,}
cp ${test_tmpdir}/ostree-srv/gnomerepo/summary.sig{.1,}
repo_reinit
${OSTREE} --repo=repo pull origin main
assert_has_file repo/tmp/cache/summaries/origin
assert_has_file repo/tmp/cache/summaries/origin.sig
cmp repo/tmp/cache/summaries/origin ${test_tmpdir}/ostree-srv/gnomerepo/summary.1 >&2
cmp repo/tmp/cache/summaries/origin.sig ${test_tmpdir}/ostree-srv/gnomerepo/summary.sig.1 >&2
# Simulate a broken summary cache to see if it can be recovered from.
# Prior to commit c4c2b5eb the client would save the summary to the
# cache before validating the signature. That would mean the cache would
# have mismatched summary and signature and ostree would remain
# deadlocked there until the remote published a new signature.
#
# First pull with OSTREE_REPO_TEST_ERROR=invalid-cache to see the
# invalid cache is detected. Then pull again to check if it can be
# recovered from.
cp ${test_tmpdir}/ostree-srv/gnomerepo/summary.2 repo/tmp/cache/summaries/origin
if OSTREE_REPO_TEST_ERROR=invalid-cache ${OSTREE} --repo=repo pull origin main 2>err.txt; then
assert_not_reached "Should have hit OSTREE_REPO_TEST_ERROR_INVALID_CACHE"
fi
assert_file_has_content err.txt "OSTREE_REPO_TEST_ERROR_INVALID_CACHE"
assert_has_file repo/tmp/cache/summaries/origin
assert_has_file repo/tmp/cache/summaries/origin.sig
cmp repo/tmp/cache/summaries/origin ${test_tmpdir}/ostree-srv/gnomerepo/summary.2 >&2
cmp repo/tmp/cache/summaries/origin.sig ${test_tmpdir}/ostree-srv/gnomerepo/summary.sig.1 >&2
${OSTREE} --repo=repo pull origin main
assert_has_file repo/tmp/cache/summaries/origin
assert_has_file repo/tmp/cache/summaries/origin.sig
cmp repo/tmp/cache/summaries/origin ${test_tmpdir}/ostree-srv/gnomerepo/summary.1 >&2
cmp repo/tmp/cache/summaries/origin.sig ${test_tmpdir}/ostree-srv/gnomerepo/summary.sig.1 >&2
# Publish new signature and check that subsequent pull succeeds
cp ${test_tmpdir}/ostree-srv/gnomerepo/summary{.2,}
cp ${test_tmpdir}/ostree-srv/gnomerepo/summary.sig{.2,}
${OSTREE} --repo=repo pull origin main
assert_has_file repo/tmp/cache/summaries/origin
assert_has_file repo/tmp/cache/summaries/origin.sig
cmp repo/tmp/cache/summaries/origin ${test_tmpdir}/ostree-srv/gnomerepo/summary.2 >&2
cmp repo/tmp/cache/summaries/origin.sig ${test_tmpdir}/ostree-srv/gnomerepo/summary.sig.2 >&2
echo "ok pull with signed summary broken cache"
libtest_cleanup_gpg libtest_cleanup_gpg

View File

@ -54,7 +54,7 @@ echo 'ok documented symbols'
# ONLY update this checksum in release commits! # ONLY update this checksum in release commits!
cat > released-sha256.txt <<EOF cat > released-sha256.txt <<EOF
611278b6081cbd34e365f3a7988e0c981644a828230973d7675a1a31ef09a0e3 ${released_syms} a34e3681f1705ed3c6fcf25238e486365cb5b53ffde905ba28a2954ef6eb0269 ${released_syms}
EOF EOF
sha256sum -c released-sha256.txt sha256sum -c released-sha256.txt