Class: PkgForge::Forge
- Inherits:
-
Object
- Object
- PkgForge::Forge
- Includes:
- Contracts::Builtin, Contracts::Core
- Defined in:
- lib/pkgforge/base.rb,
lib/pkgforge/components/run.rb,
lib/pkgforge/components/deps.rb,
lib/pkgforge/components/dirs.rb,
lib/pkgforge/components/test.rb,
lib/pkgforge/components/build.rb,
lib/pkgforge/components/patch.rb,
lib/pkgforge/components/cflags.rb,
lib/pkgforge/components/source.rb,
lib/pkgforge/components/upload.rb,
lib/pkgforge/components/package.rb,
lib/pkgforge/components/metadata.rb,
lib/pkgforge/components/configure.rb
Overview
Add configure flag options to Forge
Instance Attribute Summary collapse
- #build_block ⇒ Object
- #cflags ⇒ Object
- #configure_flags ⇒ Object
- #deps ⇒ Object
- #libs ⇒ Object
- #license ⇒ Object
- #name ⇒ Object
- #org ⇒ Object
- #patches ⇒ Object
- #test_block ⇒ Object
Instance Method Summary collapse
- #add_license! ⇒ Object
- #build! ⇒ Object
- #dep(package) ⇒ Object
-
#initialize(params = {}) ⇒ Forge
constructor
A new instance of Forge.
- #package! ⇒ Object
- #push! ⇒ Object
- #releasedir ⇒ Object
- #run(cmd, env = {}) ⇒ Object
- #test! ⇒ Object
- #test_run(cmd, env = {}) ⇒ Object
- #tmpdir(id) ⇒ Object
- #tmpfile(id) ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Forge
11 12 13 14 |
# File 'lib/pkgforge/base.rb', line 11 def initialize(params = {}) = params nil end |
Instance Attribute Details
#build_block ⇒ Object
10 11 12 |
# File 'lib/pkgforge/components/build.rb', line 10 def build_block @build_block ||= proc { raise 'No build block provided' } end |
#cflags ⇒ Object
8 9 10 |
# File 'lib/pkgforge/components/cflags.rb', line 8 def cflags @cflags ||= [] end |
#configure_flags ⇒ Object
8 9 10 |
# File 'lib/pkgforge/components/configure.rb', line 8 def configure_flags @configure_flags ||= {} end |
#deps ⇒ Object
10 11 12 |
# File 'lib/pkgforge/components/deps.rb', line 10 def deps @deps ||= {} end |
#libs ⇒ Object
13 14 15 |
# File 'lib/pkgforge/components/cflags.rb', line 13 def libs @libs ||= [] end |
#license ⇒ Object
20 21 22 |
# File 'lib/pkgforge/components/metadata.rb', line 20 def license @license ||= 'LICENSE' end |
#name ⇒ Object
10 11 12 |
# File 'lib/pkgforge/components/metadata.rb', line 10 def name @name || raise('No name provided') end |
#org ⇒ Object
15 16 17 |
# File 'lib/pkgforge/components/metadata.rb', line 15 def org @org || raise('No org provided') end |
#patches ⇒ Object
8 9 10 |
# File 'lib/pkgforge/components/patch.rb', line 8 def patches @patches ||= [] end |
#test_block ⇒ Object
10 11 12 |
# File 'lib/pkgforge/components/test.rb', line 10 def test_block @test_block ||= proc { raise 'No test block provided' } end |
Instance Method Details
#add_license! ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/pkgforge/components/metadata.rb', line 25 def add_license! src_file = File.join(tmpdir(:build), license) dest_dir = File.join( tmpdir(:release), 'usr', 'share', 'licenses', name ) dest_file = File.join(dest_dir, 'LICENSE') FileUtils.mkdir_p dest_dir FileUtils.cp src_file, dest_file nil end |
#build! ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/pkgforge/components/build.rb', line 15 def build! prepare_source! patch_source! prepare_deps! builder = PkgForge::DSL::Build.new(self) builder.instance_eval(&build_block) end |
#dep(package) ⇒ Object
9 10 11 |
# File 'lib/pkgforge/components/dirs.rb', line 9 def dep(package) tmpdir(package.to_sym) end |
#package! ⇒ Object
8 9 10 11 12 |
# File 'lib/pkgforge/components/package.rb', line 8 def package! add_license! make_tarball! copy_tarball! end |
#push! ⇒ Object
6 7 8 |
# File 'lib/pkgforge/components/upload.rb', line 6 def push! upload_artifact! end |
#releasedir ⇒ Object
14 15 16 |
# File 'lib/pkgforge/components/dirs.rb', line 14 def releasedir tmpdir(:release) end |
#run(cmd, env = {}) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/pkgforge/components/run.rb', line 6 def run(cmd, env = {}) Dir.chdir(tmpdir(:build)) do run_local(cmd, env) end nil end |
#test! ⇒ Object
15 16 17 18 |
# File 'lib/pkgforge/components/test.rb', line 15 def test! tester = PkgForge::DSL::Test.new(self) tester.instance_eval(&test_block) end |
#test_run(cmd, env = {}) ⇒ Object
14 15 16 17 18 |
# File 'lib/pkgforge/components/run.rb', line 14 def test_run(cmd, env = {}) Dir.chdir(tmpdir(:release)) do run_local(cmd, env) end end |
#tmpdir(id) ⇒ Object
19 20 21 22 |
# File 'lib/pkgforge/components/dirs.rb', line 19 def tmpdir(id) @tmpdirs ||= {} @tmpdirs[id] ||= Dir.mktmpdir(id.to_s) end |
#tmpfile(id) ⇒ Object
25 26 27 28 |
# File 'lib/pkgforge/components/dirs.rb', line 25 def tmpfile(id) @tmpfiles ||= {} @tmpfiles[id] ||= Tempfile.create(id.to_s).path end |