Gentoo Archives: gentoo-commits

From: "Andreas Hüttel" <dilfridge@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-libs/libhugetlbfs/
Date: Sat, 12 Dec 2015 12:45:03
Message-Id: 1449924285.217aee29fde28b255463e46db02e03bfc3fea186.dilfridge@gentoo
1 commit: 217aee29fde28b255463e46db02e03bfc3fea186
2 Author: Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org>
3 AuthorDate: Sat Dec 12 12:44:28 2015 +0000
4 Commit: Andreas Hüttel <dilfridge <AT> gentoo <DOT> org>
5 CommitDate: Sat Dec 12 12:44:45 2015 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=217aee29
7
8 sys-libs/libhugetlbfs: Fix perl module installation paths and perl dependency, see bug 554688 comment 7. Needs EAPI=5 bump.
9
10 Package-Manager: portage-2.2.26
11
12 sys-libs/libhugetlbfs/libhugetlbfs-2.19-r1.ebuild | 153 ++++++++++++++++++++++
13 1 file changed, 153 insertions(+)
14
15 diff --git a/sys-libs/libhugetlbfs/libhugetlbfs-2.19-r1.ebuild b/sys-libs/libhugetlbfs/libhugetlbfs-2.19-r1.ebuild
16 new file mode 100644
17 index 0000000..f6644a5
18 --- /dev/null
19 +++ b/sys-libs/libhugetlbfs/libhugetlbfs-2.19-r1.ebuild
20 @@ -0,0 +1,153 @@
21 +# Copyright 1999-2015 Gentoo Foundation
22 +# Distributed under the terms of the GNU General Public License v2
23 +# $Id$
24 +
25 +EAPI=5
26 +
27 +inherit eutils multilib toolchain-funcs perl-functions
28 +
29 +DESCRIPTION="easy hugepage access"
30 +HOMEPAGE="https://github.com/libhugetlbfs/libhugetlbfs"
31 +SRC_URI="mirror://sourceforge/${PN}/${P}.tar.gz"
32 +# Switch to github tarball w/next release.
33 +#SRC_URI="https://github.com/libhugetlbfs/libhugetlbfs/archive/${PV}.tar.gz -> ${P}.tar.gz"
34 +
35 +LICENSE="GPL-2"
36 +SLOT="0"
37 +KEYWORDS="~amd64 ~ppc64 ~x86"
38 +IUSE="static-libs"
39 +RDEPEND="dev-lang/perl:="
40 +
41 +src_prepare() {
42 + perl_set_version
43 +
44 + epatch "${FILESDIR}"/${PN}-2.9-build.patch #332517
45 + epatch "${FILESDIR}"/${PN}-2.6-noexec-stack.patch
46 + epatch "${FILESDIR}"/${PN}-2.6-fixup-testsuite.patch
47 + sed -i \
48 + -e '/^PREFIX/s:/local::' \
49 + -e '1iBUILDTYPE = NATIVEONLY' \
50 + -e '1iV = 1' \
51 + -e "/^LIB\(32\)/s:=.*:= $(get_libdir):" \
52 + -e '/^CC\(32\|64\)/s:=.*:= $(CC):' \
53 + -e "/^PMDIR = .*\/perl5\/TLBC/s::PMDIR = ${VENDOR_LIB}\/TLBC:" \
54 + Makefile || die "sed failed"
55 + if [ "$(get_libdir)" == "lib64" ]; then
56 + sed -i \
57 + -e "/^LIB\(32\)/s:=.*:= lib32:" \
58 + Makefile
59 + fi
60 +}
61 +
62 +src_compile() {
63 + tc-export AR
64 + emake CC="$(tc-getCC)" libs tools
65 +}
66 +
67 +src_install() {
68 + default
69 + use static-libs || rm -f "${D}"/usr/$(get_libdir)/*.a
70 + rm "${D}"/usr/bin/oprofile* || die
71 +}
72 +
73 +src_test_alloc_one() {
74 + hugeadm="$1"
75 + sign="$2"
76 + pagesize="$3"
77 + pagecount="$4"
78 + ${hugeadm} \
79 + --pool-pages-max ${pagesize}:${sign}${pagecount} \
80 + && \
81 + ${hugeadm} \
82 + --pool-pages-min ${pagesize}:${sign}${pagecount}
83 + return $?
84 +}
85 +
86 +# die is NOT allowed in this src_test block after the marked point, so that we
87 +# can clean up memory allocation. You'll leak at LEAST 64MiB per run otherwise.
88 +src_test() {
89 + [[ $UID -eq 0 ]] || die "Need FEATURES=-userpriv to run this testsuite"
90 + einfo "Building testsuite"
91 + emake -j1 tests || die "Failed to build tests"
92 +
93 + hugeadm='obj/hugeadm'
94 + allocated=''
95 + rc=0
96 + # the testcases need 64MiB per pagesize.
97 + MIN_HUGEPAGE_RAM=$((64*1024*1024))
98 +
99 + einfo "Planning allocation"
100 + PAGESIZES="$(${hugeadm} --page-sizes-all)"
101 +
102 + # Need to do this before we can create the mountpoints.
103 + for pagesize in ${PAGESIZES} ; do
104 + # The kernel depends on the location :-(
105 + mkdir -p /var/lib/hugetlbfs/pagesize-${pagesize}
106 + addwrite /var/lib/hugetlbfs/pagesize-${pagesize}
107 + done
108 + addwrite /proc/sys/vm/
109 + addwrite /proc/sys/kernel/shmall
110 + addwrite /proc/sys/kernel/shmmax
111 + addwrite /proc/sys/kernel/shmmni
112 +
113 + einfo "Checking HugeTLB mountpoints"
114 + ${hugeadm} --create-mounts || die "Failed to set up hugetlb mountpoints."
115 +
116 + # -----------------------------------------------------
117 + # --------- die is unsafe after this point. -----------
118 + # -----------------------------------------------------
119 +
120 + einfo "Starting allocation"
121 + for pagesize in ${PAGESIZES} ; do
122 + pagecount=$((${MIN_HUGEPAGE_RAM}/${pagesize}))
123 + einfo " ${pagecount} @ ${pagesize}"
124 + addwrite /var/lib/hugetlbfs/pagesize-${pagesize}
125 + src_test_alloc_one "$hugeadm" "+" "${pagesize}" "${pagecount}"
126 + rc=$?
127 + if [[ $rc -eq 0 ]]; then
128 + allocated="${allocated} ${pagesize}:${pagecount}"
129 + else
130 + eerror "Failed to add ${pagecount} pages of size ${pagesize}"
131 + fi
132 + done
133 +
134 + einfo "Allocation status"
135 + ${hugeadm} --pool-list
136 +
137 + if [[ -n "${allocated}" ]]; then
138 + # All our allocations worked, so time to run.
139 + einfo "Starting tests"
140 + cd "${S}"/tests
141 + TESTOPTS="-t func"
142 + case $ARCH in
143 + amd64|ppc64)
144 + TESTOPTS="${TESTOPTS} -b 64"
145 + ;;
146 + x86)
147 + TESTOPTS="${TESTOPTS} -b 32"
148 + ;;
149 + esac
150 + # This needs a bit of work to give a nice exit code still.
151 + ./run_tests.py ${TESTOPTS}
152 + rc=$?
153 + else
154 + eerror "Failed to make HugeTLB allocations."
155 + rc=1
156 + fi
157 +
158 + einfo "Cleaning up memory"
159 + cd "${S}"
160 + # Cleanup memory allocation
161 + for alloc in ${allocated} ; do
162 + pagesize="${alloc/:*}"
163 + pagecount="${alloc/*:}"
164 + einfo " ${pagecount} @ ${pagesize}"
165 + src_test_alloc_one "$hugeadm" "-" "${pagesize}" "${pagecount}"
166 + done
167 +
168 + # ---------------------------------------------------------
169 + # --------- die is safe again after this point. -----------
170 + # ---------------------------------------------------------
171 +
172 + return $rc
173 +}