Merge pull request #3230 from simar7/bpftrace-pkg

pkg/bpftrace: Add bpftrace as a core pkg
This commit is contained in:
Rolf Neugebauer 2018-12-08 09:44:35 +00:00 committed by GitHub
commit b987627a1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 102 additions and 0 deletions

37
pkg/bpftrace/Dockerfile Normal file
View File

@ -0,0 +1,37 @@
FROM linuxkit/alpine:ace75d0ec6978762d445083d6c8c6336bdb658ed AS build
RUN apk add --update \
bison \
build-base \
clang-dev \
clang-static \
cmake \
elfutils-dev \
flex-dev \
git \
linux-headers \
llvm5-dev \
llvm5-static \
zlib-dev
# Put LLVM directories where CMake expects them to be
RUN ln -s /usr/lib/cmake/llvm5 /usr/lib/cmake/llvm
RUN ln -s /usr/include/llvm5/llvm /usr/include/llvm
RUN ln -s /usr/include/llvm5/llvm-c /usr/include/llvm-c
ENV GITREPO=https://github.com/iovisor/bpftrace.git
ENV COMMIT=8f7f8214d7dd7bc25b7740a3c0e9a580a89e0244
ENV STATIC_LINKING=on
ENV RUN_TESTS=0
RUN git clone ${GITREPO} /bpftrace \
&& cd /bpftrace/ \
&& mkdir -p /bpftrace/build \
&& git checkout ${COMMIT} \
&& chmod +x /bpftrace/docker/build.sh \
&& /bpftrace/docker/build.sh /bpftrace/build Release -j$(nproc)
FROM scratch
ENTRYPOINT []
CMD []
WORKDIR /
COPY --from=build /bpftrace/build/src/bpftrace /usr/bin/bpftrace

4
pkg/bpftrace/build.yml Normal file
View File

@ -0,0 +1,4 @@
image: bpftrace
network: true
arches:
- amd64

View File

@ -0,0 +1,9 @@
#!/bin/sh
nsenter -t1 -m -- /usr/bin/bpftrace -l
if [ "$?" -ne "0" ]; then
printf "bpftrace test suite FAILED\n" >&1
exit 1
fi;
printf "bpftrace test suite PASSED\n" >&1

View File

@ -0,0 +1,23 @@
#!/bin/sh
# SUMMARY: Check that the bpftrace package works
# REPEAT:
set -e
# Source libraries. Uncomment if needed/defined
#. "${RT_LIB}"
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
NAME=bpftrace
clean_up() {
rm -rf ${NAME}-*
}
trap clean_up EXIT
# Test code goes here
linuxkit build -format kernel+initrd -name "${NAME}" test.yml
RESULT="$(linuxkit run ${NAME})"
echo "${RESULT}"
echo "${RESULT}" | grep -q "suite PASSED"
exit 0

View File

@ -0,0 +1,29 @@
kernel:
image: linuxkit/kernel:4.14.86
cmdline: "console=ttyS0 console=ttyAMA0"
init:
- linuxkit/init:v0.5
- linuxkit/runc:v0.5
- linuxkit/bpftrace:67b5c3b4f13a4acf22eab8f422091e1efc06852d
onboot:
- name: bpftrace-test
image: alpine:3.8
binds:
- /check.sh:/check.sh
command: ["sh", "./check.sh"]
pid: host
net: host
ipc: host
capabilities:
- all
- name: poweroff
image: linuxkit/poweroff:2687ed712690766b8156a77ac600005b532d2c7d
command: ["/bin/sh", "/poweroff.sh", "10"]
files:
- path: check.sh
source: ./check.sh
trust:
org:
- linuxkit
image:
- alpine:3.8