-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathYUMI.nsi
1308 lines (1168 loc) · 49.7 KB
/
YUMI.nsi
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
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
; YUMI (Your Universal Multiboot Installer) Copyright ©2011-2016 Lance http://www.pendrivelinux.com (See YUMI-Copying.txt and YUMI-Readme.txt for more information, Credits, and Licensing)
; 7-Zip Copyright © Igor Pavlovis http://7-zip.org (unmodified binaries were used)
; Syslinux © H. Peter Anvin http://syslinux.zytor.com (unmodified binary used)
; Firadisk.img © Panot Joonkhiaw Karyonix http://reboot.pro/8804/ (unmodified binary used)
; grub.exe Grub4DOS © the Gna! people + Chenall https://code.google.com/p/grub4dos-chenall/ (unmodified binary used) : Official Grub4DOS: http://gna.org/projects/grub4dos/
; Fat32format.exe © Tom Thornhill Ridgecorp Consultants http://www.ridgecrop.demon.co.uk (unmodified binary used)
; NSIS Installer © Contributors http://nsis.sourceforge.net - Install NSIS to compile this script. http://nsis.sourceforge.net/Download
; YUMI may contain remnants of Cedric Tissieres's Tazusb.exe for Slitaz ([email protected]), as his work was used as a base for singular distro installers that preceded YUMI.
!define NAME "YUMI"
!define FILENAME "YUMI"
!define VERSION "2.0.2.0"
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\nsis1-install.ico"
; MoreInfo Plugin - Adds Version Tab fields to Properties. Plugin created by onad http://nsis.sourceforge.net/MoreInfo_plug-in
VIProductVersion "${VERSION}"
VIAddVersionKey CompanyName "pendrivelinux.com"
VIAddVersionKey LegalCopyright "Copyright ©2010-2015 Lance Pendrivelinux.com"
VIAddVersionKey FileVersion "${VERSION}"
VIAddVersionKey FileDescription "Automated Universal MultiBoot UFD Creation Tool"
VIAddVersionKey License "GPL Version 2"
Name "${NAME} ${VERSION}"
OutFile "${FILENAME}-${VERSION}.exe"
RequestExecutionLevel admin ;highest
SetCompressor LZMA
CRCCheck On
XPStyle on
ShowInstDetails show
BrandingText "${NAME} ${VERSION}"
CompletedText "All Finished, Process is Complete!"
InstallButtonText "Create"
!include WordFunc.nsh
!include nsDialogs.nsh
!include MUI2.nsh
!include FileFunc.nsh
!include LogicLib.nsh
;!include TextFunc.nsh
!AddPluginDir "plugins"
; Variables
Var Capacity
Var VolName
Var Checker
Var FileFormat
Var Format
Var FormatMe
Var BlockSize
Var Dialog
Var LabelDrivePage
Var Distro
Var DistroName
Var ISOFileName
Var DestDriveTxt
Var JustDrive
Var DestDrive
Var BootDir
Var LinuxDistroSelection
Var LabelISOSelection
Var ISOFileTxt
Var TheISO
Var IsoFile
Var ISOSelection
Var ISOTest
Var JustISO
Var JustISOName
Var JustISOPath
Var ConfigFile
Var ConfigPath
Var CopyPath
Var SearchDir
Var SearchFile
Var DestDisk
Var DownloadISO
Var DownloadMe
Var Link
Var Links
Var Auth
Var DownLink
Var LocalSelection
Var Letters
Var Config2Use
Var SomeFileExt
Var AllDriveOption
Var DisplayAll
Var DistroLink
Var Homepage
Var OfficialSite
Var OfficialName
Var NameThatISO
Var OnlyVal
Var Uninstaller
Var Removal
Var InUnStall
Var SUSEDIR
Var RepeatInstall
Var ShowAll
Var ForceShowAll
Var ShowingAll
Var SizeOfCasper
Var Casper
Var CasperSlider
Var CasperSelection
Var SlideSpot
Var RemainingSpace
Var MaxPersist
Var Persistence
!include DiskVoodoo.nsh ; DiskVoodoo Script created by Lance http://www.pendrivelinux.com
; Interface settings
!define MUI_FINISHPAGE_NOAUTOCLOSE
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "usb-logo-nsis.bmp"
!define MUI_HEADERIMAGE_BITMAP_NOSTRETCH
!define MUI_HEADERIMAGE_RIGHT
; License Agreement Page
!define MUI_TEXT_LICENSE_SUBTITLE $(License_Subtitle)
!define MUI_LICENSEPAGE_TEXT_TOP $(License_Text_Top)
!define MUI_LICENSEPAGE_TEXT_BOTTOM $(License_Text_Bottom)
!define MUI_PAGE_CUSTOMFUNCTION_PRE License_PreFunction
!insertmacro MUI_PAGE_LICENSE "YUMI-Copying.txt"
; Distro Selection Page
Page custom SelectionsPage
; Install Files Page
!define MUI_INSTFILESPAGE_COLORS "00FF00 000000" ;Green and Black
!define MUI_INSTFILESPAGE_FINISHHEADER_TEXT $(Finish_Install)
!define MUI_TEXT_INSTALLING_TITLE $(Install_Title)
!define MUI_TEXT_INSTALLING_SUBTITLE $(Install_SubTitle)
!define MUI_TEXT_FINISH_SUBTITLE $(Install_Finish_Sucess)
!define MUI_PAGE_CUSTOMFUNCTION_PRE InstFiles_PreFunction
!insertmacro MUI_PAGE_INSTFILES
; Finish page
!define MUI_FINISHPAGE_TITLE $(Finish_Title)
!define MUI_FINISHPAGE_TEXT $(Finish_Text)
!define MUI_FINISHPAGE_LINK $(Finish_Link)
!define MUI_FINISHPAGE_LINK_LOCATION "http://www.pendrivelinux.com/boot-multiple-iso-from-usb-multiboot-usb/"
!define MUI_WELCOMEFINISHPAGE_BITMAP "finish.bmp"
!define MUI_PAGE_CUSTOMFUNCTION_PRE Finish_PreFunction
!insertmacro MUI_PAGE_FINISH
; English Language files
!insertmacro MUI_LANGUAGE "English" ; first language is the default language
LangString License_Subtitle ${LANG_ENGLISH} "Please review the license terms before proceeding"
LangString License_Text_Top ${LANG_ENGLISH} "The software within this program falls under the following Licenses."
LangString License_Text_Bottom ${LANG_ENGLISH} "You must accept the terms of this License agreement to run this ${NAME}. If you agree, Click I Agree to Continue."
LangString SelectDist_Title ${LANG_ENGLISH} "Drive Selection and Distro Options Page"
LangString SelectDist_Subtitle ${LANG_ENGLISH} "Choose your Flash Drive, and a Distro, ISO/ZIP file.$\r$\nAdditional Distributions can be added each time this tool is run."
LangString DrivePage_Text ${LANG_ENGLISH} "Step 1: Select the drive letter of your USB device."
LangString Distro_Text ${LANG_ENGLISH} "Step 2: Select a Distribution from the list to put on your USB."
LangString IsoPage_Text ${LANG_ENGLISH} "Step 3: Select the $FileFormat (Name must be the same as above)."
LangString IsoPage_Title ${LANG_ENGLISH} "Select Your $FileFormat"
LangString Casper_Text ${LANG_ENGLISH} "Step 4: Set a Persistent file size for storing changes (Optional)."
LangString IsoFile ${LANG_ENGLISH} "$FileFormat file|$ISOFileName" ;$ISOFileName variable previously *.iso
LangString Extract ${LANG_ENGLISH} "Extracting the $FileFormat: The progress bar will not move until finished. Please be patient..."
LangString CreateSysConfig ${LANG_ENGLISH} "Creating configuration files for $DestDisk"
LangString ExecuteSyslinux ${LANG_ENGLISH} "Executing syslinux on $BootDir"
LangString SkipSyslinux ${LANG_ENGLISH} "Good Syslinux Exists..."
LangString WarningSyslinux ${LANG_ENGLISH} "An error ($R8) occurred while executing syslinux.$\r$\nYour USB drive won't be bootable..."
LangString WarningSyslinuxOLD ${LANG_ENGLISH} "This YUMI revision uses a newer Syslinux version that is not compatible with earlier revisions.$\r$\nPlease ensure your USB drive doesn't contain earlier revision installs."
LangString Install_Title ${LANG_ENGLISH} "$InUnStall $ISOFileName"
LangString Install_SubTitle ${LANG_ENGLISH} "Please wait while we $InUnStall $DistroName on $JustDrive"
LangString Install_Finish_Sucess ${LANG_ENGLISH} "${NAME} sucessfully $InUnStalled $DistroName on $JustDrive"
LangString Finish_Install ${LANG_ENGLISH} "$InUnStallation is Complete."
LangString Finish_Title ${LANG_ENGLISH} "${NAME} has completed the $InUnStallation."
LangString Finish_Text ${LANG_ENGLISH} "Your Selections have been $InUnStalled on your USB drive.$\r$\n$\r$\nFeel Free to run this tool again to $InUnStall more Distros.$\r$\n$\r$\nYUMI will keep track of selections you have already $InUnStalled."
LangString Finish_Link ${LANG_ENGLISH} "Visit the YUMI Tutorial Page"
!include FileManipulation.nsh ; Text File Manipulation
!include FileNames.nsh ; Macro for FileNames
!include DistroList.nsh ; List of Distributions
!include "CasperScript.nsh" ; For creation of Persistent Casper-rw files
Function License_PreFunction
StrCpy $R8 1 ;This is the 1st page
FunctionEnd
Function SelectionsPage
StrCpy $R8 2
!insertmacro MUI_HEADER_TEXT $(SelectDist_Title) $(SelectDist_Subtitle)
nsDialogs::Create 1018
Pop $Dialog
${If} $RepeatInstall == "YES"
${NSD_SetText} $DestDriveTxt "$DestDrive"
; To Install or Uninstall? That is the question!
${NSD_CreateCheckBox} 60% 0 44% 15 "View or Remove Installed Distros?"
Pop $Uninstaller
${NSD_OnClick} $Uninstaller Uninstall
; Distro Selection Starts
${NSD_CreateLabel} 0 50 50% 15 $(Distro_Text)
Pop $LinuxDistroSelection
${NSD_CreateDroplist} 0 70 55% 95 "" ; was ${NSD_CreateListBox} ; Enable For DropBox
Pop $Distro
${NSD_OnChange} $Distro OnSelectDistro
${NSD_CB_SelectString} $Distro $DistroName ; Was ${NSD_LB_SelectString} $Distro $DistroName ; Enable For DropBox
; Force Show All ISO Option
${NSD_CreateCheckBox} 80% 100 20% 15 "Show All ISOs?"
Pop $ForceShowAll
${NSD_OnClick} $ForceShowAll ShowAllISOs
; ISO Download Option
${NSD_CreateCheckBox} 60% 60 40% 15 "Download the ISO (Optional)."
Pop $DownloadISO
${NSD_OnClick} $DownloadISO DownloadIt
; Clickable Link to Distribution Homepage
${NSD_CreateLink} 60% 80 40% 15 "Visit the $OfficialName HomePage"
Pop $DistroLink
${NSD_OnClick} $DistroLink onClickLinuxSite
; ISO Selection Starts
${NSD_CreateLabel} 0 100 100% 15 $(IsoPage_Text)
Pop $LabelISOSelection
${NSD_CreateText} 0 120 78% 20 "Browse to and select the $FileFormat"
Pop $ISOFileTxt
${NSD_CreateBrowseButton} 85% 120 60 20 "Browse"
Pop $ISOSelection
${NSD_OnClick} $ISOSelection ISOBrowse
; Casper-RW Selection Starts
${NSD_CreateLabel} 0 150 75% 15 $(Casper_Text)
Pop $CasperSelection
; CasperSlider - TrackBar
!define TBM_SETPOS 0x0405
!define TBM_GETPOS 0x0400
!define TBM_SETRANGEMIN 0x0407
!define TBM_SETRANGEMAX 0x0408
${NSD_CreateLabel} 52% 178 25% 25 ""
Pop $SlideSpot
nsDialogs::CreateControl "msctls_trackbar32" "0x50010000|0x00000018" "" 0 174 50% 25 ""
Pop $CasperSlider
SendMessage $CasperSlider ${TBM_SETRANGEMIN} 1 0 ; Min Range Value 0
SendMessage $CasperSlider ${TBM_SETRANGEMAX} 1 $RemainingSpace ; Max Range Value $RemainingSpace
${NSD_OnNotify} $CasperSlider onNotify_CasperSlider
; Drive Pre-Selection
${NSD_CreateLabel} 0 0 58% 15 ""
Pop $LabelDrivePage
${NSD_SetText} $LabelDrivePage "Step 1: YUMI Summoned $DestDisk as your USB Device"
; Droplist for Drive Selection
${NSD_CreateDropList} 0 20 28% 15 "" ; was 0 20 15% 15
Pop $DestDriveTxt
${If} $ShowAll == "YES"
${GetDrives} "ALL" DrivesList ; All Drives Listed
${ElseIf} $ShowAll == "NO"
${GetDrives} "FDD" DrivesList ; FDD+HDD reduced to FDD for removable media only
${EndIf}
${NSD_CB_SelectString} $DestDriveTxt "$DestDrive"
StrCpy $JustDrive $DestDrive 3
StrCpy $BootDir $DestDrive 2 ;was -1
StrCpy $DestDisk $DestDrive 2 ;was -1
SendMessage $Distro ${CB_RESETCONTENT} 0 0 ; was ${NSD_LB_Clear} $Distro "" ; Clear all distro entries because a new drive may have been chosen ; Enable for DropBox
StrCpy $Checker "Yes"
Call InstallorRemove
Call CheckSpace
Call FormatIt
Call EnableNext
${NSD_OnChange} $DestDriveTxt OnSelectDrive
; All Drives Option
${NSD_CreateCheckBox} 30% 23 30% 15 "Show All Drives?" ; was 17% 23 41% 15
Pop $AllDriveOption
${NSD_OnClick} $AllDriveOption ListAllDrives
; Format Drive Option
${NSD_CreateCheckBox} 60% 23 100% 15 "Format $DestDisk Drive (Erase Content)?"
Pop $Format
${NSD_OnClick} $Format FormatIt
; Add Help Link
${NSD_CreateLink} 0 215 65% 15 "Click HERE to visit the YUMI page for additional Help!"
Pop $Link
${NSD_OnClick} $LINK onClickMyLink
; Disable Next Button until a selection is made for all
GetDlgItem $6 $HWNDPARENT 1
EnableWindow $6 0
; Remove Back Button
GetDlgItem $6 $HWNDPARENT 3
ShowWindow $6 0
; Hide or disable steps until we state to display them
EnableWindow $LabelISOSelection 0
EnableWindow $ISOFileTxt 0
ShowWindow $ISOSelection 0
EnableWindow $DownloadISO 0
ShowWindow $DistroLink 0
StrCpy $JustISOName "NULL" ; Set to NULL until something is selected
nsDialogs::Show
${Else}
; To Install or Uninstall? That is the question!
${NSD_CreateCheckBox} 60% 0 44% 15 "View or Remove Installed Distros?"
Pop $Uninstaller
${NSD_OnClick} $Uninstaller Uninstall
; Drive Selection Starts
${NSD_CreateLabel} 0 0 58% 15 ""
Pop $LabelDrivePage
${NSD_SetText} $LabelDrivePage "Step 1: Select the Drive Letter of your USB Device."
; Droplist for Drive Selection
${NSD_CreateDropList} 0 20 28% 15 "" ; was 0 20 15% 15
Pop $DestDriveTxt
Call ListAllDrives
${NSD_OnChange} $DestDriveTxt OnSelectDrive
; All Drives Option
${NSD_CreateCheckBox} 30% 23 30% 15 "Show All Drives?" ; was 17% 23 41% 15
Pop $AllDriveOption
${NSD_OnClick} $AllDriveOption ListAllDrives
; Format Drive Option
${NSD_CreateCheckBox} 60% 23 100% 15 "Format $DestDisk Drive (Erase Content)?"
Pop $Format
${NSD_OnClick} $Format FormatIt
; Distro Selection Starts
${NSD_CreateLabel} 0 50 50% 15 $(Distro_Text)
Pop $LinuxDistroSelection
${NSD_CreateDropList} 0 70 55% 95 "" ; was ${NSD_CreateListBox} ; Enable for Dropbox
Pop $Distro
${NSD_OnChange} $Distro OnSelectDistro
${NSD_CB_SelectString} $Distro $DistroName ; Was ${NSD_LB_SelectString} $Distro $DistroName ; Enable For DropBox
; Force Show All ISO Option
${NSD_CreateCheckBox} 80% 100 20% 15 "Show All ISOs?"
Pop $ForceShowAll
${NSD_OnClick} $ForceShowAll ShowAllISOs
; ISO Download Option
${NSD_CreateCheckBox} 60% 60 40% 15 "Download the ISO (Optional)."
Pop $DownloadISO
${NSD_OnClick} $DownloadISO DownloadIt
; Clickable Link to Distribution Homepage
${NSD_CreateLink} 60% 80 40% 15 "Visit the $OfficialName HomePage"
Pop $DistroLink
${NSD_OnClick} $DistroLink onClickLinuxSite
; ISO Selection Starts
${NSD_CreateLabel} 0 100 100% 15 $(IsoPage_Text)
Pop $LabelISOSelection
${NSD_CreateText} 0 120 78% 20 "Browse to and select the $FileFormat"
Pop $ISOFileTxt
${NSD_CreateBrowseButton} 85% 120 60 20 "Browse"
Pop $ISOSelection
${NSD_OnClick} $ISOSelection ISOBrowse
; Casper-RW Selection Starts
${NSD_CreateLabel} 0 150 75% 15 $(Casper_Text)
Pop $CasperSelection
; CasperSlider - TrackBar
; !define TBM_SETPOS 0x0405
; !define TBM_GETPOS 0x0400
; !define TBM_SETRANGEMIN 0x0407
; !define TBM_SETRANGEMAX 0x0408
${NSD_CreateLabel} 52% 178 25% 25 ""
Pop $SlideSpot
nsDialogs::CreateControl "msctls_trackbar32" "0x50010000|0x00000018" "" 0 174 50% 25 ""
Pop $CasperSlider
SendMessage $CasperSlider ${TBM_SETRANGEMIN} 1 0 ; Min Range Value 0
SendMessage $CasperSlider ${TBM_SETRANGEMAX} 1 $RemainingSpace ; Max Range Value $RemainingSpace
${NSD_OnNotify} $CasperSlider onNotify_CasperSlider
; Add Help Link
${NSD_CreateLink} 0 215 65% 15 "Click HERE to visit the YUMI page for additional Help!"
Pop $Link
${NSD_OnClick} $LINK onClickMyLink
;; Add a custom donate button
; ${NSD_CreateBitmap} 80% 125 20% 50 "PayPal Donation"
; Var /Global Donate
; Var /Global DonateHandle
; Pop $Donate
; ${NSD_SetImage} $Donate $PLUGINSDIR\paypal.bmp $DonateHandle
; GetFunctionAddress $DonateHandle OnClickDonate
; nsDialogs::OnClick $Donate $DonateHandle
; Disable Next Button until a selection is made for all
GetDlgItem $6 $HWNDPARENT 1
EnableWindow $6 0
; Remove Back Button
GetDlgItem $6 $HWNDPARENT 3
ShowWindow $6 0
; Hide or disable steps until we state to display them
EnableWindow $LabelISOSelection 0
EnableWindow $ISOFileTxt 0
ShowWindow $ISOSelection 0
EnableWindow $LinuxDistroSelection 0
EnableWindow $Distro 0
EnableWindow $DownloadISO 0
ShowWindow $DistroLink 0
ShowWindow $CasperSelection 0
ShowWindow $CasperSlider 0
ShowWindow $SlideSpot 0
ShowWindow $Format 0
ShowWindow $ForceShowAll 0
ShowWindow $Uninstaller 0
nsDialogs::Show
; ${NSD_FreeImage} $DonateHandle
${EndIf}
FunctionEnd
; Function OnClickDonate
; ExecShell "open" "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=T6K3C62LC5TCG"
; FunctionEnd
Function InstFiles_PreFunction
StrCpy $R8 3
FunctionEnd
Function Finish_PreFunction
StrCpy $R8 4
Call NoQuit
FunctionEnd
Function ListAllDrives ; Set to Display All Drives
SendMessage $DestDriveTxt ${CB_RESETCONTENT} 0 0
${NSD_GetState} $AllDriveOption $DisplayAll
${If} $DisplayAll == ${BST_CHECKED}
${NSD_Check} $AllDriveOption
${NSD_SetText} $AllDriveOption "Showing All Drives"
StrCpy $ShowAll "YES"
${GetDrives} "ALL" DrivesList ; All Drives Listed
${ElseIf} $DisplayAll == ${BST_UNCHECKED}
${NSD_Uncheck} $AllDriveOption
${NSD_SetText} $AllDriveOption "Show All Drives?"
${GetDrives} "FDD" DrivesList ; FDD+HDD reduced to FDD for removable media only
StrCpy $ShowAll "NO"
${EndIf}
FunctionEnd
Function onClickMyLink
Pop $Links ; pop something to prevent corruption
ExecShell "open" "http://www.pendrivelinux.com/yumi-multiboot-usb-creator/"
FunctionEnd
Function onClickLinuxSite
Pop $OfficialSite
ExecShell "open" "$Homepage"
FunctionEnd
Function DownloadIt ; Set Download Option
${NSD_GetState} $DownloadISO $DownloadMe
${If} $DownloadMe == ${BST_CHECKED}
${NSD_Check} $DownloadISO
${NSD_SetText} $DownloadISO "Opened Download Link"
Call DownloadLinks
${ElseIf} $DownloadMe == ${BST_UNCHECKED}
${NSD_Uncheck} $DownloadISO
${NSD_SetText} $DownloadISO "Download Link"
${EndIf}
FunctionEnd
Function EnableNext ; Enable Install Button
${If} $Blocksize >= 4
${AndIf} $Removal != "Yes"
ShowWindow $Format 1
${Else}
ShowWindow $Format 0
${EndIf}
${If} $Removal != "Yes"
${AndIf} $ISOFileName != ""
${AndIf} $ISOFile != ""
${AndIf} $DestDrive != ""
${AndIf} $ISOTest != ""
StrCpy $InUnStall "Install"
GetDlgItem $6 $HWNDPARENT 1 ; Get "Install" control handle
SendMessage $6 ${WM_SETTEXT} 0 "STR:Create"
EnableWindow $6 1 ; Enable "Install" control button
${ElseIf} $Removal == "Yes"
${AndIf} $ISOFileName != ""
${AndIf} $DestDrive != ""
${AndIf} $ISOTest != ""
StrCpy $InUnStall "UnInstall"
GetDlgItem $6 $HWNDPARENT 1 ; Get "Install" control handle
SendMessage $6 ${WM_SETTEXT} 0 "STR:Remove"
EnableWindow $6 1 ; Enable "Install" control button
${EndIf}
; Test if ISO has been Selected. If not, disable Install Button
${If} $ISOTest == ""
GetDlgItem $6 $HWNDPARENT 1
EnableWindow $6 0 ; Disable "Install" if ISO not set
${EndIf}
; Show Steps in progression
${If} $DestDrive != ""
EnableWindow $LinuxDistroSelection 1
EnableWindow $Distro 1
${EndIf}
${If} $ISOFileName != ""
${AndIf} $Removal != "Yes"
EnableWindow $LabelISOSelection 1
EnableWindow $ISOFileTxt 1
ShowWindow $ISOSelection 1
${AndIf} $Removal == "Yes"
EnableWindow $LabelISOSelection 0
EnableWindow $ISOFileTxt 0
ShowWindow $ISOSelection 0
${EndIf}
; Disable Window if ISO was downloaded
${If} $TheISO == "$EXEDIR\$ISOFileName"
${AndIf} $ISOTest != ""
EnableWindow $ISOSelection 0
SetCtlColors $ISOFileTxt 009900 FFFFFF
${EndIf}
; If using Casper Persistence...
${If} $Persistence == "casper" ; If can use Casper Persistence...
${AndIf} $TheISO != ""
${AndIf} $BootDir != ""
ShowWindow $CasperSelection 1
ShowWindow $CasperSlider 1
ShowWindow $SlideSpot 1
;${NSD_SetText} $Format "Format $JustDrive Drive (Erases Content)"
; Else If not using Casper Persistence...
${ElseIf} $Persistence != "casper" ; Eventually change to "NULL"
${OrIf} $Removal == "Yes"
ShowWindow $CasperSelection 0
ShowWindow $CasperSlider 0
ShowWindow $SlideSpot 0
;${NSD_SetText} $Format "Format $JustDrive Drive (Erases Content)"
${EndIf}
FunctionEnd
Function DownloadLinks
MessageBox MB_YESNO|MB_ICONQUESTION "Launch the Download Link?$\r$\nLet the download finish before moving to step 2." IDYES DownloadIt IDNO Skip
Skip: ; Reset Download Checkbox Options
${NSD_Uncheck} $DownloadISO
${NSD_SetText} $DownloadISO "Download Link"
EnableWindow $DownloadISO 1
Goto end
DownloadIt:
${NSD_SetText} $LabelISOSelection "Step 3: Once your download has finished, Browse and select the ISO."
EnableWindow $DownloadISO 0
ExecShell "open" "$DownLink"
end:
FunctionEnd
Function LocalISODetected ; The script autodetected the ISO, so let's do the following
${If} $DownloadMe != ${BST_CHECKED}
${AndIf} $LocalSelection != "Yes"
StrCpy $ISOFile "$EXEDIR\$ISOFileName"
${EndIf}
FunctionEnd
; get only the filename
Function GrabNameOnly
Exch $4 ; count to get part
Exch
Exch $0 ; input string
Push $1
Push $2
Push $3
StrCpy $1 0
StrCpy $3 1
loop:
IntOp $1 $1 - 1
StrCpy $2 $0 1 $1
StrCmp $2 "" exit2
StrCmp $2 "\" next ; grab text to the right of "\"
Goto loop
next:
StrCmp $3 $4 exit
IntOp $3 $3 + 1
Goto loop
exit2:
IntOp $1 $1 - 1
exit:
IntOp $1 $1 + 1
StrCpy $0 $0 "" $1
Pop $3
Pop $2
Pop $1
Exch $0 ; output string
FunctionEnd
!include StrContains.nsh ; Let's check if a * wildcard exists
; On Selection of Linux Distro
Function OnSelectDistro
Pop $Distro
${If} $Removal == "Yes"
ShowWindow $ForceShowAll 0
${Else}
ShowWindow $ForceShowAll 1
${EndIf}
${NSD_GetText} $Distro $DistroName ; Was ${NSD_LB_GetSelection} $Distro $DistroName
StrCpy $DistroName "$DistroName"
StrCpy $Checker "No"
${If} $Removal == "Yes"
StrCpy $ISOFileName "$DistroName"
StrCpy $ISOTest "$DistroName"
${Else}
Call SetISOFileName
StrCpy $ISOFileName "$ISOFileName"
StrCpy $SomeFileExt "$ISOFileName" "" -3 ; Grabs the last 3 characters of the file name... zip or iso?
StrCpy $FileFormat "$SomeFileExt" ; Set file type to look for zip, tar, iso etc...
${NSD_SetText} $LabelISOSelection "Step 3: Browse and Select your $ISOFileName"
${NSD_SetText} $ISOFileTxt "Browse to your $ISOFileName -->"
SetCtlColors $ISOFileTxt FF0000 FFFFFF
StrCpy $ISOTest "" ; Set to null until a new ISO selection is made
${EndIf}
; Redraw Home page Links as necessary
${NSD_SetText} $DistroLink "Visit the $OfficialName Home Page"
ShowWindow $DistroLink 0
${If} $OfficialName == ""
${OrIf} $Removal == "Yes"
ShowWindow $DistroLink 0
${Else}
ShowWindow $DistroLink 1
${EndIf}
; Autodetect ISO's in same folder and select if they exist
${If} ${FileExists} "$EXEDIR\$ISOFileName"
${AndIf} $Removal != "Yes"
${StrContains} $WILD "*" "$ISOFileName" ; Check for Wildcard and force Browse if * exists.
${AndIf} $WILD != "*"
StrCpy $TheISO "$EXEDIR\$ISOFileName"
StrCpy $ISOFile "$TheISO"
${GetFileName} "$TheISO" $JustISO
${GetBaseName} "$JustISO" $JustISOName
${GetParent} "$TheISO" $JustISOPath
EnableWindow $DownloadISO 0
${NSD_SetText} $DownloadISO "We Found and Selected the $SomeFileExt."
EnableWindow $ISOSelection 0
SetCtlColors $ISOFileTxt 009900 FFFFFF
${NSD_SetText} $ISOFileTxt $ISOFile
${NSD_SetText} $LabelISOSelection "Step 3 DONE: $ISOFileName Found and Selected!"
StrCpy $ISOTest "$TheISO" ; Populate ISOTest so we can enable Next
Call EnableNext
${ElseIf} ${FileExists} "$EXEDIR\$ISOFileName"
${AndIf} $Removal != "Yes"
${AndIf} $WILD == "*"
EnableWindow $DownloadISO 1
EnableWindow $ISOSelection 1
${NSD_Uncheck} $DownloadISO
${NSD_SetText} $DownloadISO "Download Link"
SetCtlColors $ISOFileTxt FF9B00 FFFFFF
${NSD_SetText} $ISOFileTxt "Browse to and select the $ISOFileName"
${NSD_SetText} $LabelISOSelection "Step 3 PENDING: Browse to your $ISOFileName"
Call EnableNext
${Else}
Call EnableNext
EnableWindow $DownloadISO 1
EnableWindow $ISOSelection 1
${NSD_Uncheck} $DownloadISO
${NSD_SetText} $DownloadISO "Download Link"
${EndIf}
${If} $DownLink == "NONE"
${OrIf} $Removal == "Yes"
ShowWindow $DownloadISO 0
${Else}
ShowWindow $DownloadISO 1
${EndIf}
FunctionEnd
; On Selection of ISO File
Function ISOBrowse
${If} $ShowingAll == "Yes"
StrCpy $ISOFileName "*.iso"
${ElseIf} $ShowingAll != "Yes"
Call SetISOFileName
${EndIf}
nsDialogs::SelectFileDialog open "" $(IsoFile)
Pop $TheISO
${NSD_SetText} $ISOFileTxt $TheISO
SetCtlColors $ISOFileTxt 009900 FFFFFF
EnableWindow $DownloadISO 0
${NSD_SetText} $DownloadISO "Local $SomeFileExt Selected."
StrCpy $ISOTest "$TheISO" ; Populate ISOTest so we can enable Next
StrCpy $ISOFile "$TheISO"
${GetFileName} "$TheISO" $JustISO
${GetBaseName} "$JustISO" $JustISOName
${GetParent} "$TheISO" $JustISOPath
StrCpy $LocalSelection "Yes"
Call SetISOSize
${If} $JustISOName == ""
StrCpy $JustISOName "NULL" ; Set to NULL until something is selected
${EndIf}
${If} ${FileExists} "$BootDir\multiboot\$JustISOName\*.*"
${AndIf} $JustISOName != ""
${AndIf} $FormatMe != "Yes"
MessageBox MB_OK "$JustISOName is already on $DestDisk$\r$\nPlease Remove it first!"
${Else}
${EndIf}
Call EnableNext
; Uncomment for Testing --> MessageBox MB_ICONQUESTION|MB_OK 'Removal: "$Removal" ISOFileName: "$ISOFileName" ISOFile "$ISOFile" BootDir: "$BootDir" DestDisk: "$DestDisk" DestDrive: "$DestDrive" ISOTest: "$ISOTest"'
FunctionEnd
Function ClearAll
StrCpy $ISOTest ""
StrCpy $DistroName "" ; Clear Distro Name
StrCpy $ISOFileName "" ; Clear ISO Selection
StrCpy $SomeFileExt ""
StrCpy $FileFormat ""
FunctionEnd
Function InstallorRemove ; Populate DistroName based on Install/Removal option
${If} $Removal == "Yes"
Call RemovalList
${Else}
${NSD_SetText} $LinuxDistroSelection "Step 2: Select a Distribution to put on $DestDisk"
Call SetISOFileName
${EndIf}
FunctionEnd
; On Selection of Uninstaller Option
Function Uninstall
${NSD_GetState} $Uninstaller $Removal
${If} $Removal == ${BST_CHECKED}
ShowWindow $Format 0
ShowWindow $LabelISOSelection 0
Call ClearAll
EnableWindow $ISOFileTxt 0
ShowWindow $ISOFileTxt 0
ShowWindow $ISOSelection 0
ShowWindow $ForceShowAll 0
ShowWindow $CasperSelection 0
ShowWindow $CasperSlider 0
ShowWindow $SlideSpot 0
StrCpy $Persistence "NULL"
${NSD_Check} $Uninstaller
StrCpy $Removal "Yes"
ShowWindow $DistroLink 0
ShowWindow $DownloadISO 0
GetDlgItem $6 $HWNDPARENT 1 ; Get "Install" control handle
SendMessage $6 ${WM_SETTEXT} 0 "STR:Remove"
EnableWindow $6 0 ; Disable "Install" control button
${NSD_SetText} $Uninstaller "You're in Uninstaller Mode!"
${NSD_SetText} $LinuxDistroSelection "Step 2: Select a Distribution to remove from $DestDisk"
SendMessage $Distro ${CB_RESETCONTENT} 0 0 ; was ${NSD_LB_Clear} $Distro "" ; Clear all distro entries because a new option may have been chosen ; Enable for DropBox
StrCpy $Checker "Yes"
Call RemovalList
${ElseIf} $Removal == ${BST_UNCHECKED}
ShowWindow $Format 1
ShowWindow $LabelISOSelection 1
ShowWindow $ISOFileTxt 1
ShowWindow $ISOSelection 0
Call ClearAll
${NSD_SetText} $LabelISOSelection "Step 3: Select your $ISOFileName"
${NSD_SetText} $ISOFileTxt "Disabled until step 2 is complete"
GetDlgItem $6 $HWNDPARENT 1 ; Get "Install" control handle
SendMessage $6 ${WM_SETTEXT} 0 "STR:Create"
EnableWindow $6 0 ; Disable "Install" control button
${NSD_Uncheck} $Uninstaller
StrCpy $Removal "No"
${NSD_SetText} $Uninstaller "View or Remove Installed Distros?"
${NSD_SetText} $LinuxDistroSelection "Step 2: Select a Distribution to put on $DestDisk"
SendMessage $Distro ${CB_RESETCONTENT} 0 0 ; was ${NSD_LB_Clear} $Distro "" ; Clear all distro entries because a new option may have been chosen ; Enable for DropBox
StrCpy $Checker "Yes"
Call SetISOFileName
${EndIf}
FunctionEnd
; On Selection of USB Drive
Function OnSelectDrive
Pop $DestDriveTxt
${NSD_GetText} $DestDriveTxt $Letters
StrCpy $DestDrive "$Letters"
StrCpy $JustDrive $DestDrive 3
StrCpy $BootDir $DestDrive 2 ;was -1
StrCpy $DestDisk $DestDrive 2 ;was -1
SendMessage $Distro ${CB_RESETCONTENT} 0 0 ; was ${NSD_LB_Clear} $Distro "" ; Clear all distro entries because a new drive may have been chosen ; Enable for DropBox
StrCpy $Checker "Yes"
Call InstallorRemove
Call SetSpace
Call CheckSpace
Call FormatIt
Call EnableNext
${NSD_SetText} $LabelDrivePage "Step 1: You Selected $DestDisk as your USB Device"
; ${If} ${FileExists} $BootDir\menu.lst
; ${AndIf} ${FileExists} $BootDir\syslinux.cfg
; MessageBox MB_ICONQUESTION|MB_OK "It appears MultibootISOs was previously used on this drive? To use YUMI on this device, you must format the drive."
; ${EndIf}
FunctionEnd
Function GetDiskVolumeName
;Pop $1 ; get parameter
System::Alloc 1024 ; Allocate string body
Pop $0 ; Get the allocated string's address
!define GetVolumeInformation "Kernel32::GetVolumeInformation(t,t,i,*i,*i,*i,t,i) i"
System::Call '${GetVolumeInformation}("$9",.r0,1024,,,,,1024)' ;
;Push $0 ; Push result
${If} $0 != ""
StrCpy $VolName "$0"
${Else}
StrCpy $VolName ""
${EndIf}
FunctionEnd ; GetDiskVolumeName
Function DiskSpace
${DriveSpace} "$9" "/D=T /S=G" $1 ; used to find total space of each drive
${If} $1 > "0"
StrCpy $Capacity "$1GB"
${Else}
StrCpy $Capacity ""
${EndIf}
FunctionEnd
Function DrivesList
Call GetDiskVolumeName
Call DiskSpace
SendMessage $DestDriveTxt ${CB_ADDSTRING} 0 "STR:$9 $VolName $Capacity"
Push 1 ; must push something - see GetDrives documentation
FunctionEnd
Function FormatYes ; If Format is checked, do something
${If} $FormatMe == "Yes"
; Close All Open Explorer Windows
DetailPrint "Closing All Open Explorer Windows"
FindWindow $R0 CabinetWClass
IsWindow $R0 0 +3
SendMessage $R0 ${WM_SYSCOMMAND} 0xF060 0
Goto -3
SetShellVarContext all
InitPluginsDir
File /oname=$PLUGINSDIR\fat32format.exe "fat32format.exe"
DetailPrint "Formatting $DestDisk as Fat32 using Fat32format.exe"
nsExec::ExecToLog '"cmd" /c "echo y|$PLUGINSDIR\fat32format -c$BlockSize $DestDisk"' ;/Q /y
${EndIf}
FunctionEnd
Function FormatIt ; Set Format Option
${NSD_GetState} $Format $FormatMe
${If} $FormatMe == ${BST_CHECKED}
${NSD_Check} $Format
StrCpy $FormatMe "Yes"
${NSD_SetText} $Format "We Will Fat32 Format $DestDisk Drive!"
SendMessage $Distro ${CB_RESETCONTENT} 0 0 ; was ${NSD_LB_Clear} $Distro "" ; Clear all distro entries because a new format option may have been chosen ; Enable for DropBox
ShowWindow $Uninstaller 0 ; Disable Uninstaller option because we will be formatting the drive.
StrCpy $Checker "Yes"
${ElseIf} $FormatMe == ${BST_UNCHECKED}
${NSD_Uncheck} $Format
${NSD_SetText} $Format "Format $DestDisk Drive (Erase Content)?"
SendMessage $Distro ${CB_RESETCONTENT} 0 0 ; was ${NSD_LB_Clear} $Distro "" ; Clear all distro entries because a new format option may have been chosen ; Enable for DropBox
ShowWindow $Uninstaller 1 ; Re-enable Uninstaller option.
StrCpy $Checker "Yes"
Call SetSpace
${EndIf}
Call InstallorRemove
FunctionEnd
Function ShowAllISOs ; Set Show All ISOs Option
${NSD_GetState} $ForceShowAll $ShowingAll
${If} $ShowingAll == ${BST_CHECKED}
${NSD_Check} $ForceShowAll
StrCpy $ShowingAll "Yes"
${NSD_SetText} $ForceShowAll "Show All ISOs!"
SendMessage $ISOSelection ${CB_RESETCONTENT} 0 0
${ElseIf} $ShowingAll == ${BST_UNCHECKED}
${NSD_Uncheck} $ForceShowAll
${NSD_SetText} $ForceShowAll "Show All ISOs?"
SendMessage $ISOSelection ${CB_RESETCONTENT} 0 0
${EndIf}
FunctionEnd
Function CheckSpace ; Check total available space so we can set block size
Call TotalSpace
${If} $1 <= 511
StrCpy $BlockSize 1
${ElseIf} $1 >= 512
${AndIf} $1 <= 8191
StrCpy $BlockSize 4
${ElseIf} $1 >= 8192
${AndIf} $1 <= 16383
StrCpy $BlockSize 8
${ElseIf} $1 >= 16384
${AndIf} $1 <= 32767
StrCpy $BlockSize 16
${ElseIf} $1 > 32768
StrCpy $BlockSize 32
${EndIf}
; MessageBox MB_ICONSTOP|MB_OK "$0 Drive is $1 MB in size, blocksize = $BlockSize KB."
FunctionEnd
Function TotalSpace
${DriveSpace} "$JustDrive" "/D=T /S=M" $1 ; used to find total space of select disk
StrCpy $Capacity "$1"
FunctionEnd
Function FreeDiskSpace
${If} $FormatMe == "Yes"
${DriveSpace} "$JustDrive" "/D=T /S=M" $1
${Else}
${DriveSpace} "$JustDrive" "/D=F /S=M" $1
${EndIf}
FunctionEnd
Function SetSpace ; Set space available for persistence
;StrCpy $0 '$0'
Call FreeDiskSpace
IntOp $MaxPersist 4090 + $CasperSize ; Space required for distro and 4GB max persistent file
${If} $1 > $MaxPersist ; Check if more space is available than we need for distro + 4GB persistent file
StrCpy $RemainingSpace 4090 ; Set maximum possible value to 4090 MB (any larger wont work on fat32 Filesystem)
${Else}
StrCpy $RemainingSpace "$1"
IntOp $RemainingSpace $RemainingSpace - $SizeOfCasper ; Remaining space minus distro size
${EndIf}
IntOp $RemainingSpace $RemainingSpace - 1 ; Subtract 1MB so that we don't error for not having enough space
SendMessage $CasperSlider ${TBM_SETRANGEMAX} 1 $RemainingSpace ; Re-Setting Max Value
FunctionEnd
Function HaveSpace ; Check space required
Call CasperSize
Call FreeDiskSpace
System::Int64Op $1 > $SizeOfCasper ; Compare the space available > space required
Pop $3 ; Get the result ...
IntCmp $3 1 okay ; ... and compare it
MessageBox MB_ICONSTOP|MB_OK "Oops: There is not enough disk space! $1 MB Free, $SizeOfCasper MB Needed on $JustDrive Drive."
quit ; Close the program if the disk space was too small...
okay: ; Proceed to execute...
;MessageBox MB_OK "ISO + Persistence will use $SizeOfCasper MB of the $1 MB Free disk space on $JustDrive Drive."
;quit ; enable for testing message above
FunctionEnd
!macro DeleteMenuEntry file start stop
Push "${FILE}" ; File to search in
Push "${START}$\r$\n" ; text to start deleting from
Push "${STOP}$\r$\n" ; text to stop at
Call DeleteMenuEntry
!macroend
!define DeleteMenuEntry "!insertmacro DeleteMenuEntry"
; DeleteMenuEntry function is based on RemoveAfterLine function, by Afrow UK http://nsis.sourceforge.net/Delete_lines_from_one_line_to_another_line_inclusive, I (Lance), simply created a macro for it.
Function DeleteMenuEntry
Exch $1 ;end string
Exch
Exch $2 ;begin string
Exch 2
Exch $3 ;file
Exch 2
Push $R0
Push $R1
Push $R2
Push $R3
GetTempFileName $R2
FileOpen $R1 $R2 w
FileOpen $R0 $3 r
ClearErrors
FileRead $R0 $R3
IfErrors Done
StrCmp $R3 $2 +3
FileWrite $R1 $R3
Goto -5
ClearErrors
FileRead $R0 $R3
IfErrors Done
StrCmp $R3 $1 +4 -3
FileRead $R0 $R3
IfErrors Done
FileWrite $R1 $R3