forked from acidanthera/OpenCorePkg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_oc.tool
executable file
·219 lines (196 loc) · 5.17 KB
/
build_oc.tool
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
#!/bin/bash
buildutil() {
UTILS=(
"AppleEfiSignTool"
"EfiResTool"
"disklabel"
"icnspack"
"macserial"
"ocvalidate"
"TestBmf"
"TestDiskImage"
"TestHelloWorld"
"TestImg4"
"TestKextInject"
"TestMacho"
"TestPeCoff"
"TestRsaPreprocess"
"TestSmbios"
)
if [ "$HAS_OPENSSL_BUILD" = "1" ]; then
UTILS+=("RsaTool")
fi
local cores
cores=$(getconf _NPROCESSORS_ONLN)
pushd "${selfdir}/Utilities" || exit 1
for util in "${UTILS[@]}"; do
cd "$util" || exit 1
echo "Building ${util}..."
make clean || exit 1
make -j "$cores" || exit 1
#
# FIXME: Do not build RsaTool for Win32 without OpenSSL.
#
if [ "$util" = "RsaTool" ] && [ "$HAS_OPENSSL_W32BUILD" != "1" ]; then
continue
fi
if [ "$(which i686-w64-mingw32-gcc)" != "" ]; then
echo "Building ${util} for Windows..."
UDK_ARCH=Ia32 CC=i686-w64-mingw32-gcc STRIP=i686-w64-mingw32-strip DIST=Windows make clean || exit 1
UDK_ARCH=Ia32 CC=i686-w64-mingw32-gcc STRIP=i686-w64-mingw32-strip DIST=Windows make -j "$cores" || exit 1
fi
cd - || exit 1
done
popd || exit
}
package() {
if [ ! -d "$1" ]; then
echo "Missing package directory $1"
exit 1
fi
local ver
ver=$(grep OPEN_CORE_VERSION ./Include/Acidanthera/OpenCore.h | sed 's/.*"\(.*\)".*/\1/' | grep -E '^[0-9.]+$')
if [ "$ver" = "" ]; then
echo "Invalid version $ver"
ver="UNKNOWN"
fi
selfdir=$(pwd)
pushd "$1" || exit 1
rm -rf tmp || exit 1
dirs=(
"tmp/EFI/BOOT"
"tmp/EFI/OC/ACPI"
"tmp/EFI/OC/Bootstrap"
"tmp/EFI/OC/Drivers"
"tmp/EFI/OC/Kexts"
"tmp/EFI/OC/Tools"
"tmp/EFI/OC/Resources/Audio"
"tmp/EFI/OC/Resources/Font"
"tmp/EFI/OC/Resources/Image"
"tmp/EFI/OC/Resources/Label"
"tmp/Docs/AcpiSamples"
"tmp/Utilities"
)
for dir in "${dirs[@]}"; do
mkdir -p "${dir}" || exit 1
done
# copy OpenCore main program.
cp OpenCore.efi tmp/EFI/OC/ || exit 1
# Mark binaries to be recognisable by OcBootManagementLib.
bootsig="${selfdir}/Library/OcBootManagementLib/BootSignature.bin"
efiOCBMs=(
"BOOTx64.efi"
"OpenCore.efi"
)
for efiOCBM in "${efiOCBMs[@]}"; do
dd if="${bootsig}" \
of="${efiOCBM}" seek=64 bs=1 count=64 conv=notrunc || exit 1
done
cp Bootstrap.efi tmp/EFI/BOOT/BOOTx64.efi || exit 1
cp Bootstrap.efi tmp/EFI/OC/Bootstrap/ || exit 1
efiTools=(
"BootKicker.efi"
"ChipTune.efi"
"CleanNvram.efi"
"GopStop.efi"
"HdaCodecDump.efi"
"KeyTester.efi"
"MmapDump.efi"
"ResetSystem.efi"
"RtcRw.efi"
"OpenControl.efi"
"VerifyMsrE2.efi"
)
for efiTool in "${efiTools[@]}"; do
cp "${efiTool}" tmp/EFI/OC/Tools/ || exit 1
done
# Special case: OpenShell.efi
cp Shell.efi tmp/EFI/OC/Tools/OpenShell.efi || exit 1
efiDrivers=(
"HiiDatabase.efi"
"NvmExpressDxe.efi"
"AudioDxe.efi"
"CrScreenshotDxe.efi"
"OpenCanopy.efi"
"OpenRuntime.efi"
"OpenUsbKbDxe.efi"
"Ps2MouseDxe.efi"
"Ps2KeyboardDxe.efi"
"UsbMouseDxe.efi"
"XhciDxe.efi"
)
for efiDriver in "${efiDrivers[@]}"; do
cp "${efiDriver}" tmp/EFI/OC/Drivers/ || exit 1
done
docs=(
"Configuration.pdf"
"Differences/Differences.pdf"
"Sample.plist"
"SampleCustom.plist"
)
for doc in "${docs[@]}"; do
cp "${selfdir}/Docs/${doc}" tmp/Docs/ || exit 1
done
cp "${selfdir}/Changelog.md" tmp/Docs/ || exit 1
cp -r "${selfdir}/Docs/AcpiSamples/" tmp/Docs/AcpiSamples/ || exit 1
utilScpts=(
"LegacyBoot"
"CreateVault"
"LogoutHook"
"macrecovery"
"kpdescribe"
)
for utilScpt in "${utilScpts[@]}"; do
cp -r "${selfdir}/Utilities/${utilScpt}" tmp/Utilities/ || exit 1
done
# Copy OpenDuetPkg booter.
local arch
local tgt
local booter
arch="$(basename "$(pwd)")"
tgt="$(basename "$(dirname "$(pwd)")")"
booter="$(pwd)/../../../OpenDuetPkg/${tgt}/${arch}/boot"
if [ -f "${booter}" ]; then
echo "Copying OpenDuetPkg boot file from ${booter}..."
cp "${booter}" tmp/Utilities/LegacyBoot/boot || exit 1
else
echo "Failed to find OpenDuetPkg at ${booter}!"
fi
buildutil || exit 1
utils=(
"macserial"
"ocvalidate"
"disklabel"
"icnspack"
)
for util in "${utils[@]}"; do
dest="tmp/Utilities/${util}"
mkdir -p "${dest}" || exit 1
bin="${selfdir}/Utilities/${util}/${util}"
cp "${bin}" "${dest}" || exit 1
binEXE="${bin}.exe"
if [ -f "${binEXE}" ]; then
cp "${binEXE}" "${dest}" || exit 1
fi
done
# additional docs for macserial.
cp "${selfdir}/Utilities/macserial/FORMAT.md" tmp/Utilities/macserial/ || exit 1
cp "${selfdir}/Utilities/macserial/README.md" tmp/Utilities/macserial/ || exit 1
pushd tmp || exit 1
zip -qr -FS ../"OpenCore-${ver}-${2}.zip" ./* || exit 1
popd || exit 1
rm -rf tmp || exit 1
popd || exit 1
}
cd "$(dirname "$0")" || exit 1
if [ "$ARCHS" = "" ]; then
ARCHS=(X64 IA32)
export ARCHS
fi
SELFPKG=OpenCorePkg
NO_ARCHIVES=0
export SELFPKG
export NO_ARCHIVES
src=$(curl -Lfs https://raw.githubusercontent.com/acidanthera/ocbuild/master/efibuild.sh) && eval "$src" || exit 1
cd Library/OcConfigurationLib || exit 1
./CheckSchema.py OcConfigurationLib.c || exit 1