opkg: bump to r284 - incorporates parsing improvements upstream - fixes a couple...
authorJo-Philipp Wich <jow@openwrt.org>
Wed, 11 Nov 2009 21:42:05 +0000 (21:42 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Wed, 11 Nov 2009 21:42:05 +0000 (21:42 +0000)
SVN-Revision: 18380

package/opkg/Makefile
package/opkg/patches/001-fix-double-parsing.patch [deleted file]
package/opkg/patches/003-fs_overlay_support.patch
package/opkg/patches/004-host_cpu.patch
package/opkg/patches/005-uninitialized_err.patch
package/opkg/patches/007-force_static.patch
package/opkg/patches/008-fix_parsing_insanity.patch [deleted file]
package/opkg/patches/009-remove-upgrade-all.patch
package/opkg/patches/010-remove-flag.patch

index 9b67e3982c5484677ce64f4bfffd799e4ca5bd15..9c87e482c9268e227270dddb56d2850aa7c9ef9f 100644 (file)
@@ -8,9 +8,9 @@ include $(TOPDIR)/rules.mk
 include $(INCLUDE_DIR)/kernel.mk
 
 PKG_NAME:=opkg
-PKG_REV:=215
+PKG_REV:=284
 PKG_VERSION:=$(PKG_REV)
-PKG_RELEASE:=3
+PKG_RELEASE:=1
 
 PKG_SOURCE_PROTO:=svn
 PKG_SOURCE_VERSION:=$(PKG_REV)
diff --git a/package/opkg/patches/001-fix-double-parsing.patch b/package/opkg/patches/001-fix-double-parsing.patch
deleted file mode 100644 (file)
index a36ffa4..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
---- a/libopkg/args.c
-+++ b/libopkg/args.c
-@@ -62,7 +62,7 @@
-      if (conf_file_dir == NULL || conf_file_dir[0] == '\0') {
-         conf_file_dir = ARGS_DEFAULT_CONF_FILE_DIR;
-      }
--     sprintf_alloc(&args->conf_file, "%s/%s", conf_file_dir,
-+     sprintf_alloc(&args->conf_file, "%s/%s", OPKGETCDIR,
-                  ARGS_DEFAULT_CONF_FILE_NAME);
-      args->force_defaults = ARGS_DEFAULT_FORCE_DEFAULTS;
-
index 88a09d0a677b2a17ffd423fce89751a821974056..f84060ab1411507f2161084cd9cefdbc5b0d7cda 100644 (file)
@@ -6,7 +6,7 @@ Signed-off-by: Nicolas Thill <nico@openwrt.org>
 
 --- a/libopkg/opkg_conf.c
 +++ b/libopkg/opkg_conf.c
-@@ -70,6 +70,7 @@ int opkg_init_options_array(const opkg_c
+@@ -72,6 +72,7 @@
          { "offline_root_path", OPKG_OPT_TYPE_STRING, &conf->offline_root_path },
          { "offline_root_post_script_cmd", OPKG_OPT_TYPE_STRING, &conf->offline_root_post_script_cmd },
          { "offline_root_pre_script_cmd", OPKG_OPT_TYPE_STRING, &conf->offline_root_pre_script_cmd },
@@ -16,7 +16,7 @@ Signed-off-by: Nicolas Thill <nico@openwrt.org>
          { "query-all", OPKG_OPT_TYPE_BOOL, &conf->query_all },
 --- a/libopkg/opkg_conf.h
 +++ b/libopkg/opkg_conf.h
-@@ -70,6 +70,7 @@ struct opkg_conf
+@@ -70,6 +70,7 @@
       char *offline_root_path;
       char *offline_root_pre_script_cmd;
       char *offline_root_post_script_cmd;
@@ -26,7 +26,7 @@ Signed-off-by: Nicolas Thill <nico@openwrt.org>
       int noaction;
 --- a/libopkg/opkg_install.c
 +++ b/libopkg/opkg_install.c
-@@ -474,12 +474,15 @@ static int verify_pkg_installable(opkg_c
+@@ -470,12 +470,15 @@
       *    my diddling with the .opk file size below isn't going to cut it.
       * 3) return a proper error code instead of 1
       */
@@ -46,7 +46,7 @@ Signed-off-by: Nicolas Thill <nico@openwrt.org>
          /* round up a blocks count without doing fancy-but-slow casting jazz */ 
 --- a/libopkg/opkg_utils.c
 +++ b/libopkg/opkg_utils.c
-@@ -30,10 +30,8 @@ long unsigned int get_available_blocks(c
+@@ -31,10 +31,8 @@
  {
      struct statfs sfs;
  
index be4101eb8d813d74278fa474b1254dd43badd083..ad1c74c580137453f74dd64ae9b9609f555cf519 100644 (file)
@@ -12,9 +12,9 @@
 +++ b/libopkg/Makefile.am
 @@ -1,5 +1,5 @@
 -
--AM_CFLAGS=-Wall -Werror -DHOST_CPU_STR=\"@host_cpu@\" -DBUILD_CPU=@build_cpu@ -DLIBDIR=\"@libdir@\" -DOPKGLIBDIR=\"@opkglibdir@\" -DOPKGETCDIR=\"@opkgetcdir@\" -DDATADIR=\"@datadir@\" -I$(top_srcdir) $(BIGENDIAN_CFLAGS) $(CURL_CFLAGS) $(GPGME_CFLAGS)
+-AM_CFLAGS=-Wall -Werror -DHOST_CPU_STR=\"@host_cpu@\" -DBUILD_CPU=@build_cpu@ -DLIBDIR=\"@libdir@\" -DOPKGLIBDIR=\"@opkglibdir@\" -DOPKGETCDIR=\"@opkgetcdir@\" -DDATADIR=\"@datadir@\" -I$(top_srcdir) $(BIGENDIAN_CFLAGS) $(CURL_CFLAGS) $(GPGME_CFLAGS) $(PATHFINDER_CFLAGS)
 +HOST_CPU=@host_cpu@
-+AM_CFLAGS=-Wall -Werror -DHOST_CPU_STR=\"$(HOST_CPU)\" -DBUILD_CPU=@build_cpu@ -DLIBDIR=\"@libdir@\" -DOPKGLIBDIR=\"@opkglibdir@\" -DOPKGETCDIR=\"@opkgetcdir@\" -DDATADIR=\"@datadir@\" -I$(top_srcdir) $(BIGENDIAN_CFLAGS) $(CURL_CFLAGS) $(GPGME_CFLAGS)
++AM_CFLAGS=-Wall -Werror -DHOST_CPU_STR=\"$(HOST_CPU)\" -DBUILD_CPU=@build_cpu@ -DLIBDIR=\"@libdir@\" -DOPKGLIBDIR=\"@opkglibdir@\" -DOPKGETCDIR=\"@opkgetcdir@\" -DDATADIR=\"@datadir@\" -I$(top_srcdir) $(BIGENDIAN_CFLAGS) $(CURL_CFLAGS) $(GPGME_CFLAGS) $(PATHFINDER_CFLAGS)
  
  libopkg_includedir=$(includedir)/libopkg
  libopkg_include_HEADERS= opkg.h
index 7cf769a321cedb991b6b38d0e5500835754aaace..0d3b6cf24cc2d718e45a6da85dedc8049b2b729c 100644 (file)
@@ -1,6 +1,6 @@
 --- a/libopkg/pkg_hash.c
 +++ b/libopkg/pkg_hash.c
-@@ -363,8 +363,11 @@ pkg_t *pkg_hash_fetch_best_installation_
+@@ -384,8 +384,11 @@
       abstract_pkg_t *apkg = NULL;
       pkg_t *ret;
  
index b433eed05ea9646eb3530fb1fae866bc386d061f..632250863892df3a36100dd28e36a644f6a7695d 100644 (file)
@@ -1,8 +1,8 @@
 --- a/libopkg/Makefile.am
 +++ b/libopkg/Makefile.am
-@@ -30,15 +30,10 @@ opkg_util_sources = file_util.c file_uti
-                   sprintf_alloc.c sprintf_alloc.h str_util.c str_util.h \
-                   xregex.c xregex.h xsystem.c xsystem.h
+@@ -36,16 +36,10 @@
+ opkg_util_sources += sha256.c sha256.h
+ endif
  
 -lib_LTLIBRARIES = libopkg.la
 -libopkg_la_SOURCES = \
        $(opkg_cmd_sources) $(opkg_db_sources) \
        $(opkg_util_sources) $(opkg_list_sources)
  
--libopkg_la_LIBADD = $(top_builddir)/libbb/libbb.la $(CURL_LIBS) $(GPGME_LIBS)
+-libopkg_la_LIBADD = $(top_builddir)/libbb/libbb.la $(CURL_LIBS) $(GPGME_LIBS) $(OPENSSL_LIBS) $(PATHFINDER_LIBS)
+-
 -# make sure we only export symbols that are for public use
 -libopkg_la_LDFLAGS = -export-symbols-regex "^opkg_.*"
 -
 -
 -
-+libopkg_a_LIBADD = $(top_builddir)/libbb/libbb.a $(CURL_LIBS) $(GPGME_LIBS)
++libopkg_a_LIBADD = $(top_builddir)/libbb/libbb.a $(CURL_LIBS) $(GPGME_LIBS) $(OPENSSL_LIBS) $(PATHFINDER_LIBS)
 --- a/libbb/Makefile.am
 +++ b/libbb/Makefile.am
-@@ -2,9 +2,9 @@ HOST_CPU=@host_cpu@
+@@ -2,9 +2,9 @@
  BUILD_CPU=@build_cpu@
  ALL_CFLAGS=-g -O -Wall -DHOST_CPU_STR=\"$(HOST_CPU)\" -DBUILD_CPU=@build_cpu@
  
        wfopen.c \
 --- a/src/Makefile.am
 +++ b/src/Makefile.am
-@@ -2,5 +2,5 @@ AM_CFLAGS = -I${top_srcdir}/libopkg ${AL
+@@ -2,5 +2,5 @@
  bin_PROGRAMS = opkg-cl
  
  opkg_cl_SOURCES = opkg-frontend.c
 -opkg_cl_LDADD = $(top_builddir)/libopkg/libopkg.la \
 -                $(top_builddir)/libbb/libbb.la 
 +opkg_cl_LDADD = $(top_builddir)/libopkg/libopkg.a \
-+                $(top_builddir)/libbb/libbb.a 
++                $(top_builddir)/libbb/libbb.a
 --- a/tests/Makefile.am
 +++ b/tests/Makefile.am
-@@ -16,7 +16,7 @@ noinst_PROGRAMS = libopkg_test
+@@ -16,7 +16,7 @@
  #opkg_active_list_test_SOURCES = opkg_active_list_test.c
  #opkg_active_list_test_CFLAGS = $(ALL_CFLAGS) -I$(top_srcdir)
  
diff --git a/package/opkg/patches/008-fix_parsing_insanity.patch b/package/opkg/patches/008-fix_parsing_insanity.patch
deleted file mode 100644 (file)
index 5e5c008..0000000
+++ /dev/null
@@ -1,931 +0,0 @@
---- a/libopkg/opkg_utils.c
-+++ b/libopkg/opkg_utils.c
-@@ -44,58 +44,6 @@
-     return 0;
- }
--char **read_raw_pkgs_from_file(const char *file_name)
--{
--     FILE *fp; 
--     char **ret;
--    
--     if(!(fp = fopen(file_name, "r"))){
--        fprintf(stderr, "can't get %s open for read\n", file_name);
--        return NULL;
--     }
--
--     ret = read_raw_pkgs_from_stream(fp);
--
--     fclose(fp);
--
--     return ret;
--}
--
--char **read_raw_pkgs_from_stream(FILE *fp)
--{    
--     char **raw = NULL, *buf, *scout;
--     int count = 0;
--     size_t size = 512;
--     
--     buf = calloc (1, size);
--
--     while (fgets(buf, size, fp)) {
--        while (strlen (buf) == (size - 1)
--               && buf[size-2] != '\n') {
--             size_t o = size - 1;
--             size *= 2;
--             buf = realloc (buf, size);
--             if (fgets (buf + o, size - o, fp) == NULL)
--                  break;
--        }
--        
--        if(!(count % 50))
--             raw = realloc(raw, (count + 50) * sizeof(char *));
--      
--        if((scout = strchr(buf, '\n')))
--             *scout = '\0';
--
--        raw[count++] = strdup(buf);
--     }
--    
--     raw = realloc(raw, (count + 1) * sizeof(char *));
--     raw[count] = NULL;
--
--     free (buf);
--    
--     return raw;
--}
--
- /* something to remove whitespace, a hash pooper */
- char *trim_alloc(char *line)
- {
---- a/libopkg/pkg.c
-+++ b/libopkg/pkg.c
-@@ -20,6 +20,8 @@
- #include <alloca.h>
- #include <string.h>
- #include <stdbool.h>
-+#include <unistd.h>
-+#include <fcntl.h>
- #include <errno.h>
- #include "pkg.h"
-@@ -277,7 +279,6 @@
- int pkg_init_from_file(pkg_t *pkg, const char *filename)
- {
-      int err;
--     char **raw;
-      FILE *control_file;
-      err = pkg_init(pkg);
-@@ -290,8 +291,7 @@
-      if (err) { return err; }
-      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, 0);
-      fclose(control_file);
-@@ -459,8 +459,7 @@
- void set_flags_from_control(opkg_conf_t *conf, pkg_t *pkg){
-      char * temp_str;
--     char **raw =NULL;
--     char **raw_start=NULL; 
-+     int fd;
-      size_t str_size = strlen(pkg->dest->info_dir)+strlen(pkg->name)+12;
-      temp_str = (char *) alloca (str_size);
-@@ -471,28 +470,23 @@
-         return;
-      }
-      sprintf( temp_str,"%s/%s.control",pkg->dest->info_dir,pkg->name);
--   
--     raw = raw_start = read_raw_pkgs_from_file(temp_str);
--     if (raw == NULL ){
--        opkg_message(conf, OPKG_ERROR, "Unable to open the control file in  %s\n", __FUNCTION__);
--        return;
--     }
--     while(*raw){
--        if (!pkg_valorize_other_field(pkg, &raw ) == 0) {
--            opkg_message(conf, OPKG_DEBUG, "unable to read control file for %s. May be empty\n", pkg->name);
--        }
--     }
--     raw = raw_start;
--     while (*raw) {
--        if (raw!=NULL)
--          free(*raw++);
--     }
-+      if( (fd = open(temp_str, O_RDONLY)) > 0 )
-+      {
-+              if( pkg_valorize_other_field(pkg, fd) )
-+              {
-+                      opkg_message(conf, OPKG_DEBUG, "unable to read control file for %s. May be empty\n", pkg->name);
-+              }
--     free(raw_start); 
-+              close(fd);
-+      }
-+      else
-+      {
-+              opkg_message(conf, OPKG_ERROR, "Unable to open the control file in  %s\n", __FUNCTION__);
-+              return;
-+      }
-      return ;
--
- }
- #define CHECK_BUFF_SIZE(buff, line, buf_size, page_size) do { \
---- a/libopkg/pkg_hash.c
-+++ b/libopkg/pkg_hash.c
-@@ -20,6 +20,8 @@
- #include <ctype.h>
- #include <stdlib.h>
- #include <string.h>
-+#include <unistd.h>
-+#include <fcntl.h>
- #include "hash_table.h"
- #include "pkg.h"
-@@ -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, int no_desc)
- {
--     hash_table_t *hash = &conf->pkg_hash;
--     char **raw;
--     char **raw_start;
--     pkg_t *pkg;
--    
--     raw = raw_start = read_raw_pkgs_from_file(file_name);
--     if (!raw)
--        return -ENOMEM;
--
--     while(*raw){         /* don't worry, we'll increment raw in the parsing function */
--        pkg = pkg_new();
--        if (!pkg)
--             return -ENOMEM;
--
--        if (pkg_parse_raw(pkg, &raw, src, dest) == 0) {
--             if (!pkg->architecture) {
--                  char *version_str = pkg_version_str_alloc(pkg);
--                  pkg->architecture = pkg_get_default_arch(conf);
--                  opkg_message(conf, OPKG_ERROR, "Package %s version %s has no architecture specified, defaulting to %s.\n",
--                               pkg->name, version_str, pkg->architecture);
--                  free(version_str);
--             }
--             hash_insert_pkg(hash, pkg, is_status_file,conf);
--        } else {
--             pkg_deinit (pkg);
--             free(pkg);
--        }
--     }
-+      hash_table_t *hash = &conf->pkg_hash;
-+      pkg_t *pkg;
--     /* XXX: CLEANUP: I'd like a cleaner interface for cleaning up
--      memory after read_raw_pkgs_from_file */
--     raw = raw_start;
--     while (*raw) {
--        free(*raw++);
--     }
--     free(raw_start);
--     return 0;
-+      int fd;
-+      int rv = 0;
-+
-+      if( (fd = open(file_name, O_RDONLY)) > 0 )
-+      {
-+              while(1)
-+              {
-+                      pkg = pkg_new();
-+                      if(!pkg) {
-+                              rv = -ENOMEM;
-+                              break;
-+                      }
-+
-+                      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);
-+                                      opkg_message(conf, OPKG_ERROR, "Package %s version %s has no architecture specified, defaulting to %s.\n",
-+                                      pkg->name, version_str, pkg->architecture);
-+                                      free(version_str);
-+                              }
-+
-+                              hash_insert_pkg(hash, pkg, is_status_file, conf);
-+                      } else {
-+                              pkg_deinit (pkg);
-+                              free(pkg);
-+                              break;
-+                      }
-+              }
-+
-+              close(fd);
-+      }
-+      else
-+      {
-+              opkg_message (conf, OPKG_ERROR,
-+                      "Unable to open package list %s\n", file_name);
-+
-+              rv = -EINVAL;
-+      }
-+ 
-+      return rv;
- }
- 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,301 @@
-  
- }
--/* Some random thoughts from Carl:
--
--   This function could be considerably simplified if we just kept
--   an array of all the generic string-valued field names, and looped
--   through those looking for a match. Also, these fields could perhaps
--   be stored in the package as an array as well, (or, probably better,
--   as an nv_pair_list_t).
--
--   Fields which require special parsing or storage, (such as Depends:
--   and Status:) could be handled as they are now. 
--*/
--/* XXX: FEATURE: The Suggests: field needs to be changed from a string
--   to a dependency list. And, since we already have
--   Depends/Pre-Depends and need to add Conflicts, Recommends, and
--   Enhances, perhaps we could generalize all of these and save some
--   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 no_desc)
- {
--    int reading_conffiles, reading_description;
--    int pkg_false_provides=1;
--    char ** lines;
--    char * provide=NULL;
--
--    pkg->src = src;
--    pkg->dest = dest;
--
--    reading_conffiles = reading_description = 0;
--
--    for (lines = *raw; *lines; lines++) {
--      /*      fprintf(stderr, "PARSING %s\n", *lines);*/
--      switch (**lines) {
--      case 'P':
--          if(isGenericFieldType("Package:", *lines)) 
--              pkg->name = parseGenericFieldType("Package", *lines);
--          else if(isGenericFieldType("Priority:", *lines))
--              pkg->priority = parseGenericFieldType("Priority", *lines);
--          else if(isGenericFieldType("Provides", *lines)){
--/* Here we add the internal_use to align the off by one problem between provides_str and provides */
--              provide = (char * ) calloc(1, strlen(*lines)+ 35 ); /* Preparing the space for the new opkg_internal_use_only */
--              if ( alterProvidesLine(*lines,provide) ){
--                  return EINVAL;
--              }
--              pkg->provides_str = parseDependsString( provide, &pkg->provides_count);
--/* Let's try to hack a bit here.
--   The idea is that if a package has no Provides, we would add one generic, to permit the check of dependencies
--   in alot of other places. We will remove it before writing down the status database */
--              pkg_false_provides=0;
--              free(provide);
--          } 
--          else if(isGenericFieldType("Pre-Depends", *lines))
--              pkg->pre_depends_str = parseDependsString(*lines, &pkg->pre_depends_count);
--          break;
--
--      case 'A':
--          if(isGenericFieldType("Architecture:", *lines))
--              pkg->architecture = parseGenericFieldType("Architecture", *lines);
--          else if(isGenericFieldType("Auto-Installed:", *lines)) {
--              char *auto_installed_value;
--              auto_installed_value = parseGenericFieldType("Auto-Installed:", *lines);
--              if (strcmp(auto_installed_value, "yes") == 0) {
--                  pkg->auto_installed = 1;
--              }
--              free(auto_installed_value);
--          }
--          break;
--
--      case 'F':
--          if(isGenericFieldType("Filename:", *lines))
--              pkg->filename = parseGenericFieldType("Filename", *lines);
--          break;
--
--      case 'S':
--          if(isGenericFieldType("Section:", *lines))
--              pkg->section = parseGenericFieldType("Section", *lines);
--          else if(isGenericFieldType("Size:", *lines))
--              pkg->size = parseGenericFieldType("Size", *lines);
--          else if(isGenericFieldType("Source:", *lines))
--              pkg->source = parseGenericFieldType("Source", *lines);
--          else if(isGenericFieldType("Status", *lines))
--              parseStatus(pkg, *lines);
--          else if(isGenericFieldType("Suggests", *lines))
--              pkg->suggests_str = parseDependsString(*lines, &pkg->suggests_count);
--          break;
--
--      case 'T':
--          if(isGenericFieldType("Tags:", *lines))
--              pkg->tags = parseGenericFieldType("Tags", *lines);
--          break;
--
--      case 'M':
--          if(isGenericFieldType("MD5sum:", *lines))
--              pkg->md5sum = parseGenericFieldType("MD5sum", *lines);
--          /* The old opkg wrote out status files with the wrong case for MD5sum,
--              let's parse it either way */
--          else if(isGenericFieldType("MD5Sum:", *lines))
--              pkg->md5sum = parseGenericFieldType("MD5Sum", *lines);
--          else if(isGenericFieldType("Maintainer", *lines))
--              pkg->maintainer = parseGenericFieldType("Maintainer", *lines);
--          break;
--
--      case 'I':
--          if(isGenericFieldType("Installed-Size:", *lines))
--              pkg->installed_size = parseGenericFieldType("Installed-Size", *lines);
--          else if(isGenericFieldType("Installed-Time:", *lines)) {
--              char *time_str = parseGenericFieldType("Installed-Time", *lines);
--              pkg->installed_time = strtoul(time_str, NULL, 0);
--              free (time_str);
--          }       
--          break;
--
--      case 'E':
--          if(isGenericFieldType("Essential:", *lines)) {
--              char *essential_value;
--              essential_value = parseGenericFieldType("Essential", *lines);
--              if (strcmp(essential_value, "yes") == 0) {
--                  pkg->essential = 1;
--              }
--              free(essential_value);
--          }
--          break;
--
--      case 'V':
--          if(isGenericFieldType("Version", *lines))
--              parseVersion(pkg, *lines);
--          break;
--
--      case 'C':
--          if(isGenericFieldType("Conffiles", *lines)){
--              parseConffiles(pkg, *lines);
--              reading_conffiles = 1;
--          }
--          else if(isGenericFieldType("Conflicts", *lines))
--              pkg->conflicts_str = parseDependsString(*lines, &pkg->conflicts_count);
--          break;
--
--      case 'D':
--          if(isGenericFieldType("Description", *lines)) {
--              pkg->description = parseGenericFieldType("Description", *lines);
--              reading_conffiles = 0;
--              reading_description = 1;
--          }
--          else if(isGenericFieldType("Depends", *lines))
--              pkg->depends_str = parseDependsString(*lines, &pkg->depends_count);
--          break;
--
--      case 'R':
--          if(isGenericFieldType("Recommends", *lines))
--              pkg->recommends_str = parseDependsString(*lines, &pkg->recommends_count);
--          else if(isGenericFieldType("Replaces", *lines))
--              pkg->replaces_str = parseDependsString(*lines, &pkg->replaces_count);
--          
--          break;
--
--      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(*lines) + 1);
--              strcat(pkg->description, "\n");
--              strcat(pkg->description, (*lines));
--          }
--          else if(reading_conffiles)
--              parseConffiles(pkg, *lines);
--              
--          break;
--
--      default:
--          if(line_is_blank(*lines)) {
--              lines++;
--              goto out;
--          }
-+      char buf[4096];
-+      char line[4096];
-+      char *nl;
-+      int bsz = 0;
-+      int eof = 0;
-+      int rv = EINVAL;
-+
-+      int reading_conffiles, reading_description;
-+      int pkg_false_provides=1;
-+      char *provide = NULL;
-+
-+      pkg->src = src;
-+      pkg->dest = dest;
-+
-+      reading_conffiles = reading_description = 0;
-+
-+      memset(buf, 0, sizeof(buf));
-+
-+      while(!eof || (bsz > 0))
-+      {
-+              if(!eof)
-+              {
-+                      rv = read(fd, &buf[bsz], sizeof(buf) - bsz - 1);
-+
-+                      if( rv == 0 )
-+                      {
-+                              eof = 1;
-+
-+                              if( bsz == 0 )
-+                              {
-+                                      rv = EINVAL;
-+                                      break;
-+                              }
-+                      }
-+                      else if( rv < 0 )
-+                      {
-+                              /*opkg_message(conf, OPKG_ERROR, "I/O error while parsing package list\n");*/
-+                              printf("I/O error while parsing package list\n");
-+                              rv = EINVAL;
-+                              break;
-+                      }
-+                      else
-+                      {
-+                              bsz += rv;
-+                              buf[bsz] = 0;
-+                              rv = 0;
-+                      }
-+              }
-+
-+              if( (nl = strchr(buf, '\n')) != NULL )
-+              {
-+                      bsz -= (int)(nl - buf) + 1;
-+
-+                      memset(line, 0, sizeof(line));
-+                      memcpy(line, buf, (int)(nl - buf));
-+                      memmove(buf, &buf[(int)(nl - buf) + 1], bsz);
-+
-+                      switch(line[0])
-+                      {
-+                              case 'P':
-+                                      if(isGenericFieldType("Package:", line)) 
-+                                              pkg->name = parseGenericFieldType("Package", line);
-+                                      else if(isGenericFieldType("Priority:", line))
-+                                              pkg->priority = parseGenericFieldType("Priority", line);
-+                                      else if(isGenericFieldType("Provides", line)){
-+                                              /* Here we add the internal_use to align the off by one problem between provides_str and provides */
-+                                              provide = (char * ) calloc(1, strlen(line)+ 35 ); /* Preparing the space for the new opkg_internal_use_only */
-+                                              if ( alterProvidesLine(line,provide) ){
-+                                                      rv = EINVAL;
-+                                                      break;
-+                                              }
-+                                              pkg->provides_str = parseDependsString( provide, &pkg->provides_count);
-+                                              /* Let's try to hack a bit here.
-+                                                 The idea is that if a package has no Provides, we would add one generic, to permit the check of dependencies
-+                                                 in alot of other places. We will remove it before writing down the status database */
-+                                              pkg_false_provides=0;
-+                                              free(provide);
-+                                      }
-+                                      else if(isGenericFieldType("Pre-Depends", line))
-+                                              pkg->pre_depends_str = parseDependsString(line, &pkg->pre_depends_count);
-+                                              break;
-+
-+                              case 'A':
-+                                      if(isGenericFieldType("Architecture:", line))
-+                                              pkg->architecture = parseGenericFieldType("Architecture", line);
-+                                      else if(isGenericFieldType("Auto-Installed:", line)) {
-+                                              char *auto_installed_value;
-+                                              auto_installed_value = parseGenericFieldType("Auto-Installed:", line);
-+                                              if (strcmp(auto_installed_value, "yes") == 0) {
-+                                                      pkg->auto_installed = 1;
-+                                              }
-+                                              free(auto_installed_value);
-+                                      }
-+                                      break;
-+
-+                              case 'F':
-+                                      if(isGenericFieldType("Filename:", line))
-+                                              pkg->filename = parseGenericFieldType("Filename", line);
-+                                      break;
-+
-+                              case 'S':
-+                                      if(isGenericFieldType("Section:", line) && !no_desc)
-+                                              pkg->section = parseGenericFieldType("Section", line);
-+                                      else if(isGenericFieldType("Size:", line))
-+                                              pkg->size = parseGenericFieldType("Size", line);
-+                                      else if(isGenericFieldType("Source:", line) && !no_desc)
-+                                              pkg->source = parseGenericFieldType("Source", line);
-+                                      else if(isGenericFieldType("Status", line))
-+                                              parseStatus(pkg, line);
-+                                      else if(isGenericFieldType("Suggests", line))
-+                                              pkg->suggests_str = parseDependsString(line, &pkg->suggests_count);
-+                                      break;
-+
-+                              case 'T':
-+                                      if(isGenericFieldType("Tags:", line))
-+                                              pkg->tags = parseGenericFieldType("Tags", line);
-+                                      break;
-+
-+                              case 'M':
-+                                      if(isGenericFieldType("MD5sum:", line))
-+                                              pkg->md5sum = parseGenericFieldType("MD5sum", line);
-+                                      /* The old opkg wrote out status files with the wrong case for MD5sum,
-+                                         let's parse it either way */
-+                                      else if(isGenericFieldType("MD5Sum:", line))
-+                                              pkg->md5sum = parseGenericFieldType("MD5Sum", line);
-+                                      else if(isGenericFieldType("Maintainer", line) && !no_desc)
-+                                              pkg->maintainer = parseGenericFieldType("Maintainer", line);
-+                                      break;
-+
-+                              case 'I':
-+                                      if(isGenericFieldType("Installed-Size:", line))
-+                                              pkg->installed_size = parseGenericFieldType("Installed-Size", line);
-+                                      else if(isGenericFieldType("Installed-Time:", line)) {
-+                                              char *time_str = parseGenericFieldType("Installed-Time", line);
-+                                              pkg->installed_time = strtoul(time_str, NULL, 0);
-+                                              free (time_str);
-+                                      }           
-+                                      break;
-+
-+                              case 'E':
-+                                      if(isGenericFieldType("Essential:", line)) {
-+                                              char *essential_value;
-+                                              essential_value = parseGenericFieldType("Essential", line);
-+                                              if (strcmp(essential_value, "yes") == 0) {
-+                                                      pkg->essential = 1;
-+                                              }
-+                                              free(essential_value);
-+                                      }
-+                                      break;
-+
-+                              case 'V':
-+                                      if(isGenericFieldType("Version", line))
-+                                              parseVersion(pkg, line);
-+                                      break;
-+
-+                              case 'C':
-+                                      if(isGenericFieldType("Conffiles", line)){
-+                                              parseConffiles(pkg, line);
-+                                              reading_conffiles = 1;
-+                                      }
-+                                      else if(isGenericFieldType("Conflicts", line))
-+                                              pkg->conflicts_str = parseDependsString(line, &pkg->conflicts_count);
-+                                      break;
-+
-+                              case 'D':
-+                                      if(isGenericFieldType("Description", line)) {
-+                                              if(!no_desc)
-+                                                      pkg->description = parseGenericFieldType("Description", line);
-+                                              reading_conffiles = 0;
-+                                              reading_description = 1;
-+                                      }
-+                                      else if(isGenericFieldType("Depends", line))
-+                                              pkg->depends_str = parseDependsString(line, &pkg->depends_count);
-+                                      break;
-+
-+                              case 'R':
-+                                      if(isGenericFieldType("Recommends", line))
-+                                              pkg->recommends_str = parseDependsString(line, &pkg->recommends_count);
-+                                      else if(isGenericFieldType("Replaces", line))
-+                                              pkg->replaces_str = parseDependsString(line, &pkg->replaces_count);
-+                                      break;
-+
-+                              case ' ':
-+                                      if(reading_description) {
-+                                              /* 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);
-+                                      break;
-+
-+                              default:
-+                                      if(line_is_blank(line))
-+                                              goto out;
-+                      }
-+              }
-+              else
-+              {
-+                      /*opkg_message(conf, OPKG_ERROR, "Buffer exceeded while parsing line:\n[%s]\n", buf);*/
-+                      printf("Buffer exceeded while parsing line:\n[%s]\n", buf);
-+                      rv = EINVAL;
-+                      break;
-+              }
-       }
--    }
--out:;
--    
--    *raw = lines;
--/* If the opk has not a Provides line, we insert our false line */ 
--    if ( pkg_false_provides==1)
--    {
--       pkg->provides_count = 1;
--       pkg->provides_str = calloc (1, sizeof (char*));
--       pkg->provides_str[0] = strdup ("opkg_internal_use_only");
--    }
--
--    if (pkg->name) {
--      return 0;
--    } else {
--      return EINVAL;
--    }
-+
-+      out:
-+
-+      if (bsz)
-+              lseek(fd, -(off_t)bsz, SEEK_CUR);
-+
-+      if (!rv && pkg->name)
-+              return 0;
-+      else
-+              return EINVAL;
- }
--int pkg_valorize_other_field(pkg_t *pkg, char ***raw)
-+int pkg_valorize_other_field(pkg_t *pkg, int fd)
- {
--    char ** lines;
-+      char buf[4096];
-+      char line[4096];
-+      char *nl;
-+      int bsz = 0;
-+      int eof = 0;
-+      int rv = EINVAL;
-+
-+      memset(buf, 0, sizeof(buf));
-+
-+      while(!eof || (bsz > 0))
-+      {
-+              if(!eof)
-+              {
-+                      rv = read(fd, &buf[bsz], sizeof(buf) - bsz - 1);
-+
-+                      if( rv == 0 )
-+                      {
-+                              eof = 1;
-+
-+                              if( bsz == 0 )
-+                              {
-+                                      rv = EINVAL;
-+                                      break;
-+                              }
-+                      }
-+                      else if( rv < 0 )
-+                      {
-+                              rv = EINVAL;
-+                              break;
-+                      }
-+                      else
-+                      {
-+                              bsz += rv;
-+                              buf[bsz] = 0;
-+                              rv = 0;
-+                      }
-+              }
--    for (lines = *raw; *lines; lines++) {
--      if(isGenericFieldType("Essential:", *lines)) {
--          char *essential_value;
--          essential_value = parseGenericFieldType("Essential", *lines);
--          if (strcmp(essential_value, "yes") == 0) {
--              pkg->essential = 1;
--          }
--          free(essential_value);
-+              if( (nl = strchr(buf, '\n')) != NULL )
-+              {
-+                      bsz -= (int)(nl - buf) + 1;
-+
-+                      memset(line, 0, sizeof(line));
-+                      memcpy(line, buf, (int)(nl - buf));
-+                      memmove(buf, &buf[(int)(nl - buf) + 1], bsz);
-+
-+                      if(isGenericFieldType("Essential:", line))
-+                      {
-+                              char *essential_value;
-+                              essential_value = parseGenericFieldType("Essential", line);
-+                              if (strcmp(essential_value, "yes") == 0) {
-+                                      pkg->essential = 1;
-+                              }
-+                              free(essential_value);
-+                      }
-+              }
-+              else
-+              {
-+                      rv = EINVAL;
-+                      break;
-+              }
-       }
--    }
--    *raw = lines;
--    return 0;
-+      if (bsz)
-+              lseek(fd, -(off_t)bsz, SEEK_CUR);
-+
-+      if (!rv && pkg->name)
-+              return 0;
-+      else
-+              return EINVAL;
- }
-+
---- a/libopkg/pkg_parse.h
-+++ b/libopkg/pkg_parse.h
-@@ -25,7 +25,7 @@
- char ** parseDependsString(char * raw, int * depends_count);
- int parseVersion(pkg_t *pkg, char *raw);
- 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 no_desc);
-+int pkg_valorize_other_field(pkg_t *pkg, int fd);
- #endif
---- a/libopkg/opkg_utils.h
-+++ b/libopkg/opkg_utils.h
-@@ -26,8 +26,6 @@
- void free_error_list();
- long unsigned int get_available_blocks(char * filesystem);
--char **read_raw_pkgs_from_file(const char *file_name);
--char **read_raw_pkgs_from_stream(FILE *fp);
- 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);
index 320f7100585316b29596bdadc6934bc731b426b6..d2440e031f74c8254753a3cbc0a7691a69cc08bb 100644 (file)
@@ -1,6 +1,6 @@
 --- a/libopkg/args.c
 +++ b/libopkg/args.c
