Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix library and configuration paths (linux) #100

Merged
merged 1 commit into from Feb 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions substrate/hiera/common.yaml
@@ -1,3 +1,4 @@
---
installation_dir: "/opt/vagrant"
vagrant_substrate::build_dir: "/vagrant-substrate"
vagrant_substrate::installer_version: "2"
1 change: 1 addition & 0 deletions substrate/hiera/windows.yaml
@@ -1,2 +1,3 @@
---
installation_dir: "C:\\HashiCorp\\Vagrant"
vagrant_substrate::build_dir: "C:\\vagrant-substrate"
13 changes: 13 additions & 0 deletions substrate/modules/bsdtar/manifests/posix.pp
Expand Up @@ -113,4 +113,17 @@
subscribe => Autotools["libarchive"],
}
}

if $kernel == 'Linux' {
$libarchive_paths = [
"${install_dir}/lib/libarchive.so",
"${install_dir}/bin/bsdtar",
"${install_dir}/bin/bsdcpio",
]

vagrant_substrate::staging::linux_chrpath{ $libarchive_paths:
require => Autotools["libarchive"],
subscribe => Autotools["libarchive"],
}
}
}
14 changes: 8 additions & 6 deletions substrate/modules/curl/manifests/posix.pp
Expand Up @@ -23,7 +23,6 @@
}
} else {
$extra_autotools_environment = {
"LD_RUN_PATH" => "${install_dir}/lib",
}
}

Expand Down Expand Up @@ -88,11 +87,14 @@

if $kernel == 'Linux' {
# We need to clean up the rpaths...
exec { "curl-rpath":
command => "chrpath -r '\${ORIGIN}/../lib' ${install_dir}/bin/curl",
refreshonly => true,
require => Autotools["curl"],
subscribe => Autotools["curl"],
$libcurl_paths = [
"${install_dir}/bin/curl",
"${install_dir}/lib/libcurl.so",
]

vagrant_substrate::staging::linux_chrpath{ $libcurl_paths:
require => Autotools["curl"],
subscribe => Autotools["curl"],
}
}
}
11 changes: 11 additions & 0 deletions substrate/modules/libffi/manifests/init.pp
Expand Up @@ -92,4 +92,15 @@
subscribe => Autotools["libffi"],
}
}

if $kernel == 'Linux' {
$libffi_paths = [
"${prefix}/lib/libffi.so",
]

vagrant_substrate::staging::linux_chrpath{ $libffi_paths:
require => Autotools["libffi"],
subscribe => Autotools["libffi"],
}
}
}
13 changes: 13 additions & 0 deletions substrate/modules/libiconv/manifests/init.pp
Expand Up @@ -93,4 +93,17 @@
subscribe => Autotools["libiconv"],
}
}

if $kernel == 'Linux' {
$libiconv_paths = [
"${prefix}/bin/iconv",
"${prefix}/lib/libiconv.so",
"${prefix}/lib/libcharset.so",
]

vagrant_substrate::staging::linux_chrpath{ $libiconv_paths:
require => Autotools["libiconv"],
subscribe => Autotools["libiconv"],
}
}
}
11 changes: 11 additions & 0 deletions substrate/modules/libssh2/manifests/init.pp
Expand Up @@ -76,4 +76,15 @@
subscribe => Autotools["libssh2"],
}
}

if $kernel == 'Linux' {
$libssh2_paths = [
"${prefix}/lib/libssh2.so",
]

vagrant_substrate::staging::linux_chrpath{ $libssh2_paths:
require => Autotools["libssh2"],
subscribe => Autotools["libssh2"],
}
}
}
15 changes: 14 additions & 1 deletion substrate/modules/libxml2/manifests/init.pp
Expand Up @@ -49,7 +49,7 @@
}

autotools { "libxml2":
configure_flags => "--prefix=${prefix} --disable-dependency-tracking --without-python --without-lzma",
configure_flags => "--prefix=${prefix} --disable-dependency-tracking --without-python --without-lzma --with-zlib=${prefix}",
cwd => $source_dir_path,
environment => $real_autotools_environment,
install_sentinel => "${prefix}/lib/libxml2.a",
Expand All @@ -75,4 +75,17 @@
subscribe => Autotools["libxml2"],
}
}

if $kernel == 'Linux' {
$libxml2_paths = [
"${prefix}/lib/libxml2.so",
"${prefix}/bin/xmlcatalog",
"${prefix}/bin/xmllint",
]

vagrant_substrate::staging::linux_chrpath{ $libxml2_paths:
require => Autotools["libxml2"],
subscribe => Autotools["libxml2"],
}
}
}
12 changes: 12 additions & 0 deletions substrate/modules/libxslt/manifests/init.pp
Expand Up @@ -74,4 +74,16 @@
subscribe => Autotools["libxslt"],
}
}

