mirror of the now-defunct rocklinux.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

177 lines
4.7 KiB

  1. I know that a:
  2. md5sum --check var/adm/md5sums/$pkg
  3. is sufficent for the check task - but a statically linked version for
  4. rescue situations are a nice-to-have (ehrm yes - I had to solve some stability
  5. problems on my iBook in the last days ....). Mine should be the right place
  6. for a common package check interface.
  7. - Rene Rebe <rene@rockliunx.org>
  8. --- mine-0.15/mine.h 2003-09-27 15:20:58.000000000 +0200
  9. +++ mine-0.15-check/mine.h 2003-12-25 20:00:37.000000000 +0100
  10. @@ -20,6 +20,8 @@
  11. #ifndef MINE_H
  12. #define MINE_H
  13. +extern int gem_check(char * root, char * package);
  14. +
  15. extern int gem_create(char * varadm, char * tarbz2,
  16. char * package, char * outfile);
  17. --- mine-0.15/check.c 1970-01-01 01:00:00.000000000 +0100
  18. +++ mine-0.15-check/check.c 2003-12-25 21:10:25.000000000 +0100
  19. @@ -0,0 +1,73 @@
  20. +/*
  21. + * GEM MINE - The ROCK Linux Package Manager
  22. + * Copyright (C) 2002-2003 Clifford Wolf and Rene Rebe
  23. + *
  24. + * This program is free software; you can redistribute it and/or modify
  25. + * it under the terms of the GNU General Public License as published by
  26. + * the Free Software Foundation; either version 2 of the License, or
  27. + * (at your option) any later version.
  28. + *
  29. + * This program is distributed in the hope that it will be useful,
  30. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  31. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  32. + * GNU General Public License for more details.
  33. + *
  34. + * You should have received a copy of the GNU General Public License
  35. + * along with this program; if not, write to the Free Software
  36. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  37. + */
  38. +
  39. +#include <sys/types.h>
  40. +#include <sys/stat.h>
  41. +#include <stdlib.h>
  42. +#include <unistd.h>
  43. +#include <string.h>
  44. +#include <dirent.h>
  45. +#include <stdio.h>
  46. +#include <fcntl.h>
  47. +#include <errno.h>
  48. +
  49. +#include "mine.h"
  50. +#include "md5sum.h"
  51. +
  52. +
  53. +
  54. +int gem_check(char * root, char * package)
  55. +{
  56. + char buffer[1024];
  57. + char *filename;
  58. + int modified = 0;
  59. + FILE *f;
  60. +
  61. +
  62. + md5sum_initdb(root, 0 /* verbose */);
  63. +
  64. +
  65. +
  66. + snprintf(buffer, 1024, "%s/var/adm/flists/%s", root, package);
  67. + f = fopen(buffer, "r");
  68. + if ( f == NULL ) {
  69. + fprintf(stderr, "No such package: %s\n", package);
  70. + return 1;
  71. + }
  72. +
  73. + while ( fgets(buffer, 1024, f) != NULL )
  74. + {
  75. + strtok(buffer, " \t\n");
  76. + filename = strtok(NULL, "\n");
  77. +
  78. + if ( md5sum_check(root, filename) ) {
  79. + printf("Modified/duplicate "
  80. + "file: %s\n", filename);
  81. + modified++;
  82. + }
  83. + }
  84. +
  85. + fclose(f);
  86. +
  87. + if ( modified )
  88. + fprintf(stderr, "%d modified file%s of package %s.\n",
  89. + modified, modified != 1 ? "s" : "", package);
  90. + return modified == 0;
  91. +}
  92. +
  93. --- mine-0.15/Makefile 2003-09-27 15:20:58.000000000 +0200
  94. +++ mine-0.15-check/Makefile 2003-12-25 19:58:20.000000000 +0100
  95. @@ -21,7 +21,7 @@
  96. # Mine Itself
  97. #
  98. MINE_VER = 0.15
  99. -MINE_OBJ = create.o install.o remove.o pkglist.o
  100. +MINE_OBJ = check.o create.o install.o remove.o pkglist.o
  101. MINE_OBJ += showfile.o showkey.o memdb.o md5.o md5sum.o mine.o
  102. MINE_LDFLAGS = -static
  103. --- mine-0.15-reference/mine.c 2003-09-27 15:20:58.000000000 +0200
  104. +++ mine-0.15/mine.c 2003-12-26 00:18:25.000000000 +0100
  105. @@ -32,7 +32,8 @@
  106. MINE_MODE_REMOVE,
  107. MINE_MODE_PKGLIST,
  108. MINE_MODE_SHOWFILE,
  109. - MINE_MODE_SHOWKEY
  110. + MINE_MODE_SHOWKEY,
  111. + MINE_MODE_CHECK
  112. };
  113. int mine_mode = MINE_MODE_NONE;
  114. @@ -52,10 +53,11 @@
  115. " - ROCK Linux Package Management Tool\n"
  116. "Copyright 2002, 2003 Clifford Wolf (GPL'ed)\n"
  117. "\n"
  118. -"Install and remove GEM packages:\n"
  119. +"Install, remove and chek GEM packages:\n"
  120. "\n"
  121. " mine -i [ -t ] [ -v ] [ -f ] [ -R root ] package1.gem [ .. ]\n"
  122. " mine -r [ -t ] [ -v ] [ -f ] [ -R root ] package1 [ package2 [ .. ] ]\n"
  123. +" mine -y [ -R root ] package1 [ package2 [ .. ] ]\n"
  124. "\n"
  125. "Query installed packages or GEM package files:\n"
  126. "\n"
  127. @@ -168,7 +170,7 @@
  128. }
  129. while ( (opt = getopt(argc, argv,
  130. - "irqplmcdk:tvfhHR:")) != -1 ) {
  131. + "iryqplmcdk:tvfhHR:")) != -1 ) {
  132. switch (opt) {
  133. case 'i':
  134. set_mode(MINE_MODE_INSTALL);
  135. @@ -176,7 +178,9 @@
  136. case 'r':
  137. set_mode(MINE_MODE_REMOVE);
  138. break;
  139. -
  140. + case 'y':
  141. + set_mode(MINE_MODE_CHECK);
  142. + break;
  143. case 'q':
  144. set_mode(MINE_MODE_PKGLIST);
  145. break;
  146. @@ -290,6 +294,10 @@
  147. argv[optind]);
  148. break;
  149. + case MINE_MODE_CHECK:
  150. + rc = gem_check(mine_root_dir, argv[optind]);
  151. + break;
  152. +
  153. case MINE_MODE_PKGLIST:
  154. rc = gem_pkglist(argv[optind]);
  155. break;
  156. @@ -340,6 +348,11 @@
  157. mine_mode_header_block,
  158. namelist[n]->d_name);
  159. break;
  160. +
  161. +
  162. + case MINE_MODE_CHECK:
  163. + rc = gem_check(mine_root_dir, namelist[n]->d_name);
  164. + break;
  165. }
  166. free(namelist[n]);
  167. if ( rc > ret ) ret = rc;