libarchive: Add support for translating paths during commit
For rpm-ostree, I want to move RPM files in `/boot` to `/usr/lib/ostree-boot`. This is currently impossible without forking the libarchive code. Supporting this is pretty straightforward; we already had pathname translation in the libarchive code, we just need to expose it as an option. On the command line side, I chose to wrap this as a regexp. That should be good enough for a lot of use cases; sophisticated users should as always be making use of the API. Note that this required some new `#ifdef LIBARCHIVE` bits to use the new API. Following previous patterns here, we use the new API only if a relevant option is enabled, ensuring unit test coverage of both paths. For the test cases, I ended up changing the accounting to avoid having to multiply the test count. Closes: #1105 Approved by: jlebon
This commit is contained in:
1 parent
355e8516b0
commit
138c4d7aae
5 files changed
+229
-53
No files matched your search
@@ -22,6 +22,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "ostree-core.h"
|
||||
#include "ostree-types.h"
|
||||
#include "ostree-async-progress.h"
|
||||
@@ -688,6 +690,31 @@ gboolean ostree_repo_write_archive_to_mtree (OstreeRepo *
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
/**
|
||||
* OstreeRepoImportArchiveTranslatePathname:
|
||||
* @repo: Repo
|
||||
* @stbuf: Stat buffer
|
||||
* @src_path: Path in the archive
|
||||
* @user_data: User data
|
||||
*
|
||||
* Possibly change a pathname while importing an archive. If %NULL is returned,
|
||||
* then @src_path will be used unchanged. Otherwise, return a new pathname which
|
||||
* will be freed via `g_free()`.
|
||||
*
|
||||
* This pathname translation will be performed *before* any processing from an
|
||||
* active `OstreeRepoCommitModifier`. Will be invoked for all directory and file
|
||||
* types, first with outer directories, then their sub-files and directories.
|
||||
*
|
||||
* Note that enabling pathname translation will always override the setting for
|
||||
* `use_ostree_convention`.
|
||||
*
|
||||
* Since: 2017.11
|
||||
*/
|
||||
typedef char *(*OstreeRepoImportArchiveTranslatePathname) (OstreeRepo *repo,
|
||||
const struct stat *stbuf,
|
||||
const char *src_path,
|
||||
gpointer user_data);
|
||||
|
||||
/**
|
||||
* OstreeRepoImportArchiveOptions: (skip)
|
||||
*
|
||||
@@ -703,7 +730,9 @@ typedef struct {
|
||||
guint reserved : 28;
|
||||
|
||||
guint unused_uint[8];
|
||||
gpointer unused_ptrs[8];
|
||||
OstreeRepoImportArchiveTranslatePathname translate_pathname;
|
||||
gpointer translate_pathname_user_data;
|
||||
gpointer unused_ptrs[6];
|
||||
} OstreeRepoImportArchiveOptions;
|
||||
|
||||
_OSTREE_PUBLIC
|
||||
|
||||
Reference in new issue
Block a user