Skip to content

Commit

Permalink
Merge pull request #90 from cosmicpsyop/feature/ubuntu-pkg-job
Browse files Browse the repository at this point in the history
create debian package framework and git action job
  • Loading branch information
hoytech authored Dec 19, 2023
2 parents 5b7d3a2 + b02740d commit c0dec7c
Show file tree
Hide file tree
Showing 10 changed files with 165 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: ubuntu

on: [push, pull_request]

jobs:
ubuntu:
runs-on: ubuntu-latest
name: A job to build and run strfry on Ubuntu
steps:
- name: Checkout strfry
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Build strfry
run: |
sudo apt update && sudo apt install -y --no-install-recommends \
git g++ make pkg-config libtool ca-certificates \
libyaml-perl libtemplate-perl libregexp-grammars-perl libssl-dev zlib1g-dev \
liblmdb-dev libflatbuffers-dev libsecp256k1-dev libzstd-dev
git submodule update --init
make setup-golpe
make -j4
if ! [ -f ./strfry ]; then
echo "Strfry build failed."
exit 1
fi
- name: Package strfry
run: |
sudo apt-get install debhelper devscripts -y
dpkg-buildpackage --build=binary -us -uc
mv ../*.deb .
filename=`ls *.deb | grep -v -- -dbgsym`
echo "filename=$filename" >> $GITHUB_ENV
- name: Upload strfry deb
uses: actions/upload-artifact@v3
with:
name: ${{ env.filename }}
path: ${{ env.filename }}

- name: Run strfry
run: |
cat /etc/os-release
sudo ./strfry relay &
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
strfry (0.9.6-1) unstable; urgency=low

* Initial ubuntu test release

-- Doug Hoytech <[email protected]> Fri, 22 Sep 2023 17:32:21 +0800

1 change: 1 addition & 0 deletions debian/compat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
11
13 changes: 13 additions & 0 deletions debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Source: strfry
Section: admin
Priority: optional
Maintainer: Doug Hoytech <[email protected]>
Build-Depends: debhelper (>= 8.0.0)

Package: strfry
Architecture: amd64
Depends: ${shlibs:Depends}
Conflicts:
Replaces:
Provides: strfry
Description: strfry is a relay for the nostr protocol
22 changes: 22 additions & 0 deletions debian/copyright
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: strfry
Upstream-Contact: Doug Hoytech <[email protected]>
Source: https://github.com/hoytech/strfry

Files: *
Copyright: 2023 Doug Hoytech
License: GPL-3

License: GPL-3
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
21 changes: 21 additions & 0 deletions debian/postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh

set -e

if ! getent group strfry >/dev/null 2>&1; then
addgroup --system --quiet strfry
fi
if ! getent passwd strfry >/dev/null 2>&1; then
adduser --system --quiet --ingroup strfry \
--no-create-home --home /nonexistent \
strfry
fi

if [ "$1" = "configure" ] ; then
chown strfry:strfry /etc/strfry.conf
chown strfry:strfry /var/lib/strfry

systemctl daemon-reload
systemctl enable strfry.service
systemctl start strfry
fi
12 changes: 12 additions & 0 deletions debian/postrm
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh

set -e

if [ "$1" = remove ] && [ -d /run/systemd/system ] ; then
systemctl --system daemon-reload >/dev/null || true
fi
if [ "$1" = "purge" ]; then
if [ -x "/usr/bin/deb-systemd-helper" ]; then
deb-systemd-helper purge 'strfry.service' >/dev/null || true
fi
fi
12 changes: 12 additions & 0 deletions debian/prerm
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh

set -e

if [ "$1" = "remove" ]; then
systemctl stop strfry
systemctl disable strfry
fi

if [ "$1" = "upgrade" ]; then
systemctl stop strfry
fi
15 changes: 15 additions & 0 deletions debian/rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/make -f

#export DH_VERBOSE=1

%:
dh $@ --parallel

override_dh_auto_clean:
override_dh_auto_install:
mkdir -p debian/strfry/usr/bin/
mkdir -p debian/strfry/etc/
mkdir -p debian/strfry/var/lib/strfry/
cp -a strfry debian/strfry/usr/bin/.
cp -a strfry.conf debian/strfry/etc/.
sed -i 's|./strfry-db/|/var/lib/strfry/|g' debian/strfry/etc/strfry.conf
16 changes: 16 additions & 0 deletions debian/strfry.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[Unit]
Description=strfry relay service
After=syslog.target network.target

[Service]
User=strfry
ExecStart=/usr/bin/strfry relay
Restart=on-failure
RestartSec=5
ProtectHome=yes
NoNewPrivileges=yes
ProtectSystem=full
LimitCORE=1000000000

[Install]
WantedBy=multi-user.target

0 comments on commit c0dec7c

Please sign in to comment.