tools/cloney
author Petr Sumbera <petr.sumbera@oracle.com>
Mon, 14 Feb 2011 01:11:45 -0800
changeset 85 8098282b503b
parent 61 7684fe2a9eb5
child 116 ae6a90899b42
permissions -rwxr-xr-x
7018226 move GNU screen to userland
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}
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    39
for i in `gfind . -type d | \
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    40
    grep -v '^.$' | \
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    41
    gsed -e 's,^./,,'`
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    42
do
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    43
	mkdir -p ${destdir}/$i
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    44
done
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    45
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    46
for i in `gfind . -type f | \
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    47
    gsed -e 's,^./,,'`
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    48
do
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    49
	rm -f ${destdir}/$i
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    50
	ln -s ${srcdir}/$i ${destdir}/$i
7684fe2a9eb5 7011958 some things lost during move to userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    51
done