mirror of
https://github.com/pygos/pkg-utils.git
synced 2024-11-24 21:40:43 +01:00
Add a toc format that is also valid input for pkg pack
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
This commit is contained in:
parent
27c802fed0
commit
d55ee9bd72
4 changed files with 58 additions and 0 deletions
|
@ -32,6 +32,7 @@ typedef enum {
|
||||||
TOC_FORMAT_PRETTY = 0,
|
TOC_FORMAT_PRETTY = 0,
|
||||||
TOC_FORMAT_SQFS = 1,
|
TOC_FORMAT_SQFS = 1,
|
||||||
TOC_FORMAT_INITRD = 2,
|
TOC_FORMAT_INITRD = 2,
|
||||||
|
TOC_FORMAT_PKG = 3,
|
||||||
} TOC_FORMAT;
|
} TOC_FORMAT;
|
||||||
|
|
||||||
void image_entry_free(image_entry_t *ent);
|
void image_entry_free(image_entry_t *ent);
|
||||||
|
|
|
@ -131,10 +131,63 @@ static int print_initrd(image_entry_t *ent, const char *root)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int print_pkg(image_entry_t *ent, const char *root)
|
||||||
|
{
|
||||||
|
mode_t mode = ent->mode & (~S_IFMT);
|
||||||
|
|
||||||
|
switch (ent->mode & S_IFMT) {
|
||||||
|
case S_IFLNK:
|
||||||
|
mode = 0777;
|
||||||
|
fputs("slink", stdout);
|
||||||
|
break;
|
||||||
|
case S_IFREG:
|
||||||
|
fputs("file", stdout);
|
||||||
|
break;
|
||||||
|
case S_IFDIR:
|
||||||
|
fputs("dir", stdout);
|
||||||
|
break;
|
||||||
|
case S_IFCHR:
|
||||||
|
case S_IFBLK:
|
||||||
|
fputs("nod", stdout);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fputs("unknown file type in table of contents\n", stderr);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf(" %s 0%o %u %u ", ent->name, mode,
|
||||||
|
(unsigned int)ent->uid, (unsigned int)ent->gid);
|
||||||
|
|
||||||
|
switch (ent->mode & S_IFMT) {
|
||||||
|
case S_IFCHR:
|
||||||
|
printf("c %u %u", major(ent->data.device.devno),
|
||||||
|
minor(ent->data.device.devno));
|
||||||
|
break;
|
||||||
|
case S_IFBLK:
|
||||||
|
printf("b %u %u", major(ent->data.device.devno),
|
||||||
|
minor(ent->data.device.devno));
|
||||||
|
break;
|
||||||
|
case S_IFLNK:
|
||||||
|
fputs(ent->data.symlink.target, stdout);
|
||||||
|
break;
|
||||||
|
case S_IFREG:
|
||||||
|
if (root == NULL) {
|
||||||
|
printf("%s", ent->name);
|
||||||
|
} else {
|
||||||
|
printf("%s/%s", root, ent->name);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
fputc('\n', stdout);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static print_fun_t printers[] = {
|
static print_fun_t printers[] = {
|
||||||
[TOC_FORMAT_PRETTY] = print_pretty,
|
[TOC_FORMAT_PRETTY] = print_pretty,
|
||||||
[TOC_FORMAT_SQFS] = print_sqfs,
|
[TOC_FORMAT_SQFS] = print_sqfs,
|
||||||
[TOC_FORMAT_INITRD] = print_initrd,
|
[TOC_FORMAT_INITRD] = print_initrd,
|
||||||
|
[TOC_FORMAT_PKG] = print_pkg,
|
||||||
};
|
};
|
||||||
|
|
||||||
int dump_toc(image_entry_t *list, const char *root, TOC_FORMAT format)
|
int dump_toc(image_entry_t *list, const char *root, TOC_FORMAT format)
|
||||||
|
|
|
@ -30,6 +30,8 @@ static int cmd_dump(int argc, char **argv)
|
||||||
format = TOC_FORMAT_SQFS;
|
format = TOC_FORMAT_SQFS;
|
||||||
} else if (strcmp(optarg, "initrd") == 0) {
|
} else if (strcmp(optarg, "initrd") == 0) {
|
||||||
format = TOC_FORMAT_INITRD;
|
format = TOC_FORMAT_INITRD;
|
||||||
|
} else if (strcmp(optarg, "pkg") == 0) {
|
||||||
|
format = TOC_FORMAT_PKG;
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "unknown format '%s'\n",
|
fprintf(stderr, "unknown format '%s'\n",
|
||||||
optarg);
|
optarg);
|
||||||
|
|
|
@ -108,6 +108,8 @@ static int cmd_install(int argc, char **argv)
|
||||||
format = TOC_FORMAT_SQFS;
|
format = TOC_FORMAT_SQFS;
|
||||||
} else if (strcmp(optarg, "initrd") == 0) {
|
} else if (strcmp(optarg, "initrd") == 0) {
|
||||||
format = TOC_FORMAT_INITRD;
|
format = TOC_FORMAT_INITRD;
|
||||||
|
} else if (strcmp(optarg, "pkg") == 0) {
|
||||||
|
format = TOC_FORMAT_PKG;
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "unknown format '%s'\n",
|
fprintf(stderr, "unknown format '%s'\n",
|
||||||
optarg);
|
optarg);
|
||||||
|
|
Loading…
Reference in a new issue