forked from yelkaramacsc/converter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconvert.sh
executable file
·686 lines (598 loc) · 18.9 KB
/
convert.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
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
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
#!/bin/bash
scriptName="UUP Converter v0.7.2"
UUP_CONVERTER_SCRIPT=1
export PATH=${PATH}:/usr/sbin
if [ -f `dirname $0`/convert_ve_plugin ]; then
. `dirname $0`/convert_ve_plugin
fi
if [ -f `dirname $0`/convert_config_linux ] && [ `uname` == "Linux" ]; then
. `dirname $0`/convert_config_linux
elif [ -f `dirname $0`/convert_config_macos ] && [ `uname` == "Darwin" ]; then
. `dirname $0`/convert_config_macos
else
VIRTUAL_EDITIONS_LIST="CoreSingleLanguage Enterprise EnterpriseN Education \
EducationN ProfessionalEducation ProfessionalEducationN \
ProfessionalWorkstation ProfessionalWorkstationN ServerRdsh IoTEnterprise \
CloudEdition CloudEditionN"
fi
editions='analogonecore
andromeda
cloud
cloude
clouden
cloudn
cloudedition
cloudeditionn
core
corecountryspecific
coren
coresinglelanguage
coresystemserver
education
educationn
embedded
embeddede
embeddedeeval
embeddedeval
enterprise
enterpriseeval
enterpriseg
enterprisegn
enterprisen
enterpriseneval
enterprises
enterpriseseval
enterprisesn
enterprisesneval
holographic
hubos
iotenterprise
iotenterprises
iotos
iotuap
lite
mobilecore
onecoreupdateos
ppipro
professional
professionalcountryspecific
professionaleducation
professionaleducationn
professionaln
professionalsinglelanguage
professionalworkstation
professionalworkstationn
serverarm64
serverarm64core
serverazurecor
serverazurecorcore
serverazurenano
serverazurenanocore
serverazurestackhcicor
servercloudstorage
servercloudstoragecore
serverdatacenter
serverdatacenteracor
serverdatacenteracorcore
serverdatacentercor
serverdatacentercorcore
serverdatacentercore
serverdatacentereval
serverdatacenterevalcor
serverdatacenterevalcorcore
serverdatacenterevalcore
serverdatacenternano
serverdatacenternanocore
serverhypercore
serverrdsh
serverrdshcore
serversolution
serversolutioncore
serverstandard
serverstandardacor
serverstandardacorcore
serverstandardcor
serverstandardcorcore
serverstandardcore
serverstandardeval
serverstandardevalcor
serverstandardevalcorcore
serverstandardevalcore
serverstandardnano
serverstandardnanocore
serverstoragestandard
serverstoragestandardcore
serverstoragestandardeval
serverstoragestandardevalcore
serverstorageworkgroup
serverstorageworkgroupcore
serverstorageworkgroupeval
serverstorageworkgroupevalcore
serverturbine
serverturbinecor
serverweb
serverwebcore
starter
startern'
bootSourcesList='sources/alert.gif
sources/api-ms-win-core-apiquery-l1-1-0.dll
sources/api-ms-win-downlevel-advapi32-l1-1-0.dll
sources/api-ms-win-downlevel-advapi32-l1-1-1.dll
sources/api-ms-win-downlevel-advapi32-l2-1-0.dll
sources/api-ms-win-downlevel-advapi32-l2-1-1.dll
sources/api-ms-win-downlevel-advapi32-l3-1-0.dll
sources/api-ms-win-downlevel-advapi32-l4-1-0.dll
sources/api-ms-win-downlevel-kernel32-l1-1-0.dll
sources/api-ms-win-downlevel-kernel32-l2-1-0.dll
sources/api-ms-win-downlevel-ole32-l1-1-0.dll
sources/api-ms-win-downlevel-ole32-l1-1-1.dll
sources/api-ms-win-downlevel-shlwapi-l1-1-0.dll
sources/api-ms-win-downlevel-shlwapi-l1-1-1.dll
sources/api-ms-win-downlevel-user32-l1-1-0.dll
sources/api-ms-win-downlevel-user32-l1-1-1.dll
sources/api-ms-win-downlevel-version-l1-1-0.dll
sources/appcompat.xsl
sources/appcompat_bidi.xsl
sources/appcompat_detailed_bidi_txt.xsl
sources/appcompat_detailed_txt.xsl
sources/appraiser.dll
sources/ARUNIMG.dll
sources/arunres.dll
sources/autorun.dll
sources/bcd.dll
sources/bootsvc.dll
sources/cmisetup.dll
sources/compatctrl.dll
sources/compatprovider.dll
sources/compliance.ini
sources/cryptosetup.dll
sources/diager.dll
sources/diagnostic.dll
sources/diagtrack.dll
sources/diagtrackrunner.exe
sources/dism.exe
sources/dismapi.dll
sources/dismcore.dll
sources/dismcoreps.dll
sources/dismprov.dll
sources/ext-ms-win-advapi32-encryptedfile-l1-1-0.dll
sources/folderprovider.dll
sources/hwcompat.dll
sources/hwcompat.txt
sources/hwcompatPE.txt
sources/hwexclude.txt
sources/hwexcludePE.txt
sources/hwreqchk.dll
sources/idwbinfo.txt
sources/imagelib.dll
sources/imagingprovider.dll
sources/input.dll
sources/lang.ini
sources/locale.nls
sources/logprovider.dll
sources/MediaSetupUIMgr.dll
sources/ndiscompl.dll
sources/nlsbres.dll
sources/ntdsupg.dll
sources/offline.xml
sources/pnpibs.dll
sources/reagent.admx
sources/reagent.dll
sources/reagent.xml
sources/rollback.exe
sources/schema.dat
sources/segoeui.ttf
sources/ServicingCommon.dll
sources/setup.exe
sources/setupcompat.dll
sources/SetupCore.dll
sources/SetupHost.exe
sources/SetupMgr.dll
sources/SetupPlatform.cfg
sources/SetupPlatform.dll
sources/SetupPlatform.exe
sources/SetupPrep.exe
sources/SmiEngine.dll
sources/spflvrnt.dll
sources/spprgrss.dll
sources/spwizeng.dll
sources/spwizimg.dll
sources/spwizres.dll
sources/sqmapi.dll
sources/testplugin.dll
sources/unattend.dll
sources/unbcl.dll
sources/upgloader.dll
sources/upgrade_frmwrk.xml
sources/utcapi.dll
sources/uxlib.dll
sources/uxlibres.dll
sources/vhdprovider.dll
sources/w32uiimg.dll
sources/w32uires.dll
sources/warning.gif
sources/wdsclient.dll
sources/wdsclientapi.dll
sources/wdscommonlib.dll
sources/wdscore.dll
sources/wdscsl.dll
sources/wdsimage.dll
sources/wdstptc.dll
sources/wdsutil.dll
sources/wimgapi.dll
sources/wimprovider.dll
sources/win32ui.dll
sources/WinDlp.dll
sources/winsetup.dll
sources/wpx.dll
sources/xmllite.dll
sources/..-.*/appraiser.dll.mui
sources/..-.*/arunres.dll.mui
sources/..-.*/cmisetup.dll.mui
sources/..-.*/compatctrl.dll.mui
sources/..-.*/compatprovider.dll.mui
sources/..-.*/dism.exe.mui
sources/..-.*/dismapi.dll.mui
sources/..-.*/dismcore.dll.mui
sources/..-.*/dismprov.dll.mui
sources/..-.*/folderprovider.dll.mui
sources/..-.*/imagingprovider.dll.mui
sources/..-.*/input.dll.mui
sources/..-.*/logprovider.dll.mui
sources/..-.*/MediaSetupUIMgr.dll.mui
sources/..-.*/nlsbres.dll.mui
sources/..-.*/pnpibs.dll.mui
sources/..-.*/reagent.adml
sources/..-.*/reagent.dll.mui
sources/..-.*/rollback.exe.mui
sources/..-.*/setup.exe.mui
sources/..-.*/setup_help_upgrade_or_custom.rtf
sources/..-.*/setupcompat.dll.mui
sources/..-.*/SetupCore.dll.mui
sources/..-.*/SetupMgr.dll.mui
sources/..-.*/setupplatform.exe.mui
sources/..-.*/SetupPrep.exe.mui
sources/..-.*/smiengine.dll.mui
sources/..-.*/spwizres.dll.mui
sources/..-.*/upgloader.dll.mui
sources/..-.*/uxlibres.dll.mui
sources/..-.*/vhdprovider.dll.mui
sources/..-.*/vofflps.rtf
sources/..-.*/vofflps_server.rtf
sources/..-.*/w32uires.dll.mui
sources/..-.*/wdsclient.dll.mui
sources/..-.*/wdsimage.dll.mui
sources/..-.*/wimgapi.dll.mui
sources/..-.*/wimprovider.dll.mui
sources/..-.*/WinDlp.dll.mui
sources/..-.*/winsetup.dll.mui'
infoColor="\033[1;94m"
errorColor="\033[1;91m"
resetColor="\033[0m"
if [ "$1" == "-?" -o "$1" == "--help" -o "$1" == "-h" ]; then
echo "Usage:"
echo "$0 [compression] [uups_directory] [create_virtual_editions]"
echo ""
echo -e "${infoColor}compression options:${resetColor}"
echo "wim - standard compression (default)"
echo "esd - solid compression"
echo ""
echo -e "${infoColor}create_virtual_editions options:${resetColor}"
echo "0 - do not create virtual editions (default)"
echo "1 - create virtual edtitions"
echo ""
if [ `uname` == "Linux" ]; then
echo -e "${infoColor}convert_config_linux file${resetColor}"
elif [ `uname` == "Darwin" ]; then
echo -e "${infoColor}convert_config_macos file${resetColor}"
fi
echo "This file can be used to configure some advanced options of this script."
echo "It is required to place configuration in the same directory as script."
echo ""
echo "Possible configuration options:"
echo "VIRTUAL_EDITIONS_LIST='space delimited editions sequence'"
echo ""
echo -e "${infoColor}List of editions created if you enable virtual edtitions creation:${resetColor}"
for edition in $VIRTUAL_EDITIONS_LIST; do
echo "- $edition"
done
echo "When VIRTUAL_EDITIONS_LIST is not configured, this list contains all editions."
exit
fi
for prog in aria2c cabextract wimlib-imagex chntpw; do
which $prog &>/dev/null 2>&1 && continue;
echo "$prog does not seem to be installed"
echo "Check the readme.md for details"
exit 1
done
mkiso_present=0
which genisoimage &>/dev/null && mkiso_present=1
which mkisofs &>/dev/null && mkiso_present=1
if [ $mkiso_present -eq 0 ]; then
echo "genisoimage nor mkisofs does seem to be installed"
echo "Check the readme.md for details"
exit 1
fi
if ! [ -z $1 ]; then
type="$1"
else
type="wim"
fi
if ! [ "$type" == "wim" -o "$type" == "esd" ]; then
echo -e "$errorColor""Incorrect compression type.""$resetColor"
echo "Possible options: wim, esd"
exit 1
fi
if ! [ -z $2 ]; then
uupDir="$2"
else
uupDir="UUPs"
fi
if ! [ -z $3 ]; then
runVirtualEditions="$3"
else
runVirtualEditions=0
fi
if ! [ -d "$uupDir" ]; then
echo -e "$errorColor""Specified directory containing UUP files does not exist!""$resetColor"
exit 1
fi
if [ "$type" == "esd" ]; then
compressParam="--solid"
else
compressParam="--compress=maximum"
type="wim"
fi
function cleanup() {
rm -rf ISODIR
rm -rf "$tempDir"
}
function errorHandler() {
if [ $1 != 0 ]; then
echo -e "${errorColor}$2${resetColor}"
cleanup
exit 1
fi
}
function version() {
echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'
}
if [ -e ISODIR ]; then
rm -rf ISODIR
fi
list=
for i in $editions; do
list="$list -ie \"$i""_..-.*.esd\""
done
metadataFiles=$(find "$uupDir" 2>/dev/null | eval grep $list)
if [ $? != 0 ]; then
echo -e "$errorColor""No metadata ESDs found.""$resetColor"
exit 1
fi
list=
firstMetadata=$(head -1 <<< "$metadataFiles")
getLang=`wimlib-imagex info "$firstMetadata" 3`
lang=`grep -i "^Default Language:" <<< "$getLang" | sed "s/.* //g"`
#lang=$(grep -i "_..-.*.esd" <<< "$metadataFiles" | head -1 | tr '[:upper:]' '[:lower:]' | sed 's/.*_//g;s/.esd//g')
metadataFiles=$(grep -i "$lang" <<< "$metadataFiles" | sort | uniq)
firstMetadata=$(head -1 <<< "$metadataFiles")
tempDir=`mktemp -d`
extractDir="$tempDir/extract"
echo -e "\033[1m$scriptName\033[0m"
updatesDetected=false
for file in `find "$uupDir" -type f -iname "*windows1*-kb*.cab" -or -iname "ssu-*.cab"`; do
updatesDetected=true
done
if [ $updatesDetected == true ]; then
echo -e "\033[33mNote: This script does not and cannot support the integration of updates.\nUse the Windows version of the converter to integrate updates."
fi
if [ $runVirtualEditions -eq 1 ] && [ "$VIRTUAL_EDITIONS_PLUGIN_LOADED" != "1" ]; then
echo "Virtual editions will be not created, because plugin isn't loaded."
runVirtualEditions=0
fi
echo ""
cabextractVersion=$(cabextract --version | cut -d ' ' -f 3)
if [ $(version $cabextractVersion) -ge $(version "1.10") ] ; then
keepSymlinks="-k"
else
keepSymlinks=""
fi
for file in `find "$uupDir" -type f -iname "*.cab" -not -iname "*windows1*-kb*.cab" -not -iname "ssu-*.cab" -not -iname "*desktopdeployment*.cab" -not -iname "*aggregatedmetadata*.cab"`; do
fileName=`basename $file .cab`
echo -e "$infoColor""CAB -> ESD:""$resetColor"" $fileName"
mkdir "$extractDir"
cabextract "$keepSymlinks" -d "$extractDir" "$file" >/dev/null 2>/dev/null
errorHandler $? "Failed to extract $fileName.cab"
wimlib-imagex capture "$extractDir" "$tempDir/$fileName.esd" \
--no-acls --norpfix "Edition Package" "Edition Package" >/dev/null
errorHandler $? "Failed to create $fileName.esd"
rm -rf "$extractDir"
done
fileName=
file=
extractDir=
export WIMLIB_IMAGEX_IGNORE_CASE=1
mkdir ISODIR
echo ""
echo -e "$infoColor""Creating ISO structure...""$resetColor"
wimlib-imagex apply "$firstMetadata" 1 ISODIR --no-acls --no-attributes 2>/dev/null
errorHandler $? "Failed to create ISO structure"
echo ""
echo -e "$infoColor""Exporting winre.wim...""$resetColor"
wimlib-imagex export "$firstMetadata" 2 "$tempDir/winre.wim" \
--compress=maximum --boot
errorHandler $? "Failed to export winre.wim"
echo ""
echo -e "$infoColor""Creating boot.wim...""$resetColor"
cp "$tempDir/winre.wim" ISODIR/sources/boot.wim
wimlib-imagex info ISODIR/sources/boot.wim 1 "Microsoft Windows PE" "Microsoft Windows PE" \
--image-property FLAGS=9 >/dev/null
wimlib-imagex extract ISODIR/sources/boot.wim 1 --dest-dir="$tempDir" \
"/Windows/System32/config/SOFTWARE" --no-acls >/dev/null
errorHandler $? "Failed to extract registry"
echo 'cd Microsoft\Windows NT\CurrentVersion
nv 1 SystemRoot
ed SystemRoot
X:\$Windows.~bt\Windows
cd WinPE
nv 1 InstRoot
ed InstRoot
X:\$Windows.~bt
q
y' | chntpw -e "$tempDir/SOFTWARE" >/dev/null
wimlib-imagex update ISODIR/sources/boot.wim 1 \
--command "add $tempDir/SOFTWARE /Windows/System32/config/SOFTWARE" >/dev/null
wimlib-imagex extract ISODIR/sources/boot.wim 1 "/Windows/System32/winpe.jpg" \
--no-acls --dest-dir="ISODIR/sources" >/dev/null 2>/dev/null
bckimg=background_cli.bmp
if [ -e ./ISODIR/sources/background_svr.bmp ]; then
bckimg=background_svr.bmp
elif [ -e ./ISODIR/sources/background_cli.png ]; then
bckimg=background_cli.png
elif [ -e ./ISODIR/sources/background_svr.png ]; then
bckimg=background_svr.png
elif [ -e ./ISODIR/sources/winpe.jpg ]; then
bckimg=winpe.jpg
fi
wimlib-imagex update ISODIR/sources/boot.wim 1 \
--command "add ISODIR/sources/$bckimg /Windows/system32/winpe.jpg" >/dev/null
wimlib-imagex update ISODIR/sources/boot.wim 1 \
--command "add ISODIR/sources/$bckimg /Windows/system32/winre.jpg" >/dev/null
wimlib-imagex update ISODIR/sources/boot.wim 1 \
--command "delete /Windows/System32/winpeshl.ini" >/dev/null
wimlib-imagex export "$tempDir/winre.wim" 1 \
ISODIR/sources/boot.wim "Microsoft Windows Setup" "Microsoft Windows Setup"
errorHandler $? "Failed to create second index of boot.wim"
wimlib-imagex extract "$firstMetadata" 3 "/Windows/System32/xmllite.dll" \
--no-acls --dest-dir="ISODIR/sources" >/dev/null
wimlib-imagex info ISODIR/sources/boot.wim 2 --image-property FLAGS=2 >/dev/null
wimlib-imagex info ISODIR/sources/boot.wim 2 --boot >/dev/null
list=
for i in $bootSourcesList; do
list="$list -oie \"$i\""
done
files=$(find ISODIR -regex ".*/sources/.*" | eval grep $list)
list=
echo "delete /Windows/System32/winpeshl.ini" >"$tempDir/update.txt"
echo "add ISODIR/setup.exe /setup.exe" >>"$tempDir/update.txt"
echo "add ISODIR/sources/inf/setup.cfg /sources/inf/setup.cfg" >>"$tempDir/update.txt"
echo "add ISODIR/sources/$bckimg /sources/background.bmp" >>"$tempDir/update.txt"
echo "add ISODIR/sources/$bckimg /Windows/system32/setup.bmp" >>"$tempDir/update.txt"
echo "add ISODIR/sources/$bckimg /Windows/system32/winpe.jpg" >>"$tempDir/update.txt"
echo "add ISODIR/sources/$bckimg /Windows/system32/winre.jpg" >>"$tempDir/update.txt"
for i in $files; do
echo "add ISODIR/$i /$i" >>"$tempDir/update.txt"
done
wimlib-imagex update ISODIR/sources/boot.wim 2 <"$tempDir/update.txt" >/dev/null
errorHandler $? "Failed to add required files to second index of boot.wim"
wimlib-imagex optimize ISODIR/sources/boot.wim
rm "ISODIR/sources/xmllite.dll"
if [ -e ./ISODIR/sources/winpe.jpg ]; then
rm "ISODIR/sources/winpe.jpg"
fi
refglobs=false
for file in `find "$tempDir" -type f -iname "*.esd"`; do
refglobs=true
done
echo ""
indexesExported=0
for metadata in $metadataFiles; do
currentInfo=`wimlib-imagex info "$metadata" 3`
currentEdition=`grep -i "^Edition ID:" <<< "$currentInfo" | sed "s/.* //g"`
currentName=`grep -i "^Name:" <<< "$currentInfo" | sed "s/.* //g"`
currentType=`grep -i "^Installation Type:" <<< "$currentInfo" | sed "s/.* //g"`
if [ "$currentType" == "Server Core" ] && [ "$currentEdition" == "ServerStandard" ]; then
currentEdition="ServerStandardCore"
fi
if [ "$currentType" == "Server Core" ] && [ "$currentEdition" == "ServerDatacenter" ]; then
currentEdition="ServerDatacenterCore"
fi
editionName="Windows 10 $currentEdition"
if echo $currentName | grep -ow "Windows 11" >/dev/null; then
editionName="Windows 11 $currentEdition"
fi
if echo $currentEdition | grep -i "^Server" >/dev/null; then
editionName="Windows Server 2022 $currentEdition"
fi
echo -e "$infoColor""Exporting $editionName to install.$type...""$resetColor"
if [ $refglobs == true ]; then
wimlib-imagex export "$metadata" 3 ISODIR/sources/install.$type \
"$editionName" $compressParam --ref={"$uupDir","$tempDir"}/*.[eE][sS][dD]
else
wimlib-imagex export "$metadata" 3 ISODIR/sources/install.$type \
"$editionName" $compressParam --ref="$uupDir"/*.[eE][sS][dD]
fi
errorHandler $? "Failed to export $editionName to install.$type""$resetColor"
let indexesExported++
wimlib-imagex info ISODIR/sources/install.$type $indexesExported \
--image-property FLAGS="$currentEdition" >/dev/null
echo ""
echo -e "$infoColor""Adding winre.wim for $editionName...""$resetColor"
wimlib-imagex update ISODIR/sources/install.$type $indexesExported \
--command "add $tempDir/winre.wim /Windows/System32/Recovery/winre.wim"
echo ""
done
info=`wimlib-imagex info "$firstMetadata" 3`
build=`grep -i "^Build:" <<< "$info" | sed "s/.* //g"`
addedVirtualEditions=0
if [ $runVirtualEditions -eq 1 ] && [ $build -ge 17063 ]; then
echo -e "$infoColor""Creating virtual editions...""$resetColor"
for virtualEdition in $VIRTUAL_EDITIONS_LIST; do
echo -e "$infoColor""Adding $virtualEdition edition...""$resetColor"
createVirtualEdition "$virtualEdition"
error=$?
if [ $error -ne 1 ]; then
errorHandler $error "Failed to create virtual edition"
let addedVirtualEditions++
fi
echo ""
done
elif [ $build -lt 17063 ]; then
echo "Virtual editions creation requires build 17063 or later"
fi
let indexesSum=$addedVirtualEditions+$indexesExported
spbuild=`grep -i "^Service Pack Build:" <<< "$info" | sed "s/.* //g"`
arch=`grep -i "^Architecture:" <<< "$info" | sed "s/.* //g"`
if [ "$arch" == "x86_64" ]; then
arch="x64"
fi
if [ $indexesSum -gt 1 ]; then
isoEdition="MULTI"
else
isoEdition=`grep -i "^Edition ID:" <<< "$info" | sed "s/.* //g"`
fi
isoLabel=`tr "[:lower:]" "[:upper:]" <<< "${build}.${spbuild}_${arch}_${lang}"`
isoName=`tr "[:lower:]" "[:upper:]" <<< "${build}.${spbuild}_${isoEdition}_${arch}_${lang}.iso"`
if [ -e "$isoName" ]; then
rm "$isoName"
fi
if [ $addedVirtualEditions -ge 1 ]; then
echo -e "$infoColor""Optimizing install.$type...""$resetColor"
wimlib-imagex optimize ISODIR/sources/install.$type
echo ""
fi
if [ $build -ge 18890 ]; then
wimlib-imagex extract "$firstMetadata" 3 "/Windows/Boot/Fonts" \
--no-acls --dest-dir="ISODIR/boot" >/dev/null
mv -f ISODIR/boot/Fonts/* ISODIR/boot/fonts
cp ISODIR/boot/fonts/* ISODIR/efi/microsoft/boot/fonts
rm -r ISODIR/boot/Fonts
fi
echo -e "$infoColor""Creating ISO image...""$resetColor"
find ISODIR -exec touch {} +
# Use mkisofs as fallback to genisoimage
genisoimage="$(command -v genisoimage)"
if [ -z "$genisoimage" ]; then
genisoimage="$(command -v mkisofs)"
fi
if [ "$arch" == "arm64" ]; then
"$genisoimage" -b "efi/microsoft/boot/efisys.bin" --no-emul-boot \
--udf -iso-level 3 --hide "*" -V "$isoLabel" -o "$isoName" ISODIR
else
"$genisoimage" -b "boot/etfsboot.com" --no-emul-boot \
--eltorito-alt-boot -b "efi/microsoft/boot/efisys.bin" --no-emul-boot \
--udf -iso-level 3 --hide "*" -V "$isoLabel" -o "$isoName" ISODIR
fi
errorHandler $? "Failed to create ISO image""$resetColor"
cleanup
echo -e "\033[1;92mDone.""$resetColor"