main.c
changeset 44 3d1a1517fa1d
parent 43 d37d57c99cac
child 45 6b5f03f1c084
     1.1 --- a/main.c	Sun Sep 30 00:18:20 2007 -0400
     1.2 +++ b/main.c	Fri Oct 05 16:26:27 2007 -0400
     1.3 @@ -7,7 +7,8 @@
     1.4  #include "razor.h"
     1.5  
     1.6  static const char *repo_filename = "system.repo";
     1.7 -static const char rawhide_repo_filename[] = "rawhide.repo";
     1.8 +static const char *rawhide_repo_filename = "rawhide.repo";
     1.9 +static const char *updated_repo_filename = "system-updated.repo";
    1.10  
    1.11  static int
    1.12  command_list(int argc, const char *argv[])
    1.13 @@ -123,7 +124,7 @@
    1.14  	if (set == NULL || upstream == NULL)
    1.15  		return 1;
    1.16  	set = razor_set_update(set, upstream, argc - 2, argv + 2);
    1.17 -	razor_set_write(set, "system-updated.repo");
    1.18 +	razor_set_write(set, updated_repo_filename);
    1.19  	razor_set_destroy(set);
    1.20  	razor_set_destroy(upstream);
    1.21  	printf("wrote system-updated.repo\n");
    1.22 @@ -131,6 +132,34 @@
    1.23  	return 0;
    1.24  }
    1.25  
    1.26 +static void
    1.27 +print_diff(const char *name,
    1.28 +	   const char *old_version, const char *new_version, void *data)
    1.29 +{
    1.30 +	if (old_version)
    1.31 +		printf("removing %s %s\n", name, old_version);
    1.32 +	else
    1.33 +		printf("install %s %s\n", name, new_version);
    1.34 +}
    1.35 +
    1.36 +static int
    1.37 +command_diff(int argc, const char *argv[])
    1.38 +{
    1.39 +	struct razor_set *set, *updated;
    1.40 +
    1.41 +	set = razor_set_open(repo_filename);
    1.42 +	updated = razor_set_open(updated_repo_filename);
    1.43 +	if (set == NULL || updated == NULL)
    1.44 +		return 1;
    1.45 +
    1.46 +	razor_set_diff(set, updated, print_diff, NULL);	
    1.47 +
    1.48 +	razor_set_destroy(set);
    1.49 +	razor_set_destroy(updated);
    1.50 +
    1.51 +	return 0;
    1.52 +}
    1.53 +
    1.54  static struct {
    1.55  	const char *name;
    1.56  	const char *description;
    1.57 @@ -144,7 +173,8 @@
    1.58  	{ "import-yum", "import yum filelist.xml on stdin", command_import_yum },
    1.59  	{ "import-rpmdb", "import the system rpm database", command_import_rpmdb },
    1.60  	{ "validate", "validate a package set", command_validate },
    1.61 -	{ "update", "update all or specified packages", command_update }
    1.62 +	{ "update", "update all or specified packages", command_update },
    1.63 +	{ "diff", "show diff between two package sets", command_diff }
    1.64  };
    1.65  
    1.66  static int