desc 'Creates and uploads apt and rpm repos.' task "build:repos" => ['build:deb', 'build:rpm'] do require 'find' # CONSTANTS PKG_DIR = '/packages' START_DIR = PKG_DIR BUCKET = 'rhoconnect' def cmd(cmd) puts cmd unless @raked system(cmd) end #cmd def prepare_destination # Prompt to remove the /deb directory if it exists if File.directory?("#{PKG_DIR}/deb") if !@raked puts "Remove #{PKG_DIR}/deb?" remove = STDIN.gets.strip.downcase.chars.first else remove = 'y' end #if if remove == 'y' cmd "sudo rm -rf #{PKG_DIR}/deb" end #if end #if # Create deb directory if it does not already exist cmd "sudo mkdir -p #{PKG_DIR}/deb" unless File.directory?("#{PKG_DIR}/deb") # Create configuration file "ditributions" in deb directory filename = "#{PKG_DIR}/deb/conf/" cmd "sudo mkdir -p #{filename}" distributions = "Origin: Rhomobile, Inc.\n" + "Label: Rhomobile, Inc.\n" + "Codename: rhoconnect\n" + "Architectures: i386 amd64\n" + "Components: main\n" + "Description: Rhoconnect APT Repository" cmd "touch #{filename}/distributions" # Write distributions string to corresponding file dist_file = File.new("#{filename}/distributions", "w") dist_file.write(distributions) dist_file.close # Create rpm directory if it does not already exist cmd "sudo mkdir -p #{PKG_DIR}/rpm" unless File.directory?("#{PKG_DIR}/rpm") end #prepare_destination def copy_files # Copy the packages to their respective directory Find.find('./pkg') do |file| if !FileTest.directory?(file) dest_dir = File.extname(file) #get rid of '.' before extension name dest_dir[0] = '' if dest_dir == 'deb' || dest_dir == 'rpm' if dest_dir == 'deb' @deb_pkg = File.basename(file) end #if file_path = File.expand_path(file) cmd "sudo cp -rf #{file_path} #{PKG_DIR}/#{dest_dir}" end #if end #if end #do end #copy_files @raked = true prepare_destination copy_files # REPOIFY! cmd "sudo reprepro -b #{PKG_DIR}/deb includedeb rhoconnect #{PKG_DIR}/deb/#{@deb_pkg}" cmd "sudo createrepo #{PKG_DIR}/rpm" # Call S3 upload script cmd "ruby ./installer/utils/package_upload/s3_upload.rb #{START_DIR} #{BUCKET} #{@raked}" end #build:repos