mirror of
https://github.com/ostreedev/ostree.git
synced 2024-10-26 17:25:36 +03:00
core: Remove old "archive" mode
We'll always have "bare" mode for keeping files-as-hardlinks as root. But "archive" was my second attempt at a format for non-root file storage, used by the gnome-ostree buildsystem which runs as non-root. It was really handy to have a "tar" like mode where I can create tarballs as a user, that contain files owned by root for example. The "archive" mode stored content files as two pieces in the filesystem; ".file" contained metadata, and ".filecontent" was the actual content, uncompressed. The nice thing about this was that to check out a tree as non-root, you could just hardlink into the repo. However, archive was fairly bad for serving via HTTP; it required *two* HTTP requests per content object, greatly magnifing the already inefficient fetch process. So "archive-z2" was introduced. To allow gnome-ostree to still check out trees as a user, the "uncompressed-object-cache" was introduced, and that's how things have been working for a while. So we should just be able to kill this code. Specifically note just how much better the stage_object() function became. https://bugzilla.gnome.org/show_bug.cgi?id=706057
This commit is contained in:
parent
17560a57bf
commit
1ec7c30408
@ -21,7 +21,6 @@
|
||||
if BUILDOPT_INSTALL_TESTS
|
||||
insttestdir=$(pkglibexecdir)/installed-tests
|
||||
testfiles = test-basic \
|
||||
test-archive \
|
||||
test-archivez \
|
||||
test-remote-add \
|
||||
test-corruption \
|
||||
|
@ -188,9 +188,6 @@ find_loose_for_checkout (OstreeRepo *self,
|
||||
case OSTREE_REPO_MODE_BARE:
|
||||
path = _ostree_repo_get_object_path (self, checksum, OSTREE_OBJECT_TYPE_FILE);
|
||||
break;
|
||||
case OSTREE_REPO_MODE_ARCHIVE:
|
||||
path = _ostree_repo_get_archive_content_path (self, checksum);
|
||||
break;
|
||||
case OSTREE_REPO_MODE_ARCHIVE_Z2:
|
||||
{
|
||||
if (self->enable_uncompressed_cache)
|
||||
@ -299,7 +296,6 @@ checkout_file_thread (GSimpleAsyncResult *result,
|
||||
/* We can only do hardlinks in these scenarios */
|
||||
if (!is_symlink &&
|
||||
((checkout_data->repo->mode == OSTREE_REPO_MODE_BARE && checkout_data->mode == OSTREE_REPO_CHECKOUT_MODE_NONE)
|
||||
|| (checkout_data->repo->mode == OSTREE_REPO_MODE_ARCHIVE && checkout_data->mode == OSTREE_REPO_CHECKOUT_MODE_USER)
|
||||
|| (checkout_data->repo->mode == OSTREE_REPO_MODE_ARCHIVE_Z2 && checkout_data->mode == OSTREE_REPO_CHECKOUT_MODE_USER)))
|
||||
{
|
||||
if (!find_loose_for_checkout (checkout_data->repo, checksum, &loose_path,
|
||||
|
@ -646,8 +646,7 @@ ostree_repo_write_ref (OstreeRepo *self,
|
||||
|
||||
if (rev != NULL)
|
||||
{
|
||||
if (self->mode == OSTREE_REPO_MODE_ARCHIVE
|
||||
|| self->mode == OSTREE_REPO_MODE_ARCHIVE_Z2)
|
||||
if (self->mode == OSTREE_REPO_MODE_ARCHIVE_Z2)
|
||||
{
|
||||
if (!write_ref_summary (self, NULL, error))
|
||||
goto out;
|
||||
|
@ -270,8 +270,6 @@ ostree_repo_mode_from_string (const char *mode,
|
||||
|
||||
if (strcmp (mode, "bare") == 0)
|
||||
ret_mode = OSTREE_REPO_MODE_BARE;
|
||||
else if (strcmp (mode, "archive") == 0)
|
||||
ret_mode = OSTREE_REPO_MODE_ARCHIVE;
|
||||
else if (strcmp (mode, "archive-z2") == 0)
|
||||
ret_mode = OSTREE_REPO_MODE_ARCHIVE_Z2;
|
||||
else
|
||||
@ -333,19 +331,19 @@ ostree_repo_check (OstreeRepo *self, GError **error)
|
||||
if (!ot_keyfile_get_boolean_with_default (self->config, "core", "archive",
|
||||
FALSE, &is_archive, error))
|
||||
goto out;
|
||||
|
||||
if (is_archive)
|
||||
self->mode = OSTREE_REPO_MODE_ARCHIVE;
|
||||
else
|
||||
{
|
||||
if (!ot_keyfile_get_value_with_default (self->config, "core", "mode",
|
||||
"bare", &mode, error))
|
||||
goto out;
|
||||
|
||||
if (!ostree_repo_mode_from_string (mode, &self->mode, error))
|
||||
goto out;
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
"This version of OSTree no longer supports \"archive\" repositories; use archive-z2 instead");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!ot_keyfile_get_value_with_default (self->config, "core", "mode",
|
||||
"bare", &mode, error))
|
||||
goto out;
|
||||
if (!ostree_repo_mode_from_string (mode, &self->mode, error))
|
||||
goto out;
|
||||
|
||||
if (!ot_keyfile_get_value_with_default (self->config, "core", "parent",
|
||||
NULL, &parent_repo_path, error))
|
||||
goto out;
|
||||
@ -417,18 +415,6 @@ _ostree_repo_get_file_object_path (OstreeRepo *self,
|
||||
return _ostree_repo_get_object_path (self, checksum, OSTREE_OBJECT_TYPE_FILE);
|
||||
}
|
||||
|
||||
GFile *
|
||||
_ostree_repo_get_archive_content_path (OstreeRepo *self,
|
||||
const char *checksum)
|
||||
{
|
||||
gs_free char *path = NULL;
|
||||
|
||||
g_assert (ostree_repo_get_mode (self) == OSTREE_REPO_MODE_ARCHIVE);
|
||||
|
||||
path = ostree_get_relative_archive_content_path (checksum);
|
||||
return g_file_resolve_relative_path (self->repodir, path);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
commit_loose_object_impl (OstreeRepo *self,
|
||||
GFile *tempfile_path,
|
||||
@ -514,8 +500,6 @@ stage_object (OstreeRepo *self,
|
||||
gs_unref_object OstreeChecksumInputStream *checksum_input = NULL;
|
||||
gboolean have_obj;
|
||||
GChecksum *checksum = NULL;
|
||||
gboolean staged_raw_file = FALSE;
|
||||
gboolean staged_archive_file = FALSE;
|
||||
gboolean temp_file_is_regular;
|
||||
|
||||
g_return_val_if_fail (self->in_transaction, FALSE);
|
||||
@ -563,7 +547,6 @@ stage_object (OstreeRepo *self,
|
||||
&temp_file,
|
||||
cancellable, error))
|
||||
goto out;
|
||||
staged_raw_file = TRUE;
|
||||
}
|
||||
else if (repo_mode == OSTREE_REPO_MODE_ARCHIVE_Z2)
|
||||
{
|
||||
@ -598,58 +581,6 @@ stage_object (OstreeRepo *self,
|
||||
if (!g_output_stream_close (temp_out, cancellable, error))
|
||||
goto out;
|
||||
}
|
||||
else if (repo_mode == OSTREE_REPO_MODE_ARCHIVE)
|
||||
{
|
||||
gs_unref_variant GVariant *file_meta = NULL;
|
||||
gs_unref_object GInputStream *file_meta_input = NULL;
|
||||
gs_unref_object GFileInfo *archive_content_file_info = NULL;
|
||||
|
||||
file_meta = ostree_file_header_new (file_info, xattrs);
|
||||
file_meta_input = ot_variant_read (file_meta);
|
||||
|
||||
if (!ostree_create_temp_file_from_input (self->tmp_dir,
|
||||
ostree_object_type_to_string (objtype), NULL,
|
||||
NULL, NULL, file_meta_input,
|
||||
&temp_file,
|
||||
cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (g_file_info_get_file_type (file_info) == G_FILE_TYPE_REGULAR)
|
||||
{
|
||||
gs_unref_object GOutputStream *content_out = NULL;
|
||||
guint32 src_mode;
|
||||
guint32 target_mode;
|
||||
|
||||
if (!gs_file_open_in_tmpdir (self->tmp_dir, 0644,
|
||||
&raw_temp_file, &content_out,
|
||||
cancellable, error))
|
||||
goto out;
|
||||
|
||||
/* Don't make setuid files in the repository; all we want to preserve
|
||||
* is file type and permissions.
|
||||
*/
|
||||
src_mode = g_file_info_get_attribute_uint32 (file_info, "unix::mode");
|
||||
target_mode = src_mode & (S_IRWXU | S_IRWXG | S_IRWXO | S_IFMT);
|
||||
/* However, do ensure that archive mode files are
|
||||
* readable by all users. This is important for serving
|
||||
* files via HTTP.
|
||||
*/
|
||||
target_mode |= (S_IRUSR | S_IRGRP | S_IROTH);
|
||||
|
||||
if (chmod (gs_file_get_path_cached (raw_temp_file), target_mode) < 0)
|
||||
{
|
||||
ot_util_set_error_from_errno (error, errno);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (g_output_stream_splice (content_out, file_input,
|
||||
G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE | G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET,
|
||||
cancellable, error) < 0)
|
||||
goto out;
|
||||
|
||||
staged_archive_file = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
@ -688,53 +619,10 @@ stage_object (OstreeRepo *self,
|
||||
|
||||
if (do_commit)
|
||||
{
|
||||
/* Only do this if we *didn't* stage a bare file above */
|
||||
if (!staged_raw_file
|
||||
&& objtype == OSTREE_OBJECT_TYPE_FILE && self->mode == OSTREE_REPO_MODE_BARE)
|
||||
{
|
||||
gs_unref_object GInputStream *file_input = NULL;
|
||||
gs_unref_object GFileInfo *file_info = NULL;
|
||||
gs_unref_variant GVariant *xattrs = NULL;
|
||||
gboolean is_regular;
|
||||
|
||||
if (!ostree_content_file_parse (FALSE, temp_file, FALSE, &file_input,
|
||||
&file_info, &xattrs,
|
||||
cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (!ostree_create_temp_file_from_input (self->tmp_dir,
|
||||
ostree_object_type_to_string (objtype), NULL,
|
||||
file_info, xattrs, file_input,
|
||||
&raw_temp_file,
|
||||
cancellable, error))
|
||||
goto out;
|
||||
|
||||
is_regular = g_file_info_get_file_type (file_info) == G_FILE_TYPE_REGULAR;
|
||||
|
||||
if (!commit_loose_object_trusted (self, actual_checksum, objtype,
|
||||
raw_temp_file, is_regular, cancellable, error))
|
||||
goto out;
|
||||
g_clear_object (&raw_temp_file);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Commit content first so the process is atomic */
|
||||
if (staged_archive_file)
|
||||
{
|
||||
gs_unref_object GFile *archive_content_dest = NULL;
|
||||
|
||||
archive_content_dest = _ostree_repo_get_archive_content_path (self, actual_checksum);
|
||||
|
||||
if (!commit_loose_object_impl (self, raw_temp_file, archive_content_dest, TRUE,
|
||||
cancellable, error))
|
||||
goto out;
|
||||
g_clear_object (&raw_temp_file);
|
||||
}
|
||||
if (!commit_loose_object_trusted (self, actual_checksum, objtype, temp_file, temp_file_is_regular,
|
||||
cancellable, error))
|
||||
goto out;
|
||||
g_clear_object (&temp_file);
|
||||
}
|
||||
if (!commit_loose_object_trusted (self, actual_checksum, objtype, temp_file, temp_file_is_regular,
|
||||
cancellable, error))
|
||||
goto out;
|
||||
g_clear_object (&temp_file);
|
||||
}
|
||||
|
||||
g_mutex_lock (&self->txn_stats_lock);
|
||||
@ -938,9 +826,6 @@ scan_loose_devino (OstreeRepo *self,
|
||||
|
||||
switch (repo_mode)
|
||||
{
|
||||
case OSTREE_REPO_MODE_ARCHIVE:
|
||||
skip = !g_str_has_suffix (name, ".filecontent");
|
||||
break;
|
||||
case OSTREE_REPO_MODE_ARCHIVE_Z2:
|
||||
case OSTREE_REPO_MODE_BARE:
|
||||
skip = !g_str_has_suffix (name, ".file");
|
||||
@ -2136,40 +2021,6 @@ ostree_repo_load_file (OstreeRepo *self,
|
||||
{
|
||||
switch (repo_mode)
|
||||
{
|
||||
case OSTREE_REPO_MODE_ARCHIVE:
|
||||
{
|
||||
gs_unref_variant GVariant *archive_meta = NULL;
|
||||
|
||||
if (!ot_util_variant_map (loose_path, OSTREE_FILE_HEADER_GVARIANT_FORMAT,
|
||||
TRUE, &archive_meta, error))
|
||||
goto out;
|
||||
|
||||
if (!ostree_file_header_parse (archive_meta, &ret_file_info, &ret_xattrs,
|
||||
error))
|
||||
goto out;
|
||||
|
||||
if (g_file_info_get_file_type (ret_file_info) == G_FILE_TYPE_REGULAR)
|
||||
{
|
||||
gs_unref_object GFile *archive_content_path = NULL;
|
||||
gs_unref_object GFileInfo *content_info = NULL;
|
||||
|
||||
archive_content_path = _ostree_repo_get_archive_content_path (self, checksum);
|
||||
content_info = g_file_query_info (archive_content_path, OSTREE_GIO_FAST_QUERYINFO,
|
||||
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
|
||||
cancellable, error);
|
||||
if (!content_info)
|
||||
goto out;
|
||||
|
||||
if (out_input)
|
||||
{
|
||||
ret_input = (GInputStream*)gs_file_read_noatime (archive_content_path, cancellable, error);
|
||||
if (!ret_input)
|
||||
goto out;
|
||||
}
|
||||
g_file_info_set_size (ret_file_info, g_file_info_get_size (content_info));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case OSTREE_REPO_MODE_ARCHIVE_Z2:
|
||||
{
|
||||
if (!ostree_content_file_parse (TRUE, loose_path, TRUE,
|
||||
|
@ -43,7 +43,6 @@ GFile * ostree_repo_get_path (OstreeRepo *self);
|
||||
|
||||
typedef enum {
|
||||
OSTREE_REPO_MODE_BARE,
|
||||
OSTREE_REPO_MODE_ARCHIVE,
|
||||
OSTREE_REPO_MODE_ARCHIVE_Z2
|
||||
} OstreeRepoMode;
|
||||
|
||||
|
@ -1,29 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# 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.
|
||||
|
||||
set -e
|
||||
|
||||
. $(dirname $0)/libtest.sh
|
||||
|
||||
echo '1..11'
|
||||
|
||||
setup_test_repository "archive"
|
||||
echo "ok setup"
|
||||
|
||||
. ${SRCDIR}/archive-test.sh
|
Loading…
Reference in New Issue
Block a user