1998-02-27 07:54:42 +03:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
1998-03-15 01:36:06 +03:00
|
|
|
# Written by Stas Maximov 1998 SVR4 (UnixWare)
|
|
|
|
# stmax@u213.srcc.msu.su
|
1998-02-27 07:54:42 +03:00
|
|
|
# (C) 1996 The Free Software Foundation.
|
|
|
|
#
|
|
|
|
#
|
|
|
|
|
1998-03-15 01:36:06 +03:00
|
|
|
uni_cat ()
|
|
|
|
# $1 is the archive name
|
|
|
|
{
|
|
|
|
case "$1" in
|
|
|
|
*.cpio.Z) compress -dc "$1"
|
|
|
|
;;
|
|
|
|
*.cpio.gz) gzip -dc "$1"
|
|
|
|
;;
|
|
|
|
*.cpio) cat "$1"
|
|
|
|
;;
|
|
|
|
*) echo "unknown extension"
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
mccpiofs_list ()
|
1998-03-15 01:36:06 +03:00
|
|
|
# $1 is the archive name
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
1999-05-30 23:20:34 +04:00
|
|
|
uni_cat "$1" | cpio -itv | @AWK@ '
|
1998-03-15 01:36:06 +03:00
|
|
|
{
|
|
|
|
if (substr($9,length($9),1) == ",")
|
|
|
|
{
|
|
|
|
tmp = substr($9, 1, length($9)-1);
|
|
|
|
$9 = $8;
|
|
|
|
$8 = tmp
|
|
|
|
}
|
|
|
|
else if (substr($10,length($10),1) == ",")
|
|
|
|
{
|
|
|
|
tmp = substr($10, 1, length($10)-1);
|
|
|
|
$10 = $9
|
|
|
|
$9 = tmp
|
|
|
|
}
|
|
|
|
|
|
|
|
print $0
|
|
|
|
}'
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
mccpiofs_copyout ()
|
1998-03-15 01:36:06 +03:00
|
|
|
# $1 is the archive name
|
|
|
|
# $2 is a name of a file within the archive
|
|
|
|
# $3 is a name of a file within the system (to add from or extract to)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
1998-03-15 01:36:06 +03:00
|
|
|
TMPDIR=/tmp/mctmpdir.$$
|
1999-04-08 21:16:58 +04:00
|
|
|
# FIXME: Try harder to generate a unique directory if this fails
|
|
|
|
mkdir -m 0700 $TMPDIR || exit 1
|
1998-03-15 01:36:06 +03:00
|
|
|
cd $TMPDIR
|
|
|
|
uni_cat "$1" | cpio -icumd "$2" 2>/dev/null
|
|
|
|
mv "$2" "$3"
|
|
|
|
cd /
|
|
|
|
rm -rf $TMPDIR
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
1998-03-15 01:36:06 +03:00
|
|
|
#
|
|
|
|
# main
|
|
|
|
#
|
1998-12-16 09:16:13 +03:00
|
|
|
umask 077
|
1998-03-15 01:36:06 +03:00
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
list) mccpiofs_list $2
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
copyout) mccpiofs_copyout $2 $3 $4
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
exit 1
|
|
|
|
|