-
Simon McVittie authored
This will let us duplicate a runtime and edit it in-place. The major appeal of doing this is that it's something we can do in a Flatpak environment, where recursively invoking bubblewrap isn't allowed. It also seems like it might yield a more reliable way to overwrite parts of the runtime with their host-system equivalents than the tricks we currently use with files and directories mounted over their runtime counterparts. The major down side is that after we've done this, we have a copy of the runtime, which we need to garbage-collect and clean up eventually. Signed-off-by:
Simon McVittie <smcv@collabora.com>
Simon McVittie authoredThis will let us duplicate a runtime and edit it in-place. The major appeal of doing this is that it's something we can do in a Flatpak environment, where recursively invoking bubblewrap isn't allowed. It also seems like it might yield a more reliable way to overwrite parts of the runtime with their host-system equivalents than the tricks we currently use with files and directories mounted over their runtime counterparts. The major down side is that after we've done this, we have a copy of the runtime, which we need to garbage-collect and clean up eventually. Signed-off-by:
Simon McVittie <smcv@collabora.com>
cheap-copy.c 1.77 KiB
/*
* Copyright © 2020 Collabora Ltd.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*
* 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.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, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "subprojects/libglnx/config.h"
#include <locale.h>
#include <sysexits.h>
#include "libglnx/libglnx.h"
#include "glib-backports.h"
#include "utils.h"
static GOptionEntry options[] =
{
{ NULL }
};
int
main (int argc,
char *argv[])
{
g_autoptr(GOptionContext) context = NULL;
g_autoptr(GError) local_error = NULL;
GError **error = &local_error;
int ret = EX_USAGE;
setlocale (LC_ALL, "");
pv_avoid_gvfs ();
context = g_option_context_new ("SOURCE DEST");
g_option_context_add_main_entries (context, options, NULL);
if (!g_option_context_parse (context, &argc, &argv, error))
goto out;
if (argc >= 2 && strcmp (argv[1], "--") == 0)
{
argv++;
argc--;
}
if (argc != 3)
{
g_printerr ("Usage: %s SOURCE DEST\n", g_get_prgname ());
goto out;
}
ret = EX_UNAVAILABLE;
if (!pv_cheap_tree_copy (argv[1], argv[2], error))
goto out;
ret = 0;
out:
if (local_error != NULL)
g_warning ("%s", local_error->message);
return ret;
}