core: Switch to using mkdtemp() so we only depend on GLib 2.28
We claim to build against 2.28, let's actually make it work.
This commit is contained in:
parent
f438d9aaa6
commit
cbd4ade053
|
|
@ -25,5 +25,5 @@ ostadmin_SOURCES = src/ostadmin/main.c \
|
||||||
src/ostadmin/ot-admin-main.c \
|
src/ostadmin/ot-admin-main.c \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
ostadmin_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/src/libotutil -I$(srcdir)/src/ostadmin -DLOCALEDIR=\"$(datadir)/locale\" $(OT_DEP_GIO_UNIX_CFLAGS)
|
ostadmin_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/src/libotutil -I$(srcdir)/src/libostree -I$(srcdir)/src/ostadmin -DLOCALEDIR=\"$(datadir)/locale\" $(OT_DEP_GIO_UNIX_CFLAGS)
|
||||||
ostadmin_LDADD = libotutil.la $(OT_DEP_GIO_UNIX_LIBS)
|
ostadmin_LDADD = libotutil.la libostree.la $(OT_DEP_GIO_UNIX_LIBS)
|
||||||
|
|
|
||||||
|
|
@ -20,12 +20,17 @@
|
||||||
* Author: Colin Walters <walters@verbum.org>
|
* Author: Colin Walters <walters@verbum.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* for mkdtemp */
|
||||||
|
#define _GNU_SOURCE
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "ostree.h"
|
#include "ostree.h"
|
||||||
#include "otutil.h"
|
#include "otutil.h"
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <attr/xattr.h>
|
#include <attr/xattr.h>
|
||||||
|
|
||||||
#define ALIGN_VALUE(this, boundary) \
|
#define ALIGN_VALUE(this, boundary) \
|
||||||
|
|
@ -1303,6 +1308,40 @@ ostree_create_temp_regular_file (GFile *dir,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
ostree_create_temp_dir (GFile *dir,
|
||||||
|
const char *prefix,
|
||||||
|
const char *suffix,
|
||||||
|
GFile **out_file,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
gboolean ret = FALSE;
|
||||||
|
ot_lfree char *template = NULL;
|
||||||
|
ot_lobj GFile *ret_file = NULL;
|
||||||
|
|
||||||
|
if (dir == NULL)
|
||||||
|
dir = g_file_new_for_path (g_get_tmp_dir ());
|
||||||
|
|
||||||
|
template = g_strdup_printf ("%s/%s-XXXXXX-%s",
|
||||||
|
ot_gfile_get_path_cached (dir),
|
||||||
|
prefix ? prefix : "tmp",
|
||||||
|
suffix ? suffix : "tmp");
|
||||||
|
|
||||||
|
if (mkdtemp (template) == NULL)
|
||||||
|
{
|
||||||
|
ot_util_set_error_from_errno (error, errno);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret_file = g_file_new_for_path (template);
|
||||||
|
|
||||||
|
ret = TRUE;
|
||||||
|
ot_transfer_out_value (out_file, &ret_file);
|
||||||
|
out:
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
ostree_read_pack_entry_raw (guchar *pack_data,
|
ostree_read_pack_entry_raw (guchar *pack_data,
|
||||||
guint64 pack_len,
|
guint64 pack_len,
|
||||||
|
|
|
||||||
|
|
@ -297,6 +297,13 @@ gboolean ostree_create_temp_regular_file (GFile *dir,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
|
gboolean ostree_create_temp_dir (GFile *dir,
|
||||||
|
const char *prefix,
|
||||||
|
const char *suffix,
|
||||||
|
GFile **out_file,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
gboolean ostree_read_pack_entry_raw (guchar *pack_data,
|
gboolean ostree_read_pack_entry_raw (guchar *pack_data,
|
||||||
guint64 pack_len,
|
guint64 pack_len,
|
||||||
guint64 object_offset,
|
guint64 object_offset,
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "ot-admin-builtins.h"
|
#include "ot-admin-builtins.h"
|
||||||
#include "otutil.h"
|
#include "ostree.h"
|
||||||
|
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
|
|
@ -74,12 +74,14 @@ update_initramfs (const char *release,
|
||||||
if (!g_file_query_exists (initramfs_file, NULL))
|
if (!g_file_query_exists (initramfs_file, NULL))
|
||||||
{
|
{
|
||||||
ot_lptrarray GPtrArray *mkinitramfs_args = NULL;
|
ot_lptrarray GPtrArray *mkinitramfs_args = NULL;
|
||||||
ot_lfree char *tmpdir = NULL;
|
ot_lobj GFile *tmpdir = NULL;
|
||||||
ot_lfree char *initramfs_tmp_path = NULL;
|
ot_lfree char *initramfs_tmp_path = NULL;
|
||||||
ot_lobj GFile *initramfs_tmp_file = NULL;
|
ot_lobj GFile *initramfs_tmp_file = NULL;
|
||||||
ot_lobj GFileInfo *initramfs_tmp_info = NULL;
|
ot_lobj GFileInfo *initramfs_tmp_info = NULL;
|
||||||
|
|
||||||
if ((tmpdir = g_dir_make_tmp ("ostree-initramfs.XXXXXX", error)) == NULL)
|
|
||||||
|
if (!ostree_create_temp_dir (NULL, "ostree-initramfs", NULL, &tmpdir,
|
||||||
|
cancellable, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
last_deploy_path = g_build_filename ("/ostree", last_deploy_target, NULL);
|
last_deploy_path = g_build_filename ("/ostree", last_deploy_target, NULL);
|
||||||
|
|
@ -95,7 +97,7 @@ update_initramfs (const char *release,
|
||||||
"--mount-proc", "/proc",
|
"--mount-proc", "/proc",
|
||||||
"--mount-bind", "/dev", "/dev",
|
"--mount-bind", "/dev", "/dev",
|
||||||
"--mount-bind", "/ostree/var", "/var",
|
"--mount-bind", "/ostree/var", "/var",
|
||||||
"--mount-bind", tmpdir, "/tmp",
|
"--mount-bind", ot_gfile_get_path_cached (tmpdir), "/tmp",
|
||||||
"--mount-bind", "/ostree/modules", "/lib/modules",
|
"--mount-bind", "/ostree/modules", "/lib/modules",
|
||||||
last_deploy_path,
|
last_deploy_path,
|
||||||
"dracut", "-f", "/tmp/initramfs-ostree.img", release,
|
"dracut", "-f", "/tmp/initramfs-ostree.img", release,
|
||||||
|
|
@ -106,13 +108,9 @@ update_initramfs (const char *release,
|
||||||
if (!ot_spawn_sync_checked (NULL, (char**)mkinitramfs_args->pdata, NULL,
|
if (!ot_spawn_sync_checked (NULL, (char**)mkinitramfs_args->pdata, NULL,
|
||||||
G_SPAWN_SEARCH_PATH,
|
G_SPAWN_SEARCH_PATH,
|
||||||
NULL, NULL, NULL, NULL, error))
|
NULL, NULL, NULL, NULL, error))
|
||||||
{
|
goto out;
|
||||||
(void) unlink (initramfs_tmp_path);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
initramfs_tmp_path = g_build_filename (tmpdir, "initramfs-ostree.img", NULL);
|
initramfs_tmp_file = g_file_get_child (tmpdir, "initramfs-ostree.img");
|
||||||
initramfs_tmp_file = g_file_new_for_path (initramfs_tmp_path);
|
|
||||||
initramfs_tmp_info = g_file_query_info (initramfs_tmp_file, OSTREE_GIO_FAST_QUERYINFO,
|
initramfs_tmp_info = g_file_query_info (initramfs_tmp_file, OSTREE_GIO_FAST_QUERYINFO,
|
||||||
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
|
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
|
||||||
cancellable, error);
|
cancellable, error);
|
||||||
|
|
@ -131,8 +129,8 @@ update_initramfs (const char *release,
|
||||||
|
|
||||||
g_print ("Created: %s\n", ot_gfile_get_path_cached (initramfs_file));
|
g_print ("Created: %s\n", ot_gfile_get_path_cached (initramfs_file));
|
||||||
|
|
||||||
(void) unlink (initramfs_tmp_path);
|
(void) ot_gfile_unlink (initramfs_tmp_file, NULL, NULL);
|
||||||
(void) rmdir (tmpdir);
|
(void) rmdir (ot_gfile_get_path_cached (tmpdir));
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue