mirror of
https://github.com/netdata/libbpf.git
synced 2026-03-21 00:39:07 +08:00
We are no longer using Travis. As such, we should move away from a lot of CI functionality located in a folder called travis-ci/. This change renames the travis-ci/ directory to the more generic ci/. To preserve backwards compatibility until all "consumers" have transitioned, we add a symbolic link called travis-ci back. It will be removed in the near term future. Signed-off-by: Daniel Müller <deso@posteo.net>
53 lines
1.3 KiB
Bash
Executable File
53 lines
1.3 KiB
Bash
Executable File
#!/bin/bash
|
|
# This script builds a Debian root filesystem image for testing libbpf in a
|
|
# virtual machine. Requires debootstrap >= 1.0.95 and zstd.
|
|
|
|
# Use e.g. ./mkrootfs_debian.sh --arch=s390x to generate a rootfs for a
|
|
# foreign architecture. Requires configured binfmt_misc, e.g. using
|
|
# Debian/Ubuntu's qemu-user-binfmt package or
|
|
# https://github.com/multiarch/qemu-user-static.
|
|
|
|
set -e -u -x -o pipefail
|
|
|
|
# Check whether we are root now in order to avoid confusing errors later.
|
|
if [ "$(id -u)" != 0 ]; then
|
|
echo "$0 must run as root" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Create a working directory and schedule its deletion.
|
|
root=$(mktemp -d -p "$PWD")
|
|
trap 'rm -r "$root"' EXIT
|
|
|
|
# Install packages.
|
|
packages=(
|
|
binutils
|
|
busybox
|
|
elfutils
|
|
ethtool
|
|
iproute2
|
|
iptables
|
|
libcap2
|
|
libelf1
|
|
strace
|
|
zlib1g
|
|
)
|
|
packages=$(IFS=, && echo "${packages[*]}")
|
|
debootstrap --include="$packages" --variant=minbase "$@" bookworm "$root"
|
|
|
|
# Remove the init scripts (tests use their own). Also remove various
|
|
# unnecessary files in order to save space.
|
|
rm -rf \
|
|
"$root"/etc/rcS.d \
|
|
"$root"/usr/share/{doc,info,locale,man,zoneinfo} \
|
|
"$root"/var/cache/apt/archives/* \
|
|
"$root"/var/lib/apt/lists/*
|
|
|
|
# Apply common tweaks.
|
|
"$(dirname "$0")"/mkrootfs_tweak.sh "$root"
|
|
|
|
# Save the result.
|
|
name="libbpf-vmtest-rootfs-$(date +%Y.%m.%d).tar.zst"
|
|
rm -f "$name"
|
|
tar -C "$root" -c . | zstd -T0 -19 -o "$name"
|