Automatic import for version 1.0.6

This commit is contained in:
Rosa 2012-02-01 15:17:18 +04:00
commit e323ebdc4f
6 changed files with 880 additions and 0 deletions

2
.abf.yml Normal file
View file

@ -0,0 +1,2 @@
sources:
"bzip2-1.0.6.tar.gz": 3f89f861209ce81a6bab1fd1998c0ef311712002

68
bzgrep Normal file
View file

@ -0,0 +1,68 @@
#!/bin/sh
# zgrep -- a wrapper around a grep program that decompresses files as needed
# Adapted from a version sent by Charles Levert <charles@comm.polymtl.ca>
# Adapted to bzip2 by Bernhard Rosenkraenzer <bero@redhat.com>
PATH="/usr/bin:$PATH"; export PATH
prog=`echo $0 | sed 's|.*/||'`
case "$prog" in
*egrep) grep=${EGREP-egrep} ;;
*fgrep) grep=${FGREP-fgrep} ;;
*) grep=${GREP-grep} ;;
esac
pat=""
while test $# -ne 0; do
case "$1" in
-e | -f) opt="$opt $1"; shift; pat="$1"
if test "$grep" = grep; then # grep is buggy with -e on SVR4
grep=egrep
fi;;
-A | -B) opt="$opt $1 $2"; shift;;
-*) opt="$opt $1";;
*) if test -z "$pat"; then
pat="$1"
else
break;
fi;;
esac
shift
done
if test -z "$pat"; then
echo "grep through bzip2 files"
echo "usage: $prog [grep_options] pattern [files]"
exit 1
fi
list=0
silent=0
op=`echo "$opt" | sed -e 's/ //g' -e 's/-//g'`
case "$op" in
*l*) list=1
esac
case "$op" in
*h*) silent=1
esac
if test $# -eq 0; then
bzip2 -cdfq | $grep $opt "$pat"
exit $?
fi
res=0
for i do
if test $list -eq 1; then
bzip2 -cdfq "$i" | $grep $opt "$pat" > /dev/null && echo $i
r=$?
elif test $# -eq 1 -o $silent -eq 1; then
bzip2 -cdfq "$i" | $grep $opt "$pat"
r=$?
else
bzip2 -cdfq "$i" | $grep $opt "$pat" | sed "s|^|${i}:|"
r=$?
fi
test "$r" -ne 0 && res="$r"
done
exit $res

217
bzip2-1.0.6-makefile.diff Normal file
View file

