X-Git-Url: https://git.librecmc.org/?p=oweals%2Fopkg-lede.git;a=blobdiff_plain;f=src%2Fopkg-cl.c;h=eff84a95a119c3cc391f5f1e5c8e235cf0dbc991;hp=4ce0414133cd628c87d3e17e8106b58de000b703;hb=c49d81d4d2c3ff24c06679d16a5b1843634dc8ac;hpb=a2afaf0b997f88422e07f622ba2bec3f5786e4de diff --git a/src/opkg-cl.c b/src/opkg-cl.c index 4ce0414..eff84a9 100644 --- a/src/opkg-cl.c +++ b/src/opkg-cl.c @@ -19,10 +19,10 @@ opkg command line frontend using libopkg */ -#include "config.h" - +#define _GNU_SOURCE #include #include +#include #include "opkg_conf.h" #include "opkg_cmd.h" @@ -51,6 +51,8 @@ enum { ARGS_OPT_NOCASE, ARGS_OPT_AUTOREMOVE, ARGS_OPT_CACHE, + ARGS_OPT_FORCE_SIGNATURE, + ARGS_OPT_SIZE, }; static struct option long_options[] = { @@ -60,8 +62,8 @@ static struct option long_options[] = { {"conf-file", 1, 0, 'f'}, {"conf", 1, 0, 'f'}, {"dest", 1, 0, 'd'}, - {"force-maintainer", 0, 0, ARGS_OPT_FORCE_MAINTAINER}, - {"force_maintainer", 0, 0, ARGS_OPT_FORCE_MAINTAINER}, + {"force-maintainer", 0, 0, ARGS_OPT_FORCE_MAINTAINER}, + {"force_maintainer", 0, 0, ARGS_OPT_FORCE_MAINTAINER}, {"force-depends", 0, 0, ARGS_OPT_FORCE_DEPENDS}, {"force_depends", 0, 0, ARGS_OPT_FORCE_DEPENDS}, {"force-overwrite", 0, 0, ARGS_OPT_FORCE_OVERWRITE}, @@ -74,19 +76,21 @@ static struct option long_options[] = { {"force_space", 0, 0, ARGS_OPT_FORCE_SPACE}, {"recursive", 0, 0, ARGS_OPT_FORCE_REMOVAL_OF_DEPENDENT_PACKAGES}, {"force-removal-of-dependent-packages", 0, 0, - ARGS_OPT_FORCE_REMOVAL_OF_DEPENDENT_PACKAGES}, + ARGS_OPT_FORCE_REMOVAL_OF_DEPENDENT_PACKAGES}, {"force_removal_of_dependent_packages", 0, 0, - ARGS_OPT_FORCE_REMOVAL_OF_DEPENDENT_PACKAGES}, + ARGS_OPT_FORCE_REMOVAL_OF_DEPENDENT_PACKAGES}, {"force-removal-of-essential-packages", 0, 0, - ARGS_OPT_FORCE_REMOVAL_OF_ESSENTIAL_PACKAGES}, + ARGS_OPT_FORCE_REMOVAL_OF_ESSENTIAL_PACKAGES}, {"force_removal_of_essential_packages", 0, 0, - ARGS_OPT_FORCE_REMOVAL_OF_ESSENTIAL_PACKAGES}, + ARGS_OPT_FORCE_REMOVAL_OF_ESSENTIAL_PACKAGES}, {"force-postinstall", 0, 0, ARGS_OPT_FORCE_POSTINSTALL}, {"force_postinstall", 0, 0, ARGS_OPT_FORCE_POSTINSTALL}, {"force-remove", 0, 0, ARGS_OPT_FORCE_REMOVE}, {"force_remove", 0, 0, ARGS_OPT_FORCE_REMOVE}, {"force-checksum", 0, 0, ARGS_OPT_FORCE_CHECKSUM}, {"force_checksum", 0, 0, ARGS_OPT_FORCE_CHECKSUM}, + {"force-signature", 0, 0, ARGS_OPT_FORCE_SIGNATURE}, + {"force_signature", 0, 0, ARGS_OPT_FORCE_SIGNATURE}, {"noaction", 0, 0, ARGS_OPT_NOACTION}, {"download-only", 0, 0, ARGS_OPT_DOWNLOAD_ONLY}, {"nodeps", 0, 0, ARGS_OPT_NODEPS}, @@ -95,16 +99,18 @@ static struct option long_options[] = { {"offline-root", 1, 0, 'o'}, {"add-arch", 1, 0, ARGS_OPT_ADD_ARCH}, {"add-dest", 1, 0, ARGS_OPT_ADD_DEST}, + {"size", 0, 0, ARGS_OPT_SIZE}, {"test", 0, 0, ARGS_OPT_NOACTION}, {"tmp-dir", 1, 0, 't'}, {"tmp_dir", 1, 0, 't'}, + {"lists-dir", 1, 0, 'l'}, + {"lists_dir", 1, 0, 'l'}, {"verbosity", 2, 0, 'V'}, {"version", 0, 0, 'v'}, {0, 0, 0, 0} }; -static int -args_parse(int argc, char *argv[]) +static int args_parse(int argc, char *argv[]) { int c; int option_index = 0; @@ -112,8 +118,8 @@ args_parse(int argc, char *argv[]) char *tuple, *targ; while (1) { - c = getopt_long_only(argc, argv, "Ad:f:ino:p:t:vV::", - long_options, &option_index); + c = getopt_long_only(argc, argv, "Ad:f:ino:p:l:t:vV::", + long_options, &option_index); if (c == -1) break; @@ -136,6 +142,9 @@ args_parse(int argc, char *argv[]) case 't': conf->tmp_dir = xstrdup(optarg); break; + case 'l': + conf->lists_dir = xstrdup(optarg); + break; case 'v': printf("opkg version %s\n", VERSION); exit(0); @@ -196,20 +205,27 @@ args_parse(int argc, char *argv[]) if ((targ = strchr(tuple, ':')) != NULL) { *targ++ = 0; if ((strlen(tuple) > 0) && (strlen(targ) > 0)) { - nv_pair_list_append( - (c == ARGS_OPT_ADD_ARCH) - ? &conf->arch_list : &conf->tmp_dest_list, - tuple, targ); + nv_pair_list_append((c == + ARGS_OPT_ADD_ARCH) + ? &conf->arch_list : + &conf->tmp_dest_list, + tuple, targ); } } free(tuple); break; + case ARGS_OPT_SIZE: + conf->size = 1; + break; case ARGS_OPT_NOACTION: conf->noaction = 1; break; - case ARGS_OPT_DOWNLOAD_ONLY: + case ARGS_OPT_DOWNLOAD_ONLY: conf->download_only = 1; break; + case ARGS_OPT_FORCE_SIGNATURE: + conf->force_signature = 1; + break; case ':': parse_err = -1; break; @@ -221,7 +237,7 @@ args_parse(int argc, char *argv[]) } } - if(!conf->conf_file && !conf->offline_root) + if (!conf->conf_file && !conf->offline_root) conf->conf_file = xstrdup("/etc/opkg.conf"); if (parse_err) @@ -230,35 +246,42 @@ args_parse(int argc, char *argv[]) return optind; } -static void -usage() +static void usage() { printf("usage: opkg [options...] sub-command [arguments...]\n"); printf("where sub-command is one of:\n"); printf("\nPackage Manipulation:\n"); - printf("\tupdate Update list of available packages\n"); + printf + ("\tupdate Update list of available packages\n"); printf("\tupgrade Upgrade packages\n"); printf("\tinstall Install package(s)\n"); printf("\tconfigure Configure unpacked package(s)\n"); printf("\tremove Remove package(s)\n"); printf("\tflag Flag package(s)\n"); - printf("\t =hold|noprune|user|ok|installed|unpacked (one per invocation)\n"); + printf + ("\t =hold|noprune|user|ok|installed|unpacked (one per invocation)\n"); printf("\nInformational Commands:\n"); printf("\tlist List available packages\n"); printf("\tlist-installed List installed packages\n"); - printf("\tlist-upgradable List installed and upgradable packages\n"); - printf("\tlist-changed-conffiles List user modified configuration files\n"); + printf + ("\tlist-upgradable List installed and upgradable packages\n"); + printf + ("\tlist-changed-conffiles List user modified configuration files\n"); printf("\tfiles List files belonging to \n"); printf("\tsearch List package providing \n"); - printf("\tfind List packages whose name or description matches \n"); + printf + ("\tfind List packages whose name or description matches \n"); printf("\tinfo [pkg|regexp] Display all info for \n"); printf("\tstatus [pkg|regexp] Display all status for \n"); - printf("\tdownload Download to current directory\n"); + printf + ("\tdownload Download to current directory\n"); printf("\tcompare-versions \n"); - printf("\t compare versions using <= < > >= = << >>\n"); - printf("\tprint-architecture List installable package architectures\n"); + printf + ("\t compare versions using <= < > >= = << >>\n"); + printf + ("\tprint-architecture List installable package architectures\n"); printf("\tdepends [-A] [pkgname|pat]+\n"); printf("\twhatdepends [-A] [pkgname|pat]+\n"); printf("\twhatdependsrec [-A] [pkgname|pat]+\n"); @@ -269,7 +292,8 @@ usage() printf("\twhatreplaces [-A] [pkgname|pat]+\n"); printf("\nOptions:\n"); - printf("\t-A Query all packages not just those installed\n"); + printf + ("\t-A Query all packages not just those installed\n"); printf("\t-V[] Set verbosity level to .\n"); printf("\t--verbosity[=] Verbosity levels:\n"); printf("\t 0 errors only\n"); @@ -277,60 +301,78 @@ usage() printf("\t 2 informative messages\n"); printf("\t 3 debug\n"); printf("\t 4 debug level 2\n"); - printf("\t-f Use as the opkg configuration file\n"); + printf + ("\t-f Use as the opkg configuration file\n"); printf("\t--conf \n"); printf("\t--cache Use a package cache\n"); - printf("\t-d Use as the the root directory for\n"); - printf("\t--dest package installation, removal, upgrading.\n"); - printf(" should be a defined dest name from\n"); - printf(" the configuration file, (but can also be a\n"); + printf + ("\t-d Use as the the root directory for\n"); + printf + ("\t--dest package installation, removal, upgrading.\n"); + printf + (" should be a defined dest name from\n"); + printf + (" the configuration file, (but can also be a\n"); printf(" directory name in a pinch).\n"); printf("\t-o Use as the root directory for\n"); printf("\t--offline-root offline installation of packages.\n"); - printf("\t--add-arch : Register architecture with given priority\n"); - printf("\t--add-dest : Register destination with given path\n"); + printf + ("\t--add-arch : Register architecture with given priority\n"); + printf + ("\t--add-dest : Register destination with given path\n"); printf("\nForce Options:\n"); - printf("\t--force-depends Install/remove despite failed dependencies\n"); + printf + ("\t--force-depends Install/remove despite failed dependencies\n"); printf("\t--force-maintainer Overwrite preexisting config files\n"); printf("\t--force-reinstall Reinstall package(s)\n"); - printf("\t--force-overwrite Overwrite files from other package(s)\n"); + printf + ("\t--force-overwrite Overwrite files from other package(s)\n"); printf("\t--force-downgrade Allow opkg to downgrade packages\n"); printf("\t--force-space Disable free space checks\n"); - printf("\t--force-postinstall Run postinstall scripts even in offline mode\n"); - printf("\t--force-remove Remove package even if prerm script fails\n"); + printf + ("\t--force-postinstall Run postinstall scripts even in offline mode\n"); + printf + ("\t--force-remove Remove package even if prerm script fails\n"); printf("\t--force-checksum Don't fail on checksum mismatches\n"); printf("\t--noaction No action -- test only\n"); printf("\t--download-only No action -- download only\n"); printf("\t--nodeps Do not follow dependencies\n"); - printf("\t--nocase Perform case insensitive pattern matching\n"); + printf + ("\t--nocase Perform case insensitive pattern matching\n"); + printf + ("\t--size Print package size when listing available packages\n"); printf("\t--force-removal-of-dependent-packages\n"); printf("\t Remove package and all dependencies\n"); printf("\t--autoremove Remove packages that were installed\n"); - printf("\t automatically to satisfy dependencies\n"); + printf + ("\t automatically to satisfy dependencies\n"); printf("\t-t Specify tmp-dir.\n"); printf("\t--tmp-dir Specify tmp-dir.\n"); + printf("\t-l Specify lists-dir.\n"); + printf("\t--lists-dir Specify lists-dir.\n"); printf("\n"); - printf(" regexp could be something like 'pkgname*' '*file*' or similar\n"); - printf(" e.g. opkg info 'libstd*' or opkg search '*libop*' or opkg remove 'libncur*'\n"); + printf + (" regexp could be something like 'pkgname*' '*file*' or similar\n"); + printf + (" e.g. opkg info 'libstd*' or opkg search '*libop*' or opkg remove 'libncur*'\n"); - /* --force-removal-of-essential-packages Let opkg remove essential packages. - Using this option is almost guaranteed to break your system, hence this option - is not even advertised in the usage statement. */ + /* --force-removal-of-essential-packages Let opkg remove essential packages. + Using this option is almost guaranteed to break your system, hence this option + is not even advertised in the usage statement. */ exit(1); } -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { int opts, err = -1; char *cmd_name; opkg_cmd_t *cmd; int nocheckfordirorfile = 0; - int noreadfeedsfile = 0; + int noreadfeedsfile = 0; if (opkg_conf_init()) goto err0; @@ -345,30 +387,32 @@ main(int argc, char *argv[]) cmd_name = argv[opts++]; - if (!strcmp(cmd_name,"print-architecture") || - !strcmp(cmd_name,"print_architecture") || - !strcmp(cmd_name,"print-installation-architecture") || - !strcmp(cmd_name,"print_installation_architecture") ) + if (!strcmp(cmd_name, "install") || + !strcmp(cmd_name, "print-architecture") || + !strcmp(cmd_name, "print_architecture") || + !strcmp(cmd_name, "print-installation-architecture") || + !strcmp(cmd_name, "print_installation_architecture")) nocheckfordirorfile = 1; - if (!strcmp(cmd_name,"flag") || - !strcmp(cmd_name,"configure") || - !strcmp(cmd_name,"remove") || - !strcmp(cmd_name,"files") || - !strcmp(cmd_name,"search") || - !strcmp(cmd_name,"compare_versions") || - !strcmp(cmd_name,"compare-versions") || - !strcmp(cmd_name,"list_installed") || - !strcmp(cmd_name,"list-installed") || - !strcmp(cmd_name,"list_changed_conffiles") || - !strcmp(cmd_name,"list-changed-conffiles") || - !strcmp(cmd_name,"status") ) + if (!strcmp(cmd_name, "flag") || + !strcmp(cmd_name, "configure") || + !strcmp(cmd_name, "install") || + !strcmp(cmd_name, "remove") || + !strcmp(cmd_name, "files") || + !strcmp(cmd_name, "search") || + !strcmp(cmd_name, "compare_versions") || + !strcmp(cmd_name, "compare-versions") || + !strcmp(cmd_name, "list_installed") || + !strcmp(cmd_name, "list-installed") || + !strcmp(cmd_name, "list_changed_conffiles") || + !strcmp(cmd_name, "list-changed-conffiles") || + !strcmp(cmd_name, "status")) noreadfeedsfile = 1; cmd = opkg_cmd_find(cmd_name); if (cmd == NULL) { fprintf(stderr, "%s: unknown sub-command %s\n", argv[0], - cmd_name); + cmd_name); usage(); } @@ -379,7 +423,7 @@ main(int argc, char *argv[]) if (!nocheckfordirorfile) { if (!noreadfeedsfile) { - if (pkg_hash_load_feeds()) + if (pkg_hash_load_feeds(SF_NEED_DETAIL)) goto err1; } @@ -389,12 +433,12 @@ main(int argc, char *argv[]) if (cmd->requires_args && opts == argc) { fprintf(stderr, - "%s: the ``%s'' command requires at least one argument\n", - argv[0], cmd_name); + "%s: the ``%s'' command requires at least one argument\n", + argv[0], cmd_name); usage(); } - err = opkg_cmd_exec(cmd, argc - opts, (const char **) (argv + opts)); + err = opkg_cmd_exec(cmd, argc - opts, (const char **)(argv + opts)); #ifdef HAVE_CURL opkg_curl_cleanup();