--- lzma-4.43.orig/debian/control
+++ lzma-4.43/debian/control
@@ -0,0 +1,62 @@
+Source: lzma
+Section: utils
+Priority: optional
+Maintainer: Mohammed AdnÃ¨ne Trojette <adn+deb@diwi.org>
+Uploaders: Arnaud Fontaine <arnau@debian.org>
+Build-Depends: debhelper (>= 5.0.0), quilt, zlib1g-dev
+Homepage: http://www.7-zip.org/sdk.htm
+Vcs-Git: git://git.debian.org/git/collab-maint/lzma.git
+Vcs-Browser: http://git.debian.org/?p=collab-maint/lzma.git;a=summary
+Standards-Version: 3.7.3
+
+Package: lzma
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: Compression method of 7z format in 7-Zip program
+ LZMA is a compression algorithm, based on the famous Lempel Ziv
+ compression method.
+ .
+ The main characteristics of the algorithm are very good compression,
+ fast decompression, use of lot of RAM for compression and low usage of
+ RAM for decompression.
+ .
+ LZMA provides high compression ratio and very fast decompression, so it
+ is very suitable for embedded applications. For example, it can be used
+ for ROM (firmware) compression.
+
+Package: lzma-dev
+Architecture: any
+Depends: zlib1g-dev
+Description: Compression method of 7z format in 7-Zip program - development files
+ LZMA is a compression algorithm, based on the famous Lempel Ziv
+ compression method.
+ .
+ The main characteristics of the algorithm are very good compression,
+ fast decompression, use of lot of RAM for compression and low usage of
+ RAM for decompression.
+ .
+ LZMA provides high compression ratio and very fast decompression, so it
+ is very suitable for embedded applications. For example, it can be used
+ for ROM (firmware) compression.
+ .
+ This package contains the headers and libraries of lzma. It is
+ experimental and will be replaced by the library as soon as it is
+ available.
+ 
+Package: lzma-source
+Architecture: all
+Depends: module-assistant, debhelper (>> 4.0.0), bzip2, make, lzma-dev
+Description: Source for the lzma kernel module
+ LZMA is a compression algorithm, based on the famous Lempel Ziv
+ compression method.
+ .
+ The main characteristics of the algorithm are very good compression,
+ fast decompression, use of lot of RAM for compression and low usage of
+ RAM for decompression.
+ .
+ LZMA provides high compression ratio and very fast decompression, so it
+ is very suitable for embedded applications. For example, it can be used
+ for ROM (firmware) compression.
+ .
+ This package provides the source code for the lzma kernel modules.
+ Kernel source and headers are required to compile these modules.
--- lzma-4.43.orig/debian/rules
+++ lzma-4.43/debian/rules
@@ -0,0 +1,109 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+SRC_DIR_C = C/7zip/Compress/LZMA_C
+SRC_DIR_ALONE = C/7zip/Compress/LZMA_Alone
+MOD = $(SRC_DIR_C)/kmod/module.c $(SRC_DIR_C)/uncomp.c
+
+DEB_HOST_GNU_TYPE=$(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
+DEB_BUILD_GNU_TYPE=$(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
+ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
+CROSS=CXX=$(DEB_HOST_GNU_TYPE)-g++ CXX_C=$(DEB_HOST_GNU_TYPE)-gcc
+else
+CROSS=
+endif
+
+build: build-stamp
+
+build-stamp:
+	dh_testdir
+
+	# Add here commands to compile the package.
+	QUILT_PATCHES=debian/patches quilt push -a || test $$? = 2
+
+	Sqlzma=../../Common $(MAKE) $(CROSS) -C $(SRC_DIR_ALONE) -f sqlzma.mk
+	Sqlzma=../../Common $(MAKE) $(CROSS) -C $(SRC_DIR_C) -f sqlzma.mk
+
+	touch build-stamp
+
+clean:
+	dh_testdir
+	dh_testroot
+	rm -f build-stamp
+
+	# Add here commands to clean up after the build process.
+	$(MAKE) clean -C $(SRC_DIR_ALONE) -f makefile.gcc
+	$(MAKE) clean -C $(SRC_DIR_C) -f makefile.gcc
+
+	# Cleanup and avoid using sqlzma.mk
+	rm -f $(SRC_DIR_ALONE)/*.o $(SRC_DIR_ALONE)/*.a \
+		$(SRC_DIR_C)/*.o $(SRC_DIR_C)/*.a
+
+	QUILT_PATCHES=debian/patches quilt pop -a -R || test $$? = 2
+
+	# Remove temporary debian/modules directory
+	rm -rf .pc debian/modules
+	dh_clean 
+
+install: build
+	dh_testdir
+	dh_testroot
+	dh_clean -k 
+	dh_installdirs
+
+	# Create the temporary directory for lzma-source
+	mkdir -m755 -p debian/modules/lzma/debian
+
+	# Copy the source and header files
+	install -m644 $(MOD) $(SRC_DIR_C)/LzmaDecode.c $(SRC_DIR_C)/kmod/Makefile \
+		debian/modules/lzma
+
+	# Copy the debian specific files
+	install -m644 debian/changelog debian/compat debian/copyright \
+		debian/control.modules.in debian/modules/lzma/debian
+
+	# This rules file is specific to m-a
+	install -m755 debian/rules.modules \
+		debian/modules/lzma/debian/rules
+
+	# Finally create the tarball which contains the module directory
+	cd debian && tar jcf lzma-source/usr/src/lzma.tar.bz2 modules
+
+# Build architecture-independent files here.
+binary-indep: build install
+	dh_testdir -i
+	dh_testroot -i
+	dh_installchangelogs -i history.txt
+	dh_installdocs -i
+	dh_install -i
+	dh_link -i
+	dh_compress -i
+	dh_fixperms -i
+	dh_installdeb -i
+	dh_gencontrol -i
+	dh_md5sums -i
+	dh_builddeb -i
+
+# Build architecture-dependent files here.
+binary-arch: build install
+	dh_testdir
+	dh_testroot
+	dh_installchangelogs history.txt
+	dh_installdocs
+	dh_install
+	dh_installman debian/lzma_alone.1 debian/lzma.1
+	dh_link
+	dh_strip
+	dh_compress
+	dh_fixperms
+	dh_installdeb
+	dh_shlibdeps
+	dh_gencontrol
+	dh_md5sums
+	dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install
--- lzma-4.43.orig/debian/NEWS.Debian
+++ lzma-4.43/debian/NEWS.Debian
@@ -0,0 +1,19 @@
+lzma (4.43-2) unstable; urgency=low
+
+  * Change debian/copyright to utf-8.
+  * Build-Depends on quilt.
+  * Correct typo on description spotted by Andrey Kiselev. (Closes: #378218)
+  * Add a NEWS.Debian.
+  * Add some patches with the help of Alexander Sack and Lasse Collin to
+    integrate Tukaani's lzma-utils:
+      + 01_large_files.diff: make large files work.
+      + 02_lzmp.diff: use a wrapper to lzma to have a gzip-like interface.
+        (Closes: #379398)
+      + 03_lzma_manpage.diff: manual page for the "new" lzma.
+  * Changes introduced by the "Tukaani patch":
+      + the old /usr/bin/lzma becomes /usr/bin/lzma_alone.
+      + it is superseded by a gzip-like command line tool.
+      + manpages are updated accordingly.
+
+ -- Mohammed AdnÃ¨ne Trojette <adn+deb@diwi.org>  Tue,  8 Aug 2006 23:26:37 +0200
+
--- lzma-4.43.orig/debian/watch
+++ lzma-4.43/debian/watch
@@ -0,0 +1,7 @@
+# format version number, currently 3; this line is compulsory!
+version=3
+
+# Line continuations are performed with \
+
+opts="uversionmangle=s/\(.\)\(..\)/$1.$2/" \
+ http://qa.debian.org/watch/sf.php/sevenzip/lzma(.)(..).tar.bz2 debian uupdate
--- lzma-4.43.orig/debian/lzma_alone.1
+++ lzma-4.43/debian/lzma_alone.1
@@ -0,0 +1,63 @@
+.TH LZMA 1 "May  5 2006" "Mohammed Adnene Trojette"
+.SH NAME
+LZMA - a compression algorithm, based on Lempel Ziv's compression method.
+.SH SYNOPSIS
+.B lzma
+.BR <e|d>
+.BR inputFile
+.BR outputFile
+.BR [switches...]
+.SH DESCRIPTION
+LZMA provides high compression ratio and very fast decompression, so it is very suitable for embedded applications. For example, it can be used for ROM (firmware) compression.
+.TP
+lzma is the default and general compression method of 7z format in 7-Zip program.
+.PP
+.SH FUNCTION LETTERS
+.TP
+.B e
+Encode file
+.TP
+.B d
+Decode file
+.TP
+.B b
+Benchmark
+.SH SWITCHES
+.TP
+.B -a{N}
+Set compression mode - [0, 1], default: 1 (max)
+.TP
+.B -d{N}
+Set dictionary - [0,30], default: 23 (8MB)
+.TP
+.B -fb{N}
+Set number of fast bytes - [5, 273], default: 128
+.TP
+.B -mc{N}
+Set number of cycles for match finder
+.TP
+.B -lc{N}
+Set number of literal context bits - [0, 8], default: 3
+.TP
+.B -lp{N}
+Set number of literal pos bits - [0, 4], default: 0
+.TP
+.B -pb{N}
+Set number of pos bits - [0, 4], default: 2
+.TP
+.B -mf{MF_ID}
+Set Match Finder: [bt2, bt3, bt4, hc4], default: bt4
+.TP
+.B -eos
+Write End Of Stream marker
+.TP
+.B -si
+Read data from stdin
+.TP
+.B -so
+Write data to stdout
+.SH "SEE ALSO"
+.BR 7z(1), 7za(1)
+.SH AUTHOR
+.TP
+Written for Debian by Mohammed Adnene Trojette.
--- lzma-4.43.orig/debian/changelog
+++ lzma-4.43/debian/changelog
@@ -0,0 +1,142 @@
+lzma (4.43-12~bpo40+1) etch-backports; urgency=low
+
+  * Rebuild for Etch backports.
+
+ -- Mohammed AdnÃ¨ne Trojette <adn+deb@diwi.org>  Wed, 30 Jan 2008 23:34:55 +0100
+
+lzma (4.43-12) unstable; urgency=low
+
+  * Update sqlzma patch (needed for squashfs):
+    + Backport sqlzma patch to LZMA SDK 4.43.
+    + Update 04_sqlzma_h.diff.
+
+ -- Arnaud Fontaine <arnau@debian.org>  Sat, 08 Dec 2007 21:03:51 +0000
+
+lzma (4.43-11) unstable; urgency=low
+
+  * Upload to unstable.
+
+  [ Arnaud Fontaine ]
+  * lzma-dev should be part of the Build-Depends only and not a dependency
+    inside the resulting kernel modules package.  Thanks to Michael
+    Prokop. (Closes: #452868)
+  * Support cross building. Thanks to Neil Williams for the patch.
+    (Closes: #451598)
+  * debian/control*:
+    + Add Homepage field (dpkg supports it now).
+    + Add Vcs-Git and Vcs-Browser field (dpkg support them now).
+    + Update my email address to arnau@debian.org.
+    + Update Standards-Version to 3.7.3. No changes needed.
+
+  [ Mohammed AdnÃ¨ne Trojette ]
+  * Don't ship /usr/share/doc/lzma/LGPL.txt.gz. (Closes: #453922)
+  * debian/copyright:
+    + Include a copy of the CPL license. (Closes: #453924)
+
+ -- Mohammed AdnÃ¨ne Trojette <adn+deb@diwi.org>  Fri, 07 Dec 2007 01:59:40 +0100
+
+lzma (4.43-10) experimental; urgency=low
+
+  * debian/control:
+    + Add myself as Uploaders.
+  * debian/docs:
+    + Remove useless LGPL.txt file because it is already provided by
+      Debian.
+  * Install history.txt as the changelog in /usr/share/doc/.
+  * Add support for squashfs. (Closes: #443844).
+    + Add lzma-dev which contains headers and static libraries.
+    + Add lzma-source which contains kernel modules needed for squashfs.
+    + Add patch from sqlzma project.
+  
+ -- Arnaud Fontaine <arnaud@andesi.org>  Thu, 18 Oct 2007 12:15:12 +0100
+
+lzma (4.43-9) unstable; urgency=low
+
+  * Remove reference to missing chapter in manpage. (Closes: #424612)
+  * Remove redundancies in manpage. (Closes: #435612)
+
+ -- Mohammed AdnÃ¨ne Trojette <adn+deb@diwi.org>  Sat, 04 Aug 2007 21:32:07 +0200
+
+lzma (4.43-8) unstable; urgency=low
+
+  * Update lzmp.cpp patch to allow symlinks decompression to stdout.
+  * Correct watch file.
+
+ -- Mohammed AdnÃ¨ne Trojette <adn+deb@diwi.org>  Tue, 24 Jul 2007 00:33:43 +0200
+
+lzma (4.43-7) unstable; urgency=low
+
+  * Upload to unstable.
+  * Bump debhelper compatibility to 5.
+
+ -- Mohammed AdnÃ¨ne Trojette <adn+deb@diwi.org>  Fri, 13 Apr 2007 01:07:02 +0200
+
+lzma (4.43-6) experimental; urgency=low
+
+  * 02_lzmp.diff:
+     + include <cstdlib> to be able to build with GCC 4.3. (Closes: #417379)
+       Thanks Martin Michlmayr for the patch.
+     + use hc4 for -1 option, as hc3 is no more built in the SDK.
+       (Closes: #417304)
+       Thanks Lasse Collin for the help.
+
+ -- Mohammed AdnÃ¨ne Trojette <adn+deb@diwi.org>  Mon, 02 Apr 2007 19:59:52 +0200
+
+lzma (4.43-5) unstable; urgency=low
+
+  * Tighten license issues in debian/copyright: (Closes: #406968)
+     + LZMA SDK is released under
+         - LGPL
+         - CPL
+         - simplified license
+     + LZMA SDK is free, of course! (under the LGPL terms)
+     + Files released by Tukaani are released under GPL.
+     + Packaging is released under LGPL.
+
+ -- Mohammed AdnÃ¨ne Trojette <adn+deb@diwi.org>  Mon, 15 Jan 2007 12:37:50 +0100
+
+lzma (4.43-4) unstable; urgency=low
+
+  * Fix in manual page:
+     + typos spotted by thanks A. Costa. (Closes: #405652)
+     + reference to non existing lzmainfo(1). (Closes: #404903)
+
+ -- Mohammed AdnÃ¨ne Trojette <adn+deb@diwi.org>  Mon,  8 Jan 2007 03:46:37 +0100
+
+lzma (4.43-3) unstable; urgency=low
+
+  * Add a debian/watch file.
+
+ -- Mohammed AdnÃ¨ne Trojette <adn+deb@diwi.org>  Tue, 19 Sep 2006 02:27:29 +0200
+
+lzma (4.43-2) unstable; urgency=low
+
+  * Change debian/copyright to utf-8.
+  * Build-Depends on quilt.
+  * Correct typo on description spotted by Andrey Kiselev. (Closes: #378218)
+  * Add a NEWS.Debian.
+  * Add some patches with the help of Alexander Sack and Lasse Collin to
+    integrate Tukaani's lzma-utils:
+      + 01_large_files.diff: make large files work.
+      + 02_lzmp.diff: use a wrapper to lzma to have a gzip-like interface.
+        (Closes: #379398)
+      + 03_lzma_manpage.diff: manual page for the "new" lzma.
+  * Changes introduced by the "Tukaani patch":
+      + the old /usr/bin/lzma becomes /usr/bin/lzma_alone.
+      + it is superseded by a gzip-like command line tool.
+      + manpages are updated accordingly.
+
+ -- Mohammed AdnÃ¨ne Trojette <adn+deb@diwi.org>  Tue,  8 Aug 2006 23:26:37 +0200
+
+lzma (4.43-1) unstable; urgency=low
+
+  * New upstream version.
+
+ -- Mohammed AdnÃ¨ne Trojette <adn+deb@diwi.org>  Sun,  4 Jun 2006 13:58:58 +0200
+
+lzma (4.39-1) unstable; urgency=low
+
+  * Initial release (Closes: #364258)
+
+ -- Mohammed AdnÃ¨ne Trojette <adn+deb@diwi.org>  Mon,  1 May 2006 02:01:42 +0200
+
--- lzma-4.43.orig/debian/lzma-source.dirs
+++ lzma-4.43/debian/lzma-source.dirs
@@ -0,0 +1 @@
+usr/src
--- lzma-4.43.orig/debian/control.modules.in
+++ lzma-4.43/debian/control.modules.in
@@ -0,0 +1,28 @@
+Source: lzma
+Section: utils
+Priority: optional
+Maintainer: Mohammed Adnène Trojette <adn+deb@diwi.org>
+Uploaders: Arnaud Fontaine <arnau@debian.org>
+Build-Depends: debhelper (>= 4.0.0), linux-headers-_KVERS_, lzma-dev
+Homepage: http://www.7-zip.org/sdk.html
+Vcs-Git: git://git.debian.org/git/collab-maint/lzma.git
+Vcs-Browser: http://git.debian.org/?p=collab-maint/lzma.git;a=summary
+Standards-Version: 3.7.3
+
+Package: lzma-modules-_KVERS_
+Architecture: any
+Provides: lzma-modules
+Depends: linux-modules-_KVERS_ | linux-image-_KVERS_
+Description: Source of the lzma kernel module
+ LZMA is a compression algorithm, based on the famous Lempel Ziv
+ compression method.
+ .
+ The main characteristics of the algorithm are very good compression,
+ fast decompression, use of lot of RAM for compression and low usage of
+ RAM for decompression.
+ .
+ LZMA provides high compression ratio and very fast decompression, so it
+ is very suitable for embedded applications. For example, it can be used
+ for ROM (firmware) compression.
+ .
+ This package contains the compiled kernel module for _KVERS_
--- lzma-4.43.orig/debian/compat
+++ lzma-4.43/debian/compat
@@ -0,0 +1 @@
+5
--- lzma-4.43.orig/debian/lzma-dev.install
+++ lzma-4.43/debian/lzma-dev.install
@@ -0,0 +1,5 @@
+C/7zip/Compress/LZMA_Alone/*.a		usr/lib
+C/7zip/Compress/LZMA_C/*.a		usr/lib
+C/7zip/Common/sqlzma.h			usr/include
+C/7zip/Compress/LZMA_C/LzmaDecode.h 	usr/include
+C/7zip/Compress/LZMA_C/LzmaTypes.h 	usr/include
--- lzma-4.43.orig/debian/rules.modules
+++ lzma-4.43/debian/rules.modules
@@ -0,0 +1,52 @@
+#!/usr/bin/make -f
+# -*- mode: makefile; coding: utf-8 -*-
+
+# prefix of the target package name
+PACKAGE=lzma-modules
+# modifieable for experiments or debugging m-a
+MA_DIR ?= /usr/share/modass
+# load generic variable handling
+-include $(MA_DIR)/include/generic.make
+# load default rules, including kdist, kdist_image, ...
+-include $(MA_DIR)/include/common-rules.make
+
+# module assistant calculates all needed things for us and sets
+# following variables:
+# KSRC (kernel source directory), KVERS (kernel version string), KDREV
+# (revision of the Debian kernel-image package), CC (the correct
+# compiler), VERSION (the final package version string), PKGNAME (full
+# package name with KVERS included), DEB_DESTDIR (path to store DEBs)
+
+# The kdist_configure target is called by make-kpkg modules_config and
+# by kdist* rules by dependency. It should configure the module so it is
+# ready for compilation (mostly useful for calling configure).
+# prep-deb-files from module-assistant creates the neccessary debian/ files 
+kdist_config: prep-deb-files
+
+# the kdist_clean target is called by make-kpkg modules_clean and from
+# kdist* rules. It is responsible for cleaning up any changes that have
+# been made by the other kdist_commands (except for the .deb files created)
+kdist_clean:
+	$(MAKE) -C $(KSRC) M=$(PWD) clean
+
+binary-modules:
+	dh_testroot
+	dh_clean -k
+	dh_installdirs
+
+	$(MAKE) -C $(KSRC) M=$(PWD) modules
+
+	# Install the module
+	mkdir -p debian/$(PACKAGE)-$(KVERS)/lib/modules/$(KVERS)/extra
+	cp sqlzma.ko unlzma.ko debian/$(PACKAGE)-$(KVERS)/lib/modules/$(KVERS)/extra
+
+	dh_installdocs
+	dh_installchangelogs
+	dh_installmodules
+	dh_compress
+	dh_fixperms
+	dh_installdeb
+	dh_gencontrol -- -v$(VERSION)
+	dh_md5sums
+	dh_builddeb --destdir=$(DEB_DESTDIR)
+	dh_clean -k
--- lzma-4.43.orig/debian/lzma.dirs
+++ lzma-4.43/debian/lzma.dirs
@@ -0,0 +1 @@
+usr/bin
--- lzma-4.43.orig/debian/lzma.docs
+++ lzma-4.43/debian/lzma.docs
@@ -0,0 +1,4 @@
+7zC.txt
+7zFormat.txt
+lzma.txt
+Methods.txt
--- lzma-4.43.orig/debian/patches/03_lzma_manpage.diff
+++ lzma-4.43/debian/patches/03_lzma_manpage.diff
@@ -0,0 +1,192 @@
+Index: lzma-4.43/debian/lzma.1
+===================================================================
+--- /dev/null	1970-01-01 00:00:00.000000000 +0000
++++ lzma-4.43/debian/lzma.1	2007-01-08 03:46:09.000000000 +0100
+@@ -0,0 +1,187 @@
++.TH LZMA 1 "23 Dec 2005" "LZMA utils"
++
++.SH NAME
++lzma, unlzma, lzcat \- LZMA compression and decompression tool
++
++.SH SYNOPSIS
++.B lzma
++.RB [ \-123456789cdefhkLqtvV "] [" \-S
++.IR suffix "] [" "filenames ..." ]
++.br
++.B unlzma
++.RB [ \-cfhkLqtvV "] [" \-S
++.IR suffix "] [" "filenames ..." ]
++.br
++.B lzcat
++.RB [ \-fhLqV ]
++.RI [ "filenames ..." ]
++
++.SH DESCRIPTION
++LZMA (Lempel-Ziv-Markov chain-Algorithm) is an improved version of
++famous LZ77 compression algorithm. It was improved in way of maximum
++increasing of compression ratio, keeping high decompression speed and
++low memory requirements for decompressing.
++.PP
++.B lzma
++command line tool has a similar interface to
++.BR gzip (1)
++and
++.BR bzip2 (1)
++and is intended to make use of LZMA compression easy for the users who
++are already familiar with gzip and bzip2.
++.PP
++In this manual
++.B lzma
++is compared mostly to bzip2 because that is currently one of the most
++widely used free software to compress tar files made for distribution.
++Comparing lzma to gzip is not practical because neither lzma nor bzip2
++can compete with gzip in compression speed. On the other hand the
++compression ratio of gzip is worse than of lzma and bzip2.
++.PP
++.B lzma
++provides notably better compression ratio than bzip2 especially with
++files having other than plain text content. The other advantage of
++.B lzma
++is fast decompression which is many times quicker than bzip2. The major
++disadvantage is that achieving the highest compression ratios requires
++extensive amount of system resources, both CPU time and RAM. Also
++software to handle LZMA compressed files is not installed by default on
++most distributions.
++.PP
++When compressing or decompressing with
++.BR lzma ,
++the new file will have the same ownership information, permissions and
++timestamps as the original file. However the this information is not
++stored into the compressed file like gzip does.
++
++.SH STREAMED VS. NON-STREAMED
++LZMA files can be either streamed or non-streamed. Non-streamed files
++are created only when the size of the file being compressed is known. In
++practice this means that the source file must be a regular file. In
++other words, if compressing from the standard input or from a named pipe
++(fifo) the compressed file will always be streamed.
++.PP
++Both streamed and non-streamed files are compressed identically; the
++only differences are found from the beginnings and ends of LZMA
++compressed files: Non-streamed files contain the uncompressed size of
++the file in the LZMA file header; streamed files have uncompressed size
++marked as unknown. To know where to stop decoding, streamed files have a
++special End Of Stream marker at the end of the LZMA file. The EOS marker
++makes streamed files five or six bytes bigger than non-streamed.
++.PP
++So in practice creating non-streamed files has two advantages: 1) the
++compressed file is a few bytes smaller and 2) the uncompressed size of
++the file can be checked without decompressing the file.
++
++.SH OPTIONS
++Short options can be grouped like
++.BR \-cd.
++.TP
++.B \-c \-\-stdout \-\-to\-stdout
++The output is written to the standard output. The original files are kept
++unchanged. When compressing to the standard output there can be only one
++input file. This option is implied when input is read from the standard
++input or the script is invoked as
++.BR lzcat .
++.TP
++.B \-d \-\-decompress \-\-uncompress
++Force decompression regardless of the invocation name. This the default
++when called as
++.B unlzma
++or
++.BR lzcat .
++.TP
++.B \-f \-\-force
++Force compression or decompression even if source file is a symlink,
++target exists, or target is a terminal. In contrast to gzip and bzip2,
++if input data is not in LZMA format, \-\-force does not make lzma
++behave like
++.BR cat .
++.B lzma
++never prompts if target file should be overwritten; existing files are
++skipped or, in case of
++.BR \-\-force ,
++overwritten.
++.TP
++.B \-h \-\-help
++Show a summary of supported options and quit.
++.TP
++.B \-k \-\-keep
++Do not delete the input files after compression or decompression.
++.TP
++.B \-L \-\-license
++Show licensing information of
++.BR lzma .
++.TP
++.B \-q \-\-quiet
++Suppress all warnings. You can still check the exit status to detect if
++a warning had been shown.
++.TP
++.BI "\-S \-\-suffix " .suf
++Use
++.I .suf
++instead of the default
++.BR .lzma .
++A null suffix forces unlzma to decompress all the given files
++regardless of the filename suffix.
++.TP
++.B \-t \-\-test
++Check the integrity of the compressed file(s). Without
++.B \-\-verbose
++no output is produced if no errors are found.
++.TP
++.B \-v \-\-verbose
++Show the filename and percentage reduction of each processes file.
++.TP
++.B \-V \-\-version
++Show the version number of
++.BR lzma .
++.TP
++.B \-z \-\-compress
++Force compression regardless of the invocation name.
++.TP
++.BR \-1 " .. " \-9
++Set the compression ratio. These options have no effect when
++decompressing.
++.TP
++.B \-\-fast
++Alias to
++.BR \-1 .
++.TP
++.B \-\-best
++Alias to
++.BR \-9 .
++
++.SH DIAGNOSTICS
++Exit status:
++.br
++.B 0
++\- Everything OK.
++.br
++.B 1
++\- An error occurred.
++.br
++.B 2
++\- Something worth a warning happened but no errors.
++
++It can be especially useful with
++.BR tar (1)
++patched to support LZMA compression.
++
++.SH AUTHORS
++The LZMA algorithm and the implementation used in LZMA utils was
++developed by Igor Pavlov. The original code is available in LZMA SDK
++which can be found from http://7-zip.org/sdk.html .
++.PP
++.B lzma
++command line tool was written by Ville Koskinen.
++http://tukaani.org/lzma/
++.PP
++This manual page is inspired by manual pages of
++.B gzip
++and
++.BR bzip2 .
++
++.SH SEE ALSO
++.BR gzip (1),
++.BR bzip2 (1)
--- lzma-4.43.orig/debian/patches/02_lzmp.diff
+++ lzma-4.43/debian/patches/02_lzmp.diff
@@ -0,0 +1,1062 @@
+Index: lzma-4.43/C/7zip/Compress/LZMA_Alone/lzmp.cpp
+===================================================================
+--- /dev/null	1970-01-01 00:00:00.000000000 +0000
++++ lzma-4.43/C/7zip/Compress/LZMA_Alone/lzmp.cpp	2007-07-24 00:33:21.000000000 +0200
+@@ -0,0 +1,896 @@
++/*
++ * LZMA command line tool similar to gzip to encode and decode LZMA files.
++ *
++ * Copyright (C) 2005 Ville Koskinen
++ *
++ * 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 the Free Software Foundation; either version 2
++ * of the License, or (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
++ * USA.
++ */
++
++#include "../../../Common/MyInitGuid.h"
++#include "../../../Common/MyWindows.h"
++
++#include <iostream>
++using std::cout;
++using std::cerr;
++using std::endl;
++
++#include <cstdio>
++#include <cstdlib>
++#include <cstring>
++
++#include <string>
++using std::string;
++#include <vector>
++using std::vector;
++typedef vector<string> stringVector;
++
++#include <unistd.h>
++#include <getopt.h>
++#include <signal.h>
++
++#include <sys/types.h>
++#include <sys/stat.h>
++#include <utime.h>
++#include <sys/time.h> // futimes()
++
++// For Solaris
++#ifndef HAVE_FUTIMES
++//#define futimes(fd, tv) futimesat(fd, NULL, tv)
++#endif
++
++#if defined(_WIN32) || defined(OS2) || defined(MSDOS)
++#include <fcntl.h>
++#include <io.h>
++#define MY_SET_BINARY_MODE(file) setmode(fileno(file),O_BINARY)
++#else
++#define MY_SET_BINARY_MODE(file)
++#endif
++
++#include "../../../7zip/Common/FileStreams.h"
++
++#include "../../../Common/Types.h"
++
++#include "../../../7zip/Compress/LZMA/LZMADecoder.h"
++#include "../../../7zip/Compress/LZMA/LZMAEncoder.h"
++
++#include "Exception.h"
++
++#include "lzma_version.h"
++
++namespace lzma {
++
++const char *PROGRAM_VERSION = PACKAGE_VERSION;
++const char *PROGRAM_COPYRIGHT = "Copyright (C) 2006 Ville Koskinen";
++
++/* LZMA_Alone switches:
++    -a{N}:  set compression mode - [0, 2], default: 2 (max)
++    -d{N}:  set dictionary - [0,28], default: 23 (8MB)
++    -fb{N}: set number of fast bytes - [5, 255], default: 128
++    -lc{N}: set number of literal context bits - [0, 8], default: 3
++    -lp{N}: set number of literal pos bits - [0, 4], default: 0
++    -pb{N}: set number of pos bits - [0, 4], default: 2
++    -mf{MF_ID}: set Match Finder: [bt2, bt3, bt4, bt4b, pat2r, pat2,
++                pat2h, pat3h, pat4h, hc3, hc4], default: bt4
++*/
++
++struct lzma_option {
++	short compression_mode;			// -a
++	short dictionary;			// -d
++	short fast_bytes;			// -fb
++	wchar_t *match_finder;			// -mf
++	short literal_context_bits;		// -lc
++	short literal_pos_bits;			// -lp
++	short pos_bits;				// -pb
++};
++
++/* The following is a mapping from gzip/bzip2 style -1 .. -9 compression modes
++ * to the corresponding LZMA compression modes. Thanks, Larhzu, for coining
++ * these. */
++const lzma_option option_mapping[] = {
++	{ 0,  0,  0,    NULL, 0, 0, 0},		// -0 (needed for indexing)
++	{ 0, 16, 64,  L"hc4", 3, 0, 2},		// -1
++	{ 0, 20, 64,  L"hc4", 3, 0, 2},		// -2
++	{ 1, 19, 64,  L"bt4", 3, 0, 2},		// -3
++	{ 2, 20, 64,  L"bt4", 3, 0, 2},		// -4
++	{ 2, 21, 128, L"bt4", 3, 0, 2},		// -5
++	{ 2, 22, 128, L"bt4", 3, 0, 2},		// -6
++	{ 2, 23, 128, L"bt4", 3, 0, 2},		// -7
++	{ 2, 24, 255, L"bt4", 3, 0, 2},		// -8
++	{ 2, 25, 255, L"bt4", 3, 0, 2},		// -9
++};
++
++struct extension_pair {
++	char *from;
++	char *to;
++};
++
++const extension_pair known_extensions[] = {
++	{ ".lzma", "" },
++	{ ".tlz", ".tar" },
++	{ NULL, NULL }
++};
++
++/* Sorry, I just happen to like enumerations. */
++enum PROGRAM_MODE {
++	PM_COMPRESS = 0,
++	PM_DECOMPRESS,
++	PM_TEST,
++	PM_HELP,
++	PM_LICENSE,
++	PM_VERSION
++};
++
++enum {
++	STATUS_OK = 0,
++	STATUS_ERROR = 1,
++	STATUS_WARNING = 2
++};
++
++/* getopt options. */
++/* struct option { name, has_arg, flag, val } */
++const struct option long_options[] = {
++	{ "stdout", 0, 0, 'c' },
++	{ "decompress", 0, 0, 'd' },
++	{ "compress", 0, 0, 'z' },
++	{ "keep", 0, 0, 'k' },
++	{ "force", 0, 0, 'f' },
++	{ "test", 0, 0, 't' },
++	{ "suffix", 1, 0, 'S' },
++	{ "quiet", 0, 0, 'q' },
++	{ "verbose", 0, 0, 'v' },
++	{ "help", 0, 0, 'h' },
++	{ "license", 0, 0, 'L' },
++	{ "version", 0, 0, 'V' },
++	{ "fast", 0, 0, '1' },
++	{ "best", 0, 0, '9' },
++	{ 0, 0, 0, 0 }
++};
++
++/* getopt option string (for the above options). */
++const char option_string[] = "cdzkftS:qvhLV123456789A:D:F:";
++
++/* Defaults. */
++PROGRAM_MODE program_mode = PM_COMPRESS;
++int	verbosity			= 0;
++bool	stdinput			= false;
++bool	stdoutput			= false;
++bool	keep				= false;
++bool	force				= false;
++int	compression_mode		= 7;
++//char	*suffix				= strdup(".lzma");
++char	*suffix				= strdup(known_extensions[0].from);
++lzma_option	advanced_options 	= { -1, -1, -1, NULL, -1, -1, -1 };
++
++void print_help(const char *const argv0)
++{
++	// Help goes to stdout while other messages go to stderr.
++	cout << "\nlzma " << PROGRAM_VERSION
++		<< " " << PROGRAM_COPYRIGHT << "\n"
++		"Based on LZMA SDK " << LZMA_SDK_VERSION_STRING << " "
++		<< LZMA_SDK_COPYRIGHT_STRING
++		<< "\n\nUsage: " << argv0
++		<< " [flags and input files in any order]\n"
++"  -c --stdout       output to standard output\n"
++"  -d --decompress   force decompression\n"
++"  -z --compress     force compression\n"
++"  -k --keep         keep (don't delete) input files\n"
++"  -f --force        force overwrite of output file and compress links\n"
++"  -t --test         test compressed file integrity\n"
++"  -S .suf  --suffix .suf   use suffix .suf on compressed files\n"
++"  -q --quiet        suppress error messages\n"
++"  -v --verbose      be verbose\n"
++"  -h --help         print this message\n"
++"  -L --license      display the license information\n"
++"  -V --version      display version numbers of LZMA SDK and lzma\n"
++"  -1 .. -2          fast compression\n"
++"  -3 .. -9          good to excellent compression. -7 is the default.\n"
++"     --fast         alias for -1\n"
++"     --best         alias for -9 (usually *not* what you want)\n\n"
++"  Memory usage depends a lot on the chosen compression mode -1 .. -9.\n"
++"  See the man page lzma(1) for details.\n\n";
++}
++
++void print_license(void)
++{
++	cout << "\n  LZMA command line tool " << PROGRAM_VERSION << " - "
++		<< PROGRAM_COPYRIGHT
++		<< "\n  LZMA SDK " << LZMA_SDK_VERSION_STRING << " - "
++		<< LZMA_SDK_COPYRIGHT_STRING
++		<< "\n  This program is a part of the LZMA utils package.\n"
++		"  http://tukaani.org/lzma/\n\n"
++"  This program is free software; you can redistribute it and/or\n"
++"  modify it under the terms of the GNU General Public License\n"
++"  as published by the Free Software Foundation; either version 2\n"
++"  of the License, or (at your option) any later version.\n"
++"\n"
++"  This program is distributed in the hope that it will be useful,\n"
++"  but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
++"  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n"
++"  GNU General Public License for more details.\n"
++"\n";
++}
++
++void print_version(void)
++{
++	cout << "LZMA command line tool " << PROGRAM_VERSION << "\n"
++		<< "LZMA SDK " << LZMA_SDK_VERSION_STRING << "\n";
++}
++
++short str2int (const char *str, const int &min, const int &max)
++{
++	int value = -1;
++	char *endptr = NULL;
++	if (str == NULL || str[0] == '\0')
++		throw ArgumentException("Invalid integer option");
++	value = strtol (str, &endptr, 10);
++	if (*endptr != '\0' || value < min || value > max)
++		throw ArgumentException("Invalid integer option");
++	return value;
++}
++
++void parse_options(int argc, char **argv, stringVector &filenames)
++{
++	/* Snatched from getopt(3). */
++	int c;
++
++	/* Check how we were called */
++	{
++		char *p = strrchr (argv[0], '/'); // Remove path prefix, if any
++		if (p++ == NULL)
++			p = argv[0];
++		if (strstr (p, "un") != NULL) {
++			program_mode = PM_DECOMPRESS;
++		} else if (strstr (p, "cat") != NULL) {
++			program_mode = PM_DECOMPRESS;
++			stdoutput = true;
++		}
++	}
++
++	while (-1 != (c = getopt_long(argc, argv, option_string,
++			long_options, NULL))) {
++		switch (c) {
++			// stdout
++			case 'c':
++				stdoutput = true;
++				break;
++
++			// decompress
++			case 'd':
++				program_mode = PM_DECOMPRESS;
++				break;
++
++			// compress
++			case 'z':
++				program_mode = PM_COMPRESS;
++				break;
++
++			// keep
++			case 'k':
++				keep = true;
++				break;
++
++			// force
++			case 'f':
++				force = true;
++				break;
++
++			// test
++			case 't':
++				program_mode = PM_TEST;
++				break;
++
++			// suffix
++			case 'S':
++				if (optarg) {
++					free(suffix);
++					suffix = strdup(optarg);
++				}
++				break;
++
++			// quiet
++			case 'q':
++				verbosity = 0;
++				break;
++
++			// verbose
++			case 'v':
++				verbosity++;
++				break;
++
++			// help
++			case 'h':
++				program_mode = PM_HELP;
++				break;
++
++			// license
++			case 'L':
++				program_mode = PM_LICENSE;
++				break;
++
++			// version
++			case 'V':
++				program_mode = PM_VERSION;
++				break;
++
++			case '1': case '2': case '3': case '4': case '5':
++			case '6': case '7': case '8': case '9':
++				compression_mode = c - '0';
++				break;
++
++			// Advanced options //
++			// Compression mode
++			case 'A':
++				advanced_options.compression_mode =
++						str2int (optarg, 0, 2);
++				break;
++
++			// Dictionary size
++			case 'D':
++				advanced_options.dictionary =
++						str2int (optarg, 0, 28);
++				break;
++
++			// Fast bytes
++			case 'F':
++				advanced_options.fast_bytes =
++						str2int (optarg, 0, 273);
++				break;
++
++			default:
++				throw ArgumentException("");
++				break;
++		} // switch(c)
++	} // while(1)
++
++	for (int i = optind; i < argc; i++) {
++		if (strcmp("-", argv[i]) == 0)
++			continue;
++		filenames.push_back(argv[i]);
++	}
++} // parse_options
++
++void set_encoder_properties(NCompress::NLZMA::CEncoder *encoder,
++		lzma_option &opt)
++{
++	/* Almost verbatim from LzmaAlone.cpp. */
++	    PROPID propIDs[] =
++	{
++		NCoderPropID::kDictionarySize,
++		NCoderPropID::kPosStateBits,
++		NCoderPropID::kLitContextBits,
++		NCoderPropID::kLitPosBits,
++		NCoderPropID::kAlgorithm,
++		NCoderPropID::kNumFastBytes,
++		NCoderPropID::kMatchFinder,
++		NCoderPropID::kEndMarker
++	};
++	const int kNumProps = sizeof(propIDs) / sizeof(propIDs[0]);
++#define VALUE(x) (advanced_options.x >= 0 ? advanced_options.x : opt.x)
++	PROPVARIANT properties[kNumProps];
++	for (int p = 0; p < 6; p++)
++		properties[p].vt = VT_UI4;
++	properties[0].ulVal = UInt32(1 << VALUE (dictionary));
++	properties[1].ulVal = UInt32(VALUE (pos_bits));
++	properties[2].ulVal = UInt32(VALUE (literal_context_bits));
++	properties[3].ulVal = UInt32(VALUE (literal_pos_bits));
++	properties[4].ulVal = UInt32(VALUE (compression_mode));
++	properties[5].ulVal = UInt32(VALUE (fast_bytes));
++#undef VALUE
++
++	properties[6].vt = VT_BSTR;
++	properties[6].bstrVal = (BSTR)opt.match_finder;
++
++	properties[7].vt = VT_BOOL;
++	properties[7].boolVal = stdinput ? VARIANT_TRUE : VARIANT_FALSE;
++
++	if (encoder->SetCoderProperties(propIDs, properties, kNumProps) != S_OK)
++		throw Exception("SetCoderProperties() error");
++}
++
++void encode(NCompress::NLZMA::CEncoder *encoderSpec,
++		CMyComPtr<ISequentialInStream> inStream,
++		CMyComPtr<ISequentialOutStream> outStream,
++		lzma_option encoder_options,
++		UInt64 fileSize)
++{
++	set_encoder_properties(encoderSpec, encoder_options);
++
++	encoderSpec->WriteCoderProperties(outStream);
++
++	for (int i = 0; i < 8; i++)
++	{
++		Byte b = Byte(fileSize >> (8 * i));
++		if (outStream->Write(&b, sizeof(b), 0) != S_OK)
++			throw Exception("Write error while encoding");
++	}
++
++	HRESULT result = encoderSpec->Code(inStream, outStream, 0, 0, 0);
++
++	if (result == E_OUTOFMEMORY)
++		throw Exception("Cannot allocate memory");
++	else if (result != S_OK) {
++		char buffer[33];
++		snprintf(buffer, 33, "%d", (unsigned int)result);
++		throw Exception(string("Encoder error: ") + buffer);
++	}
++}
++
++void decode(NCompress::NLZMA::CDecoder *decoderSpec,
++		CMyComPtr<ISequentialInStream> inStream,
++		CMyComPtr<ISequentialOutStream> outStream)
++{
++	const UInt32 kPropertiesSize = 5;
++	Byte properties[kPropertiesSize];
++	UInt32 processedSize;
++	UInt64 fileSize = 0;
++
++	if (inStream->Read(properties, kPropertiesSize, &processedSize) != S_OK)
++		throw Exception("Read error");
++	if (processedSize != kPropertiesSize)
++		throw Exception("Read error");
++	if (decoderSpec->SetDecoderProperties2(properties, kPropertiesSize) != S_OK)
++		throw Exception("SetDecoderProperties() error");
++
++	for (int i = 0; i < 8; i++)
++	{
++		Byte b;
++
++		if (inStream->Read(&b, sizeof(b), &processedSize) != S_OK)
++			throw Exception("Read error");
++		if (processedSize != 1)
++			throw Exception("Read error");
++
++		fileSize |= ((UInt64)b) << (8 * i);
++	}
++
++	if (decoderSpec->Code(inStream, outStream, 0, &fileSize, 0) != S_OK)
++		throw Exception("Decoder error");
++}
++
++int open_instream(const string infile,
++		CMyComPtr<ISequentialInStream> &inStream,
++		UInt64 &fileSize)
++{
++	CInFileStream *inStreamSpec = new CInFileStream;
++	inStream = inStreamSpec;
++	if (!inStreamSpec->Open(infile.c_str()))
++		throw Exception("Cannot open input file " + infile);
++
++	inStreamSpec->File.GetLength(fileSize);
++
++	return inStreamSpec->File.GetHandle();
++}
++
++int open_outstream(const string outfile,
++		CMyComPtr<ISequentialOutStream> &outStream)
++{
++	COutFileStream *outStreamSpec = new COutFileStream;
++	outStream = outStreamSpec;
++
++	bool open_by_force = (program_mode == PM_TEST) | force;
++
++	if (!outStreamSpec->Create(outfile.c_str(), open_by_force))
++		throw Exception("Cannot open output file " + outfile);
++
++	return outStreamSpec->File.GetHandle();
++}
++
++double get_ratio(int inhandle, int outhandle)
++{
++	struct stat in_stats, out_stats;
++	fstat(inhandle, &in_stats);
++	fstat(outhandle, &out_stats);
++
++	return (double)out_stats.st_size / (double)in_stats.st_size;
++}
++
++mode_t get_file_mode(string filename)
++{
++	struct stat in_stat;
++	lstat(filename.c_str(), &in_stat);
++
++	return in_stat.st_mode;
++}
++
++bool string_ends_with(string str, string ending)
++{
++	return equal(ending.rbegin(), ending.rend(), str.rbegin());
++}
++
++bool extension_is_known(string filename)
++{
++	bool known_format = false;
++	extension_pair extension; int i = 1;
++
++	extension = known_extensions[0];
++	while (extension.from != NULL) {
++		if (string_ends_with(filename, extension.from)) {
++			known_format = true;
++			break;
++		}
++		extension = known_extensions[i];
++		i++;
++	}
++
++	if (!known_format) {
++		if (!string_ends_with(filename, suffix)) {
++			return false;
++		}
++	}
++
++	return true;
++}
++
++string replace_extension(string filename)
++{
++	int suffix_starts_at = filename.length() - strlen (suffix);
++	string from_suffix = filename.substr(suffix_starts_at, strlen (suffix));
++	string ret = filename.substr(0, suffix_starts_at);
++	extension_pair extension; int i = 1;
++
++	bool found_replacement = false;
++	extension = known_extensions[0];
++	while (extension.from != NULL) {
++		if (from_suffix.compare(extension.from) == 0) {
++			ret += extension.to;
++			found_replacement = true;
++			break;
++		}
++
++		extension = known_extensions[i];
++		i++;
++	}
++
++	return ret;
++}
++
++string pretty_print_status(string filename, string output_filename,
++		string ratio)
++{
++	string ret = "";
++
++	ret += filename;
++	ret += ":\t ";
++
++	if (program_mode == PM_TEST) {
++		ret += "decoded succesfully";
++
++		return ret;
++	}
++
++	if (!stdinput && !stdoutput) {
++		ret += ratio;
++		ret += " -- ";
++	}
++
++	if (program_mode == PM_COMPRESS) {
++		if (keep) {
++			ret += "encoded succesfully";
++
++			return ret;
++		}
++
++		ret += "replaced with ";
++		ret += output_filename;
++
++		return ret;
++	}
++
++	if (program_mode == PM_DECOMPRESS) {
++		if (keep) {
++			ret += "decoded succesfully";
++
++			return ret;
++		}
++
++		ret += "replaced with ";
++		ret += output_filename;
++
++		return ret;
++	}
++
++	return ret;
++}
++
++static string archive_name; // I know, it is crude, but I haven't found any other
++    // way then making a global variable to transfer filename to handler
++
++void signal_handler (int signum)
++{
++    unlink (archive_name.c_str()); // deleting
++    signal (signum, SIG_DFL); // we return the default function to used signal
++    kill (getpid(), signum); // and then send this signal to the process again
++}
++
++} // namespace lzma
++
++
++int main(int argc, char **argv)
++{
++	using namespace lzma;
++	using std::cerr;
++
++	stringVector filenames;
++
++	signal (SIGTERM,signal_handler);
++	signal (SIGHUP,signal_handler);
++	signal (SIGINT,signal_handler);
++
++	try {
++		parse_options(argc, argv, filenames);
++	}
++	catch (...) {
++		return STATUS_ERROR;
++	}
++
++	if (program_mode == PM_HELP) {
++		print_help(argv[0]);
++		return STATUS_OK;
++	}
++	else if (program_mode == PM_LICENSE) {
++		print_license();
++		return STATUS_OK;
++	}
++	else if (program_mode == PM_VERSION) {
++		print_version();
++		return STATUS_OK;
++	}
++
++	if (filenames.empty()) {
++		stdinput = true;
++		stdoutput = true;
++
++		/* FIXME: get rid of this */
++		filenames.push_back("-");
++	}
++
++	/* Protection: always create new files with 0600 in order to prevent
++	 * outsiders from reading incomplete data. */
++	umask(0077);
++
++	bool warning = false;
++
++	for (int i = 0; i < filenames.size(); i++) {
++		CMyComPtr<ISequentialInStream> inStream;
++		CMyComPtr<ISequentialOutStream> outStream;
++		UInt64 fileSize = 0;
++		int inhandle = 0, outhandle = 0;
++		string output_filename;
++
++		if (stdinput) {
++			inStream = new CStdInFileStream;
++			MY_SET_BINARY_MODE(stdin);
++			fileSize = (UInt64)(Int64)-1;
++
++			inhandle = STDIN_FILENO;
++
++			outStream = new CStdOutFileStream;
++			MY_SET_BINARY_MODE(stdout);
++
++			outhandle = STDOUT_FILENO;
++		}
++		else {
++			mode_t infile_mode = get_file_mode(filenames[i]);
++			if (!S_ISREG(infile_mode)) {
++				if (S_ISDIR(infile_mode)) {
++					warning = true;
++					cerr << argv[0] << ": " << filenames[i] << ": "
++						<< "cowardly refusing to work on directory"
++						<< endl;
++
++					continue;
++				}
++				else if (S_ISLNK(infile_mode)) {
++					if (!stdoutput && !force) {
++						warning = true;
++
++					cerr << argv[0] << ": " << filenames[i] << ": "
++							<< "cowardly refusing to work on symbolic link "
++							<< "(use --force to force encoding or decoding)"
++							<< endl;
++
++						continue;
++					}
++				}
++				else {
++					warning = true;
++
++					cerr << argv[0] << ": " << filenames[i] << ": "
++						<< "doesn't exist or is not a regular file"
++						<< endl;
++
++					continue;
++				}
++			}
++
++			// Test if the file already ends with *suffix.
++			if (program_mode == PM_COMPRESS && !force
++					&& string_ends_with(filenames[i],
++						suffix)) {
++				warning = true;
++
++				cerr << filenames[i] << " already has "
++					<< suffix << " suffix -- unchanged\n";
++
++				continue;
++			}
++
++			// Test if the file extension is known.
++			if (program_mode == PM_DECOMPRESS
++					&& !extension_is_known(filenames[i])) {
++				warning = true;
++
++				cerr << filenames[i] << ": "
++					<< " unknown suffix -- unchanged"
++					<< endl;
++
++				continue;
++			}
++
++			try {
++				inhandle = open_instream(filenames[i], inStream, fileSize);
++			}
++			catch (Exception e) {
++				cerr << argv[0] << ": " << e.what() << endl;
++				return STATUS_ERROR;
++			}
++
++			if (stdoutput) {
++				outStream = new CStdOutFileStream;
++				MY_SET_BINARY_MODE(stdout);
++
++				outhandle = STDOUT_FILENO;
++			}
++			else {
++				/* Testing mode is nothing else but decoding
++				 * and throwing away the result. */
++				if (program_mode == PM_TEST)
++					output_filename = "/dev/null";
++				else if (program_mode == PM_DECOMPRESS)
++					output_filename = replace_extension(filenames[i]);
++				else
++					output_filename = filenames[i]
++							+ suffix;
++				archive_name = output_filename;
++
++				try {
++					outhandle = open_outstream(output_filename, outStream);
++				}
++				catch (Exception e) {
++					cerr << argv[0] << ": " << e.what() << endl;
++					return STATUS_ERROR;
++				}
++			}
++
++		}
++
++		// Unless --force is specified, do not read/write compressed
++		// data from/to a terminal.
++		if (!force) {
++			if (program_mode == PM_COMPRESS && isatty(outhandle)) {
++				cerr << argv[0] << ": compressed data not "
++					"written to a terminal. Use "
++					"-f to force compression.\n"
++					<< argv[0] << ": For help, type: "
++					<< argv[0] << " -h\n";
++				return STATUS_ERROR;
++			} else if (program_mode == PM_DECOMPRESS
++					&& isatty(inhandle)) {
++				cerr << argv[0] << ": compressed data not "
++					"read from a terminal. Use "
++					"-f to force decompression.\n"
++					<< argv[0] << ": For help, type: "
++					<< argv[0] << " -h\n";
++				return STATUS_ERROR;
++			}
++		}
++
++		if (program_mode == PM_COMPRESS) {
++			    NCompress::NLZMA::CEncoder *encoderSpec =
++				      new NCompress::NLZMA::CEncoder;
++
++			lzma_option options = option_mapping[compression_mode];
++
++			try {
++				encode(encoderSpec, inStream, outStream, options, fileSize);
++			}
++			catch (Exception e) {
++				cerr << argv[0] << ": " << e.what() << endl;
++				unlink(output_filename.c_str());
++				delete(encoderSpec);
++
++				return STATUS_ERROR;
++			}
++
++			delete(encoderSpec);
++		}
++		else {			// PM_DECOMPRESS | PM_TEST
++		    NCompress::NLZMA::CDecoder *decoderSpec =
++		        new NCompress::NLZMA::CDecoder;
++
++			try {
++				decode(decoderSpec, inStream, outStream);
++			}
++			catch (Exception e) {
++				cerr << argv[0] << ": " << e.what() << endl;
++				unlink(output_filename.c_str());
++				delete(decoderSpec);
++
++				return STATUS_ERROR;
++			}
++
++			delete(decoderSpec);
++		}
++
++		/* Set permissions and owners. */
++		if ( (program_mode == PM_COMPRESS || program_mode == PM_DECOMPRESS )
++				&& (!stdinput && !stdoutput) ) {
++
++			int ret = 0;
++			struct stat file_stats;
++			ret = fstat(inhandle, &file_stats);
++
++			ret = fchmod(outhandle, file_stats.st_mode);
++			ret = fchown(outhandle, file_stats.st_uid, file_stats.st_gid);
++			// We need to call fchmod() again, since otherwise the SUID bits
++			// are lost.
++			ret = fchmod(outhandle, file_stats.st_mode);
++
++			struct timeval file_times[2];
++			// Access time
++			file_times[0].tv_sec = file_stats.st_atime;
++			file_times[0].tv_usec = 0;
++			// Modification time
++			file_times[1].tv_sec = file_stats.st_mtime;
++			file_times[1].tv_usec = 0;
++
++			ret = futimes(outhandle, file_times);
++
++			if (!keep)
++				unlink(filenames[i].c_str());
++		}
++
++		if (verbosity > 0) {
++			if (stdoutput) {
++				cerr << filenames[i] << ":\t ";
++				cerr << "decoded succesfully"
++					<< endl;
++			}
++
++			else {
++				char buf[10] = { 0 };
++
++				if (program_mode == PM_DECOMPRESS)
++					snprintf(buf, 10, "%.2f%%",
++							(1 - get_ratio(outhandle, inhandle)) * 100);
++				if (program_mode == PM_COMPRESS)
++					snprintf(buf, 10, "%.2f%%",
++							(1 - get_ratio(inhandle, outhandle)) * 100);
++
++				string ratio = buf;
++				cerr << pretty_print_status(filenames[i], output_filename,
++						ratio)
++					<< endl;
++			}
++		}
++	}
++
++	if (warning)
++		return STATUS_WARNING;
++
++	return STATUS_OK;
++}
++
+Index: lzma-4.43/C/7zip/Compress/LZMA_Alone/Exception.h
+===================================================================
+--- /dev/null	1970-01-01 00:00:00.000000000 +0000
++++ lzma-4.43/C/7zip/Compress/LZMA_Alone/Exception.h	2007-07-24 00:31:50.000000000 +0200
+@@ -0,0 +1,45 @@
++/* A couple of exceptions for lzmp.
++ *
++ * Copyright (C) 2005 Ville Koskinen
++ *
++ * 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 the Free Software Foundation; either version 2
++ * of the License, or (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++ * GNU General Public License for more details.
++ */
++
++#ifndef _EXCEPTION_H_
++#define _EXCEPTION_H_
++
++#include <string>
++using std::string;
++
++class Exception
++{
++private:
++	string message;
++public:
++	Exception(char *what): message(what) { }
++	Exception(string what): message(what) { }
++
++	~Exception() { }
++
++	string what(void) { return message; }
++};
++
++class ArgumentException: public Exception
++{
++public:
++	ArgumentException(char *what): Exception(what) { }
++	ArgumentException(string what): Exception(what) { }
++
++	~ArgumentException() { }
++};
++
++#endif
++
+Index: lzma-4.43/C/7zip/Compress/LZMA_Alone/makefile.gcc
+===================================================================
+--- lzma-4.43.orig/C/7zip/Compress/LZMA_Alone/makefile.gcc	2007-07-24 00:31:50.000000000 +0200
++++ lzma-4.43/C/7zip/Compress/LZMA_Alone/makefile.gcc	2007-07-24 00:31:50.000000000 +0200
+@@ -1,9 +1,10 @@
+-PROG = lzma
++PROG = lzma_alone
++PROG2 = lzma
+ CXX = g++ -O2 -Wall
+ CXX_C = gcc -O2 -Wall
+ LIB = -lm
+ RM = rm -f
+-CFLAGS = -c -I ../../../ -D_FILE_OFFSET_BITS=64
++CFLAGS = -c -I ../../../ -D_FILE_OFFSET_BITS=64 -DPACKAGE_VERSION="\"4.32.0beta3\""
+ 
+ OBJS = \
+   LzmaAlone.o \
+@@ -28,14 +29,36 @@
+   String.o \
+   StringConvert.o \
+   StringToInt.o \
+-  Vector.o \
++  Vector.o
+ 
++OBJS2 = \
++  C_FileIO.o \
++  CRC.o \
++  Alloc.o \
++  FileStreams.o \
++  StreamUtils.o \
++  InBuffer.o \
++  OutBuffer.o \
++  LZMADecoder.o \
++  RangeCoderBit.o \
++  LZInWindow.o \
++  LZOutWindow.o \
++  StringConvert.o \
++  StringToInt.o \
++  LZMAEncoder.o \
++  lzmp.o
+ 
+-all: $(PROG)
++all: $(PROG) $(PROG2)
+ 
+ $(PROG): $(OBJS)
+ 	$(CXX) -o $(PROG) $(LDFLAGS) $(OBJS) $(LIB)
+ 
++$(PROG2): $(OBJS2)
++	$(CXX) -o $(PROG2) $(LDFLAGS) $(OBJS2) $(LIB)
++
++lzmp.o: lzmp.cpp
++	$(CXX) $(CFLAGS) lzmp.cpp
++
+ LzmaAlone.o: LzmaAlone.cpp
+ 	$(CXX) $(CFLAGS) LzmaAlone.cpp
+ 
+@@ -109,5 +132,5 @@
+ 	$(CXX) $(CFLAGS) ../../../Common/Vector.cpp
+ 
+ clean:
+-	-$(RM) $(PROG) $(OBJS)
++	-$(RM) $(PROG) $(OBJS) $(PROG2) $(OBJS2)
+ 
+Index: lzma-4.43/C/7zip/Compress/LZMA_Alone/lzma_version.h
+===================================================================
+--- /dev/null	1970-01-01 00:00:00.000000000 +0000
++++ lzma-4.43/C/7zip/Compress/LZMA_Alone/lzma_version.h	2007-07-24 00:31:50.000000000 +0200
+@@ -0,0 +1,31 @@
++#ifndef LZMA_VERSION_H
++#define LZMA_VERSION_H
++
++/*
++    Version and copyright information used by LZMA utils.
++*/
++
++static const char *LZMA_SDK_VERSION_STRING = "4.43";
++
++static const char *LZMA_SDK_COPYRIGHT_STRING =
++		"Copyright (C) 1999-2006 Igor Pavlov";
++
++static const char *LZMA_SDK_COPYRIGHT_INFO =
++		"  See http://7-zip.org/sdk.html or the documentation of LZMA SDK for\n"
++		"  the license. For reference, the version 4.43 is free software\n"
++		"  licensed under the GNU LGPL.";
++
++
++static const char *LZMA_UTILS_VERSION_STRING = PACKAGE_VERSION;
++
++static const char *LZMA_UTILS_COPYRIGHT_STRING =
++		"Copyright (C) 2006 Lasse Collin";
++
++static const char *LZMA_UTILS_COPYRIGHT_INFO =
++		"This program comes with ABSOLUTELY NO WARRANTY.\n"
++		"You may redistribute copies of this program\n"
++		"under the terms of the GNU General Public License.\n"
++		"For more information about these matters, see the file "
++		"named COPYING.\n";
++
++#endif /* ifndef LZMA_VERSION_H */
+Index: lzma-4.43/C/Common/C_FileIO.h
+===================================================================
+--- lzma-4.43.orig/C/Common/C_FileIO.h	2004-07-24 13:35:06.000000000 +0200
++++ lzma-4.43/C/Common/C_FileIO.h	2007-07-24 00:31:50.000000000 +0200
+@@ -24,6 +24,7 @@
+   bool Close();
+   bool GetLength(UInt64 &length) const;
+   off_t Seek(off_t distanceToMove, int moveMethod) const;
++  int GetHandle() const { return _handle; }
+ };
+ 
+ class CInFile: public CFileBase
--- lzma-4.43.orig/debian/patches/04_sqlzma_h.diff
+++ lzma-4.43/debian/patches/04_sqlzma_h.diff
@@ -0,0 +1,86 @@
+--- /dev/null	2007-10-03 00:21:41.724022693 +0100
++++ lzma443/C/7zip/Common/sqlzma.h	2007-10-06 02:52:55.000000000 +0100
+@@ -0,0 +1,83 @@
++/*
++ * Copyright (C) 2006 Junjiro Okajima
++ * Copyright (C) 2006 Tomas Matejicek, slax.org
++ *
++ * LICENSE follows the described one in lzma.
++ */
++
++/* $Id: sqlzma.h,v 1.15 2007/11/09 14:42:12 jro Exp $ */
++
++#ifndef __sqlzma_h__
++#define __sqlzma_h__
++
++#ifndef __KERNEL__
++#include <stdlib.h>
++#include <string.h>
++#include <zlib.h>
++#ifdef _REENTRANT
++#include <pthread.h>
++#endif
++#else
++#include <linux/zlib.h>
++#endif
++#define _7ZIP_BYTE_DEFINED
++
++/*
++ * detect the compression method automatically by the first byte of compressed
++ * data.
++ * according to rfc1950, the first byte of zlib compression must be 0x?8.
++ */
++#define is_lzma(c)	(c == 0x5d)
++
++/* ---------------------------------------------------------------------- */
++
++#ifdef __cplusplus
++extern "C" {
++#endif
++
++#ifndef __KERNEL__
++/* for mksquashfs only */
++struct sqlzma_opts {
++	unsigned int	try_lzma:1;
++	unsigned int 	dicsize;
++};
++int sqlzma_cm(struct sqlzma_opts *opts, z_stream *stream, Bytef *next_in, uInt
++	      avail_in, Bytef *next_out, uInt avail_out);
++#endif
++
++/* ---------------------------------------------------------------------- */
++/*
++ * Three patterns for sqlzma uncompression. very dirty code.
++ * - kernel space (squashfs kernel module)
++ * - user space with pthread (mksquashfs)
++ * - user space without pthread (unsquashfs)
++ */
++
++struct sized_buf {
++	unsigned int	sz;
++	unsigned char	*buf;
++};
++
++enum {SQUN_PROB, SQUN_RESULT, SQUN_LAST};
++struct sqlzma_un {
++	int			un_lzma;
++	struct sized_buf	un_a[SQUN_LAST];
++	unsigned char           un_prob[31960]; /* unlzma 64KB - 1MB */
++	z_stream		un_stream;
++#define un_cmbuf	un_stream.next_in
++#define un_cmlen	un_stream.avail_in
++#define un_resbuf	un_stream.next_out
++#define un_resroom	un_stream.avail_out
++#define un_reslen	un_stream.total_out
++};
++
++int sqlzma_init(struct sqlzma_un *un, int do_lzma, unsigned int res_sz);
++int sqlzma_un(struct sqlzma_un *un, struct sized_buf *src, struct sized_buf *dst);
++void sqlzma_fin(struct sqlzma_un *un);
++
++/* ---------------------------------------------------------------------- */
++
++#ifdef __cplusplus
++};
++#endif
++#endif
--- lzma-4.43.orig/debian/patches/01_large_files.diff
+++ lzma-4.43/debian/patches/01_large_files.diff
@@ -0,0 +1,13 @@
+Index: lzma-4.43/C/7zip/Compress/LZMA_Alone/makefile.gcc
+===================================================================
+--- lzma-4.43.orig/C/7zip/Compress/LZMA_Alone/makefile.gcc	2006-08-08 22:07:54.000000000 +0200
++++ lzma-4.43/C/7zip/Compress/LZMA_Alone/makefile.gcc	2006-08-08 22:08:12.000000000 +0200
+@@ -3,7 +3,7 @@
+ CXX_C = gcc -O2 -Wall
+ LIB = -lm
+ RM = rm -f
+-CFLAGS = -c -I ../../../
++CFLAGS = -c -I ../../../ -D_FILE_OFFSET_BITS=64
+ 
+ OBJS = \
+   LzmaAlone.o \
--- lzma-4.43.orig/debian/patches/06_sqlzma.diff
+++ lzma-4.43/debian/patches/06_sqlzma.diff
@@ -0,0 +1,733 @@
+Index: lzma449/C/7zip/Compress/LZMA_C/kmod.mk
+===================================================================
+RCS file: lzma449/C/7zip/Compress/LZMA_C/kmod.mk
+diff -N lzma449/C/7zip/Compress/LZMA_C/kmod.mk
+--- /dev/null	1 Jan 1970 00:00:00 -0000
++++ lzma449/C/7zip/Compress/LZMA_C/kmod.mk	5 Nov 2007 05:43:35 -0000	1.1
+@@ -0,0 +1,40 @@
++
++# Copyright (C) 2006-2007 Junjiro Okajima
++# Copyright (C) 2006-2007 Tomas Matejicek, slax.org
++#
++# LICENSE follows the described one in lzma.txt.
++
++# $Id: kmod.mk,v 1.1 2007/11/05 05:43:35 jro Exp $
++
++ifndef Sqlzma
++$(error Sqlzma is not defined)
++endif
++ifndef KDir
++$(error KDir is not defined)
++endif
++
++#include makefile.gcc
++
++Kmod = kmod
++EXTRA_CFLAGS += -Wall -Werror -I${CURDIR} -I${Sqlzma}
++# -D_LZMA_PROB32
++EXTRA_CFLAGS += $(shell ${CPP} ${CFLAGS} -P testflags.c)
++
++all: ${Kmod}/uncomp.c
++	${MAKE} EXTRA_CFLAGS="${EXTRA_CFLAGS}" M=${CURDIR}/${Kmod} \
++		-C ${KDir} C=0 V=0 modules
++
++${Kmod}/uncomp.c: uncomp.c
++	ln $< $@
++
++clean: clean_kmod
++clean_kmod:
++	${MAKE} -C ${KDir} M=${CURDIR}/${Kmod} V=0 clean
++	${RM} ${Kmod}/*~
++	-@test -e ${Kmod}/uncomp.c && \
++		diff -q ${Kmod}/uncomp.c uncomp.c > /dev/null && \
++		find ${Kmod}/uncomp.c -links +1 | xargs -r ${RM}
++
++# Local variables: ;
++# compile-command: (concat "make Sqlzma=../../../../.. KDir=/lib/modules/`uname -r`/build -f " (file-name-nondirectory (buffer-file-name)));
++# End: ;
+Index: lzma449/C/7zip/Compress/LZMA_C/sqlzma.mk
+===================================================================
+RCS file: lzma449/C/7zip/Compress/LZMA_C/sqlzma.mk
+diff -N lzma449/C/7zip/Compress/LZMA_C/sqlzma.mk
+--- /dev/null	1 Jan 1970 00:00:00 -0000
++++ lzma449/C/7zip/Compress/LZMA_C/sqlzma.mk	5 Nov 2007 05:43:36 -0000	1.1
+@@ -0,0 +1,47 @@
++
++# Copyright (C) 2006-2007 Junjiro Okajima
++# Copyright (C) 2006-2007 Tomas Matejicek, slax.org
++#
++# LICENSE follows the described one in lzma.txt.
++
++# $Id: sqlzma.mk,v 1.1 2007/11/05 05:43:36 jro Exp $
++
++ifndef Sqlzma
++$(error Sqlzma is not defined)
++endif
++
++#include makefile.gcc
++CFLAGS = -c -O2 -Wall -pedantic -D _LZMA_PROB32
++
++ifdef KDir
++include kmod.mk
++endif
++
++ifdef UseDebugFlags
++DebugFlags = -O0 -g -UNDEBUG
++endif
++CFLAGS += -DNDEBUG ${DebugFlags}
++Tgt = libunlzma.a libunlzma_r.a
++
++all: ${Tgt}
++
++%_r.c: %.c
++	ln $< $@
++# -pthread
++%_r.o: CFLAGS += -D_REENTRANT -include pthread.h
++
++uncomp.o uncomp_r.o: CFLAGS += -I${Sqlzma}
++uncomp.o: uncomp.c ${Sqlzma}/sqlzma.h
++
++libunlzma.a: uncomp.o LzmaDecode.o
++	${AR} cr $@ $^
++libunlzma_r.a: uncomp_r.o LzmaDecode_r.o
++	${AR} cr $@ $^
++
++clean: clean_sqlzma
++clean_sqlzma:
++	$(RM) ${Tgt} uncomp.o uncomp_r.o LzmaDecode_r.o LzmaDecode.o  *~
++
++# Local variables: ;
++# compile-command: (concat "make Sqlzma=../../../../.. -f " (file-name-nondirectory (buffer-file-name)));
++# End: ;
+Index: lzma449/C/7zip/Compress/LZMA_C/testflags.c
+===================================================================
+RCS file: lzma449/C/7zip/Compress/LZMA_C/testflags.c
+diff -N lzma449/C/7zip/Compress/LZMA_C/testflags.c
+--- /dev/null	1 Jan 1970 00:00:00 -0000
++++ lzma449/C/7zip/Compress/LZMA_C/testflags.c	5 Nov 2007 05:43:36 -0000	1.1
+@@ -0,0 +1,5 @@
++#ifdef _LZMA_PROB32
++-D_LZMA_PROB32
++#else
++-U_LZMA_PROB32
++#endif
+Index: lzma449/C/7zip/Compress/LZMA_C/uncomp.c
+===================================================================
+RCS file: lzma449/C/7zip/Compress/LZMA_C/uncomp.c
+diff -N lzma449/C/7zip/Compress/LZMA_C/uncomp.c
+--- /dev/null	1 Jan 1970 00:00:00 -0000
++++ lzma449/C/7zip/Compress/LZMA_C/uncomp.c	5 Nov 2007 05:43:36 -0000	1.1
+@@ -0,0 +1,221 @@
++/*
++ * Copyright (C) 2006, 2007 Junjiro Okajima
++ * Copyright (C) 2006, 2007 Tomas Matejicek, slax.org
++ *
++ * LICENSE follows the described one in lzma.txt.
++ */
++
++/* $Id: uncomp.c,v 1.1 2007/11/05 05:43:36 jro Exp $ */
++
++/* extract some parts from lzma443/C/7zip/Compress/LZMA_C/LzmaTest.c */
++
++#ifndef __KERNEL__
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++#include <errno.h>
++#include <assert.h>
++#include <pthread.h>
++#define unlikely(x)		__builtin_expect(!!(x), 0)
++#define BUG_ON(x)		assert(!(x))
++/* sqlzma buffers are always larger than a page. true? */
++#define kmalloc(sz,gfp)		malloc(sz)
++#define kfree(p)		free(p)
++#define zlib_inflate(s, f)	inflate(s, f)
++#define zlib_inflateInit(s)	inflateInit(s)
++#define zlib_inflateReset(s)	inflateReset(s)
++#define zlib_inflateEnd(s)	inflateEnd(s)
++#else
++#include <linux/init.h>
++#include <linux/module.h>
++#include <linux/kernel.h>
++#include <linux/vmalloc.h>
++#ifndef WARN_ON_ONCE
++#define WARN_ON_ONCE(b)	WARN_ON(b)
++#endif
++#endif /* __KERNEL__ */
++
++#include "sqlzma.h"
++#include "LzmaDecode.h"
++
++static int LzmaUncompress(struct sqlzma_un *un)
++{
++	int err, i, ret;
++	SizeT outSize, inProcessed, outProcessed, srclen;
++	/* it's about 24-80 bytes structure, if int is 32-bit */
++	CLzmaDecoderState state;
++	unsigned char *dst, *src, a[8];
++	struct sized_buf *sbuf;
++
++	/* Decode LZMA properties and allocate memory */
++	err = -EINVAL;
++	src = un->un_cmbuf;
++	ret = LzmaDecodeProperties(&state.Properties, src, LZMA_PROPERTIES_SIZE);
++	src += LZMA_PROPERTIES_SIZE;
++	if (unlikely(ret != LZMA_RESULT_OK))
++		goto out;
++	i = LzmaGetNumProbs(&state.Properties);
++	if (unlikely(i <= 0))
++		i = 1;
++	i *= sizeof(CProb);
++	sbuf = un->un_a + SQUN_PROB;
++	if (unlikely(sbuf->sz < i)) {
++		if (sbuf->buf && sbuf->buf != un->un_prob)
++			kfree(sbuf->buf);
++#ifdef __KERNEL__
++		printk("%s:%d: %d --> %d\n", __func__, __LINE__, sbuf->sz, i);
++#else
++		printf("%d --> %d\n", sbuf->sz, i);
++#endif
++		err = -ENOMEM;
++		sbuf->sz = 0;
++		sbuf->buf = kmalloc(i, GFP_ATOMIC);
++		if (unlikely(!sbuf->buf))
++			goto out;
++		sbuf->sz = i;
++	}
++	state.Probs = (void*)sbuf->buf;
++
++	/* Read uncompressed size */
++	memcpy(a, src, sizeof(a));
++	src += sizeof(a);
++	outSize = a[0] | (a[1] << 8) | (a[2] << 16) | (a[3] << 24);
++
++	err = -EINVAL;
++	dst = un->un_resbuf;
++	if (unlikely(!dst || outSize > un->un_reslen))
++		goto out;
++	un->un_reslen = outSize;
++	srclen = un->un_cmlen - (src - un->un_cmbuf);
++
++	/* Decompress */
++	err = LzmaDecode(&state, src, srclen, &inProcessed, dst, outSize,
++			 &outProcessed);
++	if (err)
++		err = -EINVAL;
++
++ out:
++#ifndef __KERNEL__
++	if (err)
++		fprintf(stderr, "err %d\n", err);
++#endif
++	return err;
++}
++
++int sqlzma_un(struct sqlzma_un *un, struct sized_buf *src,
++	      struct sized_buf *dst)
++{
++	int err, by_lzma = 0;
++	if (un->un_lzma && is_lzma(*src->buf)) {
++		by_lzma = 1;
++		un->un_cmbuf = src->buf;
++		un->un_cmlen = src->sz;
++		un->un_resbuf = dst->buf;
++		un->un_reslen = dst->sz;
++
++		/* this library is thread-safe */
++		err = LzmaUncompress(un);
++		goto out;
++	}
++
++	err = zlib_inflateReset(&un->un_stream);
++	if (unlikely(err != Z_OK))
++		goto out;
++	un->un_stream.next_in = src->buf;
++	un->un_stream.avail_in = src->sz;
++	un->un_stream.next_out = dst->buf;
++	un->un_stream.avail_out = dst->sz;
++	err = zlib_inflate(&un->un_stream, Z_FINISH);
++	if (err == Z_STREAM_END)
++		err = 0;
++
++ out:
++	if (err) {
++#ifdef __KERNEL__
++		WARN_ON_ONCE(1);
++#else
++		char a[64] = "ZLIB ";
++		if (by_lzma) {
++			strcpy(a, "LZMA ");
++#ifdef _REENTRANT
++			strerror_r(err, a + 5, sizeof(a) - 5);
++#else
++			strncat(a, strerror(err), sizeof(a) - 5);
++#endif
++		} else
++			strncat(a, zError(err), sizeof(a) - 5);
++		fprintf(stderr, "%s: %.*s\n", __func__, sizeof(a), a);
++#endif
++	}
++	return err;
++}
++
++int sqlzma_init(struct sqlzma_un *un, int do_lzma, unsigned int res_sz)
++{
++	int err;
++
++	err = -ENOMEM;
++	un->un_lzma = do_lzma;
++	memset(un->un_a, 0, sizeof(un->un_a));
++	un->un_a[SQUN_PROB].buf = un->un_prob;
++	un->un_a[SQUN_PROB].sz = sizeof(un->un_prob);
++	if (res_sz) {
++		un->un_a[SQUN_RESULT].buf = kmalloc(res_sz, GFP_KERNEL);
++		if (unlikely(!un->un_a[SQUN_RESULT].buf))
++			return err;
++		un->un_a[SQUN_RESULT].sz = res_sz;
++	}
++
++	un->un_stream.next_in = NULL;
++	un->un_stream.avail_in = 0;
++#ifdef __KERNEL__
++	un->un_stream.workspace = kmalloc(zlib_inflate_workspacesize(), GFP_KERNEL);
++	if (unlikely(!un->un_stream.workspace))
++		return err;
++#else
++	un->un_stream.opaque = NULL;
++	un->un_stream.zalloc = Z_NULL;
++	un->un_stream.zfree = Z_NULL;
++#endif
++	err = zlib_inflateInit(&un->un_stream);
++	if (unlikely(err == Z_MEM_ERROR))
++		return -ENOMEM;
++	BUG_ON(err);
++	return err;
++}
++
++void sqlzma_fin(struct sqlzma_un *un)
++{
++	int i;
++	for (i = 0; i < SQUN_LAST; i++)
++		if (un->un_a[i].buf && un->un_a[i].buf != un->un_prob)
++			kfree(un->un_a[i].buf);
++	BUG_ON(zlib_inflateEnd(&un->un_stream) != Z_OK);
++}
++
++#ifdef __KERNEL__
++EXPORT_SYMBOL(sqlzma_un);
++EXPORT_SYMBOL(sqlzma_init);
++EXPORT_SYMBOL(sqlzma_fin);
++
++#if 0
++static int __init sqlzma_init(void)
++{
++	return 0;
++}
++
++static void __exit sqlzma_exit(void)
++{
++}
++
++module_init(sqlzma_init);
++module_exit(sqlzma_exit);
++#endif
++
++MODULE_LICENSE("GPL");
++MODULE_AUTHOR("Junjiro Okajima <sfjro at users dot sf dot net>");
++MODULE_VERSION("$Id: uncomp.c,v 1.1 2007/11/05 05:43:36 jro Exp $");
++MODULE_DESCRIPTION("LZMA uncompress for squashfs. "
++		   "Some functions for squashfs to support LZMA and "
++		   "a tiny wrapper for LzmaDecode.c in LZMA SDK from www.7-zip.org.");
++#endif
+Index: lzma449/C/7zip/Compress/LZMA_C/kmod/Makefile
+===================================================================
+RCS file: lzma449/C/7zip/Compress/LZMA_C/kmod/Makefile
+diff -N lzma449/C/7zip/Compress/LZMA_C/kmod/Makefile
+--- /dev/null	1 Jan 1970 00:00:00 -0000
++++ lzma449/C/7zip/Compress/LZMA_C/kmod/Makefile	5 Nov 2007 05:43:36 -0000	1.1
+@@ -0,0 +1,11 @@
++
++# Copyright (C) 2006-2007 Junjiro Okajima
++# Copyright (C) 2006-2007 Tomas Matejicek, slax.org
++#
++# LICENSE follows the described one in lzma.txt.
++
++# $Id: Makefile,v 1.1 2007/11/05 05:43:36 jro Exp $
++
++obj-m += unlzma.o sqlzma.o
++unlzma-y := module.o
++sqlzma-y := uncomp.o
+Index: lzma449/C/7zip/Compress/LZMA_C/kmod/module.c
+===================================================================
+RCS file: lzma449/C/7zip/Compress/LZMA_C/kmod/module.c
+diff -N lzma449/C/7zip/Compress/LZMA_C/kmod/module.c
+--- /dev/null	1 Jan 1970 00:00:00 -0000
++++ lzma449/C/7zip/Compress/LZMA_C/kmod/module.c	5 Nov 2007 05:43:36 -0000	1.1
+@@ -0,0 +1,36 @@
++
++/*
++ * Copyright (C) 2006-2007 Junjiro Okajima
++ * Copyright (C) 2006-2007 Tomas Matejicek, slax.org
++ *
++ * LICENSE follows the described one in lzma.txt.
++ */
++
++/* $Id: module.c,v 1.1 2007/11/05 05:43:36 jro Exp $ */
++
++#include <linux/init.h>
++#include <linux/module.h>
++
++#include "../LzmaDecode.c"
++
++EXPORT_SYMBOL(LzmaDecodeProperties);
++EXPORT_SYMBOL(LzmaDecode);
++
++#if 0
++static int __init unlzma_init(void)
++{
++	return 0;
++}
++
++static void __exit unlzma_exit(void)
++{
++}
++
++module_init(unlzma_init);
++module_exit(unlzma_exit);
++#endif
++
++MODULE_LICENSE("GPL");
++MODULE_VERSION("$Id: module.c,v 1.1 2007/11/05 05:43:36 jro Exp $");
++MODULE_DESCRIPTION("LZMA uncompress. "
++		   "A tiny wrapper for LzmaDecode.c in LZMA SDK from www.7-zip.org.");
+Index: lzma449/C/7zip/Compress/LZMA_Alone/comp.cc
+===================================================================
+RCS file: lzma449/C/7zip/Compress/LZMA_Alone/comp.cc
+diff -N lzma449/C/7zip/Compress/LZMA_Alone/comp.cc
+--- /dev/null	1 Jan 1970 00:00:00 -0000
++++ lzma449/C/7zip/Compress/LZMA_Alone/comp.cc	13 Nov 2007 13:27:23 -0000	1.3
+@@ -0,0 +1,260 @@
++/*
++ * Copyright (C) 2006-2007 Junjiro Okajima
++ * Copyright (C) 2006-2007 Tomas Matejicek, slax.org
++ *
++ * LICENSE follows the described one in lzma.txt.
++ */
++
++/* $Id: comp.cc,v 1.3 2007/11/13 13:27:23 jro Exp $ */
++
++// extract some parts from lzma443/C/7zip/Compress/LZMA_Alone/LzmaAlone.cpp
++
++#include <stdio.h>
++#include <stdlib.h>
++#include <assert.h>
++#include <errno.h>
++
++#include "StdAfx.h"
++#include "../../../Common/MyInitGuid.h"
++//#include "../../../Common/MyWindows.h"
++#include "../../../Common/StringConvert.h"
++//#include "../../../Common/StringToInt.h"
++//#include "../../Common/StreamUtils.h"
++#include "../LZMA/LZMAEncoder.h"
++
++#include <pthread.h>
++#include <zlib.h>
++#include "sqlzma.h"
++
++//////////////////////////////////////////////////////////////////////
++
++class CMemoryStream {
++protected:
++	Bytef *m_data;
++	UInt64 m_limit;
++	UInt64 m_pos;
++
++public:
++	CMemoryStream(Bytef *data, UInt64 size)
++		: m_data(data), m_limit(size), m_pos(0) {}
++
++	virtual ~CMemoryStream() {}
++};
++
++class CInMemoryStream : public CMemoryStream, public IInStream,
++			public CMyUnknownImp {
++//protected:
++	CMyComPtr<ISequentialInStream> m_stream;
++
++public:
++	MY_UNKNOWN_IMP1(IInStream);
++
++	CInMemoryStream(Bytef *data, UInt64 size)
++		: CMemoryStream(data, size), m_stream(this) {}
++
++	virtual ~CInMemoryStream() {}
++
++	STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize)
++	{
++		UInt64 room = m_limit - m_pos;
++		if (size > room)
++			size = room;
++		if (size) {
++			memcpy(data, m_data + m_pos, size);
++			m_pos += size;
++		}
++		if (processedSize)
++			*processedSize = size;
++		return S_OK;
++	}
++
++	// disabled all
++	STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition) {
++		assert(0);
++		return E_NOTIMPL;
++	}
++};
++
++class COutMemoryStream : public CMemoryStream, public IOutStream,
++			 public CMyUnknownImp {
++//protected:
++	CMyComPtr<ISequentialOutStream> m_stream;
++
++public:
++	MY_UNKNOWN_IMP1(IOutStream);
++
++	COutMemoryStream(Bytef *data, UInt64 size)
++		: CMemoryStream(data, size), m_stream(this) {}
++
++	virtual ~COutMemoryStream() {}
++
++	UInt32 GetSize() {return m_pos;}
++
++	STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize) {
++		if (m_pos + size > m_limit)
++			return -ENOSPC;
++		memcpy(m_data + m_pos, data, size);
++		m_pos += size;
++		if (processedSize)
++			*processedSize = size;
++		return S_OK;
++	}
++
++	// disabled all
++	STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition) {
++		assert(0);
++		return E_NOTIMPL;
++	}
++	STDMETHOD(SetSize)(Int64 newSize) {
++		assert(0);
++		return E_NOTIMPL;
++	}
++};
++
++//////////////////////////////////////////////////////////////////////
++
++static int
++LzmaCompress(Bytef *next_in, uInt avail_in, Bytef *next_out, uInt avail_out,
++	     struct sqlzma_opts *opts, uLong *total_out)
++{
++	int err;
++	HRESULT res;
++	const Byte a[] = {
++		avail_in, avail_in >> 8, avail_in >> 16, avail_in >> 24,
++		0, 0, 0, 0
++	};
++
++	NCompress::NLZMA::CEncoder encoderSpec;
++	CMyComPtr<ICompressCoder> encoder = &encoderSpec;
++	encoder->AddRef();
++	CInMemoryStream inStreamSpec(next_in, avail_in);
++	CMyComPtr<ISequentialInStream> inStream = &inStreamSpec;
++	inStream->AddRef();
++	COutMemoryStream outStreamSpec(next_out, avail_out);
++	CMyComPtr<ISequentialOutStream> outStream = &outStreamSpec;
++	outStream->AddRef();
++
++	// these values are dpending upon is_lzma() macro in sqlzma.h
++	const UInt32 dictionary = opts->dicsize;
++	//fprintf(stderr, "dic %u\n", dictionary);
++	const UString mf = L"BT4";
++	const UInt32 posStateBits = 2;
++	const UInt32 litContextBits = 3; // for normal files
++	// UInt32 litContextBits = 0; // for 32-bit data
++	const UInt32 litPosBits = 0;
++	// UInt32 litPosBits = 2; // for 32-bit data
++	//const UInt32 algorithm = 2;
++	const UInt32 algorithm = 1;
++	const UInt32 numFastBytes = 128;
++	const UInt32 matchFinderCycles = 16 + numFastBytes / 2;
++	//const bool matchFinderCyclesDefined = false;
++	const PROPID propIDs[] = {
++		NCoderPropID::kDictionarySize,
++		NCoderPropID::kPosStateBits,
++		NCoderPropID::kLitContextBits,
++		NCoderPropID::kLitPosBits,
++		NCoderPropID::kAlgorithm,
++		NCoderPropID::kNumFastBytes,
++		NCoderPropID::kMatchFinder,
++		NCoderPropID::kEndMarker,
++		NCoderPropID::kNumThreads,
++		NCoderPropID::kMatchFinderCycles
++	};
++	const int kNumPropsMax = sizeof(propIDs) / sizeof(propIDs[0]);
++	PROPVARIANT properties[kNumPropsMax];
++	for (int p = 0; p < 6; p++)
++		properties[p].vt = VT_UI4;
++	properties[0].ulVal = UInt32(dictionary);
++	properties[1].ulVal = UInt32(posStateBits);
++	properties[2].ulVal = UInt32(litContextBits);
++	properties[3].ulVal = UInt32(litPosBits);
++	properties[4].ulVal = UInt32(algorithm);
++	properties[5].ulVal = UInt32(numFastBytes);
++
++	properties[6].vt = VT_BSTR;
++	properties[6].bstrVal = (BSTR)(const wchar_t *)mf;
++	properties[7].vt = VT_BOOL;
++	properties[7].boolVal = VARIANT_FALSE;	// EOS
++	properties[8].vt = VT_UI4;
++	properties[8].ulVal = 1; // numThreads
++	properties[9].vt = VT_UI4;
++	properties[9].ulVal = UInt32(matchFinderCycles);
++
++	err = -EINVAL;
++	res = encoderSpec.SetCoderProperties(propIDs, properties,
++					     kNumPropsMax - 1);
++	if (res)
++		goto out;
++	res = encoderSpec.WriteCoderProperties(outStream);
++	if (res)
++		goto out;
++
++	UInt32 r;
++	res = outStream->Write(a, sizeof(a), &r);
++	if (res || r != sizeof(a))
++		goto out;
++
++	err = encoder->Code(inStream, outStream, 0, /*broken*/0, 0);
++	if (err)
++		goto out;
++	*total_out = outStreamSpec.GetSize();
++
++ out:
++	return err;
++}
++
++//////////////////////////////////////////////////////////////////////
++
++#define Failure(p) do { \
++	fprintf(stderr, "%s:%d: please report to jro " \
++		"{%02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x}\n", \
++		__func__, __LINE__, \
++		p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]); \
++	abort(); \
++} while(0)
++
++extern "C" int
++sqlzma_cm(struct sqlzma_opts *opts, z_stream *stream, Bytef *next_in, uInt
++	  avail_in, Bytef *next_out, uInt avail_out)
++{
++	int err;
++	Bytef *p = next_out;
++	uInt l = avail_out;
++
++	stream->next_in = next_in;
++	stream->avail_in = avail_in;
++	stream->next_out = p;
++	stream->avail_out = l;
++	err = deflate(stream, Z_FINISH);
++	if (err != Z_STREAM_END && err != Z_OK)
++		goto out_err;
++	if (avail_in < stream->total_out)
++		return err;
++	if (is_lzma(*p))
++		Failure(p);
++
++	if (opts->try_lzma) {
++		unsigned char a[stream->total_out];
++		uLong processed;
++
++		memcpy(a, p, stream->total_out);
++
++		// malloc family in glibc and stdc++ seems to be thread-safe
++		err = LzmaCompress(next_in, avail_in, p, l, opts, &processed);
++		if (!err && processed <= stream->total_out) {
++			if (!is_lzma(*next_out))
++				Failure(next_out);
++			stream->total_out = processed;
++			err = Z_STREAM_END;
++		} else {
++			//puts("by zlib");
++			memcpy(p, a, stream->total_out);
++			err = Z_STREAM_END;
++		}
++	}
++	return err;
++
++ out_err:
++	fprintf(stderr, "%s: ZLIB err %s\n", __func__, zError(err));
++	return err;
++}
+Index: lzma449/C/7zip/Compress/LZMA_Alone/sqlzma.mk
+===================================================================
+RCS file: lzma449/C/7zip/Compress/LZMA_Alone/sqlzma.mk
+diff -N lzma449/C/7zip/Compress/LZMA_Alone/sqlzma.mk
+--- /dev/null	1 Jan 1970 00:00:00 -0000
++++ lzma449/C/7zip/Compress/LZMA_Alone/sqlzma.mk	5 Nov 2007 05:43:36 -0000	1.1
+@@ -0,0 +1,57 @@
++
++# Copyright (C) 2006-2007 Junjiro Okajima
++# Copyright (C) 2006-2007 Tomas Matejicek, slax.org
++#
++# LICENSE follows the described one in lzma.txt.
++
++# $Id: sqlzma.mk,v 1.1 2007/11/05 05:43:36 jro Exp $
++
++ifndef Sqlzma
++$(error Sqlzma is not defined)
++endif
++
++include makefile.gcc
++
++ifdef UseDebugFlags
++DebugFlags = -Wall -O0 -g -UNDEBUG
++endif
++# -pthread
++CXXFLAGS = ${CFLAGS} -D_REENTRANT -include pthread.h -DNDEBUG ${DebugFlags}
++Tgt = liblzma_r.a
++
++all: ${Tgt}
++
++RObjs = LZMAEncoder_r.o Alloc_r.o StreamUtils_r.o MatchFinder_r.o \
++	RangeCoderBit_r.o OutBuffer_r.o 7zCrc_r.o
++
++%_r.cc: ../LZMA/%.cpp
++	ln $< $@
++%_r.c: ../../../../C/%.c
++	ln $< $@
++%_r.c: ../../../../C/Compress/Lz/%.c
++	ln $< $@
++%_r.cc: ../../Common/%.cpp
++	ln $< $@
++%_r.cc: ../RangeCoder/%.cpp
++	ln $< $@
++LZMAEncoder_r.o: CXXFLAGS += -I../LZMA
++Alloc_r.o: CFLAGS += -I../../../../C
++StreamUtils_r.o: CXXFLAGS += -I../../Common
++MatchFinder_r.o: CFLAGS += -I../../../../C/Compress/Lz
++RangeCoderBit_r.o: CXXFLAGS += -I../RangeCoder
++OutBuffer_r.o: CXXFLAGS += -I../../Common
++7zCrc_r.o: CFLAGS += -I../../../../C
++
++comp.o: CXXFLAGS += -I${Sqlzma}
++comp.o: comp.cc ${Sqlzma}/sqlzma.h
++
++liblzma_r.a: ${RObjs} comp.o
++	${AR} cr $@ $^
++
++clean: clean_sqlzma
++clean_sqlzma:
++	$(RM) comp.o *_r.o ${Tgt} *~
++
++# Local variables: ;
++# compile-command: (concat "make Sqlzma=../../../../.. -f " (file-name-nondirectory (buffer-file-name)));
++# End: ;
--- lzma-4.43.orig/debian/patches/05_fix_path.diff
+++ lzma-4.43/debian/patches/05_fix_path.diff
@@ -0,0 +1,11 @@
+--- lzma443/C/7zip/Compress/LZMA_C/kmod/module.c.old	2007-10-06 03:34:00.000000000 +0100
++++ lzma443/C/7zip/Compress/LZMA_C/kmod/module.c	2007-10-06 03:33:18.000000000 +0100
+@@ -11,7 +11,7 @@
+ #include <linux/init.h>
+ #include <linux/module.h>
+ 
+-#include "../LzmaDecode.c"
++#include "LzmaDecode.c"
+ 
+ EXPORT_SYMBOL(LzmaDecodeProperties);
+ EXPORT_SYMBOL(LzmaDecode);
--- lzma-4.43.orig/debian/patches/03_cflags_makefile.diff
+++ lzma-4.43/debian/patches/03_cflags_makefile.diff
@@ -0,0 +1,11 @@
+--- lzma-4.43.orig/C/7zip/Compress/LZMA_C/kmod/Makefile	2007-10-08 12:55:03.000000000 +0100
++++ lzma-4.43/C/7zip/Compress/LZMA_C/kmod/Makefile	2007-10-08 12:55:12.000000000 +0100
+@@ -6,6 +6,8 @@
+ 
+ # $Id: Makefile,v 1.3 2006/11/27 03:54:58 jro Exp $
+ 
++EXTRA_CFLAGS += -I/usr/include
++
+ obj-m += unlzma.o sqlzma.o
+ unlzma-y := module.o
+ sqlzma-y := uncomp.o
--- lzma-4.43.orig/debian/patches/series
+++ lzma-4.43/debian/patches/series
@@ -0,0 +1,8 @@
+06_sqlzma.diff
+05_sqlzma_backport.diff
+05_fix_path.diff
+04_sqlzma_h.diff
+03_cflags_makefile.diff
+03_lzma_manpage.diff
+01_large_files.diff
+02_lzmp.diff
--- lzma-4.43.orig/debian/patches/05_sqlzma_backport.diff
+++ lzma-4.43/debian/patches/05_sqlzma_backport.diff
@@ -0,0 +1,41 @@
+Index: lzma-4.43/C/7zip/Compress/LZMA_Alone/sqlzma.mk
+===================================================================
+--- lzma-4.43.orig/C/7zip/Compress/LZMA_Alone/sqlzma.mk	2007-12-09 00:53:08.000000000 +0000
++++ lzma-4.43/C/7zip/Compress/LZMA_Alone/sqlzma.mk	2007-12-09 00:54:45.000000000 +0000
+@@ -21,26 +21,31 @@
+ 
+ all: ${Tgt}
+ 
+-RObjs = LZMAEncoder_r.o Alloc_r.o StreamUtils_r.o MatchFinder_r.o \
++RObjs = LZMAEncoder_r.o Alloc_r.o StreamUtils_r.o LZInWindow_r.o CRC_r.o \
+ 	RangeCoderBit_r.o OutBuffer_r.o 7zCrc_r.o
+ 
+ %_r.cc: ../LZMA/%.cpp
+ 	ln $< $@
+ %_r.c: ../../../../C/%.c
+ 	ln $< $@
+-%_r.c: ../../../../C/Compress/Lz/%.c
++%_r.c: ../../Archive/7z_C/%.c
+ 	ln $< $@
+ %_r.cc: ../../Common/%.cpp
+ 	ln $< $@
++%_r.cc: ../../../Common/%.cpp
++	ln $< $@
+ %_r.cc: ../RangeCoder/%.cpp
+ 	ln $< $@
++%_r.cc: ../LZ/%.cpp
++	ln $< $@
+ LZMAEncoder_r.o: CXXFLAGS += -I../LZMA
+-Alloc_r.o: CFLAGS += -I../../../../C
++Alloc_r.o: CFLAGS += -I../../../Common
+ StreamUtils_r.o: CXXFLAGS += -I../../Common
+-MatchFinder_r.o: CFLAGS += -I../../../../C/Compress/Lz
+ RangeCoderBit_r.o: CXXFLAGS += -I../RangeCoder
+ OutBuffer_r.o: CXXFLAGS += -I../../Common
+-7zCrc_r.o: CFLAGS += -I../../../../C
++7zCrc_r.o: CFLAGS += -I../../Archive/7z_C
++LZInWindow_r.o: CFLAGS += -I../LZ
++CRC_r.o: CFLAGS += -I../../../Common
+ 
+ comp.o: CXXFLAGS += -I${Sqlzma}
+ comp.o: comp.cc ${Sqlzma}/sqlzma.h
--- lzma-4.43.orig/debian/copyright
+++ lzma-4.43/debian/copyright
@@ -0,0 +1,324 @@
+This package was debianized by Mohammed AdnÃ¨ne Trojette
+<adn+deb@diwi.org> on Fri May 5 18:01:06 CEST 2006.
+
+The current Debian maintainer is Mohammed AdnÃ¨ne Trojette
+<adn+deb@diwi.org>.
+
+It was downloaded from <http://www.7-zip.org/sdk.html>.
+
+LZMA SDK is Copyright (C) 1999-2006 Igor Pavlov.
+
+LZMA SDK is available under any of the following licenses:
+
+1. GNU Lesser General Public License (GNU LGPL)
+-----------------------------------------------
+
+ This program is free software;  you can redistribute it and/or modify
+ it  under the  terms  of the  GNU  Lesser General  Public License  as
+ published by the Free Software  Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ This program is  distributed in the hope that it  will be useful, but
+ WITHOUT  ANY   WARRANTY;  without   even  the  implied   warranty  of
+ MERCHANTABILITY  or FITNESS FOR  A PARTICULAR  PURPOSE.  See  the GNU
+ Lesser General Public License for more details.
+
+ You  should have received  a copy  of the  GNU Lesser  General Public
+ License along with  this program; if not, write  to the Free Software
+ Foundation, Inc., 51 Franklin  St, Fifth Floor, Boston, MA 02110-1301
+ USA
+
+On Debian systems, the complete text of the GNU Lesser General Public
+License, can be found in /usr/share/common-licenses/LGPL-2.1.
+
+2. Common Public License (CPL)
+------------------------------
+
+THE ACCOMPANYING  PROGRAM IS PROVIDED  UNDER THE TERMS OF  THIS COMMON
+PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF
+THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+      a) in the case of  the initial Contributor, the initial code and
+      documentation distributed under this Agreement, and
+      b) in the case of each subsequent Contributor:
+
+      i) changes to the Program, and
+
+      ii) additions to the Program;
+
+      where  such changes  and/or additions  to the  Program originate
+      from  and  are distributed  by  that  particular Contributor.  A
+      Contribution 'originates' from a  Contributor if it was added to
+      the Program by such Contributor  itself or anyone acting on such
+      Contributor's behalf. Contributions  do not include additions to
+      the  Program  which:  (i)   are  separate  modules  of  software
+      distributed  in conjunction  with  the Program  under their  own
+      license  agreement, and  (ii) are  not derivative  works  of the
+      Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed  Patents " mean  patent claims  licensable by  a Contributor
+which are necessarily infringed by the use or sale of its Contribution
+alone or when combined with the Program.
+
+"Program" means the Contributions  distributed in accordance with this
+Agreement.
+
+"Recipient"  means   anyone  who  receives  the   Program  under  this
+Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+      a)  Subject to  the terms  of this  Agreement,  each Contributor
+      hereby grants Recipient a non-exclusive, worldwide, royalty-free
+      copyright  license to  reproduce, prepare  derivative  works of,
+      publicly  display, publicly  perform, distribute  and sublicense
+      the  Contribution   of  such  Contributor,  if   any,  and  such
+      derivative works, in source code and object code form.
+
+      b)  Subject to  the terms  of this  Agreement,  each Contributor
+      hereby grants Recipient a non-exclusive, worldwide, royalty-free
+      patent license under Licensed  Patents to make, use, sell, offer
+      to sell, import and  otherwise transfer the Contribution of such
+      Contributor, if any,  in source code and object  code form. This
+      patent   license  shall   apply  to   the  combination   of  the
+      Contribution and the Program if, at the time the Contribution is
+      added  by the  Contributor,  such addition  of the  Contribution
+      causes  such   combination  to   be  covered  by   the  Licensed
+      Patents.  The  patent  license  shall  not apply  to  any  other
+      combinations which include the  Contribution. No hardware per se
+      is licensed hereunder.
+
+      c) Recipient  understands that although  each Contributor grants
+      the  licenses   to  its  Contributions  set   forth  herein,  no
+      assurances are provided by any Contributor that the Program does
+      not infringe the patent or other intellectual property rights of
+      any other  entity. Each  Contributor disclaims any  liability to
+      Recipient  for  claims brought  by  any  other  entity based  on
+      infringement of intellectual property  rights or otherwise. As a
+      condition  to   exercising  the  rights   and  licenses  granted
+      hereunder, each Recipient  hereby assumes sole responsibility to
+      secure  any  other   intellectual  property  rights  needed,  if
+      any. For example, if a third party patent license is required to
+      allow  Recipient to  distribute the  Program, it  is Recipient's
+      responsibility to  acquire that license  before distributing the
+      Program.
+
+      d)  Each Contributor  represents that  to its  knowledge  it has
+      sufficient  copyright rights  in  its Contribution,  if any,  to
+      grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form
+under its own license agreement, provided that:
+
+      a) it complies with the  terms and conditions of this Agreement;
+      and
+
+      b) its license agreement:
+
+      i)  effectively  disclaims on  behalf  of  all Contributors  all
+      warranties  and  conditions,   express  and  implied,  including
+      warranties  or  conditions of  title  and non-infringement,  and
+      implied warranties or  conditions of merchantability and fitness
+      for a particular purpose;
+
+      ii)  effectively  excludes on  behalf  of  all Contributors  all
+      liability  for  damages,  including direct,  indirect,  special,
+      incidental and consequential damages, such as lost profits;
+
+      iii) states that any provisions which differ from this Agreement
+      are  offered by  that Contributor  alone  and not  by any  other
+      party; and
+
+      iv) states  that source code  for the Program is  available from
+      such Contributor,  and informs licensees  how to obtain it  in a
+      reasonable manner  on or through  a medium customarily  used for
+      software exchange.
+
+When the Program is made available in source code form:
+
+      a) it must be made available under this Agreement; and 
+
+      b) a copy  of this Agreement must be included  with each copy of
+      the Program.
+
+Contributors may  not remove or alter any  copyright notices contained
+within the Program.
+
+Each  Contributor  must  identify  itself  as the  originator  of  its
+Contribution, if  any, in a  manner that reasonably  allows subsequent
+Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial    distributors   of    software    may   accept    certain
+responsibilities with respect to  end users, business partners and the
+like. While this license is  intended to facilitate the commercial use
+of  the  Program,  the  Contributor  who includes  the  Program  in  a
+commercial product  offering should do so  in a manner  which does not
+create  potential liability  for other  Contributors. Therefore,  if a
+Contributor  includes the  Program in  a commercial  product offering,
+such  Contributor ("Commercial Contributor")  hereby agrees  to defend
+and  indemnify  every  other Contributor  ("Indemnified  Contributor")
+against any losses, damages  and costs (collectively "Losses") arising
+from claims, lawsuits and other legal actions brought by a third party
+against the Indemnified  Contributor to the extent caused  by the acts
+or  omissions of such  Commercial Contributor  in connection  with its
+distribution  of the  Program in  a commercial  product  offering. The
+obligations  in this  section do  not apply  to any  claims  or Losses
+relating   to   any    actual   or   alleged   intellectual   property
+infringement. In order to qualify, an Indemnified Contributor must: a)
+promptly notify  the Commercial Contributor in writing  of such claim,
+and b) allow the Commercial Contributor to control, and cooperate with
+the Commercial Contributor in,  the defense and any related settlement
+negotiations. The Indemnified Contributor  may participate in any such
+claim at its own expense.
+
+For example, a  Contributor might include the Program  in a commercial
+product  offering, Product X.  That Contributor  is then  a Commercial
+Contributor.  If that  Commercial Contributor  then  makes performance
+claims, or  offers warranties related to Product  X, those performance
+claims and warranties are such Commercial Contributor's responsibility
+alone. Under  this section, the  Commercial Contributor would  have to
+defend  claims  against  the   other  Contributors  related  to  those
+performance claims and  warranties, and if a court  requires any other
+Contributor to pay any damages as a result, the Commercial Contributor
+must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT  AS EXPRESSLY  SET  FORTH  IN THIS  AGREEMENT,  THE PROGRAM  IS
+PROVIDED ON AN "AS IS"  BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND,  EITHER EXPRESS  OR IMPLIED  INCLUDING, WITHOUT  LIMITATION, ANY
+WARRANTIES OR  CONDITIONS OF TITLE,  NON-INFRINGEMENT, MERCHANTABILITY
+OR  FITNESS  FOR  A  PARTICULAR  PURPOSE.  Each  Recipient  is  solely
+responsible   for  determining  the   appropriateness  of   using  and
+distributing  the Program and  assumes all  risks associated  with its
+exercise of rights under this  Agreement, including but not limited to
+the  risks and  costs of  program errors,  compliance  with applicable
+laws,  damage  to  or  loss   of  data,  programs  or  equipment,  and
+unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR
+ANY CONTRIBUTORS  SHALL HAVE ANY  LIABILITY FOR ANY  DIRECT, INDIRECT,
+INCIDENTAL,  SPECIAL, EXEMPLARY,  OR CONSEQUENTIAL  DAMAGES (INCLUDING
+WITHOUT LIMITATION LOST PROFITS), HOWEVER  CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER  IN CONTRACT, STRICT LIABILITY,  OR TORT (INCLUDING
+NEGLIGENCE  OR  OTHERWISE)  ARISING IN  ANY  WAY  OUT  OF THE  USE  OR
+DISTRIBUTION  OF THE  PROGRAM OR  THE EXERCISE  OF ANY  RIGHTS GRANTED
+HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision  of this Agreement is invalid  or unenforceable under
+applicable law, it shall not  affect the validity or enforceability of
+the  remainder of  the terms  of this  Agreement, and  without further
+action by the parties hereto,  such provision shall be reformed to the
+minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient  institutes patent litigation against  a Contributor with
+respect to a patent applicable to software (including a cross-claim or
+counterclaim in a  lawsuit), then any patent licenses  granted by that
+Contributor to such Recipient  under this Agreement shall terminate as
+of  the date  such  litigation  is filed.  In  addition, if  Recipient
+institutes   patent  litigation  against   any  entity   (including  a
+cross-claim or  counterclaim in a  lawsuit) alleging that  the Program
+itself (excluding  combinations of the Program with  other software or
+hardware) infringes such  Recipient's patent(s), then such Recipient's
+rights granted under Section 2(b)  shall terminate as of the date such
+litigation is filed.
+
+All  Recipient's rights  under this  Agreement shall  terminate  if it
+fails to comply  with any of the material terms  or conditions of this
+Agreement and  does not  cure such failure  in a reasonable  period of
+time after  becoming aware of  such noncompliance. If  all Recipient's
+rights under  this Agreement terminate, Recipient agrees  to cease use
+and   distribution   of   the    Program   as   soon   as   reasonably
+practicable. However, Recipient's obligations under this Agreement and
+any  licenses  granted by  Recipient  relating  to  the Program  shall
+continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement,
+but in order  to avoid inconsistency the Agreement  is copyrighted and
+may only  be modified in  the following manner. The  Agreement Steward
+reserves the  right to publish  new versions (including  revisions) of
+this  Agreement from time  to time.  No one  other than  the Agreement
+Steward has  the right  to modify this  Agreement. IBM is  the initial
+Agreement Steward. IBM  may assign the responsibility to  serve as the
+Agreement Steward to  a suitable separate entity. Each  new version of
+the  Agreement will  be  given a  distinguishing  version number.  The
+Program (including Contributions) may always be distributed subject to
+the version of the Agreement under which it was received. In addition,
+after a  new version  of the Agreement  is published,  Contributor may
+elect to  distribute the  Program (including its  Contributions) under
+the new version. Except as  expressly stated in Sections 2(a) and 2(b)
+above, Recipient  receives no rights  or licenses to  the intellectual
+property of  any Contributor under this  Agreement, whether expressly,
+by implication, estoppel  or otherwise. All rights in  the Program not
+expressly granted under this Agreement are reserved.
+
+This Agreement  is governed by the laws  of the State of  New York and
+the intellectual  property laws  of the United  States of  America. No
+party to this Agreement will bring a legal action under this Agreement
+more than one year after the  cause of action arose. Each party waives
+its rights to a jury trial in any resulting litigation.
+
+3. Simplified license for unmodified code
+-----------------------------------------
+
+Igor  Pavlov, as the  author of  this code,  expressly permits  you to
+statically  or dynamically link  your code  (or bind  by name)  to the
+files from LZMA  SDK without subjecting your linked  code to the terms
+of the CPL  or GNU LGPL. Any modifications or  additions to files from
+LZMA SDK, however, are subject to the GNU LGPL or CPL terms.
+
+4. Proprietary license
+----------------------
+
+LZMA SDK also can be available under a proprietary license which can
+include:
+
+   1. Right to modify code from LZMA SDK without subjecting modified
+code to the terms of the CPL or GNU LGPL
+
+   2. Technical support for LZMA SDK via email
+
+To request such proprietary license or any additional
+consultations, send email message from page for support:
+<http://www.7-zip.org/support.html>
+
+----------------------------------------------------------------------------
+
+debian/patches/* and lzma.1 are released under the terms of the GNU
+General Public License.
+
+  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
+  the Free Software Foundation; either version 2 of the License.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License with
+  the Debian GNU/Linux distribution in file /usr/share/common-licenses/GPL;
+  if not, write to the Free Software Foundation, Inc., 51 Franklin St,
+  Fifth Floor, Boston, MA 02110-1301, USA.
+
+ On Debian systems, the complete text of the GNU General Public
+ License, version 2, can be found in /usr/share/common-licenses/GPL-2.
+
+----------------------------------------------------------------------------
+
+The current Debian packaging is (C) 2006-2007, Mohammed AdnÃ¨ne Trojette
+<adn+deb@diwi.org> and is licensed under the LGPL, see above.
--- lzma-4.43.orig/debian/lzma.install
+++ lzma-4.43/debian/lzma.install
@@ -0,0 +1,2 @@
+C/7zip/Compress/LZMA_Alone/lzma usr/bin
+C/7zip/Compress/LZMA_Alone/lzma_alone usr/bin
--- lzma-4.43.orig/debian/lzma-dev.dirs
+++ lzma-4.43/debian/lzma-dev.dirs
@@ -0,0 +1,2 @@
+usr/include
+usr/lib
--- lzma-4.43.orig/debian/lzma.links
+++ lzma-4.43/debian/lzma.links
@@ -0,0 +1,4 @@
+usr/bin/lzma usr/bin/unlzma
+usr/bin/lzma usr/bin/lzcat
+usr/share/man/man1/lzma.1.gz usr/share/man/man1/unlzma.1.gz
+usr/share/man/man1/lzma.1.gz usr/share/man/man1/lzcat.1.gz
