tools/unpack-archive
author hnhn
Tue, 15 Sep 2009 11:03:17 +0200
changeset 415 02da8ebe6414
parent 405 c601bc5ddd76
child 450 13efd215ca04
permissions -rwxr-xr-x
6865254 Include SIL's OFL-licensed fonts
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
405
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
     1
#!/bin/sh
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
     2
#
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
     3
# CDDL HEADER START
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
     4
#
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
     5
# The contents of this file are subject to the terms of the
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
     6
# Common Development and Distribution License (the "License").
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
     7
# You may not use this file except in compliance with the License.
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
     8
#
415
02da8ebe6414 6865254 Include SIL's OFL-licensed fonts
hnhn
parents: 405
diff changeset
     9
# You can obtain a copy of the license at src/OPENSOLARIS.LICENSE
405
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    10
# or http://www.opensolaris.org/os/licensing.
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    11
# See the License for the specific language governing permissions
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    12
# and limitations under the License.
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    13
#
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    14
# When distributing Covered Code, include this CDDL HEADER in each
415
02da8ebe6414 6865254 Include SIL's OFL-licensed fonts
hnhn
parents: 405
diff changeset
    15
# file and include the License file at src/OPENSOLARIS.LICENSE.
405
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    16
# If applicable, add the following below this CDDL HEADER, with the
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    17
# fields enclosed by brackets "[]" replaced with your own identifying
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    18
# information: Portions Copyright [yyyy] [name of copyright owner]
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    19
#
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    20
# CDDL HEADER END
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    21
#
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    22
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    23
# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    24
# Use is subject to license terms.
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    25
#
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    26
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    27
#
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    28
# Common script to unpack various source archives
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    29
#
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    30
FIND=${FIND:-/bin/find}
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    31
XARGS=${XARGS:-/bin/xargs}
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    32
CHMOD=${CHMOD:-/bin/chmod}
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    33
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    34
case "${1}" in
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    35
	*.bz2)
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    36
		COMMAND=${BZIP:-/usr/bin/bzip2}
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    37
		COMMAND="${COMMAND} ${DECOMP_OPTS:--dc} ${1}"
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    38
		;;
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    39
	*.gz)
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    40
		COMMAND=${GZIP:-/usr/bin/gzip}
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    41
		COMMAND="${COMMAND} ${DECOMP_OPTS:--dc} ${1}"
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    42
		;;
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    43
	*.Z)
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    44
		COMMAND=${ZCAT:-/usr/bin/zcat}
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    45
		COMMAND="${COMMAND} ${1}"
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    46
		;;
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    47
	*.zip)
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    48
		COMMAND=${UNZIP:-/usr/bin/unzip}
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    49
		COMMAND="${COMMAND} ${DECOMP_OPTS:--qo} ${1}"
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    50
		;;
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    51
esac
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    52
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    53
case "${1}" in
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    54
	*.tar.*)
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    55
		COMMAND="${COMMAND} | ${TAR:-/usr/bin/tar}"
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    56
		COMMAND="${COMMAND} ${TAR_OPTS:-oxpf} -"
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    57
		;;
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    58
esac
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    59
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    60
/bin/sh -c "${COMMAND}"
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    61
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    62
if [ $# -eq 2 -a -d "${2}" ] ; then
415
02da8ebe6414 6865254 Include SIL's OFL-licensed fonts
hnhn
parents: 405
diff changeset
    63
	${FIND} ${2} -type d | ${XARGS} -i ${CHMOD} 0755 "{}"
02da8ebe6414 6865254 Include SIL's OFL-licensed fonts
hnhn
parents: 405
diff changeset
    64
	${FIND} ${2} -type f | ${XARGS} -i ${CHMOD} a+r "{}"
405
c601bc5ddd76 added archive downloads to one location
hnhn
parents:
diff changeset
    65
fi