wok rev 897

module-init-tools: use lzlib to load modules compressed with gzip or lzma
author Pascal Bellard <pascal.bellard@slitaz.org>
date Thu Jun 12 11:53:31 2008 +0000 (2008-06-12)
parents 13768ad7e79e
children 5f88af4f7f75
files module-init-tools/receipt module-init-tools/stuff/lzlib.u
line diff
     1.1 --- a/module-init-tools/receipt	Thu Jun 12 11:51:08 2008 +0000
     1.2 +++ b/module-init-tools/receipt	Thu Jun 12 11:53:31 2008 +0000
     1.3 @@ -5,15 +5,17 @@
     1.4  CATEGORY="base-system"
     1.5  SHORT_DESC="Kernel modules manipulation tools."
     1.6  MAINTAINER="pascal.bellard@slitaz.org"
     1.7 -DEPENDS="zlib"
     1.8 +DEPENDS="zlib lzlib"
     1.9  TARBALL="$PACKAGE-$VERSION.tar.gz"
    1.10  WEB_SITE="http://ftp.kernel.org/pub/linux/utils/kernel/module-init-tools/"
    1.11  WGET_URL="${WEB_SITE}$TARBALL"
    1.12 +BUILD_DEPENDS="zlib-dev lzlib-dev lzlib"
    1.13  
    1.14  # Rules to configure and make the package.
    1.15  compile_rules()
    1.16  {
    1.17  	cd $src
    1.18 +	patch -p1 < ../stuff/lzlib.u
    1.19  	./configure --enable-zlib --prefix=/usr \
    1.20  	--sbindir=/sbin --bindir=/bin --sysconfdir=/etc \
    1.21  	--infodir=/usr/share/info --mandir=/usr/share/man \
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/module-init-tools/stuff/lzlib.u	Thu Jun 12 11:53:31 2008 +0000
     2.3 @@ -0,0 +1,83 @@
     2.4 +--- module-init-tools-3.2/zlibsupport.c
     2.5 ++++ module-init-tools-3.2/zlibsupport.c
     2.6 +@@ -16,58 +16,33 @@
     2.7 + #include "testing.h"
     2.8 + 
     2.9 + #ifdef CONFIG_USE_ZLIB
    2.10 +-#include <zlib.h>
    2.11 ++#include <lzlib.h>
    2.12 + 
    2.13 +-void *grab_contents(gzFile *gzfd, unsigned long *size)
    2.14 +-{
    2.15 +-	unsigned int max = 16384;
    2.16 +-	void *buffer = malloc(max);
    2.17 +-	int ret;
    2.18 +-
    2.19 +-	if (!buffer)
    2.20 +-		return NULL;
    2.21 +-
    2.22 +-	*size = 0;
    2.23 +-	while ((ret = gzread(gzfd, buffer + *size, max - *size)) > 0) {
    2.24 +-		*size += ret;
    2.25 +-		if (*size == max) {
    2.26 +-			buffer = realloc(buffer, max *= 2);
    2.27 +-			if (!buffer)
    2.28 +-				return NULL;
    2.29 +-		}
    2.30 +-	}
    2.31 +-	if (ret < 0) {
    2.32 +-		free(buffer);
    2.33 +-		buffer = NULL;
    2.34 +-	}
    2.35 +-	return buffer;
    2.36 +-}
    2.37 +-
    2.38 + void *grab_fd(int fd, unsigned long *size)
    2.39 + {
    2.40 +-	gzFile gzfd;
    2.41 ++	lzFile lzfd;
    2.42 + 
    2.43 +-	gzfd = gzdopen(fd, "rb");
    2.44 +-	if (!gzfd)
    2.45 ++	lzfd = lzdopen(fd, "rb");
    2.46 ++	if (!lzfd)
    2.47 + 		return NULL;
    2.48 + 
    2.49 +-	/* gzclose(gzfd) would close fd, which would drop locks.
    2.50 ++	/* lzclose(lzfd) would close fd, which would drop locks.
    2.51 + 	   Don't blame zlib: POSIX locking semantics are so horribly
    2.52 + 	   broken that they should be ripped out. */
    2.53 +-	return grab_contents(gzfd, size);
    2.54 ++	return lzgrab(lzfd, size);
    2.55 + }
    2.56 + 
    2.57 + /* gzopen handles uncompressed files transparently. */
    2.58 + void *grab_file(const char *filename, unsigned long *size)
    2.59 + {
    2.60 +-	gzFile gzfd;
    2.61 ++	lzFile lzfd;
    2.62 + 	void *buffer;
    2.63 + 
    2.64 +-	gzfd = gzopen(filename, "rb");
    2.65 +-	if (!gzfd)
    2.66 ++	lzfd = lzopen(filename, "rb");
    2.67 ++	if (!lzfd)
    2.68 + 		return NULL;
    2.69 +-	buffer = grab_contents(gzfd, size);
    2.70 +-	gzclose(gzfd);
    2.71 ++	buffer = lzgrab(lzfd, size);
    2.72 ++	lzclose(lzfd);
    2.73 + 	return buffer;
    2.74 + }
    2.75 + 
    2.76 +--- module-init-tools-3.2/configure
    2.77 ++++ module-init-tools-3.2/configure
    2.78 +@@ -1741,7 +1741,7 @@
    2.79 + #define CONFIG_USE_ZLIB 1
    2.80 + _ACEOF
    2.81 + 
    2.82 +-  zlib_flags="-Wl,-Bstatic -lz -Wl,-Bdynamic"
    2.83 ++  zlib_flags="-Wl,-Bdynamic -lz -llz"
    2.84 + fi
    2.85 + fi;
    2.86 +