if $kernel == 'Linux' {
$libxslt_paths = [
"${prefix}/bin/xsltproc",
"${prefix}/lib/libxslt.so",
]

vagrant_substrate::staging::linux_chrpath{ $libxslt_paths:
require => Autotools["libxslt"],
subscribe => Autotools["libxslt"],
}
}
}
11 changes: 11 additions & 0 deletions substrate/modules/libyaml/manifests/init.pp
Expand Up @@ -73,4 +73,15 @@
subscribe => Autotools["libyaml"],
}
}

if $kernel == 'Linux' {
$libyaml_paths = [
"${prefix}/lib/libyaml.so",
]

vagrant_substrate::staging::linux_chrpath{ $libyaml_paths:
require => Autotools["libyaml"],
subscribe => Autotools["libyaml"],
}
}
}
21 changes: 20 additions & 1 deletion substrate/modules/openssl/manifests/install/linux.pp
Expand Up @@ -7,10 +7,13 @@
$make_notify = $openssl::make_notify
$prefix = $openssl::prefix
$source_dir_path = $openssl::source_dir_path
$installation_dir = hiera("installation_dir")

$lib_version = "1"

autotools { "openssl":
configure_file => "config",
configure_flags => "--prefix=${prefix} shared",
configure_flags => "--prefix=${prefix} --openssldir=${installation_dir}/embedded shared",
configure_sentinel => "${source_dir_path}/apps/CA.pl.bak",
cwd => $source_dir_path,
environment => $autotools_environment,
Expand All @@ -19,4 +22,20 @@
make_sentinel => "${source_dir_path}/libssl.a",
require => Exec["untar-openssl"],
}

$libopenssl_paths = [
"${prefix}/lib/libssl.so",
"${prefix}/lib/libcrypto.so",
]

vagrant_substrate::staging::linux_chrpath{ $libopenssl_paths:
require => Autotools["openssl"],
subscribe => Autotools["openssl"],
}

vagrant_substrate::staging::linux_chrpath{ "${prefix}/bin/openssl":
new_rpath => '$ORIGIN/../lib',
require => Autotools["openssl"],
subscribe => Autotools["openssl"],
}
}
11 changes: 11 additions & 0 deletions substrate/modules/readline/manifests/init.pp
Expand Up @@ -83,4 +83,15 @@
subscribe => Autotools["readline"],
}
}

if $kernel == 'Linux' {
$libreadline_paths = [
"${prefix}/lib/libreadline.so",
]

vagrant_substrate::staging::linux_chrpath{ $libreadline_paths:
require => Autotools["readline"],
subscribe => Autotools["readline"],
}
}
}
31 changes: 31 additions & 0 deletions substrate/modules/ruby/manifests/source.pp
Expand Up @@ -15,6 +15,7 @@
$source_file_path = "${file_cache_dir}/${source_filename}"
$source_dir_name = regsubst($source_filename, '^(.+?)\.tar\.gz$', '\1')
$source_dir_path = "${file_cache_dir}/${source_dir_name}"
$installation_dir = hiera("installation_dir")

$lib_short_version = "2.2"
$lib_long_version = "2.2.0"
Expand Down Expand Up @@ -134,4 +135,34 @@
subscribe => Autotools["ruby"],
}
}

if $kernel == 'Linux' {

vagrant_substrate::staging::linux_chrpath{ "${prefix}/bin/ruby":
require => Autotools["ruby"],
subscribe => Autotools["ruby"],
}

vagrant_substrate::staging::linux_chrpath{ "${prefix}/lib/libruby.so":
new_rpath => '$ORIGIN/../lib',
require => Autotools["ruby"],
subscribe => Autotools["ruby"],
}

exec { "delete-mkmf-logs":
command => "find ${prefix}/lib -type f -name '*mkmf.log' -exec rm {} \\;",
subscribe => Autotools["ruby"],
refreshonly => true,
}

$embedded_include = '/vagrant-substrate/cache/ruby-2.2.5/include'
$replacement_include = "${installation_dir}/embedded/include/ruby-2.2.0"
exec { "adjust-ruby-include":
command => "grep -l -I -R '${embedded_include}' '${prefix}' | xargs sed -i 's@${embedded_include}@${replacement_include}@g'",
subscribe => Autotools["ruby"],
refreshonly => true,
onlyif => "grep -l -I -R '${embedded_include}' '${prefix}'",
}

}
}
Expand Up @@ -2,6 +2,7 @@
include vagrant_substrate

$embedded_dir = $vagrant_substrate::embedded_dir
$installation_dir = hiera("installation_dir")

