Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/cmd/pax/cpio.sh
1808 views
1
########################################################################
2
# #
3
# This software is part of the ast package #
4
# Copyright (c) 1987-2011 AT&T Intellectual Property #
5
# and is licensed under the #
6
# Eclipse Public License, Version 1.0 #
7
# by AT&T Intellectual Property #
8
# #
9
# A copy of the License is available at #
10
# http://www.eclipse.org/org/documents/epl-v10.html #
11
# (with md5 checksum b35adb5213ca9657e911e9befb180842) #
12
# #
13
# Information and Software Systems Research #
14
# AT&T Research #
15
# Florham Park NJ #
16
# #
17
# Glenn Fowler <[email protected]> #
18
# #
19
########################################################################
20
:
21
# @(#)cpio.sh (AT&T Labs Research) 1990-08-11
22
#
23
# cpio -> pax interface script
24
#
25
26
command=cpio
27
usage="
28
Usage: $command -o[acvBV] [-C size] [-M mesg] [-O file | >file ] <list
29
$command -i[bcdfkmrtsuvBSV6] [-I file | <file] [pattern ...]
30
$command -p[adlmuvV] directory"
31
32
OPTSTR='abcdfiklmoprstuvBSV6C:[size]H:[format]M:[message]O:[file]?D [ pattern | directory ]'
33
34
options="-d"
35
blocksize=1b
36
exec=eval
37
format=binary
38
list=""
39
logphys=-P
40
mode=""
41
d_default="-o nomkdir"
42
m_default="-pm"
43
u_default="-u"
44
r_ok="1"
45
w_ok="1"
46
p_ok="1"
47
48
while getopts -a $command "$OPTSTR" OPT
49
do case $OPT in
50
'D') case $exec in
51
eval) exec=print ;;
52
*) exec="eval args" ;;
53
esac
54
;;
55
[bsS6]) ;;
56
[klvV]) options="$options -$OPT" ;;
57
a) r_ok="" options="$options -p" ;;
58
c) format=cpio ;;
59
d) w_ok="" d_default="" ;;
60
f) w_ok="" p_ok="" options="$options -c" ;;
61
i) w_ok="" p_ok=""
62
case $mode in
63
'') mode=-r ;;
64
-r) ;;
65
*) mode=x ;;
66
esac
67
;;
68
m) w_ok="" m_default="" ;;
69
o) r_ok="" p_ok="" u_default=""
70
case $mode in
71
'') mode=-w ;;
72
-w) ;;
73
*) mode=x ;;
74
esac
75
;;
76
p) r_ok="" w_ok=""
77
case $mode in
78
'') mode=-rw ;;
79
-rw) ;;
80
*) mode=x ;;
81
esac
82
;;
83
r) w_ok="" p_ok="" options="$options -i" ;;
84
t) w_ok="" p_ok="" list="1" ;;
85
u) w_ok="" u_default="" ;;
86
B) blocksize=5k ;;
87
L) logphys=-L ;;
88
C) case $OPTARG in
89
*[0-9]) blocksize=${OPTARG}c ;;
90
*) blocksize=${OPTARG} ;;
91
esac
92
;;
93
H) case $OPTARG in
94
asc|ASC) format=asc ;;
95
crc|CRC) format=aschk ;;
96
odc|ODC) format=cpio ;;
97
tar|TAR) format=tar ;;
98
ustar|USTAR) format=ustar ;;
99
*) print -u2 "$command: $OPTARG: formats are {asc,crc,odc,tar,star}"; exit 1 ;;
100
esac
101
;;
102
I) w_ok="" p_ok="" options="$options -f '$OPTARG'" ;;
103
O) r_ok="" p_ok="" options="$options -f '$OPTARG'" ;;
104
M) options="$options -o eom=\"'$OPTARG'\"" ;;
105
esac
106
done
107
shift $(($OPTIND-1))
108
case $mode in
109
-r) case $r_ok in
110
"") print -u2 "$command: options inconsistent with archive read"
111
exit 2
112
;;
113
esac
114
options="$options -b $blocksize"
115
;;
116
-w) case $w_ok in
117
"") print -u2 "$command: options inconsistent with archive write"
118
exit 2
119
;;
120
esac
121
case $# in
122
0) ;;
123
*) print "$command: arguments not expected"
124
exit 2
125
;;
126
esac
127
options="$options -x $format -b $blocksize"
128
d_default="" m_default="" u_default=""
129
;;
130
-rw) case $p_ok in
131
"") print -u2 "$command: options inconsistent with file pass"
132
exit 2
133
;;
134
esac
135
case $# in
136
1) ;;
137
*) print -u2 "$command: a single directory argument is expected$usage"
138
exit 2
139
;;
140
esac
141
;;
142
'') print -u2 "$command: one of -i, -o, -p must be specified$usage"
143
exit 2
144
;;
145
*) print -u2 "$command: only one of -i, -o, -p may be specified$usage"
146
exit 2
147
;;
148
esac
149
150
case $list in
151
"1") mode="" d_default="" m_default="" u_default="" ;;
152
esac
153
154
case $exec in
155
eval) $exec pax $mode $logphys $options $d_default $m_default $u_default '"$@"' ;;
156
*) $exec pax $mode $logphys $options $d_default $m_default $u_default "$@" ;;
157
esac
158
159