From 8247be523d75574ab70fdc093b31453a4050beec Mon Sep 17 00:00:00 2001 From: Pascal Terjan Date: Sun, 27 Oct 2019 12:44:22 +0000 Subject: Add a --auto to mga-clean-distrib I think it is now safe enough to run in cron --- modules/buildsystem/templates/cleaner.rb | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'modules') diff --git a/modules/buildsystem/templates/cleaner.rb b/modules/buildsystem/templates/cleaner.rb index 6356de23..3f818e46 100755 --- a/modules/buildsystem/templates/cleaner.rb +++ b/modules/buildsystem/templates/cleaner.rb @@ -4,10 +4,11 @@ def usage puts "Usage: #{$0} [options]" puts "Moves obsolete packages" puts - puts "-h, --help show help" - puts "-m, --media which media to clean (default: core/release)" - puts "-p, --base base path to the repository" + puts "-h, --help show help" puts "-a, --archs ,,... list of architectures to clean" + puts "-a, --auto do not ask confirmation" + puts "-p, --base base path to the repository" + puts "-m, --media which media to clean (default: core/release)" puts "-d, --destination path to the old packages storage" puts "-v, --version version to clean (default: cauldron)" end @@ -20,6 +21,7 @@ def process opts = GetoptLong.new( [ '--help', '-h', GetoptLong::NO_ARGUMENT ], [ '--archs', '-a', GetoptLong::REQUIRED_ARGUMENT ], + [ '--auto', '-A', GetoptLong::NO_ARGUMENT ] [ '--base', '-p', GetoptLong::REQUIRED_ARGUMENT ], [ '--media', '-m', GetoptLong::REQUIRED_ARGUMENT ], [ '--destination', '-d', GetoptLong::REQUIRED_ARGUMENT ], @@ -31,6 +33,7 @@ def process media = "core/release" old_path = "<%= scope.lookupvar('buildsystem::var::youri::packages_archivedir') %>" version = "cauldron" + auto = false opts.each do |opt, arg| case opt @@ -43,6 +46,8 @@ def process media = arg when '--archs' archs = arg.split(",") + when '--auto' + auto = true when '--base' base_path = arg when '--version' @@ -72,24 +77,24 @@ def process debug_path = bin_path.sub("/media/", "/media/debug/") old_packages = check_binaries($srcs, $srcages, bin_path, $used_srcs) old_debug_packages = check_binaries($srcs, {}, debug_path, nil) - move_packages(bin_path, old_path, old_packages) - move_packages(debug_path, old_path, old_debug_packages) + move_packages(bin_path, old_path, old_packages, auto) + move_packages(debug_path, old_path, old_debug_packages, auto) } $used_srcs.keys.each{|s| $srcs.delete(s)} - move_packages(src_path, old_path, $srcs.keys) + move_packages(src_path, old_path, $srcs.keys, auto) end -def move_packages(src, dst, list) +def move_packages(src, dst, list, auto) list.reject!{|f| !File.exist?(src + "/" + f)} return if list.empty? list.each{|b| puts b } puts "The #{list.length} listed packages will be moved from #{src} to #{dst}." - line = Readline::readline('Are you sure [Yn]? ') - if (line =~ /^y?$/i) + line = Readline::readline('Are you sure [Yn]? ') unless auto + if auto || line =~ /^y?$/i list.each{|s| oldfile = src + "/" + s newfile = dst + "/" + s -- cgit v1.2.1