tools/cloney
author Craig Mohrman <craig.mohrman@oracle.com>
Fri, 18 Apr 2014 11:03:12 -0700
branchs11u1-sru
changeset 3086 649b12aa87ce
parent 198 172fc01ce997
child 5240 6c0884f75bd9
permissions -rwxr-xr-x
17362112 problem in UTILITY/PHP 18083695 problem in UTILITY/PHP 18181920 remove BUILD_VERSION from php package manifests 18368537 problem in UTILITY/PHP 18368630 problem in UTILITY/PHP
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
61
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
     1
#!/bin/ksh
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
     2
#
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
     3
# CDDL HEADER START
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
     4
#
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
     5
# The contents of this file are subject to the terms of the
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
     6
# Common Development and Distribution License (the "License").
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
     7
# You may not use this file except in compliance with the License.
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
     8
#
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
     9
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    10
# or http://www.opensolaris.org/os/licensing.
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    11
# See the License for the specific language governing permissions
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    12
# and limitations under the License.
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    13
#
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    14
# When distributing Covered Code, include this CDDL HEADER in each
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    15
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    16
# If applicable, add the following below this CDDL HEADER, with the
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    17
# fields enclosed by brackets "[]" replaced with your own identifying
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    18
# information: Portions Copyright [yyyy] [name of copyright owner]
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    19
#
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    20
# CDDL HEADER END
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    21
#
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    22
# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    23
#
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    24
# clone a directory to another using symlinks, in a very clunky way
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    25
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    26
if [ $# != 2 ]; then
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    27
	echo "usage $0 srcdir destdir"
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    28
	exit 1
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    29
fi
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    30
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    31
srcdir=$1
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    32
destdir=$2
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    33
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    34
PATH=/usr/bin
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    35
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    36
echo symlink cloning $srcdir to $destdir
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    37
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    38
cd ${srcdir}
116
ae6a90899b42 7022452 move ant to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents: 61
diff changeset
    39
gfind . -type d | \
61
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    40
    grep -v '^.$' | \
198
172fc01ce997 7016732 move vim from sfw to userland
Danek Duvall <danek.duvall@oracle.com>
parents: 179
diff changeset
    41
    gsed -e 's,^\./,,' | \
116
ae6a90899b42 7022452 move ant to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents: 61
diff changeset
    42
    while read i;
61
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    43
do
116
ae6a90899b42 7022452 move ant to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents: 61
diff changeset
    44
	mkdir -p "${destdir}/$i"
61
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    45
done
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    46
198
172fc01ce997 7016732 move vim from sfw to userland
Danek Duvall <danek.duvall@oracle.com>
parents: 179
diff changeset
    47
# Copy files and symlinks, making sure we ignore the gnu-patch backup
172fc01ce997 7016732 move vim from sfw to userland
Danek Duvall <danek.duvall@oracle.com>
parents: 179
diff changeset
    48
# files, too.
179
ca3935296621 7035000 cloney doesn't clone 'symlinks' to the destination directory
sonam gupta - Sun Microsystems - Bangalore India <Sonam.Gupta@Sun.COM>
parents: 116
diff changeset
    49
gfind . -type f -o -type l | \
198
172fc01ce997 7016732 move vim from sfw to userland
Danek Duvall <danek.duvall@oracle.com>
parents: 179
diff changeset
    50
    egrep -v '~[0-9]+~' | \
172fc01ce997 7016732 move vim from sfw to userland
Danek Duvall <danek.duvall@oracle.com>
parents: 179
diff changeset
    51
    gsed -e 's,^\./,,' | \
116
ae6a90899b42 7022452 move ant to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents: 61
diff changeset
    52
    while read i;
61
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    53
do
116
ae6a90899b42 7022452 move ant to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents: 61
diff changeset
    54
	rm -f "${destdir}/$i"
ae6a90899b42 7022452 move ant to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents: 61
diff changeset
    55
	ln -s "${srcdir}/$i" "${destdir}/$i"
61
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    56
done