This is the mail archive of the cygwin-apps mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

setup.exe: Support xz and lzma decompression via liblzma


Ok, here's the long-awaited xz support for setup.exe. It links against
the mingw-liblzma-devel package, which provides the static liblzma.a for
native apps.

Sadly, when compiled for native win32, liblzma is firmly in the "msvc"
camp: no auto-import. Therefore, when mingw/msvc the header files by
default decorate all symbols with declspec(dllimport) -- to link
statically you have to #define LZMA_API_STATIC when compiling.  Also,
when you use libtool to link, -Wl,-static doesn't do what you think when
there is a .la file present.  libtool turns -llzma+liblzma.la into
/full/path/to/liblzma.dll.a -- so -Wl,-static has no effect on that
particular lib.  Instead, you have to tell *libtool* that you want to
link statically.  So, I added -DLZMA_API_STATIC to AM_CPPFLAGS and
-static-libtool-libs to setup_LDFLAGS for just these reasons.

As posted, compress_xz.cc has a small number of msg() calls, which send
information to OutputDebugString. Some of these might need to be changed
to note() [e.g. MessageBox] or maybe removed entirely.  Or left as is.
Opinions?


I've put a small (230k) test tree here:
http://cygwin.cwilson.fastmail.fm/ITP/test-tree.tar.bz2

test/release/
test/release/test-data/
test/release/test-data/setup.hint
test/release/test-data/test-data-0.1-2-src.tar.xz
test/release/test-data/test-data-0.1-2.tar.xz
test/release/test-data2/
test/release/test-data2/setup.hint
test/release/test-data2/test-data2-1.0-1-src.tar.lzma
test/release/test-data2/test-data2-1.0-1.tar.lzma
test/setup.ini

2010-03-10  Charles Wilson  <...>

	Support xz and lzma decompression via liblzma
	* Makefile.am: Add -DLZMA_API_STATIC to AM_CPPFLAGS,
	-lzma to setup_LDADD, and -static-libtool-libs to
	setup_LDFLAGS. Update setup_SOURCES.
 	* compress.cc: Update includes.
	(compress::decompress): Use compress_xz rather than
	compress_lzma; compress_xz supports both xz and lzma
	decompression.
	* compress_lzma.h: Removed.
	* compress_lzma.cc: Removed.
 	* lzma-sdk/LzmaDec.c: Removed.
 	* lzma-sdk/LzmaDec.h: Removed.
	* lzma-sdk/Types.h: Removed.
	* compress_xz.h: New.
	* compress_xz.cc: New.

Enjoy...

--
Chuck
Index: Makefile.am
===================================================================
RCS file: /cvs/cygwin-apps/setup/Makefile.am,v
retrieving revision 2.77
diff -u -p -r2.77 Makefile.am
--- Makefile.am	28 Jun 2009 03:50:42 -0000	2.77
+++ Makefile.am	11 Mar 2010 04:02:26 -0000
@@ -36,7 +36,7 @@ AM_CFLAGS = $(AM_CXXFLAGS) -Wmissing-dec
 AM_YFLAGS = -d
 AM_LFLAGS = -8
 WINDRES = @WINDRES@
-AM_CPPFLAGS = -I$(srcdir)/libgetopt++/include -I$(top_builddir)/libgpg-error/src -I$(top_builddir)/libgcrypt/src -I$(srcdir)/libgcrypt/src
+AM_CPPFLAGS = -DLZMA_API_STATIC -I$(srcdir)/libgetopt++/include -I$(top_builddir)/libgpg-error/src -I$(top_builddir)/libgcrypt/src -I$(srcdir)/libgcrypt/src
 
 noinst_PROGRAMS = setup @INILINT@
 
@@ -119,8 +119,8 @@ libinilex_a_CXXFLAGS = $(BASECXXFLAGS)
 setup_LDADD = \
 	libinilex.a \
 	-Linst/lib -lgetopt++ -lgcrypt -lgpg-error \
-	-lshlwapi -lcomctl32 -lole32 -lwsock32 -lnetapi32 -luuid -lbz2 -lz 
-setup_LDFLAGS = -mwindows -Wl,-static
+	-lshlwapi -lcomctl32 -lole32 -lwsock32 -lnetapi32 -luuid -llzma -lbz2 -lz 
+setup_LDFLAGS = -mwindows -Wl,-static -static-libtool-libs
 setup_SOURCES = \
 	AntiVirus.cc \
 	AntiVirus.h \
@@ -138,8 +138,8 @@ setup_SOURCES = \
 	compress_bz.h \
 	compress_gz.cc \
 	compress_gz.h \
-	compress_lzma.cc \
-	compress_lzma.h \
+	compress_xz.cc \
+	compress_xz.h \
 	ConnectionSetting.cc \
 	ConnectionSetting.h \
 	ControlAdjuster.cc \
@@ -285,10 +285,7 @@ setup_SOURCES = \
 	csu_util/version_compare.cc \
 	csu_util/version_compare.h \
 	libmd5-rfc/md5.c \
-	libmd5-rfc/md5.h \
-	lzma-sdk/LzmaDec.c \
-	lzma-sdk/LzmaDec.h \
-	lzma-sdk/Types.h
+	libmd5-rfc/md5.h
 
 VER := $(shell sed -ne 's/^\$$Revi[s]ion: *\([^ ]*\) *$$.*/\1/p' \
                $(srcdir)/ChangeLog)
Index: compress.cc
===================================================================
RCS file: /cvs/cygwin-apps/setup/compress.cc,v
retrieving revision 2.6
diff -u -p -r2.6 compress.cc
--- compress.cc	23 Jul 2008 01:47:56 -0000	2.6
+++ compress.cc	11 Mar 2010 04:02:26 -0000
@@ -16,7 +16,7 @@
 #include "compress.h"
 #include "compress_gz.h"
 #include "compress_bz.h"
-#include "compress_lzma.h"
+#include "compress_xz.h"
 
 /* In case you are wondering why the file magic is not in one place:
  * It could be. But there is little (any?) benefit.
@@ -27,7 +27,7 @@
  * the class could test itself. 
  */
 
-#define longest_magic LZMA_PROPS_SIZE + 8
+#define longest_magic 14 /* lzma_alone */
 
 io_stream *
 compress::decompress (io_stream * original)
@@ -58,9 +58,9 @@ compress::decompress (io_stream * origin
 	  delete rv;
 	  return NULL;
 	}
-      else if (compress_lzma::is_lzma (magic, LZMA_PROPS_SIZE + 8))
+      else if (compress_xz::is_xz_or_lzma (magic, 14))
 	{
-	  compress_lzma *rv = new compress_lzma (original);
+	  compress_xz *rv = new compress_xz (original);
 	  if (!rv->error ())
 	    return rv;
 	  /* else */

Attachment: xz-support-new-files-p1.patch.bz2
Description: Binary data

Attachment: xz-support-removed-files-p1.patch.bz2
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]