From 96a73bc04e378bbbf7e1fa820d06acb537443b09 Mon Sep 17 00:00:00 2001 From: TC Johnson Date: Mon, 3 Jul 2023 02:59:50 +0000 Subject: [PATCH] Rpm building --- Earthfile | 23 +++++++- .../veilid-cli/earthly_make_veilid_cli_rpm.sh | 13 +++++ package/rpm/veilid-cli/veilid-cli.spec | 28 ++++++++++ .../earthly_make_veilid_server_rpm.sh | 13 +++++ package/rpm/veilid-server/veilid-server.spec | 52 +++++++++++++++++++ 5 files changed, 127 insertions(+), 2 deletions(-) create mode 100755 package/rpm/veilid-cli/earthly_make_veilid_cli_rpm.sh create mode 100644 package/rpm/veilid-cli/veilid-cli.spec create mode 100755 package/rpm/veilid-server/earthly_make_veilid_server_rpm.sh create mode 100644 package/rpm/veilid-server/veilid-server.spec diff --git a/Earthfile b/Earthfile index 2c7edfc0..e4fc6f64 100644 --- a/Earthfile +++ b/Earthfile @@ -118,7 +118,7 @@ unit-tests-linux-arm64: RUN cargo test --target aarch64-unknown-linux-gnu --release -p veilid-server -p veilid-cli -p veilid-tools -p veilid-core # Package -package-linux-amd64: +package-linux-amd64-deb: FROM +build-linux-amd64 ################################# ### DEBIAN DPKG .DEB FILES @@ -131,8 +131,27 @@ package-linux-amd64: RUN /veilid/package/debian/earthly_make_veilid_cli_deb.sh amd64 x86_64-unknown-linux-gnu # save artifacts SAVE ARTIFACT --keep-ts /dpkg/out/*.deb AS LOCAL ./target/packages/ + +package-linux-amd64-rpm: + FROM --platform amd64 rockylinux:8 + RUN yum install -y createrepo rpm-build rpm-sign yum-utils rpmdevtools + RUN rpmdev-setuptree + ################################# + ### RPMBUILD .RPM FILES + ################################# + RUN mkdir -p /veilid/target + COPY --dir .cargo external files scripts veilid-cli veilid-core veilid-server veilid-tools veilid-flutter veilid-wasm Cargo.lock Cargo.toml package /veilid + COPY +build-linux-amd64/x86_64-unknown-linux-gnu /veilid/target/x86_64-unknown-linux-gnu + RUN mkdir -p /rpm-work-dir/veilid-server + # veilid-server + RUN veilid/package/rpm/veilid-server/earthly_make_veilid_server_rpm.sh x86_64 x86_64-unknown-linux-gnu + #SAVE ARTIFACT --keep-ts /root/rpmbuild/RPMS/x86_64/*.rpm AS LOCAL ./target/packages/ + # veilid-cli + RUN veilid/package/rpm/veilid-cli/earthly_make_veilid_cli_rpm.sh x86_64 x86_64-unknown-linux-gnu + # save artifacts + SAVE ARTIFACT --keep-ts /root/rpmbuild/RPMS/x86_64/*.rpm AS LOCAL ./target/packages/ -package-linux-arm64: +package-linux-arm64-deb: FROM +build-linux-arm64 ################################# ### DEBIAN DPKG .DEB FILES diff --git a/package/rpm/veilid-cli/earthly_make_veilid_cli_rpm.sh b/package/rpm/veilid-cli/earthly_make_veilid_cli_rpm.sh new file mode 100755 index 00000000..0d5aa627 --- /dev/null +++ b/package/rpm/veilid-cli/earthly_make_veilid_cli_rpm.sh @@ -0,0 +1,13 @@ +#!/bin/bash +ARCH=$1 +CARGO_ARCH=$2 +CARGO_VERSION="$(/veilid/package/cargo_version.sh /veilid/veilid-cli/Cargo.toml)" + +# veilid-cli spec file +cp -rf /veilid/package/rpm/veilid-cli/veilid-cli.spec /root/rpmbuild/SPECS/ +/veilid/package/replace_variable.sh /root/rpmbuild/SPECS/veilid-cli.spec CARGO_VERSION $CARGO_VERSION +/veilid/package/replace_variable.sh /root/rpmbuild/SPECS/veilid-cli.spec ARCH $ARCH +/veilid/package/replace_variable.sh /root/rpmbuild/SPECS/veilid-cli.spec CARGO_ARCH $CARGO_ARCH + +# build the rpm +rpmbuild --target "x86_64" -bb /root/rpmbuild/SPECS/veilid-cli.spec \ No newline at end of file diff --git a/package/rpm/veilid-cli/veilid-cli.spec b/package/rpm/veilid-cli/veilid-cli.spec new file mode 100644 index 00000000..8553de0b --- /dev/null +++ b/package/rpm/veilid-cli/veilid-cli.spec @@ -0,0 +1,28 @@ +Summary: Veilid Server Command Line Interface +Name: veilid-cli +Version: $CARGO_VERSION +Release: 1 +URL: https://veilid.com +Group: System +License: MPL 2.0 +Packager: Veilid Foundation, Inc. +Requires: glibc-common >= 2.23 +BuildRoot: /rpm-work-dir/veilid-cli +BuildArch: $ARCH + +%description +Veilid Server Command Line Interface + +%install +mkdir -p %{buildroot}/usr/bin/ +cp /veilid/target/$CARGO_ARCH/release/veilid-cli %{buildroot}/usr/bin/veilid-cli + +%files +/usr/bin/veilid-cli + +%post +chmod 755 /usr/bin/veilid-cli + +%changelog +* Sun Jul 2 2023 TC +- experimental RPM building diff --git a/package/rpm/veilid-server/earthly_make_veilid_server_rpm.sh b/package/rpm/veilid-server/earthly_make_veilid_server_rpm.sh new file mode 100755 index 00000000..48f941c3 --- /dev/null +++ b/package/rpm/veilid-server/earthly_make_veilid_server_rpm.sh @@ -0,0 +1,13 @@ +#!/bin/bash +ARCH=$1 +CARGO_ARCH=$2 +CARGO_VERSION="$(/veilid/package/cargo_version.sh /veilid/veilid-server/Cargo.toml)" + +# veilid-server spec file +cp -rf /veilid/package/rpm/veilid-server/veilid-server.spec /root/rpmbuild/SPECS/ +/veilid/package/replace_variable.sh /root/rpmbuild/SPECS/veilid-server.spec CARGO_VERSION $CARGO_VERSION +/veilid/package/replace_variable.sh /root/rpmbuild/SPECS/veilid-server.spec ARCH $ARCH +/veilid/package/replace_variable.sh /root/rpmbuild/SPECS/veilid-server.spec CARGO_ARCH $CARGO_ARCH + +# build the rpm +rpmbuild --target "x86_64" -bb /root/rpmbuild/SPECS/veilid-server.spec \ No newline at end of file diff --git a/package/rpm/veilid-server/veilid-server.spec b/package/rpm/veilid-server/veilid-server.spec new file mode 100644 index 00000000..2790f042 --- /dev/null +++ b/package/rpm/veilid-server/veilid-server.spec @@ -0,0 +1,52 @@ +Summary: Install a server grade, headless Veilid node +Name: veilid-server +Version: $CARGO_VERSION +Release: 1 +URL: https://veilid.com +Group: System +License: MPL 2.0 +Packager: Veilid Foundation, Inc. +Requires: glibc-common >= 2.23 +BuildRoot: /rpm-work-dir/veilid-server +BuildArch: $ARCH + +%description +A server grade, headless Veilid node + +%install +mkdir -p %{buildroot}/usr/bin/ +cp /veilid/target/$CARGO_ARCH/release/veilid-server %{buildroot}/usr/bin/veilid-server + +mkdir -p %{buildroot}/etc/systemd/system +cp /veilid/package/systemd/veilid-server.service %{buildroot}/etc/systemd/system/veilid-server.service + +mkdir -p %{buildroot}/etc/veilid-server +cp /veilid/package/linux/veilid-server.conf %{buildroot}/etc/veilid-server/veilid-server.conf + +%files +/usr/bin/veilid-server +/etc/systemd/system/veilid-server.service +/etc/veilid-server/veilid-server.conf + +%post +adduser --system -U veilid &>/dev/null || true +mkdir -p /var/db/veilid-server/protected_store +mkdir -p /var/db/veilid-server/table_store +mkdir -p /var/db/veilid-server/block_store +chown -R veilid:veilid /var/db/veilid-server +chmod 0750 /var/db/veilid-server/protected_store +chmod 0750 /var/db/veilid-server/table_store +chmod 0750 /var/db/veilid-server/block_store +chmod 0750 /var/db/veilid-server +chmod 755 /usr/bin/veilid-server + +systemctl daemon-reload + +echo "Congratulations! To start your Veilid node and set it to start at boot, run the command systemctl enable --now veilid-server" + +%postun +systemctl daemon-reload + +%changelog +* Sun Jul 2 2023 TC +- experimental RPM building