405
|
1 |
#!/bin/sh
|
|
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 |
#
|
415
|
9 |
# You can obtain a copy of the license at src/OPENSOLARIS.LICENSE
|
405
|
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
|
415
|
15 |
# file and include the License file at src/OPENSOLARIS.LICENSE.
|
405
|
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 |
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
|
|
24 |
# Use is subject to license terms.
|
|
25 |
#
|
|
26 |
|
|
27 |
#
|
|
28 |
# Common script to unpack various source archives
|
|
29 |
#
|
450
|
30 |
# Arguments:
|
|
31 |
# $1 archive name
|
|
32 |
# $2 directory created from the archive
|
|
33 |
# $3 optional final directory name
|
|
34 |
#
|
405
|
35 |
FIND=${FIND:-/bin/find}
|
|
36 |
XARGS=${XARGS:-/bin/xargs}
|
|
37 |
CHMOD=${CHMOD:-/bin/chmod}
|
450
|
38 |
MV=${MV:-/usr/bin/mv}
|
405
|
39 |
|
|
40 |
case "${1}" in
|
|
41 |
*.bz2)
|
|
42 |
COMMAND=${BZIP:-/usr/bin/bzip2}
|
|
43 |
COMMAND="${COMMAND} ${DECOMP_OPTS:--dc} ${1}"
|
|
44 |
;;
|
|
45 |
*.gz)
|
|
46 |
COMMAND=${GZIP:-/usr/bin/gzip}
|
|
47 |
COMMAND="${COMMAND} ${DECOMP_OPTS:--dc} ${1}"
|
|
48 |
;;
|
|
49 |
*.Z)
|
|
50 |
COMMAND=${ZCAT:-/usr/bin/zcat}
|
|
51 |
COMMAND="${COMMAND} ${1}"
|
|
52 |
;;
|
|
53 |
*.zip)
|
|
54 |
COMMAND=${UNZIP:-/usr/bin/unzip}
|
|
55 |
COMMAND="${COMMAND} ${DECOMP_OPTS:--qo} ${1}"
|
|
56 |
;;
|
|
57 |
esac
|
|
58 |
|
|
59 |
case "${1}" in
|
|
60 |
*.tar.*)
|
|
61 |
COMMAND="${COMMAND} | ${TAR:-/usr/bin/tar}"
|
|
62 |
COMMAND="${COMMAND} ${TAR_OPTS:-oxpf} -"
|
|
63 |
;;
|
|
64 |
esac
|
|
65 |
|
|
66 |
/bin/sh -c "${COMMAND}"
|
|
67 |
|
450
|
68 |
if [ $# -ge 2 -a -d "${2}" ] ; then
|
|
69 |
${FIND} "${2}" -type d | ${XARGS} -i ${CHMOD} 0755 "{}"
|
|
70 |
${FIND} "${2}" -type f | ${XARGS} -i ${CHMOD} a+r "{}"
|
405
|
71 |
fi
|
450
|
72 |
|
|
73 |
if [ $# -eq 3 -a -d "${2}" -a ! -d "${3}" ] ; then
|
|
74 |
${MV} -f "${2}" "${3}"
|
|
75 |
fi
|