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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
|
#! /usr/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 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "%Z%%M% %I% %E% SMI"
#
#
# Create a set of BFU archives for posting, then deliver them as a
# tarball, including binary license files.
#
# usage: bfudrop [-n] open-proto closed-bins build-id
# -n extract non-debug closed binaries.
# (open-proto and build-id are not modified.)
# open-proto absolute path to open-only proto area.
# closed-bins name of closed-bins tarball (bzipped, in $CODEMGR_WS)
# build-ID identifier for the archives, e.g.,
# "nightly-osol".
#
usage="bfudrop [-n] open-proto closed-bins build-ID"
function fail {
print -u2 "bfudrop: $@"
exit 1
}
[[ -n "$SRC" ]] || fail "SRC must be set."
[[ -n "$CODEMGR_WS" ]] || fail "CODEMGR_WS must be set."
[[ -n "$CPIODIR" ]] || fail "CPIODIR must be set."
#
# Directory that we assemble everything in. Includes these
# subdirectories:
# tmp scratch directory
# root_$MACH combined proto area
# archives-<build-ID> copy of archives plus license files
#
stagedir=$(mktemp -dt bfudropXXXXX)
[[ -n "$stagedir" ]] || fail "can't create staging directory."
scratchdir="$stagedir/tmp"
cpio_log="$stagedir/cpio.log"
#
# 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
}
#
# Generate README.BFU-ARCHIVES.$MACH from boilerplate and the contents
# of the bfu archives.
# usage: cd archivedir; mkreadme destdir
#
function mkreadme {
destdir="$1"
readme="$destdir/README.BFU-ARCHIVES.$MACH"
sed -e s/@ISA@/$MACH/ -e s/@DELIVERY@/BFU-ARCHIVES/ \
"$SRC/tools/opensolaris/README.binaries.tmpl" > "$readme"
for f in *; do
print "==== $f ====" >> "$readme"
#
# The cpio table of contents includes directories, and
# we just want files. So unpack the cpio file into a
# temp directory, do a find(1) to get the table of
# contents, and remove the temp directory.
#
mkdir -p "$scratchdir" || fail "can't create $scratchdir."
case $f in
*.gz) cat=gzcat;;
*.Z) cat=zcat;;
*.bz2) cat=bzcat;;
*) cat=cat;;
esac
if ! $cat $f | (cd "$scratchdir"; cpio_filt -id); then
fail "can't get contents for $f"
fi
#
# "find *" will miss dot files, but we don't expect
# any. "find ." would catch them, but we'd have to
# clean up the resulting list (remove the "./").
#
(cd "$scratchdir"; find * -type f -print) | sort >> "$readme"
rm -rf "$scratchdir"
done
}
nondebug=n
while getopts n flag; do
case $flag in
n)
nondebug=y
;;
?)
print -u2 "usage: $usage"
exit 1
;;
esac
done
shift $(($OPTIND - 1))
if [[ $# -ne 3 ]]; then
print -u2 "usage: $usage"
exit 1
fi
srcroot="$1"
closedtb="$2"
build="$3"
subdir="archives-$build"
cpioparent="$(dirname $CPIODIR)"
export CPIODIR="$cpioparent/$build"
[[ -n "$MACH" ]] || MACH=$(uname -p)
export MACH
tarfile="$CODEMGR_WS/on-bfu-$build.$MACH.tar"
newproto="$stagedir/root_$MACH"
cd "$CODEMGR_WS"
[[ -d "$srcroot" ]] || fail "can't find $srcroot."
[[ -f "$closedtb" ]] || fail "can't find $closedtb."
#
# Copy the source proto area to a temp area and unpack the closed
# binaries on top. The source proto area is left alone so as not to
# break future incremental builds.
#
mkdir -p "$newproto" || fail "can't create $newproto."
(cd "$srcroot"; find . -depth -print | cpio_filt -pdm "$newproto")
[[ $? -eq 0 ]] || fail "can't copy original proto area."
mkdir -p "$scratchdir" || fail "can't create $scratchdir"
(cd "$scratchdir"; bzcat "$CODEMGR_WS/$closedtb" | tar xf -)
[[ $? -eq 0 ]] || fail "can't unpack closed binaries."
closed_root="$scratchdir/closed/root_$MACH"
[[ "$nondebug" = y ]] && closed_root="$closed_root-nd"
if [[ ! -d "$closed_root" ]]; then
fail "can't find $(basename $closed_root) in closed binaries."
fi
(cd "$closed_root"; find . -depth -print | cpio_filt -pdmu "$newproto")
[[ $? -eq 0 ]] || fail "can't copy closed binaries."
rm -rf "$scratchdir"
#
# Generate the actual archives.
#
ROOT="$newproto" makebfu
#
# Bundle up the archives and license files.
#
mkdir -p "$stagedir/$subdir/$MACH" || \
fail "can't create $stagedir/$subdir/$MACH."
archvdir=$CPIODIR
[[ -d "$archvdir" ]] || fail "can't find $archvdir."
# copy archives
(cd "$archvdir"; tar cf - .) | (cd "$stagedir/$subdir/$MACH"; tar xf -)
# Insert binary license files.
cp -p "$SRC/tools/opensolaris/BINARYLICENSE.txt" "$stagedir/$subdir" || \
fail "can't add BINARYLICENSE.txt"
(cd "$archvdir"; mkreadme "$stagedir/$subdir") || exit 1
cp -p "$CODEMGR_WS/THIRDPARTYLICENSE.BFU-ARCHIVES" "$stagedir/$subdir" || \
fail "can't add THIRDPARTYLICENSE.BFU-ARCHIVES."
(cd "$stagedir"; tar cf "$tarfile" "$subdir") || fail "can't create $tarfile."
bzip2 -f "$tarfile" || fail "can't compress $tarfile".
rm -rf "$stagedir"
exit 0
|