Skip to content

Commit

Permalink
Add binstall command
Browse files Browse the repository at this point in the history
  • Loading branch information
jam7 committed Jul 17, 2017
1 parent f99957d commit 69067f0
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions crew
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ def help (pkgName)
puts "Build a package."
puts "Usage: crew build [package]"
puts "Build [package] from source and place the archive and checksum in the current working directory."
when "binstall"
puts "Build and install a package."
puts "Usage: crew binstall [package]"
puts "Build and install [package] from source and place the archive and checksum in the current working directory."
when "download"
puts "Download a package."
puts "Usage: crew download [package]"
Expand Down Expand Up @@ -640,6 +644,43 @@ def resolve_dependencies_and_build
end
end

def resolve_dependencies_and_build_and_install
begin
origin = @pkg.name

# mark current package as which is required to compile from source
@pkg.build_from_source = true
resolve_dependencies

search origin, true
build_package Dir.pwd
if @device[:installed_packages].any? { |pkg| pkg[:name] == @pkg.name }
puts "Removing since forcing install..."
remove @pkg.name
end
puts "Installing..."
install_package CREW_DEST_DIR

#add to installed packages
@device[:installed_packages].push(name: @pkg.name, version: @pkg.version)
File.open(CREW_CONFIG_PATH + 'device.json', 'w') do |file|
output = JSON.parse @device.to_json
file.write JSON.pretty_generate(output)
end
puts "#{@pkg.name.capitalize} installed!"
rescue InstallError => e
abort "#{@pkg.name} failed to build: #{e.to_s}"
ensure
#cleanup
unless ARGV[2] == 'keep'
Dir.chdir CREW_BREW_DIR do
system "rm -rf *"
system "mkdir dest" #this is a little ugly, feel free to find a better way
end
end
end
end

def build_package (pwd)
abort "It is not possible to build fake package".lightred if @pkg.is_fake?
abort "It is not possible to build without source".lightred if !@pkg.is_source?(@device[:architecture])
Expand Down Expand Up @@ -774,6 +815,13 @@ when "build"
else
help "build"
end
when "binstall"
if @pkgName
search @pkgName
resolve_dependencies_and_build_and_install
else
help "binstall"
end
when "remove"
if @pkgName
remove @pkgName
Expand Down

0 comments on commit 69067f0

Please sign in to comment.