New upstream version 2018.2
This commit is contained in:
commit
6a333af023
380 files changed
+1783
-367
No files matched your search
@@ -4,6 +4,8 @@
|
||||
#
|
||||
# Copyright (C) 2013 Colin Walters <walters@verbum.org>
|
||||
#
|
||||
# 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
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
***/
|
||||
|
||||
/* Add new symbols here. Release commits should copy this section into -released.sym. */
|
||||
LIBOSTREE_2018.2 {
|
||||
} LIBOSTREE_2018.1;
|
||||
|
||||
/* 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
|
||||
|
||||
@@ -454,6 +454,10 @@ LIBOSTREE_2017.15 {
|
||||
LIBOSTREE_2018.1 {
|
||||
} LIBOSTREE_2017.15;
|
||||
|
||||
LIBOSTREE_2018.2 {
|
||||
ostree_commit_get_content_checksum;
|
||||
} LIBOSTREE_2018.1;
|
||||
|
||||
/* NOTE: Only add more content here in release commits! See the
|
||||
* comments at the top of this file.
|
||||
*/
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2016 Endless Mobile, Inc.
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright © 2017 Endless Mobile, Inc.
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright © 2017 Endless Mobile, Inc.
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -95,6 +95,10 @@ append_config_from_loader_entries (OstreeBootloaderSyslinux *self,
|
||||
if (val)
|
||||
g_ptr_array_add (new_lines, g_strdup_printf ("\tINITRD %s", val));
|
||||
|
||||
val = ostree_bootconfig_parser_get (config, "devicetree");
|
||||
if (val)
|
||||
g_ptr_array_add (new_lines, g_strdup_printf ("\tDEVICETREE %s", val));
|
||||
|
||||
val = ostree_bootconfig_parser_get (config, "options");
|
||||
if (val)
|
||||
g_ptr_array_add (new_lines, g_strdup_printf ("\tAPPEND %s", val));
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2011 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2011 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2011 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2011 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
@@ -82,6 +84,7 @@ _ostree_make_temporary_symlink_at (int tmp_dirfd,
|
||||
GError **error);
|
||||
|
||||
GFileInfo * _ostree_stbuf_to_gfileinfo (const struct stat *stbuf);
|
||||
void _ostree_gfileinfo_to_stbuf (GFileInfo *file_info, struct stat *out_stbuf);
|
||||
gboolean _ostree_gfileinfo_equal (GFileInfo *a, GFileInfo *b);
|
||||
gboolean _ostree_stbuf_equal (struct stat *stbuf_a, struct stat *stbuf_b);
|
||||
GFileInfo * _ostree_mode_uidgid_to_gfileinfo (mode_t mode, uid_t uid, gid_t gid);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2011 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
@@ -152,15 +154,18 @@ ostree_validate_checksum_string (const char *sha256,
|
||||
/**
|
||||
* ostree_parse_refspec:
|
||||
* @refspec: A "refspec" string
|
||||
* @out_remote: (out) (allow-none): The remote name, or %NULL if the refspec refs to a local ref
|
||||
* @out_ref: (out) (allow-none): Name of ref
|
||||
* @out_remote: (out) (nullable) (optional): Return location for the remote name,
|
||||
* or %NULL if the refspec refs to a local ref
|
||||
* @out_ref: (out) (not nullable) (optional): Return location for the ref name
|
||||
* @error: Error
|
||||
*
|
||||
* Split a refspec like "gnome-ostree:gnome-ostree/buildmaster" into
|
||||
* two parts; @out_remote will be set to "gnome-ostree", and @out_ref
|
||||
* will be "gnome-ostree/buildmaster".
|
||||
* Split a refspec like `gnome-ostree:gnome-ostree/buildmaster` or just
|
||||
* `gnome-ostree/buildmaster` into two parts. In the first case, @out_remote
|
||||
* will be set to `gnome-ostree`, and @out_ref to `gnome-ostree/buildmaster`.
|
||||
* In the second case (a local ref), @out_remote will be %NULL, and @out_ref
|
||||
* will be `gnome-ostree/buildmaster`. In both cases, %TRUE will be returned.
|
||||
*
|
||||
* If @refspec refers to a local ref, @out_remote will be %NULL.
|
||||
* Returns: %TRUE on successful parsing, %FALSE otherwise
|
||||
*/
|
||||
gboolean
|
||||
ostree_parse_refspec (const char *refspec,
|
||||
@@ -1681,6 +1686,26 @@ _ostree_stbuf_to_gfileinfo (const struct stat *stbuf)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* _ostree_gfileinfo_to_stbuf:
|
||||
* @file_info: File info
|
||||
* @out_stbuf: (out): stat buffer
|
||||
*
|
||||
* Map GFileInfo data from @file_info onto @out_stbuf.
|
||||
*/
|
||||
void
|
||||
_ostree_gfileinfo_to_stbuf (GFileInfo *file_info,
|
||||
struct stat *out_stbuf)
|
||||
{
|
||||
struct stat stbuf = {0,};
|
||||
stbuf.st_mode = g_file_info_get_attribute_uint32 (file_info, "unix::mode");
|
||||
stbuf.st_uid = g_file_info_get_attribute_uint32 (file_info, "unix::uid");
|
||||
stbuf.st_gid = g_file_info_get_attribute_uint32 (file_info, "unix::gid");
|
||||
if (S_ISREG (stbuf.st_mode))
|
||||
stbuf.st_size = g_file_info_get_attribute_uint64 (file_info, "standard::size");
|
||||
*out_stbuf = stbuf;
|
||||
}
|
||||
|
||||
/**
|
||||
* _ostree_gfileinfo_equal:
|
||||
* @a: First file info
|
||||
@@ -2346,6 +2371,51 @@ ostree_commit_get_timestamp (GVariant *commit_variant)
|
||||
return GUINT64_FROM_BE (ret);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ostree_commit_get_content_checksum:
|
||||
* @commit_variant: A commit object
|
||||
*
|
||||
* There are use cases where one wants a checksum just of the content of a
|
||||
* commit. OSTree commits by default capture the current timestamp, and may have
|
||||
* additional metadata, which means that re-committing identical content
|
||||
* often results in a new checksum.
|
||||
*
|
||||
* By comparing checksums of content, it's possible to easily distinguish
|
||||
* cases where nothing actually changed.
|
||||
*
|
||||
* The content checksums is simply defined as `SHA256(root dirtree_checksum || root_dirmeta_checksum)`,
|
||||
* i.e. the SHA-256 of the root "dirtree" object's checksum concatenated with the
|
||||
* root "dirmeta" checksum (both in binary form, not hexadecimal).
|
||||
*
|
||||
* Returns: (nullable): A SHA-256 hex string, or %NULL if @commit_variant is not well-formed
|
||||
*/
|
||||
gchar *
|
||||
ostree_commit_get_content_checksum (GVariant *commit_variant)
|
||||
{
|
||||
g_auto(OtChecksum) checksum = { 0, };
|
||||
ot_checksum_init (&checksum);
|
||||
|
||||
g_autoptr(GVariant) tree_contents_csum = NULL;
|
||||
g_autoptr(GVariant) tree_meta_csum = NULL;
|
||||
|
||||
g_variant_get_child (commit_variant, 6, "@ay", &tree_contents_csum);
|
||||
g_variant_get_child (commit_variant, 7, "@ay", &tree_meta_csum);
|
||||
|
||||
const guchar *bytes;
|
||||
bytes = ostree_checksum_bytes_peek_validate (tree_contents_csum, NULL);
|
||||
if (!bytes)
|
||||
return NULL;
|
||||
ot_checksum_update (&checksum, bytes, OSTREE_SHA256_DIGEST_LEN);
|
||||
bytes = ostree_checksum_bytes_peek_validate (tree_meta_csum, NULL);
|
||||
if (!bytes)
|
||||
return NULL;
|
||||
ot_checksum_update (&checksum, bytes, OSTREE_SHA256_DIGEST_LEN);
|
||||
char hexdigest[OSTREE_SHA256_STRING_LEN+1];
|
||||
ot_checksum_get_hexdigest (&checksum, hexdigest, sizeof (hexdigest));
|
||||
return g_strdup (hexdigest);
|
||||
}
|
||||
|
||||
/* Used in pull/deploy to validate we're not being downgraded */
|
||||
gboolean
|
||||
_ostree_compare_timestamps (const char *current_rev,
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2011 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
@@ -518,6 +520,9 @@ gchar * ostree_commit_get_parent (GVariant *commit_variant);
|
||||
_OSTREE_PUBLIC
|
||||
guint64 ostree_commit_get_timestamp (GVariant *commit_variant);
|
||||
|
||||
_OSTREE_PUBLIC
|
||||
gchar * ostree_commit_get_content_checksum (GVariant *commit_variant);
|
||||
|
||||
_OSTREE_PUBLIC
|
||||
gboolean ostree_check_version (guint required_year, guint required_release);
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2011 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2011 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
*
|
||||
* Copyright (C) 2016 Red Hat, Inc.
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
*
|
||||
* Copyright (C) 2016 Red Hat, Inc.
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2016 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
@@ -864,12 +866,6 @@ _ostree_fetcher_request_async (OstreeFetcher *self,
|
||||
initiate_next_curl_request (req, task);
|
||||
|
||||
g_hash_table_add (self->outstanding_requests, g_steal_pointer (&task));
|
||||
|
||||
/* Sanity check, I added * 2 just so we don't abort if something odd happens,
|
||||
* but we do want to abort if we're asked to do obviously too many requests.
|
||||
*/
|
||||
g_assert_cmpint (g_hash_table_size (self->outstanding_requests), <,
|
||||
_OSTREE_MAX_OUTSTANDING_FETCHER_REQUESTS * 2);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2011 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
@@ -58,7 +60,6 @@ typedef struct {
|
||||
int base_tmpdir_dfd;
|
||||
|
||||
GVariant *extra_headers;
|
||||
int max_outstanding;
|
||||
gboolean transfer_gzip;
|
||||
|
||||
/* Our active HTTP requests */
|
||||
@@ -384,8 +385,6 @@ start_pending_request (ThreadClosure *thread_closure,
|
||||
OstreeFetcherPendingURI *pending;
|
||||
GCancellable *cancellable;
|
||||
|
||||
g_assert_cmpint (g_hash_table_size (thread_closure->outstanding), <, thread_closure->max_outstanding);
|
||||
|
||||
pending = g_task_get_task_data (task);
|
||||
cancellable = g_task_get_cancellable (task);
|
||||
|
||||
@@ -471,7 +470,6 @@ ostree_fetcher_session_thread (gpointer data)
|
||||
{
|
||||
ThreadClosure *closure = data;
|
||||
g_autoptr(GMainContext) mainctx = g_main_context_ref (closure->main_context);
|
||||
gint max_conns;
|
||||
|
||||
/* This becomes the GMainContext that SoupSession schedules async
|
||||
* callbacks and emits signals from. Make it the thread-default
|
||||
@@ -492,17 +490,23 @@ ostree_fetcher_session_thread (gpointer data)
|
||||
|
||||
/* XXX: Now that we have mirrorlist support, we could make this even smarter
|
||||
* by spreading requests across mirrors. */
|
||||
gint max_conns;
|
||||
g_object_get (closure->session, "max-conns-per-host", &max_conns, NULL);
|
||||
if (max_conns < _OSTREE_MAX_OUTSTANDING_FETCHER_REQUESTS)
|
||||
{
|
||||
/* We download a lot of small objects in ostree, so this
|
||||
* helps a lot. Also matches what most modern browsers do. */
|
||||
* helps a lot. Also matches what most modern browsers do.
|
||||
*
|
||||
* Note since https://github.com/ostreedev/ostree/commit/f4d1334e19ce3ab2f8872b1e28da52044f559401
|
||||
* we don't do queuing in this libsoup backend, but we still
|
||||
* want to override libsoup's currently conservative
|
||||
* #define SOUP_SESSION_MAX_CONNS_PER_HOST_DEFAULT 2 (as of 2018-02-14).
|
||||
*/
|
||||
max_conns = _OSTREE_MAX_OUTSTANDING_FETCHER_REQUESTS;
|
||||
g_object_set (closure->session,
|
||||
"max-conns-per-host",
|
||||
max_conns, NULL);
|
||||
}
|
||||
closure->max_outstanding = 3 * max_conns;
|
||||
|
||||
/* This model ensures we don't hit a race using g_main_loop_quit();
|
||||
* see also what pull_termination_condition() in ostree-repo-pull.c
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2011,2017 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2017 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2016 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2012 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
* Copyright (C) 2011 Colin Walters <walters@verbum.org>
|
||||
* Copyright (C) 2013 Sjoerd Simons <sjoerd.simons@collabora.co.uk>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
* Copyright (C) 2011 Colin Walters <walters@verbum.org>
|
||||
* Copyright (C) 2013 Sjoerd Simons <sjoerd.simons@collabora.co.uk>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Red Hat, Inc.
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Red Hat, Inc.
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Red Hat, Inc.
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2017 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2011 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2011 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2016 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Colin Walters <walters@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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Colin Walters <walters@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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2011 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2011 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright © 2017 Endless Mobile, Inc.
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright © 2017 Endless Mobile, Inc.
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
* Copyright © 2015 Red Hat, Inc.
|
||||
* Copyright © 2017 Endless Mobile, Inc.
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
* Copyright © 2015 Red Hat, Inc.
|
||||
* Copyright © 2017 Endless Mobile, Inc.
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
* Copyright © 2015 Red Hat, Inc.
|
||||
* Copyright © 2017 Endless Mobile, Inc.
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2011,2013 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
@@ -36,13 +38,17 @@
|
||||
|
||||
/* Per-checkout call state/caching */
|
||||
typedef struct {
|
||||
GString *selabel_path_buf;
|
||||
GString *path_buf; /* buffer for real path if filtering enabled */
|
||||
GString *selabel_path_buf; /* buffer for selinux path if labeling enabled; this may be
|
||||
the same buffer as path_buf */
|
||||
} CheckoutState;
|
||||
|
||||
static void
|
||||
checkout_state_clear (CheckoutState *state)
|
||||
{
|
||||
if (state->selabel_path_buf)
|
||||
if (state->path_buf)
|
||||
g_string_free (state->path_buf, TRUE);
|
||||
if (state->selabel_path_buf && (state->selabel_path_buf != state->path_buf))
|
||||
g_string_free (state->selabel_path_buf, TRUE);
|
||||
}
|
||||
G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(CheckoutState, checkout_state_clear)
|
||||
@@ -83,6 +89,17 @@ checkout_object_for_uncompressed_cache (OstreeRepo *self,
|
||||
if (!glnx_fchmod (tmpf.fd, file_mode, error))
|
||||
return FALSE;
|
||||
|
||||
if (self->uncompressed_objects_dir_fd == -1)
|
||||
{
|
||||
if (!glnx_shutil_mkdir_p_at (self->repo_dir_fd, "uncompressed-objects-cache", 0755,
|
||||
cancellable, error))
|
||||
return FALSE;
|
||||
if (!glnx_opendirat (self->repo_dir_fd, "uncompressed-objects-cache", TRUE,
|
||||
&self->uncompressed_objects_dir_fd,
|
||||
error))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!_ostree_repo_ensure_loose_objdir_at (self->uncompressed_objects_dir_fd,
|
||||
loose_path,
|
||||
cancellable, error))
|
||||
@@ -414,7 +431,11 @@ checkout_file_hardlink (OstreeRepo *self,
|
||||
int srcfd = _ostree_repo_mode_is_bare (self->mode) ?
|
||||
self->objects_dir_fd : self->uncompressed_objects_dir_fd;
|
||||
|
||||
if (linkat (srcfd, loose_path, destination_dfd, destination_name, 0) == 0)
|
||||
if (srcfd == -1)
|
||||
{
|
||||
/* Fall through; we don't have an uncompressed object cache */
|
||||
}
|
||||
else if (linkat (srcfd, loose_path, destination_dfd, destination_name, 0) == 0)
|
||||
ret_result = HARDLINK_RESULT_LINKED;
|
||||
else if (!options->no_copy_fallback && (errno == EMLINK || errno == EXDEV || errno == EPERM))
|
||||
{
|
||||
@@ -424,6 +445,7 @@ checkout_file_hardlink (OstreeRepo *self,
|
||||
}
|
||||
else if (allow_noent && errno == ENOENT)
|
||||
{
|
||||
/* Fall through */
|
||||
}
|
||||
else if (errno == EEXIST)
|
||||
{
|
||||
@@ -527,7 +549,7 @@ checkout_file_hardlink (OstreeRepo *self,
|
||||
|
||||
static gboolean
|
||||
checkout_one_file_at (OstreeRepo *repo,
|
||||
OstreeRepoCheckoutAtOptions *options,
|
||||
OstreeRepoCheckoutAtOptions *options,
|
||||
CheckoutState *state,
|
||||
const char *checksum,
|
||||
int destination_dfd,
|
||||
@@ -543,12 +565,24 @@ checkout_one_file_at (OstreeRepo *repo,
|
||||
gboolean is_bare_user_symlink = FALSE;
|
||||
char loose_path_buf[_OSTREE_LOOSE_PATH_MAX];
|
||||
|
||||
|
||||
/* FIXME - avoid the GFileInfo here */
|
||||
g_autoptr(GFileInfo) source_info = NULL;
|
||||
if (!ostree_repo_load_file (repo, checksum, NULL, &source_info, NULL,
|
||||
cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
if (options->filter)
|
||||
{
|
||||
/* use struct stat for when we can get rid of GFileInfo; though for now, we end up
|
||||
* packing and unpacking in the non-archive case; blehh */
|
||||
struct stat stbuf = {0,};
|
||||
_ostree_gfileinfo_to_stbuf (source_info, &stbuf);
|
||||
if (options->filter (repo, state->path_buf->str, &stbuf, options->filter_user_data) ==
|
||||
OSTREE_REPO_CHECKOUT_FILTER_SKIP)
|
||||
return TRUE; /* Note early return */
|
||||
}
|
||||
|
||||
const gboolean is_symlink = (g_file_info_get_file_type (source_info) == G_FILE_TYPE_SYMBOLIC_LINK);
|
||||
const gboolean is_whiteout = (!is_symlink && options->process_whiteouts &&
|
||||
g_str_has_prefix (destination_name, WHITEOUT_PREFIX));
|
||||
@@ -748,6 +782,41 @@ checkout_one_file_at (OstreeRepo *repo,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static inline void
|
||||
push_path_element_once (GString *buf,
|
||||
const char *name,
|
||||
gboolean is_dir)
|
||||
{
|
||||
g_string_append (buf, name);
|
||||
if (is_dir)
|
||||
g_string_append_c (buf, '/');
|
||||
}
|
||||
|
||||
static inline void
|
||||
push_path_element (OstreeRepoCheckoutAtOptions *options,
|
||||
CheckoutState *state,
|
||||
const char *name,
|
||||
gboolean is_dir)
|
||||
{
|
||||
if (state->path_buf)
|
||||
push_path_element_once (state->path_buf, name, is_dir);
|
||||
if (state->selabel_path_buf && (state->selabel_path_buf != state->path_buf))
|
||||
push_path_element_once (state->selabel_path_buf, name, is_dir);
|
||||
}
|
||||
|
||||
static inline void
|
||||
pop_path_element (OstreeRepoCheckoutAtOptions *options,
|
||||
CheckoutState *state,
|
||||
const char *name,
|
||||
gboolean is_dir)
|
||||
{
|
||||
const size_t n = strlen (name) + (is_dir ? 1 : 0);
|
||||
if (state->path_buf)
|
||||
g_string_truncate (state->path_buf, state->path_buf->len - n);
|
||||
if (state->selabel_path_buf && (state->selabel_path_buf != state->path_buf))
|
||||
g_string_truncate (state->selabel_path_buf, state->selabel_path_buf->len - n);
|
||||
}
|
||||
|
||||
/*
|
||||
* checkout_tree_at:
|
||||
* @self: Repo
|
||||
@@ -798,6 +867,17 @@ checkout_tree_at_recurse (OstreeRepo *self,
|
||||
gid = GUINT32_FROM_BE (gid);
|
||||
mode = GUINT32_FROM_BE (mode);
|
||||
|
||||
if (options->filter)
|
||||
{
|
||||
struct stat stbuf = { 0, };
|
||||
stbuf.st_mode = mode;
|
||||
stbuf.st_uid = uid;
|
||||
stbuf.st_gid = gid;
|
||||
if (options->filter (self, state->path_buf->str, &stbuf, options->filter_user_data)
|
||||
== OSTREE_REPO_CHECKOUT_FILTER_SKIP)
|
||||
return TRUE; /* Note early return */
|
||||
}
|
||||
|
||||
/* First, make the directory. Push a new scope in case we end up using
|
||||
* setfscreatecon().
|
||||
*/
|
||||
@@ -863,7 +943,6 @@ checkout_tree_at_recurse (OstreeRepo *self,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
GString *selabel_path_buf = state->selabel_path_buf;
|
||||
/* Process files in this subdir */
|
||||
{ g_autoptr(GVariant) dir_file_contents = g_variant_get_child_value (dirtree, 0);
|
||||
GVariantIter viter;
|
||||
@@ -872,9 +951,7 @@ checkout_tree_at_recurse (OstreeRepo *self,
|
||||
g_autoptr(GVariant) contents_csum_v = NULL;
|
||||
while (g_variant_iter_loop (&viter, "(&s@ay)", &fname, &contents_csum_v))
|
||||
{
|
||||
const size_t origlen = selabel_path_buf ? selabel_path_buf->len : 0;
|
||||
if (selabel_path_buf)
|
||||
g_string_append (selabel_path_buf, fname);
|
||||
push_path_element (options, state, fname, FALSE);
|
||||
|
||||
char tmp_checksum[OSTREE_SHA256_STRING_LEN+1];
|
||||
_ostree_checksum_inplace_from_bytes_v (contents_csum_v, tmp_checksum);
|
||||
@@ -885,8 +962,7 @@ checkout_tree_at_recurse (OstreeRepo *self,
|
||||
cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
if (selabel_path_buf)
|
||||
g_string_truncate (selabel_path_buf, origlen);
|
||||
pop_path_element (options, state, fname, FALSE);
|
||||
}
|
||||
contents_csum_v = NULL; /* iter_loop freed it */
|
||||
}
|
||||
@@ -910,12 +986,7 @@ checkout_tree_at_recurse (OstreeRepo *self,
|
||||
if (!ot_util_filename_validate (dname, error))
|
||||
return FALSE;
|
||||
|
||||
const size_t origlen = selabel_path_buf ? selabel_path_buf->len : 0;
|
||||
if (selabel_path_buf)
|
||||
{
|
||||
g_string_append (selabel_path_buf, dname);
|
||||
g_string_append_c (selabel_path_buf, '/');
|
||||
}
|
||||
push_path_element (options, state, dname, TRUE);
|
||||
|
||||
char subdirtree_checksum[OSTREE_SHA256_STRING_LEN+1];
|
||||
_ostree_checksum_inplace_from_bytes_v (subdirtree_csum_v, subdirtree_checksum);
|
||||
@@ -927,8 +998,7 @@ checkout_tree_at_recurse (OstreeRepo *self,
|
||||
cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
if (selabel_path_buf)
|
||||
g_string_truncate (selabel_path_buf, origlen);
|
||||
pop_path_element (options, state, dname, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -990,18 +1060,44 @@ checkout_tree_at (OstreeRepo *self,
|
||||
GError **error)
|
||||
{
|
||||
g_auto(CheckoutState) state = { 0, };
|
||||
// If SELinux labeling is enabled, we need to keep track of the full path string
|
||||
|
||||
if (options->filter)
|
||||
state.path_buf = g_string_new ("/");
|
||||
|
||||
/* If SELinux labeling is enabled, we need to keep track of the full path string */
|
||||
if (options->sepolicy)
|
||||
{
|
||||
GString *buf = g_string_new (options->sepolicy_prefix ?: options->subpath);
|
||||
g_assert_cmpint (buf->len, >, 0);
|
||||
// Ensure it ends with /
|
||||
if (buf->str[buf->len-1] != '/')
|
||||
g_string_append_c (buf, '/');
|
||||
state.selabel_path_buf = buf;
|
||||
|
||||
/* Otherwise it'd just be corrupting things, and there's no use case */
|
||||
g_assert (options->force_copy);
|
||||
|
||||
const char *prefix = options->sepolicy_prefix ?: options->subpath;
|
||||
if (g_str_equal (prefix, "/") && state.path_buf)
|
||||
{
|
||||
/* just use the same scratchpad if we can */
|
||||
state.selabel_path_buf = state.path_buf;
|
||||
}
|
||||
else
|
||||
{
|
||||
GString *buf = g_string_new (prefix);
|
||||
g_assert_cmpint (buf->len, >, 0);
|
||||
/* Ensure it ends with / */
|
||||
if (buf->str[buf->len-1] != '/')
|
||||
g_string_append_c (buf, '/');
|
||||
state.selabel_path_buf = buf;
|
||||
}
|
||||
}
|
||||
|
||||
/* Uncompressed archive caches; should be considered deprecated */
|
||||
const gboolean can_cache = (options->enable_uncompressed_cache
|
||||
&& self->enable_uncompressed_cache);
|
||||
if (can_cache
|
||||
&& !_ostree_repo_mode_is_bare (self->mode)
|
||||
&& self->uncompressed_objects_dir_fd < 0)
|
||||
{
|
||||
self->uncompressed_objects_dir_fd =
|
||||
glnx_opendirat_with_errno (self->repo_dir_fd, "uncompressed-objects-cache", TRUE);
|
||||
if (self->uncompressed_objects_dir_fd < 0 && errno != ENOENT)
|
||||
return glnx_throw_errno_prefix (error, "opendir(uncompressed-objects-cache)");
|
||||
}
|
||||
|
||||
/* Special case handling for subpath of a non-directory */
|
||||
@@ -1015,7 +1111,7 @@ checkout_tree_at (OstreeRepo *self,
|
||||
*/
|
||||
int destination_dfd = destination_parent_fd;
|
||||
glnx_autofd int destination_dfd_owned = -1;
|
||||
if (strcmp (destination_name, ".") != 0)
|
||||
if (!g_str_equal (destination_name, "."))
|
||||
{
|
||||
if (mkdirat (destination_parent_fd, destination_name, 0700) < 0
|
||||
&& errno != EEXIST)
|
||||
@@ -1025,6 +1121,9 @@ checkout_tree_at (OstreeRepo *self,
|
||||
return FALSE;
|
||||
destination_dfd = destination_dfd_owned;
|
||||
}
|
||||
/* let's just ignore filter here; I can't think of a useful case for filtering when
|
||||
* only checking out one path */
|
||||
options->filter = NULL;
|
||||
return checkout_one_file_at (self, options, &state,
|
||||
ostree_repo_file_get_checksum (source),
|
||||
destination_dfd,
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2011,2013 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2016 Red Hat, Inc.
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2011 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2011 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2011 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2011 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
* Copyright © 2016 Kinvolk GmbH
|
||||
* Copyright © 2017 Endless Mobile, Inc.
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright © 2017 Endless Mobile, Inc.
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
* Copyright © 2016 Kinvolk GmbH
|
||||
* Copyright © 2017 Endless Mobile, Inc.
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright © 2017 Endless Mobile, Inc.
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright © 2017 Endless Mobile, Inc.
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright © 2017 Endless Mobile, Inc.
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright © 2017 Endless Mobile, Inc.
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright © 2017 Endless Mobile, Inc.
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright © 2017 Endless Mobile, Inc.
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright © 2017 Endless Mobile, Inc.
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright © 2017 Endless Mobile, Inc.
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright © 2017 Endless Mobile, Inc.
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2011,2013 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2011,2013 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2011,2013 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright © 2017 Endless Mobile, Inc.
|
||||
*
|
||||
* 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
|
||||
|
||||
+137
-154
@@ -2,6 +2,8 @@
|
||||
* Copyright (C) 2011,2012,2013 Colin Walters <walters@verbum.org>
|
||||
* Copyright © 2017 Endless Mobile, Inc.
|
||||
*
|
||||
* 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
|
||||
@@ -2130,19 +2132,12 @@ process_one_static_delta (OtPullData *pull_data,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
gboolean delta_byteswap;
|
||||
g_autoptr(GVariant) metadata = NULL;
|
||||
g_autoptr(GVariant) headers = NULL;
|
||||
g_autoptr(GVariant) fallback_objects = NULL;
|
||||
guint i, n;
|
||||
|
||||
delta_byteswap = _ostree_delta_needs_byteswap (delta_superblock);
|
||||
gboolean delta_byteswap = _ostree_delta_needs_byteswap (delta_superblock);
|
||||
|
||||
/* Parsing OSTREE_STATIC_DELTA_SUPERBLOCK_FORMAT */
|
||||
metadata = g_variant_get_child_value (delta_superblock, 0);
|
||||
headers = g_variant_get_child_value (delta_superblock, 6);
|
||||
fallback_objects = g_variant_get_child_value (delta_superblock, 7);
|
||||
g_autoptr(GVariant) metadata = g_variant_get_child_value (delta_superblock, 0);
|
||||
g_autoptr(GVariant) headers = g_variant_get_child_value (delta_superblock, 6);
|
||||
g_autoptr(GVariant) fallback_objects = g_variant_get_child_value (delta_superblock, 7);
|
||||
|
||||
/* Gather free space so we can do a check below */
|
||||
struct statvfs stvfsbuf;
|
||||
@@ -2150,8 +2145,8 @@ process_one_static_delta (OtPullData *pull_data,
|
||||
return glnx_throw_errno_prefix (error, "fstatvfs");
|
||||
|
||||
/* First process the fallbacks */
|
||||
n = g_variant_n_children (fallback_objects);
|
||||
for (i = 0; i < n; i++)
|
||||
guint n = g_variant_n_children (fallback_objects);
|
||||
for (guint i = 0; i < n; i++)
|
||||
{
|
||||
g_autoptr(GVariant) fallback_object =
|
||||
g_variant_get_child_value (fallback_objects, i);
|
||||
@@ -2159,99 +2154,84 @@ process_one_static_delta (OtPullData *pull_data,
|
||||
if (!process_one_static_delta_fallback (pull_data, delta_byteswap,
|
||||
fallback_object,
|
||||
cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Write the to-commit object */
|
||||
if (!pull_data->dry_run)
|
||||
{
|
||||
g_autoptr(GVariant) to_csum_v = NULL;
|
||||
g_autofree char *to_checksum = NULL;
|
||||
gboolean have_to_commit;
|
||||
{
|
||||
g_autoptr(GVariant) to_csum_v = g_variant_get_child_value (delta_superblock, 3);
|
||||
if (!ostree_validate_structureof_csum_v (to_csum_v, error))
|
||||
return FALSE;
|
||||
g_autofree char *to_checksum = ostree_checksum_from_bytes_v (to_csum_v);
|
||||
|
||||
to_csum_v = g_variant_get_child_value (delta_superblock, 3);
|
||||
if (!ostree_validate_structureof_csum_v (to_csum_v, error))
|
||||
goto out;
|
||||
to_checksum = ostree_checksum_from_bytes_v (to_csum_v);
|
||||
gboolean have_to_commit;
|
||||
if (!ostree_repo_has_object (pull_data->repo, OSTREE_OBJECT_TYPE_COMMIT, to_checksum,
|
||||
&have_to_commit, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
if (!ostree_repo_has_object (pull_data->repo, OSTREE_OBJECT_TYPE_COMMIT, to_checksum,
|
||||
&have_to_commit, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (!have_to_commit)
|
||||
{
|
||||
FetchObjectData *fetch_data;
|
||||
g_autoptr(GVariant) to_commit = g_variant_get_child_value (delta_superblock, 4);
|
||||
g_autofree char *detached_path = _ostree_get_relative_static_delta_path (from_revision, to_revision, "commitmeta");
|
||||
g_autoptr(GVariant) detached_data = NULL;
|
||||
if (!have_to_commit)
|
||||
{
|
||||
g_autoptr(GVariant) to_commit = g_variant_get_child_value (delta_superblock, 4);
|
||||
g_autofree char *detached_path = _ostree_get_relative_static_delta_path (from_revision, to_revision, "commitmeta");
|
||||
g_autoptr(GVariant) detached_data = g_variant_lookup_value (metadata, detached_path, G_VARIANT_TYPE("a{sv}"));
|
||||
|
||||
detached_data = g_variant_lookup_value (metadata, detached_path, G_VARIANT_TYPE("a{sv}"));
|
||||
if (!gpg_verify_unwritten_commit (pull_data, to_revision, to_commit, detached_data,
|
||||
cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
if (!gpg_verify_unwritten_commit (pull_data, to_revision, to_commit, detached_data,
|
||||
cancellable, error))
|
||||
goto out;
|
||||
if (detached_data && !ostree_repo_write_commit_detached_metadata (pull_data->repo,
|
||||
to_revision,
|
||||
detached_data,
|
||||
cancellable,
|
||||
error))
|
||||
return FALSE;
|
||||
|
||||
if (detached_data && !ostree_repo_write_commit_detached_metadata (pull_data->repo,
|
||||
to_revision,
|
||||
detached_data,
|
||||
cancellable,
|
||||
error))
|
||||
goto out;
|
||||
FetchObjectData *fetch_data = g_new0 (FetchObjectData, 1);
|
||||
fetch_data->pull_data = pull_data;
|
||||
fetch_data->object = ostree_object_name_serialize (to_checksum, OSTREE_OBJECT_TYPE_COMMIT);
|
||||
fetch_data->is_detached_meta = FALSE;
|
||||
fetch_data->object_is_stored = FALSE;
|
||||
fetch_data->requested_ref = (ref != NULL) ? ostree_collection_ref_dup (ref) : NULL;
|
||||
|
||||
fetch_data = g_new0 (FetchObjectData, 1);
|
||||
fetch_data->pull_data = pull_data;
|
||||
fetch_data->object = ostree_object_name_serialize (to_checksum, OSTREE_OBJECT_TYPE_COMMIT);
|
||||
fetch_data->is_detached_meta = FALSE;
|
||||
fetch_data->object_is_stored = FALSE;
|
||||
fetch_data->requested_ref = (ref != NULL) ? ostree_collection_ref_dup (ref) : NULL;
|
||||
|
||||
ostree_repo_write_metadata_async (pull_data->repo, OSTREE_OBJECT_TYPE_COMMIT, to_checksum,
|
||||
to_commit,
|
||||
pull_data->cancellable,
|
||||
on_metadata_written, fetch_data);
|
||||
pull_data->n_outstanding_metadata_write_requests++;
|
||||
}
|
||||
}
|
||||
ostree_repo_write_metadata_async (pull_data->repo, OSTREE_OBJECT_TYPE_COMMIT, to_checksum,
|
||||
to_commit,
|
||||
pull_data->cancellable,
|
||||
on_metadata_written, fetch_data);
|
||||
pull_data->n_outstanding_metadata_write_requests++;
|
||||
}
|
||||
}
|
||||
|
||||
n = g_variant_n_children (headers);
|
||||
pull_data->n_total_deltaparts += n;
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
|
||||
for (guint i = 0; i < n; i++)
|
||||
{
|
||||
const guchar *csum;
|
||||
g_autoptr(GVariant) header = NULL;
|
||||
gboolean have_all = FALSE;
|
||||
g_autofree char *deltapart_path = NULL;
|
||||
FetchStaticDeltaData *fetch_data;
|
||||
|
||||
g_autoptr(GVariant) header = g_variant_get_child_value (headers, i);
|
||||
g_autoptr(GVariant) csum_v = NULL;
|
||||
g_autoptr(GVariant) objects = NULL;
|
||||
g_autoptr(GBytes) inline_part_bytes = NULL;
|
||||
guint64 size, usize;
|
||||
guint32 version;
|
||||
|
||||
header = g_variant_get_child_value (headers, i);
|
||||
guint64 size, usize;
|
||||
g_variant_get (header, "(u@aytt@ay)", &version, &csum_v, &size, &usize, &objects);
|
||||
|
||||
version = maybe_swap_endian_u32 (delta_byteswap, version);
|
||||
size = maybe_swap_endian_u64 (delta_byteswap, size);
|
||||
usize = maybe_swap_endian_u64 (delta_byteswap, usize);
|
||||
|
||||
if (version > OSTREE_DELTAPART_VERSION)
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
"Delta part has too new version %u", version);
|
||||
goto out;
|
||||
}
|
||||
return glnx_throw (error, "Delta part has too new version %u", version);
|
||||
|
||||
csum = ostree_checksum_bytes_peek_validate (csum_v, error);
|
||||
const guchar *csum = ostree_checksum_bytes_peek_validate (csum_v, error);
|
||||
if (!csum)
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
if (!_ostree_repo_static_delta_part_have_all_objects (pull_data->repo,
|
||||
objects,
|
||||
&have_all,
|
||||
cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
pull_data->total_deltapart_size += size;
|
||||
pull_data->total_deltapart_usize += usize;
|
||||
@@ -2266,7 +2246,7 @@ process_one_static_delta (OtPullData *pull_data,
|
||||
continue;
|
||||
}
|
||||
|
||||
deltapart_path = _ostree_get_relative_static_delta_part_path (from_revision, to_revision, i);
|
||||
g_autofree char *deltapart_path = _ostree_get_relative_static_delta_part_path (from_revision, to_revision, i);
|
||||
|
||||
{ g_autoptr(GVariant) part_datav =
|
||||
g_variant_lookup_value (metadata, deltapart_path, G_VARIANT_TYPE ("(yay)"));
|
||||
@@ -2277,8 +2257,8 @@ process_one_static_delta (OtPullData *pull_data,
|
||||
|
||||
if (pull_data->dry_run)
|
||||
continue;
|
||||
|
||||
fetch_data = g_new0 (FetchStaticDeltaData, 1);
|
||||
|
||||
FetchStaticDeltaData *fetch_data = g_new0 (FetchStaticDeltaData, 1);
|
||||
fetch_data->from_revision = g_strdup (from_revision);
|
||||
fetch_data->to_revision = g_strdup (to_revision);
|
||||
fetch_data->pull_data = pull_data;
|
||||
@@ -2297,7 +2277,7 @@ process_one_static_delta (OtPullData *pull_data,
|
||||
OSTREE_STATIC_DELTA_OPEN_FLAGS_SKIP_CHECKSUM,
|
||||
NULL, &inline_delta_part,
|
||||
cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
_ostree_static_delta_part_execute_async (pull_data->repo,
|
||||
fetch_data->objects,
|
||||
@@ -2328,14 +2308,11 @@ process_one_static_delta (OtPullData *pull_data,
|
||||
{
|
||||
g_autofree char *formatted_required = g_format_size (pull_data->total_deltapart_usize);
|
||||
g_autofree char *formatted_avail = g_format_size (((guint64)stvfsbuf.f_bsize) * stvfsbuf.f_bfree);
|
||||
glnx_throw (error, "Delta requires %s free space, but only %s available",
|
||||
formatted_required, formatted_avail);
|
||||
goto out;
|
||||
return glnx_throw (error, "Delta requires %s free space, but only %s available",
|
||||
formatted_required, formatted_avail);
|
||||
}
|
||||
|
||||
ret = TRUE;
|
||||
out:
|
||||
return ret;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2806,18 +2783,16 @@ _ostree_preload_metadata_file (OstreeRepo *self,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
|
||||
if (is_metalink)
|
||||
{
|
||||
g_autoptr(OstreeMetalink) metalink = NULL;
|
||||
GError *local_error = NULL;
|
||||
|
||||
/* the metalink uri is buried in the mirrorlist as the first (and only)
|
||||
* element */
|
||||
metalink = _ostree_metalink_new (fetcher, filename,
|
||||
OSTREE_MAX_METADATA_SIZE,
|
||||
mirrorlist->pdata[0]);
|
||||
g_autoptr(OstreeMetalink) metalink =
|
||||
_ostree_metalink_new (fetcher, filename,
|
||||
OSTREE_MAX_METADATA_SIZE,
|
||||
mirrorlist->pdata[0]);
|
||||
|
||||
_ostree_metalink_request_sync (metalink, NULL, out_bytes,
|
||||
cancellable, &local_error);
|
||||
@@ -2830,25 +2805,18 @@ _ostree_preload_metadata_file (OstreeRepo *self,
|
||||
else if (local_error != NULL)
|
||||
{
|
||||
g_propagate_error (error, local_error);
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = _ostree_fetcher_mirrored_request_to_membuf (fetcher, mirrorlist,
|
||||
filename,
|
||||
OSTREE_FETCHER_REQUEST_OPTIONAL_CONTENT,
|
||||
out_bytes,
|
||||
OSTREE_MAX_METADATA_SIZE,
|
||||
cancellable, error);
|
||||
|
||||
if (!ret)
|
||||
goto out;
|
||||
return _ostree_fetcher_mirrored_request_to_membuf (fetcher, mirrorlist, filename,
|
||||
OSTREE_FETCHER_REQUEST_OPTIONAL_CONTENT,
|
||||
out_bytes, OSTREE_MAX_METADATA_SIZE,
|
||||
cancellable, error);
|
||||
}
|
||||
|
||||
ret = TRUE;
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -2858,29 +2826,23 @@ fetch_mirrorlist (OstreeFetcher *fetcher,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
g_auto(GStrv) lines = NULL;
|
||||
g_autofree char *contents = NULL;
|
||||
g_autoptr(OstreeFetcherURI) mirrorlist = NULL;
|
||||
g_autoptr(GPtrArray) ret_mirrorlist =
|
||||
g_ptr_array_new_with_free_func ((GDestroyNotify) _ostree_fetcher_uri_free);
|
||||
|
||||
mirrorlist = _ostree_fetcher_uri_parse (mirrorlist_url, error);
|
||||
g_autoptr(OstreeFetcherURI) mirrorlist = _ostree_fetcher_uri_parse (mirrorlist_url, error);
|
||||
if (!mirrorlist)
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
g_autofree char *contents = NULL;
|
||||
if (!fetch_uri_contents_utf8_sync (fetcher, mirrorlist, &contents,
|
||||
cancellable, error))
|
||||
{
|
||||
g_prefix_error (error, "While fetching mirrorlist '%s': ",
|
||||
mirrorlist_url);
|
||||
goto out;
|
||||
}
|
||||
return glnx_prefix_error (error, "While fetching mirrorlist '%s'",
|
||||
mirrorlist_url);
|
||||
|
||||
/* go through each mirror in mirrorlist and do a quick sanity check that it
|
||||
* works so that we don't waste the fetcher's time when it goes through them
|
||||
* */
|
||||
lines = g_strsplit (contents, "\n", -1);
|
||||
g_auto(GStrv) lines = g_strsplit (contents, "\n", -1);
|
||||
g_debug ("Scanning mirrorlist from '%s'", mirrorlist_url);
|
||||
for (char **iter = lines; iter && *iter; iter++)
|
||||
{
|
||||
@@ -2936,18 +2898,11 @@ fetch_mirrorlist (OstreeFetcher *fetcher,
|
||||
}
|
||||
|
||||
if (ret_mirrorlist->len == 0)
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
"No valid mirrors were found in mirrorlist '%s'",
|
||||
mirrorlist_url);
|
||||
goto out;
|
||||
}
|
||||
return glnx_throw (error, "No valid mirrors were found in mirrorlist '%s'",
|
||||
mirrorlist_url);
|
||||
|
||||
*out_mirrorlist = g_steal_pointer (&ret_mirrorlist);
|
||||
ret = TRUE;
|
||||
|
||||
out:
|
||||
return ret;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -4658,7 +4613,11 @@ static void find_remotes_cb (GObject *obj,
|
||||
* Pass the results to ostree_repo_pull_from_remotes_async() to pull the given @refs
|
||||
* from those remotes.
|
||||
*
|
||||
* No @options are currently supported.
|
||||
* The following @options are currently defined:
|
||||
*
|
||||
* * `override-commit-ids` (`as`): Array of specific commit IDs to fetch. The nth
|
||||
* commit ID applies to the nth ref, so this must be the same length as @refs, if
|
||||
* provided.
|
||||
*
|
||||
* @finders must be a non-empty %NULL-terminated array of the #OstreeRepoFinder
|
||||
* instances to use, or %NULL to use the system default set of finders, which
|
||||
@@ -4687,6 +4646,7 @@ ostree_repo_find_remotes_async (OstreeRepo *self,
|
||||
g_autoptr(OstreeRepoFinder) finder_config = NULL;
|
||||
g_autoptr(OstreeRepoFinder) finder_mount = NULL;
|
||||
g_autoptr(OstreeRepoFinder) finder_avahi = NULL;
|
||||
g_autofree char **override_commit_ids = NULL;
|
||||
|
||||
g_return_if_fail (OSTREE_IS_REPO (self));
|
||||
g_return_if_fail (is_valid_collection_ref_array (refs));
|
||||
@@ -4696,6 +4656,12 @@ ostree_repo_find_remotes_async (OstreeRepo *self,
|
||||
g_return_if_fail (progress == NULL || OSTREE_IS_ASYNC_PROGRESS (progress));
|
||||
g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
|
||||
|
||||
if (options)
|
||||
{
|
||||
(void) g_variant_lookup (options, "override-commit-ids", "^a&s", &override_commit_ids);
|
||||
g_return_if_fail (override_commit_ids == NULL || g_strv_length ((gchar **) refs) == g_strv_length (override_commit_ids));
|
||||
}
|
||||
|
||||
/* Set up a task for the whole operation. */
|
||||
task = g_task_new (self, cancellable, callback, user_data);
|
||||
g_task_set_source_tag (task, ostree_repo_find_remotes_async);
|
||||
@@ -4903,6 +4869,7 @@ find_remotes_cb (GObject *obj,
|
||||
g_autoptr(OstreeFetcher) fetcher = NULL;
|
||||
g_autofree const gchar **ref_to_latest_commit = NULL; /* indexed as @refs; (element-type commit-checksum) */
|
||||
gsize n_refs;
|
||||
g_autofree char **override_commit_ids = NULL;
|
||||
g_autoptr(GPtrArray) remotes_to_remove = NULL; /* (element-type OstreeRemote) */
|
||||
g_autoptr(GPtrArray) final_results = NULL; /* (element-type OstreeRepoFinderResult) */
|
||||
|
||||
@@ -4935,13 +4902,10 @@ find_remotes_cb (GObject *obj,
|
||||
* to be %NULL-safe. */
|
||||
g_ptr_array_set_free_func (results, (GDestroyNotify) repo_finder_result_free0);
|
||||
|
||||
/* FIXME: Add support for options:
|
||||
* - override-commit-ids (allow downgrades)
|
||||
*
|
||||
* Use case: multiple pulls of separate subdirs; want them to use the same
|
||||
* configuration.
|
||||
* Use case: downgrading a flatpak app.
|
||||
*/
|
||||
if (data->options)
|
||||
{
|
||||
(void) g_variant_lookup (data->options, "override-commit-ids", "^a&s", &override_commit_ids);
|
||||
}
|
||||
|
||||
/* FIXME: In future, we also want to pull static delta superblocks in this
|
||||
* phase, so that we have all the metadata we need for accurate size
|
||||
@@ -4956,7 +4920,7 @@ find_remotes_cb (GObject *obj,
|
||||
* remote, or %NULL if the remote doesn’t have that ref. */
|
||||
n_refs = g_strv_length ((gchar **) refs); /* it’s not a GStrv, but this works */
|
||||
refs_and_remotes_table = pointer_table_new (n_refs, results->len);
|
||||
remotes_to_remove = g_ptr_array_new_with_free_func (NULL);
|
||||
remotes_to_remove = g_ptr_array_new_with_free_func ((GDestroyNotify) ostree_remote_unref);
|
||||
|
||||
/* Fetch and validate the summary file for each result. */
|
||||
/* FIXME: All these downloads could be parallelised; that requires the
|
||||
@@ -4976,7 +4940,7 @@ find_remotes_cb (GObject *obj,
|
||||
/* Add the remote to our internal list of remotes, so other libostree
|
||||
* API can access it. */
|
||||
if (!_ostree_repo_add_remote (self, result->remote))
|
||||
g_ptr_array_add (remotes_to_remove, result->remote);
|
||||
g_ptr_array_add (remotes_to_remove, ostree_remote_ref (result->remote));
|
||||
|
||||
g_debug ("%s: Fetching summary for remote ‘%s’ with keyring ‘%s’.",
|
||||
G_STRFUNC, result->remote->name, result->remote->keyring);
|
||||
@@ -5191,10 +5155,11 @@ find_remotes_cb (GObject *obj,
|
||||
* differences between remotes: two remotes could both contain ref R, but one
|
||||
* remote could be outdated compared to the other, and point to an older
|
||||
* commit. For each ref, we want to find the most recent commit any remote
|
||||
* points to for it.
|
||||
* points to for it (unless override-commit-ids was used).
|
||||
*
|
||||
* @ref_to_latest_commit is indexed by @ref_index, and its values are the
|
||||
* latest checksum for each ref. */
|
||||
* latest checksum for each ref. If override-commit-ids was used,
|
||||
* @ref_to_latest_commit won't be initialized or used.*/
|
||||
ref_to_latest_commit = g_new0 (const gchar *, n_refs);
|
||||
|
||||
for (i = 0; i < n_refs; i++)
|
||||
@@ -5204,6 +5169,13 @@ find_remotes_cb (GObject *obj,
|
||||
const CommitMetadata *latest_commit_metadata = NULL;
|
||||
g_autofree gchar *latest_commit_timestamp_str = NULL;
|
||||
|
||||
if (override_commit_ids)
|
||||
{
|
||||
g_debug ("%s: Using specified commit ‘%s’ for ref (%s, %s).",
|
||||
G_STRFUNC, override_commit_ids[i], refs[i]->collection_id, refs[i]->ref_name);
|
||||
continue;
|
||||
}
|
||||
|
||||
for (j = 0; j < results->len; j++)
|
||||
{
|
||||
const CommitMetadata *candidate_commit_metadata;
|
||||
@@ -5264,26 +5236,37 @@ find_remotes_cb (GObject *obj,
|
||||
ostree_collection_ref_equal,
|
||||
(GDestroyNotify) ostree_collection_ref_free,
|
||||
g_free);
|
||||
n_latest_refs = 0;
|
||||
|
||||
for (j = 0; refs[j] != NULL; j++)
|
||||
if (override_commit_ids)
|
||||
{
|
||||
const gchar *latest_commit_for_ref = ref_to_latest_commit[j];
|
||||
|
||||
if (pointer_table_get (refs_and_remotes_table, j, i) != latest_commit_for_ref)
|
||||
latest_commit_for_ref = NULL;
|
||||
if (latest_commit_for_ref != NULL)
|
||||
n_latest_refs++;
|
||||
|
||||
g_hash_table_insert (validated_ref_to_checksum, ostree_collection_ref_dup (refs[j]), g_strdup (latest_commit_for_ref));
|
||||
for (j = 0; refs[j] != NULL; j++)
|
||||
g_hash_table_insert (validated_ref_to_checksum, ostree_collection_ref_dup (refs[j]),
|
||||
g_strdup (override_commit_ids[j]));
|
||||
}
|
||||
|
||||
if (n_latest_refs == 0)
|
||||
else
|
||||
{
|
||||
g_debug ("%s: Omitting remote ‘%s’ from results as none of its refs are new enough.",
|
||||
G_STRFUNC, result->remote->name);
|
||||
ostree_repo_finder_result_free (g_steal_pointer (&g_ptr_array_index (results, i)));
|
||||
continue;
|
||||
n_latest_refs = 0;
|
||||
|
||||
for (j = 0; refs[j] != NULL; j++)
|
||||
{
|
||||
const gchar *latest_commit_for_ref = ref_to_latest_commit[j];
|
||||
|
||||
if (pointer_table_get (refs_and_remotes_table, j, i) != latest_commit_for_ref)
|
||||
latest_commit_for_ref = NULL;
|
||||
if (latest_commit_for_ref != NULL)
|
||||
n_latest_refs++;
|
||||
|
||||
g_hash_table_insert (validated_ref_to_checksum, ostree_collection_ref_dup (refs[j]),
|
||||
g_strdup (latest_commit_for_ref));
|
||||
}
|
||||
|
||||
if (n_latest_refs == 0)
|
||||
{
|
||||
g_debug ("%s: Omitting remote ‘%s’ from results as none of its refs are new enough.",
|
||||
G_STRFUNC, result->remote->name);
|
||||
ostree_repo_finder_result_free (g_steal_pointer (&g_ptr_array_index (results, i)));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
result->ref_to_checksum = g_steal_pointer (&validated_ref_to_checksum);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2011,2013 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2013,2014 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
@@ -1370,7 +1372,6 @@ ostree_repo_static_delta_generate (OstreeRepo *self,
|
||||
g_autoptr(GVariant) detached = NULL;
|
||||
gboolean inline_parts;
|
||||
guint endianness = G_BYTE_ORDER;
|
||||
glnx_autofd int tmp_dfd = -1;
|
||||
builder.parts = g_ptr_array_new_with_free_func ((GDestroyNotify)ostree_static_delta_part_builder_unref);
|
||||
builder.fallback_objects = g_ptr_array_new_with_free_func ((GDestroyNotify)g_variant_unref);
|
||||
g_auto(GLnxTmpfile) descriptor_tmpf = { 0, };
|
||||
@@ -1416,36 +1417,13 @@ ostree_repo_static_delta_generate (OstreeRepo *self,
|
||||
&to_commit, error))
|
||||
goto out;
|
||||
|
||||
if (opt_filename)
|
||||
{
|
||||
g_autofree char *dnbuf = g_strdup (opt_filename);
|
||||
const char *dn = dirname (dnbuf);
|
||||
if (!glnx_opendirat (AT_FDCWD, dn, TRUE, &tmp_dfd, error))
|
||||
goto out;
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp_dfd = fcntl (self->tmp_dir_fd, F_DUPFD_CLOEXEC, 3);
|
||||
if (tmp_dfd < 0)
|
||||
{
|
||||
glnx_set_error_from_errno (error);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
builder.parts_dfd = tmp_dfd;
|
||||
builder.delta_opts = delta_opts;
|
||||
|
||||
/* Ignore optimization flags */
|
||||
if (!generate_delta_lowlatency (self, from, to, delta_opts, &builder,
|
||||
cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (opt_filename)
|
||||
{
|
||||
g_autofree char *dnbuf = g_strdup (opt_filename);
|
||||
const char *dn = dirname (dnbuf);
|
||||
descriptor_name = g_strdup (opt_filename);
|
||||
descriptor_name = g_strdup (glnx_basename (opt_filename));
|
||||
|
||||
if (!glnx_opendirat (AT_FDCWD, dn, TRUE, &descriptor_dfd, error))
|
||||
goto out;
|
||||
@@ -1463,6 +1441,12 @@ ostree_repo_static_delta_generate (OstreeRepo *self,
|
||||
|
||||
descriptor_name = g_strdup (basename (descriptor_relpath));
|
||||
}
|
||||
builder.parts_dfd = descriptor_dfd;
|
||||
|
||||
/* Ignore optimization flags */
|
||||
if (!generate_delta_lowlatency (self, from, to, delta_opts, &builder,
|
||||
cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (!glnx_open_tmpfile_linkable_at (descriptor_dfd, ".", O_WRONLY | O_CLOEXEC,
|
||||
&descriptor_tmpf, error))
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2013,2014 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2011 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
* Copyright (C) 2011 Colin Walters <walters@verbum.org>
|
||||
* Copyright (C) 2015 Red Hat, Inc.
|
||||
*
|
||||
* 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
|
||||
@@ -3027,18 +3029,6 @@ ostree_repo_open (OstreeRepo *self,
|
||||
if (!ostree_repo_reload_config (self, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
/* TODO - delete this */
|
||||
if (self->mode == OSTREE_REPO_MODE_ARCHIVE && self->enable_uncompressed_cache)
|
||||
{
|
||||
if (!glnx_shutil_mkdir_p_at (self->repo_dir_fd, "uncompressed-objects-cache", 0755,
|
||||
cancellable, error))
|
||||
return FALSE;
|
||||
if (!glnx_opendirat (self->repo_dir_fd, "uncompressed-objects-cache", TRUE,
|
||||
&self->uncompressed_objects_dir_fd,
|
||||
error))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
self->inited = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2011 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
@@ -940,6 +942,34 @@ ostree_repo_checkout_tree (OstreeRepo *self,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
/**
|
||||
* OstreeRepoCheckoutFilterResult:
|
||||
* @OSTREE_REPO_CHECKOUT_FILTER_ALLOW: Do checkout this object
|
||||
* @OSTREE_REPO_CHECKOUT_FILTER_SKIP: Ignore this object
|
||||
*
|
||||
* Since: 2018.2
|
||||
*/
|
||||
typedef enum {
|
||||
OSTREE_REPO_CHECKOUT_FILTER_ALLOW,
|
||||
OSTREE_REPO_CHECKOUT_FILTER_SKIP
|
||||
} OstreeRepoCheckoutFilterResult;
|
||||
|
||||
/**
|
||||
* OstreeRepoCheckoutFilter:
|
||||
* @repo: Repo
|
||||
* @path: Path to file
|
||||
* @stbuf: File information
|
||||
* @user_data: User data
|
||||
*
|
||||
* Returns: #OstreeRepoCheckoutFilterResult saying whether or not to checkout this file
|
||||
*
|
||||
* Since: 2018.2
|
||||
*/
|
||||
typedef OstreeRepoCheckoutFilterResult (*OstreeRepoCheckoutFilter) (OstreeRepo *repo,
|
||||
const char *path,
|
||||
struct stat *stbuf,
|
||||
gpointer user_data);
|
||||
|
||||
/**
|
||||
* OstreeRepoCheckoutAtOptions:
|
||||
*
|
||||
@@ -967,7 +997,9 @@ typedef struct {
|
||||
OstreeRepoDevInoCache *devino_to_csum_cache;
|
||||
|
||||
int unused_ints[6];
|
||||
gpointer unused_ptrs[5];
|
||||
gpointer unused_ptrs[3];
|
||||
OstreeRepoCheckoutFilter filter; /* Since: 2018.2 */
|
||||
gpointer filter_user_data; /* Since: 2018.2 */
|
||||
OstreeSePolicy *sepolicy; /* Since: 2017.6 */
|
||||
const char *sepolicy_prefix;
|
||||
} OstreeRepoCheckoutAtOptions;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2017 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2012,2014 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
@@ -93,24 +95,42 @@ sysroot_flags_to_copy_flags (GLnxFileCopyFlags defaults,
|
||||
}
|
||||
|
||||
/* Try a hardlink if we can, otherwise fall back to copying. Used
|
||||
* right now for kernels/initramfs in /boot, where we can just
|
||||
* right now for kernels/initramfs/device trees in /boot, where we can just
|
||||
* hardlink if we're on the same partition.
|
||||
*/
|
||||
static gboolean
|
||||
hardlink_or_copy_at (int src_dfd,
|
||||
const char *src_subpath,
|
||||
int dest_dfd,
|
||||
const char *dest_subpath,
|
||||
OstreeSysrootDebugFlags flags,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
install_into_boot (OstreeSePolicy *sepolicy,
|
||||
int src_dfd,
|
||||
const char *src_subpath,
|
||||
int dest_dfd,
|
||||
const char *dest_subpath,
|
||||
OstreeSysrootDebugFlags flags,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
if (linkat (src_dfd, src_subpath, dest_dfd, dest_subpath, 0) != 0)
|
||||
{
|
||||
if (G_IN_SET (errno, EMLINK, EXDEV))
|
||||
return glnx_file_copy_at (src_dfd, src_subpath, NULL, dest_dfd, dest_subpath,
|
||||
sysroot_flags_to_copy_flags (0, flags),
|
||||
cancellable, error);
|
||||
{
|
||||
/* Be sure we relabel when copying the kernel, as in current
|
||||
* e.g. Fedora it might be labeled module_object_t or usr_t,
|
||||
* but policy may not allow other processes to read from that
|
||||
* like kdump.
|
||||
* See also https://github.com/fedora-selinux/selinux-policy/commit/747f4e6775d773ab74efae5aa37f3e5e7f0d4aca
|
||||
* This means we also drop xattrs but...I doubt anyone uses
|
||||
* non-SELinux xattrs for the kernel anyways aside from perhaps
|
||||
* IMA but that's its own story.
|
||||
*/
|
||||
g_auto(OstreeSepolicyFsCreatecon) fscreatecon = { 0, };
|
||||
const char *boot_path = glnx_strjoina ("/boot/", glnx_basename (dest_subpath));
|
||||
if (!_ostree_sepolicy_preparefscreatecon (&fscreatecon, sepolicy,
|
||||
boot_path, S_IFREG | 0644,
|
||||
error))
|
||||
return FALSE;
|
||||
return glnx_file_copy_at (src_dfd, src_subpath, NULL, dest_dfd, dest_subpath,
|
||||
GLNX_FILE_COPY_NOXATTRS,
|
||||
cancellable, error);
|
||||
}
|
||||
else
|
||||
return glnx_throw_errno_prefix (error, "linkat(%s)", dest_subpath);
|
||||
}
|
||||
@@ -894,6 +914,8 @@ typedef struct {
|
||||
char *kernel_namever;
|
||||
char *initramfs_srcpath;
|
||||
char *initramfs_namever;
|
||||
char *devicetree_srcpath;
|
||||
char *devicetree_namever;
|
||||
char *bootcsum;
|
||||
} OstreeKernelLayout;
|
||||
static void
|
||||
@@ -904,6 +926,8 @@ _ostree_kernel_layout_free (OstreeKernelLayout *layout)
|
||||
g_free (layout->kernel_namever);
|
||||
g_free (layout->initramfs_srcpath);
|
||||
g_free (layout->initramfs_namever);
|
||||
g_free (layout->devicetree_srcpath);
|
||||
g_free (layout->devicetree_namever);
|
||||
g_free (layout->bootcsum);
|
||||
g_free (layout);
|
||||
}
|
||||
@@ -1025,6 +1049,22 @@ get_kernel_from_tree_usrlib_modules (int deployment_dfd,
|
||||
if (!ot_gio_splice_update_checksum (NULL, in, &checksum, cancellable, error))
|
||||
return FALSE;
|
||||
}
|
||||
g_clear_object (&in);
|
||||
glnx_close_fd (&fd);
|
||||
|
||||
if (!ot_openat_ignore_enoent (ret_layout->boot_dfd, "devicetree", &fd, error))
|
||||
return FALSE;
|
||||
if (fd != -1)
|
||||
{
|
||||
ret_layout->devicetree_srcpath = g_strdup ("devicetree");
|
||||
ret_layout->devicetree_namever = g_strdup_printf ("devicetree-%s", kver);
|
||||
in = g_unix_input_stream_new (fd, FALSE);
|
||||
if (!ot_gio_splice_update_checksum (NULL, in, &checksum, cancellable, error))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_clear_object (&in);
|
||||
glnx_close_fd (&fd);
|
||||
|
||||
char hexdigest[OSTREE_SHA256_STRING_LEN+1];
|
||||
ot_checksum_get_hexdigest (&checksum, hexdigest, sizeof (hexdigest));
|
||||
@@ -1044,6 +1084,7 @@ get_kernel_from_tree_legacy_layouts (int deployment_dfd,
|
||||
const char *legacy_paths[] = {"usr/lib/ostree-boot", "boot"};
|
||||
g_autofree char *kernel_checksum = NULL;
|
||||
g_autofree char *initramfs_checksum = NULL;
|
||||
g_autofree char *devicetree_checksum = NULL;
|
||||
g_autoptr(OstreeKernelLayout) ret_layout = _ostree_kernel_layout_new ();
|
||||
|
||||
for (guint i = 0; i < G_N_ELEMENTS (legacy_paths); i++)
|
||||
@@ -1110,9 +1151,23 @@ get_kernel_from_tree_legacy_layouts (int deployment_dfd,
|
||||
ret_layout->initramfs_namever = g_strndup (name, dash - name);
|
||||
}
|
||||
}
|
||||
/* See if this is the devicetree */
|
||||
else if (ret_layout->devicetree_srcpath == NULL && g_str_has_prefix (name, "devicetree-"))
|
||||
{
|
||||
const char *dash = strrchr (name, '-');
|
||||
g_assert (dash);
|
||||
if (ostree_validate_structureof_checksum_string (dash + 1, NULL))
|
||||
{
|
||||
devicetree_checksum = g_strdup (dash + 1);
|
||||
ret_layout->devicetree_srcpath = g_strdup (name);
|
||||
ret_layout->devicetree_namever = g_strndup (name, dash - name);
|
||||
}
|
||||
}
|
||||
|
||||
/* If we found both a kernel and initramfs, break out of the loop */
|
||||
if (ret_layout->kernel_srcpath != NULL && ret_layout->initramfs_srcpath != NULL)
|
||||
/* If we found a kernel, an initramfs and a devicetree, break out of the loop */
|
||||
if (ret_layout->kernel_srcpath != NULL &&
|
||||
ret_layout->initramfs_srcpath != NULL &&
|
||||
ret_layout->devicetree_srcpath != NULL)
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1132,6 +1187,19 @@ get_kernel_from_tree_legacy_layouts (int deployment_dfd,
|
||||
return glnx_throw (error, "Mismatched kernel checksum vs initrd");
|
||||
}
|
||||
|
||||
/* The kernel/devicetree checksums must be the same */
|
||||
if (ret_layout->devicetree_srcpath != NULL)
|
||||
{
|
||||
g_assert (kernel_checksum != NULL);
|
||||
g_assert (devicetree_checksum != NULL);
|
||||
if (strcmp (kernel_checksum, devicetree_checksum) != 0)
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
|
||||
"Mismatched kernel checksum vs device tree in tree");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
ret_layout->bootcsum = g_steal_pointer (&kernel_checksum);
|
||||
|
||||
*out_layout = g_steal_pointer (&ret_layout);
|
||||
@@ -1567,7 +1635,12 @@ install_deployment_kernel (OstreeSysroot *sysroot,
|
||||
&deployment_dfd, error))
|
||||
return FALSE;
|
||||
|
||||
/* Find the kernel/initramfs in the tree */
|
||||
/* We need to label the kernels */
|
||||
g_autoptr(OstreeSePolicy) sepolicy = ostree_sepolicy_new_at (deployment_dfd, cancellable, error);
|
||||
if (!sepolicy)
|
||||
return FALSE;
|
||||
|
||||
/* Find the kernel/initramfs/devicetree in the tree */
|
||||
g_autoptr(OstreeKernelLayout) kernel_layout = NULL;
|
||||
if (!get_kernel_from_tree (deployment_dfd, &kernel_layout,
|
||||
cancellable, error))
|
||||
@@ -1602,11 +1675,10 @@ install_deployment_kernel (OstreeSysroot *sysroot,
|
||||
return FALSE;
|
||||
if (errno == ENOENT)
|
||||
{
|
||||
if (!hardlink_or_copy_at (kernel_layout->boot_dfd,
|
||||
kernel_layout->kernel_srcpath,
|
||||
bootcsum_dfd, kernel_layout->kernel_namever,
|
||||
sysroot->debug_flags,
|
||||
cancellable, error))
|
||||
if (!install_into_boot (sepolicy, kernel_layout->boot_dfd, kernel_layout->kernel_srcpath,
|
||||
bootcsum_dfd, kernel_layout->kernel_namever,
|
||||
sysroot->debug_flags,
|
||||
cancellable, error))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -1620,10 +1692,25 @@ install_deployment_kernel (OstreeSysroot *sysroot,
|
||||
return FALSE;
|
||||
if (errno == ENOENT)
|
||||
{
|
||||
if (!hardlink_or_copy_at (kernel_layout->boot_dfd, kernel_layout->initramfs_srcpath,
|
||||
bootcsum_dfd, kernel_layout->initramfs_namever,
|
||||
sysroot->debug_flags,
|
||||
cancellable, error))
|
||||
if (!install_into_boot (sepolicy, kernel_layout->boot_dfd, kernel_layout->initramfs_srcpath,
|
||||
bootcsum_dfd, kernel_layout->initramfs_namever,
|
||||
sysroot->debug_flags,
|
||||
cancellable, error))
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (kernel_layout->devicetree_srcpath)
|
||||
{
|
||||
g_assert (kernel_layout->devicetree_namever);
|
||||
if (!glnx_fstatat_allow_noent (bootcsum_dfd, kernel_layout->devicetree_namever, &stbuf, 0, error))
|
||||
return FALSE;
|
||||
if (errno == ENOENT)
|
||||
{
|
||||
if (!install_into_boot (sepolicy, kernel_layout->boot_dfd, kernel_layout->devicetree_srcpath,
|
||||
bootcsum_dfd, kernel_layout->devicetree_namever,
|
||||
sysroot->debug_flags,
|
||||
cancellable, error))
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
@@ -1717,6 +1804,12 @@ install_deployment_kernel (OstreeSysroot *sysroot,
|
||||
_ostree_kernel_args_replace_take (kargs, g_steal_pointer (&prepare_root_arg));
|
||||
}
|
||||
|
||||
if (kernel_layout->devicetree_namever)
|
||||
{
|
||||
g_autofree char * boot_relpath = g_strconcat ("/", bootcsumdir, "/", kernel_layout->devicetree_namever, NULL);
|
||||
ostree_bootconfig_parser_set (bootconfig, "devicetree", boot_relpath);
|
||||
}
|
||||
|
||||
/* Note this is parsed in ostree-impl-system-generator.c */
|
||||
g_autofree char *ostree_kernel_arg = g_strdup_printf ("ostree=/ostree/boot.%d/%s/%s/%d",
|
||||
new_bootversion, osname, bootcsum,
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2012,2013 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
Loaded 100 of 380 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user