import.c
changeset 107 38f78baf0be9
parent 90 7bd64a40cb03
     1.1 --- a/import.c	Sat Dec 29 19:00:25 2007 -0500
     1.2 +++ b/import.c	Mon Feb 04 10:12:04 2008 -0500
     1.3 @@ -288,6 +288,25 @@
     1.4  	unsigned int *flags;
     1.5  };
     1.6  
     1.7 +static void
     1.8 +add_properties(struct razor_importer *importer,
     1.9 +	       enum razor_property_type property_type,
    1.10 +	       Header h, int_32 name_tag, int_32 version_tag, int_32 flags_tag)
    1.11 +{
    1.12 +	union rpm_entry names, versions, flags;
    1.13 +	int_32 i, type, count;
    1.14 +
    1.15 +	headerGetEntry(h, name_tag, &type, &names.p, &count);
    1.16 +	headerGetEntry(h, version_tag, &type, &versions.p, &count);
    1.17 +	headerGetEntry(h, flags_tag, &type, &flags.p, &count);
    1.18 +
    1.19 +	for (i = 0; i < count; i++)
    1.20 +		razor_importer_add_property(importer,
    1.21 +					    names.list[i],
    1.22 +					    versions.list[i],
    1.23 +					    property_type);
    1.24 +}
    1.25 +
    1.26  struct razor_set *
    1.27  razor_set_create_from_rpmdb(void)
    1.28  {
    1.29 @@ -296,7 +315,6 @@
    1.30  	Header h;
    1.31  	int_32 type, count, i;
    1.32  	union rpm_entry name, version, release;
    1.33 -	union rpm_entry property_names, property_versions, property_flags;
    1.34  	union rpm_entry basenames, dirnames, dirindexes;
    1.35  	char filename[PATH_MAX];
    1.36  	rpmdb db;
    1.37 @@ -319,53 +337,25 @@
    1.38  			 version.string, release.string);
    1.39  		razor_importer_begin_package(importer, name.string, filename);
    1.40  
    1.41 -		headerGetEntry(h, RPMTAG_REQUIRENAME, &type,
    1.42 -			       &property_names.p, &count);
    1.43 -		headerGetEntry(h, RPMTAG_REQUIREVERSION, &type,
    1.44 -			       &property_versions.p, &count);
    1.45 -		headerGetEntry(h, RPMTAG_REQUIREFLAGS, &type,
    1.46 -			       &property_flags.p, &count);
    1.47 -		for (i = 0; i < count; i++)
    1.48 -			razor_importer_add_property(importer,
    1.49 -						    property_names.list[i],
    1.50 -						    property_versions.list[i],
    1.51 -						    RAZOR_PROPERTY_REQUIRES);
    1.52 +		add_properties(importer, RAZOR_PROPERTY_REQUIRES, h,
    1.53 +			       RPMTAG_REQUIRENAME,
    1.54 +			       RPMTAG_REQUIREVERSION,
    1.55 +			       RPMTAG_REQUIREFLAGS);
    1.56  
    1.57 -		headerGetEntry(h, RPMTAG_PROVIDENAME, &type,
    1.58 -			       &property_names.p, &count);
    1.59 -		headerGetEntry(h, RPMTAG_PROVIDEVERSION, &type,
    1.60 -			       &property_versions.p, &count);
    1.61 -		headerGetEntry(h, RPMTAG_PROVIDEFLAGS, &type,
    1.62 -			       &property_flags.p, &count);
    1.63 -		for (i = 0; i < count; i++)
    1.64 -			razor_importer_add_property(importer,
    1.65 -						    property_names.list[i],
    1.66 -						    property_versions.list[i],
    1.67 -						    RAZOR_PROPERTY_PROVIDES);
    1.68 +		add_properties(importer, RAZOR_PROPERTY_PROVIDES, h,
    1.69 +			       RPMTAG_PROVIDENAME,
    1.70 +			       RPMTAG_PROVIDEVERSION,
    1.71 +			       RPMTAG_PROVIDEFLAGS);
    1.72  
    1.73 -		headerGetEntry(h, RPMTAG_OBSOLETENAME, &type,
    1.74 -			       &property_names.p, &count);
    1.75 -		headerGetEntry(h, RPMTAG_OBSOLETEVERSION, &type,
    1.76 -			       &property_versions.p, &count);
    1.77 -		headerGetEntry(h, RPMTAG_OBSOLETEFLAGS, &type,
    1.78 -			       &property_flags.p, &count);
    1.79 -		for (i = 0; i < count; i++)
    1.80 -			razor_importer_add_property(importer,
    1.81 -						    property_names.list[i],
    1.82 -						    property_versions.list[i],
    1.83 -						    RAZOR_PROPERTY_OBSOLETES);
    1.84 +		add_properties(importer, RAZOR_PROPERTY_OBSOLETES, h,
    1.85 +			       RPMTAG_OBSOLETENAME,
    1.86 +			       RPMTAG_OBSOLETEVERSION,
    1.87 +			       RPMTAG_OBSOLETEFLAGS);
    1.88  
    1.89 -		headerGetEntry(h, RPMTAG_CONFLICTNAME, &type,
    1.90 -			       &property_names.p, &count);
    1.91 -		headerGetEntry(h, RPMTAG_CONFLICTVERSION, &type,
    1.92 -			       &property_versions.p, &count);
    1.93 -		headerGetEntry(h, RPMTAG_CONFLICTFLAGS, &type,
    1.94 -			       &property_flags.p, &count);
    1.95 -		for (i = 0; i < count; i++)
    1.96 -			razor_importer_add_property(importer,
    1.97 -						    property_names.list[i],
    1.98 -						    property_versions.list[i],
    1.99 -						    RAZOR_PROPERTY_CONFLICTS);
   1.100 +		add_properties(importer, RAZOR_PROPERTY_CONFLICTS, h,
   1.101 +			       RPMTAG_CONFLICTNAME,
   1.102 +			       RPMTAG_CONFLICTVERSION,
   1.103 +			       RPMTAG_CONFLICTFLAGS);
   1.104  
   1.105  		headerGetEntry(h, RPMTAG_BASENAMES, &type,
   1.106  			       &basenames.p, &count);