@@ -70,16 +70,22 @@ function LoadDistroParseLine(line)
7070local toks , str
7171local iso_details = {}
7272
73+ iso_details .install_type = " "
7374toks = strutil .TOKENIZER (line , " \\ S" , " Q" )
7475str = toks :next ()
7576while str ~= nil
7677do
7778 if string.sub (str , 1 , 5 )== " name=" then iso_details .name = strutil .stripQuotes (string.sub (str , 6 )) end
79+ if string.sub (str , 1 , 13 )== " install_type=" then iso_details .install_type = strutil .stripQuotes (string.sub (str , 14 )) end
7880 if string.sub (str , 1 , 3 )== " id=" then iso_details .pattern = strutil .stripQuotes (string.sub (str , 4 )) end
7981 if string.sub (str , 1 , 7 )== " kernel=" then iso_details .kernel = strutil .stripQuotes (string.sub (str , 8 )) end
8082 if string.sub (str , 1 , 7 )== " initrd=" then iso_details .initrd = strutil .stripQuotes (string.sub (str , 8 )) end
8183 if string.sub (str , 1 , 7 )== " append=" then iso_details .append = strutil .stripQuotes (string.sub (str , 8 )) end
82- if string.sub (str , 1 , 12 )== " append-live=" then iso_details .append_live = strutil .stripQuotes (string.sub (str , 13 )) end
84+ if string.sub (str , 1 , 12 )== " append-live="
85+ then
86+ iso_details .install_type = " live"
87+ iso_details .append_live = strutil .stripQuotes (string.sub (str , 13 ))
88+ end
8389 str = toks :next ()
8490end
8591
8995
9096function LoadDistroList ()
9197local S , str , iso_details
98+ local toks
9299
93- S = stream .STREAM (Settings .distro_file , " r" )
100+ toks = strutil .TOKENIZER (Settings .distro_file , " :" )
101+ path = toks :next ()
102+
103+ while path ~= nil
104+ do
105+
106+ S = stream .STREAM (path , " r" )
94107if S ~= nil
95108then
96109 str = S :readln ()
97110 while str ~= nil
98111 do
99- str = strutil .trim (str )
100- if strutil .strlen (str ) > 0 and string.sub (str , 1 , 1 ) ~= ' #'
101- then
102- iso_details = LoadDistroParseLine (str )
103- table.insert (Settings .iso_list , iso_details )
104- end
105- str = S :readln ()
112+ str = strutil .trim (str )
113+ if strutil .strlen (str ) > 0 and string.sub (str , 1 , 1 ) ~= ' #'
114+ then
115+ iso_details = LoadDistroParseLine (str )
116+ table.insert (Settings .iso_list , iso_details )
117+ end
118+ str = S :readln ()
106119 end
107120
108121 S :close ()
122+ break
123+ end
124+
125+ path = toks :next ()
109126end
110127
111128end
136153 if ISOFindIDFiles (distro , details .pattern ) == true
137154 then
138155 distro .name = details .name
156+ distro .install_type = details .install_type
139157 if strutil .strlen (details .kernel ) > 0 then distro .kernel = ISOFindItem (details .kernel , distro .mnt ) end
140158 if strutil .strlen (details .initrd ) > 0 then distro .initrd = ISOFindItem (details .initrd , distro .mnt ) end
141159 distro .append = details .append
@@ -368,23 +386,25 @@ local from, to
368386end
369387
370388
371- function InstallAddSyslinuxEntry (S , name , distro , install_type )
389+ function InstallAddSyslinuxEntry (S , name , distro )
372390
373- if install_type == " live" then name = name .. " -LIVE" end
391+ if distro . install_type == " live" then name = name .. " -LIVE" end
374392
375393S :writeln (" LABEL " .. name .. " \n " )
376394S :writeln (" MENU LABEL " .. name .. " \n " )
377395if strutil .strlen (distro .kernel ) > 0 then S :writeln (" KERNEL " .. " /" .. name .. distro .kernel .. " \n " ) end
378396if strutil .strlen (distro .initrd ) > 0 then S :writeln (" INITRD " .. " /" .. name .. distro .initrd .. " \n " ) end
379397
380- if install_type == " live"
398+ if distro . install_type == " live"
381399then
382400 str = string.gsub (distro .append_live , " %$%(distdir%)" , name )
383401 str = string.gsub (str , " %$%(uuid%)" , Settings .DestUUID )
384402 S :writeln (" APPEND " .. str .. " \n " )
385403elseif strutil .strlen (distro .append ) > 0
386404then
387405 str = string.gsub (distro .append , " %$%(distdir%)" , name )
406+
407+ if distro .install_type == " iso" then str = string.gsub (str , " %$%(isoname%)" , name .. " .iso" ) end
388408 str = string.gsub (str , " %$%(uuid%)" , Settings .DestUUID )
389409 S :writeln (" APPEND " .. str .. " \n " )
390410end
@@ -394,14 +414,25 @@ end
394414
395415
396416function InstallISO (S , iso_path , distro )
397- local name , bootdir
417+ local name , dest
398418
399419 name = string.gsub (filesys .basename (iso_path ), " .iso$" , " " )
400- bootdir = Settings .MountPoint .. " /" .. name .. " /"
401- filesys .mkdir (bootdir )
402420
403- -- print("COPYDIR: "..distro.mnt, bootdir)
404- filesys .copydir (distro .mnt , bootdir )
421+ dest = Settings .MountPoint .. " /" .. name .. " /"
422+ filesys .mkdir (dest )
423+
424+ if distro .install_type == " iso"
425+ then
426+ filesys .mkdirPath (dest .. distro .kernel )
427+ filesys .copy (distro .mnt .. distro .kernel , dest .. distro .kernel )
428+
429+ filesys .mkdirPath (dest .. distro .initrd )
430+ filesys .copy (distro .mnt .. distro .initrd , dest .. distro .initrd )
431+
432+ filesys .copy (iso_path , dest .. name .. " .iso" )
433+ else
434+ filesys .copydir (distro .mnt , dest )
435+ end
405436
406437 InstallAddSyslinuxEntry (S , name , distro , " " )
407438 if strutil .strlen (distro .append_live ) > 0 then InstallAddSyslinuxEntry (S , name , distro , " live" ) end
@@ -492,15 +523,17 @@ end
492523function InitConfig ()
493524local str
494525
495- Settings .Version = " 2 .0"
526+ Settings .Version = " 3 .0"
496527Settings .MountPoint = " /mnt"
497528str = string.gsub (process .getenv (" PATH" ), " /bin" , " /share" )
498529Settings .SyslinuxDir = filesys .find (" syslinux" , str )
499530Settings .SyslinuxMBR = " mbr.bin"
500531Settings .SyslinuxModules = " ldlinux.c32,memdisk,libutil.c32,menu.c32"
501532Settings .InstallItems = " "
502533Settings .Force = false
503- Settings .distro_file = " /etc/distroflash.conf"
534+ Settings .distro_file = process .getenv (" HOME" ).. " /.config/distroflash.conf"
535+ Settings .distro_file = Settings .distro_file .. " :" .. process .getenv (" HOME" ).. " /.distroflash.conf"
536+ Settings .distro_file = Settings .distro_file .. " :" .. " /etc/distroflash.conf"
504537end
505538
506539
@@ -533,7 +566,7 @@ print("")
533566print (" -d <device> destination device to install to. Can be either a partition (e.g. /dev/sda1), or a drive (e.g. /dev/sda)" )
534567print (" -dev <device> destination device to install to. Can be either a partition, or a drive" )
535568print (" -device <device> destination device to install to. Can be either a partition, or a drive" )
536- print (" -c <path> path to distroflash.conf config file, overriding default of / etc/distroflash.conf" )
569+ print (" -c <path> path to distroflash.conf config file, overriding default search path. Multiple paths can be supplied, seperated by ':'. The default is '~/.config/distroflash.conf:~/.distroflash.conf:/ etc/distroflash.conf' " )
537570print (" -force if distroflash objects that a device is not removable (not all devices set this flag) this option forces using the device" )
538571print (" -format by default distroflash.lua will not format a partition (it will if you give it a drive). This option forces format." )
539572print (" -syslinuxdir path to syslinux dir containing mbr.bin, ldlinux.c32, etc. distroflash.lua should find this itself." )
@@ -670,6 +703,13 @@ then
670703 Out :puts (" ~rERROR:~0 some required programs are missing. Please install them or add the directories they are installed in to your $PATH.\n " )
671704else
672705
706+ if FindRequiredPrograms (" modprobe" ) == true
707+ then
708+ os.execute (Settings .programs [" modprobe" ] .. " loop" )
709+ else
710+ Out :puts (" ~yWARNING:~0 Can't find the 'modprobe' program. Make sure the module for loopback filesystems ('modprobe loop') is loaded.\n " )
711+ end
712+
673713 if FindRequiredPrograms (" blkid" ) ~= true
674714 then
675715 Out :puts (" ~yWARNING:~0 Can't find the 'blkid' program. Some distros (TinyCore,Arch,Calculate,CentOS,NST,SystemRescueCD) may not work.\n " )
0 commit comments