mirror of
https://github.com/pygos/pkg-utils.git
synced 2024-11-21 20:39:46 +01:00
Add flag to surpress creation of symlinks when unpacking
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
This commit is contained in:
parent
deb7bb0d4e
commit
6f32c6b883
4 changed files with 16 additions and 4 deletions
|
@ -7,6 +7,7 @@
|
|||
enum {
|
||||
UNPACK_NO_CHOWN = 0x01,
|
||||
UNPACK_NO_CHMOD = 0x02,
|
||||
UNPACK_NO_SYMLINKS = 0x04,
|
||||
};
|
||||
|
||||
int pkg_unpack(int rootfd, int flags, pkg_reader_t *rd);
|
||||
|
|
|
@ -9,10 +9,11 @@ static const struct option long_opts[] = {
|
|||
{ "list-packages", no_argument, NULL, 'p' },
|
||||
{ "list-files", no_argument, NULL, 'l' },
|
||||
{ "format", required_argument, NULL, 'F' },
|
||||
{ "no-symlinks", no_argument, NULL, 'L' },
|
||||
{ NULL, 0, NULL, 0 },
|
||||
};
|
||||
|
||||
static const char *short_opts = "r:omdR:plF:";
|
||||
static const char *short_opts = "r:omdR:plF:L";
|
||||
|
||||
static int unpack_packages(int repofd, int rootfd, int flags,
|
||||
struct pkg_dep_list *list)
|
||||
|
@ -150,6 +151,9 @@ static int cmd_install(int argc, char **argv)
|
|||
case 'm':
|
||||
flags |= UNPACK_NO_CHMOD;
|
||||
break;
|
||||
case 'L':
|
||||
flags |= UNPACK_NO_SYMLINKS;
|
||||
break;
|
||||
default:
|
||||
tell_read_help(argv[0]);
|
||||
goto out;
|
||||
|
|
|
@ -14,10 +14,11 @@ static const struct option long_opts[] = {
|
|||
{ "root", required_argument, NULL, 'r' },
|
||||
{ "no-chown", no_argument, NULL, 'o' },
|
||||
{ "no-chmod", no_argument, NULL, 'm' },
|
||||
{ "no-symlinks", no_argument, NULL, 'L' },
|
||||
{ NULL, 0, NULL, 0 },
|
||||
};
|
||||
|
||||
static const char *short_opts = "r:om";
|
||||
static const char *short_opts = "r:omL";
|
||||
|
||||
static int cmd_unpack(int argc, char **argv)
|
||||
{
|
||||
|
@ -34,6 +35,9 @@ static int cmd_unpack(int argc, char **argv)
|
|||
case 'r':
|
||||
root = optarg;
|
||||
break;
|
||||
case 'L':
|
||||
flags |= UNPACK_NO_SYMLINKS;
|
||||
break;
|
||||
case 'o':
|
||||
flags |= UNPACK_NO_CHOWN;
|
||||
break;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include "pkgio.h"
|
||||
#include "util/util.h"
|
||||
|
||||
static int create_hierarchy(int dirfd, image_entry_t *list)
|
||||
static int create_hierarchy(int dirfd, image_entry_t *list, int flags)
|
||||
{
|
||||
image_entry_t *ent;
|
||||
|
||||
|
@ -27,6 +27,9 @@ static int create_hierarchy(int dirfd, image_entry_t *list)
|
|||
|
||||
for (ent = list; ent != NULL; ent = ent->next) {
|
||||
if (S_ISLNK(ent->mode)) {
|
||||
if (flags & UNPACK_NO_SYMLINKS)
|
||||
continue;
|
||||
|
||||
if (symlinkat(ent->data.symlink.target,
|
||||
dirfd, ent->name)) {
|
||||
fprintf(stderr, "symlink %s to %s: %s\n",
|
||||
|
@ -175,7 +178,7 @@ int pkg_unpack(int rootfd, int flags, pkg_reader_t *rd)
|
|||
if (pkg_reader_rewind(rd))
|
||||
goto fail;
|
||||
|
||||
if (create_hierarchy(rootfd, list))
|
||||
if (create_hierarchy(rootfd, list, flags))
|
||||
goto fail;
|
||||
|
||||
for (;;) {
|
||||
|
|
Loading…
Reference in a new issue