diff options
author | jow <jow@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2009-10-22 15:15:19 +0000 |
---|---|---|
committer | jow <jow@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2009-10-22 15:15:19 +0000 |
commit | d968f2b92f68a0a2b0d45c28fc369d082b13c88c (patch) | |
tree | 196ef68435ca631b64b9cd676e75eff1f321593a /package/opkg | |
parent | a460e82adb8a229339e8d5b0e6296876ee37dc34 (diff) |
[package] opkg:
- re-enable upgrade and restrict it to signle packages, fix usage text
- only read package descriptions if they're actually needed (almost never),
saves even more space when parsing package lists
- refresh patches
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@18120 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/opkg')
-rw-r--r-- | package/opkg/patches/008-fix_parsing_insanity.patch | 192 | ||||
-rw-r--r-- | package/opkg/patches/009-remove-upgrade-all.patch | 40 | ||||
-rw-r--r-- | package/opkg/patches/009-remove-upgrade.patch | 143 | ||||
-rw-r--r-- | package/opkg/patches/010-remove-flag.patch | 12 | ||||
-rw-r--r-- | package/opkg/patches/011-fix_nullpointer_deref.patch | 2 |
5 files changed, 226 insertions, 163 deletions
diff --git a/package/opkg/patches/008-fix_parsing_insanity.patch b/package/opkg/patches/008-fix_parsing_insanity.patch index f70d64f96..03e03a86f 100644 --- a/package/opkg/patches/008-fix_parsing_insanity.patch +++ b/package/opkg/patches/008-fix_parsing_insanity.patch @@ -84,7 +84,7 @@ rewind(control_file); - raw = read_raw_pkgs_from_stream(control_file); - pkg_parse_raw(pkg, &raw, NULL, NULL); -+ pkg_parse_fd(pkg, fileno(control_file), NULL, NULL); ++ pkg_parse_fd(pkg, fileno(control_file), NULL, NULL, 0); fclose(control_file); @@ -151,9 +151,12 @@ #include "hash_table.h" #include "pkg.h" -@@ -112,43 +114,50 @@ +@@ -110,45 +112,52 @@ + } + int pkg_hash_add_from_file(opkg_conf_t *conf, const char *file_name, - pkg_src_t *src, pkg_dest_t *dest, int is_status_file) +- pkg_src_t *src, pkg_dest_t *dest, int is_status_file) ++ pkg_src_t *src, pkg_dest_t *dest, int is_status_file, int no_desc) { - hash_table_t *hash = &conf->pkg_hash; - char **raw; @@ -207,7 +210,7 @@ + break; + } + -+ if (pkg_parse_fd(pkg, fd, src, dest) == 0) { ++ if (pkg_parse_fd(pkg, fd, src, dest, no_desc) == 0) { + if (!pkg->architecture) { + char *version_str = pkg_version_str_alloc(pkg); + pkg->architecture = pkg_get_default_arch(conf); @@ -240,7 +243,7 @@ abstract_pkg_t * abstract_pkg_fetch_by_name(hash_table_t * hash, const char * pkg_name) --- a/libopkg/pkg_parse.c +++ b/libopkg/pkg_parse.c -@@ -191,214 +191,297 @@ +@@ -191,214 +191,301 @@ } @@ -262,7 +265,7 @@ - code duplication. -*/ -int pkg_parse_raw(pkg_t *pkg, char ***raw, pkg_src_t *src, pkg_dest_t *dest) -+int pkg_parse_fd(pkg_t *pkg, int fd, pkg_src_t *src, pkg_dest_t *dest) ++int pkg_parse_fd(pkg_t *pkg, int fd, pkg_src_t *src, pkg_dest_t *dest, int no_desc) { - int reading_conffiles, reading_description; - int pkg_false_provides=1; @@ -584,7 +587,8 @@ + + case 'D': + if(isGenericFieldType("Description", line)) { -+ pkg->description = parseGenericFieldType("Description", line); ++ if(!no_desc) ++ pkg->description = parseGenericFieldType("Description", line); + reading_conffiles = 0; + reading_description = 1; + } @@ -601,11 +605,14 @@ + + case ' ': + if(reading_description) { -+ /* we already know it's not blank, so the rest of description */ -+ pkg->description = realloc(pkg->description, -+ strlen(pkg->description) + 1 + strlen(line) + 1); -+ strcat(pkg->description, "\n"); -+ strcat(pkg->description, (line)); ++ /* we already know it's not blank, so the rest of description */ ++ if(!no_desc) ++ { ++ pkg->description = realloc(pkg->description, ++ strlen(pkg->description) + 1 + strlen(line) + 1); ++ strcat(pkg->description, "\n"); ++ strcat(pkg->description, (line)); ++ } + } + else if(reading_conffiles) + parseConffiles(pkg, line); @@ -748,7 +755,7 @@ void parseConffiles(pkg_t * pkg, char * raw); -int pkg_parse_raw(pkg_t *pkg, char ***raw, pkg_src_t *src, pkg_dest_t *dest); -int pkg_valorize_other_field(pkg_t *pkg, char ***raw); -+int pkg_parse_fd(pkg_t *pkg, int fd, pkg_src_t *src, pkg_dest_t *dest); ++int pkg_parse_fd(pkg_t *pkg, int fd, pkg_src_t *src, pkg_dest_t *dest, int no_desc); +int pkg_valorize_other_field(pkg_t *pkg, int fd); #endif @@ -763,3 +770,162 @@ char *trim_alloc(char * line); int line_is_blank(const char *line); +--- a/libopkg/libopkg.c ++++ b/libopkg/libopkg.c +@@ -88,6 +88,7 @@ + char *cmd_name; + opkg_cmd_t *cmd; + opkg_conf_t opkg_conf; ++ int no_desc = 1; + + args_init (&args); + +@@ -122,12 +123,18 @@ + !strcmp(cmd_name,"status") ) + args.noreadfeedsfile = 1; + ++ if( !strcmp(cmd_name,"list") || ++ !strcmp(cmd_name,"list-installed") || ++ !strcmp(cmd_name,"list_installed") || ++ !strcmp(cmd_name,"search") ) ++ no_desc = 0; ++ + opkg_cb_message = default_opkg_message_callback; + opkg_cb_response = default_opkg_response_callback; + opkg_cb_status = default_opkg_status_callback; + + +- err = opkg_conf_init (&opkg_conf, &args); ++ err = opkg_conf_init (&opkg_conf, &args, no_desc); + if (err) + { + opkg_print_error_list (&opkg_conf); +--- a/libopkg/opkg.c ++++ b/libopkg/opkg.c +@@ -205,7 +205,7 @@ + } + + opkg->conf = calloc (1, sizeof (opkg_conf_t)); +- err = opkg_conf_init (opkg->conf, opkg->args); ++ err = opkg_conf_init (opkg->conf, opkg->args, 0); + if (err) + { + free (opkg->conf); +@@ -286,7 +286,7 @@ + + /* throw away old opkg_conf and start again */ + opkg_conf_deinit (opkg->conf); +- opkg_conf_init (opkg->conf, opkg->args); ++ opkg_conf_init (opkg->conf, opkg->args, 0); + + free (opkg->options); + opkg_init_options_array (opkg->conf, &opkg->options); +--- a/libopkg/opkg_conf.c ++++ b/libopkg/opkg_conf.c +@@ -44,9 +44,9 @@ + static int opkg_conf_set_default_dest(opkg_conf_t *conf, + const char *default_dest_name); + static int set_and_load_pkg_src_list(opkg_conf_t *conf, +- pkg_src_list_t *nv_pair_list); ++ pkg_src_list_t *nv_pair_list, int no_desc); + static int set_and_load_pkg_dest_list(opkg_conf_t *conf, +- nv_pair_list_t *nv_pair_list, char * lists_dir); ++ nv_pair_list_t *nv_pair_list, char * lists_dir, int no_desc); + + int opkg_init_options_array(const opkg_conf_t *conf, opkg_option_t **options) + { +@@ -106,7 +106,7 @@ + } + } + +-int opkg_conf_init(opkg_conf_t *conf, const args_t *args) ++int opkg_conf_init(opkg_conf_t *conf, const args_t *args, int no_desc) + { + int err; + char *tmp_dir_base; +@@ -294,12 +294,12 @@ + if ( !(args->nocheckfordirorfile)){ + /* need to run load the source list before dest list -Jamey */ + if ( !(args->noreadfeedsfile)) +- set_and_load_pkg_src_list(conf, &conf->pkg_src_list); ++ set_and_load_pkg_src_list(conf, &conf->pkg_src_list, no_desc); + + /* Now that we have resolved conf->offline_root, we can commit to + the directory names for the dests and load in all the package + lists. */ +- set_and_load_pkg_dest_list(conf, &tmp_dest_nv_pair_list,lists_dir); ++ set_and_load_pkg_dest_list(conf, &tmp_dest_nv_pair_list,lists_dir, no_desc); + + if (args->dest) { + err = opkg_conf_set_default_dest(conf, args->dest); +@@ -409,7 +409,7 @@ + return 1; + } + +-static int set_and_load_pkg_src_list(opkg_conf_t *conf, pkg_src_list_t *pkg_src_list) ++static int set_and_load_pkg_src_list(opkg_conf_t *conf, pkg_src_list_t *pkg_src_list, int no_desc) + { + pkg_src_list_elt_t *iter; + pkg_src_t *src; +@@ -426,7 +426,7 @@ + src->name); + + if (file_exists(list_file)) { +- pkg_hash_add_from_file(conf, list_file, src, NULL, 0); ++ pkg_hash_add_from_file(conf, list_file, src, NULL, 0, no_desc); + } + free(list_file); + } +@@ -434,7 +434,7 @@ + return 0; + } + +-static int set_and_load_pkg_dest_list(opkg_conf_t *conf, nv_pair_list_t *nv_pair_list, char *lists_dir ) ++static int set_and_load_pkg_dest_list(opkg_conf_t *conf, nv_pair_list_t *nv_pair_list, char *lists_dir, int no_desc) + { + nv_pair_list_elt_t *iter; + nv_pair_t *nv_pair; +@@ -459,7 +459,7 @@ + } + if (file_exists(dest->status_file_name)) { + pkg_hash_add_from_file(conf, dest->status_file_name, +- NULL, dest, 1); ++ NULL, dest, 1, no_desc); + } + } + +--- a/libopkg/opkg_conf.h ++++ b/libopkg/opkg_conf.h +@@ -102,7 +102,7 @@ + const void *value; + }; + +-int opkg_conf_init(opkg_conf_t *conf, const args_t *args); ++int opkg_conf_init(opkg_conf_t *conf, const args_t *args, int no_desc); + void opkg_conf_deinit(opkg_conf_t *conf); + + int opkg_conf_write_status_files(opkg_conf_t *conf); +--- a/tests/opkg_hash_test.c ++++ b/tests/opkg_hash_test.c +@@ -33,8 +33,8 @@ + } + pkg_hash_init("test", hash, 1024); + +- pkg_hash_add_from_file(&conf, argv[1], NULL, NULL, 0); +- pkg_hash_add_from_file(&conf, argv[2], NULL, NULL, 0); ++ pkg_hash_add_from_file(&conf, argv[1], NULL, NULL, 0, 0); ++ pkg_hash_add_from_file(&conf, argv[2], NULL, NULL, 0, 0); + + if (argc < 4) { + pkg_print_info( pkg_hash_fetch_by_name_version(hash, "libc6", "2.2.3-2"), stdout); +--- a/libopkg/pkg_hash.h ++++ b/libopkg/pkg_hash.h +@@ -33,7 +33,7 @@ + void pkg_hash_fetch_available(hash_table_t *hash, pkg_vec_t *available); + + int pkg_hash_add_from_file(opkg_conf_t *conf, const char *file_name, +- pkg_src_t *src, pkg_dest_t *dest, int is_status_file); ++ pkg_src_t *src, pkg_dest_t *dest, int is_status_file, int no_desc); + pkg_t *hash_insert_pkg(hash_table_t *hash, pkg_t *pkg, int set_status,opkg_conf_t *conf); + + abstract_pkg_t * ensure_abstract_pkg_by_name(hash_table_t * hash, const char * pkg_name); diff --git a/package/opkg/patches/009-remove-upgrade-all.patch b/package/opkg/patches/009-remove-upgrade-all.patch new file mode 100644 index 000000000..320f71005 --- /dev/null +++ b/package/opkg/patches/009-remove-upgrade-all.patch @@ -0,0 +1,40 @@ +--- a/libopkg/args.c ++++ b/libopkg/args.c +@@ -263,7 +263,7 @@ + + printf("\nPackage Manipulation:\n"); + printf("\tupdate Update list of available packages\n"); +- printf("\tupgrade Upgrade all installed packages to latest version\n"); ++ printf("\tupgrade <pkg> Upgrade package to latest version\n"); + printf("\tinstall <pkg> Download and install <pkg> (and dependencies)\n"); + printf("\tinstall <file.opk> Install package <file.opk>\n"); + printf("\tconfigure [<pkg>] Configure unpacked packages\n"); +--- a/libopkg/opkg_cmd.c ++++ b/libopkg/opkg_cmd.c +@@ -79,7 +79,7 @@ + array for easier maintenance */ + static opkg_cmd_t cmds[] = { + {"update", 0, (opkg_cmd_fun_t)opkg_update_cmd}, +- {"upgrade", 0, (opkg_cmd_fun_t)opkg_upgrade_cmd}, ++ {"upgrade", 1, (opkg_cmd_fun_t)opkg_upgrade_cmd}, + {"list", 0, (opkg_cmd_fun_t)opkg_list_cmd}, + {"list_installed", 0, (opkg_cmd_fun_t)opkg_list_installed_cmd}, + {"list_upgradable", 0, (opkg_cmd_fun_t)opkg_list_upgradable_cmd}, +@@ -640,17 +640,6 @@ + opkg_install_by_name(conf, arg); + } + } +- } else { +- pkg_vec_t *installed = pkg_vec_alloc(); +- +- pkg_info_preinstall_check(conf); +- +- pkg_hash_fetch_all_installed(&conf->pkg_hash, installed); +- for (i = 0; i < installed->len; i++) { +- pkg = installed->pkgs[i]; +- opkg_upgrade_pkg(conf, pkg); +- } +- pkg_vec_free(installed); + } + + /* recheck to verify that all dependences are satisfied */ diff --git a/package/opkg/patches/009-remove-upgrade.patch b/package/opkg/patches/009-remove-upgrade.patch deleted file mode 100644 index 1d2f4e91d..000000000 --- a/package/opkg/patches/009-remove-upgrade.patch +++ /dev/null @@ -1,143 +0,0 @@ ---- a/libopkg/args.c -+++ b/libopkg/args.c -@@ -263,7 +263,6 @@ - - printf("\nPackage Manipulation:\n"); - printf("\tupdate Update list of available packages\n"); -- printf("\tupgrade Upgrade all installed packages to latest version\n"); - printf("\tinstall <pkg> Download and install <pkg> (and dependencies)\n"); - printf("\tinstall <file.opk> Install package <file.opk>\n"); - printf("\tconfigure [<pkg>] Configure unpacked packages\n"); -@@ -274,7 +273,6 @@ - printf("\nInformational Commands:\n"); - printf("\tlist List available packages and descriptions\n"); - printf("\tlist_installed List all and only the installed packages and description \n"); -- printf("\tlist_upgradable List all the installed and upgradable packages\n"); - printf("\tfiles <pkg> List all files belonging to <pkg>\n"); - printf("\tsearch <file|regexp> Search for a package providing <file>\n"); - printf("\tinfo [pkg|regexp] Display all info for <pkg>\n"); ---- a/libopkg/opkg_cmd.c -+++ b/libopkg/opkg_cmd.c -@@ -48,14 +48,12 @@ - static void *p_userdata = NULL; - - static int opkg_update_cmd(opkg_conf_t *conf, int argc, char **argv); --static int opkg_upgrade_cmd(opkg_conf_t *conf, int argc, char **argv); - static int opkg_list_cmd(opkg_conf_t *conf, int argc, char **argv); - static int opkg_info_cmd(opkg_conf_t *conf, int argc, char **argv); - static int opkg_status_cmd(opkg_conf_t *conf, int argc, char **argv); - static int opkg_install_pending_cmd(opkg_conf_t *conf, int argc, char **argv); - static int opkg_install_cmd(opkg_conf_t *conf, int argc, char **argv); - static int opkg_list_installed_cmd(opkg_conf_t *conf, int argc, char **argv); --static int opkg_list_upgradable_cmd(opkg_conf_t *conf, int argc, char **argv); - static int opkg_remove_cmd(opkg_conf_t *conf, int argc, char **argv); - static int opkg_purge_cmd(opkg_conf_t *conf, int argc, char **argv); - static int opkg_flag_cmd(opkg_conf_t *conf, int argc, char **argv); -@@ -79,10 +77,8 @@ - array for easier maintenance */ - static opkg_cmd_t cmds[] = { - {"update", 0, (opkg_cmd_fun_t)opkg_update_cmd}, -- {"upgrade", 0, (opkg_cmd_fun_t)opkg_upgrade_cmd}, - {"list", 0, (opkg_cmd_fun_t)opkg_list_cmd}, - {"list_installed", 0, (opkg_cmd_fun_t)opkg_list_installed_cmd}, -- {"list_upgradable", 0, (opkg_cmd_fun_t)opkg_list_upgradable_cmd}, - {"info", 0, (opkg_cmd_fun_t)opkg_info_cmd}, - {"flag", 1, (opkg_cmd_fun_t)opkg_flag_cmd}, - {"status", 0, (opkg_cmd_fun_t)opkg_status_cmd}, -@@ -599,69 +595,6 @@ - return err; - } - --static int opkg_upgrade_cmd(opkg_conf_t *conf, int argc, char **argv) --{ -- int i; -- pkg_t *pkg; -- int err; -- -- global_conf = conf; -- signal(SIGINT, sigint_handler); -- -- if (argc) { -- for (i=0; i < argc; i++) { -- char *arg = argv[i]; -- -- err = opkg_prepare_url_for_install(conf, arg, &arg); -- if (err != EINVAL && err != 0) -- return err; -- } -- pkg_info_preinstall_check(conf); -- -- for (i=0; i < argc; i++) { -- char *arg = argv[i]; -- if (conf->restrict_to_default_dest) { -- pkg = pkg_hash_fetch_installed_by_name_dest(&conf->pkg_hash, -- argv[i], -- conf->default_dest); -- if (pkg == NULL) { -- opkg_message(conf, OPKG_NOTICE, -- "Package %s not installed in %s\n", -- argv[i], conf->default_dest->name); -- continue; -- } -- } else { -- pkg = pkg_hash_fetch_installed_by_name(&conf->pkg_hash, -- argv[i]); -- } -- if (pkg) -- opkg_upgrade_pkg(conf, pkg); -- else { -- opkg_install_by_name(conf, arg); -- } -- } -- } else { -- pkg_vec_t *installed = pkg_vec_alloc(); -- -- pkg_info_preinstall_check(conf); -- -- pkg_hash_fetch_all_installed(&conf->pkg_hash, installed); -- for (i = 0; i < installed->len; i++) { -- pkg = installed->pkgs[i]; -- opkg_upgrade_pkg(conf, pkg); -- } -- pkg_vec_free(installed); -- } -- -- /* recheck to verify that all dependences are satisfied */ -- if (0) opkg_satisfy_all_dependences(conf); -- -- opkg_configure_packages(conf, NULL); -- -- write_status_files_if_changed(conf); -- -- return 0; --} - - static int opkg_download_cmd(opkg_conf_t *conf, int argc, char **argv) - { -@@ -788,26 +721,6 @@ - return 0; - } - --static int opkg_list_upgradable_cmd(opkg_conf_t *conf, int argc, char **argv) --{ -- struct active_list *head = prepare_upgrade_list(conf); -- struct active_list *node=NULL; -- pkg_t *_old_pkg, *_new_pkg; -- char *old_v, *new_v; -- for (node = active_list_next(head, head); node;node = active_list_next(head,node)) { -- _old_pkg = list_entry(node, pkg_t, list); -- _new_pkg = pkg_hash_fetch_best_installation_candidate_by_name(conf, _old_pkg->name, NULL); -- old_v = pkg_version_str_alloc(_old_pkg); -- new_v = pkg_version_str_alloc(_new_pkg); -- if (opkg_cb_list) -- opkg_cb_list(_old_pkg->name, new_v, old_v, _old_pkg->state_status, p_userdata); -- free(old_v); -- free(new_v); -- } -- active_list_head_delete(head); -- return 0; --} -- - static int opkg_info_status_cmd(opkg_conf_t *conf, int argc, char **argv, int installed_only) - { - int i; diff --git a/package/opkg/patches/010-remove-flag.patch b/package/opkg/patches/010-remove-flag.patch index d550ec7b3..20bebda4b 100644 --- a/package/opkg/patches/010-remove-flag.patch +++ b/package/opkg/patches/010-remove-flag.patch @@ -1,6 +1,6 @@ --- a/libopkg/args.c +++ b/libopkg/args.c -@@ -267,8 +267,6 @@ +@@ -268,8 +268,6 @@ printf("\tinstall <file.opk> Install package <file.opk>\n"); printf("\tconfigure [<pkg>] Configure unpacked packages\n"); printf("\tremove <pkg|regexp> Remove package <pkg|packages following regexp>\n"); @@ -11,23 +11,23 @@ printf("\tlist List available packages and descriptions\n"); --- a/libopkg/opkg_cmd.c +++ b/libopkg/opkg_cmd.c -@@ -56,7 +56,6 @@ - static int opkg_list_installed_cmd(opkg_conf_t *conf, int argc, char **argv); +@@ -58,7 +58,6 @@ + static int opkg_list_upgradable_cmd(opkg_conf_t *conf, int argc, char **argv); static int opkg_remove_cmd(opkg_conf_t *conf, int argc, char **argv); static int opkg_purge_cmd(opkg_conf_t *conf, int argc, char **argv); -static int opkg_flag_cmd(opkg_conf_t *conf, int argc, char **argv); static int opkg_files_cmd(opkg_conf_t *conf, int argc, char **argv); static int opkg_search_cmd(opkg_conf_t *conf, int argc, char **argv); static int opkg_download_cmd(opkg_conf_t *conf, int argc, char **argv); -@@ -80,7 +79,6 @@ - {"list", 0, (opkg_cmd_fun_t)opkg_list_cmd}, +@@ -84,7 +83,6 @@ {"list_installed", 0, (opkg_cmd_fun_t)opkg_list_installed_cmd}, + {"list_upgradable", 0, (opkg_cmd_fun_t)opkg_list_upgradable_cmd}, {"info", 0, (opkg_cmd_fun_t)opkg_info_cmd}, - {"flag", 1, (opkg_cmd_fun_t)opkg_flag_cmd}, {"status", 0, (opkg_cmd_fun_t)opkg_status_cmd}, {"install_pending", 0, (opkg_cmd_fun_t)opkg_install_pending_cmd}, {"install", 1, (opkg_cmd_fun_t)opkg_install_cmd}, -@@ -974,48 +972,6 @@ +@@ -1050,48 +1048,6 @@ return 0; } diff --git a/package/opkg/patches/011-fix_nullpointer_deref.patch b/package/opkg/patches/011-fix_nullpointer_deref.patch index 1eecfd3ff..ed198af39 100644 --- a/package/opkg/patches/011-fix_nullpointer_deref.patch +++ b/package/opkg/patches/011-fix_nullpointer_deref.patch @@ -1,6 +1,6 @@ --- a/libopkg/opkg_cmd.c +++ b/libopkg/opkg_cmd.c -@@ -878,7 +878,7 @@ +@@ -954,7 +954,7 @@ pkg_to_remove = pkg_hash_fetch_installed_by_name(&conf->pkg_hash, pkg->name ); } |