f6f6fe945cd9875155852dc1a58fd4694435bee9
1 /* opkglib.c - the opkg package management system
5 Copyright (C) 2003 kernel concepts
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2, or (at
10 your option) any later version.
12 This program is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
22 #include "opkg_conf.h"
24 #include "file_util.h"
26 #include "opkg_message.h"
28 /* This is used for backward compatibility */
30 opkg_op (int argc
, char *argv
[])
36 int nocheckfordirorfile
= 0;
37 int noreadfeedsfile
= 0;
41 opts
= args_parse (&args
, argc
, argv
);
42 if (opts
== argc
|| opts
< 0)
44 args_usage ("opkg must have one sub-command argument");
47 cmd_name
= argv
[opts
++];
49 if ( !strcmp(cmd_name
,"print-architecture") ||
50 !strcmp(cmd_name
,"print_architecture") ||
51 !strcmp(cmd_name
,"print-installation-architecture") ||
52 !strcmp(cmd_name
,"print_installation_architecture") )
53 nocheckfordirorfile
= 1;
55 if ( !strcmp(cmd_name
,"flag") ||
56 !strcmp(cmd_name
,"configure") ||
57 !strcmp(cmd_name
,"remove") ||
58 !strcmp(cmd_name
,"files") ||
59 !strcmp(cmd_name
,"search") ||
60 !strcmp(cmd_name
,"compare_versions") ||
61 !strcmp(cmd_name
,"compare-versions") ||
62 !strcmp(cmd_name
,"list_installed") ||
63 !strcmp(cmd_name
,"list-installed") ||
64 !strcmp(cmd_name
,"status") )
67 cmd
= opkg_cmd_find (cmd_name
);
70 fprintf (stderr
, "%s: unknown sub-command %s\n", argv
[0],
77 err
= opkg_conf_init (&args
);
82 if (!nocheckfordirorfile
) {
83 if (!noreadfeedsfile
) {
84 if ((err
= pkg_hash_load_feeds()))
88 if ((err
= pkg_hash_load_status_files()))
92 if (cmd
->requires_args
&& opts
== argc
)
95 "%s: the ``%s'' command requires at least one argument\n",
100 err
= opkg_cmd_exec (cmd
, argc
- opts
, (const char **) (argv
+ opts
));