Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/stable'
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Smith committed Jun 19, 2015
2 parents 564b7ff + 8e52095 commit fcb6357
Show file tree
Hide file tree
Showing 9 changed files with 112 additions and 47 deletions.
11 changes: 10 additions & 1 deletion CMakeLists.txt
Expand Up @@ -13,6 +13,8 @@ endif()

option(YAMLCPP_STATIC "Use yaml-cpp's static libraries" OFF)

option(CURL_STATIC "Use curl's static libraries" OFF)

set(FACTER_PATH "" CACHE PATH "Specify the location to look for specific binaries before trying PATH.")
if (FACTER_PATH)
# Specify a preferred location for binary lookup that will be prioritized over PATH.
Expand Down Expand Up @@ -74,10 +76,17 @@ if ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux" AND NOT WITHOUT_BLKID)
find_package(BLKID)
endif()

if ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux" AND NOT WITHOUT_CURL)
if ((("${CMAKE_SYSTEM_NAME}" MATCHES "Linux") OR WIN32) AND NOT WITHOUT_CURL)
find_package(CURL)
if (CURL_FOUND)
add_definitions(-DUSE_CURL)
if (CURL_STATIC)
add_definitions(-DCURL_STATICLIB)
if (WIN32)
# Linking statically on Windows requires some extra libraries.
list(APPEND CURL_LIBRARIES wldap32.lib ws2_32.lib)
endif()
endif()
endif()
set_package_properties(CURL PROPERTIES DESCRIPTION "A free and easy-to-use client-side URL transfer library" URL "http://curl.haxx.se/libcurl/")
set_package_properties(CURL PROPERTIES TYPE OPTIONAL PURPOSE "Enables facts that require HTTP.")
Expand Down
27 changes: 19 additions & 8 deletions acceptance/tests/facts/debian.rb
Expand Up @@ -7,10 +7,23 @@
# Facts tested: os, processors, networking, identity, kernel
#

confine :to, :platform => /debian-squeeze|debian-wheezy/
confine :to, :platform => /debian-squeeze|debian-wheezy|debian-jessie/

agents.each do |agent|
os_version = agent['platform'] =~ /squeeze/ ? '6' : '7'
if agent['platform'] =~ /squeeze/
codename = 'squeeze'
os_version = '6'
os_kernel = '2.6'
elsif agent['platform'] =~ /wheezy/
codename = 'wheezy'
os_version = '7'
os_kernel = '3.2'
elsif agent['platform'] =~ /jessie/
codename = 'jessie'
os_version = '8'
os_kernel = '3.16'
end

