Revert "Remove unused variable in shell script"
[bitcoinplatinum.git] / contrib / macdeploy / extract-osx-sdk.sh
blobff9fbd58df0718d5bb123c927a6488ef5eef2ce0
1 #!/bin/bash
2 # Copyright (c) 2016 The Bitcoin Core developers
3 # Distributed under the MIT software license, see the accompanying
4 # file COPYING or http://www.opensource.org/licenses/mit-license.php.
6 set -e
8 INPUTFILE="Xcode_7.3.1.dmg"
9 HFSFILENAME="5.hfs"
10 SDKDIR="Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk"
12 7z x "${INPUTFILE}" "${HFSFILENAME}"
13 SDKNAME="$(basename "${SDKDIR}")"
14 SDKDIRINODE=$(ifind -n "${SDKDIR}" "${HFSFILENAME}")
15 fls "${HFSFILENAME}" -rpF ${SDKDIRINODE} |
16 while read type inode filename; do
17 inode="${inode::-1}"
18 if [ "${filename:0:14}" = "usr/share/man/" ]; then
19 continue
21 filename="${SDKNAME}/$filename"
22 echo "Extracting $filename ..."
23 mkdir -p "$(dirname "$filename")"
24 if [ "$type" = "l/l" ]; then
25 ln -s "$(icat "${HFSFILENAME}" $inode)" "$filename"
26 else
27 icat "${HFSFILENAME}" $inode >"$filename"
29 done
30 echo "Building ${SDKNAME}.tar.gz ..."
31 MTIME="$(istat "${HFSFILENAME}" "${SDKDIRINODE}" | perl -nle 'm/Content Modified:\s+(.*?)\s\(/ && print $1')"
32 find "${SDKNAME}" | sort | tar --no-recursion --mtime="${MTIME}" --mode='u+rw,go+r-w,a+X' --owner=0 --group=0 -c -T - | gzip -9n > "${SDKNAME}.tar.gz"
33 echo 'All done!'