forked from AlexxandreFS/Batocera.PLUS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-batocera.plus
executable file
·414 lines (325 loc) · 19.5 KB
/
build-batocera.plus
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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
#!/bin/sh
##
## Batocera.PLUS
##
################################################################################
# Versão do Batocera.PLUS
VERSION='2.05'
#RELEASE='dev'
NVIDIA_LEGACY='0'
# Pasta temporária em uma partição Linux
TEMP_DIR='./tmp'
#TEMP_DIR='/media/NO_LABEL/tmp'
#TEMP_DIR='/media/NO_LABEL_1/tmp'
#TEMP_DIR='/media/NO_LABEL_2/tmp'
#TEMP_DIR='/mnt/tmp'
# Imagem oficial do batocera.linux.
IMG_OFICIAL_NORMAL='img/batocera-5.27-x86_64-20200912.img.gz'
IMG_OFICIAL_NVIDIA='img/batocera-5.27-x86_64-20200919.img.gz'
# BatoceraZero.
IMG_ZERO='img/BatoceraZero3.3GB.7z'
# Arquivos extras do Batocera.PLUS
PLUS_DIR='plus'
UPDATE_DIR='update'
BOOT_DIR='boot'
DOWNLOAD_DIR='download'
PATCH_DIR='patch'
################################################################################
# DOWNLOADS LINKS
URL_THEME_A="https://github.com/BatoceraPLUS/Theme-batocera-plus/archive/master.zip#/Theme-batocera-plus-${VERSION}${RELEASE}.zip"
URL_FIREFOX="https://download.mozilla.org/?product=firefox-esr-latest&os=linux64&lang=en-US#/firefox-esr-${VERSION}${RELEASE}.tar.bz2"
URL_MAME='https://github.com/BatoceraPLUS/Mame-Mess/releases/download/0220/mame_libretro_0220.7z'
URL_JAVA="https://javadl.oracle.com/webapps/download/AutoDL?BundleId=242050_3d5a2bb8f8d4428bbe94aed7ec7ae784#/java-jre-linux-x64-${VERSION}${RELEASE}.tar.gz"
URL_WINE_STABLE='https://github.com/AlexxandreFS/Wine.PLUS/releases/download/release/wine-stable-5.0.2-3.7z'
URL_WINE_STAGING='https://github.com/AlexxandreFS/Wine.PLUS/releases/download/release/wine-staging-5.20-1.7z'
URL_WINE_LUTRIS='https://github.com/AlexxandreFS/Wine.PLUS/releases/download/release/wine-lutris-5.7-11-2.7z'
URL_WINE_PROTON_VALVE='https://github.com/AlexxandreFS/Wine.PLUS/releases/download/release/proton-valve-5.13-2.7z'
URL_WINE_PROTON_GE_CUSTOM='https://github.com/AlexxandreFS/Wine.PLUS/releases/download/release/proton-ge-custom-5.9-4.7z'
URL_WINE_PROTON_TKG='https://github.com/AlexxandreFS/Wine.PLUS/releases/download/release/proton-tkg-5.19.r1-3.7z'
URL_WINE_EXTRA_LIBS='https://github.com/AlexxandreFS/Wine.PLUS/releases/download/wine-extra-libs/wine-extra-libs-5.7z'
URL_WINE_MONO='https://dl.winehq.org/wine/wine-mono/5.1.1/wine-mono-5.1.1-x86.tar.xz'
URL_WINE_DIRECTX='https://github.com/BatoceraPLUS/Wine/releases/download/DX9Jun2010/DX9Jun2010.7z'
URL_WINE_DXVK='https://github.com/doitsujin/dxvk/releases/download/v1.7.2/dxvk-1.7.2.tar.gz'
URL_WINE_VKD3D_PROTON='https://github.com/HansKristian-Work/vkd3d-proton/releases/download/v2.0/vkd3d-proton-2.0.tar.zst'
URL_CEMU="$(curl -s http://cemu.info | grep -i 'cemu_.*' | tail -n 1 | cut -d '"' -f 2 | cut -d ' ' -f 1)"
URL_CEMUHOOK="$(curl -s https://cemuhook.sshnuke.net/ | grep -A 2 -F '<h2>Current versions</h2>' | grep '.zip' | cut -d '"' -f 2)"
URL_CEMUFAKEFILES='https://github.com/sabotendarsama/fakefiles/releases/download/1.0/fakefiles.zip'
URL_EXTRAFILES='https://github.com/sabotendarsama/cemuextras/releases/download/v1.0/cemuextras.zip'
URL_MODEL2='https://github.com/sabotendarsama/Model2/releases/download/V1.0/model2-1.1.zip'
URL_MODEL3='https://github.com/sabotendarsama/Model3/releases/download/v1.0/model3-1.1.zip'
URL_FLASH="$(curl -s 'https://fpdownload.macromedia.com/pub/flashplayer/masterversion/masterversion.xml' | grep 'NPAPI_linux version' | head -n 1 | cut -d '"' -f 2 | sed 's/,/./g')"
if ! [ "${URL_FLASH}" ]; then
URL_FLASH='32.0.0.414'
fi
URL_FLASH="https://fpdownload.adobe.com/get/flashplayer/pdc/${URL_FLASH}/flash_player_npapi_linux.x86_64.tar.gz#/flash_player_npapi_linux.x86_64_${URL_FLASH}.tar.gz"
# REMOVA este link quando for atualizar
URL_NVIDIA=http://download.nvidia.com/XFree86/Linux-x86_64/450.66/NVIDIA-Linux-x86_64-450.66.run
# DOWNLOAD
mkdir -p "${DOWNLOAD_DIR}"
for URL in "${URL_NVIDIA}" "${URL_WINE_STABLE}" "${URL_WINE_STAGING}" "${URL_WINE_LUTRIS}" "${URL_WINE_PROTON_VALVE}" "${URL_WINE_PROTON_GE_CUSTOM}" "${URL_WINE_PROTON_TKG}" "${URL_WINE_EXTRA_LIBS}" "${URL_WINE_MONO}" "${URL_WINE_DIRECTX}" "${URL_WINE_DXVK}" "${URL_WINE_VKD3D_PROTON}" "${URL_FIREFOX}" "${URL_MAME}" "${URL_JAVA}" "${URL_FLASH}" "${URL_THEME_A}" "${URL_CEMU}" "${URL_CEMUHOOK}" "${URL_CEMUFAKEFILES}" "${URL_EXTRAFILES}" "${URL_MODEL2}" "${URL_MODEL3}"; do
PKG_NAME="$(basename "${URL}")"
echo "Baixando ${PKG_NAME}..."
if ! [ -f "${DOWNLOAD_DIR}/${PKG_NAME}" ]; then
curl -L -C - "${URL}" -o "${DOWNLOAD_DIR}/${PKG_NAME}"
fi
done
################################################################################
echo 'Descompactando Batocera oficial...'
if [ "${NVIDIA_LEGACY}" == '0' ]; then
echo 'ALVO: IMAGEM NORMAL'
IMG_OFICIAL="${IMG_OFICIAL_NORMAL}"
elif ! [ "${NVIDIA_LEGACY}" ]; then
echo 'ALVO: IMAGEM NORMAL'
IMG_OFICIAL="${IMG_OFICIAL_NORMAL}"
elif [ "${NVIDIA_LEGACY}" == '1' ]; then
echo 'ALVO: IMAGEM NVIDIA LEGACY'
IMG_OFICIAL="${IMG_OFICIAL_NVIDIA}"
else
echo 'Erro: Valor desconhecido para NVIDIA LEGACY'
exit 1
fi
mkdir -p "$TEMP_DIR"
if ! [ -f "$IMG_OFICIAL" ]; then
echo "A imagem $IMG_OFICIAL não foi encontrada!"
exit $?
fi
gunzip -k "$IMG_OFICIAL" -c > "$TEMP_DIR/batocera.linux.img" || exit $?
echo 'Adicionando imagem oficial do batocera.linux ao disposivo loop...'
losetup -f
losetup /dev/loop7 -o $((512 * 2048)) "$TEMP_DIR/batocera.linux.img" || exit $?
echo 'Montando imagem oficial do batcera.linux...'
mkdir "$TEMP_DIR/BATOCERA"
mount -o rw /dev/loop7 "$TEMP_DIR/BATOCERA" || exit $?
echo 'Descompactando arquivo squashfs...'
unsquashfs -d "$TEMP_DIR/squashfs-root" "$TEMP_DIR/BATOCERA/boot/batocera" || exit $?
################################################################################
echo 'Removendo arquivos desnecessários...'
rm -r "$TEMP_DIR/squashfs-root/usr/share/icons/Adwaita" || exit $?
rm -r "$TEMP_DIR/squashfs-root/usr/share/batocera/music" || exit $?
for x in c64 cannonball gba megadrive mrboom nes pcengine prboom snes; do
for y in "$TEMP_DIR/squashfs-root/usr/share/batocera/datainit/roms/${x}/"*; do
if [ "${y}" != "$TEMP_DIR/squashfs-root/usr/share/batocera/datainit/roms/${x}/_info.txt" ]; then
rm -r "${y}" || exit $?
fi
done
done
echo 'Desativando servicos...'
mv "$TEMP_DIR/squashfs-root/etc/init.d/S49ntp" "$TEMP_DIR/squashfs-root/etc/init.d/K49ntp" || exit $?
mv "$TEMP_DIR/squashfs-root/etc/init.d/S50triggerhappy" "$TEMP_DIR/squashfs-root/etc/init.d/K50triggerhappy" || exit $?
echo 'Criando arquivo de versão...'
mv "$TEMP_DIR/squashfs-root/usr/share/batocera/batocera.version" "$TEMP_DIR/squashfs-root/usr/share/batocera/recalbox.version" || exit $?
echo "$VERSION $(date +'%Y/%m/%d %H:%M')" > "$TEMP_DIR/squashfs-root/usr/share/batocera/batocera.version" || exit $?
################################################################################
echo 'Copiando arquivos do batocera.plus...'
cp -r -f "$PLUS_DIR/"* "$TEMP_DIR/squashfs-root" || exit $?
cp -r -f "$UPDATE_DIR/"* "$TEMP_DIR/squashfs-root" || exit $?
################################################################################
echo 'Descompactando Libretro mame0174...'
7zr x "$TEMP_DIR/squashfs-root/usr/lib/libretro/mame0174_libretro.so.7z" -o"$TEMP_DIR/squashfs-root/usr/lib/libretro" || exit $?
rm -f "$TEMP_DIR/squashfs-root/usr/lib/libretro/mame0174_libretro.so.7z"
echo 'Descompactando Libretro mame0200...'
7zr x "$TEMP_DIR/squashfs-root/usr/lib/libretro/mame0200_libretro.so.7z" -o"$TEMP_DIR/squashfs-root/usr/lib/libretro" || exit $?
rm -f "$TEMP_DIR/squashfs-root/usr/lib/libretro/mame0200_libretro.so.7z"
echo 'Descompactando Libretro hbmame...'
7zr x "$TEMP_DIR/squashfs-root/usr/lib/libretro/hbmame_libretro.so.7z" -o"$TEMP_DIR/squashfs-root/usr/lib/libretro" || exit $?
rm -f "$TEMP_DIR/squashfs-root/usr/lib/libretro/hbmame_libretro.so.7z"
#echo 'Descompactando Libretro mame_mame...'
#7zr x "$TEMP_DIR/squashfs-root/usr/lib/libretro/mame_mame_libretro.so.7z.001" -o"$TEMP_DIR/squashfs-root/usr/lib/libretro" || exit $?
#rm -f "$TEMP_DIR/squashfs-root/usr/lib/libretro/mame_mame_libretro.so.7z."*
echo 'Descompactando Fontes Microsoft msttcorefonts...'
7zr x "$TEMP_DIR/squashfs-root/usr/share/fonts/truetype/msttcorefonts.7z" -o"$TEMP_DIR/squashfs-root/usr/share/fonts/truetype" || exit $?
rm -f "$TEMP_DIR/squashfs-root/usr/share/fonts/truetype/msttcorefonts.7z"
################################################################################
echo 'Descompactando tema batocera.plus...'
PKG_NAME="$(basename "${URL_THEME_A}")"
unzip "${DOWNLOAD_DIR}/${PKG_NAME}" \
-d "${TEMP_DIR}/squashfs-root/usr/share/emulationstation/themes" || exit $?
mv "${TEMP_DIR}/squashfs-root/usr/share/emulationstation/themes/Theme-batocera-plus-master" \
"${TEMP_DIR}/squashfs-root/usr/share/emulationstation/themes/batocera-plus" || exit $?
echo "Descompactando Wine-Stable..."
PKG_NAME="$(basename "${URL_WINE_STABLE}")"
7zr x "${DOWNLOAD_DIR}/${PKG_NAME}" -o"${TEMP_DIR}/squashfs-root/opt/Wine" || exit $?
echo "Descompactando Wine-Staging..."
PKG_NAME="$(basename "${URL_WINE_STAGING}")"
7zr x "${DOWNLOAD_DIR}/${PKG_NAME}" -o"${TEMP_DIR}/squashfs-root/opt/Wine" || exit $?
echo "Descompactando Wine-Lutris..."
PKG_NAME="$(basename "${URL_WINE_LUTRIS}")"
7zr x "${DOWNLOAD_DIR}/${PKG_NAME}" -o"${TEMP_DIR}/squashfs-root/opt/Wine" || exit $?
echo "Descompactando Proton-Valve..."
PKG_NAME="$(basename "${URL_WINE_PROTON_VALVE}")"
7zr x "${DOWNLOAD_DIR}/${PKG_NAME}" -o"${TEMP_DIR}/squashfs-root/opt/Wine" || exit $?
echo "Descompactando Proton-GE-Custom..."
PKG_NAME="$(basename "${URL_WINE_PROTON_GE_CUSTOM}")"
7zr x "${DOWNLOAD_DIR}/${PKG_NAME}" -o"${TEMP_DIR}/squashfs-root/opt/Wine" || exit $?
echo "Descompactando Proton-TKG..."
PKG_NAME="$(basename "${URL_WINE_PROTON_TKG}")"
7zr x "${DOWNLOAD_DIR}/${PKG_NAME}" -o"${TEMP_DIR}/squashfs-root/opt/Wine" || exit $?
echo "Descompactando Wine-Extra Libs..."
PKG_NAME="$(basename "${URL_WINE_EXTRA_LIBS}")"
7zr x "${DOWNLOAD_DIR}/${PKG_NAME}" -o"${TEMP_DIR}/squashfs-root/opt/Wine" || exit $?
# Remova a linha à baixo (mv) em uma futura atualização.
mv "${TEMP_DIR}/squashfs-root/opt/Wine/wine-extra-libs/linux" "${TEMP_DIR}"
cp -r "${TEMP_DIR}/squashfs-root/opt/Wine/wine-extra-libs/"* "${TEMP_DIR}/squashfs-root/opt/Wine" || exit $?
rm -r "${TEMP_DIR}/squashfs-root/opt/Wine/wine-extra-libs"
echo 'Descompactando Wine Mono...'
PKG_NAME="$(basename "${URL_WINE_MONO}")"
mkdir -p "${TEMP_DIR}/squashfs-root/opt/Wine/apps"
xz -d -k -c -v "${DOWNLOAD_DIR}/${PKG_NAME}" | tar xv -C "${TEMP_DIR}/squashfs-root/opt/Wine/apps" || exit $?
mv "${TEMP_DIR}/squashfs-root/opt/Wine/apps/wine-mono-"* \
"${TEMP_DIR}/squashfs-root/opt/Wine/apps/mono"
echo 'Descompactando Wine DXVK...'
PKG_NAME="$(basename "${URL_WINE_DXVK}")"
mkdir -p "${TEMP_DIR}/squashfs-root/opt/Wine/apps"
gunzip -k "${DOWNLOAD_DIR}/${PKG_NAME}" -c | tar x -v -C "${TEMP_DIR}/squashfs-root/opt/Wine/apps" || exit $?
mv "${TEMP_DIR}/squashfs-root/opt/Wine/apps/dxvk-"* "${TEMP_DIR}/squashfs-root/opt/Wine/apps/dxvk"
rm "${TEMP_DIR}/squashfs-root/opt/Wine/apps/dxvk/setup_dxvk.sh"
echo 'Descompactando Wine VKD3D_PROTON (DXVK12)...'
PKG_NAME="$(basename "${URL_WINE_VKD3D_PROTON}")"
mkdir -p "${TEMP_DIR}/squashfs-root/opt/Wine/apps/dxvk/x32" "${TEMP_DIR}/squashfs-root/opt/Wine/apps/dxvk/x64"
if ! [ -f /usr/bin/zstd ]; then
# Este bloco if foi adicionado para não quebrar a compilação do batocera.plus em versões mais antigas (batocera.plus 2.0)
# Remova este bloco if quando sair a pŕoxima imagem stable.
"${PLUS_DIR}/usr/bin/zstd" -d -c "${DOWNLOAD_DIR}/${PKG_NAME}" | tar -xvC "${TEMP_DIR}/squashfs-root/opt/Wine/apps" || exit $?
else
# Não remova esta linha quando remover o bloco if.
zstd -d -c "${DOWNLOAD_DIR}/${PKG_NAME}" | tar -xvC "${TEMP_DIR}/squashfs-root/opt/Wine/apps" || exit $?
fi
mv "${TEMP_DIR}/squashfs-root/opt/Wine/apps/${PKG_NAME%.tar.zst}/x86/d3d12.dll" "${TEMP_DIR}/squashfs-root/opt/Wine/apps/dxvk/x32"
mv "${TEMP_DIR}/squashfs-root/opt/Wine/apps/${PKG_NAME%.tar.zst}/x64/d3d12.dll" "${TEMP_DIR}/squashfs-root/opt/Wine/apps/dxvk/x64"
rm -r "${TEMP_DIR}/squashfs-root/opt/Wine/apps/${PKG_NAME%.tar.zst}"
echo 'Descompactando Directx...'
PKG_NAME="$(basename "${URL_WINE_DIRECTX}")"
mkdir -p "${TEMP_DIR}/squashfs-root/opt/Wine/apps"
7zr x "${DOWNLOAD_DIR}/${PKG_NAME}" -o"${TEMP_DIR}/squashfs-root/opt/Wine/apps" || exit $?
echo 'Descompactando Firefox...'
PKG_NAME="$(basename "${URL_FIREFOX}")"
bunzip2 -d -k -v -c "${DOWNLOAD_DIR}/${PKG_NAME}" | tar x -v -C "${TEMP_DIR}/squashfs-root/opt/Firefox" || exit $?
mv "${TEMP_DIR}/squashfs-root/opt/Firefox/firefox/"* \
"${TEMP_DIR}/squashfs-root/opt/Firefox/firefox-esr"
rmdir "${TEMP_DIR}/squashfs-root/opt/Firefox/firefox"
echo 'Descompactando Flash Player...'
PKG_NAME="$(basename "${URL_FLASH}")"
mkdir -p "${TEMP_DIR}/squashfs-root/usr/lib/mozilla/plugins"
gunzip -k "${DOWNLOAD_DIR}/${PKG_NAME}" -c | tar x -v -C "${TEMP_DIR}/squashfs-root/usr/lib/mozilla/plugins" || exit $?
rm -r "${TEMP_DIR}/squashfs-root/usr/lib/mozilla/plugins/LGPL" \
"${TEMP_DIR}/squashfs-root/usr/lib/mozilla/plugins/usr" \
"${TEMP_DIR}/squashfs-root/usr/lib/mozilla/plugins/license.pdf"
echo 'Descompactando Mame...'
PKG_NAME="$(basename "${URL_MAME}")"
7zr x "${DOWNLOAD_DIR}/${PKG_NAME}" -o"${TEMP_DIR}/squashfs-root/usr/lib/libretro" -y || exit $?
echo 'Descompactando Java...'
PKG_NAME="$(basename "${URL_JAVA}")"
gunzip -k "${DOWNLOAD_DIR}/${PKG_NAME}" -c | tar x -v -C "${TEMP_DIR}/squashfs-root/opt" || exit $?
mv "${TEMP_DIR}/squashfs-root/opt/jre"* "${TEMP_DIR}/squashfs-root/opt/Java"
echo 'Descompactando Cemu...'
PKG_NAME="$(basename "${URL_CEMU%.*}")"
unzip "${DOWNLOAD_DIR}/${PKG_NAME}" -d "${TEMP_DIR}/squashfs-root/opt" || exit $?
mkdir -p "${TEMP_DIR}/squashfs-root/opt/Cemu/emulator"
mv "${TEMP_DIR}/squashfs-root/opt/${PKG_NAME}/"* "${TEMP_DIR}/squashfs-root/opt/Cemu/emulator"
rm -r "${TEMP_DIR}/squashfs-root/opt/${PKG_NAME}"
echo 'Descompactando Cemu Extras...'
PKG_NAME="$(basename "${URL_EXTRAFILES%.*}")"
unzip "${DOWNLOAD_DIR}/${PKG_NAME}" -d "${TEMP_DIR}/squashfs-root/opt/Cemu" || exit $?
echo 'Descompactando CemuHook...'
PKG_NAME="$(basename "${URL_CEMUHOOK%.*}")"
unzip "${DOWNLOAD_DIR}/${PKG_NAME}" -d "${TEMP_DIR}/squashfs-root/opt/${PKG_NAME}" || exit $?
mkdir -p "${TEMP_DIR}/squashfs-root/opt/Cemu/cemuhook"
rm -r "${TEMP_DIR}/squashfs-root/opt/${PKG_NAME}/Go to project website for updates.url"
mv "${TEMP_DIR}/squashfs-root/opt/${PKG_NAME}/"* "${TEMP_DIR}/squashfs-root/opt/Cemu/cemuhook"
rmdir "${TEMP_DIR}/squashfs-root/opt/${PKG_NAME}"
echo 'Descompactando Cemu Fakefiles...'
PKG_NAME="$(basename "${URL_CEMUFAKEFILES%.*}")"
unzip "${DOWNLOAD_DIR}/${PKG_NAME}" -d "${TEMP_DIR}/squashfs-root/opt/Cemu" || exit $?
echo 'Descompactando Model 2 Emulator...'
PKG_NAME="$(basename "${URL_MODEL2%.*}")"
unzip "${DOWNLOAD_DIR}/${PKG_NAME}" -d "${TEMP_DIR}/squashfs-root/opt/Model2" || exit $?
echo 'Descompactando Model 3 Emulator...'
PKG_NAME="$(basename "${URL_MODEL3%.*}")"
unzip "${DOWNLOAD_DIR}/${PKG_NAME}" -d "${TEMP_DIR}/squashfs-root/opt/Model3" || exit $?
# REMOVA o driver da nvidia quando for atualizar.
echo Descompactando driver nvidia ...
if ! [ "${NVIDIA_LEGACY}" == '1' ]; then
PKG_NAME="$(basename "${URL_NVIDIA}")"
chmod +x "${DOWNLOAD_DIR}/${PKG_NAME}"
"${DOWNLOAD_DIR}/${PKG_NAME}" -x --target "${TEMP_DIR}/${PKG_NAME%.run}" || exit $?
mv "${TEMP_DIR}/${PKG_NAME%.run}/nvidia_icd.json" "${TEMP_DIR}/squashfs-root/usr/share/vulkan/icd.d" || exit $?
mv "${TEMP_DIR}/${PKG_NAME%.run}/libnvidia-glvkspirv.so."* "${TEMP_DIR}/squashfs-root/usr/lib" || exit $?
mv "${TEMP_DIR}/${PKG_NAME%.run}/32/libnvidia-glvkspirv.so."* "${TEMP_DIR}/squashfs-root/lib32" || exit $?
mkdir -p "${TEMP_DIR}/squashfs-root/usr/share/vulkan/implicit_layer.d"
mv "${TEMP_DIR}/${PKG_NAME%.run}/nvidia_layers.json" "${TEMP_DIR}/squashfs-root/usr/share/vulkan/implicit_layer.d" || exit $?
rm -r "${TEMP_DIR}/${PKG_NAME%.run}" || exit $?
fi
################################################################################
echo 'Aplicando Patch...'
cp -f "${TEMP_DIR}/squashfs-root/etc/samba/smb.conf" "${TEMP_DIR}/squashfs-root/etc/samba/smb-ps2smb.conf" || exit $?
for i in $(du -a "${PATCH_DIR}" | grep -F '.patch' | awk '{print $2}' | sed "s#${PATCH_DIR}/##"); do
patch -p1 "${TEMP_DIR}/squashfs-root/${i%.patch}" "${PATCH_DIR}/${i}" || exit $?
done
################################################################################
echo 'Compactando arquivo squashfs...'
mksquashfs "$TEMP_DIR/squashfs-root/"* "$TEMP_DIR/batocera" || exit $?
echo 'Descompactando imagem do BatoceraZero...'
7zr x "$IMG_ZERO" -o"$TEMP_DIR" || exit $?
echo 'Adicionando imagem BatoceraZero ao dispositivo loop...'
losetup -o $((512 * 2048)) /dev/loop6 "$TEMP_DIR/BatoceraZero.img" || exit $?
echo 'Montando imagem do BatoceraZero...'
mkdir "$TEMP_DIR/BatoceraZero"
mount /dev/loop6 "$TEMP_DIR/BatoceraZero" || exit $?
echo 'Movendo arquivos de boot para o BatoceraZero...'
rm "$TEMP_DIR/BATOCERA/boot/batocera" || exit $?
rm "$TEMP_DIR/BATOCERA/boot/syslinux/ldlinux.sys" || exit $?
cp -r "$TEMP_DIR/BATOCERA/"* "$TEMP_DIR/BatoceraZero" || exit $?
# Remova a linha à baixo (mv) em uma futura atualização.
mv -f "$TEMP_DIR/linux" "$TEMP_DIR/BatoceraZero/boot" || exit $?
echo 'Movendo arquivo squashfs para o BatoceraZero...'
mv "$TEMP_DIR/batocera" "$TEMP_DIR/BatoceraZero/boot/batocera" || exit $?
echo 'Copiando arquivos extras para o BatoceraZero...'
cp -r -f "$BOOT_DIR/"* "$TEMP_DIR/BatoceraZero" || exit $?
echo 'Editando arquivo batocera-boot.conf...'
echo "$(
while read FILE; do
echo "${FILE}"
if [ "$(echo "${FILE}" | grep 'autoresize=')" ]; then
echo
echo '# enable the splash video on startup /userdata/splashvideo (remove the # to enable video)'
echo '#splash.video=true'
echo
echo '# open a terminal (Win + F4) type xrandr to see all supported resolutions'
echo '#global.videomode=1280x720'
fi
done < "${TEMP_DIR}/BatoceraZero/batocera-boot.conf"
)" > "${TEMP_DIR}/BatoceraZero/batocera-boot.conf"
sync
echo 'Desmontando imagens...'
umount /dev/loop7 || exit $?
umount /dev/loop6 || exit $?
echo 'Removendo imagens dos disposivos loop...'
losetup -d /dev/loop7 || exit $?
losetup -d /dev/loop6 || exit $?
sync
mv "$TEMP_DIR/BatoceraZero.img" "$TEMP_DIR/Batocera.PLUS.img" || exit $?
if [ "${RELEASE}" ]; then
echo 'Copiando arquivos extra para a release...'
if [ "${NVIDIA_LEGACY}" == '1' ]; then
RELEASE="${RELEASE}-Nvidia-Legacy"
fi
cp -f "${BOOT_DIR}/batocera-hd-edition/grub.cfg" "${TEMP_DIR}" || exit $?
cp -f "${BOOT_DIR}/batocera-hd-edition/leia-me.txt" "${TEMP_DIR}/dualboot-leia-me.txt" || exit $?
#cp -f "whatsnew.txt" "${TEMP_DIR}" || exit $?
#sed -i "1s/^/#### Batocera.PLUS-${VERSION}-${RELEASE} ####\n\n/" "${TEMP_DIR}/whatsnew.txt" || exit $?
echo 'Compactando imagem final...'
7zr a "${TEMP_DIR}/Batocera.PLUS-${VERSION}-${RELEASE}.7z" "${TEMP_DIR}/Batocera.PLUS.img" || exit $?
echo 'Gerando Md5sum...'
md5sum "${TEMP_DIR}/Batocera.PLUS-${VERSION}-${RELEASE}.7z" | cut -d ' ' -f 1 >> "${TEMP_DIR}/md5sum.txt" || exit $?
fi
echo 'Removendo arquivos temporários...'
rmdir "$TEMP_DIR/BATOCERA" || exit $?
rmdir "$TEMP_DIR/BatoceraZero" || exit $?
rm -r "$TEMP_DIR/squashfs-root" || exit $?
rm "$TEMP_DIR/batocera.linux.img" || exit $?
if [ "${RELEASE}" ]; then
rm -r "${TEMP_DIR}/Batocera.PLUS.img" || exit $?
fi
sync
echo 'IMAGEM CRIADA COM SUCESSO!'
exit 0