if agent['platform'] =~ /x86_64/
os_arch = 'amd64'
os_hardware = 'x86_64'
Expand All @@ -22,7 +35,7 @@
step "Ensure the OS fact resolves as expected"
expected_os = {
'os.architecture' => os_arch,
'os.distro.codename' => os_version == '6' ? 'squeeze' : 'wheezy',
'os.distro.codename' => codename,
'os.distro.description' => /Debian GNU\/Linux #{os_version}\.\d/,
'os.distro.id' => 'Debian',
'os.distro.release.full' => /#{os_version}\.\d/,
Expand Down Expand Up @@ -83,13 +96,11 @@
end

step "Ensure the kernel fact resolves as expected"
kernel_version = os_version == '7' ? '3.2' : '2.6'

expected_kernel = {
'kernel' => 'Linux',
'kernelrelease' => kernel_version,
'kernelversion' => kernel_version,
'kernelmajversion' => kernel_version
'kernelrelease' => os_kernel,
'kernelversion' => os_kernel,
'kernelmajversion' => os_kernel
}

expected_kernel.each do |fact, value|
Expand Down
8 changes: 6 additions & 2 deletions acceptance/tests/facts/ubuntu.rb
Expand Up @@ -7,7 +7,7 @@
# Facts tested: os, processors, networking, identity, kernel
#

confine :to, :platform => /ubuntu-precise|ubuntu-trusty|ubuntu-utopic/
confine :to, :platform => /ubuntu-precise|ubuntu-trusty|ubuntu-utopic|ubuntu-vivid/

agents.each do |agent|
if agent['platform'] =~ /ubuntu-precise/
Expand All @@ -18,10 +18,14 @@
os_name = 'trusty'
os_version = '14.04'
os_kernel = '3.13'
else
elsif agent['platform'] =~ /ubuntu-utopic/
os_name = 'utopic'
os_version = '14.10'
os_kernel = '3.16'
elsif agent['platform'] =~ /ubuntu-vivid/
os_name = 'vivid'
os_version = '15.04'
os_kernel = '3.19'
end

if agent['platform'] =~ /x86_64/
Expand Down
21 changes: 21 additions & 0 deletions contrib/facter.ps1
Expand Up @@ -58,6 +58,9 @@ $boostPkg = "${boostVer}-${mingwVer}"
$yamlCppVer = "yaml-cpp-0.5.1"
$yamlPkg = "${yamlCppVer}-${mingwVer}"

$curlVer = "curl-7.42.1"
$curlPkg = "${curlVer}-${mingwVer}"

### Setup, build, and install
## Install Chocolatey, then use it to install required tools.
Function Install-Choco ($pkg, $ver, $opts = "") {
Expand Down Expand Up @@ -152,6 +155,18 @@ if ($buildSource) {
)
cmake $args
mingw32-make install -j $cores
cd $toolsDir

(New-Object net.webclient).DownloadFile("http://curl.haxx.se/download/${curlVer}.zip", "$toolsDir\${curlVer}.zip")
& 7za x "${curlVer}.zip" | FIND /V "ing "
cd $curlVer

mingw32-make mingw32
mkdir -Path $toolsDir\$curlPkg\include
cp -r include\curl $toolsDir\$curlPkg\include
mkdir -Path $toolsDir\$curlPkg\lib
cp lib\libcurl.a $toolsDir\$curlPkg\lib
cd $toolsDir
} else {
## Download and unpack Boost from a pre-built package in S3
(New-Object net.webclient).DownloadFile("https://s3.amazonaws.com/kylo-pl-bucket/${boostPkg}.7z", "$toolsDir\${boostPkg}.7z")
Expand All @@ -160,6 +175,10 @@ if ($buildSource) {
## Download and unpack yaml-cpp from a pre-built package in S3
(New-Object net.webclient).DownloadFile("https://s3.amazonaws.com/kylo-pl-bucket/${yamlPkg}.7z", "$toolsDir\${yamlPkg}.7z")
& 7za x "${yamlPkg}.7z" | FIND /V "ing "

## Download and unpack curl from a pre-built package in S3
(New-Object net.webclient).DownloadFile("https://s3.amazonaws.com/kylo-pl-bucket/${curlPkg}.7z", "$toolsDir\${curlPkg}.7z")
& 7za x "${curlPkg}.7z" | FIND /V "ing "
}

## Build Facter
Expand All @@ -170,6 +189,8 @@ $args = @(
"-DBOOST_ROOT=`"$toolsDir\$boostPkg`"",
"-DBOOST_STATIC=ON",
"-DYAMLCPP_ROOT=`"$toolsDir\$yamlPkg`"",
"-DCMAKE_PREFIX_PATH=`"$toolsDir\$curlPkg`"",
"-DCURL_STATIC=ON",
".."
)
cmake $args
Expand Down
42 changes: 8 additions & 34 deletions ext/build_defaults.yaml
Expand Up @@ -3,40 +3,14 @@ packaging_url: 'git@github.com:puppetlabs/packaging --branch=master'
packaging_repo: 'packaging'
deb_build_mirrors:
- deb http://pl-build-tools.delivery.puppetlabs.net/debian __DIST__ main
default_cow: 'base-wheezy-i386.cow'
# Which debian distributions to build for. Noarch packages only need one arch of each cow.
cows: 'base-precise-amd64.cow base-precise-i386.cow base-squeeze-amd64.cow base-squeeze-i386.cow base-trusty-amd64.cow base-trusty-i386.cow base-wheezy-amd64.cow base-wheezy-i386.cow'
# The pbuilder configuration file to use
pbuild_conf: '/etc/pbuilderrc'
# Who is packaging. Turns up in various packaging artifacts
packager: 'puppetlabs'
# Who is signing packages
gpg_name: 'info@puppetlabs.com'
# GPG key ID of the signer
gpg_key: '4BD6EC30'
# Whether to require tarball signing as a prerequisite of other package building
sign_tar: FALSE
# a space separated list of mock configs. These are the rpm distributions to package for. If a noarch package, only one arch of each is needed.
final_mocks: 'pl-el-5-x86_64 pl-el-5-i386 pl-el-6-x86_64 pl-el-6-i386 pl-el-7-x86_64 pl-fedora-20-i386 pl-fedora-20-x86_64 pl-fedora-21-i386 pl-fedora-21-x86_64'
# The host that contains the yum repository to ship to
yum_host: 'yum.puppetlabs.com'
# The remote path the repository on the yum\_host
yum_repo_path: '/opt/repository/yum/'
# The host that contains the apt repository to ship to
apt_host: 'apt.puppetlabs.com'
# The URL to use for the apt dependencies in cow building
apt_repo_url: 'http://apt.puppetlabs.com'
# The path on the remote apt host that debs should ship to
apt_repo_path: '/opt/repository/incoming'
# The host that stores the tarballs for downloading

# These are the build targets used by the packaging repo. Uncomment to allow use.
#final_mocks: 'pl-el-5-x86_64 pl-el-5-i386 pl-el-6-x86_64 pl-el-6-i386 pl-el-7-x86_64'
#default_cow: 'base-trusty-i386.cow'
#cows: 'base-precise-amd64.cow base-precise-i386.cow base-trusty-amd64.cow base-trusty-i386.cow base-wheezy-amd64.cow base-wheezy-i386.cow'
#pbuild_conf: '/etc/pbuilderrc'

tar_host: 'downloads.puppetlabs.com'
# Whether to present the gem and apple tasks
build_gem: FALSE
build_dmg: FALSE
# Whether to execute the rdoc rake tasks prior to composing the tarball
build_doc: FALSE
# Whether to present the Solaris 11 IPS packaging tasks
# This requires suitable IPS packaging artifacts in the project in ext/ips
build_ips: FALSE
# Whether this project is a PE project or not
build_pe: FALSE
sign_tar: FALSE
1 change: 1 addition & 0 deletions lib/CMakeLists.txt
Expand Up @@ -194,6 +194,7 @@ elseif ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
"src/facts/linux/disk_resolver.cc"
"src/facts/linux/dmi_resolver.cc"
"src/facts/linux/filesystem_resolver.cc"
"src/facts/linux/kernel_resolver.cc"
"src/facts/linux/memory_resolver.cc"
"src/facts/linux/networking_resolver.cc"
"src/facts/linux/operating_system_resolver.cc"
Expand Down
25 changes: 25 additions & 0 deletions lib/inc/internal/facts/linux/kernel_resolver.hpp
@@ -0,0 +1,25 @@
/**
* @file
* Declares the Linux kernel fact resolver.
*/
#pragma once

#include "../posix/kernel_resolver.hpp"

namespace facter { namespace facts { namespace linux {

/**
* Responsible for resolving kernel facts.
*/
struct kernel_resolver : posix::kernel_resolver
{
protected:
/**
* Parses the major and minor kernel versions.
* @param version The version to parse.
* @return Returns a tuple of major and minor versions.
*/
std::tuple<std::string, std::string> parse_version(std::string const& version) const override;
};

}}} // namespace facter::facts::linux
4 changes: 2 additions & 2 deletions lib/src/facts/linux/collection.cc
@@ -1,5 +1,5 @@
#include <facter/facts/collection.hpp>
#include <internal/facts/posix/kernel_resolver.hpp>
#include <internal/facts/linux/kernel_resolver.hpp>
#include <internal/facts/posix/identity_resolver.hpp>
#include <internal/facts/linux/operating_system_resolver.hpp>
#include <internal/facts/linux/networking_resolver.hpp>
Expand All @@ -21,7 +21,7 @@ namespace facter { namespace facts {

void collection::add_platform_facts()
{
add(make_shared<posix::kernel_resolver>());
add(make_shared<linux::kernel_resolver>());
add(make_shared<linux::operating_system_resolver>());
add(make_shared<linux::networking_resolver>());
add(make_shared<linux::disk_resolver>());
Expand Down
20 changes: 20 additions & 0 deletions lib/src/facts/linux/kernel_resolver.cc
@@ -0,0 +1,20 @@
#include <internal/facts/linux/kernel_resolver.hpp>
#include <internal/util/regex.hpp>
#include <boost/regex.hpp>
#include <tuple>

using namespace std;
using namespace facter::util;

namespace facter { namespace facts { namespace linux {

tuple<string, string> kernel_resolver::parse_version(string const& version) const
{
string major, minor;
if (re_search(version, boost::regex("(\\d+\\.\\d+)(.*)"), &major, &minor)) {
return make_tuple(major, minor);
}
return make_tuple(move(version), string());
}

}}} // namespace facter::facts::resolvers

0 comments on commit fcb6357

Please sign in to comment.