installer/utils/package_upload/repos.rake in rhoconnect-3.1.0 vs installer/utils/package_upload/repos.rake in rhoconnect-3.1.1
- old
+ new
@@ -1,15 +1,25 @@
+require 'rake'
+
desc 'Creates and uploads apt and rpm repos.'
-task "build:repos" => ['build:deb', 'build:rpm'] do
+task "build:repos", :build_type do |t, args|
+ # Run dependent rake jobs first
+ Rake::Task['build:deb'].invoke
+ Rake::Task['build:rpm'].invoke
+ args.with_defaults :build_type => 'nightly-build'
+ puts args
+ # Exit if args are not valid args
+ exit 1 if !args[:build_type].eql? "nightly-build" and !args[:build_type].eql? "release-build"
+
require 'find'
require 'fileutils'
# CONSTANTS
PKG_DIR = '/packages'
BETA_PKG_DIR = '/beta-packages'
- BUCKET = 'rhoconnect'
+ BUCKET = args[:build_type].eql?('release-build') ? 'rhoconnect-test' : 'rhoconnect'
def cmd(cmd)
puts cmd unless @raked
system(cmd)
end #cmd
@@ -56,11 +66,10 @@
end #prepare_destination
def copy_files
# Copy the packages to their respective directory
Find.find('./pkg') do |file|
- puts "File: #{file}"
if !FileTest.directory?(file)
dest_dir = File.extname(file)
dest_dir[0] = '' #get rid of '.' before extension name
if dest_dir == 'deb' || dest_dir == 'rpm'
if dest_dir == 'deb'
@@ -83,21 +92,21 @@
cmd "sudo reprepro -b #{PKG_DIR}/deb includedeb rhoconnect #{PKG_DIR}/deb/#{@deb_pkg}"
cmd "sudo createrepo #{PKG_DIR}/rpm"
# Call S3 upload script
['deb', 'rpm'].each do |dir|
- beta = 0
+ beta = false
pkg_dir = PKG_DIR
Find.find("#{PKG_DIR}/#{dir}") do |file|
if File.extname(file) =~ /deb|rpm/
- file =~ /.*beta.*/ ? beta += 1 : beta = beta
- pkg_dir = BETA_PKG_DIR
+ beta = file.include?('beta') ? true : false
+ pkg_dir = BETA_PKG_DIR if beta
cmd "sudo mkdir #{BETA_PKG_DIR}" unless File.directory? BETA_PKG_DIR
cmd "sudo chmod 777 #{BETA_PKG_DIR}"
# If one beta pkg is found, break.
- break
+ break if beta
end #if
end #do
- cmd "sudo cp -rf #{PKG_DIR}/#{dir} #{BETA_PKG_DIR}/#{dir}"
+ cmd "sudo cp -rf #{PKG_DIR}/#{dir} #{BETA_PKG_DIR}/#{dir}" if pkg_dir == BETA_PKG_DIR
cmd "sudo ruby ./installer/utils/package_upload/s3_upload.rb #{pkg_dir}/#{dir} #{BUCKET} #{@raked}"
end #do
end #build:repos