--- Begin Message ---
Package: quinn-diff
Version: 0.60
Tags: patch
Severity: wishlist
Hi James,
please consider to add support for a "include-only"-list for
quinn-diff, like e.g. the patch below does.
Thanks.
Cheers,
Andi
diff -Nur quinn-diff-0.60-prev/src/Makefile.am quinn-diff-0.60/src/Makefile.am
--- quinn-diff-0.60-prev/src/Makefile.am Thu May 24 23:07:09 2001
+++ quinn-diff-0.60/src/Makefile.am Mon Aug 30 14:08:24 2004
@@ -1,4 +1,4 @@
bin_PROGRAMS = quinn-diff
-quinn_diff_SOURCES = error.c nfmalloc.c xmalloc.c getopt.c getopt1.c init.c
list.c arch_specific.c vercmp.c output.c utils.c parse_sources.c
parse_packages.c main.c arch_specific.h common.h error.h getopt.h init.h list.h
nfmalloc.h output.h parse_sources.h parse_packages.h utils.h vercmp.h xmalloc.h
globals.h
+quinn_diff_SOURCES = error.c nfmalloc.c xmalloc.c getopt.c getopt1.c init.c
list.c arch_specific.c vercmp.c output.c utils.c parse_sources.c
parse_packages.c main.c arch_specific.h common.h error.h getopt.h init.h list.h
nfmalloc.h output.h parse_sources.h parse_packages.h utils.h vercmp.h xmalloc.h
globals.h incl.c incl.h
quinn_diff_LDADD = @EFENCE@ @CCMALLOC@
CPPFLAGS = $(shell glib-config --cflags)
diff -Nur quinn-diff-0.60-prev/src/Makefile.in quinn-diff-0.60/src/Makefile.in
--- quinn-diff-0.60-prev/src/Makefile.in Thu Jan 10 22:29:04 2002
+++ quinn-diff-0.60/src/Makefile.in Mon Aug 30 14:28:41 2004
@@ -66,7 +66,7 @@
VERSION = @VERSION@
bin_PROGRAMS = quinn-diff
-quinn_diff_SOURCES = error.c nfmalloc.c xmalloc.c getopt.c getopt1.c init.c
list.c arch_specific.c vercmp.c output.c utils.c parse_sources.c
parse_packages.c main.c arch_specific.h common.h error.h getopt.h init.h list.h
nfmalloc.h output.h parse_sources.h parse_packages.h utils.h vercmp.h xmalloc.h
globals.h
+quinn_diff_SOURCES = error.c nfmalloc.c xmalloc.c getopt.c getopt1.c init.c
list.c arch_specific.c vercmp.c output.c utils.c parse_sources.c
parse_packages.c main.c arch_specific.h common.h error.h getopt.h init.h list.h
nfmalloc.h output.h parse_sources.h parse_packages.h utils.h vercmp.h xmalloc.h
globals.h incl.c incl.h
quinn_diff_LDADD = @EFENCE@ @CCMALLOC@
CPPFLAGS = $(shell glib-config --cflags)
mkinstalldirs = $(SHELL) $(top_srcdir)/scripts/mkinstalldirs
@@ -80,7 +80,7 @@
LIBS = @LIBS@
quinn_diff_OBJECTS = error.o nfmalloc.o xmalloc.o getopt.o getopt1.o \
init.o list.o arch_specific.o vercmp.o output.o utils.o parse_sources.o \
-parse_packages.o main.o
+parse_packages.o main.o incl.o
quinn_diff_DEPENDENCIES =
quinn_diff_LDFLAGS =
CFLAGS = @CFLAGS@
diff -Nur quinn-diff-0.60-prev/src/error.h quinn-diff-0.60/src/error.h
--- quinn-diff-0.60-prev/src/error.h Sun May 30 16:10:11 1999
+++ quinn-diff-0.60/src/error.h Mon Aug 30 14:35:04 2004
@@ -33,6 +33,7 @@
#define debug_output 0020 /* Output functions */
#define debug_versions 0040 /* Version comparsion functions */
#define debug_utils 0100 /* Util functions */
+#define debug_incl 0200 /* include only functions */
/* Flags for fubar */
diff -Nur quinn-diff-0.60-prev/src/globals.h quinn-diff-0.60/src/globals.h
--- quinn-diff-0.60-prev/src/globals.h Fri Dec 7 03:05:29 2001
+++ quinn-diff-0.60/src/globals.h Mon Aug 30 14:20:19 2004
@@ -32,6 +32,10 @@
/* The filename for the Packages-arch-specific file */
GLOBAL char *packages_source_filename;
+
+/* The filename for the inlcude-only file */
+GLOBAL char *packages_include_only_filename;
+
/* Output format */
GLOBAL int output_format;
diff -Nur quinn-diff-0.60-prev/src/incl.c quinn-diff-0.60/src/incl.c
--- quinn-diff-0.60-prev/src/incl.c Thu Jan 1 01:00:00 1970
+++ quinn-diff-0.60/src/incl.c Mon Aug 30 14:36:58 2004
@@ -0,0 +1,242 @@
+/* Quinn Diff, Determine which packages need recompiled for any given
architecture */
+/* Copyright (C) 1997-2001, James Troup <ja...@nocrew.org> */
+
+/* This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+#include "globals.h"
+#include "error.h"
+#include "utils.h"
+#include "xmalloc.h"
+#include "incl.h"
+
+/* Used to stop quinn diff trying to parse Packages-arch-specific
+ files which it can't */
+
+#define NEWEST_PARSEABLE_VERSION 1
+
+GHashTable *incl_packages_hash_table;
+
+void incl_package_free_ht_entry (gpointer key, gpointer package, gpointer
cruft);
+void open_incl_file(FILE *fp, char **buffer_p, long *buffer_length);
+void read_incl_packages (const char *buffer_p, const unsigned long
buffer_length);
+void incl_packages_ht_add (char *package_name);
+void check_parseable_incl (const char *buffer_p, const unsigned long
buffer_length);
+
+/* Public functions */
+
+void
+incl_packages_ht_create (void)
+{
+
+ incl_packages_hash_table = g_hash_table_new (quinn_hash_function,
quinn_key_compare_function);
+
+ if (incl_packages_hash_table == NULL)
+ fubar (SYSERR, "Unable to create hash table for include file.");
+
+}
+
+void
+incl_packages_read (void)
+{
+
+ FILE *fp = NULL;
+ char *buffer_p;
+ unsigned long buffer_length;
+
+ open_incl_file (fp, &buffer_p, &buffer_length);
+ debug (debug_incl, "read_incl_file: read %ld bytes of \"%s\"",
+ buffer_length, packages_include_only_filename);
+
+ read_incl_packages (buffer_p, buffer_length);
+ xfree (buffer_p);
+
+}
+
+boolean
+is_incl (char *package)
+{
+
+ gpointer incl;
+
+ incl = g_hash_table_lookup (incl_packages_hash_table, package);
+
+ if (incl)
+ {
+ debug (debug_incl, "is_incl: %s is.", package);
+ return TRUE;
+ }
+ else
+ {
+ debug (debug_incl, "is_incl: %s is not.", package);
+ return FALSE;
+ }
+
+}
+
+void
+incl_packages_ht_destroy (void)
+{
+
+ g_hash_table_foreach (incl_packages_hash_table, incl_package_free_ht_entry,
NULL);
+ g_hash_table_destroy (incl_packages_hash_table);
+
+}
+
+void
+incl_package_free_ht_entry (gpointer key,
+ gpointer package __attribute__ ((unused)),
+ gpointer cruft __attribute__ ((unused)))
+{
+
+ xfree (key);
+
+}
+
+/* Private functions */
+
+void open_incl_file(FILE *fp, char **buffer_p, long *buffer_length)
+{
+ long n_read;
+
+ fp = fopen (packages_include_only_filename, "r");
+ if (fp == NULL)
+ fubar (SYSERR, "%s: couldn't open file \"%s\"",
+ program_name, packages_include_only_filename);
+ if ((fseek (fp, 0, SEEK_END)) != 0)
+ fubar (SYSERR, "%s: couldn't seek to the end of file \"%s\"",
+ program_name, packages_include_only_filename);
+ *buffer_length = ftell (fp);
+ rewind (fp);
+
+ /* FIXME: this probably shouldn't bomb out */
+
+ if (*buffer_length == 0)
+ fubar (NONSYS, "%s: \"%s\" is zero-length.", program_name,
packages_include_only_filename);
+
+ /* We don't do any memory management, we just ask for a chunk of
+ * memory the size of the file */
+
+ *buffer_p = xmalloc (*buffer_length);
+
+ n_read = fread (*buffer_p, sizeof (char), *buffer_length, fp);
+ if (n_read == 0)
+ fubar (SYSERR, "%s: couldn't read file \"%s\" into buffer",
+ program_name, packages_include_only_filename);
+ else if (n_read < *buffer_length)
+ fubar (SYSERR, "%s: short read (found %ld, expected %ld) in file \"%s\"",
+ program_name, n_read, *buffer_length,
packages_include_only_filename);
+
+ if (fclose (fp) == EOF)
+ fubar (SYSERR, "%s: couldn't close file \"%s\"", program_name,
+ packages_include_only_filename);
+}
+
+
+void read_incl_packages (const char *buffer_p, const unsigned long
buffer_length)
+{
+
+ char *line;
+ unsigned long i;
+ unsigned int k;
+
+ check_parseable_incl (buffer_p, buffer_length);
+
+ i = 0;
+
+ while (i < buffer_length)
+ {
+
+ /* We don't need to bother with either comment lines or empty lines */
+
+ if (buffer_p[i] == ' ' || buffer_p[i] == '#')
+ {
+ skip_line (buffer_p, &i, buffer_length);
+ continue;
+ }
+
+ line = read_line (buffer_p, buffer_length, &i);
+
+ /* Parse the line by splitting it up into package name and the packages'
supported architectures */
+
+ /* Package name is everything */
+
+ for (k = 0; line[k] != '\n' && line[k] != '\0' && line[k] != ' '; k++)
+ ;
+ line[k] ='\0';
+ debug(debug_incl, "include package name \"%s\"", line);
+ incl_packages_ht_add(line);
+
+ xfree (line);
+
+ }
+
+}
+
+void incl_packages_ht_add (char *package)
+{
+
+ char *key;
+
+ key = xstrdup (package);
+
+ debug (debug_incl, "incl_hash_add: Adding \"%s\" to allowed packages",
package);
+
+ /* NB: The 1 is a dummy number; it doesn't matter what it is, as
+ long as it isn't 0 */
+
+ g_hash_table_insert (incl_packages_hash_table, key, (gpointer) 1);
+
+
+}
+
+ /* First line should be a special comment field giving the version
+ number of the Packages-arch-specific file; use this to ensure
+ we're not trying to parse something we don't understand */
+
+void check_parseable_incl (const char *buffer_p, const unsigned long
buffer_length)
+{
+
+ char *line;
+ char *incl_version_string, *errors;
+ unsigned long i;
+ long incl_version;
+
+ i = 0;
+
+ if (buffer_p[i] == '#')
+ {
+ line = read_line (buffer_p, buffer_length, &i);
+ incl_version_string = strstr (line, "Packages-arch-specific-version: ");
+ if (incl_version_string != NULL)
+ {
+ incl_version_string += 32;
+ incl_version = strtol(incl_version_string, &errors, 10);
+ if (errors != incl_version_string)
+ {
+ if (incl_version > NEWEST_PARSEABLE_VERSION)
+ fubar (NONSYS, "I can't understand this type of
Packages-arch-specific file; please upgrade.");
+ }
+ else
+ fubar (NONSYS, "I can't understand this type of
Packages-arch-specific file; please upgrade.");
+ }
+ xfree (line);
+ }
+
+}
diff -Nur quinn-diff-0.60-prev/src/incl.h quinn-diff-0.60/src/incl.h
--- quinn-diff-0.60-prev/src/incl.h Thu Jan 1 01:00:00 1970
+++ quinn-diff-0.60/src/incl.h Mon Aug 30 14:08:08 2004
@@ -0,0 +1,29 @@
+/* Quinn Diff, Determine which packages need recompiled for any given
architecture */
+/* Copyright (C) 1997-2001, James Troup <ja...@nocrew.org> */
+
+/* This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef __INCL_H__
+#define __INCL_H__
+
+#include "common.h"
+
+void incl_packages_ht_create (void);
+void incl_packages_read (void);
+boolean is_incl (char *package_name);
+void incl_packages_ht_destroy (void);
+
+#endif /* __INCL_H__ */
Binary files quinn-diff-0.60-prev/src/incl.o and quinn-diff-0.60/src/incl.o
differ
diff -Nur quinn-diff-0.60-prev/src/init.c quinn-diff-0.60/src/init.c
--- quinn-diff-0.60-prev/src/init.c Fri Dec 7 03:19:54 2001
+++ quinn-diff-0.60/src/init.c Mon Aug 30 14:17:18 2004
@@ -41,6 +41,7 @@
static struct option long_options[] =
{
{"arch-specific-packages", required_argument, NULL, 'a'},
+ {"include-only", required_argument, NULL, 'I'},
{"architecture", required_argument, NULL, 'A'},
{"debug", required_argument, NULL, 'D'},
{"help", no_argument, NULL, 'h'},
@@ -52,7 +53,7 @@
{0, 0, 0, 0}
};
- c = getopt_long (argc, argv, "a:A:D:hip:s:w:V",
+ c = getopt_long (argc, argv, "a:A:D:hip:s:w:VI:",
long_options, &option_index);
if (c == EOF)
break;
@@ -108,6 +109,11 @@
case 'V':
fprintf (stderr, "Quinn diff version %s\n", VERSION);
exit (0);
+ break;
+
+ case 'I':
+ xfree_if_non_null (packages_include_only_filename);
+ packages_include_only_filename = xstrdup (optarg);
break;
case '?':
diff -Nur quinn-diff-0.60-prev/src/main.c quinn-diff-0.60/src/main.c
--- quinn-diff-0.60-prev/src/main.c Fri Dec 7 03:06:43 2001
+++ quinn-diff-0.60/src/main.c Mon Aug 30 14:42:18 2004
@@ -19,6 +19,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include "incl.h"
#include "arch_specific.h"
#include "error.h"
#include "init.h"
@@ -62,12 +63,15 @@
packages->file_name = xstrdup ("Packages");
packages_arch_specific_filename = xstrdup ("/etc/Packages-arch-specific");
packages_architecture = NULL;
+ packages_include_only_filename = NULL;
parse_opt (argc, argv, sources, packages);
/* Initalize the hash tables */
packages_ht_create ();
arch_specific_packages_ht_create ();
+ if (packages_include_only_filename != NULL)
+ incl_packages_ht_create ();
output_ht_create ();
/* Read and process the Packages file */
@@ -80,6 +84,8 @@
/* Read and process Packages-arch-specific */
arch_specific_packages_read ();
+ if (packages_include_only_filename != NULL)
+ incl_packages_read();
/* Read and process the Sources file */
@@ -94,11 +100,14 @@
packages_ht_destroy ();
arch_specific_packages_ht_destroy ();
+ if (packages_include_only_filename != NULL)
+ incl_packages_ht_destroy();
output_ht_destroy ();
xfree (sources->buffer);
xfree (sources);
xfree (packages);
xfree (packages_architecture);
+ xfree (packages_include_only_filename);
xfree (binary_architecture_match);
return (0);
diff -Nur quinn-diff-0.60-prev/src/parse_sources.c
quinn-diff-0.60/src/parse_sources.c
--- quinn-diff-0.60-prev/src/parse_sources.c Fri Dec 7 03:25:15 2001
+++ quinn-diff-0.60/src/parse_sources.c Mon Aug 30 14:38:05 2004
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include <string.h>
#include "arch_specific.h"
+#include "incl.h"
#include "error.h"
#include "globals.h"
#include "list.h"
@@ -81,6 +82,14 @@
xfree (source->name);
continue;
}
+ if (packages_include_only_filename != NULL) {
+ q = is_incl (source->name);
+ if (!q)
+ {
+ xfree (source->name);
+ continue;
+ }
+ }
/* If we're ignoring 'Architecture: all' packages, check this isn't */
if (ignore_arch_all && strstr(source->architecture,"all"))
--
http://home.arcor.de/andreas-barth/
PGP 1024/89FB5CE5 DC F1 85 6D A6 45 9C 0F 3B BE F1 D0 C5 D1 D9 0C
--- End Message ---