Skip to content

Commit

Permalink
fix: no double clean if clean and wrong cache
Browse files Browse the repository at this point in the history
  • Loading branch information
maxirmx committed Jan 9, 2025
1 parent 68aff35 commit ae2fda0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
10 changes: 5 additions & 5 deletions lib/tebako/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class Cli < Thor # rubocop:disable Metrics/ClassLength
desc: "tebako configuration file 'tebafile', '$PWD/.tebako.yml' by default"
desc "clean", "Clean tebako packaging environment"
def clean
(_, cm) = bootstrap
(_, cm) = bootstrap(clean: true)
cm.clean_cache
end

Expand All @@ -63,7 +63,7 @@ def clean
desc: "Ruby version to clean, all available versions by default"
def clean_ruby
puts "Cleaning Ruby sources from tebako packaging environment"
(om,) = bootstrap
(om,) = bootstrap(clean: true)

suffix = options["Ruby"].nil? ? "" : "_#{options["Ruby"]}"
nmr = "src/_ruby#{suffix}*"
Expand Down Expand Up @@ -127,7 +127,7 @@ def press
def setup
(om, cm) = bootstrap

do_setup(om, cm)
do_setup(om)
cm.ensure_version_file
rescue Tebako::Error => e
puts "Tebako script failed: #{e.message} [#{e.error_code}]"
Expand All @@ -139,11 +139,11 @@ def self.exit_on_failure?
end

no_commands do
def bootstrap
def bootstrap(clean: false)
options_manager = Tebako::OptionsManager.new(options)
cache_manager = Tebako::CacheManager.new(options_manager.deps, options_manager.source,
options_manager.output_folder)
cache_manager.version_cache_check unless options[:devmode]
cache_manager.version_cache_check unless options[:devmode] || clean
[options_manager, cache_manager]
end

Expand Down
9 changes: 7 additions & 2 deletions lib/tebako/cli_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def do_press_runtime(options_manager, scenario_manager)
true
end

def do_setup(options_manager, scenario_manager)
def do_setup(options_manager)
puts "Setting up tebako packaging environment"

cfg_cmd = "cmake -DSETUP_MODE:BOOLEAN=ON #{options_manager.cfg_options}"
Expand All @@ -80,7 +80,7 @@ def do_setup(options_manager, scenario_manager)
Tebako.packaging_error(101) unless system(merged_env, cfg_cmd)
Tebako.packaging_error(102) unless system(merged_env, build_cmd)

FileUtils.chmod("+x", File.join(options_manager.deps_bin_dir, "mkdwarfs#{scenario_manager.exe_suffix}"))
fix_mkdwarfs_permissions(options_manager)
true
end

Expand All @@ -98,6 +98,11 @@ def generate_files(options_manager, scenario_manager)
Tebako::Codegen.generate_stub_rb(options_manager)
end

def fix_mkdwarfs_permissions(options_manager)
scenario_manager = Tebako::ScenarioManager.new(options_manager.root, options_manager.fs_entrance)
FileUtils.chmod("+x", File.join(options_manager.deps_bin_dir, "mkdwarfs#{scenario_manager.exe_suffix}"))
end

def options_from_tebafile(tebafile)
::YAML.load_file(tebafile)["options"] || {}
rescue Psych::SyntaxError => e
Expand Down

0 comments on commit ae2fda0

Please sign in to comment.