#include "pkg.h"
#include "opkg_utils.h"
#include "pkg_parse.h"
+#include "libbb/libbb.h"
int isGenericFieldType(char * type, char * line)
{
return NULL;
}
while(raw && *raw){
- depends = (char **)realloc(depends, sizeof(char *) * (line_count + 1));
+ depends = xrealloc(depends, sizeof(char *) * (line_count + 1));
while(isspace(*raw)) raw++;
if (!pkg->version)
{
- pkg->version= calloc(1, strlen(raw)+1);
- if ( pkg->version == NULL ) {
- fprintf(stderr, "%s: out of memory \n", __FUNCTION__);
- return ENOMEM;
- }
- strcpy(pkg->version, raw);
+ pkg->version= xcalloc(1, strlen(raw)+1);
+ strcpy(pkg->version, raw);
}
hyphen= strrchr(pkg->version,'-');
return 0;
}
-
-/* This code is needed to insert in first position the keyword for the aligning bug */
-
-int alterProvidesLine(char *raw, char *temp)
-{
-
-
- if (!*raw) {
- fprintf(stderr, "%s: ERROR: Provides string is empty", __FUNCTION__);
- return -EINVAL;
- }
-
- if ( temp == NULL ) {
- fprintf(stderr, "%s: out of memory \n", __FUNCTION__);
- return -ENOMEM;
- }
-
- if (strncmp(raw, "Provides:", 9) == 0) {
- raw += 9;
- }
- while (*raw && isspace(*raw)) {
- raw++;
- }
-
- snprintf ( temp, 35, "Provides: opkg_internal_use_only, "); /* First part of the line */
- while (*raw) {
- strncat( temp, raw++, 1);
- }
- return 0;
-
-}
-
/* Some random thoughts from Carl:
This function could be considerably simplified if we just kept
int pkg_parse_raw(pkg_t *pkg, char ***raw, 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;
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);
+ pkg->provides_str = parseDependsString(*lines, &pkg->provides_count);
}
else if(isGenericFieldType("Pre-Depends", *lines))
pkg->pre_depends_str = parseDependsString(*lines, &pkg->pre_depends_count);
case 'S':
if(isGenericFieldType("Section:", *lines))
pkg->section = parseGenericFieldType("Section", *lines);
+#ifdef HAVE_SHA256
+ else if(isGenericFieldType("SHA256sum:", *lines))
+ pkg->sha256sum = parseGenericFieldType("SHA256sum", *lines);
+#endif
else if(isGenericFieldType("Size:", *lines))
pkg->size = parseGenericFieldType("Size", *lines);
else if(isGenericFieldType("Source:", *lines))
case ' ':
if(reading_description) {
/* we already know it's not blank, so the rest of description */
- pkg->description = realloc(pkg->description,
+ pkg->description = xrealloc(pkg->description,
strlen(pkg->description)
+ 1 + strlen(*lines) + 1);
strcat(pkg->description, "\n");
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;