-@@ -263,7 +263,7 @@
+@@ -259,7 +259,7 @@
      
       printf("\nPackage Manipulation:\n");
       printf("\tupdate                 Update list of available packages\n");
@@ -11,7 +11,7 @@
       printf("\tconfigure [<pkg>]      Configure unpacked packages\n");
 --- a/libopkg/opkg_cmd.c
 +++ b/libopkg/opkg_cmd.c
-@@ -79,7 +79,7 @@
+@@ -75,7 +75,7 @@
     array for easier maintenance */
  static opkg_cmd_t cmds[] = {
       {"update", 0, (opkg_cmd_fun_t)opkg_update_cmd}, 
@@ -20,7 +20,7 @@
       {"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 @@
+@@ -607,17 +607,6 @@
                    opkg_install_by_name(conf, arg);
                 }
          }
@@ -37,4 +37,4 @@
 -        pkg_vec_free(installed);
       }
  
-      /* recheck to verify that all dependences are satisfied */
+      opkg_configure_packages(conf, NULL);
index 20bebda4b680c1f1ef121d50e77eca80ae725e79..9b988b89e0f9a74c3489bffddbc71de16a0da879 100644 (file)
@@ -1,6 +1,6 @@
 --- a/libopkg/args.c
 +++ b/libopkg/args.c
-@@ -268,8 +268,6 @@
+@@ -264,8 +264,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,7 +11,7 @@
       printf("\tlist                   List available packages and descriptions\n");
 --- a/libopkg/opkg_cmd.c
 +++ b/libopkg/opkg_cmd.c
-@@ -58,7 +58,6 @@
+@@ -54,7 +54,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);
@@ -19,7 +19,7 @@
  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);
-@@ -84,7 +83,6 @@
+@@ -80,7 +79,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},
@@ -27,7 +27,7 @@
       {"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},
-@@ -1050,48 +1048,6 @@
+@@ -960,48 +958,6 @@
       return 0;
  }