; ------------------------------------------------------------------------- ; creates fli4l-files and archives __FLI4LVER__ ; ; Creation: lanspezi 2005-04-04 ; $Id$ ; ------------------------------------------------------------------------- #include-once Dim $kernel_version Dim $bool_recover="no" Func update_version () ; not implement in windows-build EndFunc Func get_one_val () ; windows build use "read_var_from_rc_cfg" EndFunc Func gen_md5_sums () $msg = build_time () & $MSG_04_generating_md5sums & " " fli4lbuild_msg ($msg,0) Dim $md5files[5][2] $md5files[0][0] = "rc.cfg" $md5files[0][1] = "FLI4L_MD5_RC_CFG=" $md5files[1][0] = "kernel" $md5files[1][1] = "FLI4L_MD5_KERNEL=" $md5files[2][0] = "rootfs.img" $md5files[2][1] = "FLI4L_MD5_ROOTFS_IMG=" $md5files[3][0] = "opt.img" $md5files[3][1] = "FLI4L_MD5_OPT_IMG=" $md5files[4][0] = "syslinux.cfg" $md5files[4][1] = "FLI4L_MD5_SYSLINUX_CFG=" FileCopy ($dir_base & "\windows\scripts\md5.pif", $glob_dir_tmpbuild, 1) ; needed for W9x For $_n = 0 to 4 $md5file = $md5files[$_n][0] If FileExists($glob_dir_tmpbuild & "\" & $md5file) then $run_call = StringFormat ('"%s\\windows\\md5sum.exe" %s > md5.tmp',$dir_base, $md5file) FileWriteLine ($glob_dir_tmpbuild & "\md5.bat", $run_call) $val = RunWait ($glob_dir_tmpbuild & "\md5.bat", $glob_dir_tmpbuild , @SW_HIDE) $line = FileReadLine ($glob_dir_tmpbuild & "\md5.tmp") $md5 = StringLeft ($line, 32) FileWriteLine ($glob_dir_tmpbuild & "\rc.cfg", $md5files[$_n][1] & "'" & $md5 & "'" & @LF) FileDelete ($glob_dir_tmpbuild & "\md5.bat") FileDelete ($glob_dir_tmpbuild & "\md5.tmp") $md5="" EndIf Next FileDelete ($glob_dir_tmpbuild & "\md5.pif") fli4lbuild_msg ($MSG_finished & @CRLF,0) EndFunc Func get_config_values () Dim $comp_type_rootfs Dim $comp_type_opt Dim $kernel_version_id read_var_from_rc_cfg ("KERNEL_VERSION", $kernel_version) $kernel_version_id = StringUpper(StringReplace(StringReplace($kernel_version, ".", "_"), "-", "_")) read_var_from_rc_cfg ("COMP_TYPE_ROOTFS", $comp_type_rootfs) read_var_from_rc_cfg ("COMP_TYPE_OPT", $comp_type_opt) If ("$remotehostname" = "") then read_var_from_rc_cfg ("HOSTNAME", $remotehostname) EndIf read_var_from_rc_cfg ("OPT_RECOVER", $bool_recover) EndFunc Func copy_kernel () Dim $file $file = "opt\files\boot\kernel-" & $kernel_version If FileExists ($dir_config & "\" & $file) then FileCopy ($dir_config & "\" & $file, $glob_dir_tmpbuild & "\kernel",1) Else If FileExists ($file) then FileCopy ($file, $glob_dir_tmpbuild & "\kernel",1) Else $msg = "Warning: Can't find " & $file & _ "! Either use a different kernel version or a different compression method." fli4lbuild_errmsg ($msg, 1) $bool_error = "true" exit_fli4l_build () EndIf EndIf EndFunc Func mkopt () Dim $file Dim $squeeze_file msg_lang_read ("mkopt") $msg = @CRLF & $MSG_LINE & @CRLF & build_time () & $MSG_04_start & " " fli4lbuild_msg ($msg,1) $progressbar = GUICtrlCreateProgress (70,425,520,20) GUICtrlSetData ($progressbar,0) $icon = GUICtrlCreateIcon ("windows\scripts\ico_build.ico",-1, 20,422,32,32) $msg = @CRLF & build_time () & $MSG_04_confdir & $dir_config & "' " & @CRLF & _ build_time () & $MSG_04_builddir & $dir_build & "'" & @CRLF fli4lbuild_msg ($msg,0) GUICtrlSetData ($progressbar,25) If FileExists ($glob_dir_tmpbuild & "\modules.alias") then FileDelete ($glob_dir_tmpbuild & "\modules.alias") EndIf If FileExists ($glob_dir_tmpbuild & "\modules.dep") then FileDelete ($glob_dir_tmpbuild & "\modules.dep") EndIF ; remove old version of all fli4l-files in build-dir cleanup_fli4lfiles () If NOT FileExists ($dir_config & "\etc") then fli_DirCreate ($dir_config & "\etc") EndIf If NOT FileExists ($dir_config & "\etc\rc.cfg") then $file = FileOpen ($dir_config & "\etc\rc.cfg",2) FileClose($file) EndIf ; if bool_squeeze ist true files are squeezed(compressed) If $bool_squeeze <> "true" then $squeeze_file = "--no-squeeze" Else $squeeze_file = "" EndIf ;parse config-files - check configuration and generate filelist for archives $msg = build_time () & $MSG_04_readcheckconf & @CRLF fli4lbuild_msg ($msg,0) $run_call = StringFormat ('windows\\mkfli4l.exe %s -c "%s" -t "%s" -b "%s" -l "%s\\mkfli4l.log" %s', _ $mkfli4l_debug_option, $dir_config, $glob_dir_tmptar, $glob_dir_tmpbuild, $glob_dir_tmplog, $squeeze_file) $val = RunWait ($run_call, @WorkingDir, @SW_HIDE) GUICtrlSetData ($progressbar,60) If $val = 0 then ; fli4l-config OK and Archives was build $message = read_mkfli4l_log () $wline = "---------------------------------------------------------" $wline = $wline & "---------------------------------------------------------------------------" $warn = StringInStr ($message, "Warning:") If Stringlen($message)>60000 Then $message = StringLeft($message, 60000) & @CRLF & @CRLF & "Log too large to show, use log-file: '" & $dir_build & "\mkfli4l.log'" & @CRLF EndIf If $warn AND $verbose = "false" Then fli4lbuild_msg (@CRLF & $wline & @CRLF& $message & $wline & @CRLF,1) Else If $warn Then fli4lbuild_msg (@CRLF & $wline & @CRLF & $message & $wline & @CRLF,0) EndIf EndIf FileCopy ( $dir_config & "\etc\rc.cfg", $glob_dir_tmpbuild & "\rc.cfg", 1) fli4lbuild_msg (build_time () & $MSG_finished & @CRLF,0) get_config_values () ;copy kernel defined by config to build-dir copy_kernel () GUICtrlSetData ($progressbar,75) ;generating md5sum of files gen_md5_sums () ;copy all files (rc.cfg, opt.tar/opt.img, syslinux.cfg, rootfs.img, kernel and rc_full.cfg to build dir FileCopy ($glob_dir_tmpbuild & "\kernel", $dir_build & "\kernel",1) FileCopy ($glob_dir_tmpbuild & "\rootfs.img", $dir_build & "\rootfs.img",1) FileCopy ($glob_dir_tmpbuild & "\rc.cfg", $dir_build & "\rc.cfg",1) FileCopy ($glob_dir_tmpbuild & "\syslinux.cfg", $dir_build & "\syslinux.cfg", 1) If FileExists ($glob_dir_tmpbuild & "\opt.img") then FileCopy ($glob_dir_tmpbuild & "\opt.img", $dir_build & "\opt.img",1) EndIf FileCopy ($glob_dir_tmpbuild & "\full_rc.cfg", $dir_build & "\full_rc.cfg", 1) If $bool_recover <> "no" then FileCopy ($dir_base & "\img\boot.msg", $dir_build & "\boot.msg", 1) FileCopy ($dir_base & "\img\boot_s.msg", $dir_build & "\boot_s.msg", 1) FileCopy ($dir_base & "\img\boot_z.msg", $dir_build & "\boot_z.msg", 1) FileCopy ($dir_base & "\img\boot.msg", $glob_dir_tmpbuild & "\boot.msg", 1) FileCopy ($dir_base & "\img\boot_s.msg", $glob_dir_tmpbuild & "\boot_s.msg", 1) FileCopy ($dir_base & "\img\boot_z.msg", $glob_dir_tmpbuild & "\boot_z.msg", 1) EndIf If $verbose = "true" then $msg = $MSG_04_finished & @CRLF & $MSG_LINE & @CRLF Else $msg = $MSG_finished & @CRLF & $MSG_LINE & @CRLF EndIf fli4lbuild_msg (build_time () & $msg,1) GUICtrlSetData ($progressbar,100) WinActivate("fli4l-Build","") else ;error in check of fli4l-config or build of fli4l archiv-files fli4lbuild_msg ($MSG_cancel & @CRLF , 1) $msg = read_mkfli4l_log () fli4l_log_error ($MSG_04_msgboxerror & @CRLF & $MSG_LINE & @CRLF) fli4l_log_error ($msg) If StringLen ($msg) > 1500 then $msg1 = StringLeft ($msg, 1500) $msg1 = $msg1 & @CRLF & @CRLF & " - please read complete output in " If $verbose ="true" Then $msg1 = $msg1 & "main window or in " EndIf $msg1 = $msg1 & "log-file!" Else $msg1=$msg EndIf MsgBox(48 + 4096, $MSG_04_msgboxerror, $msg1) If Stringlen($msg)>60000 Then $msg=StringLeft($msg, 60000) & @CRLF & @CRLF & "Log too large to show, use log-file: '" & $dir_build & "\mkfli4l_error.log'" & @CRLF EndIf fli4lbuild_msg ($MSG_LINE & @CRLF & $msg,0) ; show errormessage in build-window if verbose $bool_error = "true" EndIf sleep (2000) GUICtrlDelete ($progressbar) GUICtrlDelete ($icon) EndFunc ; ------------------------------- ; Functions only in windows-build ; ------------------------------- Func read_mkfli4l_log () Dim $msg , $_msg , $file if FileExists ($glob_dir_tmplog & "\mkfli4l.log") Then $file = FileOpen($glob_dir_tmplog & "\mkfli4l.log", 0) ; Check if file opened for reading OK If $file = -1 Then $msg = $MSG_04_nologfile & @CRLF & "'" & $glob_dir_tmpbuild & "\mkfli4l.log'." MsgBox(0, $MSG_msgbox_error, $msg) FileClose($file) Return $msg Else ; Read in lines of text until the EOF is reached While 1 $_msg = FileReadLine($file) ; abort on EOF, strip unnessecary mkfli4l output If (@error = -1) or (StringLeft ($_msg,22) = "Error in configuration") or (StringLeft ($_msg,5) = "total") or (StringLeft ($_msg,14) = " total") Then ExitLoop ; strip empty lines if $_msg <> "" Then $msg = $msg & $_msg & @CRLF Wend FileClose($file) Return $msg EndIf FileClose($file) Else Return "" EndIf EndFunc Func read_var_from_rc_cfg ($var, ByRef $parameter) Dim $result Dim $line Dim $val Dim $file Dim $len Dim $end $len = StringLen($var) $file = FileOpen($glob_dir_tmpbuild & "\rc.cfg", 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file '"& $glob_dir_tmpbuild & "\rc.cfg") else ; Read in lines of text until the EOF is reached While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop If StringLeft($line, $len) = $var then $end = StringInStr($line, "'", 1, 2) $result = StringMid ($line, $len + 3, $end - $len - 3) ExitLoop EndIf Wend FileClose($file) If $result <> "" then $parameter = $result EndIf Return $result EndIf EndFunc