@ -0,0 +1,217 @@
diff -Naur bzip2-1.0.6/Makefile bzip2-1.0.6.oden/Makefile
--- bzip2-1.0.6/Makefile 2010-09-11 00:46:02.000000000 +0200
+++ bzip2-1.0.6.oden/Makefile 2010-09-20 12:22:58.718326583 +0200
@@ -12,45 +12,76 @@
# in the file LICENSE.
# ------------------------------------------------------------------
+include config.in
+
+# define libdir name
+lib ?= lib
+
+# define standard opt flags
+CFLAGS ?= -O2 -fomit-frame-pointer
+
SHELL=/bin/sh
# To assist in cross-compiling
CC=gcc
AR=ar
RANLIB=ranlib
-LDFLAGS=
+LDFLAGS+=
-BIGFILES=-D_FILE_OFFSET_BITS=64
-CFLAGS=-Wall -Winline -O2 -g $(BIGFILES)
+# Large file support
+CFLAGS += -D_FILE_OFFSET_BITS=64
-# Where you want it installed when you do 'make install'
-PREFIX=/usr/local
+# Warnings
+CFLAGS += -Wall -Winline
-
-OBJS= blocksort.o \
- huffman.o \
- crctable.o \
- randtable.o \
- compress.o \
- decompress.o \
- bzlib.o
-
-all: libbz2.a bzip2 bzip2recover test
-
-bzip2: libbz2.a bzip2.o
- $(CC) $(CFLAGS) $(LDFLAGS) -o bzip2 bzip2.o -L. -lbz2
-
-bzip2recover: bzip2recover.o
- $(CC) $(CFLAGS) $(LDFLAGS) -o bzip2recover bzip2recover.o
-
-libbz2.a: $(OBJS)
- rm -f libbz2.a
- $(AR) cq libbz2.a $(OBJS)
- @if ( test -f $(RANLIB) -o -f /usr/bin/ranlib -o \
- -f /bin/ranlib -o -f /usr/ccs/bin/ranlib ) ; then \
- echo $(RANLIB) libbz2.a ; \
- $(RANLIB) libbz2.a ; \
- fi
+OBJS= blocksort.lo \
+ huffman.lo \
+ crctable.lo \
+ randtable.lo \
+ compress.lo \
+ decompress.lo \
+ bzlib.lo
+
+LIB=libbz2.la
+
+prefix=/usr
+bindir=$(prefix)/bin
+libdir=$(prefix)/$(lib)
+mandir=$(prefix)/share/man
+includedir=$(prefix)/include
+DESTDIR=
+
+all: $(LIB) bzip2 bzip2recover test
+
+install: all test
+ mkdir -p $(DESTDIR)$(bindir)
+ libtool --mode=install install -s -m 0755 bzip2 $(DESTDIR)$(bindir)/
+ libtool --mode=install install -s -m 0755 bzip2recover $(DESTDIR)$(bindir)/
+ libtool --mode=install install -m 0755 bzdiff $(DESTDIR)$(bindir)/
+ libtool --mode=install install -m 0755 bzmore $(DESTDIR)$(bindir)/
+ ln -sf bzip2 $(DESTDIR)$(bindir)/bunzip2
+ ln -sf bzip2 $(DESTDIR)$(bindir)/bzcat
+ mkdir -p $(DESTDIR)$(mandir)/man1
+ install -c -m 0644 bzip2.1 $(DESTDIR)$(mandir)/man1/
+ install -c -m 0644 bzdiff.1 $(DESTDIR)$(mandir)/man1/
+ install -c -m 0644 bzmore.1 $(DESTDIR)$(mandir)/man1/
+ ln -sf bzip2.1 $(DESTDIR)$(mandir)/man1/bunzip2.1
+ ln -sf bzip2.1 $(DESTDIR)$(mandir)/man1/bzcat.1
+ ln -sf bzip2.1 $(DESTDIR)$(mandir)/man1/bzip2recover.1
+ mkdir -p $(DESTDIR)$(libdir)
+ libtool --mode=install install $(LIB) $(DESTDIR)$(libdir)
+ mkdir -p $(DESTDIR)$(includedir)
+ install -c -m 0644 bzlib.h $(DESTDIR)$(includedir)
+
+bzip2: bzip2.c $(LIB)
+ libtool --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ bzip2.c $(LIB)
+
+bzip2recover: bzip2recover.c
+ libtool --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ bzip2recover.c
+
+$(LIB): $(OBJS)
+ libtool --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) -rpath $(libdir) \
+ -version-info 1:0:0
check: test
test: bzip2
@@ -69,70 +100,18 @@
cmp sample3.tst sample3.ref
@cat words3
-install: bzip2 bzip2recover
- if ( test ! -d $(PREFIX)/bin ) ; then mkdir -p $(PREFIX)/bin ; fi
- if ( test ! -d $(PREFIX)/lib ) ; then mkdir -p $(PREFIX)/lib ; fi
- if ( test ! -d $(PREFIX)/man ) ; then mkdir -p $(PREFIX)/man ; fi
- if ( test ! -d $(PREFIX)/man/man1 ) ; then mkdir -p $(PREFIX)/man/man1 ; fi
- if ( test ! -d $(PREFIX)/include ) ; then mkdir -p $(PREFIX)/include ; fi
- cp -f bzip2 $(PREFIX)/bin/bzip2
- cp -f bzip2 $(PREFIX)/bin/bunzip2
- cp -f bzip2 $(PREFIX)/bin/bzcat
- cp -f bzip2recover $(PREFIX)/bin/bzip2recover
- chmod a+x $(PREFIX)/bin/bzip2
- chmod a+x $(PREFIX)/bin/bunzip2
- chmod a+x $(PREFIX)/bin/bzcat
- chmod a+x $(PREFIX)/bin/bzip2recover
- cp -f bzip2.1 $(PREFIX)/man/man1
- chmod a+r $(PREFIX)/man/man1/bzip2.1
- cp -f bzlib.h $(PREFIX)/include
- chmod a+r $(PREFIX)/include/bzlib.h
- cp -f libbz2.a $(PREFIX)/lib
- chmod a+r $(PREFIX)/lib/libbz2.a
- cp -f bzgrep $(PREFIX)/bin/bzgrep
- ln -s -f $(PREFIX)/bin/bzgrep $(PREFIX)/bin/bzegrep
- ln -s -f $(PREFIX)/bin/bzgrep $(PREFIX)/bin/bzfgrep
- chmod a+x $(PREFIX)/bin/bzgrep
- cp -f bzmore $(PREFIX)/bin/bzmore
- ln -s -f $(PREFIX)/bin/bzmore $(PREFIX)/bin/bzless
- chmod a+x $(PREFIX)/bin/bzmore
- cp -f bzdiff $(PREFIX)/bin/bzdiff
- ln -s -f $(PREFIX)/bin/bzdiff $(PREFIX)/bin/bzcmp
- chmod a+x $(PREFIX)/bin/bzdiff
- cp -f bzgrep.1 bzmore.1 bzdiff.1 $(PREFIX)/man/man1
- chmod a+r $(PREFIX)/man/man1/bzgrep.1
- chmod a+r $(PREFIX)/man/man1/bzmore.1
- chmod a+r $(PREFIX)/man/man1/bzdiff.1
- echo ".so man1/bzgrep.1" > $(PREFIX)/man/man1/bzegrep.1
- echo ".so man1/bzgrep.1" > $(PREFIX)/man/man1/bzfgrep.1
- echo ".so man1/bzmore.1" > $(PREFIX)/man/man1/bzless.1
- echo ".so man1/bzdiff.1" > $(PREFIX)/man/man1/bzcmp.1
-
clean:
- rm -f *.o libbz2.a bzip2 bzip2recover \
+ rm -f *.o *.lo *.a $(LIB) bzip2 bzip2recover \
sample1.rb2 sample2.rb2 sample3.rb2 \
sample1.tst sample2.tst sample3.tst
-blocksort.o: blocksort.c
- @cat words0
- $(CC) $(CFLAGS) -c blocksort.c
-huffman.o: huffman.c
- $(CC) $(CFLAGS) -c huffman.c
-crctable.o: crctable.c
- $(CC) $(CFLAGS) -c crctable.c
-randtable.o: randtable.c
- $(CC) $(CFLAGS) -c randtable.c
-compress.o: compress.c
- $(CC) $(CFLAGS) -c compress.c
-decompress.o: decompress.c
- $(CC) $(CFLAGS) -c decompress.c
-bzlib.o: bzlib.c
- $(CC) $(CFLAGS) -c bzlib.c
-bzip2.o: bzip2.c
- $(CC) $(CFLAGS) -c bzip2.c
-bzip2recover.o: bzip2recover.c
- $(CC) $(CFLAGS) -c bzip2recover.c
+.SUFFIXES: .c .o .lo
+
+%.o: %.c bzlib.h bzlib_private.h
+ $(CC) $(CFLAGS) -c $<
+%.lo: %.c bzlib.h bzlib_private.h
+ libtool --mode=compile $(CC) $(CFLAGS) -c $<
distclean: clean
rm -f manual.ps manual.html manual.pdf
diff -Naur bzip2-1.0.6/Makefile-libbz2_so bzip2-1.0.6.oden/Makefile-libbz2_so
--- bzip2-1.0.6/Makefile-libbz2_so 2010-09-11 01:07:52.000000000 +0200
+++ bzip2-1.0.6.oden/Makefile-libbz2_so 2010-09-20 12:22:58.719327028 +0200
@@ -20,11 +20,13 @@
# in the file LICENSE.
# ------------------------------------------------------------------
+include config.in
SHELL=/bin/sh
CC=gcc
BIGFILES=-D_FILE_OFFSET_BITS=64
-CFLAGS=-fpic -fPIC -Wall -Winline -O2 -g $(BIGFILES)
+CFLAGS +=-fpic -fPIC -Wall -Winline -O2 -g $(BIGFILES)
+LDFLAGS +=
OBJS= blocksort.o \
huffman.o \
@@ -35,8 +37,8 @@
bzlib.o
all: $(OBJS)
- $(CC) -shared -Wl,-soname -Wl,libbz2.so.1.0 -o libbz2.so.1.0.6 $(OBJS)
- $(CC) $(CFLAGS) -o bzip2-shared bzip2.c libbz2.so.1.0.6
+ $(CC) $(CFLAGS) -shared -Wl,-soname -Wl,libbz2.so.1.0 $(LDFLAGS) -o libbz2.so.1.0.6 $(OBJS)
+ $(CC) $(CFLAGS) $(LDFLAGS) -o bzip2-shared bzip2.c libbz2.so.1.0.6
rm -f libbz2.so.1.0
ln -s libbz2.so.1.0.6 libbz2.so.1.0

