Skip to content

Commit

Permalink
rpkg Fedora packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
vidplace7 committed Jan 12, 2025
1 parent fd60c9b commit c0169e1
Show file tree
Hide file tree
Showing 6 changed files with 163 additions and 2 deletions.
75 changes: 75 additions & 0 deletions .github/workflows/hook_copr.yml
Original file line number Diff line number Diff line change
@@ -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()
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Nightly Debian Packaging
name: Nightly Packaging
on:
schedule:
- cron: 0 9 * * *
Expand All @@ -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
Expand All @@ -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
3 changes: 3 additions & 0 deletions bin/readprops.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions bin/rpkg.macros
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
function meshtastic_version {
meshtastic_version=$(python3 bin/buildinfo.py short)
echo -n "$meshtastic_version"
}
69 changes: 69 additions & 0 deletions meshtasticd.spec.rpkg
Original file line number Diff line number Diff line change
@@ -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 }}}
2 changes: 2 additions & 0 deletions rpkg.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[rpkg]
user_macros = "${git_props:root}/bin/rpkg.macros"

0 comments on commit c0169e1

Please sign in to comment.