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

dev-ruby/facter: ebuild cleanup #9339

Closed
wants to merge 1 commit into from
Closed
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
Expand Up @@ -17,18 +17,16 @@ if [[ ${PV} == 9999 ]] ; then
inherit git-r3
EGIT_REPO_URI="https://github.com/puppetlabs/facter.git"
EGIT_BRANCH="master"
S="${S}/${P}"
else
[[ "${PV}" = *_rc* ]] || \
KEYWORDS="~amd64 ~arm ~hppa ~ppc ~ppc64 ~sparc ~x86"
SRC_URI="https://github.com/puppetlabs/${PN}/archive/${PV}.tar.gz -> ${P}.tar.gz"
S="${S}/all/${P}"
fi

BDEPEND="
>=sys-devel/gcc-4.8:*
dev-cpp/cpp-hocon"
CDEPEND="
COMMON_DEPEND="
>=dev-libs/leatherman-1.0.0:=
dev-libs/openssl:*
sys-apps/util-linux
Expand All @@ -40,23 +38,29 @@ CDEPEND="

ruby_add_bdepend "test? ( dev-ruby/rake dev-ruby/rspec:2 dev-ruby/mocha:0.14 )"

RDEPEND="${CDEPEND}"
RDEPEND="${COMMON_DEPEND}"
DEPEND="${BDEPEND}
${CDEPEND}"
${COMMON_DEPEND}"

# restore ${S} and override all phases exported by ruby-ng.eclass
S="${WORKDIR}/${P}"

pkg_setup() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ruby isn't actually needed for this package to work, so no need to run it's pkg_setup

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This package already depends on ruby via ruby-ng.eclass (RUBY_OPTIONAL != yes). It can be made optional, but this should be done via use flag. Otherwise we can't properly install facter.rb for all ruby targets.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ya, should probably be made optional then

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't expect me to do that in this PR as it probably require changes in reverse deps (app-admin/puppet). :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, but you can do multiple commits in a PR, but that's up to you :P

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, build system does not allow to disable ruby support. So this needs either additional hacks in the ebuild or patches for build system.

ruby-ng_pkg_setup
}

src_unpack() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't this section the default already?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to avoid ruby-ng_src_unpack()

default

if [[ ${PV} == 9999 ]] ; then
git-r3_src_unpack
fi
}

