# HG changeset patch # User Pascal Bellard # Date 1213271468 0 # Node ID 13768ad7e79ed68ee1ba4e2f800fd58a8dbe10f4 # Parent 14b8cd9b18d06a72c6e08014a7b204763bd61b5b Split lzma in lzma + lzlib diff -r 14b8cd9b18d0 -r 13768ad7e79e lzlib-dev/receipt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lzlib-dev/receipt Thu Jun 12 11:51:08 2008 +0000 @@ -0,0 +1,17 @@ +# SliTaz package receipt. + +PACKAGE="lzlib-dev" +VERSION="4.57" +CATEGORY="base-system" +SHORT_DESC="Compressor with a high compression ratio devel files." +MAINTAINER="pascal.bellard@slitaz.org" +WEB_SITE="http://sourceforge.net/projects/sevenzip/" +WANTED="lzma" + +# Rules to gen a SliTaz package suitable for Tazpkg. +genpkg_rules() +{ + mkdir -p $fs/usr/include + cp -a $src/CPP/7zip/Compress/LZMA_Alone/lzlib.h $fs/usr/include +} + diff -r 14b8cd9b18d0 -r 13768ad7e79e lzlib/receipt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lzlib/receipt Thu Jun 12 11:51:08 2008 +0000 @@ -0,0 +1,19 @@ +# SliTaz package receipt. + +PACKAGE="lzlib" +VERSION="4.57" +CATEGORY="base-system" +SHORT_DESC="Compressor with a high compression ratio library." +MAINTAINER="pascal.bellard@slitaz.org" +WEB_SITE="http://sourceforge.net/projects/sevenzip/" +WANTED="lzma" + +# Rules to gen a SliTaz package suitable for Tazpkg. +genpkg_rules() +{ + mkdir -p $fs/lib + cp -a $src/CPP/7zip/Compress/LZMA_Alone/liblz.so.1.0.0 $fs/lib + ln -s liblz.so.1.0.0 $fs/lib/liblz.so + ln -s liblz.so.1.0.0 $fs/lib/liblz.so.1 +} + diff -r 14b8cd9b18d0 -r 13768ad7e79e lzma/receipt --- a/lzma/receipt Tue Jun 10 16:54:11 2008 +0200 +++ b/lzma/receipt Thu Jun 12 11:51:08 2008 +0000 @@ -8,12 +8,16 @@ TARBALL="lzma$(echo $VERSION | sed 's/\.//').tar.bz2" WEB_SITE="http://sourceforge.net/projects/sevenzip/" WGET_URL="$SF_MIRROR/sevenzip/$TARBALL" +DEPENDS="lzlib" # Rules to configure and make the package. compile_rules() { + ln -sf . $src + patch -p0 < stuff/lzlib.u || return 1 cd CPP/7zip/Compress/LZMA_Alone - make -f makefile.gcc + make -f makefile.gcc lzma + make -f makefile.gcc liblz.so.1.0.0 } @@ -21,7 +25,6 @@ genpkg_rules() { mkdir -p $fs/usr/bin - cp -a CPP/7zip/Compress/LZMA_Alone/lzma $fs/usr/bin - strip -s $fs/usr/bin/* + cp -a CPP/7zip/Compress/LZMA_Alone/lzma-shared $fs/usr/bin/lzma } diff -r 14b8cd9b18d0 -r 13768ad7e79e lzma/stuff/lzlib.u --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lzma/stuff/lzlib.u Thu Jun 12 11:51:08 2008 +0000 @@ -0,0 +1,202 @@ +--- CPP/7zip/Compress/LZMA_Alone/makefile.gcc ++++ CPP/7zip/Compress/LZMA_Alone/makefile.gcc +@@ -1,6 +1,6 @@ + PROG = lzma +-CXX = g++ -O2 -Wall +-CXX_C = gcc -O2 -Wall ++CXX = g++ -s -O2 -Wall ++CXX_C = gcc -s -O2 -Wall + LIB = -lm + RM = rm -f + CFLAGS = -c +@@ -46,8 +46,47 @@ + LzmaDecode.o \ + LzmaRamDecode.o \ + ++LIB = liblz.so.1.0.0 ++LIB_OBJS = \ ++ LzmaRamDecode.o \ ++ LzmaDecode.o \ ++ BranchX86.o \ ++ Wrapper.o \ ++ ++SHARED_OBJS = \ ++ LzmaAlone.o \ ++ LzmaBench.o \ ++ LzmaBenchCon.o \ ++ LZMADecoder.o \ ++ LZMAEncoder.o \ ++ LzmaRam.o \ ++ InBuffer.o \ ++ OutBuffer.o \ ++ CRC.o \ ++ IntToString.o \ ++ MyString.o \ ++ StringConvert.o \ ++ StringToInt.o \ ++ MyVector.o \ ++ 7zCrc.o \ ++ Alloc.o \ ++ MatchFinder.o \ ++ StreamUtils.o \ ++ LZOutWindow.o \ ++ RangeCoderBit.o \ ++ FileStreams.o \ ++ $(FILE_IO).o \ ++ CommandLineParser.o \ ++ ++all: $(PROG) $(LIB) ++ ++$(LIB): $(LIB_OBJS) ++ $(CXX) -shared -Wl,-soname -Wl,liblz.so.1 -o $(LIB) $(LIB_OBJS) -lz ++ $(CXX) $(LDFLAGS) -o lzma-shared $(SHARED_OBJS) liblz.so.1.0.0 $(LIB) $(LIB2) ++ ++Wrapper.o: Wrapper.c ++ $(CXX_C) $(CFLAGS) Wrapper.c + +-all: $(PROG) + + $(PROG): $(OBJS) + $(CXX) -o $(PROG) $(LDFLAGS) $(OBJS) $(LIB) $(LIB2) + +--- CPP/7zip/Compress/LZMA_Alone/lzlib.h ++++ CPP/7zip/Compress/LZMA_Alone/lzlib.h +@@ -0,0 +1,15 @@ ++#ifndef LZLIB_H ++#define LZLIB_H ++#include ++typedef struct { ++ int handlertype; ++ unsigned long lzsize; ++ int fd; ++ gzFile gzfd; ++} *lzFile; ++ ++extern lzFile lzdopen(int fd, const char *mode); ++extern lzFile lzopen(const char *path, const char *mode); ++extern void *lzgrab(lzFile file, unsigned long *size); ++extern int lzclose(lzFile file); ++#endif + +--- CPP/7zip/Compress/LZMA_Alone/Wrapper.c ++++ CPP/7zip/Compress/LZMA_Alone/Wrapper.c +@@ -0,0 +1,119 @@ ++#include ++#include ++#include ++#include ++#include ++#include "lzlib.h" ++#include "LzmaRamDecode.h" ++ ++#define LZ_READ 0 ++#define LZ_GZREAD 1 ++#define LZ_LZREAD 2 ++ ++#define LZMA_PROP 0x5d ++ ++static int fullread(int fd, unsigned char *buffer, size_t len) ++{ ++ int i, n; ++ for (n = 0; (i = read(fd, buffer + n, len - n)) > 0; n += i); ++ return n; ++} ++ ++lzFile lzdopen(int fd, const char *mode) ++{ ++ unsigned char tmp[13]; ++ int n; ++ lzFile lzfd; ++ ++ if (fd < 0) return NULL; ++ n = fullread(fd, tmp, sizeof(tmp)); ++ lzfd = malloc(sizeof(*lzfd)); ++ if (!lzfd) return NULL; ++ lzfd->handlertype = LZ_READ; ++ if (n == sizeof(tmp) && tmp[0] == LZMA_PROP && ++ !LzmaRamGetUncompressedSize(tmp-1, sizeof(tmp)+1, &lzfd->lzsize)) ++ lzfd->handlertype = LZ_LZREAD; ++ else if (n > 2 && tmp[0] == 0x1F && tmp[1] == 0x8B) ++ lzfd->handlertype = LZ_GZREAD; ++ lzfd->fd = fd; ++ lseek(fd, 0, SEEK_SET); ++ if (lzfd->handlertype != LZ_LZREAD) { ++ if (lzfd->handlertype == LZ_GZREAD) { ++ lzfd->gzfd = gzdopen(fd, mode); ++ if (lzfd->gzfd == Z_NULL) { ++ free(lzfd); ++ return NULL; ++ } ++ } ++ } ++ return lzfd; ++} ++ ++lzFile lzopen(const char *path, const char *mode) ++{ ++ int fd = open(path, O_RDONLY); ++ return lzdopen(fd, mode); ++} ++ ++static int lzread(lzFile file, void *buf, unsigned len) ++{ ++ if (file->handlertype == LZ_GZREAD) ++ return gzread(file->gzfd, buf, len); ++ return read(file->fd, buf, len); ++} ++ ++void *lzgrab(lzFile file, unsigned long *size) ++{ ++ unsigned int n, max; ++ unsigned char *output; ++ ++ if (!file) return NULL; ++ if (file->handlertype == LZ_LZREAD) { ++ unsigned char *input; ++ size_t outsize; ++ ++ output = malloc(file->lzsize + file->lzsize/20); // 105% ++ if (!output) return NULL; ++ output[0] = 0; ++ max = 1 + fullread(file->fd, output+1, file->lzsize); ++ input = realloc(output, max); ++ output = malloc(file->lzsize); ++ if (!output || LzmaRamDecompress(input, max, ++ output, file->lzsize, &outsize, malloc, free)) { ++ if (output) free(output); ++ free(input); ++ return NULL; ++ } ++ free(input); ++ *size = outsize; ++ return output; ++ } ++ max = 16384; ++ output = malloc(max); ++ if (!output) return NULL; ++ *size = 0; ++ while ((n = lzread(file, output + *size, max - *size)) > 0) { ++ *size += n; ++ if (*size == max) { ++ output = realloc(output, max *= 2); ++ if (!output) return NULL; ++ } ++ } ++ if (n < 0) { ++ free(output); ++ return NULL; ++ } ++ return realloc(output, *size); ++} ++ ++int lzclose(lzFile file) ++{ ++ int status = -1; ++ if (file) { ++ if (file->handlertype == LZ_GZREAD) ++ status = gzclose(file->gzfd); ++ else status = close(file->fd); ++ free(file); ++ } ++ return status; ++}