Merge branch 'master' of git://github.com/gmakrydakis/lrzip

This commit is contained in:
Con Kolivas 2010-04-03 22:14:13 +11:00
commit d5bd8a5f4c
3 changed files with 43 additions and 12 deletions

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
*~

View file

@ -101,8 +101,10 @@ zpipe.o: zpipe.cpp
install: all
mkdir -p $(DESTDIR)${INSTALL_BIN}
${INSTALLCMD} -m 755 lrzip $(DESTDIR)${INSTALL_BIN}
( cd $(DESTDIR)${INSTALL_BIN} && ${LN_S} -f lrzip lrunzip )
${INSTALLCMD} -m 755 lrztar $(DESTDIR)${INSTALL_BIN}
${LN_S} -f $(DESTDIR)${INSTALL_BIN}/lrzip $(DESTDIR)${INSTALL_BIN}/lrunzip
${LN_S} -f $(DESTDIR)${INSTALL_BIN}/lrztar $(DESTDIR)${INSTALL_BIN}/lrzuntar
chmod 755 $(DESTDIR)${INSTALL_BIN}/lrzuntar
mkdir -p $(DESTDIR)${INSTALL_MAN1}
${INSTALLCMD} -m 644 $(MAN1FILES) $(DESTDIR)${INSTALL_MAN1}
mkdir -p $(DESTDIR)${INSTALL_MAN5}
@ -111,7 +113,11 @@ install: all
${INSTALLCMD} -m 644 $(DOCFILES) $(DESTDIR)${INSTALL_DOC}
mkdir -p $(DESTDIR)${INSTALL_DOC_LZMA}
${INSTALLCMD} -m 644 $(DOCFILES_LZMA) $(DESTDIR)${INSTALL_DOC_LZMA}
uninstall:
rm -rf $(DESTDIR)${INSTALL_BIN}/{lrztar,lrzuntar,lrunzip,lrzip}
rm -rf $(DESTDIR)${INSTALL_DOC}
rm -rf $(DESTDIR)${INSTALL_MAN1}/{lrunzip.1,lrzip.1,lrztar.1}
rm -rf $(DESTDIR)${INSTALL_MAN5}/lrzip.conf.5
lrzip: $(OBJS)
$(CXX) $(LDFLAGS) -o lrzip $(OBJS) $(LIBS)

43
lrztar
View file

@ -1,17 +1,30 @@
#!/bin/bash
# A basic skeleton for making a new lrzip tar wrapper place messages etc
# where you think you want them, it kind of self - documents itself.
# For the time being, lrzip does not like pipes.
# Copyright (C) George Makrydakis 2009, 2010
# Copyright (C) Con Kolivas 2010
# Public domain with no warranties or suitability whatsoever etc.
# G.M.
# A bash wrapper for Con Kolivas' excellent lrzip utility. For the time
# being, lrzip does not like pipes, so we had to do this. It is kind of
# self - documenting, spawned out of a test tube bash shell script.
# 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, see <http://www.gnu.org/licenses/>.
function lrztar_local() {
local p="${@:1:$(($#-1))}" s="${!#}" tname= fname= \
v_w=0 v_O=0 v_S=0 v_D=0 v_P=0 v_q=0 v_L=0 \
v_n=0 v_l=0 v_b=0 v_g=0 v_z=0 v_M=0 v_T=0 \
v_N=0 v_v=0 v_f=0 v_d=0 v_h=0 x=
v_N=0 v_v=0 v_f=0 v_d=0 v_h=0 x= i=
OPTERR=0
trap '[[ -z $tname ]] || rm -rf "$tname" &> /dev/null' 1 2 3 15
which tar &> /dev/null || { printf "lrztar: no tar in your path\n"; return 1; }
@ -20,23 +33,33 @@ function lrztar_local() {
[[ $x == [otV] ]] || ((v_$x=1)) &> /dev/null \
|| { printf "lrztar: invalid option for lrztar %s\n" "$x"; return 1; }
done
[[ $(basename "$0") == lrzuntar ]] \
&& { v_d=1; p="-d $p"; }
{ ! (($#)) || ((v_h)); } && {
printf "lrztar wrapper for compressing/decompressing whole directories with lrzip.\n"
printf "usage: lrztar [lrzip options] <directory> will compress directory to directory.tar.lrz\n"
printf "lrztar -d [lrzip options] <directory.tar.lrz> will extract directory from directory.tar.lrz\n"
printf "lrzip -h will list lrzip options\n"
printf "lrzuntar [lrzip options] <directory.tar.lrz> will extract directory from directory.tar.lrz\n"
printf "lrz[un]tar -h will display this help message\n"
printf "lrzip -h will display lrzip options\n"
return
}
((v_d)) && {
fname="$(basename "$s")"; tname="${fname%.lrz}"
fname="$(basename "$s")"; tname="${fname%.lrz}";
! ((v_f)) && [[ -e ${tname%.tar} ]] && {
printf "lrztar: ${tname%.tar} already present, aborting\n"
return 1
}
lrzip $p "$fname" && tar xf "$tname"
[[ ${s%/*} != $s ]] && i="${s%/*}/" || i="./"
tname="$i$tname"
lrzip $p "$i$fname" && tar xf "$tname"
x=$?
} || {
tname="$(basename "$s").tar"
fname="$(basename "$s")"; tname="$fname.tar"
[[ $fname == *.lrz ]] && {
printf "lrztar: $fname is already a .lrz file, aborting\n"
return 1
}
tar cf "$tname" "$s" && lrzip $p "$tname"
x=$?
}