1
0
Fork 0
mirror of https://github.com/pygos/pkg-utils.git synced 2024-11-22 12:59:46 +01:00

cleanup: merge listing & format flags for dump and install commands

Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
This commit is contained in:
David Oberhollenzer 2019-03-08 19:16:59 +01:00
parent 20aea96396
commit f038cc52b3
2 changed files with 49 additions and 49 deletions

View file

@ -3,13 +3,12 @@
static const struct option long_opts[] = { static const struct option long_opts[] = {
{ "dependencies", no_argument, NULL, 'd' }, { "dependencies", no_argument, NULL, 'd' },
{ "list-files", no_argument, NULL, 'l' }, { "list-files", required_argument, NULL, 'l' },
{ "format", required_argument, NULL, 'f' },
{ "root", required_argument, NULL, 'r' }, { "root", required_argument, NULL, 'r' },
{ NULL, 0, NULL, 0 }, { NULL, 0, NULL, 0 },
}; };
static const char *short_opts = "dlf:r:"; static const char *short_opts = "dl:r:";
static int cmd_dump(int argc, char **argv) static int cmd_dump(int argc, char **argv)
{ {
@ -26,13 +25,16 @@ static int cmd_dump(int argc, char **argv)
break; break;
switch (i) { switch (i) {
case 'f': case 'l':
flags |= DUMP_TOC;
if (strcmp(optarg, "sqfs") == 0) { if (strcmp(optarg, "sqfs") == 0) {
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) { } else if (strcmp(optarg, "pkg") == 0) {
format = TOC_FORMAT_PKG; format = TOC_FORMAT_PKG;
} else if (strcmp(optarg, "detail") == 0) {
format = TOC_FORMAT_PRETTY;
} else { } else {
fprintf(stderr, "unknown format '%s'\n", fprintf(stderr, "unknown format '%s'\n",
optarg); optarg);
@ -43,9 +45,6 @@ static int cmd_dump(int argc, char **argv)
case 'r': case 'r':
root = optarg; root = optarg;
break; break;
case 'l':
flags |= DUMP_TOC;
break;
case 'd': case 'd':
flags |= DUMP_DEPS; flags |= DUMP_DEPS;
break; break;
@ -103,25 +102,25 @@ static command_t dump = {
"Possible options:\n" "Possible options:\n"
" --dependencies, -d Show dependency information of a package.\n" " --dependencies, -d Show dependency information of a package.\n"
"\n" "\n"
" --list-files, -l Produce a list of files. The format for the list\n" " --list-files, -l <format> Produce a list of files with a specified\n"
" can be specified with --format.\n" " formating.\n"
"\n" "\n"
" --format, -f <format> Specify what format to use for printing the table\n" " If \"detail\" is specified, a human readable,\n"
" of contents. Default is a pretty printed, human\n" " pretty printed format with details is used.\n"
" readable version.\n"
"\n" "\n"
" If \"sqfs\" is specified, a squashfs pseudo file\n" " If \"sqfs\" is specified, a squashfs pseudo\n"
" is genareated for setting permissions bits and\n" " file is genareated for setting permissions\n"
" ownership appropriately.\n" " bits and ownership appropriately.\n"
"\n" "\n"
" If \"initrd\" is specified, a format appropriate\n" " If \"initrd\" is specified, the format of\n"
" for Linux gen_init_cpio is produced.\n" " Linux gen_init_cpio is produced.\n"
"\n" "\n"
" --root, -r <path> If a format is used that requires absoulute input\n" " --root, -r <path> If a format is used that requires absoulute\n"
" paths (e.g. initrd), prefix all file paths with\n" " input paths (e.g. initrd), prefix all file\n"
" this. Can be used, for instance to unpack a\n" " paths with this. Can be used, for instance to\n"
" package to a staging directory and generate a\n" " unpack a package to a staging directory and\n"
" a listing for Linux CONFIG_INITRAMFS_SOURCE.\n", " generate a a listing for Linux\n"
" CONFIG_INITRAMFS_SOURCE.\n",
.run_cmd = cmd_dump, .run_cmd = cmd_dump,
}; };

View file

@ -8,8 +8,7 @@ static const struct option long_opts[] = {
{ "no-dependencies", no_argument, NULL, 'd' }, { "no-dependencies", no_argument, NULL, 'd' },
{ "repo-dir", required_argument, NULL, 'R' }, { "repo-dir", required_argument, NULL, 'R' },
{ "list-packages", no_argument, NULL, 'p' }, { "list-packages", no_argument, NULL, 'p' },
{ "list-files", no_argument, NULL, 'l' }, { "list-files", required_argument, NULL, 'l' },
{ "format", required_argument, NULL, 'F' },
{ "no-symlinks", no_argument, NULL, 'L' }, { "no-symlinks", no_argument, NULL, 'L' },
{ "no-devices", no_argument, NULL, 'D' }, { "no-devices", no_argument, NULL, 'D' },
{ NULL, 0, NULL, 0 }, { NULL, 0, NULL, 0 },
@ -102,14 +101,14 @@ static int cmd_install(int argc, char **argv)
break; break;
case 'l': case 'l':
mode = INSTALL_MODE_LIST_FILES; mode = INSTALL_MODE_LIST_FILES;
break;
case 'F':
if (strcmp(optarg, "sqfs") == 0) { if (strcmp(optarg, "sqfs") == 0) {
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) { } else if (strcmp(optarg, "pkg") == 0) {
format = TOC_FORMAT_PKG; format = TOC_FORMAT_PKG;
} else if (strcmp(optarg, "detail")) {
format = TOC_FORMAT_PRETTY;
} else { } else {
fprintf(stderr, "unknown format '%s'\n", fprintf(stderr, "unknown format '%s'\n",
optarg); optarg);
@ -213,31 +212,33 @@ static command_t install = {
"packages are evaluated and also installed.\n" "packages are evaluated and also installed.\n"
"\n" "\n"
"Possible options:\n" "Possible options:\n"
" --repo-dir, -R <path> Specify the input repository path to fetch the\n" " --repo-dir, -R <path> Specify the input repository path to fetch the\n"
" packages from.\n" " packages from.\n"
" --root, -r <path> A root directory to unpack the package. Defaults\n" " --root, -r <path> A root directory to unpack the package. Default\n"
" to the current working directory if not set.\n" " if not set is the current working directory.\n"
" --no-chown, -o Do not change ownership of the extracted data.\n" " --no-chown, -o Do not change ownership of the extracted data.\n"
" Keep the uid/gid of the user who runs the program.\n" " Keep the uid/gid of the user who runs the \n"
" --no-chmod, -m Do not change permission flags of the extarcted\n" " program."
" data. Use 0644 for all files and 0755 for all\n" " --no-chmod, -m Do not change permission flags of the extarcted\n"
" directories.\n" " data. Use 0644 for all files and 0755 for all\n"
" --no-dependencies, -d Do not resolve dependencies, only install files\n" " directories.\n"
" packages listed on the command line.\n" " --no-dependencies, -d Do not resolve dependencies, only install files\n"
" --list-packages, -p Do not install packages, print out final package\n" " packages listed on the command line.\n"
" list that would be installed.\n" " --list-packages, -p Do not install packages, print out final\n"
" --list-files, -l Do not install packages, print out table of\n" " package list that would be installed.\n"
" contents for all packages that would be installed.\n" " --list-files, -l <format> Do not install packages, print out table of\n"
" --format, -F <format> Specify what format to use for printing the table\n" " contents for all packages that would be\n"
" of contents. Default is a pretty printed, human\n" " installed in a specified format.\n"
" readable version.\n"
"\n" "\n"
" If \"sqfs\" is specified, a squashfs pseudo file\n" " If \"detail\" is specified, a human readable,\n"
" is genareated for setting permissions bits and\n" " pretty printed format with details is used.\n"
" ownership appropriately.\n"
"\n" "\n"
" If \"initrd\" is specified, a format appropriate\n" " If \"sqfs\" is specified, a squashfs pseudo\n"
" for Linux gen_init_cpio is produced.\n", " file is genareated for setting permissions bits\n"
" and ownership appropriately.\n"
"\n"
" If \"initrd\" is specified, the format of Linux\n"
" gen_init_cpio is produced.\n",
.run_cmd = cmd_install, .run_cmd = cmd_install,
}; };