bnt 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NGIwZGZjNmFjNDk4MDMyNjQ1M2EzMjUzMjI3MjZiODllMjE0ZGMyYw==
5
+ data.tar.gz: !binary |-
6
+ ZDRjNzRhMDM4YjRhMmFlMzU0MWJmNTQ5YTk1ZjIzMGVlY2Q3N2E0YQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ NzViYzQ1OGNmOTRjOWM4Zjc1Mjc1NzMzNWNiZjg1YzFlZjk5OTM1ZWM5M2Nm
10
+ YmFhZTQ5YWFjOWVjODBhZGZlMmI5ZDAzYjgyMzhmNGYyNzE3NjI1MzFlMWRi
11
+ Y2ZmZGIxZTUyZjE4YWJkOTNkNmY4OTIzOTAzMGQ5MzdlYjZmYzI=
12
+ data.tar.gz: !binary |-
13
+ ZTExN2NlOTI3ZDMxMDRmZTMyZWIxZDY2OTJkMzY0ZjdlOTBlYzA5MGQ5MjQ1
14
+ N2QyODc0MzJhZThkZjVlNmZlOGYxZWY4NzcxN2U3ZGIxMjdjMDY3ODM1Nzk4
15
+ NDRiNDM2ZTljZmU5N2RiNTViZTdjMmZmYTNhNGQ2YzI0MmE3M2Q=
@@ -0,0 +1,6 @@
1
+ *.swp
2
+ *~
3
+ *#
4
+ #*
5
+ .#
6
+ bnt*.gem
data/README ADDED
@@ -0,0 +1,20 @@
1
+ BOSH Ninja Tools
2
+ ================
3
+
4
+ Bnt is a fast way to test bosh package compilation using chroot
5
+
6
+ Usage
7
+ -----
8
+
9
+ gem install bnt
10
+
11
+ $ export CAGE_PATH=~/.bnt/cages/latest-bosh-stemcell/
12
+ $ sudo -E ./bin/bnt-create-cage
13
+
14
+ Now you are able to start testing your bosh packages like this:
15
+
16
+ $ ./bin/bnt /path/to/bosh/package
17
+
18
+ You'll need root permissions to use BNT.
19
+
20
+ Have fun!
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/bnt/env'
4
+
5
+ puts "==> Using #{Cage.path}"
6
+ puts "-> [ Creating bosh dirs structure ]"
7
+
8
+ bosh_dirs = "/var/vcap/packages/ /var/vcap/jobs/ /var/vcap/sys/run /var/vcap/sys/log/ /var/vcap/store /var/vcap/bnt"
9
+
10
+ Runner.exec "sudo chroot #{Cage.path} mkdir -p #{bosh_dirs}"
11
+
12
+ puts "-> [ Copying scripts to cage ]"
13
+ builder_script_path = 'bin/bnt-make-package'
14
+ Runner.exec "sudo cp #{builder_script_path} #{Cage.path}/var/vcap/bnt/"
15
+
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/bnt/env'
4
+ require 'fileutils'
5
+
6
+ def download_stemcell(cache_path)
7
+ FileUtils.cd cache_path do
8
+ Runner.exec "wget -c http://bosh-jenkins-gems-warden.s3.amazonaws.com/stemcells/latest-bosh-stemcell-warden.tgz"
9
+ end
10
+ end
11
+
12
+ def untar_stemcell(cage_path, cache_stemcell_path)
13
+ FileUtils.cd cage_path do
14
+ Runner.exec "tar -xzf #{cache_stemcell_path}"
15
+ end
16
+ end
17
+
18
+ def gunzip_stemcell_img(cage_path)
19
+ FileUtils.cd cage_path do
20
+ stemcell_version = `grep "^version:" stemcell.MF`
21
+ msg = "decompressing stemcell #{stemcell_version}"
22
+ `mv image image.tar.gz`
23
+ Runner.exec :cmd => "sudo -E tar -xzf image.tar.gz", :msg => msg
24
+ end
25
+ end
26
+
27
+ cache_path = File.expand_path('~/.bnt/cache/')
28
+ cache_stemcell_path = "#{cache_path}/latest-bosh-stemcell-warden.tgz"
29
+ cage_path = File.expand_path('~/.bnt/cages/latest-bosh-stemcell')
30
+
31
+ Runner.exec "mkdir -p #{cache_path}"
32
+ Runner.exec "mkdir -p #{cage_path}"
33
+
34
+ download_stemcell cache_path
35
+ untar_stemcell cage_path, cache_stemcell_path
36
+ gunzip_stemcell_img cage_path
37
+
38
+ ENV['CAGE_PATH'] = cage_path
39
+ Runner.exec "./bin/bnt-create-bosh-dirs"
40
+
41
+ Runner.exec "sudo cp /etc/resolv.conf #{cage_path}/etc/"
42
+
43
+ puts "now you can use this new cage doing 'export CAGE_PATH=#{cage_path}'"
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/bnt/env'
4
+ require "readline"
5
+
6
+ Runner.exec "sudo umount #{Cage.tmp_dir}"
7
+
8
+ puts "\n\nWARNING!!! I'm going to delete #{Cage.path}"
9
+ input = Readline.readline("yes|no >", true)
10
+ Runner.exec "sudo rm -rf #{Cage.path}" if input == "yes"
11
+
@@ -0,0 +1,21 @@
1
+ #!/bin/sh -x
2
+
3
+ export BOSH_INSTALL_TARGET=/var/vcap/packages/$1
4
+ export BOSH_COMPILE_TARGET=/tmp/bosh-compile/
5
+ export BOSH_RELEASE_DIR=/tmp/bosh-release
6
+
7
+ mkdir -p $BOSH_COMPILE_TARGET
8
+ mkdir -p $BOSH_RELEASE_DIR
9
+
10
+ echo \-\> compiling: $BOSH_INSTALL_TARGET
11
+ cd $BOSH_COMPILE_TARGET
12
+
13
+ if [ ! -f $1 ]; then
14
+ ln -s $BOSH_RELEASE_DIR/src/$1 $1
15
+ fi
16
+
17
+ . $BOSH_RELEASE_DIR/packages/$1/packaging
18
+
19
+ # Remove the sources
20
+ rm -rf $BOSH_COMPILE_TARGET
21
+
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/bnt/env'
4
+
5
+ package_path = ARGV[0]
6
+ package_name = package_path.split("/").last
7
+ package_cage_path = "#{Cage.packages_path}/#{package_name}"
8
+
9
+ release_path = package_path.split("/")
10
+ release_path.pop
11
+ release_path.pop
12
+ release_path = release_path.join("/")
13
+
14
+ Runner.exec "sudo mkdir -p #{Cage.package_path(package_name)}"
15
+
16
+ unless File.directory? Cage.tmp_dir
17
+ Runner.exec "sudo mkdir #{Cage.tmp_dir}"
18
+ end
19
+
20
+ mount_check = `mount | grep #{Cage.path}`
21
+
22
+ if mount_check.empty?
23
+ Runner.exec "sudo mount --bind #{release_path} #{Cage.tmp_dir}"
24
+ end
25
+
26
+ Runner.exec "sudo chroot #{Cage.path} sh /var/vcap/bnt/bnt-make-package #{package_name} "
@@ -0,0 +1,21 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'bnt/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "bnt"
8
+ spec.version = Bnt::VERSION
9
+ spec.authors = ["Gaston Ramos"]
10
+ spec.email = ["ramos.gaston@gmail.com"]
11
+ spec.description = %q{Bosh ninja tools}
12
+ spec.summary = %q{Bosh ninja tools to test bosh packages in fast way}
13
+ spec.homepage = ""
14
+ spec.license = "GPL"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ #spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ["lib"]
21
+ end
@@ -0,0 +1,36 @@
1
+ class Cage
2
+
3
+ def self.path
4
+ error_msg = <<-EOS "\n\nEmpty cage path please ensure that CAGE_PATH env var is available 'export CAGE_PATH=~/.bnt/cages/latest-bosh-stemcell/'"
5
+ EOS
6
+ raise error_msg if ENV['CAGE_PATH'].nil?
7
+ ENV['CAGE_PATH']
8
+ end
9
+
10
+ def self.packages_path
11
+ "/var/vcap/packages"
12
+ end
13
+
14
+ def self.package_path(pkg)
15
+ "#{path}#{packages_path}/#{pkg}"
16
+ end
17
+
18
+ def self.tmp_dir
19
+ "#{path}/tmp/bosh-release"
20
+ end
21
+ end
22
+
23
+ class Runner
24
+ def self.exec(args)
25
+ msg = ""
26
+ cmd = args
27
+
28
+ if args.is_a? Hash
29
+ cmd = args[:cmd]
30
+ msg = "* #{args[:msg]}"
31
+ end
32
+
33
+ puts "#{msg} ==> #{cmd}"
34
+ system cmd
35
+ end
36
+ end
@@ -0,0 +1,3 @@
1
+ module Bnt
2
+ VERSION = "0.0.2"
3
+ end
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bnt
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Gaston Ramos
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-12-12 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Bosh ninja tools
14
+ email:
15
+ - ramos.gaston@gmail.com
16
+ executables:
17
+ - bnt-create-bosh-dirs
18
+ - bnt-create-cage
19
+ - bnt-delete-cage
20
+ - bnt-make-package
21
+ - bnt-test-package
22
+ extensions: []
23
+ extra_rdoc_files: []
24
+ files:
25
+ - .gitignore
26
+ - README
27
+ - bin/bnt-create-bosh-dirs
28
+ - bin/bnt-create-cage
29
+ - bin/bnt-delete-cage
30
+ - bin/bnt-make-package
31
+ - bin/bnt-test-package
32
+ - bnt.gemspec
33
+ - lib/bnt/env.rb
34
+ - lib/bnt/version.rb
35
+ homepage: ''
36
+ licenses:
37
+ - GPL
38
+ metadata: {}
39
+ post_install_message:
40
+ rdoc_options: []
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ! '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ requirements: []
54
+ rubyforge_project:
55
+ rubygems_version: 2.1.5
56
+ signing_key:
57
+ specification_version: 4
58
+ summary: Bosh ninja tools to test bosh packages in fast way
59
+ test_files: []