forked from Netflix/bpftop
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for building RPM packages
- Loading branch information
1 parent
41258d7
commit a737971
Showing
6 changed files
with
154 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,11 +28,16 @@ jobs: | |
run: cargo clippy --all --tests --all-features --no-deps | ||
- name: Build | ||
run: cargo build --release | ||
- name: Create Release and Upload Artficat | ||
|
||
- name: Build RPM | ||
if: startsWith(github.ref, 'refs/tags/v') | ||
run: ./build-rpm.sh | ||
|
||
- name: Create Release and Upload Artifacts | ||
uses: ncipollo/[email protected] | ||
if: startsWith(github.ref, 'refs/tags/v') | ||
with: | ||
artifacts: "target/release/bpftop" | ||
artifacts: "target/release/bpftop,*-vendor.tar.gz,bpftop-*.rpm" | ||
draft: true | ||
allowUpdates: true | ||
updateOnlyUnreleased: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,8 @@ target/ | |
root/ | ||
deploy.sh | ||
perf.data | ||
flamegraph.svg | ||
flamegraph.svg | ||
vendor/ | ||
*.tar.gz | ||
rpmbuild/ | ||
*.rpm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,10 @@ | |
name = "bpftop" | ||
version = "0.5.1" | ||
edition = "2021" | ||
description = "Dynamic real-time view of running eBPF programs" | ||
license = "Apache-2.0" | ||
license-file = "LICENSE" | ||
authors = ["Jose Fernandez <[email protected]>"] | ||
|
||
[build-dependencies] | ||
libbpf-cargo = "0.23.1" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/bash | ||
|
||
IMAGE_NAME="rpm-builder" | ||
CONTAINER_NAME="rpm-builder-container" | ||
VERSION=$(grep -m 1 '^version =' Cargo.toml | sed 's/version = "\(.*\)"/\1/') | ||
|
||
git archive --format=tar.gz --prefix=bpftop-$VERSION/ -o v${VERSION}.tar.gz HEAD | ||
|
||
cargo vendor | ||
|
||
tar -czf v${VERSION}-vendor.tar.gz vendor | ||
|
||
rm -rf vendor | ||
|
||
echo "Building docker image" | ||
docker build --build-arg VERSION=$VERSION -t $IMAGE_NAME -f dockerfiles/Dockerfile.rpm . | ||
|
||
echo "Running docker container" | ||
docker run --privileged --name $CONTAINER_NAME -d $IMAGE_NAME tail -f /dev/null | ||
|
||
echo "Building RPM" | ||
docker exec $CONTAINER_NAME mock -r fedora-40-x86_64 --buildsrpm --spec /home/builder/rpmbuild/SPECS/bpftop.spec --sources /home/builder/rpmbuild/SOURCES --resultdir /home/builder/rpmbuild/SRPMS | ||
docker exec $CONTAINER_NAME mock -r fedora-40-x86_64 --rebuild /home/builder/rpmbuild/SRPMS/bpftop-$VERSION-1.fc40.src.rpm --resultdir /home/builder/rpmbuild/RPMS | ||
|
||
echo "Copying RPM to host" | ||
docker cp $CONTAINER_NAME:/home/builder/rpmbuild/RPMS/bpftop-$VERSION-1.fc40.x86_64.rpm . | ||
|
||
echo "Cleaning up" | ||
docker stop $CONTAINER_NAME | ||
docker rm $CONTAINER_NAME |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
FROM fedora:latest | ||
RUN dnf install -y dnf-plugins-core \ | ||
mock \ | ||
rpm-build \ | ||
rpmdevtools \ | ||
rust2rpm \ | ||
cargo \ | ||
git \ | ||
sudo \ | ||
wget && \ | ||
dnf clean all | ||
|
||
ARG VERSION | ||
|
||
ENV VERSION=$VERSION | ||
|
||
RUN useradd -m builder | ||
|
||
RUN echo 'builder ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/builder | ||
|
||
RUN usermod -a -G mock builder | ||
|
||
USER builder | ||
|
||
WORKDIR /home/builder | ||
|
||
RUN rpmdev-setuptree | ||
|
||
COPY packaging/rpm/bpftop.spec /home/builder/rpmbuild/SPECS/bpftop.spec | ||
COPY v${VERSION}.tar.gz /home/builder/rpmbuild/SOURCES/ | ||
COPY v${VERSION}-vendor.tar.gz /home/builder/rpmbuild/SOURCES/ | ||
|
||
ENTRYPOINT ["/bin/bash"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# Generated by rust2rpm 26 | ||
%bcond_without check | ||
|
||
# prevent library files from being installed | ||
%global cargo_install_lib 0 | ||
|
||
Name: bpftop | ||
Version: 0.5.1 | ||
Release: %autorelease | ||
Summary: Dynamic real-time view of running eBPF programs | ||
|
||
SourceLicense: Apache-2.0 | ||
# 0BSD OR MIT OR Apache-2.0 | ||
# Apache-2.0 | ||
# Apache-2.0 OR BSL-1.0 | ||
# Apache-2.0 OR MIT | ||
# Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT | ||
# BSD-2-Clause | ||
# BSD-2-Clause OR Apache-2.0 OR MIT | ||
# BSD-3-Clause | ||
# BSD-3-Clause OR MIT OR Apache-2.0 | ||
# LGPL-2.1-only OR BSD-2-Clause | ||
# MIT | ||
# MIT OR Apache-2.0 | ||
# MIT OR Zlib OR Apache-2.0 | ||
License: License: (0BSD OR MIT OR Apache-2.0) AND (Apache-2.0) AND (Apache-2.0 OR BSL-1.0) AND (Apache-2.0 OR MIT) AND (Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT) AND (BSD-2-Clause) AND (BSD-2-Clause OR Apache-2.0 OR MIT) AND (BSD-3-Clause) AND (BSD-3-Clause OR MIT OR Apache-2.0) AND (LGPL-2.1-only OR BSD-2-Clause) AND (MIT) AND (MIT OR Apache-2.0) AND (MIT OR Zlib OR Apache-2.0) | ||
# LICENSE.dependencies contains a full license breakdown | ||
|
||
URL: https://github.com/Netflix/%{name} | ||
Source0: https://github.com/Netflix/%{name}/archive/refs/tags/v%{version}.tar.gz | ||
Source1: https://github.com/Netflix/%{name}/releases/download/v%{version}/v%{version}-vendor.tar.gz | ||
|
||
BuildRequires: cargo-rpm-macros >= 26 | ||
BuildRequires: elfutils-libelf-devel | ||
BuildRequires: zlib-devel | ||
BuildRequires: clang | ||
|
||
Requires: elfutils-libelf | ||
Requires: zlib | ||
|
||
%global _description %{expand: | ||
Dynamic real-time view of running eBPF programs.} | ||
|
||
%description %{_description} | ||
|
||
%prep | ||
%autosetup -n %{name}-%{version} -p1 | ||
tar -xzf %{SOURCE1} -C . | ||
%cargo_prep -v vendor | ||
|
||
%generate_buildrequires | ||
|
||
%build | ||
%cargo_build | ||
%{cargo_license_summary} | ||
%{cargo_license} > LICENSE.dependencies | ||
%{cargo_vendor_manifest} > cargo-vendor.txt | ||
|
||
%install | ||
%cargo_install | ||
|
||
%if %{with check} | ||
%check | ||
%cargo_test | ||
%endif | ||
|
||
%files | ||
%license LICENSE | ||
%license LICENSE.dependencies | ||
%license cargo-vendor.txt | ||
%doc README.md | ||
%{_bindir}/bpftop | ||
|
||
%changelog | ||
%autochangelog |