1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # T2 SDE: package/*/mine/any-archiver.patch
3 # Copyright (C) 2004 - 2024 The T2 SDE Project
5 # This Copyright note is generated by scripts/Create-CopyPatch,
6 # more information can be found in the files COPYING and README.
8 # This patch file is dual-licensed. It is available under the license the
9 # patched project is licensed under, as long as it is an OpenSource license
10 # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
11 # of the GNU General Public License version 2 as used by the T2 SDE.
12 # --- T2-COPYRIGHT-NOTE-END ---
14 This fixes a few bugs like crashing on non-existing file and reading the
15 package database before checking for the file.
17 Implements using any compressed tar package as archiver and not use the
18 bzip2 copy but the systen compressors.
20 (This is just a quick gap filler until we get rid of the whole mine mess.)
22 - Rene Rebe <rene@exactcode.de>
25 ===================================================================
26 --- ./install.c (revision 3)
27 +++ ./install.c (revision 13)
30 * GEM MINE - The ROCK Linux Package Manager
31 * Copyright (C) 2002-2005 Clifford Wolf
32 + * Copyright (C) 2005-2024 René Rebe
34 * This program is free software; you can redistribute it and/or modify
35 * it under the terms of the GNU General Public License as published by
50 + char *decompressor = 0;
58 - md5sum_initdb(root, mode_verbose);
61 - if ( (gem_fd = open(package, O_RDONLY)) < 0 ) goto error_errno;
62 - cdb_init(&c, gem_fd);
63 + decompressor = strstr (package, ".tar");
67 + /* some substitution, other, e.g. lzma are used as it */
69 + decompressor = "cat";
70 + else if (strcmp (decompressor, ".bz2") == 0)
71 + decompressor = "bzip2";
72 + else if (strcmp (decompressor, ".gz") == 0)
73 + decompressor = "gzip";
74 + else if (strcmp (decompressor, ".lzo") == 0)
75 + decompressor = "lzop";
76 + else if (strcmp (decompressor, ".lzma") == 0)
77 + decompressor = "lzma";
78 + else if (strcmp (decompressor, ".xz") == 0)
79 + decompressor = "xz";
80 + else if (strcmp (decompressor, ".zst") == 0)
81 + decompressor = "zstd";
82 + else if (strcmp (decompressor, ".br") == 0)
83 + decompressor = "brotli";
85 + ++decompressor; /* skip over leading dot (.) */
88 - rc = cdb_find(&c, "pkg_name", 8);
89 - if ( rc <= 0 ) goto error;
90 - pos = cdb_datapos(&c); len = cdb_datalen(&c);
91 - pname = malloc(len+1); pname[len] = 0;
92 - if (cdb_read(&c, pname, len, pos) == -1) goto error;
98 - * Extract tar.bz2 from GEM file
101 - close(gem2bunzip[0]);
102 - close(bunzip2tar[0]);
103 - close(bunzip2tar[1]);
104 + if (!decompressor) {
105 + decompressor = "bzip2"; /* let the generic code decompress it */
107 - rc = cdb_find(&c, "pkg_tarbz2", 10);
108 - if ( rc <= 0 ) exit(1);
109 + if ( (gem_fd = open(package, O_RDONLY)) < 0 ) goto error_errno;
110 + cdb_init(&c, gem_fd);
112 - pos = cdb_datapos(&c);
113 - len = cdb_datalen(&c);
114 - if (len <= 0) exit(1);
115 + rc = cdb_find(&c, "pkg_name", 8);
116 + if ( rc <= 0 ) goto error;
117 + pos = cdb_datapos(&c); len = cdb_datalen(&c);
118 + pname = malloc(len+1); pname[len] = 0;
119 + if (cdb_read(&c, pname, len, pos) == -1) goto error;
122 - if ( cdb_read(&c, buffer, len>512 ? 512 : len,
123 - pos) == -1 ) goto error;
124 - write(gem2bunzip[1], buffer, len > 512 ? 512 : len);
125 - pos += len > 512 ? 512 : len;
128 + * Extract tar.bz2 from GEM file
131 + close(gem2bunzip[0]);
133 + rc = cdb_find(&c, "pkg_tarbz2", 10);
134 + if ( rc <= 0 ) exit(1);
136 + pos = cdb_datapos(&c);
137 + len = cdb_datalen(&c);
138 + if (len <= 0) exit(1);
141 + if ( cdb_read(&c, buffer, len>512 ? 512 : len,
142 + pos) == -1 ) goto error;
143 + write(gem2bunzip[1], buffer, len > 512 ? 512 : len);
144 + pos += len > 512 ? 512 : len;
154 + else /* vanilla tar flavour */
157 + close(gem2bunzip[0]);
161 + int fd = open (package, O_RDONLY);
162 + if (fd < 0) goto error_errno;
165 + len = read(fd, buffer, sizeof(buffer));
166 + if (len < 0) goto error;
167 + write(gem2bunzip[1], buffer, len);
180 - * Bunzip tar.bz2 file
184 close(gem2bunzip[1]);
185 close(bunzip2tar[0]);
187 - b = BZ2_bzdopen(gem2bunzip[0], "r");
188 - while ( (rc=BZ2_bzread(b, buffer, 512)) > 0 )
189 - write(bunzip2tar[1], buffer, rc);
193 + dup2 (gem2bunzip[0], 0);
194 + dup2 (bunzip2tar[1], 1);
195 + close (gem2bunzip[0]);
196 + close (bunzip2tar[1]);
197 + if (strcmp (decompressor, "cat") == 0)
198 + execlp (decompressor, decompressor, NULL);
200 + execlp (decompressor, decompressor, "-d", "-c", NULL);
206 close(gem2bunzip[1]);
207 close(bunzip2tar[1]);
209 + if ( ! mode_force )
210 + md5sum_initdb(root, mode_verbose);
212 if (tar_fdopen(&t, bunzip2tar[0], "pipe", NULL,
213 O_RDONLY, 0, 0) == -1) goto error_errno;
214 if ( mode_test && mode_verbose ) printf("-- %s --\n", pname);
218 fprintf(stderr, "While installing GEM file %s%s%s%s: %s\n", package,
219 - filename?" (":"", filename?filename:"", filename?"(":"",
220 + filename ? " (" : "",
221 + filename ? filename : "",
222 + filename ? ")" : "",
223 errno ? strerror(errno) : "Unknown error");
224 if ( t != NULL) tar_close(t);
225 if ( gem_fd != -1 ) { cdb_free(&c); close(gem_fd); }
227 ===================================================================
228 --- ./Makefile (revision 3)
229 +++ ./Makefile (revision 13)
231 CDB_OBJ = $(CDB_DIR)/cdb.a $(CDB_DIR)/alloc.a $(CDB_DIR)/buffer.a
232 CDB_OBJ += $(CDB_DIR)/byte.a $(CDB_DIR)/unix.a
234 -# LibBzip2 Sub-Package
237 -BZIP2_DIR = bzip2-$(BZIP2_VER)
238 -BZIP2_OBJ = $(BZIP2_DIR)/libbz2.a
245 # The usual list of build targets
247 -MINE_ALL_OBJS = $(MINE_OBJ) $(CDB_OBJ) $(BZIP2_OBJ) $(LIBTAR_OBJ)
248 +MINE_ALL_OBJS = $(MINE_OBJ) $(CDB_OBJ) $(LIBTAR_OBJ)
250 # Set and configure the c-compiler
252 -CFLAGS = -I$(CDB_DIR) -I$(BZIP2_DIR) -I$(LIBTAR_DIR)/lib -I. -Wall -Os
253 +CFLAGS = -I$(CDB_DIR) -I/usr/include -I$(LIBTAR_DIR)/lib -I. -Wall -Os
254 CFLAGS += -I$(LIBTAR_DIR)/listhash -DMINE_VERSION=\"$(MINE_VER)\" -ggdb
255 CFLAGS += -DGEMCACHE=\"/var/cache/gem\" -DMINECURLOPT=\"/etc/mine.curlopt\"
258 $(CC) $(MINE_ALL_OBJS) -o mine
261 - $(CC) $(MINE_ALL_OBJS) -static -o mine.static
262 + $(CC) -static $(MINE_ALL_OBJS) $(MINE_ALL_LIBS) -o mine.static
265 $(CC) $(GAS_OBJ) -ldialog -lcurses -lm -o gasgui
268 [ -f $(sysprefix)/etc/rocket.conf ] || cp rocket.conf $(sysprefix)/etc/
270 -$(MINE_OBJ): $(CDB_OBJ) $(BZIP2_OBJ) $(LIBTAR_OBJ)
271 +$(MINE_OBJ): $(CDB_OBJ) $(LIBTAR_OBJ)
274 $(BUILDCC) -o $(CDB_DIR)/auto-str $(CDB_DIR)/auto-str.c
275 $(MAKE) 'AR=$(AR)' 'RANLIB=$(RANLIB)' -C $(CDB_DIR)
278 - $(MAKE) -C $(BZIP2_DIR) libbz2.a
281 cd $(LIBTAR_DIR) && ./configure --without-zlib $(CONFOPT)
282 $(MAKE) -C $(LIBTAR_DIR)
285 sh xdiff.sh $(CDB_DIR)/ > $(CDB_DIR).patch
286 -# sh xdiff.sh (BZIP2_DIR)/ > $(BZIP2_DIR).patch
287 sh xdiff.sh $(LIBTAR_DIR)/ > $(LIBTAR_DIR).patch
291 grep -qx "$${x#$(CDB_DIR)/}" $(CDB_DIR)/FILES || rm -v $$x ; \
293 @rm -vf *.o mine mine.static gasgui core
294 - -@make -C $(BZIP2_DIR) distclean
295 -@make -C $(LIBTAR_DIR) distclean
296 echo "GEM MINE $(MINE_VER)" > VERSION
298 --- ./readdb.c 2005-03-23 09:51:06.000000000 +0100
299 +++ ./readdb.c 2006-06-05 14:55:33.817538500 +0200
302 * GEM MINE - The ROCK Linux Package Manager
303 * Copyright (C) 2002-2005 Clifford Wolf
304 + * Copyright (C) 2006 René Rebe
306 * This program is free software; you can redistribute it and/or modify
307 * it under the terms of the GNU General Public License as published by
308 @@ -215,11 +216,12 @@
310 if ( !dbf ) fclose(f);
312 - snprintf(line, 1024, "%s/pkgs/%s-%s.gem", config, p->name, p->version);
313 + /* without extension, it is cut off above */
314 + snprintf(line, 1024, "%s/pkgs/%s-%s", config, p->name, p->version);
315 if ( memdb_get(&files_on_disks, line) ) {
316 p->disk_number = atoi(memdb_search_result);
318 - snprintf(line, 1024, "%s/pkgs/%s.gem", config, p->name);
319 + snprintf(line, 1024, "%s/pkgs/%s", config, p->name);
320 if ( memdb_get(&files_on_disks, line) )
321 p->disk_number = atoi(memdb_search_result);
324 snprintf(pkgdir, 200, "%s/pkgs/", config);
326 while ( fgets(line, 160, f) != NULL ) {
328 sscanf(line, "disk%s %s", disk, filename);
329 + /* cut the extension */
330 + s = strstr (filename, ".tar.");
331 + if ( !s ) s = strstr (filename, ".gem");
333 if ( !strncmp(filename, pkgdir, strlen(pkgdir)) )
334 memdb_put(&files_on_disks, filename, disk);
335 if ( atoi(disk) > max_disk_number )