235
bzip2.spec Normal file
View file

@ -0,0 +1,235 @@
%define major 1
%define libname %mklibname %{name}_ %{major}
%define develname %mklibname %{name} -d
%define buildpdf 0
Summary: Extremely powerful file compression utility
Name: bzip2
Version: 1.0.6
Release: %mkrel 3
License: BSD
Group: Archiving/Compression
URL: http://www.bzip.org/index.html
Source0: http://www.bzip.org/%{version}/%{name}-%{version}.tar.gz
Source1: bzgrep
Source2: bzme
Source3: bzme.1
Patch0: bzip2-1.0.6-makefile.diff
Requires: mktemp
Requires: %{libname} = %{version}-%{release}
%if %buildpdf
BuildRequires: tetex-dvips
BuildRequires: tetex-latex
%endif
BuildRequires: texinfo
BuildRequires: libtool
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
%description
Bzip2 compresses files using the Burrows-Wheeler block-sorting text
compression algorithm, and Huffman coding. Compression is generally
considerably better than that achieved by more conventional LZ77/LZ78-based
compressors, and approaches the performance of the PPM family of statistical
compressors.
The command-line options are deliberately very similar to those of GNU Gzip,
but they are not identical.
%package -n %{libname}
Summary: Libraries for developing apps which will use bzip2
Group: System/Libraries
%description -n %{libname}
Library of bzip2 functions, for developing apps which will use the
bzip2 library (aka libz2).
%package -n %{develname}
Summary: Header files for developing apps which will use bzip2
Group: Development/C
Requires: %{libname} = %{version}-%{release}
Provides: lib%{name}-devel = %{version}-%{release}
Provides: %{name}-devel = %{version}-%{release}
Obsoletes: %{mklibname bzip2_ 1 -d} < 1.0.5-3
Provides: %{mklibname bzip2_ 1 -d}
%description -n %{develname}
Header files and static library of bzip2 functions, for developing apps which
will use the bzip2 library (aka libz2).
%prep
%setup -q
%patch0 -p1 -b .makefile
echo "lib = %{_lib}" >> config.in
echo "CFLAGS = %{optflags}" >> config.in
echo "LDFLAGS = %{ldflags}" >> config.in
cp %{SOURCE1} bzgrep
cp %{SOURCE2} bzme
cp %{SOURCE3} bzme.1
%build
%make -f Makefile-libbz2_so
%make
%if %buildpdf
texi2dvi --pdf manual.texi
%endif
%install
rm -rf %{buildroot}
%makeinstall_std
install -m0755 bzme %{buildroot}%{_bindir}/
install -m0755 bzgrep %{buildroot}%{_bindir}/
install -m0644 bzgrep.1 %{buildroot}%{_mandir}/man1/
cat > %{buildroot}%{_bindir}/bzless <<EOF
#!/bin/sh
%{_bindir}/bunzip2 -c "\$@" | %{_bindir}/less
EOF
chmod 755 %{buildroot}%{_bindir}/bzless
install -m 644 %{SOURCE3} %{buildroot}%{_mandir}/man1/
%if %mdkversion < 200900
%post -n %{libname} -p /sbin/ldconfig
%endif
%if %mdkversion < 200900
%postun -n %{libname} -p /sbin/ldconfig
%endif
%clean
rm -rf %{buildroot}
%files
%defattr(-,root,root,755)
%doc README LICENSE CHANGES
%{_bindir}/*
%{_mandir}/man1/*
%files -n %{libname}
%defattr(-,root,root,755)
%doc LICENSE
%{_libdir}/libbz2.so.%{major}*
%files -n %{develname}
%defattr(-,root,root,755)
%doc *.html LICENSE
%if %buildpdf
%doc manual.pdf
%endif
%{_libdir}/libbz2.a
%{_libdir}/libbz2.la
%{_libdir}/libbz2.so
%{_includedir}/*.h
%changelog
* Tue May 03 2011 Oden Eriksson <oeriksson@mandriva.com> 1.0.6-3mdv2011.0
+ Revision: 663345
- mass rebuild
* Fri Oct 15 2010 Thierry Vignaud <tv@mandriva.org> 1.0.6-2mdv2011.0
+ Revision: 585829
- bzme: able to recompress rar files too
- bzme: adapt for Fedora/RHEL
* Mon Sep 20 2010 Oden Eriksson <oeriksson@mandriva.com> 1.0.6-1mdv2011.0
+ Revision: 579942
- 1.0.6
- rediffed P0
* Sun Mar 14 2010 Oden Eriksson <oeriksson@mandriva.com> 1.0.5-7mdv2010.1
+ Revision: 518988
- rebuild
* Sun Aug 09 2009 Oden Eriksson <oeriksson@mandriva.com> 1.0.5-6mdv2010.0
+ Revision: 413193
- rebuild
* Sat Jan 10 2009 Tomasz Pawel Gajc <tpg@mandriva.org> 1.0.5-5mdv2009.1
+ Revision: 328087
- merge both patches into one
- make sure that -D_FILE_OFFSET_BITS=64 is always passed during compilation (mdvbz #46851)
* Sat Dec 20 2008 Oden Eriksson <oeriksson@mandriva.com> 1.0.5-4mdv2009.1
+ Revision: 316557
- use -fPIC
- really use %%{optflags} and %%{ldflags}
* Sun Jul 06 2008 Tomasz Pawel Gajc <tpg@mandriva.org> 1.0.5-3mdv2009.0
+ Revision: 232090
- new library policy
- protect major
- spec file clean
* Mon Jun 16 2008 Thierry Vignaud <tv@mandriva.org> 1.0.5-2mdv2009.0
+ Revision: 220495
- rebuild
+ Pixel <pixel@mandriva.com>
- do not call ldconfig in %%post/%%postun, it is now handled by filetriggers
* Fri Mar 21 2008 Gustavo De Nardin <gustavodn@mandriva.com> 1.0.5-1mdv2008.1
+ Revision: 189334
- new version, 1.0.5, fixes a security hole
* Fri Jan 11 2008 Thierry Vignaud <tv@mandriva.org> 1.0.4-3mdv2008.1
+ Revision: 149066
- rebuild
- kill re-definition of %%buildroot on Pixel's request
+ Olivier Blin <oblin@mandriva.com>
- restore BuildRoot
* Thu Aug 16 2007 Thierry Vignaud <tv@mandriva.org> 1.0.4-2mdv2008.0
+ Revision: 64221
- rebuild
* Fri Jan 05 2007 Oden Eriksson <oeriksson@mandriva.com> 1.0.4-1mdv2007.0
+ Revision: 104592
- 1.0.4
- rediffed the makefile patch (now P0)
- nuked upstream fixes for CAN-2005-0953, CAN-2005-0758 and other sec holes
- rebuild
- Import bzip2
* Sun Jul 30 2006 Oden Eriksson <oeriksson@mandriva.com> 1.0.3-6mdk
- sync with fedora (1.0.3-2.2.1)
- dropped the progress patch (P2) because it don't work with
large files, fixes #22262
* Sat May 13 2006 Stefan van der Eijk <stefan@eijk.nu> 1.0.3-5mdk
- rebuild for sparc
* Tue Jan 31 2006 Oden Eriksson <oeriksson@mandriva.com> 1.0.3-4mdk
- merge with the 1.0.3-1.2.20060mdk relese (CVE-2005-0953,CVE-2005-0758)
* Sat Jan 07 2006 Christiaan Welvaart <cjw@daneel.dyndns.org> 1.0.3-3mdk
- add BuildRequires: libtool
* Sat Dec 31 2005 Mandriva Linux Team <http://www.mandrivaexpert.com/> 1.0.3-2mdk
- Rebuild
* Wed Jun 08 2005 Götz Waschk <waschk@mandriva.org> 1.0.3-1mdk
- update patch 1
- fix URLs
- new version
* Fri Feb 11 2005 Olivier Blin <oblin@mandrakesoft.com> 1.0.2-20mdk
- bzme: allow to force compression with -F option
(#11183, patch from Michael Scherer)
- fix summary ended with dot
* Fri Sep 17 2004 Gwenole Beauchesne <gbeauchesne@mandrakesoft.com> 1.0.2-19mdk
- ship with bzdiff, bzmore
- automake build is evil here for a so small project
* Tue Apr 06 2004 Thierry Vignaud <tvignaud@mandrakesoft.com> 1.0.2-18mdk
- fix url

212
bzme Normal file
View file

@ -0,0 +1,212 @@
#!/bin/sh
# bzme re-compress gzip, zip, ... files into bzip2
#==============================================================================
# Copyright (C) 1999-2002 MandrakeSoft (tvignaud@mandrakesoft.com)
# By Thierry Vignaud <tvignaud@mandrakesoft.com>
#
# 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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# The GNU General Public License can be read at
# http://www.fsf.org/copyleft/gpl.html
#==============================================================================
#
# Know bugs:
# ----------
# - bash getopt isn't gnu style aware, ie cmd opt1 file1 file2 opt2
# will result in ignoring opt2 option
#
#==============================================================================
#
# Changelog:
# ----------
# v1.0: original release
# v1.1: fix space usage (use pipe rather than temp file)
# v1.2: keep source file, not bz2 one if eof while decompressing
# v1.3: reduce used cpu time (decompressing only one time;
# source crc error 're detected through PIPESTATUS)
# v1.4: add zip support on popular^h^h^h^h^hGwenole request
# v1.5:
# - make zip method acting as z one (remove original file,
# keeping only smallest file, displaying size gain, ...)
# thus giving occasion to factorize some common code
# - check that the source file does exists
# - handle corrupted zip source file
# - comment the script and verbos-ize() some old changes
# - use cheaper shell tests
# - add GPL reference
# - update online help to reflect optional options and newer
# supported formats
# - remove dependency on sed by using ${1%old}new_extension
# v1.6:
# - print error message on stderr rather than on stdin
# - factorize/simplify zip method (fix erase temp files on bzip2ing
# error)
# - typo fixes
# - simplify for_each(file) loop
# - add "Know bugs" and TODO sections
# - add -h and -k options
# - if -k (keep) option is used, keep all files
# v1.7: - handle file names with spaces
# v1.8:
# - able to recompress rar files too
# - adapt for Fedora/RHEL
#==============================================================================
#
#
# TODO:
# - retrieve my patch for solaris file utils
# - add trap for zip method (is it really useful?)
# - add a man page
# - move bzme in its own package that requires tar too
# Defaults
force=
keep=
# Corrupted source error message
src_err_msg ()
{ if [ "$2" != 0 ]; then
echo "Corrupted source file ($1) !" 1>&2
rm -f "$TARGET"
STATUS=1
fi
}
gz_compr ()
{ zcat "$1" | bzip2 -9 > "$TARGET"
# Keep PIPESTATUS
MY_STATUS=( ${PIPESTATUS[*]} )
src_err_msg "$1" ${MY_STATUS[0]}
if [[ "${MY_STATUS[1]}" != "0" ]]; then
echo "error while bziping !" 1>&2
STATUS=1
fi
}
create_temp_dir ()
{
[[ -z "$TMPDIR" ]] && TMPDIR=$TMP
[[ -z "$TMPDIR" ]] && TMPDIR=~/tmp
MY_TMP=$(mktemp -d $TMPDIR/gzme.XXXXXX)
}
rar_compr ()
{
create_temp_dir
(cd $MY_TMP; unrar x "$OLDPWD/$1") > /dev/null
src_err_msg "$1" $?
tar cfj "$TARGET" -C $MY_TMP .
if [[ $? != 0 ]]; then
echo "error while taring !" 1>&2
STATUS=1
fi
# Removing temporary files
rm -fr $MY_TMP
}
zip_compr ()
{
create_temp_dir
unzip -qd $MY_TMP "$1"
src_err_msg "$1" $?
tar cfj "$TARGET" -C $MY_TMP .
if [[ $? != 0 ]]; then
echo "error while taring !" 1>&2
STATUS=1
fi
# Removing temporary files
rm -fr $MY_TMP
}
compress ()
{ echo -n "Compressing $1 ... "
if [[ ! -f "$1" ]]; then
echo "Source file doesn't exist" 1>&2
return
fi
STATUS=0
SIZE=$(du "$1"|cut -f 1 -d " ")
SIZE_o=$(du -b "$1"|cut -f 1 -d " ")
if [[ -f "$TARGET" ]]; then
if [[ -n $force ]];then
rm -f "$TARGET"
else
echo "$TARGET already exists !!" 1>&2
echo "Use -f to force it"
return
fi
fi
# Do the real compression job
$METHOD "$1"
# if there was an error
if [[ $STATUS = 1 ]]; then
[[ -z $keep ]] && rm -f "$TARGET"
return
fi
# Compare size in order to only keep the smallest file
SIZE2=$(du "$TARGET"|cut -f 1 -d " ")
SIZE2_o=$(du -b "$TARGET"|cut -f 1 -d " ")
if [[ $SIZE_o -lt $SIZE2_o && -z $force_compress ]]
then
echo "=> $TARGET is bigger than $1 ($SIZE"kb" => $SIZE2"kb") !!!"
echo "Use -F to force the recompression"
[[ -z $keep ]] && rm -f "$TARGET"
else
echo "=> $TARGET ($SIZE"kb" => $SIZE2"kb")"
[[ -z $keep ]] && rm -f "$1"
fi
}
while getopts Ffhk opt; do
case "$opt" in
F) force_compress="yes";;
f) force="yes";;
k) keep="yes";;
h)
echo "Usage: bzme [-Ffhk] file.*.({,t}gz|Z|zip)"
exit 1;;
*)
echo "See bzme -h for usage"
exit 1;;
esac
done
shift $((OPTIND - 1))
echo keeping: $keep
while [[ "$1" != "" ]]
do
#default method is gz,.Z,.z,..
METHOD=gz_compr
case "$1" in
*.bz2) echo "$1: already compressed!"; shift;continue;;
*.tgz) TARGET=${1%.tgz}.tar.bz2;;
*.Z) TARGET=${1%.Z}.bz2;;
*.gz) TARGET=${1%.gz}.bz2;;
*.rar)
METHOD=rar_compr
TARGET=${1%.rar}.bz2
;;
*.zip)
METHOD=zip_compr
TARGET=${1%.zip}.tar.bz2
;;
*) echo "$1: unknown file extension => ignored"; shift; continue;;
esac
compress "$1"
shift
done

146
bzme.1 Normal file
View file

@ -0,0 +1,146 @@
.PU
.TH bzip2 1
.SH NAME
bzme \- recompress gziped, ziped, ... files into bzip2
.SH SYNOPSIS
.ll +8
.B bzmz
.RB [ " \-fh " ]
[
.I "filenames \&..."
]
.SH DESCRIPTION
.I bzme
recompresses files using the Burrows-Wheeler block sorting text compression
algorithm, and Huffman coding. Compression is generally considerably better
than that achieved by more conventional LZ77/LZ78-based compressors,
and approaches the performance of the PPM family of statistical compressors.
.I bzme
expects a list of file names to accompany the command-line flags.
Each file is replaced by a recompressed version of itself, with the name
as described in
.B "NEW NAMES"
section.
.I bzme
won't overwrite by default existing files. If you want this to happen, specify
the \-f flag.
.SH "NEW NAMES"
.I bzip2
attempts to guess the filename for the decompressed file
from that of the compressed file as follows:
filename.tgz becomes filename.tar.bz2
filename.tar.gz becomes filename.tar.bz2
filename.zip becomes filename.tar.bz2
filename.z becomes filename.bz2
filename.Z becomes filename.bz2
filename.gz becomes filename.bz2
If the file does not end in one of the recognised endings, \fI.tgz\fP,
or \fI.zip\fP,
.I bzme
complains that it cannot guess if the name of the recompressed file (ie it
doesn't detect the original name to be a file compressed in a known format)
.SH OPTIONS
.TP
.B \-f
Force overwrite of output files, even if
.I -k
is used. Normally,
.I bzip2
will not overwrite existing output files.
.TP
.B \-k
Keep (don't delete) input files during compression
or decompression.
.".TP
.".B \-q --quiet
."Suppress non-essential warning messages. Messages pertaining to
."I/O errors and other critical events will not be suppressed.
.".TP
.".B \-v --verbose
."Verbose mode -- dysplay space gain (default)
.".TP
.".B \-L --license -V --version
."Display the software version, license terms and conditions.
.SH SECURITY
.I bzme
will keep source file if there's an error while decompressing source file
or recompressing new file (or
.I -k
option is used of course).
.I bzme
won't overwite the target file, even if
.I -k
option is used, if the source file doesn't exists.
As a self-check for your protection,
.I bzip2
uses 32-bit CRCs to make sure that the decompressed version of a file is
identical to the original.
.BR
This offers a better protection against corruption
of the compressed data than offered by gzip.
.SH SPACE GAIN
Compression is only performed if the compressed file is smaller than the
original: the original file is only removed if the newly compressed file
is smaller, else the new recompressed file is deleted.
Text (aka non binary) files're quite nearly always better compressed
by bzip2 rather than gzip.
.SH MEMORY VS SPACE TRADEOFF
There're two things :
.TP
.B Consumed CPU time
The needed cpu time is reduced by decompressing only one time.
Files to recompress were compressed through compress or gzip, used to be
decompressed by gunzip -t in order to check that the original file was ok.
This resulted in passing two times the data in the decompression process
(one to check integrity, one to recompress).
temporary space usage will be zero since bzme will use a pipe
rather than a temporary file as it does in the early ages.
Source error're detected through bash PIPESTATUS feature.
.TP
.B Occupied space
While recompressing files, if they were compressed through compress or gzip,
temporary space usage will be zero since bzme will use a pipe
rather than a temporary file as it did in the early ages.
Source error're detected through bash PIPESTATUS feature.
Zip files're still fully decompressed on disk.
As for the recompressed file and original file, only the smallest file
is kept.
.SH RETURN VALUES
0 for a normal exit.
1 will be returned if an unknown option is passed.
.SH BUGS
Bash getopt (which is used to analyse options) isn't gnu style aware, ie cmd
opt1 file1 file2 opt2 will result in ignoring opt2 option.
Solaris/SunOs du doesn't supports gnu option, and thus, bzme won't
work on those OSes unless GNU fileutils got installed.
.BR
I had once a day patched bzme to use right options for solaris but i had
lost my changes.
.LP
So solaris remains unsupported.
.SH "SEE ALSO"
bzip2(1), bunzip2(1)
.SH AUTHOR
Thierry Vignaud <tvignaud@mandrakesoft.com>, 1999-2002