Skip to content

Commit

Permalink
lib/job2sh.rb: fix rewrite define_files
Browse files Browse the repository at this point in the history
[why]
use cat or echo direct input strings to files are unaccurately.

[how]
read define files --> val
val encode by base64
echo decode val to files at testbox

Signed-off-by: Wei Jihui <[email protected]>
  • Loading branch information
WJiHui committed Jun 25, 2021
1 parent b991a0c commit c6fdfa6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/job2sh.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
require "#{LKP_SRC}/lib/job"
require "#{LKP_SRC}/lib/lkp_path"
require 'shellwords'
require 'base64'

TMP ||= ENV['TMP'] || '/tmp'

Expand Down Expand Up @@ -352,8 +353,9 @@ def sh_define_files
out_line
out_line "\texport define_files='#{define_files.keys.join ' '}'"
define_files.each do |file, val|
val = Base64.encode64(val)
out_line "\tmkdir -p $LKP_SRC/$(dirname #{file})"
out_line "\techo \'#{val}\' > $LKP_SRC/#{file}"
out_line "\techo \"#{val}\" | base64 -d > $LKP_SRC/#{file}"
if File::executable?("#{ENV['LKP_SRC']}/#{file}")
out_line "\tchmod +x $LKP_SRC/#{file}"
end
Expand Down

0 comments on commit c6fdfa6

Please sign in to comment.