1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
4 # T2 SDE: package/.../mine/any-archiver.patch
5 # Copyright (C) 2004 - 2016 The T2 SDE Project
7 # More information can be found in the files COPYING and README.
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
15 # --- T2-COPYRIGHT-NOTE-END ---
17 This fixes a few bugs like crashing on non-existing file and reading the
18 package database before checking for the file.
20 Implements using any compressed tar package as archiver and not use the
21 bzip2 copy but the systen compressors.
23 (This is just a quick gap filler until we get rid of the whole mine mess.)
25 - Rene Rebe <rene@exactcode.de>
28 ===================================================================
29 --- ./install.c (revision 3)
30 +++ ./install.c (revision 13)
33 * GEM MINE - The ROCK Linux Package Manager
34 * Copyright (C) 2002-2005 Clifford Wolf
35 + * Copyright (C) 2005-2010 René Rebe
37 * This program is free software; you can redistribute it and/or modify
38 * it under the terms of the GNU General Public License as published by
53 + char *decompressor = 0;
61 - md5sum_initdb(root, mode_verbose);
64 - if ( (gem_fd = open(package, O_RDONLY)) < 0 ) goto error_errno;
65 - cdb_init(&c, gem_fd);
66 + decompressor = strstr (package, ".tar");
70 + /* some substitution, other, e.g. lzma are used as it */
72 + decompressor = "cat";
73 + else if (strcmp (decompressor, ".bz2") == 0)
74 + decompressor = "bzip2";
75 + else if (strcmp (decompressor, ".gz") == 0)
76 + decompressor = "gzip";
77 + else if (strcmp (decompressor, ".lzo") == 0)
78 + decompressor = "lzop";
79 + else if (strcmp (decompressor, ".lzma") == 0)
80 + decompressor = "lzma";
81 + else if (strcmp (decompressor, ".xz") == 0)
82 + decompressor = "xz";
83 + else if (strcmp (decompressor, ".zst") == 0)
84 + decompressor = "zstd";
86 + ++decompressor; /* skip over leading dot (.) */
89 - rc = cdb_find(&c, "pkg_name", 8);
90 - if ( rc <= 0 ) goto error;
91 - pos = cdb_datapos(&c); len = cdb_datalen(&c);
92 - pname = malloc(len+1); pname[len] = 0;
93 - if (cdb_read(&c, pname, len, pos) == -1) goto error;
99 - * Extract tar.bz2 from GEM file
102 - close(gem2bunzip[0]);
103 - close(bunzip2tar[0]);
104 - close(bunzip2tar[1]);
105 + if (!decompressor) {
106 + decompressor = "bzip2"; /* let the generic code decompress it */
108 - rc = cdb_find(&c, "pkg_tarbz2", 10);
109 - if ( rc <= 0 ) exit(1);
110 + if ( (gem_fd = open(package, O_RDONLY)) < 0 ) goto error_errno;
111 + cdb_init(&c, gem_fd);
113 - pos = cdb_datapos(&c);
114 - len = cdb_datalen(&c);
115 - if (len <= 0) exit(1);
116 + rc = cdb_find(&c, "pkg_name", 8);
117 + if ( rc <= 0 ) goto error;
118 + pos = cdb_datapos(&c); len = cdb_datalen(&c);
119 + pname = malloc(len+1); pname[len] = 0;
120 + if (cdb_read(&c, pname, len, pos) == -1) goto error;
123 - if ( cdb_read(&c, buffer, len>512 ? 512 : len,
124 - pos) == -1 ) goto error;
125 - write(gem2bunzip[1], buffer, len > 512 ? 512 : len);
126 - pos += len > 512 ? 512 : len;
129 + * Extract tar.bz2 from GEM file
132 + close(gem2bunzip[0]);
134 + rc = cdb_find(&c, "pkg_tarbz2", 10);
135 + if ( rc <= 0 ) exit(1);
137 + pos = cdb_datapos(&c);
138 + len = cdb_datalen(&c);
139 + if (len <= 0) exit(1);
142 + if ( cdb_read(&c, buffer, len>512 ? 512 : len,
143 + pos) == -1 ) goto error;
144 + write(gem2bunzip[1], buffer, len > 512 ? 512 : len);
145 + pos += len > 512 ? 512 : len;
155 + else /* vanilla tar flavour */
158 + close(gem2bunzip[0]);
162 + int fd = open (package, O_RDONLY);
163 + if (fd < 0) goto error_errno;
166 + len = read(fd, buffer, sizeof(buffer));
167 + if (len < 0) goto error;
168 + write(gem2bunzip[1], buffer, len);
181 - * Bunzip tar.bz2 file
185 close(gem2bunzip[1]);
186 close(bunzip2tar[0]);
188 - b = BZ2_bzdopen(gem2bunzip[0], "r");
189 - while ( (rc=BZ2_bzread(b, buffer, 512)) > 0 )
190 - write(bunzip2tar[1], buffer, rc);
194 + dup2 (gem2bunzip[0], 0);
195 + dup2 (bunzip2tar[1], 1);
196 + close (gem2bunzip[0]);
197 + close (bunzip2tar[1]);
198 + if (strcmp (decompressor, "cat") == 0)
199 + execlp (decompressor, decompressor, NULL);
201 + execlp (decompressor, decompressor, "-d", "-c", NULL);
207 close(gem2bunzip[1]);
208 close(bunzip2tar[1]);
210 + if ( ! mode_force )
211 + md5sum_initdb(root, mode_verbose);
213 if (tar_fdopen(&t, bunzip2tar[0], "pipe", NULL,
214 O_RDONLY, 0, 0) == -1) goto error_errno;
215 if ( mode_test && mode_verbose ) printf("-- %s --\n", pname);
219 fprintf(stderr, "While installing GEM file %s%s%s%s: %s\n", package,
220 - filename?" (":"", filename?filename:"", filename?"(":"",
221 + filename ? " (" : "",
222 + filename ? filename : "",
223 + filename ? ")" : "",
224 errno ? strerror(errno) : "Unknown error");
225 if ( t != NULL) tar_close(t);
226 if ( gem_fd != -1 ) { cdb_free(&c); close(gem_fd); }
228 ===================================================================
229 --- ./Makefile (revision 3)
230 +++ ./Makefile (revision 13)
232 CDB_OBJ = $(CDB_DIR)/cdb.a $(CDB_DIR)/alloc.a $(CDB_DIR)/buffer.a
233 CDB_OBJ += $(CDB_DIR)/byte.a $(CDB_DIR)/unix.a
235 -# LibBzip2 Sub-Package
238 -BZIP2_DIR = bzip2-$(BZIP2_VER)
239 -BZIP2_OBJ = $(BZIP2_DIR)/libbz2.a
246 # The usual list of build targets
248 -MINE_ALL_OBJS = $(MINE_OBJ) $(CDB_OBJ) $(BZIP2_OBJ) $(LIBTAR_OBJ)
249 +MINE_ALL_OBJS = $(MINE_OBJ) $(CDB_OBJ) $(LIBTAR_OBJ)
251 # Set and configure the c-compiler
253 -CFLAGS = -I$(CDB_DIR) -I$(BZIP2_DIR) -I$(LIBTAR_DIR)/lib -I. -Wall -Os
254 +CFLAGS = -I$(CDB_DIR) -I/usr/include -I$(LIBTAR_DIR)/lib -I. -Wall -Os
255 CFLAGS += -I$(LIBTAR_DIR)/listhash -DMINE_VERSION=\"$(MINE_VER)\" -ggdb
256 CFLAGS += -DGEMCACHE=\"/var/cache/gem\" -DMINECURLOPT=\"/etc/mine.curlopt\"
259 $(CC) $(MINE_ALL_OBJS) -o mine
262 - $(CC) $(MINE_ALL_OBJS) -static -o mine.static
263 + $(CC) -static $(MINE_ALL_OBJS) $(MINE_ALL_LIBS) -o mine.static
266 $(CC) $(GAS_OBJ) -ldialog -lcurses -lm -o gasgui
269 [ -f $(sysprefix)/etc/rocket.conf ] || cp rocket.conf $(sysprefix)/etc/
271 -$(MINE_OBJ): $(CDB_OBJ) $(BZIP2_OBJ) $(LIBTAR_OBJ)
272 +$(MINE_OBJ): $(CDB_OBJ) $(LIBTAR_OBJ)
275 $(BUILDCC) -o $(CDB_DIR)/auto-str $(CDB_DIR)/auto-str.c
276 $(MAKE) 'AR=$(AR)' 'RANLIB=$(RANLIB)' -C $(CDB_DIR)
279 - $(MAKE) -C $(BZIP2_DIR) libbz2.a
282 cd $(LIBTAR_DIR) && ./configure --without-zlib $(CONFOPT)
283 $(MAKE) -C $(LIBTAR_DIR)
286 sh xdiff.sh $(CDB_DIR)/ > $(CDB_DIR).patch
287 -# sh xdiff.sh (BZIP2_DIR)/ > $(BZIP2_DIR).patch
288 sh xdiff.sh $(LIBTAR_DIR)/ > $(LIBTAR_DIR).patch
292 grep -qx "$${x#$(CDB_DIR)/}" $(CDB_DIR)/FILES || rm -v $$x ; \
294 @rm -vf *.o mine mine.static gasgui core
295 - -@make -C $(BZIP2_DIR) distclean
296 -@make -C $(LIBTAR_DIR) distclean
297 echo "GEM MINE $(MINE_VER)" > VERSION
299 --- ./readdb.c 2005-03-23 09:51:06.000000000 +0100
300 +++ ./readdb.c 2006-06-05 14:55:33.817538500 +0200
303 * GEM MINE - The ROCK Linux Package Manager
304 * Copyright (C) 2002-2005 Clifford Wolf
305 + * Copyright (C) 2006 René Rebe
307 * This program is free software; you can redistribute it and/or modify
308 * it under the terms of the GNU General Public License as published by
309 @@ -215,11 +216,12 @@
311 if ( !dbf ) fclose(f);
313 - snprintf(line, 1024, "%s/pkgs/%s-%s.gem", config, p->name, p->version);
314 + /* without extension, it is cut off above */
315 + snprintf(line, 1024, "%s/pkgs/%s-%s", config, p->name, p->version);
316 if ( memdb_get(&files_on_disks, line) ) {
317 p->disk_number = atoi(memdb_search_result);
319 - snprintf(line, 1024, "%s/pkgs/%s.gem", config, p->name);
320 + snprintf(line, 1024, "%s/pkgs/%s", config, p->name);
321 if ( memdb_get(&files_on_disks, line) )
322 p->disk_number = atoi(memdb_search_result);
325 snprintf(pkgdir, 200, "%s/pkgs/", config);
327 while ( fgets(line, 160, f) != NULL ) {
329 sscanf(line, "disk%s %s", disk, filename);
330 + /* cut the extension */
331 + s = strstr (filename, ".tar.");
332 + if ( !s ) s = strstr (filename, ".gem");
334 if ( !strncmp(filename, pkgdir, strlen(pkgdir)) )
335 memdb_put(&files_on_disks, filename, disk);
336 if ( atoi(disk) > max_disk_number )