deploy: Find kernel/initramfs consistently from filesystem

I'm porting the deployment code to be fd-relative, but part of the
logic was using `GFile` to talk to `OstreeRepoFile` to determine the
"bootcsum" (boot config checksum) before checking out the file tree.

We can avoid having both code paths by checking out the tree first,
then looking at it on the filesystem.
This commit is contained in:
Colin Walters 2015-04-20 22:02:14 -04:00
parent 6f96571679
commit 506a891e36
3 changed files with 58 additions and 20 deletions

View File

@ -0,0 +1,29 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
*
* Copyright (C) 2015 Colin Walters <walters@verbum.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2 of the licence or (at
* your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*/
#pragma once
#include "ostree-deployment.h"
G_BEGIN_DECLS
void _ostree_deployment_set_bootcsum (OstreeDeployment *self, const char *bootcsum);
G_END_DECLS

View File

@ -20,7 +20,7 @@
#include "config.h"
#include "ostree-deployment.h"
#include "ostree-deployment-private.h"
#include "libglnx.h"
struct _OstreeDeployment
@ -129,6 +129,14 @@ ostree_deployment_set_origin (OstreeDeployment *self, GKeyFile *origin)
self->origin = g_key_file_ref (origin);
}
void
_ostree_deployment_set_bootcsum (OstreeDeployment *self,
const char *bootcsum)
{
g_free (self->bootcsum);
self->bootcsum = g_strdup (bootcsum);
}
/**
* ostree_deployment_clone:
* @self: Deployment

View File

@ -24,6 +24,7 @@
#include <gio/gunixoutputstream.h>
#include "ostree-sysroot-private.h"
#include "ostree-deployment-private.h"
#include "ostree-core-private.h"
#include "ostree-linuxfsutil.h"
#include "otutil.h"
@ -1934,7 +1935,6 @@ ostree_sysroot_deploy_tree (OstreeSysroot *self,
glnx_unref_object OstreeRepo *repo = NULL;
g_autoptr(GFile) osdeploydir = NULL;
g_autoptr(GFile) deployment_var = NULL;
g_autoptr(GFile) commit_root = NULL;
g_autoptr(GFile) tree_kernel_path = NULL;
g_autoptr(GFile) tree_initramfs_path = NULL;
glnx_fd_close int deployment_dfd = -1;
@ -1960,24 +1960,6 @@ ostree_sysroot_deploy_tree (OstreeSysroot *self,
if (!ostree_sysroot_get_repo (self, &repo, cancellable, error))
goto out;
if (!ostree_repo_read_commit (repo, revision, &commit_root, NULL, cancellable, error))
goto out;
if (!get_kernel_from_tree (commit_root, &tree_kernel_path, &tree_initramfs_path,
cancellable, error))
goto out;
if (tree_initramfs_path != NULL)
{
if (!checksum_from_kernel_src (tree_initramfs_path, &new_bootcsum, error))
goto out;
}
else
{
if (!checksum_from_kernel_src (tree_kernel_path, &new_bootcsum, error))
goto out;
}
if (provided_merge_deployment != NULL)
merge_deployment = g_object_ref (provided_merge_deployment);
@ -1997,6 +1979,25 @@ ostree_sysroot_deploy_tree (OstreeSysroot *self,
goto out;
}
deployment_dir = ostree_sysroot_get_deployment_directory (self, new_deployment);
if (!get_kernel_from_tree (deployment_dir, &tree_kernel_path, &tree_initramfs_path,
cancellable, error))
goto out;
if (tree_initramfs_path != NULL)
{
if (!checksum_from_kernel_src (tree_initramfs_path, &new_bootcsum, error))
goto out;
}
else
{
if (!checksum_from_kernel_src (tree_kernel_path, &new_bootcsum, error))
goto out;
}
_ostree_deployment_set_bootcsum (new_deployment, new_bootcsum);
/* Create an empty boot configuration; we will merge things into
* it as we go.
*/