Class: BuildrDeb::DebTask
- Inherits:
-
Buildr::ArchiveTask
- Object
- Buildr::ArchiveTask
- BuildrDeb::DebTask
- Defined in:
- lib/buildrdeb/package.rb
Instance Attribute Summary collapse
-
#control ⇒ Object
Returns the value of attribute control.
-
#postinst ⇒ Object
Returns the value of attribute postinst.
-
#postrm ⇒ Object
Returns the value of attribute postrm.
-
#preinst ⇒ Object
Returns the value of attribute preinst.
-
#prerm ⇒ Object
Returns the value of attribute prerm.
-
#triggers ⇒ Object
Returns the value of attribute triggers.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
-
#create_from(file_map) ⇒ Object
The ArchiveTask class delegates this method so we can create the archive.
Instance Attribute Details
#control ⇒ Object
Returns the value of attribute control.
20 21 22 |
# File 'lib/buildrdeb/package.rb', line 20 def control @control end |
#postinst ⇒ Object
Returns the value of attribute postinst.
20 21 22 |
# File 'lib/buildrdeb/package.rb', line 20 def postinst @postinst end |
#postrm ⇒ Object
Returns the value of attribute postrm.
20 21 22 |
# File 'lib/buildrdeb/package.rb', line 20 def postrm @postrm end |
#preinst ⇒ Object
Returns the value of attribute preinst.
20 21 22 |
# File 'lib/buildrdeb/package.rb', line 20 def preinst @preinst end |
#prerm ⇒ Object
Returns the value of attribute prerm.
20 21 22 |
# File 'lib/buildrdeb/package.rb', line 20 def prerm @prerm end |
#triggers ⇒ Object
Returns the value of attribute triggers.
20 21 22 |
# File 'lib/buildrdeb/package.rb', line 20 def triggers @triggers end |
#version ⇒ Object
Returns the value of attribute version.
20 21 22 |
# File 'lib/buildrdeb/package.rb', line 20 def version @version end |
Instance Method Details
#create_from(file_map) ⇒ Object
The ArchiveTask class delegates this method so we can create the archive. the file_map is the result of the computations of the include and exclude filters.
With deb we recreate the structure asked by the user then we will call dpkg –build over it.
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 |
# File 'lib/buildrdeb/package.rb', line 28 def create_from(file_map) root = File.join("target", "_#{File.basename(name)}") mkpath File.join(root, "DEBIAN") #echo "THe version " + @version for file in ["control", "prerm", "postinst", "postrm", "preinst", "triggers"] thefile = eval("self."+file) targetFile = File.join(root, "DEBIAN", file) if !thefile.nil? and File.exists? thefile actualFile = File.open(thefile, "r") myfile = File.open( targetFile, "w") actualFile.each { |line| if file == "control" then if line.match /^Version: / and !@version.nil? then myfile.puts("Version: " + @version +"\n") else myfile.puts eval('"'+ line + '"') end else myfile.puts line end } myfile.close actualFile.close File.chmod 0755, targetFile #cp send(file.to_sym), File.join(root, "DEBIAN", file) #File.chmod 0755, File.join(root, "DEBIAN", file) end end file_map.each do |path, content| _path = File.join(root, path) if content.respond_to?(:call) raise "Not implemented" content.call path elsif content.nil? || File.directory?(content.to_s) mkpath _path else mkpath File.dirname(_path) cp content.to_s, _path end end out = %x[ dpkg --build \"#{root}\" \"#{name}\" 2>&1 ] raise "dpkg failed with this error:\n#{out}" if $? != 0 end |