libostree: Move prune into OstreeRepo namespace
More library work.
This commit is contained in:
parent
2aa0251b1b
commit
5dd0d5da40
|
|
@ -33,6 +33,7 @@ libostree_la_SOURCES = src/libostree/ostree.h \
|
||||||
src/libostree/ostree-repo.c \
|
src/libostree/ostree-repo.c \
|
||||||
src/libostree/ostree-repo-checkout.c \
|
src/libostree/ostree-repo-checkout.c \
|
||||||
src/libostree/ostree-repo-libarchive.c \
|
src/libostree/ostree-repo-libarchive.c \
|
||||||
|
src/libostree/ostree-repo-prune.c \
|
||||||
src/libostree/ostree-repo-refs.c \
|
src/libostree/ostree-repo-refs.c \
|
||||||
src/libostree/ostree-repo-traverse.c \
|
src/libostree/ostree-repo-traverse.c \
|
||||||
src/libostree/ostree-repo.h \
|
src/libostree/ostree-repo.h \
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,6 @@ bin_PROGRAMS += ostree
|
||||||
ostree_SOURCES = src/ostree/main.c \
|
ostree_SOURCES = src/ostree/main.c \
|
||||||
src/ostree/ostree-curl-fetcher.h \
|
src/ostree/ostree-curl-fetcher.h \
|
||||||
src/ostree/ostree-curl-fetcher.c \
|
src/ostree/ostree-curl-fetcher.c \
|
||||||
src/ostree/ostree-prune.h \
|
|
||||||
src/ostree/ostree-prune.c \
|
|
||||||
src/ostree/ot-builtin-admin.c \
|
src/ostree/ot-builtin-admin.c \
|
||||||
src/ostree/ot-builtins.h \
|
src/ostree/ot-builtins.h \
|
||||||
src/ostree/ot-builtin-cat.c \
|
src/ostree/ot-builtin-cat.c \
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
|
||||||
*
|
*
|
||||||
* Copyright (C) 2011 Colin Walters <walters@verbum.org>
|
* Copyright (C) 2011,2013 Colin Walters <walters@verbum.org>
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "ostree-prune.h"
|
#include "ostree-repo.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
OstreeRepo *repo;
|
OstreeRepo *repo;
|
||||||
|
|
@ -36,7 +36,7 @@ typedef struct {
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
maybe_prune_loose_object (OtPruneData *data,
|
maybe_prune_loose_object (OtPruneData *data,
|
||||||
OstreePruneFlags flags,
|
OstreeRepoPruneFlags flags,
|
||||||
const char *checksum,
|
const char *checksum,
|
||||||
OstreeObjectType objtype,
|
OstreeObjectType objtype,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
|
|
@ -52,7 +52,7 @@ maybe_prune_loose_object (OtPruneData *data,
|
||||||
|
|
||||||
if (!g_hash_table_lookup_extended (data->reachable, key, NULL, NULL))
|
if (!g_hash_table_lookup_extended (data->reachable, key, NULL, NULL))
|
||||||
{
|
{
|
||||||
if (!(flags & OSTREE_PRUNE_FLAGS_NO_PRUNE))
|
if (!(flags & OSTREE_REPO_PRUNE_FLAGS_NO_PRUNE))
|
||||||
{
|
{
|
||||||
gs_unref_object GFileInfo *info = NULL;
|
gs_unref_object GFileInfo *info = NULL;
|
||||||
|
|
||||||
|
|
@ -85,14 +85,14 @@ maybe_prune_loose_object (OtPruneData *data,
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
ostree_prune (OstreeRepo *repo,
|
ostree_repo_prune (OstreeRepo *repo,
|
||||||
OstreePruneFlags flags,
|
OstreeRepoPruneFlags flags,
|
||||||
gint depth,
|
gint depth,
|
||||||
gint *out_objects_total,
|
gint *out_objects_total,
|
||||||
gint *out_objects_pruned,
|
gint *out_objects_pruned,
|
||||||
guint64 *out_pruned_object_size_total,
|
guint64 *out_pruned_object_size_total,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
GHashTableIter hash_iter;
|
GHashTableIter hash_iter;
|
||||||
|
|
@ -101,7 +101,7 @@ ostree_prune (OstreeRepo *repo,
|
||||||
gs_unref_hashtable GHashTable *all_refs = NULL;
|
gs_unref_hashtable GHashTable *all_refs = NULL;
|
||||||
gs_free char *formatted_freed_size = NULL;
|
gs_free char *formatted_freed_size = NULL;
|
||||||
OtPruneData data;
|
OtPruneData data;
|
||||||
gboolean refs_only = flags & OSTREE_PRUNE_FLAGS_REFS_ONLY;
|
gboolean refs_only = flags & OSTREE_REPO_PRUNE_FLAGS_REFS_ONLY;
|
||||||
|
|
||||||
memset (&data, 0, sizeof (data));
|
memset (&data, 0, sizeof (data));
|
||||||
|
|
||||||
|
|
@ -332,6 +332,20 @@ gboolean ostree_repo_traverse_commit (OstreeRepo *repo,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
OSTREE_REPO_PRUNE_FLAGS_NONE,
|
||||||
|
OSTREE_REPO_PRUNE_FLAGS_NO_PRUNE,
|
||||||
|
OSTREE_REPO_PRUNE_FLAGS_REFS_ONLY
|
||||||
|
} OstreeRepoPruneFlags;
|
||||||
|
|
||||||
|
gboolean ostree_repo_prune (OstreeRepo *repo,
|
||||||
|
OstreeRepoPruneFlags flags,
|
||||||
|
gint depth,
|
||||||
|
gint *out_objects_total,
|
||||||
|
gint *out_objects_pruned,
|
||||||
|
guint64 *out_pruned_object_size_total,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,43 +0,0 @@
|
||||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
|
|
||||||
*
|
|
||||||
* Copyright (C) 2013 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"
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
OSTREE_PRUNE_FLAGS_NONE,
|
|
||||||
OSTREE_PRUNE_FLAGS_NO_PRUNE,
|
|
||||||
OSTREE_PRUNE_FLAGS_REFS_ONLY
|
|
||||||
} OstreePruneFlags;
|
|
||||||
|
|
||||||
gboolean ostree_prune (OstreeRepo *repo,
|
|
||||||
OstreePruneFlags flags,
|
|
||||||
gint depth,
|
|
||||||
gint *out_objects_total,
|
|
||||||
gint *out_objects_pruned,
|
|
||||||
guint64 *out_pruned_object_size_total,
|
|
||||||
GCancellable *cancellable,
|
|
||||||
GError **error);
|
|
||||||
|
|
||||||
G_END_DECLS
|
|
||||||
|
|
||||||
|
|
@ -27,8 +27,7 @@
|
||||||
#include "ot-deployment.h"
|
#include "ot-deployment.h"
|
||||||
#include "ot-config-parser.h"
|
#include "ot-config-parser.h"
|
||||||
#include "otutil.h"
|
#include "otutil.h"
|
||||||
#include "ostree-core.h"
|
#include "ostree.h"
|
||||||
#include "ostree-prune.h"
|
|
||||||
#include "libgsystem.h"
|
#include "libgsystem.h"
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
@ -463,9 +462,9 @@ generate_deployment_refs_and_prune (GFile *sysroot,
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ostree_prune (repo, OSTREE_PRUNE_FLAGS_REFS_ONLY, 0,
|
if (!ostree_repo_prune (repo, OSTREE_REPO_PRUNE_FLAGS_REFS_ONLY, 0,
|
||||||
&n_objects_total, &n_objects_pruned, &freed_space,
|
&n_objects_total, &n_objects_pruned, &freed_space,
|
||||||
cancellable, error))
|
cancellable, error))
|
||||||
goto out;
|
goto out;
|
||||||
if (freed_space > 0)
|
if (freed_space > 0)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,7 @@
|
||||||
#include "ot-config-parser.h"
|
#include "ot-config-parser.h"
|
||||||
#include "ot-bootloader-syslinux.h"
|
#include "ot-bootloader-syslinux.h"
|
||||||
#include "otutil.h"
|
#include "otutil.h"
|
||||||
#include "ostree-core.h"
|
#include "ostree.h"
|
||||||
#include "ostree-prune.h"
|
|
||||||
#include "libgsystem.h"
|
#include "libgsystem.h"
|
||||||
|
|
||||||
OtOrderedHash *
|
OtOrderedHash *
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "ot-builtins.h"
|
#include "ot-builtins.h"
|
||||||
#include "ostree-prune.h"
|
#include "ostree.h"
|
||||||
|
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
#include <glib/gprintf.h>
|
#include <glib/gprintf.h>
|
||||||
|
|
@ -47,7 +47,7 @@ ostree_builtin_prune (int argc, char **argv, GFile *repo_path, GError **error)
|
||||||
GCancellable *cancellable = NULL;
|
GCancellable *cancellable = NULL;
|
||||||
gs_unref_object OstreeRepo *repo = NULL;
|
gs_unref_object OstreeRepo *repo = NULL;
|
||||||
gs_free char *formatted_freed_size = NULL;
|
gs_free char *formatted_freed_size = NULL;
|
||||||
OstreePruneFlags pruneflags = 0;
|
OstreeRepoPruneFlags pruneflags = 0;
|
||||||
gint n_objects_total;
|
gint n_objects_total;
|
||||||
gint n_objects_pruned;
|
gint n_objects_pruned;
|
||||||
guint64 objsize_total;
|
guint64 objsize_total;
|
||||||
|
|
@ -63,13 +63,13 @@ ostree_builtin_prune (int argc, char **argv, GFile *repo_path, GError **error)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (opt_refs_only)
|
if (opt_refs_only)
|
||||||
pruneflags |= OSTREE_PRUNE_FLAGS_REFS_ONLY;
|
pruneflags |= OSTREE_REPO_PRUNE_FLAGS_REFS_ONLY;
|
||||||
if (opt_no_prune)
|
if (opt_no_prune)
|
||||||
pruneflags |= OSTREE_PRUNE_FLAGS_NO_PRUNE;
|
pruneflags |= OSTREE_REPO_PRUNE_FLAGS_NO_PRUNE;
|
||||||
|
|
||||||
if (!ostree_prune (repo, pruneflags, opt_depth,
|
if (!ostree_repo_prune (repo, pruneflags, opt_depth,
|
||||||
&n_objects_total, &n_objects_pruned, &objsize_total,
|
&n_objects_total, &n_objects_pruned, &objsize_total,
|
||||||
cancellable, error))
|
cancellable, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
formatted_freed_size = g_format_size_full (objsize_total, 0);
|
formatted_freed_size = g_format_size_full (objsize_total, 0);
|
||||||
|
|
@ -77,7 +77,7 @@ ostree_builtin_prune (int argc, char **argv, GFile *repo_path, GError **error)
|
||||||
g_print ("Total objects: %u\n", n_objects_total);
|
g_print ("Total objects: %u\n", n_objects_total);
|
||||||
if (n_objects_pruned == 0)
|
if (n_objects_pruned == 0)
|
||||||
g_print ("No unreachable objects\n");
|
g_print ("No unreachable objects\n");
|
||||||
else if (pruneflags & OSTREE_PRUNE_FLAGS_NO_PRUNE)
|
else if (pruneflags & OSTREE_REPO_PRUNE_FLAGS_NO_PRUNE)
|
||||||
g_print ("Would delete: %u objects, freeing %s bytes\n",
|
g_print ("Would delete: %u objects, freeing %s bytes\n",
|
||||||
n_objects_pruned, formatted_freed_size);
|
n_objects_pruned, formatted_freed_size);
|
||||||
else
|
else
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue