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
						
					
					
				
			
		
		
	
	
							333 lines
						
					
					
						
							9.3 KiB
						
					
					
				# --- T2-COPYRIGHT-NOTE-BEGIN --- | 
						|
# This copyright note is auto-generated by ./scripts/Create-CopyPatch. | 
						|
#  | 
						|
# T2 SDE: package/.../mine/any-archiver.patch | 
						|
# Copyright (C) 2004 - 2006 The T2 SDE Project | 
						|
#  | 
						|
# More information can be found in the files COPYING and README. | 
						|
#  | 
						|
# This patch file is dual-licensed. It is available under the license the | 
						|
# patched project is licensed under, as long as it is an OpenSource license | 
						|
# as defined at http://www.opensource.org/ (e.g. BSD, X11) or 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. | 
						|
# --- T2-COPYRIGHT-NOTE-END --- | 
						|
 | 
						|
this fixes a few bugs like crashing on non-existing file and reading the | 
						|
package database before checking for the file. | 
						|
 | 
						|
Implements using any compressed tar package as archiver and not use the | 
						|
bzip2 copy but the systen compressors. | 
						|
 | 
						|
(This is just a quick gap filler until we get rid of the whole mine mess.) | 
						|
 | 
						|
  - Rene Rebe <[email protected]> | 
						|
 | 
						|
Index: install.c | 
						|
=================================================================== | 
						|
--- ./install.c	(revision 3) | 
						|
+++ ./install.c	(revision 13) | 
						|
@@ -1,6 +1,7 @@ | 
						|
 /* | 
						|
  *  GEM MINE - The ROCK Linux Package Manager | 
						|
  *  Copyright (C) 2002-2005 Clifford Wolf | 
						|
+ *  Copyright (C) 2005-2006 René 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 | 
						|
@@ -29,7 +30,6 @@ | 
						|
 #include <fnmatch.h> | 
						|
  | 
						|
 #include "cdb.h" | 
						|
-#include "bzlib.h" | 
						|
 #include "libtar.h" | 
						|
  | 
						|
 #include "mine.h" | 
						|
@@ -60,70 +60,114 @@ | 
						|
 	int pos, len; | 
						|
 	int rc; | 
						|
  | 
						|
-	char *filename; | 
						|
+	char *filename = 0; | 
						|
+	char *decompressor = 0; | 
						|
 	char buffer[1024]; | 
						|
 	char buffer2[1024]; | 
						|
 	char buffer3[1024]; | 
						|
 	TAR *t = NULL; | 
						|
-	BZFILE *b = NULL; | 
						|
  | 
						|
-	if ( ! mode_force ) | 
						|
-		md5sum_initdb(root, mode_verbose); | 
						|
+	errno = 0; | 
						|
  | 
						|
-	if ( (gem_fd = open(package, O_RDONLY)) < 0 ) goto error_errno; | 
						|
-	cdb_init(&c, gem_fd); | 
						|
+	decompressor = strstr (package, ".tar"); | 
						|
+	if (decompressor) { | 
						|
+	/* strip .tar. */ | 
						|
+	decompressor += 4; | 
						|
+		// fprintf (stderr, "Decomp: '%s'\n", decompressor); | 
						|
+		if (!*decompressor) | 
						|
+			decompressor = "cat"; | 
						|
+		else if (strcmp (decompressor, ".bz2") == 0) | 
						|
+			decompressor = "bzip2"; | 
						|
+		else if (strcmp (decompressor, ".gz") == 0) | 
						|
+			decompressor = "gzip"; | 
						|
+		else if (strcmp (decompressor, ".lzo") == 0) | 
						|
+			decompressor = "lzop"; | 
						|
+		else { | 
						|
+			fprintf (stderr, "Unknown decompressor '%s'.\n", | 
						|
+			         decompressor); | 
						|
+			return 1; | 
						|
+		} | 
						|
+	} | 
						|
  | 
						|
-	rc = cdb_find(&c, "pkg_name", 8); | 
						|
-	if ( rc <= 0 ) goto error; | 
						|
-	pos = cdb_datapos(&c); len = cdb_datalen(&c); | 
						|
-	pname = malloc(len+1); pname[len] = 0; | 
						|
-	if (cdb_read(&c, pname, len, pos) == -1) goto error; | 
						|
- | 
						|
 	pipe(gem2bunzip); | 
						|
-	pipe(bunzip2tar); | 
						|
  | 
						|
-	/* | 
						|
-	 * Extract tar.bz2 from GEM file | 
						|
-	 */ | 
						|
-	if (!fork()) { | 
						|
-		close(gem2bunzip[0]); | 
						|
-		close(bunzip2tar[0]); | 
						|
-		close(bunzip2tar[1]); | 
						|
+	if (!decompressor) { | 
						|
+		decompressor = "bzip2"; /* let the generic code decompress it */ | 
						|
  | 
						|
-		rc = cdb_find(&c, "pkg_tarbz2", 10); | 
						|
-		if ( rc <= 0 ) exit(1); | 
						|
+		if ( (gem_fd = open(package, O_RDONLY)) < 0 ) goto error_errno; | 
						|
+		cdb_init(&c, gem_fd); | 
						|
  | 
						|
-		pos = cdb_datapos(&c); | 
						|
-		len = cdb_datalen(&c); | 
						|
-		if (len <= 0) exit(1); | 
						|
+		rc = cdb_find(&c, "pkg_name", 8); | 
						|
+		if ( rc <= 0 ) goto error; | 
						|
+		pos = cdb_datapos(&c); len = cdb_datalen(&c); | 
						|
+		pname = malloc(len+1); pname[len] = 0; | 
						|
+		if (cdb_read(&c, pname, len, pos) == -1) goto error; | 
						|
  | 
						|
-		while (len > 0) { | 
						|
-			if ( cdb_read(&c, buffer, len>512 ? 512 : len, | 
						|
-			                  pos) == -1 ) goto error; | 
						|
-			write(gem2bunzip[1], buffer, len > 512 ? 512 : len); | 
						|
-			pos += len > 512 ? 512 : len; | 
						|
-			len -= 512; | 
						|
+		/* | 
						|
+		 * Extract tar.bz2 from GEM file | 
						|
+		 */ | 
						|
+		if (!fork()) { | 
						|
+			close(gem2bunzip[0]); | 
						|
+ | 
						|
+			rc = cdb_find(&c, "pkg_tarbz2", 10); | 
						|
+			if ( rc <= 0 ) exit(1); | 
						|
+ | 
						|
+			pos = cdb_datapos(&c); | 
						|
+			len = cdb_datalen(&c); | 
						|
+			if (len <= 0) exit(1); | 
						|
+ | 
						|
+			while (len > 0) { | 
						|
+				if ( cdb_read(&c, buffer, len>512 ? 512 : len, | 
						|
+				                  pos) == -1 ) goto error; | 
						|
+				write(gem2bunzip[1], buffer, len > 512 ? 512 : len); | 
						|
+				pos += len > 512 ? 512 : len; | 
						|
+				len -= 512; | 
						|
+			} | 
						|
+ | 
						|
+			cdb_free(&c); | 
						|
+			close(gem_fd); | 
						|
+ | 
						|
+			exit(0); | 
						|
 		} | 
						|
+	} | 
						|
+	else /* vanilla tar flavour */ | 
						|
+	{ | 
						|
+		if (!fork()) { | 
						|
+			close(gem2bunzip[0]); | 
						|
  | 
						|
-		cdb_free(&c); | 
						|
-		close(gem_fd); | 
						|
+			int fd = open (package, O_RDONLY); | 
						|
+			if (fd < 0) goto error_errno; | 
						|
+			int len; | 
						|
+			do { | 
						|
+				len = read(fd, buffer, sizeof(buffer)); | 
						|
+				if (len < 0) goto error; | 
						|
+				write(gem2bunzip[1], buffer, len); | 
						|
  | 
						|
-		exit(0); | 
						|
+			} while (len > 0); | 
						|
+ | 
						|
+			close(fd); | 
						|
+			exit(0); | 
						|
+		} | 
						|
 	} | 
						|
  | 
						|
+	pipe(bunzip2tar); | 
						|
+ | 
						|
 	/* | 
						|
-	 * Bunzip tar.bz2 file | 
						|
+	 * decompress | 
						|
 	 */ | 
						|
 	if (!fork()) { | 
						|
 		close(gem2bunzip[1]); | 
						|
 		close(bunzip2tar[0]); | 
						|
  | 
						|
-		b = BZ2_bzdopen(gem2bunzip[0], "r"); | 
						|
-		while ( (rc=BZ2_bzread(b, buffer, 512)) > 0 ) | 
						|
-			write(bunzip2tar[1], buffer, rc); | 
						|
-		BZ2_bzclose(b); | 
						|
-		 | 
						|
-		exit(0); | 
						|
+		dup2 (gem2bunzip[0], 0); | 
						|
+		dup2 (bunzip2tar[1], 1); | 
						|
+		close (gem2bunzip[0]); | 
						|
+		close (bunzip2tar[1]); | 
						|
+		if (strcmp (decompressor, "cat") == 0) | 
						|
+			execlp (decompressor, decompressor, NULL); | 
						|
+		else | 
						|
+			execlp (decompressor, decompressor, "-d", "-c", NULL); | 
						|
+		goto error_errno; | 
						|
 	} | 
						|
  | 
						|
 	/* | 
						|
@@ -133,6 +177,9 @@ | 
						|
 	close(gem2bunzip[1]); | 
						|
 	close(bunzip2tar[1]); | 
						|
  | 
						|
+	if ( ! mode_force ) | 
						|
+		md5sum_initdb(root, mode_verbose); | 
						|
+ | 
						|
 	if (tar_fdopen(&t, bunzip2tar[0], "pipe", NULL, | 
						|
 		       O_RDONLY, 0, 0) == -1) goto error_errno; | 
						|
 	if ( mode_test && mode_verbose ) printf("-- %s --\n", pname); | 
						|
@@ -225,7 +272,9 @@ | 
						|
  | 
						|
 error_errno: | 
						|
 	fprintf(stderr, "While installing GEM file %s%s%s%s: %s\n", package, | 
						|
-			filename?" (":"", filename?filename:"", filename?"(":"", | 
						|
+			filename ? " (" : "", | 
						|
+			filename ? filename : "", | 
						|
+			filename ? ")" : "", | 
						|
 	                errno ? strerror(errno) : "Unknown error"); | 
						|
 	if ( t != NULL) tar_close(t); | 
						|
 	if ( gem_fd != -1 ) { cdb_free(&c); close(gem_fd); } | 
						|
Index: Makefile | 
						|
=================================================================== | 
						|
--- ./Makefile	(revision 3) | 
						|
+++ ./Makefile	(revision 13) | 
						|
@@ -6,12 +6,6 @@ | 
						|
 CDB_OBJ  = $(CDB_DIR)/cdb.a  $(CDB_DIR)/alloc.a $(CDB_DIR)/buffer.a | 
						|
 CDB_OBJ += $(CDB_DIR)/byte.a $(CDB_DIR)/unix.a | 
						|
  | 
						|
-# LibBzip2 Sub-Package | 
						|
-# | 
						|
-BZIP2_VER = 1.0.2 | 
						|
-BZIP2_DIR = bzip2-$(BZIP2_VER) | 
						|
-BZIP2_OBJ = $(BZIP2_DIR)/libbz2.a | 
						|
- | 
						|
 # LibTar Sub-Package | 
						|
 # | 
						|
 LIBTAR_VER = 1.2.11 | 
						|
@@ -43,11 +37,11 @@ | 
						|
  | 
						|
 # The usual list of build targets | 
						|
 # | 
						|
-MINE_ALL_OBJS = $(MINE_OBJ) $(CDB_OBJ) $(BZIP2_OBJ) $(LIBTAR_OBJ) | 
						|
+MINE_ALL_OBJS = $(MINE_OBJ) $(CDB_OBJ) $(LIBTAR_OBJ) | 
						|
  | 
						|
 # Set and configure the c-compiler | 
						|
 # | 
						|
-CFLAGS  = -I$(CDB_DIR) -I$(BZIP2_DIR) -I$(LIBTAR_DIR)/lib -I. -Wall -Os | 
						|
+CFLAGS  = -I$(CDB_DIR) -I/usr/include -I$(LIBTAR_DIR)/lib -I. -Wall -Os | 
						|
 CFLAGS += -I$(LIBTAR_DIR)/listhash -DMINE_VERSION=\"$(MINE_VER)\" -ggdb | 
						|
 CFLAGS += -DGEMCACHE=\"/var/cache/gem\" -DMINECURLOPT=\"/etc/mine.curlopt\" | 
						|
 ifeq ($(USE_AVL), 1) | 
						|
@@ -86,7 +80,7 @@ | 
						|
 	$(CC) $(MINE_ALL_OBJS) -o mine | 
						|
  | 
						|
 mine.static: | 
						|
-	$(CC) $(MINE_ALL_OBJS) -static -o mine.static | 
						|
+	$(CC) -static $(MINE_ALL_OBJS) $(MINE_ALL_LIBS) -o mine.static | 
						|
  | 
						|
 gasgui: $(GAS_OBJ) | 
						|
 	$(CC) $(GAS_OBJ) -ldialog -lcurses -lm -o gasgui | 
						|
@@ -100,22 +94,18 @@ | 
						|
 endif | 
						|
 	[ -f $(sysprefix)/etc/rocket.conf ] || cp rocket.conf $(sysprefix)/etc/ | 
						|
  | 
						|
-$(MINE_OBJ): $(CDB_OBJ) $(BZIP2_OBJ) $(LIBTAR_OBJ) | 
						|
+$(MINE_OBJ): $(CDB_OBJ) $(LIBTAR_OBJ) | 
						|
  | 
						|
 $(CDB_OBJ): | 
						|
 	$(BUILDCC) -o $(CDB_DIR)/auto-str $(CDB_DIR)/auto-str.c | 
						|
 	$(MAKE) 'AR=$(AR)' 'RANLIB=$(RANLIB)' -C $(CDB_DIR) | 
						|
  | 
						|
-$(BZIP2_OBJ): | 
						|
-	$(MAKE) -C $(BZIP2_DIR) libbz2.a | 
						|
- | 
						|
 $(LIBTAR_OBJ): | 
						|
 	cd $(LIBTAR_DIR) && ./configure --without-zlib $(CONFOPT) | 
						|
 	$(MAKE) -C $(LIBTAR_DIR) | 
						|
  | 
						|
 patchfiles: | 
						|
 	sh xdiff.sh $(CDB_DIR)/ > $(CDB_DIR).patch | 
						|
-#	sh xdiff.sh (BZIP2_DIR)/ > $(BZIP2_DIR).patch | 
						|
 	sh xdiff.sh $(LIBTAR_DIR)/ > $(LIBTAR_DIR).patch | 
						|
  | 
						|
 clean: | 
						|
@@ -124,7 +114,6 @@ | 
						|
 		grep -qx "$${x#$(CDB_DIR)/}" $(CDB_DIR)/FILES || rm -v $$x ; \ | 
						|
 	done | 
						|
 	@rm -vf *.o mine mine.static gasgui core | 
						|
-	-@make -C $(BZIP2_DIR) distclean | 
						|
 	-@make -C $(LIBTAR_DIR) distclean | 
						|
 	echo "GEM MINE $(MINE_VER)" > VERSION | 
						|
  | 
						|
--- ./readdb.c	2005-03-23 09:51:06.000000000 +0100 | 
						|
+++ ./readdb.c	2006-06-05 14:55:33.817538500 +0200 | 
						|
@@ -1,6 +1,7 @@ | 
						|
 /* | 
						|
  *  GEM MINE - The ROCK Linux Package Manager | 
						|
  *  Copyright (C) 2002-2005 Clifford Wolf | 
						|
+ *  Copyright (C) 2006 René 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 | 
						|
@@ -215,11 +216,12 @@ | 
						|
 	} | 
						|
 	if ( !dbf ) fclose(f); | 
						|
  | 
						|
-	snprintf(line, 1024, "%s/pkgs/%s-%s.gem", config, p->name, p->version); | 
						|
+	/* without extension, it is cut off above */ | 
						|
+	snprintf(line, 1024, "%s/pkgs/%s-%s", config, p->name, p->version); | 
						|
 	if ( memdb_get(&files_on_disks, line) ) { | 
						|
 		p->disk_number = atoi(memdb_search_result); | 
						|
 	} else { | 
						|
-		snprintf(line, 1024, "%s/pkgs/%s.gem", config, p->name); | 
						|
+		snprintf(line, 1024, "%s/pkgs/%s", config, p->name); | 
						|
 		if ( memdb_get(&files_on_disks, line) ) | 
						|
 			p->disk_number = atoi(memdb_search_result); | 
						|
 	} | 
						|
@@ -420,7 +423,12 @@ | 
						|
 			snprintf(pkgdir, 200, "%s/pkgs/", config); | 
						|
  | 
						|
 			while ( fgets(line, 160, f) != NULL ) { | 
						|
+				char* s; | 
						|
 				sscanf(line, "disk%s %s", disk, filename); | 
						|
+				/* cut the extension */ | 
						|
+				s = strstr (filename, ".tar."); | 
						|
+				if ( !s ) s = strstr (filename, ".gem"); | 
						|
+				if ( s ) *s = 0; | 
						|
 				if ( !strncmp(filename, pkgdir, strlen(pkgdir)) ) | 
						|
 					memdb_put(&files_on_disks, filename, disk); | 
						|
 				if ( atoi(disk) > max_disk_number )
 | 
						|
 |