blob: 2987b485ca17a8990bbab6c5c4f74a9b1158cb79 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2010 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Create a tarball with crypto binaries.
#
usage="cryptodrop [-n] result-path"
isa=`uname -p`
function fail {
print -u2 "cryptodrop: $@"
exit 1
}
[[ -n "$ROOT" ]] || fail "ROOT must be set."
# Verify below (after adjusting for -n) that $ROOT exists, is a directory.
[[ -n "$SRC" ]] || fail "SRC must be set."
[[ -d "$SRC" ]] || fail "SRC ($SRC) is not a directory."
[[ -n "$CODEMGR_WS" ]] || fail "CODEMGR_WS must be set."
[[ -d "$CODEMGR_WS" ]] || fail "CODEMGR_WS ($CODEMGR_WS) is not a directory."
#
# Wrapper over cpio to filter out "NNN blocks" messages.
#
function cpio_filt {
integer cpio_stat
cpio "$@" > "$cpio_log" 2>&1
cpio_stat=$?
cat "$cpio_log" | awk '$0 !~ /[0-9]+ blocks/ { print }'
return $cpio_stat
}
#
# Create the README from boilerplate and the contents of the closed
# binary tree.
#
# usage: mkreadme targetdir
#
function mkreadme {
typeset targetdir="$1"
typeset readme="README.CRYPTO-BINARIES.$isa"
sed -e s/@ISA@/$isa/ -e s/@DELIVERY@/CRYPTO-BINARIES/ \
"$SRC/tools/opensolaris/README.binaries.tmpl" > "$targetdir/$readme"
(cd "$targetdir"; find "$rootdir" -type f -print | \
sort >> "$targetdir/$readme")
}
nondebug=n
while getopts n flag; do
case $flag in
n)
nondebug=y
if [ "$MULTI_PROTO" = yes ]; then
export ROOT="$ROOT-nd"
fi
;;
?)
print -u2 "usage: $usage"
exit 1
;;
esac
done
shift $(($OPTIND - 1))
if [[ $# -ne 1 ]]; then
print -u2 "usage: $usage"
exit 1
fi
[[ -d "$ROOT" ]] || fail "ROOT ($ROOT) is not a directory."
tarfile="$1"
if [[ "$nondebug" = n ]]; then
rootdir="root_$isa"
else
rootdir="root_$isa-nd"
fi
tmpdir=$(mktemp -dt cryptodropXXXXX)
[[ -n "$tmpdir" ]] || fail "could not create temporary directory."
tmproot="$tmpdir/proto/$rootdir"
mkdir -p "$tmproot" || exit 1
cpio_log="$tmpdir/cpio.log"
filelist="$tmpdir/files"
#
# Copy the crypto binaries into a temp directory. This is a bit messy
# because we want to preserve the permissions of intermediate
# directories without including all the contents of those
# directories.
#
# Echo all the parent directories of the given file.
function alldirs {
d=$(dirname "$1")
while [ "$d" != . ]; do
echo $d
d=$(dirname "$d")
done
}
findcrypto "$SRC/tools/codesign/creds" | awk '{ print $2 }' > "$filelist"
#
# Both alldirs and the cpio -p invocation assume that findcrypto only
# produces relative paths.
#
for f in $(cat "$filelist"); do
if [[ "$f" = /* ]]; then
fail "findcrypto produced absolute path ($f)"
fi
done
for f in $(cat "$filelist"); do
echo "$f"
alldirs "$f"
done | sort -u | (cd "$ROOT"; cpio_filt -pdm "$tmproot")
[[ $? -eq 0 ]] || fail "could not copy crypto files."
rm -f "$cpio_log" "$filelist"
#
# Insert binary license files.
#
cp -p "$SRC/tools/opensolaris/BINARYLICENSE.txt" "$tmpdir/proto" || \
fail "could not add BINARYLICENSE.txt"
mkreadme "$tmpdir/proto" || exit 1
cp -p "$CODEMGR_WS/THIRDPARTYLICENSE.ON-CRYPTO" "$tmpdir/proto" || \
fail "could not add THIRDPARTYLICENSE.ON-CRYPTO."
(cd "$tmpdir"; tar cf "$tarfile" proto) || fail "could not create $tarfile."
bzip2 -f "$tarfile" || fail "could not compress $tarfile".
rm -rf "$tmpdir"
exit 0
|