File rpminjectfile-vendor.diff of Package rembrand

--- rpminjectfile-1.0/rpminjectfile.c.orig	2006-11-22 21:36:19.000000000 +0100
+++ rpminjectfile-1.0/rpminjectfile.c	2006-11-23 00:50:16.410556000 +0100
@@ -172,7 +172,9 @@
   int fileCount = 0;
   struct stat stb;
   int replace = 0;
+  int verbose = 1;
   char *newrel = 0;
+  char *newvendor = 0;
 
   uint_32 d32;
   uint_16 d16;
@@ -192,15 +194,18 @@
   int nlink;
   int lasthlcomp;
 
-  if (argc == 7 && !strcmp(argv[1], "--release"))
+  while (argc > 5)
     {
-      newrel = argv[2];
-      argc -= 2;
-      argv += 2;
+      if      (argc > 6 && !strcmp(argv[1], "--release")) { newrel    = argv[2]; argc--; argv++; }
+      else if (argc > 6 && !strcmp(argv[1], "--vendor"))  { newvendor = argv[2]; argc--; argv++; }
+      else if (!strcmp(argv[1], "--quiet"))               { verbose = 0; }
+      else { fprintf(stderr, "unknown option %s\n", argv[1]); break; /* hit 'argc != 5' below */ }
+      argc--; argv++;
     }
+
   if (argc != 5)
     {
-      fprintf(stderr, "Usage: rpminjectfile [--release <newrel>] oldrpm newrpm file archive_filename\n");
+      fprintf(stderr, "Usage: rpminjectfile [--release <newrel>] [--vendor <new_vendor>] [--quiet] oldrpm newrpm file archive_filename\n");
       exit(1);
     }
   if (argv[4][0] != '/')
@@ -276,7 +281,7 @@
       filectx = rpmDigestInit(PGPHASHALGO_MD5, RPMDIGEST_NONE);
       rpmDigestUpdate(filectx, filedata, stb.st_size);
       rpmDigestFinal(filectx, (void **)&filemd5, 0, 1);
-      // printf("file digest: %s\n", filemd5);
+      // if (verbose) printf("file digest: %s\n", filemd5);
     }
 
   if ((fd = open(argv[1], O_RDONLY)) == -1)
@@ -432,6 +437,12 @@
   d32 = (uint_32)time((time_t)0);
   headerAddOrAppendEntry(h2, RPMTAG_BUILDTIME, RPM_INT32_TYPE, &d32, 1);
 
+  if (newvendor)
+    {
+      headerRemoveEntry(h2, RPMTAG_VENDOR);
+      headerAddOrAppendEntry(h2, RPMTAG_VENDOR, RPM_STRING_TYPE, newvendor, 1);
+    }
+
   if (newrel)
     {
       char *lp;
@@ -542,7 +553,7 @@
 	    }
 	}
     }
-  printf("copying...\n");
+  if (verbose) printf("copying...\n");
   oname = argv[2];
   ofd = Fopen(oname, "w+.ufdio");
   if (ofd == 0 || Ferror(ofd))
@@ -706,7 +717,7 @@
     }
 
   /* pass2: calculate and update signature */
-  printf("fixing signatures...\n");
+  if (verbose) printf("fixing signatures...\n");
   if (Fseek(ofd, headerstart, SEEK_SET) == -1)
     {
       fprintf(stderr, "cannot rewind output file to header\n");
@@ -734,6 +745,6 @@
       exit(1);
     }
   Fclose(ofd);
-  printf("done.\n");
+  if (verbose) printf("done.\n");
   exit(0);
 }
--- rpminjectfile-1.0/Makefile.orig	2006-11-23 00:50:41.000000000 +0100
+++ rpminjectfile-1.0/Makefile	2006-11-23 00:50:47.786148000 +0100
@@ -1,5 +1,5 @@
 rpminjectfile: rpminjectfile.c
-	cc -Wall rpminjectfile.c -o rpminjectfile -I/usr/include/rpm -static -lrpm -lrpmdb -lrpmio -lpopt -lz -lbz2 -lpthread -lelf
+	$(CC) $(CFLAGS) rpminjectfile.c -o rpminjectfile -I/usr/include/rpm -lrpm -lrpmdb -lrpmio -lpopt -lz -lbz2 -lpthread -lelf
 
 clean:
 	rm -f rpminjectfile rpminjectfile.o
openSUSE Build Service is sponsored by