VirtualBox

source: vbox/trunk/tools/darwin.x86/bin/xcode-4.1-extrator.sh@ 77807

Last change on this file since 77807 was 69210, checked in by vboxsync, 7 years ago

tools: scm cleanups

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 4.9 KB
Line 
1#!/bin/bash
2# $Id: xcode-4.1-extrator.sh 69210 2017-10-24 13:38:47Z vboxsync $
3## @file
4# Extracts the necessary bits from the Xcode 4.1 lion package (inside installercode_41_lion.dmg).
5
6#
7# Copyright (C) 2014 Oracle Corporation
8#
9# This file is part of VirtualBox Open Source Edition (OSE), as
10# available from http://www.virtualbox.org. This file is free software;
11# you can redistribute it and/or modify it under the terms of the GNU
12# General Public License (GPL) as published by the Free Software
13# Foundation, in version 2 as it comes in the "COPYING" file of the
14# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16#
17
18#
19# Make sure we're talking the same language.
20#
21LC_ALL=C
22export LC_ALL
23
24#
25# Figure the tools/darwin.x86 location.
26#
27MY_DARWIN_DIR=`dirname "$0"`
28MY_DARWIN_DIR=`(cd "${MY_DARWIN_DIR}" ; pwd)`
29MY_DARWIN_DIR=`dirname "${MY_DARWIN_DIR}"`
30
31#
32# Constants.
33#
34MY_PKGS="gcc4.2.pkg llvm-gcc4.2.pkg DeveloperToolsCLI.pkg xcrun.pkg JavaSDK.pkg MacOSX10.6.pkg MacOSX10.7.pkg"
35MY_LAST_PKG="MacOSX10.7.pkg"
36MY_PKGS="clang.pkg"
37MY_LAST_PKG="clang.pkg"
38declare -a MY_FULL_PKGS
39for i in $MY_PKGS;
40do
41 MY_FULL_PKGS[$((${#MY_FULL_PKGS[*]}))]="./Applications/Install Xcode.app/Contents/Resources/Packages/${i}"
42done
43
44#
45# Parse arguments.
46#
47MY_TMP_DIR=/var/tmp/xcode41extractor
48MY_DST_DIR="${MY_DARWIN_DIR}/xcode/v41"
49MY_PKG_FILE=
50
51my_usage()
52{
53 echo "usage: $0 [--tmpdir|-t <tmpdir>] <--destination|-d> <dstdir> <--filename|-f> <dir/InstallXcodeLion.pkg>";
54 exit $1;
55}
56
57while test $# -ge 1;
58do
59 ARG=$1;
60 shift;
61 case "$ARG" in
62
63 --tmpdir|-t)
64 if test $# -eq 0; then
65 echo "error: missing --tmpdir argument." 1>&2;
66 exit 1;
67 fi
68 MY_TMP_DIR="$1";
69 shift;
70 ;;
71
72 --destination|-d)
73 if test $# -eq 0; then
74 echo "error: missing --tmpdir argument." 1>&2;
75 exit 1;
76 fi
77 MY_DST_DIR="$1";
78 shift;
79 ;;
80
81 --filename|-f)
82 if test $# -eq 0; then
83 echo "error: missing --filename argument." 1>&2;
84 exit 1;
85 fi
86 MY_PKG_FILE="$1";
87 shift;
88 ;;
89
90 --h*|-h*|-?|--?)
91 my_usage 0;
92 esac
93done
94
95# Check the package file.
96if [ -z "${MY_PKG_FILE}" ]; then
97 echo "error: missing --filename <dir/InstallXcodeLion.pkg>." 1>&2l
98 my_usage 1;
99fi
100if ! xar -tf "${MY_PKG_FILE}" > /dev/null ; then
101 echo "error: xar has trouble with '${MY_PKG_FILE}'." 1>&2;
102 exit 1;
103fi
104
105# Check the destination directory.
106if [ -z "${MY_DST_DIR}" ]; then
107 echo "error: missing --destination <dstdir>." 1>&2;
108 my_usage 1;
109fi
110if ! mkdir -p "${MY_DST_DIR}"; then
111 echo "error: error creating '${MY_DST_DIR}'." 1>&2;
112 exit 1;
113fi
114
115# Check the temporary directory.
116if [ -z "${MY_TMP_DIR}" ]; then
117 echo "error: empty --tmpdir <tmpdir>." 1>&2;
118 my_usage 1;
119fi
120if ! mkdir -p "${MY_TMP_DIR}/x"; then
121 echo "error: error creating '${MY_TMP_DIR}/x'." 1>&2;
122 exit 1;
123fi
124
125#
126# Extract the "Applications/Install Xcode.app" payload, calling it MainPayload.tar.
127#
128if [ ! -f "${MY_TMP_DIR}/x/MainPayload.tar" ]; then
129 echo "info: Extracting '${MY_PKG_FILE}'..."
130 if ! xar -xvf "${MY_PKG_FILE}" -C "${MY_TMP_DIR}/x"; then
131 echo "error: extraction error." 1>&2;
132 exit 1;
133 fi
134 if ! mv -f "${MY_TMP_DIR}/x/InstallXcodeLion.pkg/Payload" "${MY_TMP_DIR}/x/MainPayload.tar"; then
135 echo "error: Failed to move the package payload. Did you get the right package file?" 1>&2;
136 exit 1;
137 fi
138fi
139
140#
141# Extract the sub-packages from MainPayload.tar.
142#
143if [ ! -f "${MY_TMP_DIR}/x/${MY_LAST_PKG}" ]; then
144 echo "info: Extracting packages from 'MainPayload.tar'..."
145 if ! tar xvf "${MY_TMP_DIR}/x/MainPayload.tar" -C "${MY_TMP_DIR}/x" "${MY_FULL_PKGS[@]}"; then
146 echo "error: Failure extracting sub-packages from MainPayload.tar (see above)." 1>&2;
147 exit 1;
148 fi
149
150 for i in $MY_PKGS;
151 do
152 if ! mv -f "${MY_TMP_DIR}/x/Applications/Install Xcode.app/Contents/Resources/Packages/${i}" "${MY_TMP_DIR}/x/${i}"; then
153 echo "error: Failed to move the package ${i}." 1>&2;
154 exit 1;
155 fi
156 done
157fi
158
159#
160# Work the sub-packages, extracting their payload content into the destination directory.
161#
162for i in $MY_PKGS;
163do
164 rm -f -- "${MY_TMP_DIR}/x/Payload";
165 echo "info: Extracting payload of sub-package ${i}...";
166 if ! xar -xvf "${MY_TMP_DIR}/x/${i}" -C "${MY_TMP_DIR}/x" Payload; then
167 echo "error: Failed to extract the payload of sub-package ${i}." 1>&2;
168 exit 1;
169 fi
170 if ! tar xvf "${MY_TMP_DIR}/x/Payload" -C "${MY_DST_DIR}"; then
171 echo "error: Failed to extract the payload content of sub-package ${i}." 1>&2;
172 exit 1;
173 fi
174done
175
176#
177# Clean up.
178#
179echo "info: Successfully extracted. Cleaning up temporary files..."
180rm -Rf -- "${MY_TMP_DIR}/x/"
181rmdir -- "${MY_TMP_DIR}"
182
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle
ContactPrivacy/Do Not Sell My InfoTerms of Use