You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

extract-osx-sdk.sh 1.2KB

123456789101112131415161718192021222324252627282930313233
  1. #!/bin/bash
  2. # Copyright (c) 2016 The Starwels developers
  3. # Distributed under the MIT software license, see the accompanying
  4. # file COPYING or http://www.opensource.org/licenses/mit-license.php.
  5. set -e
  6. INPUTFILE="Xcode_7.3.1.dmg"
  7. HFSFILENAME="5.hfs"
  8. SDKDIR="Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk"
  9. 7z x "${INPUTFILE}" "${HFSFILENAME}"
  10. SDKNAME="$(basename "${SDKDIR}")"
  11. SDKDIRINODE=$(ifind -n "${SDKDIR}" "${HFSFILENAME}")
  12. fls "${HFSFILENAME}" -rpF ${SDKDIRINODE} |
  13. while read type inode filename; do
  14. inode="${inode::-1}"
  15. if [ "${filename:0:14}" = "usr/share/man/" ]; then
  16. continue
  17. fi
  18. filename="${SDKNAME}/$filename"
  19. echo "Extracting $filename ..."
  20. mkdir -p "$(dirname "$filename")"
  21. if [ "$type" = "l/l" ]; then
  22. ln -s "$(icat "${HFSFILENAME}" $inode)" "$filename"
  23. else
  24. icat "${HFSFILENAME}" $inode >"$filename"
  25. fi
  26. done
  27. echo "Building ${SDKNAME}.tar.gz ..."
  28. MTIME="$(istat "${HFSFILENAME}" "${SDKDIRINODE}" | perl -nle 'm/Content Modified:\s+(.*?)\s\(/ && print $1')"
  29. 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"
  30. echo 'All done!'