aboutsummaryrefslogtreecommitdiffstats
path: root/modules/buildsystem/templates/cleaner.rb
diff options
context:
space:
mode:
authorPascal Terjan <pterjan@mageia.org>2019-10-27 12:44:22 +0000
committerPascal Terjan <pterjan@mageia.org>2019-10-27 12:44:22 +0000
commit8247be523d75574ab70fdc093b31453a4050beec (patch)
treec7e17cca75684cc5b9014eb5976649d517476e53 /modules/buildsystem/templates/cleaner.rb
parent7b163f979e3f16af09c87ef60a8447f579029d9f (diff)
downloadpuppet-8247be523d75574ab70fdc093b31453a4050beec.tar
puppet-8247be523d75574ab70fdc093b31453a4050beec.tar.gz
puppet-8247be523d75574ab70fdc093b31453a4050beec.tar.bz2
puppet-8247be523d75574ab70fdc093b31453a4050beec.tar.xz
puppet-8247be523d75574ab70fdc093b31453a4050beec.zip
Add a --auto to mga-clean-distrib
I think it is now safe enough to run in cron
Diffstat (limited to 'modules/buildsystem/templates/cleaner.rb')
-rwxr-xr-xmodules/buildsystem/templates/cleaner.rb23
1 files changed, 14 insertions, 9 deletions
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 <media> which media to clean (default: core/release)"
- puts "-p, --base <path> base path to the repository"
+ puts "-h, --help show help"
puts "-a, --archs <arch1>,<arch2>,... list of architectures to clean"
+ puts "-a, --auto do not ask confirmation"
+ puts "-p, --base <path> base path to the repository"
+ puts "-m, --media <media> which media to clean (default: core/release)"
puts "-d, --destination <path> path to the old packages storage"
puts "-v, --version <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