src_prepare() {
# Remove the code that installs facter.rb to the wrong directory.
sed -i '/install(.*facter\.rb/d' lib/CMakeLists.txt || die
sed -i '/install(.*facter\.jar/d' lib/CMakeLists.txt || die
# make it support multilib
sed -i "s/\ lib)/\ $(get_libdir))/g" lib/CMakeLists.txt || die
sed -i "s/lib\")/$(get_libdir)\")/g" CMakeLists.txt || die
# make the require work
sed -i 's/\${LIBFACTER_INSTALL_DESTINATION}\///g' lib/facter.rb.in || die
# be explicit about the version of rspec we test with and use the
# correct lib directory for tests
# be explicit about the version of rspec we test with
sed -i -e '/libfacter.*specs/ s/rspec/rspec-2/' \
-e '/libfacter.*specs/ s/lib64/lib/' CMakeLists.txt || die
CMakeLists.txt || die
# be more lenient for software versions for tests
sed -i -e '/rake/ s/~> 10.1.0/>= 10/' \
-e '/rspec/ s/2.11.0/2.11/' \
Expand All @@ -66,12 +70,18 @@ src_prepare() {
cmake-utils_src_prepare
}

each_ruby_configure() {
# hack for correct calculation of relative path from facter.rb to
# libfacter.so
my_ruby_sitelibdir=$(ruby_rbconfig_value 'sitelibdir')
}

src_configure() {
ruby-ng_src_configure

local mycmakeargs=(
-DCMAKE_VERBOSE_MAKEFILE=ON
-DCMAKE_BUILD_TYPE=None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why'd you get rid of the build type? and install prefix? and blkid location?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CMAKE_BUILD_TYPE and CMAKE_INSTALL_PREFIX are passed by cmake-utils.eclass. Do we really need to override them? BLKID_LIBRARY is not used by build system for a long time:
puppetlabs/facter@364b947#diff-dd2044c7974dda8071b268f0652e866e

-DCMAKE_INSTALL_PREFIX=/usr
-DBLKID_LIBRARY=/$(get_libdir)/libblkid.so.1
-DRUBY_LIB_INSTALL=${my_ruby_sitelibdir}
)
if use debug; then
mycmakeargs+=(
Expand All @@ -85,21 +95,15 @@ src_compile() {
cmake-utils_src_compile
}

each_ruby_install() {
doruby "${BUILD_DIR}"/lib/facter.rb
}

src_test() {
cmake-utils_src_test
}

each_ruby_install() {
doruby "${BUILD_DIR}"/lib/facter.rb
}

src_install() {
cmake-utils_src_install
ruby-ng_src_install

# need a variable file in env.d :(
diropts -m0755
dodir /etc/env.d
echo -n "FACTERDIR=/usr/$(get_libdir)" > "${D}/etc/env.d/00facterdir"
fperms 0644 /etc/env.d/00facterdir
}
64 changes: 34 additions & 30 deletions dev-ruby/facter/facter-9999.ebuild
Expand Up @@ -2,7 +2,7 @@
# Distributed under the terms of the GNU General Public License v2

EAPI=6
USE_RUBY="ruby21 ruby22 ruby23 ruby24"
USE_RUBY="ruby23 ruby24 ruby25"

# git-r3 goes after ruby-ng so that it overrides src_unpack properly
inherit cmake-utils eutils multilib ruby-ng
Expand All @@ -17,18 +17,16 @@ if [[ ${PV} == 9999 ]] ; then
inherit git-r3
EGIT_REPO_URI="https://github.com/puppetlabs/facter.git"
EGIT_BRANCH="master"
S="${S}/${P}"
else
[[ "${PV}" = *_rc* ]] || \
KEYWORDS="~amd64 ~arm ~hppa ~ppc ~ppc64 ~sparc ~x86"
SRC_URI="https://github.com/puppetlabs/${PN}/archive/${PV}.tar.gz -> ${P}.tar.gz"
S="${S}/all/${P}"
fi

BDEPEND="
>=sys-devel/gcc-4.8:*
dev-cpp/cpp-hocon"
CDEPEND="
COMMON_DEPEND="
>=dev-libs/leatherman-1.0.0:=
dev-libs/openssl:*
sys-apps/util-linux
Expand All @@ -40,23 +38,29 @@ CDEPEND="

ruby_add_bdepend "test? ( dev-ruby/rake dev-ruby/rspec:2 dev-ruby/mocha:0.14 )"

RDEPEND="${CDEPEND}"
RDEPEND="${COMMON_DEPEND}"
DEPEND="${BDEPEND}
${CDEPEND}"
${COMMON_DEPEND}"

# restore ${S} and override all phases exported by ruby-ng.eclass
S="${WORKDIR}/${P}"

pkg_setup() {
ruby-ng_pkg_setup
}

src_unpack() {
default

if [[ ${PV} == 9999 ]] ; then
git-r3_src_unpack
fi
}

src_prepare() {
# Remove the code that installs facter.rb to the wrong directory.
sed -i '/install(.*facter\.rb/d' lib/CMakeLists.txt || die
sed -i '/install(.*facter\.jar/d' lib/CMakeLists.txt || die
# make it support multilib
sed -i "s/\ lib)/\ $(get_libdir))/g" lib/CMakeLists.txt || die
sed -i "s/lib\")/$(get_libdir)\")/g" CMakeLists.txt || die
# make the require work
sed -i 's/\${LIBFACTER_INSTALL_DESTINATION}\///g' lib/facter.rb.in || die
# be explicit about the version of rspec we test with and use the
# correct lib directory for tests
# be explicit about the version of rspec we test with
sed -i -e '/libfacter.*specs/ s/rspec/rspec-2/' \
-e '/libfacter.*specs/ s/lib64/lib/' CMakeLists.txt || die
CMakeLists.txt || die
# be more lenient for software versions for tests
sed -i -e '/rake/ s/~> 10.1.0/>= 10/' \
-e '/rspec/ s/2.11.0/2.11/' \
Expand All @@ -66,12 +70,18 @@ src_prepare() {
cmake-utils_src_prepare
}

each_ruby_configure() {
# hack for correct calculation of relative path from facter.rb to
# libfacter.so
my_ruby_sitelibdir=$(ruby_rbconfig_value 'sitelibdir')
}

src_configure() {
ruby-ng_src_configure

local mycmakeargs=(
-DCMAKE_VERBOSE_MAKEFILE=ON
-DCMAKE_BUILD_TYPE=None
-DCMAKE_INSTALL_PREFIX=/usr
-DBLKID_LIBRARY=/$(get_libdir)/libblkid.so.1
-DRUBY_LIB_INSTALL=${my_ruby_sitelibdir}
)
if use debug; then
mycmakeargs+=(
Expand All @@ -85,21 +95,15 @@ src_compile() {
cmake-utils_src_compile
}

each_ruby_install() {
doruby "${BUILD_DIR}"/lib/facter.rb
}

src_test() {
cmake-utils_src_test
}

each_ruby_install() {
doruby "${BUILD_DIR}"/lib/facter.rb
}

src_install() {
cmake-utils_src_install
ruby-ng_src_install

# need a variable file in env.d :(
diropts -m0755
dodir /etc/env.d
echo -n "FACTERDIR=/usr/$(get_libdir)" > "${D}/etc/env.d/00facterdir"
fperms 0644 /etc/env.d/00facterdir
}