commit a79c6e11e959c0738b6eb8a835c0b74493b4e4cf Author: Sukhbir Singh sukhbir@torproject.org Date: Tue Aug 1 11:01:31 2017 -0400
Update the clean-old script
Also add the rbm.local.conf file that the script uses. --- rbm.local.conf | 9 +++++ tools/clean-old | 110 +------------------------------------------------------- 2 files changed, 10 insertions(+), 109 deletions(-)
diff --git a/rbm.local.conf b/rbm.local.conf new file mode 100644 index 0000000..39fff92 --- /dev/null +++ b/rbm.local.conf @@ -0,0 +1,9 @@ +var: + local_conf: 1 + + clean: + master: + - project: release + target: + - release + - tormessenger-all diff --git a/tools/clean-old b/tools/clean-old deleted file mode 100755 index a4de55f..0000000 --- a/tools/clean-old +++ /dev/null @@ -1,109 +0,0 @@ -#!/usr/bin/perl -w -use strict; -use Cwd qw(getcwd); -use IO::CaptureOutput qw(capture_exec); -use FindBin; - -my $rbm = "$FindBin::Bin/../rbm/rbm"; -my $projects_dir = "$FindBin::Bin/../projects"; -my $product_target = 'tor-messenger'; -my @targets = qw(linux-x86_64 linux-i686 windows-i686 osx-x86_64); -my @sig_ext = qw(.sig .gpg .asc); -my $docker_image_prefix = docker_image_prefix(); - -sub clean_project_build_files { - my ($project) = @_; - my $old_cwd = getcwd; - chdir "$FindBin::Bin/../out/$project"; - my @files = grep { -f $_ } glob '*'; - chdir $old_cwd; - my %keep_files; - foreach my $target (@targets) { - my ($out, $err, $success) = capture_exec($rbm, - 'showconf', $project, 'filename', "--target=$product_target", - "--target=$target"); - return unless $success; - chomp $out; - $keep_files{$out} = 1; - ($out, $err, $success) = capture_exec($rbm, - 'showconf', $project, 'var/input_files_list', - "--target=$product_target", "--target=$target"); - next unless $success; - my @input_files = split("\n", $out); - foreach my $input_file (@input_files) { - chomp $input_file; - next unless $input_file; - $keep_files{$input_file} = 1; - foreach my $ext (qw(sig gpg asc)) { - $keep_files{"$input_file.$ext"} = 1; - } - } - } - foreach my $file (@files) { - next if $keep_files{$file}; - print "Removing $file\n"; - unlink "$FindBin::Bin/../out/$project/$file"; - } -} - -sub clean_build_files { - chdir $projects_dir; - foreach my $project (glob '*') { - next if $project eq 'docker-image'; - next unless -f "$project/config"; - print "Cleaning project: $project\n"; - clean_project_build_files($project); - } -} - -sub docker_image_prefix { - my ($out, $err, $success) = capture_exec($rbm, 'showconf', 'docker-image', - 'docker_image_prefix'); - die "Cannot get docker image prefix" unless $success; - chomp $out; - return $out; -} - -sub remove_docker_image { - my ($image_name) = @_; - my $image = "$docker_image_prefix:$image_name"; - print "Removing docker image $image\n"; - my ($out, $err, $success) = capture_exec('docker', 'rmi', '-f', $image); - if (!$success) { - print STDERR "Error removing docker image $image\n"; - return; - } - unlink "$FindBin::Bin/../out/docker-image/$image_name"; -} - -sub clean_docker_images { - chdir "$FindBin::Bin/../out/docker-image" or return; - print "Cleaning docker images\n"; - my @docker_files = grep { -f $_ } glob '*'; - my %keep_docker_files; - chdir $projects_dir; - foreach my $project (glob '*') { - next if $project eq 'docker-image'; - next unless -f "$project/config"; - foreach my $target (@targets) { - my ($out, $err, $success) = capture_exec($rbm, 'showconf', $project, - 'remote_docker', "--target=$product_target", "--target=$target"); - next unless $success; - chomp $out; - next unless $out; - ($out, $err, $success) = capture_exec($rbm, 'showconf', $project, - 'docker_image', "--target=$product_target", "--target=$target"); - next unless $success; - chomp $out; - my (undef, $image_file) = split(':', $out); - $keep_docker_files{$image_file} = 1; - } - } - foreach my $docker_file (@docker_files) { - next if $keep_docker_files{$docker_file}; - remove_docker_image($docker_file); - } -} - -clean_build_files; -clean_docker_images; diff --git a/tools/clean-old b/tools/clean-old new file mode 120000 index 0000000..bbe9bfd --- /dev/null +++ b/tools/clean-old @@ -0,0 +1 @@ +../tor-browser-build/tools/clean-old \ No newline at end of file