cpio.sh revision 3f54fd611f536639ec30dd53c48e5ec1897cc7d9
2b873214c9ab511bbca437c036371ab664aedaceChristian Maeder########################################################################
f66fcd981f556c238df7dd6dfa42123745e3b1d2Christian Maeder# #
c63ebf815c8a874525cf18670ad74847f7fc7b26Christian Maeder# This software is part of the ast package #
c092fcac4b8f5c524c22ca579189c4487c13edf7Christian Maeder# Copyright (c) 1987-2011 AT&T Intellectual Property #
fefee7e1dee1ee5f0768a03a4abae88d1ca2c3fdRazvan Pascanu# and is licensed under the #
75a6279dbae159d018ef812185416cf6df386c10Till Mossakowski# Eclipse Public License, Version 1.0 #
3f69b6948966979163bdfe8331c38833d5d90ecdChristian Maeder# by AT&T Intellectual Property #
75a6279dbae159d018ef812185416cf6df386c10Till Mossakowski# #
75a6279dbae159d018ef812185416cf6df386c10Till Mossakowski# A copy of the License is available at #
f66fcd981f556c238df7dd6dfa42123745e3b1d2Christian Maeder# http://www.eclipse.org/org/documents/epl-v10.html #
c092fcac4b8f5c524c22ca579189c4487c13edf7Christian Maeder# (with md5 checksum b35adb5213ca9657e911e9befb180842) #
dda5ab793f1615c1ba1dcaa97a4346b0878da6b1Christian Maeder# #
f66fcd981f556c238df7dd6dfa42123745e3b1d2Christian Maeder# Information and Software Systems Research #
f66fcd981f556c238df7dd6dfa42123745e3b1d2Christian Maeder# AT&T Research #
da955132262baab309a50fdffe228c9efe68251dCui Jian# Florham Park NJ #
dda5ab793f1615c1ba1dcaa97a4346b0878da6b1Christian Maeder# #
dda5ab793f1615c1ba1dcaa97a4346b0878da6b1Christian Maeder# Glenn Fowler <gsf@research.att.com> #
f66fcd981f556c238df7dd6dfa42123745e3b1d2Christian Maeder# #
f66fcd981f556c238df7dd6dfa42123745e3b1d2Christian Maeder########################################################################
0799b5dc3f06d2640e66e9ab54b8b217348fd719Christian Maeder:
0799b5dc3f06d2640e66e9ab54b8b217348fd719Christian Maeder# @(#)cpio.sh (AT&T Labs Research) 1990-08-11
43b4c41fbb07705c9df321221ab9cb9832460407Christian Maeder#
4c8d3c5a9e938633f6147b5a595b9b93bfca99e6Christian Maeder# cpio -> pax interface script
fbc4f8708092d571a45cb483f37cc6b674da45a7Christian Maeder#
fbc4f8708092d571a45cb483f37cc6b674da45a7Christian Maeder
fbc4f8708092d571a45cb483f37cc6b674da45a7Christian Maedercommand=cpio
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowskiusage="
c4451dc7da4a15726ba96179aecf046a5df5cae1Christian MaederUsage: $command -o[acvBV] [-C size] [-M mesg] [-O file | >file ] <list
3c4e64e0b4361a24275ee8f308fa965ab1e52f2eHeng Jiang $command -i[bcdfkmrtsuvBSV6] [-I file | <file] [pattern ...]
fa388aea9cef5f9734fec346159899a74432ce26Christian Maeder $command -p[adlmuvV] directory"
0799b5dc3f06d2640e66e9ab54b8b217348fd719Christian Maeder
fe4e6766a6e51cca3f8cc9632c25936af147d8b9Christian MaederOPTSTR='abcdfiklmoprstuvBSV6C:[size]H:[format]M:[message]O:[file]?D [ pattern | directory ]'
59fddbdd745a05adeaf655b617ab8da947903832Christian Maeder
fe4e6766a6e51cca3f8cc9632c25936af147d8b9Christian Maederoptions="-d"
cfaa17b0d2ed0a663f0a4f18b23f98ab876c2f40Christian Maederblocksize=1b
f77f29e84b3f6e791c82e61b13fbf76582bedd2fChristian Maederexec=eval
dda5ab793f1615c1ba1dcaa97a4346b0878da6b1Christian Maederformat=binary
d56ece59c372cb887355825901222b9f3377f7e6Thiemo Wiedemeyerlist=""
d56ece59c372cb887355825901222b9f3377f7e6Thiemo Wiedemeyerlogphys=-P
f77f29e84b3f6e791c82e61b13fbf76582bedd2fChristian Maedermode=""
f66fcd981f556c238df7dd6dfa42123745e3b1d2Christian Maederd_default="-o nomkdir"
c0c2380bced8159ff0297ece14eba948bd236471Christian Maederm_default="-pm"
da333ffa6336cf59a4071fcddad358c5eafd3e61Sonja Gröningu_default="-u"
c0c2380bced8159ff0297ece14eba948bd236471Christian Maederr_ok="1"
6352f3c31da3043783a13be6594aacb2147378baRazvan Pascanuw_ok="1"
8ef91a173e69219fc2ebd45c76a35891c7785abdMarkus Grossp_ok="1"
fc1a590cd3ee36797c0a032ff41e07f8e2469341Christian Maeder
a2b04db3e156312a8596d8084f7f0f51acf8a96bChristian Maederwhile getopts -a $command "$OPTSTR" OPT
fc1a590cd3ee36797c0a032ff41e07f8e2469341Christian Maederdo case $OPT in
66a774f13272fde036481edd2298081ab3d04678Razvan Pascanu 'D') case $exec in
834c2e71b8e390e5b05c8d02bb6eb22621125133Markus Gross eval) exec=print ;;
6e52f1dfc0da4bc4a7701cf856641c9dce08fc7dChristian Maeder *) exec="eval args" ;;
923e25bb8c7cf9f2978c7844ad173704482cc3b0Martin Kühl esac
9f85afecbd79b3df5a0bb17bd28cd0b288dc3213Kristina Sojakova ;;
63da71bfb4226f504944b293fb77177ebcaea7d4Ewaryst Schulz [bsS6]) ;;
923e25bb8c7cf9f2978c7844ad173704482cc3b0Martin Kühl [klvV]) options="$options -$OPT" ;;
f66fcd981f556c238df7dd6dfa42123745e3b1d2Christian Maeder a) r_ok="" options="$options -p" ;;
2b873214c9ab511bbca437c036371ab664aedaceChristian Maeder c) format=cpio ;;
fe4e6766a6e51cca3f8cc9632c25936af147d8b9Christian Maeder d) w_ok="" d_default="" ;;
834c2e71b8e390e5b05c8d02bb6eb22621125133Markus Gross f) w_ok="" p_ok="" options="$options -c" ;;
8ef91a173e69219fc2ebd45c76a35891c7785abdMarkus Gross i) w_ok="" p_ok=""
8ef91a173e69219fc2ebd45c76a35891c7785abdMarkus Gross case $mode in
8ef91a173e69219fc2ebd45c76a35891c7785abdMarkus Gross '') mode=-r ;;
8ef91a173e69219fc2ebd45c76a35891c7785abdMarkus Gross -r) ;;
ee1c7c5796832536932d7b06cbfb1ca13f9a0d7bMartin Kühl *) mode=x ;;
ee1c7c5796832536932d7b06cbfb1ca13f9a0d7bMartin Kühl esac
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder ;;
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder m) w_ok="" m_default="" ;;
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder o) r_ok="" p_ok="" u_default=""
c0c2380bced8159ff0297ece14eba948bd236471Christian Maeder case $mode in
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder '') mode=-w ;;
c0c2380bced8159ff0297ece14eba948bd236471Christian Maeder -w) ;;
c4451dc7da4a15726ba96179aecf046a5df5cae1Christian Maeder *) mode=x ;;
2b873214c9ab511bbca437c036371ab664aedaceChristian Maeder esac
fa388aea9cef5f9734fec346159899a74432ce26Christian Maeder ;;
fe4e6766a6e51cca3f8cc9632c25936af147d8b9Christian Maeder p) r_ok="" w_ok=""
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder case $mode in
fe4e6766a6e51cca3f8cc9632c25936af147d8b9Christian Maeder '') mode=-rw ;;
63719301448519453f66383f4e583d9fd5b89ecbChristian Maeder -rw) ;;
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder *) mode=x ;;
fc1a590cd3ee36797c0a032ff41e07f8e2469341Christian Maeder esac
fc1a590cd3ee36797c0a032ff41e07f8e2469341Christian Maeder ;;
923e25bb8c7cf9f2978c7844ad173704482cc3b0Martin Kühl r) w_ok="" p_ok="" options="$options -i" ;;
9f85afecbd79b3df5a0bb17bd28cd0b288dc3213Kristina Sojakova t) w_ok="" p_ok="" list="1" ;;
63da71bfb4226f504944b293fb77177ebcaea7d4Ewaryst Schulz u) w_ok="" u_default="" ;;
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder B) blocksize=5k ;;
fbc4f8708092d571a45cb483f37cc6b674da45a7Christian Maeder L) logphys=-L ;;
fbc4f8708092d571a45cb483f37cc6b674da45a7Christian Maeder C) case $OPTARG in
fbc4f8708092d571a45cb483f37cc6b674da45a7Christian Maeder *[0-9]) blocksize=${OPTARG}c ;;
8ef91a173e69219fc2ebd45c76a35891c7785abdMarkus Gross *) blocksize=${OPTARG} ;;
8ef91a173e69219fc2ebd45c76a35891c7785abdMarkus Gross esac
8ef91a173e69219fc2ebd45c76a35891c7785abdMarkus Gross ;;
f77f29e84b3f6e791c82e61b13fbf76582bedd2fChristian Maeder H) case $OPTARG in
d56ece59c372cb887355825901222b9f3377f7e6Thiemo Wiedemeyer asc|ASC) format=asc ;;
d56ece59c372cb887355825901222b9f3377f7e6Thiemo Wiedemeyer crc|CRC) format=aschk ;;
d56ece59c372cb887355825901222b9f3377f7e6Thiemo Wiedemeyer odc|ODC) format=cpio ;;
f1dec6898638ba1131a9fadbc4d1544c93dfabb0Klaus Luettich tar|TAR) format=tar ;;
d56ece59c372cb887355825901222b9f3377f7e6Thiemo Wiedemeyer ustar|USTAR) format=ustar ;;
d56ece59c372cb887355825901222b9f3377f7e6Thiemo Wiedemeyer *) print -u2 "$command: $OPTARG: formats are {asc,crc,odc,tar,star}"; exit 1 ;;
d56ece59c372cb887355825901222b9f3377f7e6Thiemo Wiedemeyer esac
d56ece59c372cb887355825901222b9f3377f7e6Thiemo Wiedemeyer ;;
f77f29e84b3f6e791c82e61b13fbf76582bedd2fChristian Maeder I) w_ok="" p_ok="" options="$options -f '$OPTARG'" ;;
O) r_ok="" p_ok="" options="$options -f '$OPTARG'" ;;
M) options="$options -o eom=\"'$OPTARG'\"" ;;
esac
done
shift $(($OPTIND-1))
case $mode in
-r) case $r_ok in
"") print -u2 "$command: options inconsistent with archive read"
exit 2
;;
esac
options="$options -b $blocksize"
;;
-w) case $w_ok in
"") print -u2 "$command: options inconsistent with archive write"
exit 2
;;
esac
case $# in
0) ;;
*) print "$command: arguments not expected"
exit 2
;;
esac
options="$options -x $format -b $blocksize"
d_default="" m_default="" u_default=""
;;
-rw) case $p_ok in
"") print -u2 "$command: options inconsistent with file pass"
exit 2
;;
esac
case $# in
1) ;;
*) print -u2 "$command: a single directory argument is expected$usage"
exit 2
;;
esac
;;
'') print -u2 "$command: one of -i, -o, -p must be specified$usage"
exit 2
;;
*) print -u2 "$command: only one of -i, -o, -p may be specified$usage"
exit 2
;;
esac
case $list in
"1") mode="" d_default="" m_default="" u_default="" ;;
esac
case $exec in
eval) $exec pax $mode $logphys $options $d_default $m_default $u_default '"$@"' ;;
*) $exec pax $mode $logphys $options $d_default $m_default $u_default "$@" ;;
esac