New upstream version 2019.4

This commit is contained in:
Simon McVittie committed 2019-10-01 09:20:02 +01:00
commit bfa407c9d3
33 files changed
+445 -127

No files matched your search

+4
View File
@@ -571,6 +571,10 @@ global:
ostree_kernel_args_to_string;
} LIBOSTREE_2018.9;
LIBOSTREE_2019.4 {
ostree_repo_mark_commit_partial_reason;
} LIBOSTREE_2019.3;
/* NOTE: Only add more content here in release commits! See the
* comments at the top of this file.
*/
+13 -27
View File
@@ -30,7 +30,6 @@ struct _OstreeBootconfigParser
const char *separators;
GHashTable *options;
GPtrArray *lines;
};
typedef GObjectClass OstreeBootconfigParserClass;
@@ -48,9 +47,6 @@ ostree_bootconfig_parser_clone (OstreeBootconfigParser *self)
{
OstreeBootconfigParser *parser = ostree_bootconfig_parser_new ();
for (guint i = 0; i < self->lines->len; i++)
g_ptr_array_add (parser->lines, g_variant_ref (self->lines->pdata[i]));
GLNX_HASH_TABLE_FOREACH_KV (self->options, const char*, k, const char*, v)
g_hash_table_replace (parser->options, g_strdup (k), g_strdup (v));
@@ -84,7 +80,6 @@ ostree_bootconfig_parser_parse_at (OstreeBootconfigParser *self,
for (char **iter = lines; *iter; iter++)
{
const char *line = *iter;
char *keyname = "";
if (g_ascii_isalpha (*line))
{
@@ -92,7 +87,6 @@ ostree_bootconfig_parser_parse_at (OstreeBootconfigParser *self,
items = g_strsplit_set (line, self->separators, 2);
if (g_strv_length (items) == 2 && items[0][0] != '\0')
{
keyname = items[0];
g_hash_table_insert (self->options, items[0], items[1]);
g_free (items); /* Transfer ownership */
}
@@ -101,7 +95,6 @@ ostree_bootconfig_parser_parse_at (OstreeBootconfigParser *self,
g_strfreev (items);
}
}
g_ptr_array_add (self->lines, g_variant_new ("(ss)", keyname, line));
}
self->parsed = TRUE;
@@ -153,34 +146,29 @@ ostree_bootconfig_parser_write_at (OstreeBootconfigParser *self,
GCancellable *cancellable,
GError **error)
{
/* Write the fields in a deterministic order, following what is used
* in the bootconfig example of the BootLoaderspec document:
* https://systemd.io/BOOT_LOADER_SPECIFICATION
*/
const char *fields[] = { "title", "version", "options", "devicetree", "linux", "initrd" };
g_autoptr(GHashTable) keys_written = g_hash_table_new (g_str_hash, g_str_equal);
g_autoptr(GString) buf = g_string_new ("");
g_autoptr(GHashTable) written_overrides = g_hash_table_new (g_str_hash, g_str_equal);
for (guint i = 0; i < self->lines->len; i++)
for (guint i = 0; i < G_N_ELEMENTS (fields); i++)
{
GVariant *linedata = self->lines->pdata[i];
const char *key;
const char *value;
const char *line;
g_variant_get (linedata, "(&s&s)", &key, &line);
value = g_hash_table_lookup (self->options, key);
if (value == NULL)
{
g_string_append (buf, line);
g_string_append_c (buf, '\n');
}
else
const char *key = fields[i];
const char *value = g_hash_table_lookup (self->options, key);
if (value != NULL)
{
write_key (self, buf, key, value);
g_hash_table_add (written_overrides, (gpointer)key);
g_hash_table_add (keys_written, (gpointer)key);
}
}
/* Write unknown fields */
GLNX_HASH_TABLE_FOREACH_KV (self->options, const char*, k, const char*, v)
{
if (g_hash_table_lookup (written_overrides, k))
if (g_hash_table_lookup (keys_written, k))
continue;
write_key (self, buf, k, v);
}
@@ -210,7 +198,6 @@ ostree_bootconfig_parser_finalize (GObject *object)
OstreeBootconfigParser *self = OSTREE_BOOTCONFIG_PARSER (object);
g_hash_table_unref (self->options);
g_ptr_array_unref (self->lines);
G_OBJECT_CLASS (ostree_bootconfig_parser_parent_class)->finalize (object);
}
@@ -219,7 +206,6 @@ static void
ostree_bootconfig_parser_init (OstreeBootconfigParser *self)
{
self->options = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
self->lines = g_ptr_array_new_with_free_func ((GDestroyNotify)g_variant_unref);
}
void
+58 -21
View File
@@ -1873,6 +1873,57 @@ ensure_txn_refs (OstreeRepo *self)
g_free);
}
/**
* ostree_repo_mark_commit_partial_reason:
* @self: Repo
* @checksum: Commit SHA-256
* @is_partial: Whether or not this commit is partial
* @in_state: Reason bitmask for partial commit
* @error: Error
*
* Allows the setting of a reason code for a partial commit. Presently
* it only supports setting reason bitmask to
* OSTREE_REPO_COMMIT_STATE_FSCK_PARTIAL, or
* OSTREE_REPO_COMMIT_STATE_NORMAL. This will allow successive ostree
* fsck operations to exit properly with an error code if the
* repository has been truncated as a result of fsck trying to repair
* it.
*
* Since: 2019.4
*/
gboolean
ostree_repo_mark_commit_partial_reason (OstreeRepo *self,
const char *checksum,
gboolean is_partial,
OstreeRepoCommitState in_state,
GError **error)
{
g_autofree char *commitpartial_path = _ostree_get_commitpartial_path (checksum);
if (is_partial)
{
glnx_autofd int fd = openat (self->repo_dir_fd, commitpartial_path,
O_EXCL | O_CREAT | O_WRONLY | O_CLOEXEC | O_NOCTTY, 0644);
if (fd == -1)
{
if (errno != EEXIST)
return glnx_throw_errno_prefix (error, "open(%s)", commitpartial_path);
}
else
{
if (in_state & OSTREE_REPO_COMMIT_STATE_FSCK_PARTIAL)
if (glnx_loop_write (fd, "f", 1) < 0)
return glnx_throw_errno_prefix (error, "write(%s)", commitpartial_path);
}
}
else
{
if (!ot_ensure_unlinked_at (self->repo_dir_fd, commitpartial_path, 0))
return FALSE;
}
return TRUE;
}
/**
* ostree_repo_mark_commit_partial:
* @self: Repo
@@ -1880,9 +1931,10 @@ ensure_txn_refs (OstreeRepo *self)
* @is_partial: Whether or not this commit is partial
* @error: Error
*
* Commits in "partial" state do not have all their child objects written. This
* occurs in various situations, such as during a pull, but also if a "subpath"
* pull is used, as well as "commit only" pulls.
* Commits in the "partial" state do not have all their child objects
* written. This occurs in various situations, such as during a pull,
* but also if a "subpath" pull is used, as well as "commit only"
* pulls.
*
* This function is used by ostree_repo_pull_with_options(); you
* should use this if you are implementing a different type of transport.
@@ -1895,24 +1947,9 @@ ostree_repo_mark_commit_partial (OstreeRepo *self,
gboolean is_partial,
GError **error)
{
g_autofree char *commitpartial_path = _ostree_get_commitpartial_path (checksum);
if (is_partial)
{
glnx_autofd int fd = openat (self->repo_dir_fd, commitpartial_path,
O_EXCL | O_CREAT | O_WRONLY | O_CLOEXEC | O_NOCTTY, 0644);
if (fd == -1)
{
if (errno != EEXIST)
return glnx_throw_errno_prefix (error, "open(%s)", commitpartial_path);
}
}
else
{
if (!ot_ensure_unlinked_at (self->repo_dir_fd, commitpartial_path, 0))
return FALSE;
}
return TRUE;
return ostree_repo_mark_commit_partial_reason (self, checksum, is_partial,
OSTREE_REPO_COMMIT_STATE_NORMAL,
error);
}
/**
+2
View File
@@ -385,6 +385,8 @@ check_outstanding_requests_handle_error (OtPullData *pull_data,
GError *error = *errorp;
if (error)
{
g_debug ("Request caught error: %s", error->message);
if (!pull_data->caught_error)
{
pull_data->caught_error = TRUE;
+12 -3
View File
@@ -3768,10 +3768,19 @@ load_metadata_internal (OstreeRepo *self,
g_autofree char *commitpartial_path = _ostree_get_commitpartial_path (sha256);
*out_state = 0;
if (!glnx_fstatat_allow_noent (self->repo_dir_fd, commitpartial_path, NULL, 0, error))
glnx_autofd int fd = -1;
if (!ot_openat_ignore_enoent (self->repo_dir_fd, commitpartial_path, &fd, error))
return FALSE;
if (errno == 0)
*out_state |= OSTREE_REPO_COMMIT_STATE_PARTIAL;
if (fd != -1)
{
*out_state |= OSTREE_REPO_COMMIT_STATE_PARTIAL;
char reason;
if (read (fd, &reason, 1) == 1)
{
if (reason == 'f')
*out_state |= OSTREE_REPO_COMMIT_STATE_FSCK_PARTIAL;
}
}
}
}
else if (self->parent_repo)
+27 -17
View File
@@ -248,6 +248,26 @@ gboolean ostree_repo_write_config (OstreeRepo *self,
GKeyFile *new_config,
GError **error);
/**
* OstreeRepoCommitState:
* @OSTREE_REPO_COMMIT_STATE_NORMAL: Commit is complete. This is the default.
* (Since: 2017.14.)
* @OSTREE_REPO_COMMIT_STATE_PARTIAL: One or more objects are missing from the
* local copy of the commit, but metadata is present. (Since: 2015.7.)
* @OSTREE_REPO_COMMIT_STATE_FSCK_PARTIAL: One or more objects are missing from the
* local copy of the commit, due to an fsck --delete. (Since: 2019.4.)
*
* Flags representing the state of a commit in the local repository, as returned
* by ostree_repo_load_commit().
*
* Since: 2015.7
*/
typedef enum {
OSTREE_REPO_COMMIT_STATE_NORMAL = 0,
OSTREE_REPO_COMMIT_STATE_PARTIAL = (1 << 0),
OSTREE_REPO_COMMIT_STATE_FSCK_PARTIAL = (1 << 1),
} OstreeRepoCommitState;
/**
* OstreeRepoTransactionStats:
* @metadata_objects_total: The total number of metadata objects
@@ -315,6 +335,13 @@ gboolean ostree_repo_mark_commit_partial (OstreeRepo *self,
gboolean is_partial,
GError **error);
_OSTREE_PUBLIC
gboolean ostree_repo_mark_commit_partial_reason (OstreeRepo *self,
const char *checksum,
gboolean is_partial,
OstreeRepoCommitState in_state,
GError **error);
_OSTREE_PUBLIC
void ostree_repo_transaction_set_refspec (OstreeRepo *self,
const char *refspec,
@@ -526,23 +553,6 @@ gboolean ostree_repo_load_variant_if_exists (OstreeRepo *self,
GVariant **out_variant,
GError **error);
/**
* OstreeRepoCommitState:
* @OSTREE_REPO_COMMIT_STATE_NORMAL: Commit is complete. This is the default.
* (Since: 2017.14.)
* @OSTREE_REPO_COMMIT_STATE_PARTIAL: One or more objects are missing from the
* local copy of the commit, but metadata is present. (Since: 2015.7.)
*
* Flags representing the state of a commit in the local repository, as returned
* by ostree_repo_load_commit().
*
* Since: 2015.7
*/
typedef enum {
OSTREE_REPO_COMMIT_STATE_NORMAL = 0,
OSTREE_REPO_COMMIT_STATE_PARTIAL = (1 << 0),
} OstreeRepoCommitState;
_OSTREE_PUBLIC
gboolean ostree_repo_load_commit (OstreeRepo *self,
const char *checksum,
+3 -4
View File
@@ -1746,10 +1746,9 @@ install_deployment_kernel (OstreeSysroot *sysroot,
g_string_append_c (title_key, ':');
g_string_append (title_key, osname);
}
if (!(deployment_version && *deployment_version))
{
g_string_append_printf (title_key, ":%d", ostree_deployment_get_index (deployment));
}
g_string_append_printf (title_key, ":%d", ostree_deployment_get_index (deployment));
g_string_append_c (title_key, ')');
ostree_bootconfig_parser_set (bootconfig, "title", title_key->str);
+12 -1
View File
@@ -959,7 +959,18 @@ ostree_sysroot_load_if_changed (OstreeSysroot *self,
}
if (self->root_is_ostree_booted && !self->booted_deployment)
return glnx_throw (error, "Unexpected state: /run/ostree-booted found and in / sysroot but not in a booted deployment");
{
if (!glnx_fstatat_allow_noent (self->sysroot_fd, "boot/loader", NULL, AT_SYMLINK_NOFOLLOW, error))
return FALSE;
if (errno == ENOENT)
{
return glnx_throw (error, "Unexpected state: /run/ostree-booted found, but no /boot/loader directory");
}
else
{
return glnx_throw (error, "Unexpected state: /run/ostree-booted found and in / sysroot, but bootloader entry not found");
}
}
if (!_ostree_sysroot_reload_staged (self, error))
return FALSE;
+3 -3
View File
@@ -43,7 +43,7 @@
*
* Since: 2017.4
*/
#define OSTREE_RELEASE_VERSION (3)
#define OSTREE_RELEASE_VERSION (4)
/**
* OSTREE_VERSION
@@ -52,7 +52,7 @@
*
* Since: 2017.4
*/
#define OSTREE_VERSION (2019.3)
#define OSTREE_VERSION (2019.4)
/**
* OSTREE_VERSION_S:
@@ -62,7 +62,7 @@
*
* Since: 2017.4
*/
#define OSTREE_VERSION_S "2019.3"
#define OSTREE_VERSION_S "2019.4"
#define OSTREE_ENCODE_VERSION(year,release) \
((year) << 16 | (release))