|
|
diff -dur mine-0.24/check.c mine-0.24-patch/check.c
--- mine-0.24/check.c 2005-09-30 12:34:36.000000000 +0200
+++ mine-0.24-patch/check.c 2006-04-27 20:14:38.000000000 +0200
@@ -72,9 +72,14 @@
strtok(buffer, " \t\n"); filename = strtok(NULL, "\n"); - if ( md5sum_check(root, filename) ) {
- printf("Modified/duplicate "
- "file: %s\n", filename);
+ int result = 0;
+ if ( result = md5sum_check(root, filename) ) {
+ switch (result) {
+ case MD5SUM_CHECK_DUPLICATE: printf("Duplicate "); break;
+ case MD5SUM_CHECK_MODIFIED: printf("Modified "); break;
+ case MD5SUM_CHECK_SHARED: printf("Shared "); break;
+ }
+ printf("file: %s\n", filename);
modified++; } } diff -dur mine-0.24/install.c mine-0.24-patch/install.c
--- mine-0.24/install.c 2006-04-27 21:06:40.000000000 +0200
+++ mine-0.24-patch/install.c 2006-04-27 20:15:52.000000000 +0200
@@ -256,6 +256,7 @@
unlink(buffer3); } + int result = 0;
if (patterns && glob_check(patterns, filename)) { if ( mode_verbose ) { printf("Exclude glob " @@ -265,15 +266,22 @@
if (TH_ISREG(t) && tar_skip_regfile(t) != 0) goto error_errno; } - else if ( ! mode_force && md5sum_check(root, filename) ) {
+ else if ( ! mode_force && (result = md5sum_check(root, filename)) ) {
+ if ( ! mode_test || ! mode_verbose )
+ printf("%s: ", pname);
+ printf("WARNING: Skip ");
+ switch (result) {
+ case MD5SUM_CHECK_DUPLICATE: printf("duplicate "); break;
+ case MD5SUM_CHECK_MODIFIED: printf("modified "); break;
+ case MD5SUM_CHECK_SHARED: printf("shared "); break;
+ }
+ printf("file %s", filename);
if ( mode_test && mode_verbose ) { - printf("WARNING: Skip modified/duplicate "
- "file %s:\n", filename);
+ printf(":\n");
th_print_long_ls(t); - } else {
- printf("%s: WARNING: Skip modified/duplicate "
- "file: %s\n", pname, filename);
- }
+ } else
+ printf(".\n");
+
if ( mode_test ) { if (TH_ISREG(t) && tar_skip_regfile(t) != 0) goto error_errno; diff -dur mine-0.24/md5sum.c mine-0.24-patch/md5sum.c
--- mine-0.24/md5sum.c 2005-08-09 12:57:29.000000000 +0200
+++ mine-0.24-patch/md5sum.c 2006-04-27 21:11:22.000000000 +0200
@@ -20,6 +20,7 @@
#include <stdio.h> #include <dirent.h> #include <string.h> +#include <sys/types.h>
#include <sys/stat.h> #include <unistd.h> @@ -37,35 +38,42 @@
struct stat statbuf; snprintf(realfilename, 1024, "%s/%s", root, filename); - return (stat(realfilename, &statbuf) != 0 || S_ISFIFO(statbuf.st_mode))
- ? "" : md5_file(realfilename);
+ if (lstat(realfilename, &statbuf) != 0 || S_ISDIR(statbuf.st_mode))
+ return "";
+ else if (!S_ISREG(statbuf.st_mode))
+ return "X";
+ else
+ return md5_file(realfilename);
} -/* Returns 1 if file is duplicate, 2 if file is modified. */
+/* Returns if file is unmodified, modified, duplicate, or shared. */
int md5sum_check(char * root, char * filename) { char *md5_f, *md5_d; md5_f = md5sum_create(root, filename); md5_d = memdb_get(&md5_memdb, filename); -
- if (md5_f == NULL || strcmp(md5_f, "") == 0)
- return 0;
+
+/* printf ("md5sum_check(): md5_f: %s, md5_d: %s\n",
+ (md5_f) ? md5_f : "NULL", (md5_d) ? md5_d : "NULL");
+*/
+ if (strcmp(md5_f, "") == 0)
+ return MD5SUM_CHECK_OK;
else if (md5_d == NULL) - return 1;
- else if (strcmp(md5_f, md5_d) == 0)
- return 0;
+ return MD5SUM_CHECK_DUPLICATE;
+ else if (strcmp(md5_f, md5_d) == 0 || strcmp(md5_d, "X") == 0)
+ return MD5SUM_CHECK_OK;
+ else if (strcmp(md5_d, "Duplicate entry") == 0)
+ return MD5SUM_CHECK_SHARED;
else - return 2;
+ return MD5SUM_CHECK_MODIFIED;
} void md5sum_initdb(char * root, int verbose) { struct dirent *md5_dent; - char buffer[1024], buffer2[1024];
+ char buffer[1024];
char *md5sum, *filename; - const char const *admdirs[6] =
- {"cksums", "dependencies", "descs", "flists", "md5sums", "packages"};
FILE *f; DIR *d; @@ -81,16 +86,6 @@
root, md5_dent->d_name); f = fopen(buffer, "r"); if ( f != NULL ) { - /* Add the /var/adm files of each package to the
- md5sum memdb so md5sum_check() recognizes them. */
- int n;
- for (n = 0; n < 6; n++) {
- snprintf(buffer2, 1024, "var/adm/%s/%s",
- admdirs[n], md5_dent->d_name);
- memdb_put(&md5_memdb, buffer2,
- md5sum_create(root, buffer2));
- }
-
while (fgets(buffer, 1024, f) != NULL) { md5sum = strtok(buffer, " \t\n"); filename = strtok(NULL, "\n"); diff -dur mine-0.24/md5sum.h mine-0.24-patch/md5sum.h
--- mine-0.24/md5sum.h 2005-03-23 09:51:06.000000000 +0100
+++ mine-0.24-patch/md5sum.h 2006-04-27 20:14:38.000000000 +0200
@@ -20,6 +20,11 @@
#ifndef MD5SUM_H #define MD5SUM_H +#define MD5SUM_CHECK_OK 0
+#define MD5SUM_CHECK_DUPLICATE 1
+#define MD5SUM_CHECK_MODIFIED 2
+#define MD5SUM_CHECK_SHARED 3
+
char * md5sum_create(char * root, char * filename); int md5sum_check(char * root, char * filename); void md5sum_initdb(char * root, int verbose); diff -dur mine-0.24/remove.c mine-0.24-patch/remove.c
--- mine-0.24/remove.c 2005-08-09 12:57:29.000000000 +0200
+++ mine-0.24-patch/remove.c 2006-04-27 20:14:38.000000000 +0200
@@ -120,11 +120,17 @@
flist = (flist_tmp=flist)->next; free(flist_tmp); - if ( ! mode_force && md5sum_check(root, filename) ) {
+ int result = 0;
+ if ( ! mode_force && (result = md5sum_check(root, filename)) ) {
if ( ! mode_test || ! mode_verbose ) printf("%s: ", package); - printf("WARNING: Skip modified/duplicate "
- "file: %s\n", filename);
+ printf("WARNING: Skip ");
+ switch (result) {
+ case MD5SUM_CHECK_DUPLICATE: printf("duplicate "); break;
+ case MD5SUM_CHECK_MODIFIED: printf("modified "); break;
+ case MD5SUM_CHECK_SHARED: printf("shared "); break;
+ }
+ printf("file %s:\n", filename);
} else if ( mode_test ) {
|