8,10 → 8,10 |
#include "package.h" |
#include "http.h" |
|
void process_task(list_t *task); |
|
#define BUFFSIZE (64*1024) |
|
extern char conbuf[256]; |
|
#define OPTION_STD_BASE 150 |
|
enum option_values |
18,7 → 18,8 |
{ |
OPTION_HELP = OPTION_STD_BASE, |
OPTION_LIST_PACKAGES, |
OPTION_LIST_INSTALLED |
OPTION_LIST_INSTALLED, |
OPTION_INSTALL_ALL |
}; |
|
static const struct option longopts[] = |
25,9 → 26,32 |
{ |
{"list-packages", no_argument, NULL, OPTION_LIST_PACKAGES}, |
{"list-installed",no_argument, NULL, OPTION_LIST_INSTALLED}, |
{"install-all",no_argument, NULL, OPTION_INSTALL_ALL}, |
{NULL,0,NULL,0} |
}; |
|
static void show_usage () |
{ |
sprintf (conbuf, "Usage: kpm [option...]\n"); |
con_write_asciiz(conbuf); |
|
sprintf (conbuf, ("\ |
Options:\n\ |
--list-packages\n\ |
show available packages\n")); |
con_write_asciiz(conbuf); |
|
sprintf (conbuf, ("\ |
--list-installed\n\ |
show available packages\n")); |
con_write_asciiz(conbuf); |
|
sprintf (conbuf, ("\ |
--install all\n\ |
install all packages\n")); |
con_write_asciiz(conbuf); |
}; |
|
int main(int argc, char *argv[]) |
{ |
LIST_HEAD(server_list); |
39,6 → 63,7 |
int count; |
char *cache_path; |
char *tmp_path; |
int act = 1; |
|
if(http_init()) |
goto err_init; |
54,7 → 79,7 |
if(count) |
build_server_list(&server_list, tmp_path); |
|
while(1) |
while(act) |
{ |
int val; |
int index; |
61,9 → 86,6 |
|
val = getopt_long_only(argc, argv,"",longopts, &index); |
|
if(val == -1) |
break; |
|
switch(val) |
{ |
case OPTION_LIST_PACKAGES: |
70,46 → 92,28 |
sprintf(conbuf,"available packages:\n\n"); |
con_write_asciiz(conbuf); |
print_pkg_list(&server_list); |
con_exit(0); |
return 0; |
act = 0; |
break; |
|
case OPTION_LIST_INSTALLED: |
sprintf(conbuf,"installed packages:\n\n"); |
con_write_asciiz(conbuf); |
print_pkg_list(&local_list); |
con_exit(0); |
return 0; |
act = 0; |
break; |
|
case OPTION_INSTALL_ALL: |
copy_list(&task_list, &server_list); |
process_task(&task_list); |
act = 0; |
break; |
|
default: |
break; |
show_usage(); |
act = 0; |
} |
}; |
|
#if 0 |
{ |
package_t *pkg; |
LIST_HEAD(install_list); |
LIST_HEAD(download_list); |
|
if(collection && build_install_list(&install_list, collection)) |
{ |
if(build_download_list(&download_list, &install_list)) |
do_download(&download_list); |
|
if(!list_empty(&download_list)) |
remove_missing_packages(&install_list, &download_list); |
|
list_for_each_entry(pkg, &install_list, list) |
{ |
sprintf(conbuf,"install package %s-%s\n", pkg->name, pkg->version); |
con_write_asciiz(conbuf); |
}; |
|
do_install(&install_list); |
}; |
} |
#endif |
|
con_exit(0); |
|
return 0; |
119,6 → 123,3 |
return -1; |
} |
|
|
|
|