diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml new file mode 100644 index 0000000..febe6cb --- /dev/null +++ b/.github/workflows/ubuntu.yml @@ -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 & + diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..d080eba --- /dev/null +++ b/debian/changelog @@ -0,0 +1,6 @@ +strfry (0.9.6-1) unstable; urgency=low + + * Initial ubuntu test release + + -- Doug Hoytech Fri, 22 Sep 2023 17:32:21 +0800 + diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..b4de394 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +11 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..be49f79 --- /dev/null +++ b/debian/control @@ -0,0 +1,13 @@ +Source: strfry +Section: admin +Priority: optional +Maintainer: Doug Hoytech +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 diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..7075072 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,22 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: strfry +Upstream-Contact: Doug Hoytech +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 . diff --git a/debian/postinst b/debian/postinst new file mode 100644 index 0000000..a64f47f --- /dev/null +++ b/debian/postinst @@ -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 diff --git a/debian/postrm b/debian/postrm new file mode 100644 index 0000000..de62cd9 --- /dev/null +++ b/debian/postrm @@ -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 diff --git a/debian/prerm b/debian/prerm new file mode 100644 index 0000000..b8bb8e2 --- /dev/null +++ b/debian/prerm @@ -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 diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..8ee0a82 --- /dev/null +++ b/debian/rules @@ -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 diff --git a/debian/strfry.service b/debian/strfry.service new file mode 100644 index 0000000..aeaa65e --- /dev/null +++ b/debian/strfry.service @@ -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