Import obsoletes and conflicts; add commands to list them.
authorKristian H?gsberg <krh@redhat.com>
Sat Nov 03 17:15:29 2007 -0400 (2007-11-03)
changeset 67cfe57117efee
parent 66 bb4ca4a47f66
child 68 0587f1759f09
Import obsoletes and conflicts; add commands to list them.
import.c
main.c
     1.1 --- a/import.c	Wed Oct 31 22:41:27 2007 -0400
     1.2 +++ b/import.c	Sat Nov 03 17:15:29 2007 -0400
     1.3 @@ -159,6 +159,8 @@
     1.4  	YUM_STATE_PACKAGE_NAME,
     1.5  	YUM_STATE_REQUIRES,
     1.6  	YUM_STATE_PROVIDES,
     1.7 +	YUM_STATE_OBSOLETES,
     1.8 +	YUM_STATE_CONFLICTS,
     1.9  	YUM_STATE_FILE
    1.10  };
    1.11  
    1.12 @@ -201,6 +203,10 @@
    1.13  		ctx->state = YUM_STATE_REQUIRES;
    1.14  	} else if (strcmp(name, "rpm:provides") == 0) {
    1.15  		ctx->state = YUM_STATE_PROVIDES;
    1.16 +	} else if (strcmp(name, "rpm:obsoletes") == 0) {
    1.17 +		ctx->state = YUM_STATE_OBSOLETES;
    1.18 +	} else if (strcmp(name, "rpm:conflicts") == 0) {
    1.19 +		ctx->state = YUM_STATE_CONFLICTS;
    1.20  	} else if (strcmp(name, "rpm:entry") == 0 &&
    1.21  		   ctx->state != YUM_STATE_BEGIN) {
    1.22  		n = NULL;
    1.23 @@ -238,6 +244,14 @@
    1.24  			razor_importer_add_property(ctx->importer, n, buffer,
    1.25  						    RAZOR_PROPERTY_PROVIDES);
    1.26  			break;
    1.27 +		case YUM_STATE_OBSOLETES:
    1.28 +			razor_importer_add_property(ctx->importer, n, buffer,
    1.29 +						    RAZOR_PROPERTY_OBSOLETES);
    1.30 +			break;
    1.31 +		case YUM_STATE_CONFLICTS:
    1.32 +			razor_importer_add_property(ctx->importer, n, buffer,
    1.33 +						    RAZOR_PROPERTY_CONFLICTS);
    1.34 +			break;
    1.35  		}
    1.36  	} else if (strcmp(name, "file") == 0) {
    1.37  		ctx->state = YUM_STATE_FILE;
    1.38 @@ -365,12 +379,38 @@
    1.39  			       &property_names.p, &count);
    1.40  		headerGetEntry(h, RPMTAG_PROVIDEVERSION, &type,
    1.41  			       &property_versions.p, &count);
    1.42 +		headerGetEntry(h, RPMTAG_PROVIDEFLAGS, &type,
    1.43 +			       &property_flags.p, &count);
    1.44  		for (i = 0; i < count; i++)
    1.45  			razor_importer_add_property(importer,
    1.46  						    property_names.list[i],
    1.47  						    property_versions.list[i],
    1.48  						    RAZOR_PROPERTY_PROVIDES);
    1.49  
    1.50 +		headerGetEntry(h, RPMTAG_OBSOLETENAME, &type,
    1.51 +			       &property_names.p, &count);
    1.52 +		headerGetEntry(h, RPMTAG_OBSOLETEVERSION, &type,
    1.53 +			       &property_versions.p, &count);
    1.54 +		headerGetEntry(h, RPMTAG_OBSOLETEFLAGS, &type,
    1.55 +			       &property_flags.p, &count);
    1.56 +		for (i = 0; i < count; i++)
    1.57 +			razor_importer_add_property(importer,
    1.58 +						    property_names.list[i],
    1.59 +						    property_versions.list[i],
    1.60 +						    RAZOR_PROPERTY_OBSOLETES);
    1.61 +
    1.62 +		headerGetEntry(h, RPMTAG_CONFLICTNAME, &type,
    1.63 +			       &property_names.p, &count);
    1.64 +		headerGetEntry(h, RPMTAG_CONFLICTVERSION, &type,
    1.65 +			       &property_versions.p, &count);
    1.66 +		headerGetEntry(h, RPMTAG_CONFLICTFLAGS, &type,
    1.67 +			       &property_flags.p, &count);
    1.68 +		for (i = 0; i < count; i++)
    1.69 +			razor_importer_add_property(importer,
    1.70 +						    property_names.list[i],
    1.71 +						    property_versions.list[i],
    1.72 +						    RAZOR_PROPERTY_CONFLICTS);
    1.73 +
    1.74  		headerGetEntry(h, RPMTAG_BASENAMES, &type,
    1.75  			       &basenames.p, &count);
    1.76  		headerGetEntry(h, RPMTAG_DIRNAMES, &type,
     2.1 --- a/main.c	Wed Oct 31 22:41:27 2007 -0400
     2.2 +++ b/main.c	Sat Nov 03 17:15:29 2007 -0400
     2.3 @@ -47,6 +47,30 @@
     2.4  }
     2.5  
     2.6  static int
     2.7 +command_list_obsoletes(int argc, const char *argv[])
     2.8 +{
     2.9 +	struct razor_set *set;
    2.10 +
    2.11 +	set = razor_set_open(repo_filename);
    2.12 +	razor_set_list_properties(set, argv[0], RAZOR_PROPERTY_OBSOLETES);
    2.13 +	razor_set_destroy(set);
    2.14 +
    2.15 +	return 0;
    2.16 +}
    2.17 +
    2.18 +static int
    2.19 +command_list_conflicts(int argc, const char *argv[])
    2.20 +{
    2.21 +	struct razor_set *set;
    2.22 +
    2.23 +	set = razor_set_open(repo_filename);
    2.24 +	razor_set_list_properties(set, argv[0], RAZOR_PROPERTY_CONFLICTS);
    2.25 +	razor_set_destroy(set);
    2.26 +
    2.27 +	return 0;
    2.28 +}
    2.29 +
    2.30 +static int
    2.31  command_list_files(int argc, const char *argv[])
    2.32  {
    2.33  	struct razor_set *set;
    2.34 @@ -210,8 +234,10 @@
    2.35  	int (*func)(int argc, const char *argv[]);
    2.36  } razor_commands[] = {
    2.37  	{ "list", "list all packages", command_list },
    2.38 -	{ "list-requires", "list all requires or requires for the given package", command_list_requires },
    2.39 -	{ "list-provides", "list all provides or provides for the give package", command_list_provides },
    2.40 +	{ "list-requires", "list all requires for the given package", command_list_requires },
    2.41 +	{ "list-provides", "list all provides for the give package", command_list_provides },
    2.42 +	{ "list-obsoletes", "list all obsoletes for the give package", command_list_obsoletes },
    2.43 +	{ "list-conflicts", "list all conflicts for the give package", command_list_conflicts },
    2.44  	{ "list-files", "list files for package set", command_list_files },
    2.45  	{ "list-file-packages", "list packages owning file", command_list_file_packages },
    2.46  	{ "list-package-files", "list files in package", command_list_package_files },