1 #! /usr/bin/ksh -p 2 # 3 # CDDL HEADER START 4 # 5 # The contents of this file are subject to the terms of the 6 # Common Development and Distribution License (the "License"). 7 # You may not use this file except in compliance with the License. 8 # 9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 # or http://www.opensolaris.org/os/licensing. 11 # See the License for the specific language governing permissions 12 # and limitations under the License. 13 # 14 # When distributing Covered Code, include this CDDL HEADER in each 15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 # If applicable, add the following below this CDDL HEADER, with the 17 # fields enclosed by brackets "[]" replaced with your own identifying 18 # information: Portions Copyright [yyyy] [name of copyright owner] 19 # 20 # CDDL HEADER END 21 # 22 23 # 24 # Copyright 2008 Sun Microsystems, Inc. All rights reserved. 25 # Use is subject to license terms. 26 # 27 #ident "%Z%%M% %I% %E% SMI" 28 # 29 # Create an encumbered binaries tarball from a full build proto area, 30 # less the contents of an OpenSolaris proto area. Special handling 31 # for crypto binaries that need to be signed by Sun Release 32 # Engineering. 33 # 34 35 usage="bindrop [-n] full-root open-root basename" 36 37 isa=`uname -p` 38 if [[ "$isa" = sparc ]]; then 39 isa_short=s 40 else 41 isa_short=x 42 fi 43 44 # 45 # Crypto related binaries need to be signed in order to be loaded. 46 # We pull the ongk signed binaries from the gate machine's build 47 # at the path below so that the closed-bins tarballs are kept in sync 48 # with what we're actually delivering. We default to pulling out of 49 # nightly, but if CRYPTO_BINS_PATH is set, then we pull from that path 50 # instead. This allows us to override with something like 51 # /ws/onnv-gate/packages/$isa/snv_XX instead. 52 # 53 gatepkgs=${CRYPTO_BINS_PATH:-"/ws/onnv-gate/packages/$isa/nightly"} 54 55 PATH="$PATH:/usr/bin:/usr/sfw/bin" 56 57 function fail { 58 print -u2 "bindrop: $@" 59 exit 1 60 } 61 62 function warn { 63 print -u2 "bindrop: warning: $@" 64 } 65 66 [[ -n "$SRC" ]] || fail "SRC must be set." 67 [[ -n "$CODEMGR_WS" ]] || fail "CODEMGR_WS must be set." 68 69 # 70 # Create the README from boilerplate and the contents of the closed 71 # binary tree. 72 # 73 # usage: mkreadme targetdir 74 # 75 function mkreadme { 76 typeset targetdir="$1" 77 typeset readme="README.ON-BINARIES.$isa" 78 79 sed -e s/@ISA@/$isa/ -e s/@DELIVERY@/ON-BINARIES/ \ 80 "$SRC/tools/opensolaris/README.binaries.tmpl" > "$targetdir/$readme" 81 (cd "$targetdir"; find "$rootdir" -type f -print | \ 82 sort >> "$targetdir/$readme") 83 } 84 85 nondebug=n 86 while getopts n flag; do 87 case $flag in 88 n) 89 nondebug=y 90 ;; 91 ?) 92 print -u2 "usage: $usage" 93 exit 1 94 ;; 95 esac 96 done 97 shift $(($OPTIND - 1)) 98 99 if [[ $# -ne 3 ]]; then 100 print -u2 "usage: $usage" 101 exit 1 102 fi 103 104 full="$1" 105 open="$2" 106 tarfile="$CODEMGR_WS/$3.$isa.tar" 107 108 rootdir="root_$isa" 109 if [[ "$nondebug" = y ]]; then 110 rootdir="root_$isa-nd" 111 gatepkgs="$gatepkgs-nd" 112 fi 113 114 [[ -d "$gatepkgs" ]] || fail "can't find gate's crypto packages ($gatepkgs)." 115 [[ -d "$full" ]] || fail "can't find $full." 116 [[ -d "$open" ]] || fail "can't find $open." 117 118 tmpdir=$(mktemp -dt bindropXXXXX) 119 [[ -n "$tmpdir" ]] || fail "can't create temporary directory." 120 mkdir -p "$tmpdir/closed/$rootdir" || exit 1 121 122 # 123 # This will hold a temp list of directories that must be kept, even if 124 # empty. 125 # 126 needdirs=$(mktemp -t needdirsXXXXX) 127 [[ -n "$needdirs" ]] || fail "can't create temporary directory list file." 128 129 # 130 # Copy the full tree into a temp directory. 131 # 132 (cd "$full"; tar cf - .) | (cd "$tmpdir/closed/$rootdir"; tar xpf -) 133 134 # 135 # Remove internal ON crypto signing certs 136 # 137 delete=" 138 etc/certs/SUNWosnetSE 139 etc/certs/SUNWosnetSolaris 140 etc/crypto/certs/SUNWosnet 141 etc/crypto/certs/SUNWosnetLimited 142 etc/crypto/certs/SUNWosnetCF 143 etc/crypto/certs/SUNWosnetCFLimited 144 " 145 146 # 147 # Remove miscellaneous files that we don't want to ship. 148 # 149 150 # SUNWsvvs (SVVS test drivers). 151 delete="$delete 152 usr/include/sys/lo.h 153 usr/include/sys/tidg.h 154 usr/include/sys/tivc.h 155 usr/include/sys/tmux.h 156 usr/kernel/drv/amd64/lo 157 usr/kernel/drv/amd64/tidg 158 usr/kernel/drv/amd64/tivc 159 usr/kernel/drv/amd64/tmux 160 usr/kernel/drv/lo 161 usr/kernel/drv/lo.conf 162 usr/kernel/drv/sparcv9/lo 163 usr/kernel/drv/sparcv9/tidg 164 usr/kernel/drv/sparcv9/tivc 165 usr/kernel/drv/sparcv9/tmux 166 usr/kernel/drv/tidg 167 usr/kernel/drv/tidg.conf 168 usr/kernel/drv/tivc 169 usr/kernel/drv/tivc.conf 170 usr/kernel/drv/tmux 171 usr/kernel/drv/tmux.conf 172 usr/kernel/strmod/amd64/lmodb 173 usr/kernel/strmod/amd64/lmode 174 usr/kernel/strmod/amd64/lmodr 175 usr/kernel/strmod/amd64/lmodt 176 usr/kernel/strmod/lmodb 177 usr/kernel/strmod/lmode 178 usr/kernel/strmod/lmodr 179 usr/kernel/strmod/lmodt 180 usr/kernel/strmod/sparcv9/lmodb 181 usr/kernel/strmod/sparcv9/lmode 182 usr/kernel/strmod/sparcv9/lmodr 183 usr/kernel/strmod/sparcv9/lmodt 184 " 185 # encumbered binaries and associated files 186 delete="$delete 187 etc/smartcard/ 188 kernel/drv/amd64/audioens 189 kernel/drv/amd64/bmc 190 kernel/drv/amd64/pcn 191 kernel/drv/audioens 192 kernel/drv/audioens.conf 193 kernel/drv/bmc 194 kernel/drv/bmc.conf 195 kernel/drv/ifp.conf 196 kernel/drv/pcn 197 kernel/drv/pcn.conf 198 kernel/drv/sparcv9/audioens 199 kernel/drv/sparcv9/ifp 200 kernel/drv/sparcv9/isp 201 kernel/drv/spwr 202 kernel/drv/spwr.conf 203 kernel/kmdb/sparcv9/isp 204 kernel/misc/amd64/phx 205 kernel/misc/phx 206 kernel/misc/sparcv9/phx 207 platform/SUNW,Sun-Blade-100/kernel/drv/grppm.conf 208 platform/SUNW,Sun-Blade-100/kernel/drv/sparcv9/grfans 209 platform/SUNW,Sun-Blade-100/kernel/drv/sparcv9/grppm 210 platform/sun4u/kernel/misc/sparcv9/i2c_svc 211 usr/bin/ksh 212 usr/bin/pfksh 213 usr/bin/rksh 214 usr/bin/smartcard 215 usr/ccs/bin/dis 216 usr/include/smartcard/ 217 usr/include/sys/audio/audioens.h 218 usr/include/sys/phx.h 219 usr/include/sys/scsi/adapters/ifpcmd.h 220 usr/include/sys/scsi/adapters/ifpio.h 221 usr/include/sys/scsi/adapters/ifpmail.h 222 usr/include/sys/scsi/adapters/ifpreg.h 223 usr/include/sys/scsi/adapters/ifpvar.h 224 usr/include/sys/scsi/adapters/ispcmd.h 225 usr/include/sys/scsi/adapters/ispmail.h 226 usr/include/sys/scsi/adapters/ispreg.h 227 usr/include/sys/scsi/adapters/ispvar.h 228 usr/lib/amd64/libsmartcard.so.1 229 usr/lib/amd64/libsmartcard.so 230 usr/lib/amd64/llib-lsmartcard.ln 231 usr/lib/libsmartcard.so.1 232 usr/lib/libsmartcard.so 233 usr/lib/llib-lsmartcard.ln 234 usr/lib/llib-lsmartcard 235 usr/lib/locale/C/LC_MESSAGES/libsmartcard.msg 236 usr/lib/mdb/disasm/sparc.so 237 usr/lib/mdb/disasm/sparcv9/sparc.so 238 usr/lib/mdb/kvm/sparcv9/isp.so 239 usr/lib/security/amd64/pam_smartcard.so.1 240 usr/lib/security/amd64/pam_smartcard.so 241 usr/lib/security/pam_smartcard.so.1 242 usr/lib/security/pam_smartcard.so 243 usr/lib/security/sparcv9/pam_smartcard.so.1 244 usr/lib/security/sparcv9/pam_smartcard.so 245 usr/lib/smartcard/ 246 usr/lib/sparcv9/libsmartcard.so.1 247 usr/lib/sparcv9/libsmartcard.so 248 usr/lib/sparcv9/llib-lsmartcard.ln 249 usr/platform/SUNW,Netra-T12/ 250 usr/platform/sun4u/include/sys/i2c/misc/i2c_svc.h 251 usr/platform/sun4u/include/sys/memtestio.h 252 usr/platform/sun4u/include/sys/memtestio_ch.h 253 usr/platform/sun4u/include/sys/memtestio_chp.h 254 usr/platform/sun4u/include/sys/memtestio_ja.h 255 usr/platform/sun4u/include/sys/memtestio_jg.h 256 usr/platform/sun4u/include/sys/memtestio_sf.h 257 usr/platform/sun4u/include/sys/memtestio_sr.h 258 usr/platform/sun4u/include/sys/memtestio_u.h 259 usr/platform/sun4u/include/sys/memtestio_pn.h 260 usr/platform/sun4v/include/sys/memtestio.h 261 usr/platform/sun4v/include/sys/memtestio_ni.h 262 usr/platform/sun4v/include/sys/memtestio_v.h 263 usr/sbin/ocfserv 264 usr/share/javadoc/smartcard/ 265 usr/share/lib/smartcard/ 266 usr/share/lib/sgml/locale/C/dtds/docbook/docbook.dtd 267 usr/share/lib/sgml/locale/C/dtds/docbook/ 268 usr/share/lib/sgml/locale/C/dtds/solbookv1/solbook.dtd 269 usr/share/lib/sgml/locale/C/dtds/solbookv1/ 270 var/svc/manifest/network/rpc/ocfserv.xml 271 " 272 # memory fault injector test framework 273 delete="$delete 274 usr/bin/mtst 275 platform/sun4u/kernel/drv/sparcv9/memtest 276 platform/sun4u/kernel/drv/memtest.conf 277 platform/sun4v/kernel/drv/sparcv9/memtest 278 platform/sun4v/kernel/drv/memtest.conf 279 platform/i86pc/kernel/drv/memtest.conf 280 platform/i86pc/kernel/drv/memtest 281 platform/i86pc/kernel/drv/amd64/memtest 282 usr/platform/i86pc/lib/mtst/mtst_AuthenticAMD_15.so 283 " 284 # pci test tool 285 delete="$delete 286 usr/share/man/man1m/pcitool.1m 287 usr/sbin/pcitool 288 " 289 for f in $delete; do 290 rm -rf "$tmpdir/closed/$rootdir/$f" 291 done 292 293 # 294 # Remove files that the open tree already has. 295 # 296 (cd "$open"; find . -type f -print -o -type l -print) > "$tmpdir/deleteme" 297 (cd "$tmpdir/closed/$rootdir"; cat "$tmpdir/deleteme" | xargs rm -f) 298 299 # 300 # Remove any header files. If they're in the closed tree, they're 301 # probably not freely redistributable. 302 # 303 (cd "$tmpdir/closed/$rootdir"; find . -name \*.h -exec rm -f {} \;) 304 305 # 306 # Remove empty directories that the open tree doesn't need. 307 # 308 # Step 1: walk the usr/src/pkgdefs files to find out which directories 309 # are specified in the open packages; save that list to a temporary 310 # file $needdirs. 311 # 312 (cd "$SRC/pkgdefs"; \ 313 find . -name prototype\* -exec grep "^d" {} \; | awk '{print $3}' > \ 314 "$needdirs") 315 # 316 # Step 2: go to our closed directory, and find all the subdirectories, 317 # filtering out the ones needed by the open packages (saved in that 318 # temporary file). Sort in reverse order, so that parent directories 319 # come after any subdirectories, and pipe that to rmdir. If there are 320 # still any lingering files, rmdir will complain. That's fine--we 321 # only want to delete empty directories--so redirect the complaints to 322 # /dev/null. 323 # 324 (cd "$tmpdir/closed/$rootdir"; \ 325 find * -type d -print | /usr/xpg4/bin/grep -xv -f $needdirs | \ 326 sort -r | xargs -l rmdir 2>/dev/null ) 327 328 rm "$needdirs" 329 330 # 331 # Up above we removed the files that were already in the open tree. 332 # But that blew away the minimal closed binaries that are needed to do 333 # an open build, so restore them here. 334 # 335 336 mkclosed "$isa" "$full" "$tmpdir/closed/$rootdir" || \ 337 fail "can't restore minimal binaries." 338 339 # 340 # Replace the crypto binaries with ones that have been signed by ongk. 341 # Get these from onnv-gate's nightly build 342 # 343 344 # List of files to copy, in the form "pkgname file [file ...]" 345 # common files 346 cfiles=" 347 SUNWcsl 348 usr/lib/security/pkcs11_kernel.so.1 349 usr/lib/security/pkcs11_softtoken.so.1 350 " 351 # sparc-only 352 csfiles=" 353 SUNWcakr.u 354 platform/sun4u-us3/kernel/crypto/sparcv9/aes 355 platform/sun4u/kernel/crypto/sparcv9/arcfour 356 platform/sun4u/kernel/crypto/sparcv9/des 357 SUNWcakr.v 358 platform/sun4v/kernel/drv/sparcv9/ncp 359 SUNWckr 360 kernel/crypto/sparcv9/aes 361 kernel/crypto/sparcv9/arcfour 362 kernel/crypto/sparcv9/blowfish 363 kernel/crypto/sparcv9/des 364 SUNWcsl 365 usr/lib/security/sparcv9/pkcs11_kernel.so.1 366 usr/lib/security/sparcv9/pkcs11_softtoken.so.1 367 SUNWdcar 368 kernel/drv/sparcv9/dca 369 SUNWn2cp.v 370 platform/sun4v/kernel/drv/sparcv9/n2cp 371 " 372 # x86-only 373 cxfiles=" 374 SUNWckr 375 kernel/crypto/aes 376 kernel/crypto/arcfour 377 kernel/crypto/blowfish 378 kernel/crypto/des 379 kernel/crypto/amd64/aes 380 kernel/crypto/amd64/arcfour 381 kernel/crypto/amd64/blowfish 382 kernel/crypto/amd64/des 383 SUNWcsl 384 usr/lib/security/amd64/pkcs11_kernel.so.1 385 usr/lib/security/amd64/pkcs11_softtoken.so.1 386 SUNWdcar 387 kernel/drv/dca 388 kernel/drv/amd64/dca 389 " 390 # These all have hard links from crypto/foo to misc/foo. 391 linkedfiles=" 392 platform/sun4u/kernel/crypto/sparcv9/des 393 kernel/crypto/des 394 kernel/crypto/amd64/des 395 kernel/crypto/sparcv9/des 396 " 397 398 if [[ "$isa" = sparc ]]; then 399 cfiles="$cfiles $csfiles" 400 else 401 cfiles="$cfiles $cxfiles" 402 fi 403 404 # Copy $pkgfiles from the gate's build for $pkg 405 function pkgextract 406 { 407 [[ -d "$gatepkgs/$pkg" ]] || fail "$gatepkgs/$pkg doesn't exist." 408 if [[ -n "$pkg" && -n "$pkgfiles" ]]; then 409 (cd "$gatepkgs/$pkg/reloc" && tar cf - $pkgfiles) | \ 410 (cd "$tmpdir/closed/$rootdir"; tar xf - ) 411 # Doesn't look like we can rely on $? here. 412 for f in $pkgfiles; do 413 [[ -f "$tmpdir/closed/$rootdir/$f" ]] || 414 warn "couldn't find $f in $gatepkgs/$pkg" 415 done 416 fi 417 } 418 419 pkg="" 420 pkgfiles="" 421 for cf in $cfiles; do 422 if [[ "$cf" = SUNW* ]]; then 423 pkgextract 424 pkg="$cf" 425 pkgfiles="" 426 continue 427 else 428 pkgfiles="$pkgfiles $cf" 429 fi 430 done 431 pkgextract # last package in $cfiles 432 433 # Patch up the crypto hard links. 434 for f in $linkedfiles; do 435 [[ -f "$tmpdir/closed/$rootdir/$f" ]] || continue 436 link=$(print $f | sed -e s=crypto=misc=) 437 (cd "$tmpdir/closed/$rootdir"; rm "$link"; ln "$f" "$link") 438 done 439 440 # 441 # Add binary license files. 442 # 443 444 cp -p "$SRC/tools/opensolaris/BINARYLICENSE.txt" "$tmpdir/closed" || \ 445 fail "can't add BINARYLICENSE.txt" 446 mkreadme "$tmpdir/closed" 447 cp -p "$CODEMGR_WS/THIRDPARTYLICENSE.ON-BINARIES" "$tmpdir/closed" || \ 448 fail "can't add THIRDPARTYLICENSE.ON-BINARIES." 449 450 (cd "$tmpdir"; tar cf "$tarfile" closed) || fail "can't create $tarfile." 451 bzip2 -f "$tarfile" || fail "can't compress $tarfile". 452 453 rm -rf "$tmpdir" 454 455 exit 0 456