|
|
@ -0,0 +1,177 @@ |
|
|
|
|
|
|
|
I know that a: |
|
|
|
md5sum --check var/adm/md5sums/$pkg |
|
|
|
|
|
|
|
is sufficent for the check task - but a statically linked version for |
|
|
|
rescue situations are a nice-to-have (ehrm yes - I had to solve some stability |
|
|
|
problems on my iBook in the last days ....). Mine should be the right place |
|
|
|
for a common package check interface. |
|
|
|
|
|
|
|
- Rene Rebe <rene@rockliunx.org> |
|
|
|
|
|
|
|
--- mine-0.15/mine.h 2003-09-27 15:20:58.000000000 +0200
|
|
|
|
+++ mine-0.15-check/mine.h 2003-12-25 20:00:37.000000000 +0100
|
|
|
|
@@ -20,6 +20,8 @@
|
|
|
|
#ifndef MINE_H |
|
|
|
#define MINE_H |
|
|
|
|
|
|
|
+extern int gem_check(char * root, char * package);
|
|
|
|
+
|
|
|
|
extern int gem_create(char * varadm, char * tarbz2, |
|
|
|
char * package, char * outfile); |
|
|
|
|
|
|
|
--- mine-0.15/check.c 1970-01-01 01:00:00.000000000 +0100
|
|
|
|
+++ mine-0.15-check/check.c 2003-12-25 21:10:25.000000000 +0100
|
|
|
|
@@ -0,0 +1,73 @@
|
|
|
|
+/*
|
|
|
|
+ * GEM MINE - The ROCK Linux Package Manager
|
|
|
|
+ * Copyright (C) 2002-2003 Clifford Wolf and Rene Rebe
|
|
|
|
+ *
|
|
|
|
+ * 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 <sys/types.h>
|
|
|
|
+#include <sys/stat.h>
|
|
|
|
+#include <stdlib.h>
|
|
|
|
+#include <unistd.h>
|
|
|
|
+#include <string.h>
|
|
|
|
+#include <dirent.h>
|
|
|
|
+#include <stdio.h>
|
|
|
|
+#include <fcntl.h>
|
|
|
|
+#include <errno.h>
|
|
|
|
+
|
|
|
|
+#include "mine.h"
|
|
|
|
+#include "md5sum.h"
|
|
|
|
+
|
|
|
|
+extern int check_initialized = 0;
|
|
|
|
+
|
|
|
|
+int gem_check(char * root, char * package)
|
|
|
|
+{
|
|
|
|
+ char buffer[1024];
|
|
|
|
+ char *filename;
|
|
|
|
+ int modified = 0;
|
|
|
|
+ FILE *f;
|
|
|
|
+
|
|
|
|
+ if ( ! check_initialized ) {
|
|
|
|
+ md5sum_initdb(root, 0 /* verbose */);
|
|
|
|
+ check_initialized = 1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ snprintf(buffer, 1024, "%s/var/adm/flists/%s", root, package);
|
|
|
|
+ f = fopen(buffer, "r");
|
|
|
|
+ if ( f == NULL ) {
|
|
|
|
+ fprintf(stderr, "No such package: %s\n", package);
|
|
|
|
+ return 1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ while ( fgets(buffer, 1024, f) != NULL )
|
|
|
|
+ {
|
|
|
|
+ strtok(buffer, " \t\n");
|
|
|
|
+ filename = strtok(NULL, "\n");
|
|
|
|
+
|
|
|
|
+ if ( md5sum_check(root, filename) ) {
|
|
|
|
+ printf("Modified/duplicate "
|
|
|
|
+ "file: %s\n", filename);
|
|
|
|
+ modified++;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ fclose(f);
|
|
|
|
+
|
|
|
|
+ if ( modified )
|
|
|
|
+ fprintf(stderr, "%d modified file%s of package %s.\n",
|
|
|
|
+ modified, modified != 1 ? "s" : "", package);
|
|
|
|
+ return modified == 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
--- mine-0.15/Makefile 2003-09-27 15:20:58.000000000 +0200
|
|
|
|
+++ mine-0.15-check/Makefile 2003-12-25 19:58:20.000000000 +0100
|
|
|
|
@@ -21,7 +21,7 @@
|
|
|
|
# Mine Itself |
|
|
|
# |
|
|
|
MINE_VER = 0.15 |
|
|
|
-MINE_OBJ = create.o install.o remove.o pkglist.o
|
|
|
|
+MINE_OBJ = check.o create.o install.o remove.o pkglist.o
|
|
|
|
MINE_OBJ += showfile.o showkey.o memdb.o md5.o md5sum.o mine.o |
|
|
|
MINE_LDFLAGS = -static |
|
|
|
|
|
|
|
--- mine-0.15-reference/mine.c 2003-09-27 15:20:58.000000000 +0200
|
|
|
|
+++ mine-0.15/mine.c 2003-12-26 00:18:25.000000000 +0100
|
|
|
|
@@ -32,7 +32,8 @@
|
|
|
|
MINE_MODE_REMOVE, |
|
|
|
MINE_MODE_PKGLIST, |
|
|
|
MINE_MODE_SHOWFILE, |
|
|
|
- MINE_MODE_SHOWKEY
|
|
|
|
+ MINE_MODE_SHOWKEY,
|
|
|
|
+ MINE_MODE_CHECK
|
|
|
|
}; |
|
|
|
|
|
|
|
int mine_mode = MINE_MODE_NONE; |
|
|
|
@@ -52,10 +53,11 @@
|
|
|
|
" - ROCK Linux Package Management Tool\n" |
|
|
|
"Copyright 2002, 2003 Clifford Wolf (GPL'ed)\n" |
|
|
|
"\n" |
|
|
|
-"Install and remove GEM packages:\n"
|
|
|
|
+"Install, remove and chek GEM packages:\n"
|
|
|
|
"\n" |
|
|
|
" mine -i [ -t ] [ -v ] [ -f ] [ -R root ] package1.gem [ .. ]\n" |
|
|
|
" mine -r [ -t ] [ -v ] [ -f ] [ -R root ] package1 [ package2 [ .. ] ]\n" |
|
|
|
+" mine -y [ -R root ] package1 [ package2 [ .. ] ]\n"
|
|
|
|
"\n" |
|
|
|
"Query installed packages or GEM package files:\n" |
|
|
|
"\n" |
|
|
|
@@ -168,7 +170,7 @@
|
|
|
|
} |
|
|
|
|
|
|
|
while ( (opt = getopt(argc, argv, |
|
|
|
- "irqplmcdk:tvfhHR:")) != -1 ) {
|
|
|
|
+ "iryqplmcdk:tvfhHR:")) != -1 ) {
|
|
|
|
switch (opt) { |
|
|
|
case 'i': |
|
|
|
set_mode(MINE_MODE_INSTALL); |
|
|
|
@@ -176,7 +178,9 @@
|
|
|
|
case 'r': |
|
|
|
set_mode(MINE_MODE_REMOVE); |
|
|
|
break; |
|
|
|
-
|
|
|
|
+ case 'y':
|
|
|
|
+ set_mode(MINE_MODE_CHECK);
|
|
|
|
+ break;
|
|
|
|
case 'q': |
|
|
|
set_mode(MINE_MODE_PKGLIST); |
|
|
|
break; |
|
|
|
@@ -290,6 +294,10 @@
|
|
|
|
argv[optind]); |
|
|
|
break; |
|
|
|
|
|
|
|
+ case MINE_MODE_CHECK:
|
|
|
|
+ rc = gem_check(mine_root_dir, argv[optind]);
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
case MINE_MODE_PKGLIST: |
|
|
|
rc = gem_pkglist(argv[optind]); |
|
|
|
break; |
|
|
|
@@ -340,6 +348,11 @@
|
|
|
|
mine_mode_header_block, |
|
|
|
namelist[n]->d_name); |
|
|
|
break; |
|
|
|
+
|
|
|
|
+
|
|
|
|
+ case MINE_MODE_CHECK:
|
|
|
|
+ rc = gem_check(mine_root_dir, namelist[n]->d_name);
|
|
|
|
+ break;
|
|
|
|
} |
|
|
|
free(namelist[n]); |
|
|
|
if ( rc > ret ) ret = rc; |