class SyncWrap::Hashdot

Provision the Hashdot JVM/script launcher by building it with gcc on the target host.

Host component dependencies: <Distro>, <JDK>, JRubyVM

Constants

DEFAULT_VERSION

Default hashdot_version to install

DEFAULT_VERSION_HASH

SHA256 hash for DEFAULT_VERSION

Attributes

hash[W]

A cryptographic hash value (hexadecimal, some standard length) to use for verifying the 'hashdot-*-src.tar.gz' package.

hashdot_version[RW]

Hashdot version (default: DEFAULT_VERSION)

Public Class Methods

new( opts = {} ) click to toggle source
Calls superclass method SyncWrap::Component.new
# File lib/syncwrap/components/hashdot.rb, line 47
def initialize( opts = {} )
  @hashdot_version = DEFAULT_VERSION
  @hash = nil
  super
end

Public Instance Methods

hash() click to toggle source
# File lib/syncwrap/components/hashdot.rb, line 53
def hash
  @hash || ( hashdot_version == DEFAULT_VERSION && DEFAULT_VERSION_HASH )
end
hashdot_bin_url() click to toggle source
# File lib/syncwrap/components/hashdot.rb, line 57
def hashdot_bin_url
  [ 'http://downloads.sourceforge.net/project/hashdot/hashdot',
    hashdot_version,
    "hashdot-#{hashdot_version}-src.tar.gz" ].join( '/' )
end
install() click to toggle source

Install hashdot if the binary version doesn't match, otherwise just update the profile config files.

# File lib/syncwrap/components/hashdot.rb, line 65
def install
  if !test_hashdot_binary
    install_system_deps
    install_hashdot
    changes = [ :installed ]
  else
    # Just update config as needed.
    changes = rput( 'src/hashdot/profiles/',
                    "#{local_root}/lib/hashdot/profiles/",
                    excludes: :dev, user: :root )
  end
  unless changes.empty?
    state[ :hashdot_updated ] = changes
  end
  changes
end
install_hashdot() click to toggle source
# File lib/syncwrap/components/hashdot.rb, line 110
def install_hashdot
  src_root = '/tmp/src/hashdot'
  src = "#{src_root}/hashdot-#{hashdot_version}"
  sfile = "#{src_root}/hashdot-#{hashdot_version}-src.tar.gz"

  sh <<-SH
    sudo rm -rf /tmp/src
    mkdir -p #{src_root}
    curl -sSL -o #{sfile} #{hashdot_bin_url}
  SH

  hash_verify( hash, sfile ) if hash

  sh <<-SH
    tar -C #{src_root} -zxf #{sfile}
  SH

  rput( 'src/hashdot/', "#{src}/", :excludes => :dev )

  sh <<-SH
    cd #{src}
    make
    sudo make install
    rm -rf #{src_root}
  SH

end
install_system_deps() click to toggle source
# File lib/syncwrap/components/hashdot.rb, line 82
def install_system_deps
  deps = %w[ curl make gcc ]
  deps += case distro
          when Debian
            %w[ libapr1 libapr1-dev ]
          when RHEL
            %w[ apr apr-devel ]
          else
            %w[ apr ]
          end
  dist_install( *deps )
end
test_hashdot_binary() click to toggle source
# File lib/syncwrap/components/hashdot.rb, line 95
    def test_hashdot_binary
      binary = "#{local_root}/bin/hashdot"
      code,_ = capture( "        if [ -x #{binary} ]; then
          cver=`(#{binary} 2>&1 || true) | grep -o -E '([0-9]\.?){2,}'`
          if [ "$cver" = "#{hashdot_version}" ]; then
            exit 0
          fi
          exit 92
        fi
        exit 91
", accept: [0,91,92] )
      (code == 0)
    end