This repository has been archived by the owner on Jan 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen_sdk_package_tools_dmg.sh
executable file
·105 lines (81 loc) · 2.69 KB
/
gen_sdk_package_tools_dmg.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/usr/bin/env bash
#
# Extract Xcode Command Line Tools .dmg, process "Command Line Tools.pkg"
# and its sub-archives/packages, and run gen_sdk_package_tools.sh.
#
# Tested with XCode Command Line Tools 12.x
#
pushd "${0%/*}/.." &>/dev/null
source tools/tools.sh
require cpio
if [ $PLATFORM == "Darwin" ]; then
echo "Use gen_sdk_package_tools.sh on macOS" 1>&2
exit 1
fi
if [ $# -eq 0 ]; then
echo "Usage: $0 <Command_Line_Tools_for_Xcode.dmg>" 1>&2
exit 1
fi
XCODE_TOOLS_DMG=$(make_absolute_path "$1" $(get_exec_dir))
mkdir -p $BUILD_DIR
pushd $BUILD_DIR &>/dev/null
require git
require $MAKE
require cpio
[ -n "$CC" ] && require $CC
[ -n "$CXX" ] && require $CXX
# build xar
build_xar
# build pbzx
get_sources https://github.com/tpoechtrager/pbzx.git master
if [ $f_res -eq 1 ]; then
pushd $CURRENT_BUILD_PROJECT_NAME &>/dev/null
mkdir -p $TARGET_DIR_SDK_TOOLS/bin
verbose_cmd $CC -I $TARGET_DIR/include -L $TARGET_DIR/lib pbzx.c \
-o $TARGET_DIR_SDK_TOOLS/bin/pbzx -llzma -lxar \
-Wl,-rpath,$TARGET_DIR/lib
build_success
popd &>/dev/null
fi
# build 7z
get_sources https://github.com/tpoechtrager/p7zip.git master
if [ $f_res -eq 1 ]; then
pushd $CURRENT_BUILD_PROJECT_NAME &>/dev/null
if [ -n "$CC" ] && [ -n "$CXX" ]; then
[[ $CC == *clang* ]] && CC="$CC -Qunused-arguments"
[[ $CXX == *clang* ]] && CXX="$CXX -Qunused-arguments"
$MAKE 7z -j $JOBS CC="$CC" CXX="$CXX -std=gnu++98"
else
$MAKE 7z -j $JOBS CXX="c++ -std=gnu++98"
fi
$MAKE install DEST_HOME=$TARGET_DIR_SDK_TOOLS
find $TARGET_DIR_SDK_TOOLS/share -type f -exec chmod 0664 {} \;
find $TARGET_DIR_SDK_TOOLS/share -type d -exec chmod 0775 {} \;
popd &>/dev/null
build_success
fi
create_tmp_dir
pushd $TMP_DIR &>/dev/null
echo ""
echo "Unpacking $XCODE_TOOLS_DMG ..."
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$TARGET_DIR/lib \
verbose_cmd "$TARGET_DIR_SDK_TOOLS/bin/7z x \"$XCODE_TOOLS_DMG\" \"Command Line Developer Tools/*.pkg\" \"$XCODE_TOOLS_PKG\""
XCODE_TOOLS_PKG=$(find 'Command Line Developer Tools/' -type f -name "*.pkg")
echo "Extracted $XCODE_TOOLS_PKG ..."
echo ""
echo "Unpacking $XCODE_TOOLS_PKG ..."
mkdir "$TMP_DIR/pkg_data"
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$TARGET_DIR/lib \
verbose_cmd "$TARGET_DIR/bin/xar -xf \"$XCODE_TOOLS_PKG\" -C $TMP_DIR/pkg_data"
echo ""
echo "Processing packages ..."
mkdir "$TMP_DIR/out"
for PKG in $TMP_DIR/pkg_data/*.pkg; do
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$TARGET_DIR/lib \
verbose_cmd "$TARGET_DIR/SDK/tools/bin/pbzx -n \"$PKG/Payload\" | cpio -i -D $TMP_DIR/out"
done
popd &>/dev/null # TMP_DIR
popd &>/dev/null # BUILD_DIR
echo ""
XCODE_TOOLS_DIR="$TMP_DIR/out/Library/Developer/CommandLineTools" \
./tools/gen_sdk_package_tools.sh