unpacker: major rework
- Delete unpack_to_dfd path - Get rid of copynpaste stuff and use the newly reworked ostree libarchive API which now supports the callbacks we need Closes: #289 Approved by: cgwalters
This commit is contained in:
parent
2a036cf8b4
commit
ca162dece2
@ -37,10 +37,6 @@ librpmostreepriv_la_SOURCES = \
|
||||
src/libpriv/rpmostree-rpm-util.h \
|
||||
src/libpriv/rpmostree-unpacker.c \
|
||||
src/libpriv/rpmostree-unpacker.h \
|
||||
src/libpriv/ostree-libarchive-input-stream.c \
|
||||
src/libpriv/ostree-libarchive-input-stream.h \
|
||||
src/libpriv/rpmostree-ostree-libarchive-copynpaste.c \
|
||||
src/libpriv/rpmostree-ostree-libarchive-copynpaste.h \
|
||||
src/libpriv/rpmostree-output.c \
|
||||
src/libpriv/rpmostree-output.h \
|
||||
$(NULL)
|
||||
|
@ -36,17 +36,18 @@
|
||||
#include "rpmostree-libbuiltin.h"
|
||||
#include "rpmostree-rpm-util.h"
|
||||
#include "rpmostree-unpacker.h"
|
||||
#include "rpmostree-postprocess.h"
|
||||
|
||||
#include "libgsystem.h"
|
||||
|
||||
static gboolean opt_suid_fcaps = FALSE;
|
||||
static gboolean opt_owner = FALSE;
|
||||
static gboolean opt_to_ostree_repo = FALSE;
|
||||
static gboolean opt_selinux = FALSE;
|
||||
static gboolean opt_ostree_convention = FALSE;
|
||||
|
||||
static GOptionEntry option_entries[] = {
|
||||
{ "suid-fcaps", 0, 0, G_OPTION_ARG_NONE, &opt_suid_fcaps, "Enable setting suid/sgid and capabilities", NULL },
|
||||
{ "owner", 0, 0, G_OPTION_ARG_NONE, &opt_owner, "Enable chown", NULL },
|
||||
{ "to-ostree-repo", 0, 0, G_OPTION_ARG_NONE, &opt_to_ostree_repo, "Interpret TARGET as an OSTree repo", "REPO" },
|
||||
{ "selinux", 0, 0, G_OPTION_ARG_NONE, &opt_selinux,
|
||||
"Enable setting SELinux labels", NULL },
|
||||
{ "ostree-convention", 0, 0, G_OPTION_ARG_NONE, &opt_ostree_convention,
|
||||
"Change file paths following ostree conventions", NULL },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
@ -57,14 +58,15 @@ rpmostree_internals_builtin_unpack (int argc,
|
||||
GError **error)
|
||||
{
|
||||
int exit_status = EXIT_FAILURE;
|
||||
GOptionContext *context = g_option_context_new ("ROOT RPM");
|
||||
GOptionContext *context = g_option_context_new ("REPO RPM");
|
||||
RpmOstreeUnpackerFlags flags = 0;
|
||||
glnx_unref_object RpmOstreeUnpacker *unpacker = NULL;
|
||||
const char *target;
|
||||
const char *rpmpath;
|
||||
glnx_fd_close int rootfs_fd = -1;
|
||||
glnx_unref_object OstreeRepo *ostree_repo = NULL;
|
||||
|
||||
glnx_unref_object OstreeSePolicy *sepolicy = NULL;
|
||||
|
||||
if (!rpmostree_option_context_parse (context,
|
||||
option_entries,
|
||||
&argc, &argv,
|
||||
@ -76,55 +78,44 @@ rpmostree_internals_builtin_unpack (int argc,
|
||||
|
||||
if (argc < 3)
|
||||
{
|
||||
rpmostree_usage_error (context, "TARGET and RPM must be specified", error);
|
||||
rpmostree_usage_error (context, "REPO and RPM must be specified", error);
|
||||
goto out;
|
||||
}
|
||||
|
||||
target = argv[1];
|
||||
rpmpath = argv[2];
|
||||
|
||||
if (opt_to_ostree_repo)
|
||||
{
|
||||
g_autoptr(GFile) to_ostree_repo_file = g_file_new_for_path (target);
|
||||
{
|
||||
g_autoptr(GFile) ostree_repo_file = g_file_new_for_path (target);
|
||||
|
||||
ostree_repo = ostree_repo_new (to_ostree_repo_file);
|
||||
if (!ostree_repo_open (ostree_repo, cancellable, error))
|
||||
goto out;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!glnx_opendirat (AT_FDCWD, argv[1], TRUE, &rootfs_fd, error))
|
||||
goto out;
|
||||
}
|
||||
ostree_repo = ostree_repo_new (ostree_repo_file);
|
||||
if (!ostree_repo_open (ostree_repo, cancellable, error))
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* suid implies owner too...anything else is dangerous, as we might write
|
||||
* a setuid binary for the caller.
|
||||
*/
|
||||
if (opt_owner || opt_suid_fcaps)
|
||||
flags |= RPMOSTREE_UNPACKER_FLAGS_OWNER;
|
||||
if (opt_suid_fcaps)
|
||||
flags |= RPMOSTREE_UNPACKER_FLAGS_SUID_FSCAPS;
|
||||
if (opt_ostree_convention)
|
||||
flags |= RPMOSTREE_UNPACKER_FLAGS_OSTREE_CONVENTION;
|
||||
|
||||
unpacker = rpmostree_unpacker_new_at (AT_FDCWD, rpmpath, flags, error);
|
||||
if (!unpacker)
|
||||
goto out;
|
||||
|
||||
if (opt_to_ostree_repo)
|
||||
{
|
||||
const char *branch = rpmostree_unpacker_get_ostree_branch (unpacker);
|
||||
g_autofree char *checksum = NULL;
|
||||
/* just use current policy */
|
||||
if (opt_selinux)
|
||||
if (!rpmostree_prepare_rootfs_get_sepolicy (AT_FDCWD, "/", &sepolicy,
|
||||
cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (!rpmostree_unpacker_unpack_to_ostree (unpacker, ostree_repo, NULL,
|
||||
&checksum, cancellable, error))
|
||||
goto out;
|
||||
{
|
||||
const char *branch = rpmostree_unpacker_get_ostree_branch (unpacker);
|
||||
g_autofree char *checksum = NULL;
|
||||
|
||||
g_print ("Imported %s to %s -> %s\n", rpmpath, branch, checksum);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!rpmostree_unpacker_unpack_to_dfd (unpacker, rootfs_fd, cancellable, error))
|
||||
goto out;
|
||||
}
|
||||
if (!rpmostree_unpacker_unpack_to_ostree (unpacker, ostree_repo, sepolicy,
|
||||
&checksum, cancellable, error))
|
||||
goto out;
|
||||
|
||||
g_print ("Imported %s to %s -> %s\n", rpmpath, branch, checksum);
|
||||
}
|
||||
|
||||
exit_status = EXIT_SUCCESS;
|
||||
out:
|
||||
|
@ -1,185 +0,0 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
|
||||
*
|
||||
* Copyright (C) 2011 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
||||
#include <archive.h>
|
||||
#include <gio/gio.h>
|
||||
#include "ostree-libarchive-input-stream.h"
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_ARCHIVE
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (OstreeLibarchiveInputStream, _ostree_libarchive_input_stream, G_TYPE_INPUT_STREAM)
|
||||
|
||||
struct _OstreeLibarchiveInputStreamPrivate {
|
||||
struct archive *archive;
|
||||
};
|
||||
|
||||
static void ostree_libarchive_input_stream_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void ostree_libarchive_input_stream_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static gssize ostree_libarchive_input_stream_read (GInputStream *stream,
|
||||
void *buffer,
|
||||
gsize count,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
static gboolean ostree_libarchive_input_stream_close (GInputStream *stream,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
static void
|
||||
ostree_libarchive_input_stream_finalize (GObject *object)
|
||||
{
|
||||
G_OBJECT_CLASS (_ostree_libarchive_input_stream_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
_ostree_libarchive_input_stream_class_init (OstreeLibarchiveInputStreamClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
GInputStreamClass *stream_class = G_INPUT_STREAM_CLASS (klass);
|
||||
|
||||
g_type_class_add_private (klass, sizeof (OstreeLibarchiveInputStreamPrivate));
|
||||
|
||||
gobject_class->get_property = ostree_libarchive_input_stream_get_property;
|
||||
gobject_class->set_property = ostree_libarchive_input_stream_set_property;
|
||||
gobject_class->finalize = ostree_libarchive_input_stream_finalize;
|
||||
|
||||
stream_class->read_fn = ostree_libarchive_input_stream_read;
|
||||
stream_class->close_fn = ostree_libarchive_input_stream_close;
|
||||
|
||||
/**
|
||||
* OstreeLibarchiveInputStream:archive:
|
||||
*
|
||||
* The archive that the stream reads from.
|
||||
*/
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_ARCHIVE,
|
||||
g_param_spec_pointer ("archive",
|
||||
"", "",
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
ostree_libarchive_input_stream_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
OstreeLibarchiveInputStream *self;
|
||||
|
||||
self = OSTREE_LIBARCHIVE_INPUT_STREAM (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_ARCHIVE:
|
||||
self->priv->archive = g_value_get_pointer (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
ostree_libarchive_input_stream_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
OstreeLibarchiveInputStream *self;
|
||||
|
||||
self = OSTREE_LIBARCHIVE_INPUT_STREAM (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_ARCHIVE:
|
||||
g_value_set_pointer (value, self->priv->archive);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_ostree_libarchive_input_stream_init (OstreeLibarchiveInputStream *self)
|
||||
{
|
||||
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
|
||||
OSTREE_TYPE_LIBARCHIVE_INPUT_STREAM,
|
||||
OstreeLibarchiveInputStreamPrivate);
|
||||
|
||||
}
|
||||
|
||||
GInputStream *
|
||||
_ostree_libarchive_input_stream_new (struct archive *a)
|
||||
{
|
||||
OstreeLibarchiveInputStream *stream;
|
||||
|
||||
stream = g_object_new (OSTREE_TYPE_LIBARCHIVE_INPUT_STREAM,
|
||||
"archive", a,
|
||||
NULL);
|
||||
|
||||
return G_INPUT_STREAM (stream);
|
||||
}
|
||||
|
||||
static gssize
|
||||
ostree_libarchive_input_stream_read (GInputStream *stream,
|
||||
void *buffer,
|
||||
gsize count,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
OstreeLibarchiveInputStream *self;
|
||||
gssize res = -1;
|
||||
|
||||
self = OSTREE_LIBARCHIVE_INPUT_STREAM (stream);
|
||||
|
||||
if (g_cancellable_set_error_if_cancelled (cancellable, error))
|
||||
return -1;
|
||||
|
||||
res = archive_read_data (self->priv->archive, buffer, count);
|
||||
if (res < 0)
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
"%s", archive_error_string (self->priv->archive));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
ostree_libarchive_input_stream_close (GInputStream *stream,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
@ -1,65 +0,0 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
|
||||
*
|
||||
* Copyright (C) 2011 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Author: Alexander Larsson <alexl@redhat.com>
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <gio/gio.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define OSTREE_TYPE_LIBARCHIVE_INPUT_STREAM (_ostree_libarchive_input_stream_get_type ())
|
||||
#define OSTREE_LIBARCHIVE_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), OSTREE_TYPE_LIBARCHIVE_INPUT_STREAM, OstreeLibarchiveInputStream))
|
||||
#define OSTREE_LIBARCHIVE_INPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), OSTREE_TYPE_LIBARCHIVE_INPUT_STREAM, OstreeLibarchiveInputStreamClass))
|
||||
#define OSTREE_IS_LIBARCHIVE_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), OSTREE_TYPE_LIBARCHIVE_INPUT_STREAM))
|
||||
#define OSTREE_IS_LIBARCHIVE_INPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), OSTREE_TYPE_LIBARCHIVE_INPUT_STREAM))
|
||||
#define OSTREE_LIBARCHIVE_INPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), OSTREE_TYPE_LIBARCHIVE_INPUT_STREAM, OstreeLibarchiveInputStreamClass))
|
||||
|
||||
typedef struct _OstreeLibarchiveInputStream OstreeLibarchiveInputStream;
|
||||
typedef struct _OstreeLibarchiveInputStreamClass OstreeLibarchiveInputStreamClass;
|
||||
typedef struct _OstreeLibarchiveInputStreamPrivate OstreeLibarchiveInputStreamPrivate;
|
||||
|
||||
struct _OstreeLibarchiveInputStream
|
||||
{
|
||||
GInputStream parent_instance;
|
||||
|
||||
/*< private >*/
|
||||
OstreeLibarchiveInputStreamPrivate *priv;
|
||||
};
|
||||
|
||||
struct _OstreeLibarchiveInputStreamClass
|
||||
{
|
||||
GInputStreamClass parent_class;
|
||||
|
||||
/*< private >*/
|
||||
/* Padding for future expansion */
|
||||
void (*_g_reserved1) (void);
|
||||
void (*_g_reserved2) (void);
|
||||
void (*_g_reserved3) (void);
|
||||
void (*_g_reserved4) (void);
|
||||
void (*_g_reserved5) (void);
|
||||
};
|
||||
|
||||
GType _ostree_libarchive_input_stream_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GInputStream * _ostree_libarchive_input_stream_new (struct archive *a);
|
||||
|
||||
G_END_DECLS
|
@ -1,180 +0,0 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
|
||||
*
|
||||
* Copyright (C) 2015 Red Hat, Inc.
|
||||
*
|
||||
* Licensed under the GNU Lesser General Public License Version 2.1
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements unpacking an RPM. The design here is to reuse
|
||||
* libarchive's RPM support for most of it. We do however need to
|
||||
* look at file capabilities, which are part of the header.
|
||||
*
|
||||
* Hence we end up with two file descriptors open.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "rpmostree-ostree-libarchive-copynpaste.h"
|
||||
#include "ostree-libarchive-input-stream.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
gboolean
|
||||
rpmostree_split_path_ptrarray_validate (const char *path,
|
||||
GPtrArray **out_components,
|
||||
GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
g_autoptr(GPtrArray) ret_components = NULL;
|
||||
|
||||
if (strlen (path) > PATH_MAX)
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
"Path '%s' is too long", path);
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret_components = g_ptr_array_new_with_free_func (g_free);
|
||||
|
||||
do
|
||||
{
|
||||
const char *p = strchr (path, '/');
|
||||
g_autofree char *component = NULL;
|
||||
|
||||
if (!p)
|
||||
{
|
||||
component = g_strdup (path);
|
||||
path = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
component = g_strndup (path, p - path);
|
||||
path = p + 1;
|
||||
}
|
||||
|
||||
if (!component[0])
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
"Invalid empty component in path '%s'", path);
|
||||
goto out;
|
||||
}
|
||||
if (g_str_equal (component, ".") ||
|
||||
g_str_equal (component, ".."))
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
"Invalid special element '.' or '..' in path %s", path);
|
||||
goto out;
|
||||
}
|
||||
|
||||
g_ptr_array_add (ret_components, (char*)g_steal_pointer (&component));
|
||||
} while (path && *path);
|
||||
|
||||
ret = TRUE;
|
||||
*out_components = g_steal_pointer (&ret_components);
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static GFileType
|
||||
gfile_type_for_mode (guint32 mode)
|
||||
{
|
||||
if (S_ISDIR (mode))
|
||||
return G_FILE_TYPE_DIRECTORY;
|
||||
else if (S_ISREG (mode))
|
||||
return G_FILE_TYPE_REGULAR;
|
||||
else if (S_ISLNK (mode))
|
||||
return G_FILE_TYPE_SYMBOLIC_LINK;
|
||||
else if (S_ISBLK (mode) || S_ISCHR(mode) || S_ISFIFO(mode))
|
||||
return G_FILE_TYPE_SPECIAL;
|
||||
else
|
||||
return G_FILE_TYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
static GFileInfo *
|
||||
_ostree_header_gfile_info_new (mode_t mode, uid_t uid, gid_t gid)
|
||||
{
|
||||
GFileInfo *ret = g_file_info_new ();
|
||||
g_file_info_set_attribute_uint32 (ret, "standard::type", gfile_type_for_mode (mode));
|
||||
g_file_info_set_attribute_boolean (ret, "standard::is-symlink", S_ISLNK (mode));
|
||||
g_file_info_set_attribute_uint32 (ret, "unix::uid", uid);
|
||||
g_file_info_set_attribute_uint32 (ret, "unix::gid", gid);
|
||||
g_file_info_set_attribute_uint32 (ret, "unix::mode", mode);
|
||||
return ret;
|
||||
}
|
||||
|
||||
GFileInfo *
|
||||
_rpmostree_libarchive_to_file_info (struct archive_entry *entry)
|
||||
{
|
||||
g_autoptr(GFileInfo) ret = NULL;
|
||||
struct stat st;
|
||||
|
||||
st = *archive_entry_stat (entry);
|
||||
|
||||
if (S_ISDIR (st.st_mode))
|
||||
{
|
||||
/* Always ensure we can write and execute directories...since
|
||||
* this content should ultimately be read-only entirely, we're
|
||||
* just breaking things by dropping write permissions during
|
||||
* builds.
|
||||
*/
|
||||
st.st_mode |= 0700;
|
||||
}
|
||||
|
||||
ret = _ostree_header_gfile_info_new (st.st_mode, st.st_uid, st.st_gid);
|
||||
|
||||
if (S_ISREG (st.st_mode))
|
||||
g_file_info_set_attribute_uint64 (ret, "standard::size", st.st_size);
|
||||
if (S_ISLNK (st.st_mode))
|
||||
g_file_info_set_attribute_byte_string (ret, "standard::symlink-target", archive_entry_symlink (entry));
|
||||
|
||||
return g_steal_pointer (&ret);
|
||||
}
|
||||
|
||||
gboolean
|
||||
_rpmostree_import_libarchive_entry_file (OstreeRepo *repo,
|
||||
struct archive *a,
|
||||
struct archive_entry *entry,
|
||||
GFileInfo *file_info,
|
||||
GVariant *xattrs,
|
||||
guchar **out_csum,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
g_autoptr(GInputStream) file_object_input = NULL;
|
||||
g_autoptr(GInputStream) archive_stream = NULL;
|
||||
guint64 length;
|
||||
|
||||
if (g_cancellable_set_error_if_cancelled (cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
if (g_file_info_get_file_type (file_info) == G_FILE_TYPE_REGULAR)
|
||||
archive_stream = _ostree_libarchive_input_stream_new (a);
|
||||
|
||||
if (!ostree_raw_file_to_content_stream (archive_stream, file_info, xattrs,
|
||||
&file_object_input, &length, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (!ostree_repo_write_content (repo, NULL, file_object_input, length, out_csum,
|
||||
cancellable, error))
|
||||
goto out;
|
||||
|
||||
ret = TRUE;
|
||||
out:
|
||||
return ret;
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
/* -*- 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.h>
|
||||
#include <archive.h>
|
||||
#include <archive_entry.h>
|
||||
|
||||
#include "libglnx.h"
|
||||
|
||||
gboolean
|
||||
rpmostree_split_path_ptrarray_validate (const char *path,
|
||||
GPtrArray **out_components,
|
||||
GError **error);
|
||||
|
||||
GFileInfo *_rpmostree_libarchive_to_file_info (struct archive_entry *entry);
|
||||
|
||||
gboolean
|
||||
_rpmostree_import_libarchive_entry_file (OstreeRepo *repo,
|
||||
struct archive *a,
|
||||
struct archive_entry *entry,
|
||||
GFileInfo *file_info,
|
||||
GVariant *xattrs,
|
||||
guchar **out_csum,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
File diff suppressed because it is too large
Load Diff
@ -33,20 +33,24 @@ typedef struct RpmOstreeUnpacker RpmOstreeUnpacker;
|
||||
|
||||
GType rpmostree_unpacker_get_type (void);
|
||||
|
||||
/**
|
||||
* RpmOstreeUnpackerFlags:
|
||||
* @RPMOSTREE_UNPACKER_FLAGS_OSTREE_CONVENTION: Move files to follow ostree convention
|
||||
*/
|
||||
typedef enum {
|
||||
RPMOSTREE_UNPACKER_FLAGS_SUID_FSCAPS = (1 << 0),
|
||||
RPMOSTREE_UNPACKER_FLAGS_OWNER = (1 << 1)
|
||||
RPMOSTREE_UNPACKER_FLAGS_OSTREE_CONVENTION = (1 << 0)
|
||||
} RpmOstreeUnpackerFlags;
|
||||
#define RPMOSTREE_UNPACKER_FLAGS_ALL (RPMOSTREE_UNPACKER_FLAGS_SUID_FSCAPS | RPMOSTREE_UNPACKER_FLAGS_OWNER)
|
||||
|
||||
RpmOstreeUnpacker *rpmostree_unpacker_new_fd (int fd, RpmOstreeUnpackerFlags flags, GError **error);
|
||||
RpmOstreeUnpacker*
|
||||
rpmostree_unpacker_new_fd (int fd,
|
||||
RpmOstreeUnpackerFlags flags,
|
||||
GError **error);
|
||||
|
||||
RpmOstreeUnpacker *rpmostree_unpacker_new_at (int dfd, const char *path, RpmOstreeUnpackerFlags flags, GError **error);
|
||||
|
||||
gboolean rpmostree_unpacker_unpack_to_dfd (RpmOstreeUnpacker *unpacker,
|
||||
int dfd,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
RpmOstreeUnpacker*
|
||||
rpmostree_unpacker_new_at (int dfd,
|
||||
const char *path,
|
||||
RpmOstreeUnpackerFlags flags,
|
||||
GError **error);
|
||||
|
||||
gboolean
|
||||
rpmostree_unpacker_read_metainfo (int fd,
|
||||
@ -55,11 +59,13 @@ rpmostree_unpacker_read_metainfo (int fd,
|
||||
rpmfi *out_fi,
|
||||
GError **error);
|
||||
|
||||
const char *rpmostree_unpacker_get_ostree_branch (RpmOstreeUnpacker *unpacker);
|
||||
const char*
|
||||
rpmostree_unpacker_get_ostree_branch (RpmOstreeUnpacker *unpacker);
|
||||
|
||||
gboolean rpmostree_unpacker_unpack_to_ostree (RpmOstreeUnpacker *unpacker,
|
||||
OstreeRepo *repo,
|
||||
OstreeSePolicy *sepolicy,
|
||||
char **out_commit,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
gboolean
|
||||
rpmostree_unpacker_unpack_to_ostree (RpmOstreeUnpacker *unpacker,
|
||||
OstreeRepo *repo,
|
||||
OstreeSePolicy *sepolicy,
|
||||
char **out_commit,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
Loading…
Reference in New Issue
Block a user