wok-current rev 896
Split lzma in lzma + lzlib
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Thu Jun 12 11:51:08 2008 +0000 (2008-06-12) |
parents | 14b8cd9b18d0 |
children | cf7f6d5ad5ca |
files | lzlib-dev/receipt lzlib/receipt lzma/receipt lzma/stuff/lzlib.u |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/lzlib-dev/receipt Thu Jun 12 11:51:08 2008 +0000 1.3 @@ -0,0 +1,17 @@ 1.4 +# SliTaz package receipt. 1.5 + 1.6 +PACKAGE="lzlib-dev" 1.7 +VERSION="4.57" 1.8 +CATEGORY="base-system" 1.9 +SHORT_DESC="Compressor with a high compression ratio devel files." 1.10 +MAINTAINER="pascal.bellard@slitaz.org" 1.11 +WEB_SITE="http://sourceforge.net/projects/sevenzip/" 1.12 +WANTED="lzma" 1.13 + 1.14 +# Rules to gen a SliTaz package suitable for Tazpkg. 1.15 +genpkg_rules() 1.16 +{ 1.17 + mkdir -p $fs/usr/include 1.18 + cp -a $src/CPP/7zip/Compress/LZMA_Alone/lzlib.h $fs/usr/include 1.19 +} 1.20 +
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/lzlib/receipt Thu Jun 12 11:51:08 2008 +0000 2.3 @@ -0,0 +1,19 @@ 2.4 +# SliTaz package receipt. 2.5 + 2.6 +PACKAGE="lzlib" 2.7 +VERSION="4.57" 2.8 +CATEGORY="base-system" 2.9 +SHORT_DESC="Compressor with a high compression ratio library." 2.10 +MAINTAINER="pascal.bellard@slitaz.org" 2.11 +WEB_SITE="http://sourceforge.net/projects/sevenzip/" 2.12 +WANTED="lzma" 2.13 + 2.14 +# Rules to gen a SliTaz package suitable for Tazpkg. 2.15 +genpkg_rules() 2.16 +{ 2.17 + mkdir -p $fs/lib 2.18 + cp -a $src/CPP/7zip/Compress/LZMA_Alone/liblz.so.1.0.0 $fs/lib 2.19 + ln -s liblz.so.1.0.0 $fs/lib/liblz.so 2.20 + ln -s liblz.so.1.0.0 $fs/lib/liblz.so.1 2.21 +} 2.22 +
3.1 --- a/lzma/receipt Tue Jun 10 16:54:11 2008 +0200 3.2 +++ b/lzma/receipt Thu Jun 12 11:51:08 2008 +0000 3.3 @@ -8,12 +8,16 @@ 3.4 TARBALL="lzma$(echo $VERSION | sed 's/\.//').tar.bz2" 3.5 WEB_SITE="http://sourceforge.net/projects/sevenzip/" 3.6 WGET_URL="$SF_MIRROR/sevenzip/$TARBALL" 3.7 +DEPENDS="lzlib" 3.8 3.9 # Rules to configure and make the package. 3.10 compile_rules() 3.11 { 3.12 + ln -sf . $src 3.13 + patch -p0 < stuff/lzlib.u || return 1 3.14 cd CPP/7zip/Compress/LZMA_Alone 3.15 - make -f makefile.gcc 3.16 + make -f makefile.gcc lzma 3.17 + make -f makefile.gcc liblz.so.1.0.0 3.18 } 3.19 3.20 3.21 @@ -21,7 +25,6 @@ 3.22 genpkg_rules() 3.23 { 3.24 mkdir -p $fs/usr/bin 3.25 - cp -a CPP/7zip/Compress/LZMA_Alone/lzma $fs/usr/bin 3.26 - strip -s $fs/usr/bin/* 3.27 + cp -a CPP/7zip/Compress/LZMA_Alone/lzma-shared $fs/usr/bin/lzma 3.28 } 3.29
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/lzma/stuff/lzlib.u Thu Jun 12 11:51:08 2008 +0000 4.3 @@ -0,0 +1,202 @@ 4.4 +--- CPP/7zip/Compress/LZMA_Alone/makefile.gcc 4.5 ++++ CPP/7zip/Compress/LZMA_Alone/makefile.gcc 4.6 +@@ -1,6 +1,6 @@ 4.7 + PROG = lzma 4.8 +-CXX = g++ -O2 -Wall 4.9 +-CXX_C = gcc -O2 -Wall 4.10 ++CXX = g++ -s -O2 -Wall 4.11 ++CXX_C = gcc -s -O2 -Wall 4.12 + LIB = -lm 4.13 + RM = rm -f 4.14 + CFLAGS = -c 4.15 +@@ -46,8 +46,47 @@ 4.16 + LzmaDecode.o \ 4.17 + LzmaRamDecode.o \ 4.18 + 4.19 ++LIB = liblz.so.1.0.0 4.20 ++LIB_OBJS = \ 4.21 ++ LzmaRamDecode.o \ 4.22 ++ LzmaDecode.o \ 4.23 ++ BranchX86.o \ 4.24 ++ Wrapper.o \ 4.25 ++ 4.26 ++SHARED_OBJS = \ 4.27 ++ LzmaAlone.o \ 4.28 ++ LzmaBench.o \ 4.29 ++ LzmaBenchCon.o \ 4.30 ++ LZMADecoder.o \ 4.31 ++ LZMAEncoder.o \ 4.32 ++ LzmaRam.o \ 4.33 ++ InBuffer.o \ 4.34 ++ OutBuffer.o \ 4.35 ++ CRC.o \ 4.36 ++ IntToString.o \ 4.37 ++ MyString.o \ 4.38 ++ StringConvert.o \ 4.39 ++ StringToInt.o \ 4.40 ++ MyVector.o \ 4.41 ++ 7zCrc.o \ 4.42 ++ Alloc.o \ 4.43 ++ MatchFinder.o \ 4.44 ++ StreamUtils.o \ 4.45 ++ LZOutWindow.o \ 4.46 ++ RangeCoderBit.o \ 4.47 ++ FileStreams.o \ 4.48 ++ $(FILE_IO).o \ 4.49 ++ CommandLineParser.o \ 4.50 ++ 4.51 ++all: $(PROG) $(LIB) 4.52 ++ 4.53 ++$(LIB): $(LIB_OBJS) 4.54 ++ $(CXX) -shared -Wl,-soname -Wl,liblz.so.1 -o $(LIB) $(LIB_OBJS) -lz 4.55 ++ $(CXX) $(LDFLAGS) -o lzma-shared $(SHARED_OBJS) liblz.so.1.0.0 $(LIB) $(LIB2) 4.56 ++ 4.57 ++Wrapper.o: Wrapper.c 4.58 ++ $(CXX_C) $(CFLAGS) Wrapper.c 4.59 + 4.60 +-all: $(PROG) 4.61 + 4.62 + $(PROG): $(OBJS) 4.63 + $(CXX) -o $(PROG) $(LDFLAGS) $(OBJS) $(LIB) $(LIB2) 4.64 + 4.65 +--- CPP/7zip/Compress/LZMA_Alone/lzlib.h 4.66 ++++ CPP/7zip/Compress/LZMA_Alone/lzlib.h 4.67 +@@ -0,0 +1,15 @@ 4.68 ++#ifndef LZLIB_H 4.69 ++#define LZLIB_H 4.70 ++#include <zlib.h> 4.71 ++typedef struct { 4.72 ++ int handlertype; 4.73 ++ unsigned long lzsize; 4.74 ++ int fd; 4.75 ++ gzFile gzfd; 4.76 ++} *lzFile; 4.77 ++ 4.78 ++extern lzFile lzdopen(int fd, const char *mode); 4.79 ++extern lzFile lzopen(const char *path, const char *mode); 4.80 ++extern void *lzgrab(lzFile file, unsigned long *size); 4.81 ++extern int lzclose(lzFile file); 4.82 ++#endif 4.83 + 4.84 +--- CPP/7zip/Compress/LZMA_Alone/Wrapper.c 4.85 ++++ CPP/7zip/Compress/LZMA_Alone/Wrapper.c 4.86 +@@ -0,0 +1,119 @@ 4.87 ++#include <stdlib.h> 4.88 ++#include <unistd.h> 4.89 ++#include <sys/types.h> 4.90 ++#include <sys/stat.h> 4.91 ++#include <fcntl.h> 4.92 ++#include "lzlib.h" 4.93 ++#include "LzmaRamDecode.h" 4.94 ++ 4.95 ++#define LZ_READ 0 4.96 ++#define LZ_GZREAD 1 4.97 ++#define LZ_LZREAD 2 4.98 ++ 4.99 ++#define LZMA_PROP 0x5d 4.100 ++ 4.101 ++static int fullread(int fd, unsigned char *buffer, size_t len) 4.102 ++{ 4.103 ++ int i, n; 4.104 ++ for (n = 0; (i = read(fd, buffer + n, len - n)) > 0; n += i); 4.105 ++ return n; 4.106 ++} 4.107 ++ 4.108 ++lzFile lzdopen(int fd, const char *mode) 4.109 ++{ 4.110 ++ unsigned char tmp[13]; 4.111 ++ int n; 4.112 ++ lzFile lzfd; 4.113 ++ 4.114 ++ if (fd < 0) return NULL; 4.115 ++ n = fullread(fd, tmp, sizeof(tmp)); 4.116 ++ lzfd = malloc(sizeof(*lzfd)); 4.117 ++ if (!lzfd) return NULL; 4.118 ++ lzfd->handlertype = LZ_READ; 4.119 ++ if (n == sizeof(tmp) && tmp[0] == LZMA_PROP && 4.120 ++ !LzmaRamGetUncompressedSize(tmp-1, sizeof(tmp)+1, &lzfd->lzsize)) 4.121 ++ lzfd->handlertype = LZ_LZREAD; 4.122 ++ else if (n > 2 && tmp[0] == 0x1F && tmp[1] == 0x8B) 4.123 ++ lzfd->handlertype = LZ_GZREAD; 4.124 ++ lzfd->fd = fd; 4.125 ++ lseek(fd, 0, SEEK_SET); 4.126 ++ if (lzfd->handlertype != LZ_LZREAD) { 4.127 ++ if (lzfd->handlertype == LZ_GZREAD) { 4.128 ++ lzfd->gzfd = gzdopen(fd, mode); 4.129 ++ if (lzfd->gzfd == Z_NULL) { 4.130 ++ free(lzfd); 4.131 ++ return NULL; 4.132 ++ } 4.133 ++ } 4.134 ++ } 4.135 ++ return lzfd; 4.136 ++} 4.137 ++ 4.138 ++lzFile lzopen(const char *path, const char *mode) 4.139 ++{ 4.140 ++ int fd = open(path, O_RDONLY); 4.141 ++ return lzdopen(fd, mode); 4.142 ++} 4.143 ++ 4.144 ++static int lzread(lzFile file, void *buf, unsigned len) 4.145 ++{ 4.146 ++ if (file->handlertype == LZ_GZREAD) 4.147 ++ return gzread(file->gzfd, buf, len); 4.148 ++ return read(file->fd, buf, len); 4.149 ++} 4.150 ++ 4.151 ++void *lzgrab(lzFile file, unsigned long *size) 4.152 ++{ 4.153 ++ unsigned int n, max; 4.154 ++ unsigned char *output; 4.155 ++ 4.156 ++ if (!file) return NULL; 4.157 ++ if (file->handlertype == LZ_LZREAD) { 4.158 ++ unsigned char *input; 4.159 ++ size_t outsize; 4.160 ++ 4.161 ++ output = malloc(file->lzsize + file->lzsize/20); // 105% 4.162 ++ if (!output) return NULL; 4.163 ++ output[0] = 0; 4.164 ++ max = 1 + fullread(file->fd, output+1, file->lzsize); 4.165 ++ input = realloc(output, max); 4.166 ++ output = malloc(file->lzsize); 4.167 ++ if (!output || LzmaRamDecompress(input, max, 4.168 ++ output, file->lzsize, &outsize, malloc, free)) { 4.169 ++ if (output) free(output); 4.170 ++ free(input); 4.171 ++ return NULL; 4.172 ++ } 4.173 ++ free(input); 4.174 ++ *size = outsize; 4.175 ++ return output; 4.176 ++ } 4.177 ++ max = 16384; 4.178 ++ output = malloc(max); 4.179 ++ if (!output) return NULL; 4.180 ++ *size = 0; 4.181 ++ while ((n = lzread(file, output + *size, max - *size)) > 0) { 4.182 ++ *size += n; 4.183 ++ if (*size == max) { 4.184 ++ output = realloc(output, max *= 2); 4.185 ++ if (!output) return NULL; 4.186 ++ } 4.187 ++ } 4.188 ++ if (n < 0) { 4.189 ++ free(output); 4.190 ++ return NULL; 4.191 ++ } 4.192 ++ return realloc(output, *size); 4.193 ++} 4.194 ++ 4.195 ++int lzclose(lzFile file) 4.196 ++{ 4.197 ++ int status = -1; 4.198 ++ if (file) { 4.199 ++ if (file->handlertype == LZ_GZREAD) 4.200 ++ status = gzclose(file->gzfd); 4.201 ++ else status = close(file->fd); 4.202 ++ free(file); 4.203 ++ } 4.204 ++ return status; 4.205 ++}