OpenSDE Packages Database (without history before r20070)
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.

333 lines
9.3 KiB

  1. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # Filename: package/.../mine/any-archiver.patch
  5. # Copyright (C) 2004 - 2006 The T2 SDE Project
  6. #
  7. # More information can be found in the files COPYING and README.
  8. #
  9. # This patch file is dual-licensed. It is available under the license the
  10. # patched project is licensed under, as long as it is an OpenSource license
  11. # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
  12. # of the GNU General Public License as published by the Free Software
  13. # Foundation; either version 2 of the License, or (at your option) any later
  14. # version.
  15. # --- SDE-COPYRIGHT-NOTE-END ---
  16. this fixes a few bugs like crashing on non-existing file and reading the
  17. package database before checking for the file.
  18. Implements using any compressed tar package as archiver and not use the
  19. bzip2 copy but the systen compressors.
  20. (This is just a quick gap filler until we get rid of the whole mine mess.)
  21. - Rene Rebe <rene@exactcode.de>
  22. Index: install.c
  23. ===================================================================
  24. --- ./install.c (revision 3)
  25. +++ ./install.c (revision 13)
  26. @@ -1,6 +1,7 @@
  27. /*
  28. * GEM MINE - The ROCK Linux Package Manager
  29. * Copyright (C) 2002-2005 Clifford Wolf
  30. + * Copyright (C) 2005-2006 Ren� Rebe
  31. *
  32. * This program is free software; you can redistribute it and/or modify
  33. * it under the terms of the GNU General Public License as published by
  34. @@ -29,7 +30,6 @@
  35. #include <fnmatch.h>
  36. #include "cdb.h"
  37. -#include "bzlib.h"
  38. #include "libtar.h"
  39. #include "mine.h"
  40. @@ -60,70 +60,114 @@
  41. int pos, len;
  42. int rc;
  43. - char *filename;
  44. + char *filename = 0;
  45. + char *decompressor = 0;
  46. char buffer[1024];
  47. char buffer2[1024];
  48. char buffer3[1024];
  49. TAR *t = NULL;
  50. - BZFILE *b = NULL;
  51. - if ( ! mode_force )
  52. - md5sum_initdb(root, mode_verbose);
  53. + errno = 0;
  54. - if ( (gem_fd = open(package, O_RDONLY)) < 0 ) goto error_errno;
  55. - cdb_init(&c, gem_fd);
  56. + decompressor = strstr (package, ".tar");
  57. + if (decompressor) {
  58. + /* strip .tar. */
  59. + decompressor += 4;
  60. + // fprintf (stderr, "Decomp: '%s'\n", decompressor);
  61. + if (!*decompressor)
  62. + decompressor = "cat";
  63. + else if (strcmp (decompressor, ".bz2") == 0)
  64. + decompressor = "bzip2";
  65. + else if (strcmp (decompressor, ".gz") == 0)
  66. + decompressor = "gzip";
  67. + else if (strcmp (decompressor, ".lzo") == 0)
  68. + decompressor = "lzop";
  69. + else {
  70. + fprintf (stderr, "Unknown decompressor '%s'.\n",
  71. + decompressor);
  72. + return 1;
  73. + }
  74. + }
  75. - rc = cdb_find(&c, "pkg_name", 8);
  76. - if ( rc <= 0 ) goto error;
  77. - pos = cdb_datapos(&c); len = cdb_datalen(&c);
  78. - pname = malloc(len+1); pname[len] = 0;
  79. - if (cdb_read(&c, pname, len, pos) == -1) goto error;
  80. -
  81. pipe(gem2bunzip);
  82. - pipe(bunzip2tar);
  83. - /*
  84. - * Extract tar.bz2 from GEM file
  85. - */
  86. - if (!fork()) {
  87. - close(gem2bunzip[0]);
  88. - close(bunzip2tar[0]);
  89. - close(bunzip2tar[1]);
  90. + if (!decompressor) {
  91. + decompressor = "bzip2"; /* let the generic code decompress it */
  92. - rc = cdb_find(&c, "pkg_tarbz2", 10);
  93. - if ( rc <= 0 ) exit(1);
  94. + if ( (gem_fd = open(package, O_RDONLY)) < 0 ) goto error_errno;
  95. + cdb_init(&c, gem_fd);
  96. - pos = cdb_datapos(&c);
  97. - len = cdb_datalen(&c);
  98. - if (len <= 0) exit(1);
  99. + rc = cdb_find(&c, "pkg_name", 8);
  100. + if ( rc <= 0 ) goto error;
  101. + pos = cdb_datapos(&c); len = cdb_datalen(&c);
  102. + pname = malloc(len+1); pname[len] = 0;
  103. + if (cdb_read(&c, pname, len, pos) == -1) goto error;
  104. - while (len > 0) {
  105. - if ( cdb_read(&c, buffer, len>512 ? 512 : len,
  106. - pos) == -1 ) goto error;
  107. - write(gem2bunzip[1], buffer, len > 512 ? 512 : len);
  108. - pos += len > 512 ? 512 : len;
  109. - len -= 512;
  110. + /*
  111. + * Extract tar.bz2 from GEM file
  112. + */
  113. + if (!fork()) {
  114. + close(gem2bunzip[0]);
  115. +
  116. + rc = cdb_find(&c, "pkg_tarbz2", 10);
  117. + if ( rc <= 0 ) exit(1);
  118. +
  119. + pos = cdb_datapos(&c);
  120. + len = cdb_datalen(&c);
  121. + if (len <= 0) exit(1);
  122. +
  123. + while (len > 0) {
  124. + if ( cdb_read(&c, buffer, len>512 ? 512 : len,
  125. + pos) == -1 ) goto error;
  126. + write(gem2bunzip[1], buffer, len > 512 ? 512 : len);
  127. + pos += len > 512 ? 512 : len;
  128. + len -= 512;
  129. + }
  130. +
  131. + cdb_free(&c);
  132. + close(gem_fd);
  133. +
  134. + exit(0);
  135. }
  136. + }
  137. + else /* vanilla tar flavour */
  138. + {
  139. + if (!fork()) {
  140. + close(gem2bunzip[0]);
  141. - cdb_free(&c);
  142. - close(gem_fd);
  143. + int fd = open (package, O_RDONLY);
  144. + if (fd < 0) goto error_errno;
  145. + int len;
  146. + do {
  147. + len = read(fd, buffer, sizeof(buffer));
  148. + if (len < 0) goto error;
  149. + write(gem2bunzip[1], buffer, len);
  150. - exit(0);
  151. + } while (len > 0);
  152. +
  153. + close(fd);
  154. + exit(0);
  155. + }
  156. }
  157. + pipe(bunzip2tar);
  158. +
  159. /*
  160. - * Bunzip tar.bz2 file
  161. + * decompress
  162. */
  163. if (!fork()) {
  164. close(gem2bunzip[1]);
  165. close(bunzip2tar[0]);
  166. - b = BZ2_bzdopen(gem2bunzip[0], "r");
  167. - while ( (rc=BZ2_bzread(b, buffer, 512)) > 0 )
  168. - write(bunzip2tar[1], buffer, rc);
  169. - BZ2_bzclose(b);
  170. -
  171. - exit(0);
  172. + dup2 (gem2bunzip[0], 0);
  173. + dup2 (bunzip2tar[1], 1);
  174. + close (gem2bunzip[0]);
  175. + close (bunzip2tar[1]);
  176. + if (strcmp (decompressor, "cat") == 0)
  177. + execlp (decompressor, decompressor, NULL);
  178. + else
  179. + execlp (decompressor, decompressor, "-d", "-c", NULL);
  180. + goto error_errno;
  181. }
  182. /*
  183. @@ -133,6 +177,9 @@
  184. close(gem2bunzip[1]);
  185. close(bunzip2tar[1]);
  186. + if ( ! mode_force )
  187. + md5sum_initdb(root, mode_verbose);
  188. +
  189. if (tar_fdopen(&t, bunzip2tar[0], "pipe", NULL,
  190. O_RDONLY, 0, 0) == -1) goto error_errno;
  191. if ( mode_test && mode_verbose ) printf("-- %s --\n", pname);
  192. @@ -225,7 +272,9 @@
  193. error_errno:
  194. fprintf(stderr, "While installing GEM file %s%s%s%s: %s\n", package,
  195. - filename?" (":"", filename?filename:"", filename?"(":"",
  196. + filename ? " (" : "",
  197. + filename ? filename : "",
  198. + filename ? ")" : "",
  199. errno ? strerror(errno) : "Unknown error");
  200. if ( t != NULL) tar_close(t);
  201. if ( gem_fd != -1 ) { cdb_free(&c); close(gem_fd); }
  202. Index: Makefile
  203. ===================================================================
  204. --- ./Makefile (revision 3)
  205. +++ ./Makefile (revision 13)
  206. @@ -6,12 +6,6 @@
  207. CDB_OBJ = $(CDB_DIR)/cdb.a $(CDB_DIR)/alloc.a $(CDB_DIR)/buffer.a
  208. CDB_OBJ += $(CDB_DIR)/byte.a $(CDB_DIR)/unix.a
  209. -# LibBzip2 Sub-Package
  210. -#
  211. -BZIP2_VER = 1.0.2
  212. -BZIP2_DIR = bzip2-$(BZIP2_VER)
  213. -BZIP2_OBJ = $(BZIP2_DIR)/libbz2.a
  214. -
  215. # LibTar Sub-Package
  216. #
  217. LIBTAR_VER = 1.2.11
  218. @@ -43,11 +37,11 @@
  219. # The usual list of build targets
  220. #
  221. -MINE_ALL_OBJS = $(MINE_OBJ) $(CDB_OBJ) $(BZIP2_OBJ) $(LIBTAR_OBJ)
  222. +MINE_ALL_OBJS = $(MINE_OBJ) $(CDB_OBJ) $(LIBTAR_OBJ)
  223. # Set and configure the c-compiler
  224. #
  225. -CFLAGS = -I$(CDB_DIR) -I$(BZIP2_DIR) -I$(LIBTAR_DIR)/lib -I. -Wall -Os
  226. +CFLAGS = -I$(CDB_DIR) -I/usr/include -I$(LIBTAR_DIR)/lib -I. -Wall -Os
  227. CFLAGS += -I$(LIBTAR_DIR)/listhash -DMINE_VERSION=\"$(MINE_VER)\" -ggdb
  228. CFLAGS += -DGEMCACHE=\"/var/cache/gem\" -DMINECURLOPT=\"/etc/mine.curlopt\"
  229. ifeq ($(USE_AVL), 1)
  230. @@ -86,7 +80,7 @@
  231. $(CC) $(MINE_ALL_OBJS) -o mine
  232. mine.static:
  233. - $(CC) $(MINE_ALL_OBJS) -static -o mine.static
  234. + $(CC) -static $(MINE_ALL_OBJS) $(MINE_ALL_LIBS) -o mine.static
  235. gasgui: $(GAS_OBJ)
  236. $(CC) $(GAS_OBJ) -ldialog -lcurses -lm -o gasgui
  237. @@ -100,22 +94,18 @@
  238. endif
  239. [ -f $(sysprefix)/etc/rocket.conf ] || cp rocket.conf $(sysprefix)/etc/
  240. -$(MINE_OBJ): $(CDB_OBJ) $(BZIP2_OBJ) $(LIBTAR_OBJ)
  241. +$(MINE_OBJ): $(CDB_OBJ) $(LIBTAR_OBJ)
  242. $(CDB_OBJ):
  243. $(BUILDCC) -o $(CDB_DIR)/auto-str $(CDB_DIR)/auto-str.c
  244. $(MAKE) 'AR=$(AR)' 'RANLIB=$(RANLIB)' -C $(CDB_DIR)
  245. -$(BZIP2_OBJ):
  246. - $(MAKE) -C $(BZIP2_DIR) libbz2.a
  247. -
  248. $(LIBTAR_OBJ):
  249. cd $(LIBTAR_DIR) && ./configure --without-zlib $(CONFOPT)
  250. $(MAKE) -C $(LIBTAR_DIR)
  251. patchfiles:
  252. sh xdiff.sh $(CDB_DIR)/ > $(CDB_DIR).patch
  253. -# sh xdiff.sh (BZIP2_DIR)/ > $(BZIP2_DIR).patch
  254. sh xdiff.sh $(LIBTAR_DIR)/ > $(LIBTAR_DIR).patch
  255. clean:
  256. @@ -124,7 +114,6 @@
  257. grep -qx "$${x#$(CDB_DIR)/}" $(CDB_DIR)/FILES || rm -v $$x ; \
  258. done
  259. @rm -vf *.o mine mine.static gasgui core
  260. - -@make -C $(BZIP2_DIR) distclean
  261. -@make -C $(LIBTAR_DIR) distclean
  262. echo "GEM MINE $(MINE_VER)" > VERSION
  263. --- ./readdb.c 2005-03-23 09:51:06.000000000 +0100
  264. +++ ./readdb.c 2006-06-05 14:55:33.817538500 +0200
  265. @@ -1,6 +1,7 @@
  266. /*
  267. * GEM MINE - The ROCK Linux Package Manager
  268. * Copyright (C) 2002-2005 Clifford Wolf
  269. + * Copyright (C) 2006 Ren� Rebe
  270. *
  271. * This program is free software; you can redistribute it and/or modify
  272. * it under the terms of the GNU General Public License as published by
  273. @@ -215,11 +216,12 @@
  274. }
  275. if ( !dbf ) fclose(f);
  276. - snprintf(line, 1024, "%s/pkgs/%s-%s.gem", config, p->name, p->version);
  277. + /* without extension, it is cut off above */
  278. + snprintf(line, 1024, "%s/pkgs/%s-%s", config, p->name, p->version);
  279. if ( memdb_get(&files_on_disks, line) ) {
  280. p->disk_number = atoi(memdb_search_result);
  281. } else {
  282. - snprintf(line, 1024, "%s/pkgs/%s.gem", config, p->name);
  283. + snprintf(line, 1024, "%s/pkgs/%s", config, p->name);
  284. if ( memdb_get(&files_on_disks, line) )
  285. p->disk_number = atoi(memdb_search_result);
  286. }
  287. @@ -420,7 +423,12 @@
  288. snprintf(pkgdir, 200, "%s/pkgs/", config);
  289. while ( fgets(line, 160, f) != NULL ) {
  290. + char* s;
  291. sscanf(line, "disk%s %s", disk, filename);
  292. + /* cut the extension */
  293. + s = strstr (filename, ".tar.");
  294. + if ( !s ) s = strstr (filename, ".gem");
  295. + if ( s ) *s = 0;
  296. if ( !strncmp(filename, pkgdir, strlen(pkgdir)) )
  297. memdb_put(&files_on_disks, filename, disk);
  298. if ( atoi(disk) > max_disk_number )