#!/usr/bin/env ruby require 'pathname' repoprefix = "/var/www/html/repo/" relativepath = "/centos/7/beta/" repoprefix = ARGV[0] relativepath = ARGV[1] #puts repoprefix #puts relativepath fullrepopath = Pathname.new("#{repoprefix}#{relativepath}").cleanpath.to_s puts fullrepopath updatetime = Time.new(1985,01,01, 9, 00, 00, "+02:00") markmodtime = File.mtime("#{fullrepopath}/updatemark") puts markmodtime puts updatetime puts updatetime == markmodtime if updatetime == markmodtime ## Check for avaliable arch'es(x86_64,i686\i386\i586) and update each of them # Update repository # res = `cd #{repoprefix}#{relativepath}/i686;createrepo ./` # puts res if File.directory?("#{fullrepopath}/i686") puts "----starting to work on #{fullrepopath}/i686" res = `cd #{fullrepopath}/i686;createrepo ./` puts res end if File.directory?("#{fullrepopath}/x86_64") puts "----starting to work on #{fullrepopath}/x86_64" res = `cd #{fullrepopath}/x86_64;createrepo ./` puts res end if File.directory?("#{fullrepopath}/SRPMS") puts "----starting to work on #{fullrepopath}/SRPMS" res = `cd #{fullrepopath}/SRPMS;createrepo ./` puts res end `touch #{fullrepopath}/updatemark` else puts "Enter to mark an update: " + "`touch -d '1 Jan 1985 09:00' #{fullrepopath}/updatemark`" puts "The repo is up-to-date" end