exec { "clear-openssl-man":
command => "rm -rf ${embedded_dir}/ssl/man",
Expand All @@ -24,4 +25,33 @@
exec { "remove-la-files":
command => "rm -rf ${embedded_dir}/lib/*.la",
}

$new_rpath = "\$ORIGIN/../lib:${installation_dir}/embedded/lib"
exec { "replace-so-rpaths":
command => "find ${embedded_dir}/{lib64,lib/*}/ -name '*.so' -exec chrpath --replace '${new_rpath}' {} \\;",
onlyif => "ls ${embedded_dir}/lib64",
}

exec { "replace-so-rpaths-constrained":
command => "find ${embedded_dir}/lib/*/ -name '*.so' -exec chrpath --replace '${new_rpath}' {} \\;",
unless => "ls ${embedded_dir}/lib64",
}

exec { "convert-so-runpaths":
command => "find ${embedded_dir}/{lib64,lib/*}/ -name '*.so' -exec chrpath --convert {} \\;",
subscribe => Exec["replace-so-rpaths"],
refreshonly => true,
}

exec { "convert-so-runpaths-constrained":
command => "find ${embedded_dir}/lib/*/ -name '*.so' -exec chrpath --convert {} \\;",
subscribe => Exec["replace-so-rpaths-constrained"],
refreshonly => true
}

$destination_dir = "${installation_dir}/embedded"
exec { "scrub-substrate-paths":
command => "grep -l -I -R '${embedded_dir}' '${embedded_dir}' | xargs sed -i 's@${embedded_dir}@${destination_dir}@g'",
onlyif => "grep -l -I -R '${embedded_dir}' '${embedded_dir}'",
}
}
@@ -0,0 +1,21 @@
# == Define: vagrant_substrate::staging::linux_chrpath
#
# A helper to set proper RUN_PATH information on Linux
#
define vagrant_substrate::staging::linux_chrpath(
$new_rpath='$ORIGIN/../lib:/opt/vagrant/embedded/lib',
$target_file_path=$name,
) {

exec { "set-${name}-rpath":
command => "chrpath --replace '${new_rpath}' '${target_file_path}'",
onlyif => "chrpath --list '${target_file_path}' | grep RPATH",
}

exec { "convert-${name}-runpath":
command => "chrpath --convert '${target_file_path}'",
onlyif => "chrpath '${target_file_path}' | grep RPATH",
subscribe => Exec["set-${name}-rpath"],
}

}
25 changes: 9 additions & 16 deletions substrate/modules/vagrant_substrate/manifests/staging/posix.pp
Expand Up @@ -9,23 +9,17 @@
#------------------------------------------------------------------
# Calculate variables based on operating system
#------------------------------------------------------------------
$extra_autotools_ldflags = $operatingsystem ? {
'Darwin' => "",
default => '',
$extra_autotools_ldflags = $kernel ? {
"Darwin" => "",
"Linux" => "-Wl,-rpath=XORIGIN/../lib:${embedded_dir}/lib",
default => "",
}

$default_autotools_environment = {
"CFLAGS" =>
"-I${embedded_dir}/include",
"LDFLAGS" =>
"-L${embedded_dir}/lib ${extra_autotools_ldflags}",
"MACOSX_DEPLOYMENT_TARGET" => "10.5",
}

$default_curl_autotools_environment = {
"CPPFLAGS" => "-I${embedded_dir}/include",
"LDFLAGS" => "-L${embedded_dir}/lib ${extra_autotools_ldflags}",
"CFLAGS" => "-I${embedded_dir}/include",
"LDFLAGS" => "-L${embedded_dir}/lib ${extra_autotools_ldflags}",
"MACOSX_DEPLOYMENT_TARGET" => "10.5",
"LD_RPATH" => "${embedded_dir}/lib:XORIGIN/../lib",
}

if $operatingsystem == 'Darwin' {
Expand Down Expand Up @@ -78,11 +72,9 @@
}
} elsif $kernel == 'Linux' {
$bsdtar_autotools_environment = {
"LD_RUN_PATH" => '$ORIGIN/../lib',
}

$ruby_autotools_environment = {
"LD_RUN_PATH" => '\$ORIGIN/../lib',
}
}

Expand Down Expand Up @@ -187,10 +179,11 @@

class { "curl":
autotools_environment => autotools_merge_environments(
$default_curl_autotools_environment, $curl_autotools_environment),
$default_autotools_environment, $curl_autotools_environment),
file_cache_dir => $cache_dir,
install_dir => $embedded_dir,
require => [
Class["libssh2"],
Class["openssl"],
Class["zlib"],
],
Expand Down
11 changes: 11 additions & 0 deletions substrate/modules/xz/manifests/init.pp
Expand Up @@ -73,4 +73,15 @@
subscribe => Autotools["xz"],
}
}

if $kernel == 'Linux' {
$libxz_paths = [
"${prefix}/lib/liblzma.so",
]

vagrant_substrate::staging::linux_chrpath{ $libxz_paths:
require => Autotools["xz"],
subscribe => Autotools["xz"],
}
}
}