initial commit
Some checks failed
continuous-integration/drone Build is failing

This commit is contained in:
Ben Vincent 2024-08-25 02:08:28 +10:00
commit ac3c60376d
3 changed files with 139 additions and 0 deletions

43
.drone.yml Normal file
View File

@ -0,0 +1,43 @@
kind: pipeline
type: docker
name: default
steps:
- name: build
image: almalinux:8.10
commands:
# Add custom EPEL repository
- echo -e "[epel]\nname=epel repository\nbaseurl=https://edgecache.query.consul/epel/8/Everything/x86_64\ngpgkey=http://edgecache.query.consul/epel/RPM-GPG-KEY-EPEL-8\nenabled=1\ngpgcheck=1" > /etc/yum.repos.d/epel.repo
# Add custom BaseOS repository
- echo -e "[baseos]\nname=baseos repository\nbaseurl=https://edgecache.query.consul/almalinux/8.10/BaseOS/x86_64/os\ngpgkey=http://edgecache.query.consul/almalinux/RPM-GPG-KEY-AlmaLinux-8\nenabled=1\ngpgcheck=1" > /etc/yum.repos.d/baseos.repo
# Add custom AppStream repository
- echo -e "[appstream]\nname=appstream repository\nbaseurl=https://edgecache.query.consul/almalinux/8.10/AppStream/x86_64/os\ngpgkey=http://edgecache.query.consul/almalinux/RPM-GPG-KEY-AlmaLinux-8\nenabled=1\ngpgcheck=1" > /etc/yum.repos.d/appstream.repo
# Add custom PowerTools repository
- echo -e "[powertools]\nname=powertools repository\nbaseurl=https://edgecache.query.consul/almalinux/8.10/PowerTools/x86_64/os\ngpgkey=http://edgecache.query.consul/almalinux/RPM-GPG-KEY-AlmaLinux-8\nenabled=1\ngpgcheck=1" > /etc/yum.repos.d/powertools.repo
# Clean and update repository cache
- dnf clean all
- dnf makecache
# Install the required packages using custom repositories
- dnf install -y \
golang \
gcc \
gcc-c++ \
make \
git \
sqlite-devel \
taglib-devel \
ffmpeg \
mpv \
rpmdevtools \
wget \
systemd \
sqlite \
taglib
# Run the `make` command
- make

32
Makefile Normal file
View File

@ -0,0 +1,32 @@
.PHONY: all prep download build clean
RPMBUILD := $(HOME)/rpmbuild
SOURCES := $(RPMBUILD)/SOURCES
SPECS := $(RPMBUILD)/SPECS
SPECFILE := gonic.spec
# Extract the version from the spec file
VERSION := $(shell grep "^Version:" $(SPECFILE) | awk '{print $$2}')
all: build
prep:
@echo "Creating rpmbuild directories..."
@mkdir -p $(RPMBUILD)/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
download: prep
@echo "Downloading sources..."
@wget -O $(SOURCES)/gonic-$(VERSION).tar.gz https://github.com/sentriz/gonic/archive/refs/tags/v$(VERSION).tar.gz
@wget -O $(SOURCES)/gonic-config https://raw.githubusercontent.com/sentriz/gonic/master/contrib/config
@wget -O $(SOURCES)/gonic.service https://raw.githubusercontent.com/sentriz/gonic/master/contrib/gonic.service
@echo "Sources downloaded."
build: $(SPECFILE) download
@echo "Building RPM..."
@rpmbuild -ba $(SPECFILE)
@echo "RPM built."
clean:
@echo "Cleaning up..."
@rm -rf $(RPMBUILD)
@echo "Clean up done."

64
gonic.spec Normal file
View File

@ -0,0 +1,64 @@
Name: gonic
Version: 0.16.4
Release: 1%{?dist}
Summary: Gonic - A lightweight music streaming server
License: MIT
URL: https://github.com/sentriz/gonic
Source0: %{name}-%{version}.tar.gz
Source1: gonic-config
Source2: gonic.service
BuildRequires: golang, gcc, gcc-c++, make, git, sqlite-devel, taglib-devel, ffmpeg, mpv, rpmdevtools, wget, systemd
Requires: golang, git, sqlite, taglib, ffmpeg, mpv, systemd
%description
Gonic is a lightweight music streaming server written in Go.
%global debug_package %{nil}
%prep
%autosetup -n %{name}-%{version}
%build
mkdir -p build
go build -o build/gonic ./cmd/gonic
%install
mkdir -p %{buildroot}/usr/local/bin
cp build/gonic %{buildroot}/usr/local/bin/gonic
mkdir -p %{buildroot}/var/lib/gonic
mkdir -p %{buildroot}/etc/gonic
mkdir -p %{buildroot}/etc/systemd/system
cp %{SOURCE1} %{buildroot}/etc/gonic/config
cp %{SOURCE2} %{buildroot}/etc/systemd/system/gonic.service
%post
/usr/sbin/groupadd --system gonic || :
/usr/sbin/useradd --system --no-create-home --gid gonic gonic || :
chown -R gonic:gonic /var/lib/gonic/
chown gonic:gonic /etc/gonic/config
systemctl daemon-reload
systemctl enable --now gonic
%preun
if [ $$1 -eq 0 ]; then
systemctl stop gonic
systemctl disable gonic
fi
%postun
if [ $$1 -ge 1 ]; then
systemctl daemon-reload
fi
%files
/usr/local/bin/gonic
/var/lib/gonic/
/etc/gonic/config
/etc/systemd/system/gonic.service
%changelog
* Thu Aug 01 2024 Ben Vincent <ben@unkin.net> - 0.16.4-1
- Initial package