diff options
-rw-r--r-- | package/opkg/Makefile | 2 | ||||
-rw-r--r-- | package/opkg/patches/008-fix_parsing_insanity.patch | 765 | ||||
-rw-r--r-- | package/opkg/patches/009-remove-upgrade.patch | 143 | ||||
-rw-r--r-- | package/opkg/patches/010-remove-flag.patch | 78 | ||||
-rw-r--r-- | package/opkg/patches/011-fix_nullpointer_deref.patch | 11 |
5 files changed, 998 insertions, 1 deletions
diff --git a/package/opkg/Makefile b/package/opkg/Makefile index 68bc8efe10..9b67e3982c 100644 --- a/package/opkg/Makefile +++ b/package/opkg/Makefile @@ -10,7 +10,7 @@ include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=opkg PKG_REV:=215 PKG_VERSION:=$(PKG_REV) -PKG_RELEASE:=2 +PKG_RELEASE:=3 PKG_SOURCE_PROTO:=svn PKG_SOURCE_VERSION:=$(PKG_REV) diff --git a/package/opkg/patches/008-fix_parsing_insanity.patch b/package/opkg/patches/008-fix_parsing_insanity.patch new file mode 100644 index 0000000000..f70d64f961 --- /dev/null +++ b/package/opkg/patches/008-fix_parsing_insanity.patch @@ -0,0 +1,765 @@ +--- 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); + + 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" +@@ -112,43 +114,50 @@ + 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) + { +- 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) == 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,297 @@ + + } + +-/* 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 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)) ++ pkg->section = parseGenericFieldType("Section", line); ++ else if(isGenericFieldType("Size:", line)) ++ pkg->size = parseGenericFieldType("Size", line); ++ else if(isGenericFieldType("Source:", line)) ++ 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)) ++ 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)) { ++ 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 */ ++ 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 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); + diff --git a/package/opkg/patches/009-remove-upgrade.patch b/package/opkg/patches/009-remove-upgrade.patch new file mode 100644 index 0000000000..1d2f4e91d7 --- /dev/null +++ b/package/opkg/patches/009-remove-upgrade.patch @@ -0,0 +1,143 @@ +--- 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 new file mode 100644 index 0000000000..d550ec7b31 --- /dev/null +++ b/package/opkg/patches/010-remove-flag.patch @@ -0,0 +1,78 @@ +--- a/libopkg/args.c ++++ b/libopkg/args.c +@@ -267,8 +267,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"); +- printf("\tflag <flag> <pkg> ... Flag package(s) <pkg>\n"); +- printf("\t <flag>=hold|noprune|user|ok|installed|unpacked (one per invocation) \n"); + + printf("\nInformational Commands:\n"); + 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); + 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}, + {"list_installed", 0, (opkg_cmd_fun_t)opkg_list_installed_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 @@ + return 0; + } + +-static int opkg_flag_cmd(opkg_conf_t *conf, int argc, char **argv) +-{ +- int i; +- pkg_t *pkg; +- const char *flags = argv[0]; +- +- global_conf = conf; +- signal(SIGINT, sigint_handler); +- +- for (i=1; i < argc; i++) { +- if (conf->restrict_to_default_dest) { +- pkg = pkg_hash_fetch_installed_by_name_dest(&conf->pkg_hash, +- argv[i], +- conf->default_dest); +- } else { +- pkg = pkg_hash_fetch_installed_by_name(&conf->pkg_hash, argv[i]); +- } +- +- if (pkg == NULL) { +- opkg_message(conf, OPKG_ERROR, +- "Package %s is not installed.\n", argv[i]); +- continue; +- } +- if (( strcmp(flags,"hold")==0)||( strcmp(flags,"noprune")==0)|| +- ( strcmp(flags,"user")==0)||( strcmp(flags,"ok")==0)) { +- pkg->state_flag = pkg_state_flag_from_str(flags); +- } +-/* pb_ asked this feature 03292004 */ +-/* Actually I will use only this two, but this is an open for various status */ +- if (( strcmp(flags,"installed")==0)||( strcmp(flags,"unpacked")==0)){ +- pkg->state_status = pkg_state_status_from_str(flags); +- } +- opkg_state_changed++; +- opkg_message(conf, OPKG_NOTICE, +- "Setting flags for package %s to %s\n", +- pkg->name, flags); +- } +- +- write_status_files_if_changed(conf); +- return 0; +-} +- + static int opkg_files_cmd(opkg_conf_t *conf, int argc, char **argv) + { + pkg_t *pkg; diff --git a/package/opkg/patches/011-fix_nullpointer_deref.patch b/package/opkg/patches/011-fix_nullpointer_deref.patch new file mode 100644 index 0000000000..1eecfd3ff0 --- /dev/null +++ b/package/opkg/patches/011-fix_nullpointer_deref.patch @@ -0,0 +1,11 @@ +--- a/libopkg/opkg_cmd.c ++++ b/libopkg/opkg_cmd.c +@@ -878,7 +878,7 @@ + pkg_to_remove = pkg_hash_fetch_installed_by_name(&conf->pkg_hash, pkg->name ); + } + +- if (pkg == NULL) { ++ if (pkg_to_remove == NULL) { + opkg_message(conf, OPKG_ERROR, "Package %s is not installed.\n", pkg->name); + continue; + } |