1998-02-27 07:54:42 +03:00
|
|
|
#! /bin/sh
|
|
|
|
#
|
|
|
|
# Written by andrey joukov
|
|
|
|
# (C) 1996 2:5020/337.13@fidonet.org
|
1999-04-21 14:55:07 +04:00
|
|
|
# Updated by christian.gennerat@alcatel.fr 1999
|
2000-12-15 14:50:45 +03:00
|
|
|
# Andrew V. Samoilov <sav@bcs.zp.ua> 2000
|
1999-04-21 14:55:07 +04:00
|
|
|
# beta version 2.0
|
1998-02-27 07:54:42 +03:00
|
|
|
#
|
1999-04-21 14:55:07 +04:00
|
|
|
DRAR=/usr/bin
|
|
|
|
RAR=$DRAR/rar
|
|
|
|
UNRAR=$DRAR/unrar # Prefer unrar (freeware)
|
1998-02-27 07:54:42 +03:00
|
|
|
#
|
|
|
|
# NOTE: rar ver 2.0 by Eugene Roshal
|
|
|
|
# ftp.elf.stuba.sk/pub/pc/pack
|
|
|
|
#
|
|
|
|
|
|
|
|
mcrarfs_list ()
|
|
|
|
{
|
1999-04-21 14:55:07 +04:00
|
|
|
$UNRAR v -c- "$1" | @AWK@ -v uid=${UID-0} '
|
1998-02-27 07:54:42 +03:00
|
|
|
BEGIN { flag=0; date="JanFebMarAprMayJunJulAugSepOctNovDec" }
|
|
|
|
/^-------/ { flag++; if (flag > 1) exit 0; next }
|
|
|
|
{
|
|
|
|
if (flag == 0) next
|
1999-04-21 14:55:07 +04:00
|
|
|
if ( !/ [0-9][0-9]:[0-9][0-9] /) str = $0 # there is no time spec in this line
|
1998-02-27 07:54:42 +03:00
|
|
|
else {
|
|
|
|
if (str ~ /^\^/)
|
|
|
|
str=substr(str, 2)
|
|
|
|
split($4, a, "-")
|
|
|
|
if (a[3] < 50)
|
|
|
|
a[3] = 2000 + a[3]
|
|
|
|
else
|
|
|
|
a[3] = 1900 + a[3]
|
|
|
|
if (index($6, "D") != 0)
|
|
|
|
$6="drwxr-xr-x"
|
|
|
|
else
|
|
|
|
if (index($6, ".") != 0)
|
|
|
|
$6="-rw-r--r--"
|
|
|
|
printf "%s 1 %-8d %-8d %8d %3s %2d %4d %s %s\n", $6, uid, 0, $1, substr(date, (a[2]-1)*3+1, 3), a[1], a[3], $5, str
|
|
|
|
}
|
2000-12-15 14:50:45 +03:00
|
|
|
}' 2>/dev/null
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
1999-04-21 14:55:07 +04:00
|
|
|
mcrarfs_copyin ()
|
|
|
|
{
|
|
|
|
# copyin by christian.gennerat@alcatel.fr
|
|
|
|
# preserve pwd. It is clean, but is it necessary?
|
|
|
|
pwd=`pwd`
|
|
|
|
# Create a directory and copy in it the tmp file with the good name
|
|
|
|
mkdir $3.dir
|
|
|
|
cd $3.dir
|
|
|
|
di="${2%/*}"
|
|
|
|
# if file is to be written upper in the archive tree, make fake dir
|
|
|
|
if test "$di" != "${2##*/}" ; then
|
|
|
|
mkdir -p "$di"
|
|
|
|
fi
|
|
|
|
# (cp -p) to preserve date, but $2 is dated now!
|
|
|
|
cp -p $3 "$3.dir/$2"
|
|
|
|
$RAR a "$1" "$2" >/dev/null
|
|
|
|
cd $pwd
|
|
|
|
rm -rf $3.dir
|
|
|
|
}
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
mcrarfs_copyout ()
|
|
|
|
{
|
1999-04-21 14:55:07 +04:00
|
|
|
$UNRAR p -c- -inul "$1" "$2" > $3 2>/dev/null
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
1999-05-15 20:11:04 +04:00
|
|
|
|
|
|
|
mcrarfs_mkdir ()
|
|
|
|
{
|
|
|
|
# preserve pwd. It is clean, but is it necessary?
|
|
|
|
pwd=`pwd`
|
|
|
|
# Create a directory and create in it a tmp directory with the good name
|
|
|
|
dir=tmpdir.${RANDOM}
|
|
|
|
mkdir $dir
|
|
|
|
cd $dir
|
|
|
|
mkdir -p "$2"
|
|
|
|
# rar cannot create an empty directory
|
|
|
|
touch "$2"/.rarfs
|
|
|
|
$RAR a -r "$1" "$2" &>/dev/null
|
|
|
|
$RAR d "$1" "$2"/.rarfs &>/dev/null
|
|
|
|
cd $pwd
|
|
|
|
rm -rf $dir
|
|
|
|
}
|
|
|
|
|
|
|
|
mcrarfs_rm ()
|
|
|
|
{
|
|
|
|
$RAR d "$1" "$2" &>/dev/null
|
|
|
|
}
|
|
|
|
|
1998-12-16 09:16:13 +03:00
|
|
|
umask 077
|
1998-02-27 07:54:42 +03:00
|
|
|
|
1999-04-21 14:55:07 +04:00
|
|
|
# uncomment this line for debugging
|
|
|
|
#echo "`date +%T` ${0##*/} $1 $2 to=$3 tmp=$4" >>/tmp/${0##*/}.log
|
1998-02-27 07:54:42 +03:00
|
|
|
case "$1" in
|
2000-12-15 14:50:45 +03:00
|
|
|
list) mcrarfs_list "$2" | sort +9 ; exit 0;;
|
1999-05-15 20:11:04 +04:00
|
|
|
rm) mcrarfs_rm "$2" "$3" ; exit 0;;
|
|
|
|
rmdir) mcrarfs_rm "$2" "$3" ; exit 0;;
|
|
|
|
mkdir) mcrarfs_mkdir "$2" "$3" ; exit 0;;
|
1999-04-21 14:55:07 +04:00
|
|
|
copyin) mcrarfs_copyin "$2" "$3" $4; exit 0;;
|
|
|
|
copyout) mcrarfs_copyout "$2" "$3" $4; exit 0;;
|
1998-02-27 07:54:42 +03:00
|
|
|
esac
|
|
|
|
exit 1
|