Remove myself from maintainers
[gentoo.git] / sys-apps / linux-misc-apps / linux-misc-apps-5.6.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=5
5
6 inherit versionator eutils toolchain-funcs linux-info autotools flag-o-matic
7
8 DESCRIPTION="Misc tools bundled with kernel sources"
9 HOMEPAGE="https://kernel.org/"
10
11 LICENSE="GPL-2"
12 SLOT="0"
13 KEYWORDS="~amd64 ~ppc ~x86"
14 IUSE="static-libs tcpd usbip"
15
16 MY_PV="${PV/_/-}"
17 MY_PV="${MY_PV/-pre/-git}"
18
19 LINUX_V=$(get_version_component_range 1-2)
20
21 if [ ${PV/_rc} != ${PV} ]; then
22         LINUX_VER=$(get_version_component_range 1-2).$(($(get_version_component_range 3)-1))
23         PATCH_VERSION=$(get_version_component_range 1-3)
24         LINUX_PATCH=patch-${PV//_/-}.xz
25         SRC_URI="https://www.kernel.org/pub/linux/kernel/v3.x/testing/${LINUX_PATCH}
26                 https://www.kernel.org/pub/linux/kernel/v3.x/testing/v${PATCH_VERSION}/${LINUX_PATCH}"
27 elif [ $(get_version_component_count) == 4 ]; then
28         # stable-release series
29         LINUX_VER=$(get_version_component_range 1-3)
30         LINUX_PATCH=patch-${PV}.xz
31         SRC_URI="https://www.kernel.org/pub/linux/kernel/v3.x/${LINUX_PATCH}"
32 else
33         LINUX_VER=${PV}
34 fi
35
36 LINUX_SOURCES=linux-${LINUX_VER}.tar.xz
37 SRC_URI="${SRC_URI} https://www.kernel.org/pub/linux/kernel/v3.x/${LINUX_SOURCES}"
38
39 # pmtools also provides turbostat
40 # usbip available in seperate package now
41 RDEPEND="sys-apps/hwids
42                 >=dev-libs/glib-2.6
43                 >=sys-kernel/linux-headers-$(get_version_component_range 1-2)
44                 usbip? (
45                         !net-misc/usbip
46                         tcpd? ( sys-apps/tcp-wrappers )
47                         virtual/libudev
48                 )
49                 !sys-power/pmtools"
50 DEPEND="${RDEPEND}
51                 virtual/pkgconfig"
52
53 S="${WORKDIR}/linux-${LINUX_VER}"
54
55 # All of these are integrated with the kernel build system,
56 # No make install, and ideally build with with the root Makefile
57 TARGETS_SIMPLE=(
58         samples/watchdog/watchdog-simple.c
59         tools/accounting/getdelays.c
60         tools/cgroup/cgroup_event_listener.c
61         tools/laptop/freefall/freefall.c
62         tools/testing/selftests/networking/timestamping/timestamping.c
63         tools/vm/slabinfo.c
64         usr/gen_init_cpio.c
65         # Broken:
66         #tools/lguest/lguest.c # fails to compile
67         #tools/vm/page-types.c # page-types.c:(.text+0xe2b): undefined reference to `debugfs__mount', not defined anywhere
68         #tools/net/bpf_jit_disasm.c # /usr/include/x86_64-pc-linux-gnu/bfd.h:35:2: error: #error config.h must be included before this header
69 )
70 # tools/vm/page-types.c - broken, header path issue
71 # tools/hv/hv_kvp_daemon.c - broken in 3.7 by missing linux/hyperv.h userspace
72 # Documentation/networking/ifenslave.c - obsolete
73 # Documentation/ptp/testptp.c - pending linux-headers-3.0
74
75 # These have a broken make install, no DESTDIR
76 TARGET_MAKE_SIMPLE=(
77         samples/mei:mei-amt-version
78         tools/firewire:nosy-dump
79         tools/iio:iio_event_monitor
80         tools/iio:iio_generic_buffer
81         tools/iio:lsiio
82         tools/laptop/dslm:dslm
83         tools/power/x86/turbostat:turbostat
84         tools/power/x86/x86_energy_perf_policy:x86_energy_perf_policy
85         tools/thermal/tmon:tmon
86 )
87 # tools/perf - covered by dev-utils/perf
88 # tools/usb - testcases only
89 # tools/virtio - testcaes only
90
91         #for _pattern in {Documentation,scripts,tools,usr,include,lib,"arch/*/include",Makefile,Kbuild,Kconfig}; do
92 src_unpack() {
93         unpack ${LINUX_SOURCES}
94
95         MY_A=
96         for _AFILE in ${A}; do
97                 [[ ${_AFILE} == ${LINUX_SOURCES} ]] && continue
98                 [[ ${_AFILE} == ${LINUX_PATCH} ]] && continue
99                 MY_A="${MY_A} ${_AFILE}"
100         done
101         [[ -n ${MY_A} ]] && unpack ${MY_A}
102 }
103
104 src_prepare() {
105         if [[ -n ${LINUX_PATCH} ]]; then
106                 epatch "${DISTDIR}"/${LINUX_PATCH}
107         fi
108
109         pushd tools/usb/usbip/ >/dev/null &&
110         sed -i 's/-Werror[^ ]* //g' configure.ac &&
111         eautoreconf -i -f -v &&
112         popd >/dev/null || die "usbip"
113
114         sed -i \
115                 -e '/^nosy-dump.*LDFLAGS/d' \
116                 -e '/^nosy-dump.*CFLAGS/d' \
117                 -e '/^nosy-dump.*CPPFLAGS/s,CPPFLAGS =,CPPFLAGS +=,g' \
118                 "${S}"/tools/firewire/Makefile
119 }
120
121 kernel_asm_arch() {
122         a="${1:${ARCH}}"
123         case ${a} in
124                 # Merged arches
125                 x86|amd64) echo x86 ;;
126                 ppc*) echo powerpc ;;
127                 # Non-merged
128                 alpha|arm|ia64|m68k|mips|sh|sparc*) echo ${1} ;;
129                 *) die "TODO: Update the code for your asm-ARCH symlink" ;;
130         esac
131 }
132
133 src_configure() {
134         if use usbip; then
135                 pushd tools/usb/usbip/ || die
136                 econf \
137                         $(use_enable static-libs static) \
138                         $(use tcpd || echo --without-tcp-wrappers) \
139                         --with-usbids-dir=/usr/share/misc
140                 popd
141         fi
142 }
143
144 src_compile() {
145         local karch=$(kernel_asm_arch "${ARCH}")
146         # This is the minimal amount needed to start building host binaries.
147         #emake allmodconfig ARCH=${karch}
148         #emake prepare modules_prepare ARCH=${karch}
149         #touch Module.symvers
150
151         # Now we can start building
152         append-cflags -I./tools/lib
153         for s in ${TARGETS_SIMPLE[@]} ; do
154                 dir=$(dirname $s) src=$(basename $s) bin=${src%.c}
155                 einfo "Building $s => $bin"
156                 emake -f /dev/null M=${dir} ARCH=${karch} ${s%.c}
157         done
158
159         for t in ${TARGET_MAKE_SIMPLE[@]} ; do
160                 dir=${t/:*} target_binfile=${t#*:}
161                 target=${target_binfile/:*} binfile=${target_binfile/*:}
162                 [ -z "${binfile}" ] && binfile=$target
163                 einfo "Building $dir => $binfile (via emake $target)"
164                 emake -C $dir ARCH=${karch} $target
165         done
166
167         if use usbip; then
168                 emake -C tools/usb/usbip
169         fi
170 }
171
172 src_install() {
173         into /usr
174         for s in ${TARGETS_SIMPLE[@]} ; do
175                 dir=$(dirname $s) src=$(basename $s) bin=${src%.c}
176                 einfo "Installing $s => $bin"
177                 dosbin ${dir}/${bin}
178         done
179
180         for t in ${TARGET_MAKE_SIMPLE[@]} ; do
181                 dir=${t/:*} target_binfile=${t#*:}
182                 target=${target_binfile/:*} binfile=${target_binfile/*:}
183                 [ -z "${binfile}" ] && binfile=$target
184                 einfo "Installing $dir => $binfile"
185                 dosbin ${dir}/${binfile}
186         done
187
188         if use usbip; then
189                 pushd tools/usb/usbip/ >/dev/null || die "usbip"
190                 emake DESTDIR="${D}" install
191                 newdoc README README.usbip
192                 newdoc AUTHORS AUTHORS.usbip
193                 popd >/dev/null
194                 dodoc Documentation/usb/usbip_protocol.rst
195                 find "${D}" -name 'libusbip*.la' -delete || die
196         fi
197
198         # At one point upstream it was moved, but be generic to detect if it's
199         # happened already
200         if [[ -f "${D}"/usr/sbin/generic_buffer ]] && \
201                 [[ ! -f "${D}"/usr/sbin/iio_generic_buffer ]]; then
202                 mv -f "${D}"/usr/sbin/{,iio_}generic_buffer || die
203         fi
204
205         newconfd "${FILESDIR}"/freefall.confd freefall
206         newinitd "${FILESDIR}"/freefall.initd freefall
207 }
208
209 pkg_postinst() {
210         echo
211         elog "The cpupower utility is maintained separately at sys-power/cpupower"
212         elog "The lguest utility no longer builds, and has been dropped."
213         elog "The hpfall tool has been renamed by upstream to freefall; update your config if needed"
214         if find "${ROOT}"/etc/runlevels/ -name hpfall ; then
215                 ewarn "You must change hpfall to freefall in your runlevels!"
216         fi
217         if use usbip; then
218                 elog "For using USB/IP you need to enable USBIP_VHCI_HCD in the client"
219                 elog "machine's kernel config and USBIP_HOST on the server."
220         fi
221 }