Skip to content

Commit

Permalink
Merge pull request #200 from Guillaume001/add-rpm-el9
Browse files Browse the repository at this point in the history
Add RPM package for almalinux 9
  • Loading branch information
vruello authored Dec 2, 2024
2 parents 64a593a + c6e7044 commit 0d5b869
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 1 deletion.
23 changes: 22 additions & 1 deletion .github/workflows/release-draft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,21 @@ jobs:
with:
name: openwec-deb-bullseye-package
path: ./target/debian/*.deb
- name: Make almalinux 9 package
run: |
cargo clean && \
cd build-pkg && \
docker build -t openwec-builder:almalinux-9 -f Dockerfile-almalinux-9 . && \
docker run -t -u $(id -u):$(id -g) -v $(pwd)/../:/SRC \
--env CARGO_HOME=/SRC/target/.cargo openwec-builder:almalinux-9 \
sh -c "cargo build --release --locked && \
strip -s target/release/openwec{d,} && \
cargo generate-rpm --package common --metadata-overwrite=./common/Cargo.toml --set-metadata=\"release='1.el9'\""
- name: Upload almalinux 9 package
uses: actions/upload-artifact@v4
with:
name: openwec-alma-9-package
path: ./target/generate-rpm/*.rpm
# Need to select "Read and write permissions" under Actions / General / Workflow Permissions
release:
name: Github release draft
Expand All @@ -60,15 +75,21 @@ jobs:
uses: actions/download-artifact@v4
with:
name: openwec-deb-bullseye-package
- name: Download almalinux 9 package
uses: actions/download-artifact@v4
with:
name: openwec-alma-9-package
- name: Get artifacts names
id: artifacts_names
run: |
echo "U_PKG_DEB_BOOKWORM=$(ls openwec*_deb12.deb)" >> "$GITHUB_OUTPUT" && \
echo "U_PKG_DEB_BULLSEYE=$(ls openwec*_deb11.deb)" >> "$GITHUB_OUTPUT"
echo "U_PKG_DEB_BULLSEYE=$(ls openwec*_deb11.deb)" >> "$GITHUB_OUTPUT" && \
echo "U_PKG_ALMA_9=$(ls openwec*el9*.rpm)" >> "$GITHUB_OUTPUT"
- name: Create draft release
uses: softprops/action-gh-release@v2
with:
draft: true
files: |
${{ steps.artifacts_names.outputs.U_PKG_DEB_BOOKWORM }}
${{ steps.artifacts_names.outputs.U_PKG_DEB_BULLSEYE }}
${{ steps.artifacts_names.outputs.U_PKG_ALMA_9 }}
19 changes: 19 additions & 0 deletions build-pkg/Dockerfile-almalinux-9
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM almalinux:9

ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH

RUN set -eux; \
dnf check-update && dnf update -y ; \
dnf install -y \
pkgconf \
clang \
make \
openssl-devel \
krb5-devel ; \
dnf clean all ; \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path ; \
cargo install cargo-generate-rpm ;

WORKDIR /SRC
1 change: 1 addition & 0 deletions build-pkg/almalinux/openwecd.service
15 changes: 15 additions & 0 deletions build-pkg/almalinux/preinstall
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh
set -e

OPENWEC_USER="openwec"
OPENWEC_HOME="/var/empty/openwec"
OPENWEC_SHELL="/sbin/nologin"

create_user() {
if id ${OPENWEC_USER} > /dev/null 2>&1; then return; fi
/usr/sbin/adduser --system --create-home --home-dir "${OPENWEC_HOME}" --shell "${OPENWEC_SHELL}" --comment "OpenWEC user" "${OPENWEC_USER}"
}

create_user

exit 0
15 changes: 15 additions & 0 deletions common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,18 @@ assets = [
conf-files = ["/etc/openwec.conf.toml"]
maintainer-scripts = "../build-pkg/debian/"
systemd-units = { unit-name = "openwecd", enable = false }

# generate-rpm
[package.metadata.generate-rpm]
name = "openwec"
license = "GPL-3.0"
pre_install_script = "../build-pkg/almalinux/preinstall"
assets = [
{ source = "target/release/openwec", dest = "/usr/bin/openwec", mode = "0755" },
{ source = "target/release/openwecd", dest = "/usr/bin/", mode = "0755" },
{ source = "../build-pkg/almalinux/openwecd.service", dest = "/usr/lib/systemd/system/openwecd.service", mode = "0644" },
{ source = "../openwec.conf.sample.toml", dest = "/etc/openwec.conf.toml", mode = "0644", config = "noreplace" },
{ source = "../openwec.conf.sample.toml", dest = "/usr/share/doc/openwec/", mode = "0644", doc = true },
{ source = "../README.md", dest = "/usr/share/doc/openwec/", mode = "0644", doc = true },
{ source = "../doc/*", dest = "/usr/share/doc/openwec/doc/", mode = "0644", doc = true },
]

0 comments on commit 0d5b869

Please sign in to comment.