; ------------------------------------------------------------------------- ; parse command line __FLI4LVER__ ; ; Creation: lanspezi 2005-04-04 ; $Id$ ; ------------------------------------------------------------------------- #include-once Global $verbose Func parse_cmd() msg_lang_read ("parse_cmd") Global $dummy ; needed for func read_var_from_config_file $message = @CRLF & $MSG_02_start & @CRLF & $MSG_LINE & @CRLF & @CRLF fli4lbuild_msg ($message,1) ; save active drive and dir Global $dir_base = @WorkingDir Global $drive_base = StringLeft( $dir_base, 2) ; set default value of variables parse_cmd_default() ; first check of the command-line-options - only need "dir_config" parse_cmd_option () ;check for a cygwin-installation cygwin_check_install () if ($bool_interactive = "true") AND ($bool_error <> "true") then If @OSType = "WIN32_NT" then GUISetState ( @SW_DISABLE , $win_fli4l_build) EndIf dlg_mkfli4l_conf () GUISetState ( @SW_ENABLE , $win_fli4l_build) WinActivate("fli4l-Build","") EndIf ;check for exist of base.txt in config-dir If NOT FileExists($dir_config & "\base.txt") Then fli4lbuild_msg ($MSG_02_noconfdir & @CRLF & $dir_config, 1) fli4lbuild_errmsg ($MSG_02_noconfdir & @CRLF & $dir_config, 1) $bool_error = "true" exit_fli4l_build () EndIf If ($bool_build_abort = "false") AND ($bool_error = "false") then $message = $MSG_02_useconfig & $dir_config & "' ..." & @CRLF fli4lbuild_msg ($message, 1) EndIf If $bool_interactive = "false" then ; get parameters from config-dir/mkfli4l.conf If FileExists($dir_config & "\mkfli4l.conf") then parse_mkfli4l_conf(0) EndIf ; check options/parameters from command-line again - overwrite parameters set in mkfli4l.conf parse_cmd_option () EndIf ;check exist of build-dir create it if NOT FileExists($dir_build) then fli_DirCreate ($dir_build) EndIf ;check boot_type from base.txt BOOT_TYPE= Global $boot_type = read_var_from_base ("BOOT_TYPE=", $dummy) If $boot_type = "" then fli4lbuild_errmsg ($MSG_02_undefboottype,1) $bool_error = "true" exit_fli4l_build () EndIf ;read comp_type_kernel and comp_type_roofs from /base.txt read_var_from_base ("COMP_TYPE_KERNEL=", $comp_type_kernel) read_var_from_base ("COMP_TYPE_ROOTFS=", $comp_type_rootfs) ;read passwd from /base.txt read_var_from_base ("PASSWORD=", $sshpasswd) ;replace all "\" to "/" in build_dir - tar has a Problem when in string "\r" or "\R" Global $dir_build_r = StringReplace($dir_build, "\","/") Global $opt_type Select Case $boot_type = "integrated" $opt_type = "integrated" Case $boot_type = "netboot" $opt_type = "integrated" Case $boot_type = "pxeboot" $opt_type = "integrated" Case $boot_type = "attached" $opt_type = "attached" Case $boot_type = "cd" $opt_type = "tar" Case $boot_type = "cdemul" $opt_type = "tar" Case Else $opt_type = "bzip2" EndSelect EndFunc ; --- Func parse_cmd_default() ; Variabel with defaults ; logic - boolean Global $bool_error = "false" Global $bool_filesonly = "false" Global $bool_cleanup = "false" Global $bool_imonc = "false" Global $bool_interactive = "true" Global $bool_squeeze = "true" Global $bool_do_hdinstall = "false" Global $bool_force_select_config = "false" Global $bool_test_version = "false" ; pathnames Global $dir_config = "config" Global $dir_build = "build" ; type of opt [integrated/attached/bzip2/tar] Global $opt_type ; others Global $drive = "a:" Global $drive_hdinstall = "" Global $suffix ;scp - remoteupdate Global $remoteusername = "fli4l" Global $remotehostname Global $remotepathname = "/boot" Global $remoteupdate = "false" Global $remoteport = 22 Global $sshpasswd = "" Global $sshkeyfile = "" Global $hostsglobalfile = "" Global $mkfli4l_debug_option = "" ; tftpboot Global $tftpboot_path = "/tftpboot" Global $tftpboot_image = "fli4l.tftp" Global $pxe_subdir = "fli4l" ; comp-type of kernel and rootfs Global $comp_type_kernel = "gzip" Global $comp_type_rootfs = "gzip" EndFunc Func parse_cmd_option () $bool_interactive = "true" For $i = 1 to $CmdLine[0] Select Case $CmdLine[$i] = "-t" $bool_test_version = "true" Case $CmdLine[$i] = "-v" OR $CmdLine[$i] = "--verbose" $verbose = "true" Case $CmdLine[$i] = "-s" OR $CmdLine[$i] = "--safe" $suffix = "-s" Case $CmdLine[$i] = "-d" OR $CmdLine[$i] = "--drive" If ($i + 1) <= $CmdLine[0] Then $drive = $CmdLine[$i + 1] $i = $i + 1 Else MsgBox(0,"Debug","Error --drive at end") ; todo - error-msg EndIf Case $CmdLine[$i] = "-b" OR $CmdLine[$i] = "--build" If ($i + 1) <= $CmdLine[0] Then $dir_build = $CmdLine[$i + 1] If StringRight($dir_build, 1) = "\" Then $dir_build = StringTrimRight ($dir_build, 1) EndIf $i = $i + 1 Else MsgBox(0,"Debug","Error --build at end") ; todo - error-msg EndIf Case $CmdLine[$i] = "-c" OR $CmdLine[$i] = "--clean" $bool_cleanup = "true" Case $CmdLine[$i] = "-h" OR $CmdLine[$i] = "--help" usage() Case $CmdLine[$i] = "--filesonly" $bool_filesonly = "true" Case $CmdLine[$i] = "--remotehost" If ($i + 1) <= $CmdLine[0] Then $remotehostname = $CmdLine[$i + 1] $i = $i + 1 Else MsgBox(0,"Debug","Error --remotehost at end") ; todo - error-msg EndIf Case $CmdLine[$i] = "--remoteuser" If ($i + 1) <= $CmdLine[0] Then $remoteusername = $CmdLine[$i + 1] $i = $i + 1 Else MsgBox(0,"Debug","Error --remoteuser at end") ; todo - error-msg EndIf Case $CmdLine[$i] = "--remotepath" If ($i + 1) <= $CmdLine[0] Then $remotepathname = $CmdLine[$i + 1] $i = $i + 1 Else MsgBox(0,"Debug","Error --remotepath at end") ; todo - error-msg EndIf Case $CmdLine[$i] = "--remoteport" If ($i + 1) <= $CmdLine[0] Then $remoteport = $CmdLine[$i + 1] $i = $i + 1 Else MsgBox(0,"Debug","Error --remoteport at end") ; todo - error-msg EndIf Case $CmdLine[$i] = "--remoteupdate" $remoteupdate = "true" Case $CmdLine[$i] = "--imonc" $bool_imonc = "true" Case $Cmdline[$i] = "--nogui" $bool_interactive = "false" Case $Cmdline[$i] = "--no-squeeze" $bool_squeeze = "false" Case $Cmdline[$i] = "--force-select-config" $bool_force_select_config = "true" Case $Cmdline[$i] = "--lang" If ($i + 1) <= $CmdLine[0] Then $i = $i + 1 Else MsgBox(0,"Debug","Error --lang at end") ; todo - error-msg EndIf Case Else $dir_config = $CmdLine[$i] If StringRight($dir_config, 1) = "\" then $dir_config = StringTrimRight ($dir_config, 1) EndIf EndSelect Next If $bool_imonc = "true" then $bool_interactive = "false" EndIf ;check value of some variables If StringLen ($drive) <> 2 OR StringRight ($drive, 1) <> ":" OR NOT StringIsAlpha(StringLeft($drive, 1)) Then $drive = "a:" ; todo - error-msg - fatal EndIf If DriveGetType ($drive) <> "Removable" then $drive = "a:" ; todo - error-msg - fatal EndIf ; make path absolute $dir_config=make_abs($dir_config) $dir_build=make_abs($dir_build) ;check for the hostname of the fli4l-router if none is parsed from the command-line If FileExists ($dir_config) then If FileExists ($dir_config & "\base.txt") then If $remotehostname = "" then $remotehostname = read_var_from_base ("HOSTNAME=", $dummy) EndIf EndIf If FileExists ($dir_config & "\mkfli4l.conf") then $tmp = read_var_from_config_file ("mkfli4l.conf", "DISABLE_OPTION_GUI=", $dummy) If $tmp = "yes" then $bool_interactive = "false" EndIf EndIf EndIf EndFunc Func make_abs ($path) ; make $path absolute If StringLeft ($path,1) = "\" then $path = $drive_base & $path Else If StringMid ($path, 2, 1) <> ":" then $path = $dir_base & "\" & $path EndIf EndIf Return $path EndFunc Func usage () $win_dlg_mkfli4l_conf = GUICreate("fli4l-Build - Usage",500,380,-1,-1, _ BitOr ($WS_POPUPWINDOW,$WS_CAPTION), -1 ,$win_fli4l_build) GUISetIcon("windows\fli4l.ico") GUISetState(@SW_SHOW) $l1 = 30 $l2 = 45 $l3 = 134 GUICtrlCreateLabel ("mkfli4l.bat [options] [config-dir] ", 10, 20, 480) GUICtrlSetFont (-1, 10, 400) GUICtrlCreateGroup ("[options]", 10, 50, 480, 230) GUICtrlCreateLabel ("-c,", $l1, 70) GUICtrlCreateLabel ("--clean", $l2, 70) GUICtrlCreateLabel ("cleanup the build-directory", $l3, 70) GUICtrlCreateLabel ("-b,", $l1, 90) GUICtrlCreateLabel ("--build ", $l2, 90) GUICtrlCreateLabel ("set build-directory to for the fli4l-files", $l3, 90) GUICtrlCreateLabel ("-v,", $l1, 110) GUICtrlCreateLabel ("--verbose", $l2, 110) GUICtrlCreateLabel ("verbose - some debug-output", $l3, 110) GUICtrlCreateLabel ("-d,", $l1, 130) GUICtrlCreateLabel ("--drive X:", $l2, 130) GUICtrlCreateLabel ("set target-drive to X: - default a:", $l3, 130) GUICtrlCreateLabel ("-s,", $l1, 150) GUICtrlCreateLabel ("--safe", $l2, 150) GUICtrlCreateLabel ("safe-mode for floppy-boot", $l3, 150) GUICtrlCreateLabel ("", $l1, 170) GUICtrlCreateLabel ("--filesonly", $l2, 170) GUICtrlCreateLabel ("create only fli4l-files - do not create a disk", $l3, 170) GUICtrlCreateLabel ("", $l1, 190) GUICtrlCreateLabel ("--no-squeeze", $l2, 190) GUICtrlCreateLabel ("don't compress shell scripts", $l3, 190) GUICtrlCreateLabel ("", $l1, 210) GUICtrlCreateLabel ("--nogui", $l2, 210) GUICtrlCreateLabel ("disable the dialog to change options", $l3, 210) GUICtrlCreateLabel ("", $l1, 230) GUICtrlCreateLabel ("--lang", $l2, 230) GUICtrlCreateLabel ("change language [deutsch|english|espanol|french|magyar|nederlands]", $l3, 230) GUICtrlCreateLabel ("-h,", $l1, 250) GUICtrlCreateLabel ("--help", $l2, 250) GUICtrlCreateLabel ("display this usage", $l3, 250) GUICtrlCreateLabel ("[config-dir]", $l1, 300) GUICtrlCreateLabel ("set other config-directory - default is 'config'", $l3, 300) $_b_OK = GUICtrlCreateButton ("OK", 120, 330, 140, 25 , $BS_DEFPUSHBUTTON) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE OR $msg = $_b_OK Then ExitLoop EndIf Wend GUIDelete() $bool_error = "false" exit_fli4l_build () EndFunc