Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Remove wget dependency and verify existence of 7z.exe in build script #60

Merged
merged 2 commits into from
Nov 29, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 31 additions & 10 deletions build_cmder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,28 @@
# conemu-maximus5. Correct files are beeing picked by using labels.
# I will move the script for getting files by labels from php to here as soon I feel like it

require 'FileUtils'
require 'fileutils'
require 'open-uri'
require 'uri'

def get_file project, query
# Should be changed to integrated downloader
urlToFile = 'wget -q -O - "http://samuelvasko.tk/gcode/?project='+project+'&query='+query+'"'
urlToFile = `#{urlToFile}`
urlToFile = urlToFile.split("\n").first
urlToFile = URI.escape('http://samuelvasko.tk/gcode/?project='+project+'&query='+query)
open(urlToFile) do |resp|
urlToFile = URI.escape(resp.read.split(/\r?\n/).first)
end

extension = urlToFile.split('.').last
filename = project+'.'+extension

puts "\n ------ Downloading #{project} ------- \n \n"
get_file = system("wget -O #{filename} #{urlToFile}")

unless get_file
puts "Failied to download #{project} from #{urlToFile}"
puts "\n ------ Downloading #{project} from #{urlToFile} ------- \n \n"
begin
open(urlToFile, 'rb') do |infile|
open(filename, 'wb') do |outfile|
outfile.write(infile.read)
end
end
rescue IOError => error
puts error
FileUtils.rm(filename) if File.exists?(filename)
exit(1)
end
Expand All @@ -39,7 +45,17 @@ def get_file project, query
FileUtils.mv(Dir.glob("#{temp_name}/*")[0], project)
FileUtils.rm_r(temp_name)
end
end

def find_on_path exe
path = ENV['PATH'].split(File::PATH_SEPARATOR)
for dir in path
if File.exists?(File.join(dir, exe))
return true
end
end

return false
end

puts '
Expand All @@ -53,6 +69,11 @@ def get_file project, query
|___/
'

unless find_on_path('7z.exe')
puts '7z.exe not found. Ensure 7-zip is installed and on the PATH.'
exit(1)
end

puts 'Cleanup'

if Dir.exists?('vendor')
Expand Down