Class: Gaffer::Deb
- Inherits:
-
Object
- Object
- Gaffer::Deb
- Defined in:
- lib/gaffer/deb.rb
Instance Attribute Summary collapse
-
#arch ⇒ Object
Returns the value of attribute arch.
-
#depends ⇒ Object
Returns the value of attribute depends.
-
#package ⇒ Object
Returns the value of attribute package.
-
#readme ⇒ Object
Returns the value of attribute readme.
Instance Method Summary collapse
- #build ⇒ Object
- #build_name ⇒ Object
- #control ⇒ Object
- #description ⇒ Object
- #filebase ⇒ Object
- #has_init? ⇒ Boolean
-
#initialize(base, _package, _depends) ⇒ Deb
constructor
A new instance of Deb.
- #maintainer ⇒ Object
- #origin ⇒ Object
- #origin_url ⇒ Object
- #project ⇒ Object
- #template(type) ⇒ Object
Constructor Details
#initialize(base, _package, _depends) ⇒ Deb
Returns a new instance of Deb.
5 6 7 8 9 10 11 |
# File 'lib/gaffer/deb.rb', line 5 def initialize(base, _package, _depends) @base = base @arch = "all" @package = _package @depends = _depends @dev = !!(@package =~ /-dev$/) end |
Instance Attribute Details
#arch ⇒ Object
Returns the value of attribute arch.
3 4 5 |
# File 'lib/gaffer/deb.rb', line 3 def arch @arch end |
#depends ⇒ Object
Returns the value of attribute depends.
3 4 5 |
# File 'lib/gaffer/deb.rb', line 3 def depends @depends end |
#package ⇒ Object
Returns the value of attribute package.
3 4 5 |
# File 'lib/gaffer/deb.rb', line 3 def package @package end |
#readme ⇒ Object
Returns the value of attribute readme.
3 4 5 |
# File 'lib/gaffer/deb.rb', line 3 def readme @readme end |
Instance Method Details
#build ⇒ Object
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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/gaffer/deb.rb', line 13 def build Dir.mktmpdir do |dir| install_dir = Rush["#{dir}/#{@base.prefix}/"] Git.clone(@base.dir, install_dir.full_path) Rush.bash "mkdir #{dir}/DEBIAN" File.open("#{dir}/DEBIAN/control", "w") do |f| f.write(control) end puts control if @dev Rush.bash "find #{install_dir.full_path} | grep -v [.]git | grep -v #{install_dir.full_path}$ | xargs rm -rf" else Rush.bash "find #{install_dir.full_path} | grep [.]git | grep -v #{install_dir.full_path}$ | xargs rm -rf" [ :preinst, :postinst, :prerm, :postrm ].each do |script| File.open("#{dir}/DEBIAN/#{script}","w") do |file| file.chmod(0755) file.write(template(script)) end end if install_dir["sudoers"].exists? Rush["#{dir}/etc/sudoers.d/"].create File.open("#{dir}/etc/sudoers.d/#{project}","w") do |file| file.chmod(0440) file.write install_dir["sudoers"].read end puts "sudoers -> /etc/sudoers.d/#{project}" end if install_dir["init.conf"].exists? puts " * detected init.conf - installing..." Rush["#{dir}/etc/init/"].create Rush["#{dir}/etc/init/#{project}.conf"].write install_dir["init.conf"].read puts "init.conf -> /etc/init/#{project}.conf" elsif install_dir["run"].exists? puts " * detected file 'run' - setting up initfile ..." initfile = template(:init) puts "----" puts initfile puts "----" puts " * installing to /etc/init/#{project}.conf" Rush["#{dir}/etc/init/#{project}.conf"].parent.create Rush["#{dir}/etc/init/#{project}.conf"].write(initfile) end if install_dir["Gemfile"].exists? puts " * Gemfile detected - installing gems before packaging" ## bundle output cannot be trusted - errors go to stdout and output goes to stderr begin install_dir.bash "bundle package 2>&1 > .tmp.bundle.out" # install_dir.bash "bundle install --development 2>&1 > .tmp.bundle.out" rescue Object => e puts " * Bundle error:" puts install_dir[".tmp.bundle.out"].read raise "Bundle failed" end puts install_dir[".tmp.bundle.out"].read # if out.match(/native extensions/) # puts "Warning: native extensions - the package is arch specific" # @arch = Rush.bash("dpkg --print-architecture").chomp # end # end end end puts Rush.bash "pwd" puts "fakeroot dpkg-deb -b #{dir} ./#{filebase}.deb" puts Rush.bash "fakeroot dpkg-deb -b #{dir} ./#{filebase}.deb" x = File.("./#{filebase}.deb") puts x x end end |
#build_name ⇒ Object
111 112 113 |
# File 'lib/gaffer/deb.rb', line 111 def build_name @base.build_name end |
#control ⇒ Object
119 120 121 |
# File 'lib/gaffer/deb.rb', line 119 def control template(:control) end |
#description ⇒ Object
91 92 93 |
# File 'lib/gaffer/deb.rb', line 91 def description "Gaffer package #{package} #{build_name}" end |
#filebase ⇒ Object
95 96 97 |
# File 'lib/gaffer/deb.rb', line 95 def filebase "#{package}_#{build_name}_#{@arch}" end |
#has_init? ⇒ Boolean
83 84 85 |
# File 'lib/gaffer/deb.rb', line 83 def has_init? File.exists?("#{@base.dir}/init.conf") end |
#maintainer ⇒ Object
107 108 109 |
# File 'lib/gaffer/deb.rb', line 107 def maintainer @base.maintainer end |
#origin ⇒ Object
103 104 105 |
# File 'lib/gaffer/deb.rb', line 103 def origin Rush[@base.dir] end |
#origin_url ⇒ Object
87 88 89 |
# File 'lib/gaffer/deb.rb', line 87 def origin_url @base.git.remotes.select { |r| r.name == "origin" }.map { |r| r.url }.first end |
#project ⇒ Object
115 116 117 |
# File 'lib/gaffer/deb.rb', line 115 def project @base.project end |
#template(type) ⇒ Object
99 100 101 |
# File 'lib/gaffer/deb.rb', line 99 def template(type) ERB.new(File.read("#{File.dirname(__FILE__)}/../../templates/#{type}.erb")).result(binding) end |