forked from BrandonArp/Chimera
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prep_manifest.rb
executable file
·57 lines (49 loc) · 1.34 KB
/
prep_manifest.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env ruby
require 'fileutils'
require 'optparse'
$: << File.dirname( __FILE__)
require 'lib/aptutils'
require 'lib/deploy'
#def install_package(package_name)
# #install me
# my_info = get_package_info(package_name)
# my_version = get_package_version(my_info)
# my_cache_deb = get_cache_deb(my_info)
# package_loc = "/chimera/packages/#{package_name}/#{my_version}"
# if not File.directory?(package_loc)
# FileUtils.mkpath(package_loc)
# end
#
# `dpkg -x #{my_cache_deb} #{package_loc}`
# puts "error extracting package '#{package_name}'" unless $? == 0
#end
packages = []
manifest = nil
opts = OptionParser.new
opts.on('-m', '--manifest MANIFEST', "manifest file to prepare") do |mani|
manifest = mani
end
opts.on('-h', '--help', 'show this help dialog') do
puts opts
exit 0
end
opts.parse!
if not manifest
puts 'missing required argument manifest'
puts opts
exit 1
end
manifest_file = File.open(manifest, 'r')
manifest_file.each_line do |line|
if (line =~ /(.*)=>(.*)/)
package = $1
packages.push(package)
end
end
puts "Getting packages with apt, please wait..."
output = `apt-get install -y -d #{packages.join(" ")}`
puts "error getting package. are you running as root?\n#{output}" unless $? == 0
packages.each do |package|
puts "Installing package #{package} into chimera cache"
install_package(package)
end