Home | History | Annotate | Download | only in scripts
      1 #!/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 # ident	"%Z%%M%	%I%	%E% SMI"
     25 #
     26 # Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
     27 # Use is subject to license terms.
     28 #
     29 # Source drop generator.
     30 #
     31 
     32 PATH=$(dirname $(whence $0)):$PATH
     33 export PATH
     34 
     35 tmpdir=$(mktemp -dt sdropXXXXX)
     36 
     37 cleanup() {
     38 	[ -n "$tmpdir" ] && rm -rf $tmpdir
     39 }
     40 
     41 fail() {
     42 	echo $*
     43 	cleanup
     44 	exit 1
     45 }
     46 
     47 [ -n "$CODEMGR_WS" ] || fail "Please define CODEMGR_WS."
     48 [ -n "$tmpdir" ] || fail "Can't create temp directory."
     49 
     50 tarfile=$CODEMGR_WS/on-src.tar
     51 
     52 cd $CODEMGR_WS
     53 which_scm | read SCM_TYPE junk || exit 1
     54 
     55 #
     56 # Copy anything that's registered with source control, except for deleted files,
     57 # into a temp directory.  Then tar that up.
     58 #
     59 case "$SCM_TYPE" in
     60 mercurial)
     61 	hg locate -X deleted_files/ | cpio -pd $tmpdir
     62 	;;
     63 teamware)
     64 	find usr/src -name 's\.*' -a -type f -print | \
     65     	sed -e 's,SCCS\/s.,,' | \
     66     	grep -v '/\.del-*' | \
     67     	cpio -pd $tmpdir
     68 	;;
     69 unknown)
     70 	fail "Unknown type of SCM in use."
     71 	;;
     72 *)
     73 	fail "Unsupported SCM type: $SCM_TYPE"
     74 	;;
     75 esac
     76 [ $? -eq 0 ] || fail "Couldn't populate temp directory $tmpdir."
     77 
     78 cp README.opensolaris $tmpdir || fail "Couldn't copy README.opensolaris."
     79 
     80 (cd $tmpdir; tar cf $tarfile .) || fail "Couldn't create $tarfile."
     81 bzip2 -f $tarfile || fail "Couldn't bzip2 $tarfile."
     82 
     83 cleanup
     84