Skip to content

Commit

Permalink
Merge pull request #24 from rock-core/fix_permission_of_root_in_packing
Browse files Browse the repository at this point in the history
fix: make sure the root of created tarball artifacts are go+rx
  • Loading branch information
doudou authored Aug 19, 2024
2 parents 735d7dd + e902f4c commit 8fcc205
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 5 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ source "https://rubygems.org"
gem "autoproj", git: "https://github.com/rock-core/autoproj"
group :vscode do
gem "debase", ">= 0.2.2.beta10"
gem "ffi", "<= 1.16.3"
gem "pry"
gem "pry-byebug"
gem "rubocop"
Expand Down
6 changes: 4 additions & 2 deletions lib/autoproj/cli/ci.rb
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,10 @@ def cleanup_build_cache(dir, size_limit)
total_size -= stat.size
end

Autoproj.message format("current build cache size: %.1f GB",
Float(total_size) / 1_000_000_000)
Autoproj.message(
format("current build cache size: %<size>.1f GB",
size: Float(total_size) / 1_000_000_000)
)
total_size
end

Expand Down
2 changes: 1 addition & 1 deletion lib/autoproj/cli/main_ci.rb
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def cache_pull(dir, ignore: [])

# options[:ignore] is not set if we call from another
# command, e.g. build
ignore += (options.delete(:ignore) || [])
ignore += options.delete(:ignore) || []
results = cli.cache_pull(*dir, ignore: ignore)

if report && !report.empty?
Expand Down
2 changes: 2 additions & 0 deletions lib/autoproj/cli/standalone_ci.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class StandaloneCI < Thor
type: :string, default: nil
def rebuild_root(config_dir, cache_root, output)
dir = Dir.mktmpdir
FileUtils.chmod 0o755, dir

Autoproj::CI::Rebuild.prepare_synthetic_buildroot(
File.join(config_dir, "installation-manifest"),
File.join(config_dir, "versions.yml"),
Expand Down
4 changes: 2 additions & 2 deletions test/autoproj/cli/ci_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -495,10 +495,10 @@ def self.consolidated_report_single_behavior( # rubocop:disable Metrics/AbcSize
end

consolidated_report_single_behavior(
"import", report_path_accessor: ->(ws) { ws.import_report_path }
"import", report_path_accessor: lambda(&:import_report_path)
)
consolidated_report_single_behavior(
"build", report_path_accessor: ->(ws) { ws.build_report_path }
"build", report_path_accessor: lambda(&:build_report_path)
)
consolidated_report_single_behavior(
"test", report_path_accessor: ->(ws) { ws.utility_report_path("test") }
Expand Down
11 changes: 11 additions & 0 deletions test/autoproj/cli/standalone_ci_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ module Autoproj::CLI # rubocop:disable Style/ClassAndModuleChildren
assert File.file?(iodrivers_base_file)
end

it "sets the tarball's root folder permissions to be 0755" do
output = File.join(make_tmpdir, "output.tar.gz")
StandaloneCI.start(["rebuild-root", @fixtures_path, @cache_root, output])

contents = `tar tvf "#{output}"`.split("\n").map(&:strip)
root_folder = contents.find { |line| %r{\./$}.match?(line) }
assert root_folder, "cannot find the root folder in created tarball"
assert root_folder.start_with?("drwxr-xr-x"),
"expected #{root_folder} to have r-x permission for group and user"
end

it "handles relative paths" do
out_dir = make_tmpdir
output = "output.tar.gz"
Expand Down

0 comments on commit 8fcc205

Please sign in to comment.