From c0169e113a213085dece33b91884332070a0e81d Mon Sep 17 00:00:00 2001 From: vidplace7 Date: Fri, 3 Jan 2025 11:12:48 -0500 Subject: [PATCH] rpkg Fedora packaging --- .github/workflows/hook_copr.yml | 75 +++++++++++++++++++ ...ghtly_debian.yml => nightly_packaging.yml} | 12 ++- bin/readprops.py | 3 + bin/rpkg.macros | 4 + meshtasticd.spec.rpkg | 69 +++++++++++++++++ rpkg.conf | 2 + 6 files changed, 163 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/hook_copr.yml rename .github/workflows/{nightly_debian.yml => nightly_packaging.yml} (75%) create mode 100644 bin/rpkg.macros create mode 100644 meshtasticd.spec.rpkg create mode 100644 rpkg.conf diff --git a/.github/workflows/hook_copr.yml b/.github/workflows/hook_copr.yml new file mode 100644 index 0000000000..3ea8c3410d --- /dev/null +++ b/.github/workflows/hook_copr.yml @@ -0,0 +1,75 @@ +name: Trigger COPR build + +on: + workflow_call: + secrets: + COPR_HOOK_DAILY: + COPR_HOOK_ALPHA: + COPR_HOOK_BETA: + inputs: + copr_project: + description: COPR project to target + required: true + type: string + +permissions: read-all + +jobs: + build-copr-hook: + runs-on: ubuntu-24.04 + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + submodules: recursive + ref: ${{ github.ref }} + repository: ${{ github.repository }} + + - name: Install Python dependencies + run: | + pip install requests + + - name: Trigger COPR build + shell: python + run: | + import requests + + project_name = "${{ inputs.copr_project }}" + hook_secret = "" + project_id = 0 + if project_name == "daily": + hook_secret = "${{ secrets.COPR_HOOK_DAILY }}" + project_id = 160277 + elif project_name == "alpha": + hook_secret = "${{ secrets.COPR_HOOK_ALPHA }}" + project_id = 160278 + elif project_name == "beta": + hook_secret = "${{ secrets.COPR_HOOK_BETA }}" + project_id = 160279 + else: + raise ValueError(f"Unknown COPR project: {project_name}") + + webhook_url = f"https://copr.fedorainfracloud.org/webhooks/github/{project_id}/{hook_secret}/meshtasticd/" + copr_payload = { + "event": "push", + "payload": { + "ref": "${{ github.ref }}", + "after": "${{ github.sha }}", + "repository": { + "id": "${{ github.repository_id }}", + "full_name": "${{ github.repository }}", + "git_url": "${{ github.repositoryUrl }}", + "owner": { + "name": "${{ github.repository_owner }}" + } + }, + "pusher": { + "name": "${{ github.actor }}" + }, + "sender": { + "login": "github-actions[bot]" + } + } + } + r = requests.post(webhook_url, json=copr_payload) + r.raise_for_status() diff --git a/.github/workflows/nightly_debian.yml b/.github/workflows/nightly_packaging.yml similarity index 75% rename from .github/workflows/nightly_debian.yml rename to .github/workflows/nightly_packaging.yml index aa001854e6..e477fe194b 100644 --- a/.github/workflows/nightly_debian.yml +++ b/.github/workflows/nightly_packaging.yml @@ -1,4 +1,4 @@ -name: Nightly Debian Packaging +name: Nightly Packaging on: schedule: - cron: 0 9 * * * @@ -8,10 +8,12 @@ on: - master paths: - debian/** - - .github/workflows/nightly_debian.yml + - "*.rpkg" + - .github/workflows/nightly_packaging.yml - .github/workflows/build_debian_src.yml - .github/workflows/package_ppa.yml - .github/workflows/package_obs.yml + - .github/workflows/hook_copr.yml permissions: contents: write @@ -35,3 +37,9 @@ jobs: obs_project: home:meshtastic:daily series: unstable secrets: inherit + + hook-copr: + uses: ./.github/workflows/hook_copr.yml + with: + copr_project: daily + secrets: inherit diff --git a/bin/readprops.py b/bin/readprops.py index 731a3d0d3b..f146e95ef6 100644 --- a/bin/readprops.py +++ b/bin/readprops.py @@ -14,6 +14,7 @@ def readProps(prefsLoc): short="{}.{}.{}".format(version["major"], version["minor"], version["build"]), long="unset", deb="unset", + rpm="unset", ) # Try to find current build SHA if if the workspace is clean. This could fail if git is not installed @@ -32,11 +33,13 @@ def readProps(prefsLoc): # suffix = sha + "-d" verObj["long"] = "{}.{}".format(verObj["short"], suffix) verObj["deb"] = "{}.{}~{}{}".format(verObj["short"], run_number, build_location, sha) + verObj["rpm"] = "{}-{}".format(verObj["short"], sha) except: # print("Unexpected error:", sys.exc_info()[0]) # traceback.print_exc() verObj["long"] = verObj["short"] verObj["deb"] = "{}.{}~{}".format(verObj["short"], run_number, build_location) + verObj["rpm"] = verObj["short"] # print("firmware version " + verStr) return verObj diff --git a/bin/rpkg.macros b/bin/rpkg.macros new file mode 100644 index 0000000000..c8988196f6 --- /dev/null +++ b/bin/rpkg.macros @@ -0,0 +1,4 @@ +function meshtastic_version { + meshtastic_version=$(python3 bin/buildinfo.py short) + echo -n "$meshtastic_version" +} diff --git a/meshtasticd.spec.rpkg b/meshtasticd.spec.rpkg new file mode 100644 index 0000000000..67d410cece --- /dev/null +++ b/meshtasticd.spec.rpkg @@ -0,0 +1,69 @@ +# meshtasticd spec file for RPM-based distributions +# +# Build locally with: +# ``` +# sudo dnf install rpkg-util +# rpkg local +# ``` +# +# See: +# - https://docs.pagure.org/rpkg-util/v3/index.html +# - https://docs.fedoraproject.org/en-US/packaging-guidelines/Versioning/ + +Name: meshtasticd +Version: {{{ meshtastic_version }}} +Release: %autorelease +VCS: {{{ git_dir_vcs }}} +Summary: Meshtastic daemon for communicating with Meshtastic devices + +License: GPL-3.0 +URL: https://github.com/meshtastic/firmware +Source0: {{{ git_dir_pack }}} + +BuildRequires: systemd-rpm-macros +BuildRequires: python3-devel +BuildRequires: platformio +BuildRequires: python3dist(protobuf) +BuildRequires: python3dist(grpcio[protobuf]) +BuildRequires: python3dist(grpcio-tools) +BuildRequires: git-core +BuildRequires: gcc-c++ +BuildRequires: pkgconfig(yaml-cpp) +BuildRequires: pkgconfig(libgpiod) +BuildRequires: pkgconfig(bluez) +BuildRequires: pkgconfig(libusb-1.0) +BuildRequires: libi2c-devel + +%description +Meshtastic daemon for controlling Meshtastic devices. Meshtastic is an off-grid +text communication platform that uses inexpensive LoRa radios. + +%prep +{{{ git_dir_setup_macro }}} + +%build +# Use the “native” environment from platformio to build a Linux binary +platformio run -e native + +%install +mkdir -p %{buildroot}%{_sbindir} +install -m 0755 .pio/build/native/program %{buildroot}%{_sbindir}/meshtasticd + +mkdir -p %{buildroot}%{_sysconfdir}/meshtasticd +install -m 0644 bin/config-dist.yaml %{buildroot}%{_sysconfdir}/meshtasticd/config.yaml +mkdir -p %{buildroot}%{_sysconfdir}/meshtasticd/config.d +mkdir -p %{buildroot}%{_sysconfdir}/meshtasticd/available.d +cp -r bin/config.d/* %{buildroot}%{_sysconfdir}/meshtasticd/available.d + +install -D -m 0644 bin/meshtasticd.service %{buildroot}%{_unitdir}/meshtasticd.service + +%files +%license LICENSE +%doc README.md +%{_sbindir}/meshtasticd +%ghost %config(noreplace) %{_sysconfdir}/meshtasticd/config.yaml +%config %{_sysconfdir}/meshtasticd/available.d/* +%{_unitdir}/meshtasticd.service + +%changelog +{{{ git_dir_changelog }}} diff --git a/rpkg.conf b/rpkg.conf new file mode 100644 index 0000000000..f574f9a137 --- /dev/null +++ b/rpkg.conf @@ -0,0 +1,2 @@ +[rpkg] +user_macros = "${git_props:root}/bin/rpkg.macros"