blob: bf37e8ab587091a93903bbe303e91ae80178ae9b [file] [log] [blame]
#
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
#
define hdp2::java::package(
$size,
$include_artifact_dir = true
)
{
include hdp2::params
$jdk_bin = $hdp2::params::jdk_bins[$size]
$artifact_dir = $hdp2::params::artifact_dir
$jdk_location = $hdp2::params::jdk_location
$jdk_curl_target = "${artifact_dir}/${jdk_bin}"
if ($size == "32") {
$java_home = $hdp2::params::java32_home
} else {
$java_home = $hdp2::params::java64_home
}
$java_exec = "${java_home}/bin/java"
$java_dir = regsubst($java_home,'/[^/]+$','')
if ($include_artifact_dir == true) {
hdp2::artifact_dir{ "java::package::${name}": }
}
$curl_cmd = "mkdir -p ${artifact_dir} ; curl -f --retry 10 ${jdk_location}/${jdk_bin} -o ${jdk_curl_target}"
exec{ "${curl_cmd} ${name}":
command => $curl_cmd,
creates => $jdk_curl_target,
path => ["/bin","/usr/bin/"],
unless => "test -e ${java_exec}"
}
$install_cmd = "mkdir -p ${java_dir} ; chmod +x ${jdk_curl_target}; cd ${java_dir} ; echo A | ${jdk_curl_target} -noregister > /dev/null 2>&1"
exec{ "${install_cmd} ${name}":
command => $install_cmd,
unless => "test -e ${java_exec}",
path => ["/bin","/usr/bin/"]
}
file { "${java_exec} ${name}":
ensure => present
}
anchor{"hdp2::java::package::${name}::begin":} -> Exec["${curl_cmd} ${name}"] -> Exec["${install_cmd} ${name}"] -> File["${java_exec} ${name}"] -> anchor{"hdp2::java::package::${name}::end":}
if ($include_artifact_dir == true) {
Anchor["hdp2::java::package::${name}::begin"] -> Hdp2::Artifact_dir["java::package::${name}"] -> Exec["${curl_cmd} ${name}"]
}
}