# docker.io/acmel/linux-perf-tools-build-centos:5
FROM docker.io/centos:5
MAINTAINER Arnaldo Carvalho de Melo <acme@kernel.org>
# Should add perl-ExtUtils-Embed in the mix and remove NO_LIBPERL=1
# from the ENTRYPOINT after fixing these problems:
#   CC       /tmp/build/perf/util/trace-event-scripting.o
# cc1: warnings being treated as errors
# Context.c: In function 'boot_Perf__Trace__Context':
# Context.c:128: warning: passing argument 2 of 'Perl_newXS' discards qualifiers from pointer target type

# the flex package that comes with Centos5 can't build perf, build one from Centos6
# Rebuilt from http://vault.centos.org/6.8/os/Source/SPackages/flex-2.5.35-9.el6.src.rpm
COPY flex-2.5.35-9.x86_64.rpm /tmp
COPY CentOS-Base.repo /etc/yum.repos.d/
COPY libselinux.repo /etc/yum.repos.d/
RUN yum -y install make gcc flex bison bc elfutils-libelf-devel.x86_64 elfutils-devel.x86_64 \
		   curl xz \
		   libunwind-devel.x86_64 audit-libs-devel.x86_64 openssl-devel.x86_64 slang-devel.x86_64 \
		   gtk2-devel.x86_64 python-devel.x86_64 binutils-devel.x86_64 \
		   systemtap-sdt-devel xz-devel.x86_64 numactl-devel.x86_64 && \
    yum -y clean all && \
    rpm -Uvh /tmp/flex-2.5.35-9.x86_64.rpm && \
    rm -rf /usr/share/doc /usr/share/gtk-doc /usr/share/locale /usr/share/man
RUN mkdir -m 777 -p /git /tmp/build/perf /tmp/build/objtool /tmp/build/linux && \
    groupadd -r perfbuilder && \
    useradd -m -r -g perfbuilder perfbuilder && \
    chown -R perfbuilder.perfbuilder /tmp/build/ /git/
USER perfbuilder
COPY rx_and_build.sh /
ENV EXTRA_MAKE_ARGS=NO_LIBPERL=1
ENTRYPOINT ["/rx_and_build.sh"]
