Class: Yast::DebugHooksClass
- Inherits:
-
Module
- Object
- Module
- Yast::DebugHooksClass
- Defined in:
- ../../src/modules/DebugHooks.rb
Instance Method Summary (collapse)
-
- (void) Checkpoint(filename, at_entry)
called whenever an inst_*.ycp file is called during installation.
-
- (Object) ExecuteScript(script, type)
Execute Script.
- - (Object) main
-
- (Object) Run(filename, at_entry)
Run Script.
Instance Method Details
- (void) Checkpoint(filename, at_entry)
This method returns an undefined value.
called whenever an inst_*.ycp file is called during installation. checks if /tmp/<filename> exists and pops up a "Entry: <filename>" or "Exit: <filename>" box
56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File '../../src/modules/DebugHooks.rb', line 56 def Checkpoint(filename, at_entry) if Ops.greater_or_equal( WFM.Read(path(".local.size"), Ops.add("/tmp/", filename)), 0 ) if at_entry Popup.Message(Builtins.sformat("Entry: %1", filename)) else Popup.Message(Builtins.sformat("Exit: %1", filename)) end end nil end |
- (Object) ExecuteScript(script, type)
Execute Script
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 |
# File '../../src/modules/DebugHooks.rb', line 74 def ExecuteScript(script, type) Builtins.y2milestone("Executing script: %1", script) # string message = sformat(_("Executing user supplied script: %1"), scriptName); executionString = "" scriptPath = Builtins.sformat("%1/%2", @tmp_dir, script) if type == "shell" executionString = Builtins.sformat( "/bin/sh -x %1 2&> %2/%3.log", scriptPath, @log_dir, script ) WFM.Execute(path(".local.bash"), executionString) elsif type == "perl" executionString = Builtins.sformat( "/usr/bin/perl %1 2&> %2/%3.log", scriptPath, @log_dir, script ) WFM.Execute(path(".local.bash"), executionString) else Builtins.y2error("Unknown interpreter: %1", type) end Builtins.y2milestone("Script Execution command: %1", executionString) nil end |
- (Object) main
34 35 36 37 38 39 40 41 42 43 44 45 |
# File '../../src/modules/DebugHooks.rb', line 34 def main Yast.import "Popup" Yast.import "Directory" @tmp_dir = Convert.to_string(WFM.Read(path(".local.tmpdir"), [])) @log_dir = Directory.logdir # script types, ycp does not make sense, it can be added directly # to the workflow. @supported_types = ["sh", "pl"] end |
- (Object) Run(filename, at_entry)
Run Script
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 |
# File '../../src/modules/DebugHooks.rb', line 106 def Run(filename, at_entry) Builtins.y2debug("Running debug hook: %1", filename) # do not run scripts twice if at_entry if Ops.greater_than( WFM.Read( path(".local.size"), Builtins.sformat("%1/%2_pre.sh", @tmp_dir, filename) ), 0 ) ExecuteScript(Builtins.sformat("%1_pre.sh", filename), "shell") elsif Ops.greater_than( WFM.Read( path(".local.size"), Builtins.sformat("%1/%2_pre.pl", @tmp_dir, filename) ), 0 ) ExecuteScript(Builtins.sformat("%1_pre.pl", filename), "perl") else Builtins.y2debug( "Debug hook not found: %1/%2_pre.{sh,pl}", @tmp_dir, filename ) end else if Ops.greater_than( WFM.Read( path(".local.size"), Builtins.sformat("%1/%2_post.sh", @tmp_dir, filename) ), 0 ) ExecuteScript(Builtins.sformat("%1_post.sh", filename), "shell") elsif Ops.greater_than( WFM.Read( path(".local.size"), Builtins.sformat("%1/%2_post.pl", @tmp_dir, filename) ), 0 ) ExecuteScript(Builtins.sformat("%1_post.pl", filename), "perl") else Builtins.y2debug( "Debug hook not found: %1/%2_post.{sh,pl}", @tmp_dir, filename ) end end nil end |