-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from ripienaar/14
(#14) Add basic packager for el8 and 9
- Loading branch information
Showing
12 changed files
with
357 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
name: build_tasks | ||
description: Choria Build Tasks | ||
|
||
commands: | ||
- name: dependencies | ||
type: parent | ||
description: Manage dependencies | ||
aliases: [d] | ||
commands: | ||
- name: update | ||
description: Update dependencies | ||
type: exec | ||
aliases: [up] | ||
dir: "{{ AppDir }}" | ||
flags: | ||
- name: verbose | ||
description: Log verbosely | ||
short: v | ||
bool: true | ||
- name: proxy | ||
description: Enable using go proxy | ||
bool: true | ||
default: "true" | ||
script: | | ||
. "{{ BashHelperPath }}" | ||
|
||
ab_announce Updating all dependencies | ||
echo | ||
|
||
{{ if eq .Flags.proxy false }} | ||
export GOPROXY=direct | ||
ab_say Disabling go mod proxy | ||
{{ end }} | ||
|
||
go get -u -n -a -t {{- if .Flags.verbose }} -d -x {{ end }} ./... | ||
|
||
ab_say Running go mod tidy | ||
|
||
go mod tidy | ||
|
||
- name: build | ||
type: parent | ||
aliases: [b] | ||
description: Code build steps | ||
commands: | ||
- name: binary | ||
description: Build a basic test binary | ||
type: exec | ||
dir: "{{ AppDir }}" | ||
aliases: [bin] | ||
banner: | | ||
>>> | ||
>>> Building 'tally' locally | ||
>>> | ||
>>> Target: {{ if .Flags.target }}{{ .Flags.target }}{{else}}host{{end}} | ||
>>> | ||
flags: | ||
- name: target | ||
description: Target platform to build for | ||
enum: ["linux/amd64", "linux/arm64"] | ||
short: T | ||
- name: verbose | ||
description: Logs packages being build | ||
bool: true | ||
short: v | ||
script: | | ||
set -e | ||
|
||
. "{{ BashHelperPath }}" | ||
|
||
{{ if eq .Flags.target "linux/amd64" }} | ||
export GOOS=linux | ||
export GOARCH=amd64 | ||
{{ else if eq .Flags.target "linux/arm64" }} | ||
export GOOS=linux | ||
export GOARCH=arm64 | ||
{{ end }} | ||
|
||
{{ if .Flags.verbose }} | ||
ab_say Packages being build | ||
{{ end }} | ||
|
||
go build \ | ||
{{ if .Flags.verbose }}-v{{ end }} \ | ||
-ldflags="-s -w \ | ||
-X 'github.com/choria-io/tally.version=0.98.0.$(date +%s)' \ | ||
" -o tally | ||
|
||
ab_say Build completed | ||
|
||
echo | ||
ls -l tally | ||
echo | ||
file tally | ||
echo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
foss: | ||
compile_targets: | ||
defaults: | ||
output: tally-{{version}}-{{os}}-{{arch}} | ||
strip: true | ||
|
||
64bit_linux: | ||
os: linux | ||
arch: amd64 | ||
|
||
packages: | ||
defaults: | ||
name: tally | ||
bindir: /usr/sbin | ||
etcdir: /etc/tally | ||
release: 1 | ||
|
||
el8_64: | ||
dist: el8 | ||
template: el/el8 | ||
target_arch: x86_64 | ||
binary: 64bit_linux | ||
|
||
el9_64: | ||
dist: el9 | ||
template: el/el9 | ||
target_arch: x86_64 | ||
binary: 64bit_linux |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
required_properties: | ||
- name | ||
- etcdir | ||
- bindir | ||
- release | ||
- dist | ||
|
||
artifacts: | ||
- /usr/src/redhat/**/*.rpm | ||
- /root/rpmbuild/**/*.rpm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[Unit] | ||
Description=The Choria Tally Service | ||
After=network.target | ||
|
||
[Service] | ||
EnvironmentFile=/etc/sysconfig/{{cpkg_name}} | ||
StandardOutput=syslog | ||
StandardError=syslog | ||
User=root | ||
Group=root | ||
ExecStart={{cpkg_bindir}}/{{cpkg_name}} --component '*' --port 8080 --prefix choria_tally --config={{cpkg_etcdir}}/choria.conf | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
%define debug_package %{nil} | ||
%define pkgname {{cpkg_name}} | ||
%define version {{cpkg_version}} | ||
%define bindir {{cpkg_bindir}} | ||
%define etcdir {{cpkg_etcdir}} | ||
%define release {{cpkg_release}} | ||
%define dist {{cpkg_dist}} | ||
%define binary {{cpkg_binary}} | ||
%define tarball {{cpkg_tarball}} | ||
|
||
Name: %{pkgname} | ||
Version: %{version} | ||
Release: %{release}.%{dist} | ||
Summary: The Choria Tally Service | ||
License: Apache-2.0 | ||
URL: https://choria.io | ||
Group: System Tools | ||
Packager: R.I.Pienaar <[email protected]> | ||
Source0: %{tarball} | ||
BuildRoot: %{_tmppath}/%{pkgname}-%{version}-%{release}-root-%(%{__id_u} -n) | ||
Requires(pre): /usr/sbin/useradd, /usr/bin/getent | ||
Requires(postun): /usr/sbin/userdel | ||
|
||
%description | ||
A service that passively listen for events on a Choria network and expose the | ||
observed data via a Prometheus compatible exporter. | ||
|
||
%prep | ||
%setup -q | ||
|
||
%build | ||
|
||
%install | ||
rm -rf %{buildroot} | ||
%{__install} -d -m0755 %{buildroot}/etc/sysconfig | ||
%{__install} -d -m0755 %{buildroot}/usr/lib/systemd/system | ||
%{__install} -d -m0755 %{buildroot}/etc/logrotate.d | ||
%{__install} -d -m0755 %{buildroot}%{bindir} | ||
%{__install} -d -m0755 %{buildroot}%{etcdir} | ||
%{__install} -d -m0755 %{buildroot}/var/log/%{pkgname} | ||
%{__install} -m0644 dist/%{pkgname}.service %{buildroot}/usr/lib/systemd/system/%{pkgname}.service | ||
%{__install} -m0644 dist/sysconfig %{buildroot}/etc/sysconfig/%{pkgname} | ||
%{__install} -m0644 dist/%{pkgname}-logrotate %{buildroot}/etc/logrotate.d/%{pkgname} | ||
%{__install} -m0755 %{binary} %{buildroot}%{bindir}/%{pkgname} | ||
%{__install} -m0755 dist/choria.conf %{buildroot}%{etcdir}/choria.conf | ||
|
||
touch %{buildroot}/var/log/%{pkgname}/%{pkgname}.log | ||
|
||
%clean | ||
rm -rf %{buildroot} | ||
|
||
%post | ||
if [ $1 -eq 1 ] ; then | ||
systemctl --no-reload preset %{pkgname} >/dev/null 2>&1 || : | ||
fi | ||
|
||
/bin/systemctl --system daemon-reload >/dev/null 2>&1 || : | ||
|
||
if [ $1 -ge 1 ]; then | ||
/bin/systemctl try-restart %{pkgname} >/dev/null 2>&1 || :; | ||
fi | ||
|
||
%preun | ||
if [ $1 -eq 0 ] ; then | ||
systemctl --no-reload disable --now %{pkgname} >/dev/null 2>&1 || : | ||
/usr/sbin/userdel %{pkgname} || : | ||
fi | ||
|
||
%pre | ||
/usr/bin/getent group %{pkgname} || /usr/sbin/groupadd -r %{pkgname} | ||
/usr/bin/getent passwd %{pkgname} || /usr/sbin/useradd -r -s /sbin/nologin -d /home/%{pkgname} -g %{pkgname} -c "Choria Tally Service" %{pkgname} | ||
|
||
%files | ||
%{bindir}/%{pkgname} | ||
/etc/logrotate.d/%{pkgname} | ||
/usr/lib/systemd/system/%{pkgname}.service | ||
%attr(755, %{pkgname}, %{pkgname})/var/log/%{pkgname} | ||
%config(noreplace) /etc/sysconfig/%{pkgname} | ||
%config(noreplace) %{etcdir} | ||
|
||
%changelog | ||
* Fri Nov 08 2024 R.I.Pienaar <[email protected]> | ||
- Initial Release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
required_properties: | ||
- name | ||
- etcdir | ||
- bindir | ||
- release | ||
- dist | ||
|
||
artifacts: | ||
- /usr/src/redhat/**/*.rpm | ||
- /root/rpmbuild/**/*.rpm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[Unit] | ||
Description=The Choria Tally Service | ||
After=network.target | ||
|
||
[Service] | ||
EnvironmentFile=/etc/sysconfig/{{cpkg_name}} | ||
StandardOutput=syslog | ||
StandardError=syslog | ||
User=root | ||
Group=root | ||
ExecStart={{cpkg_bindir}}/{{cpkg_name}} --component '*' --port 8080 --prefix choria_tally --config={{cpkg_etcdir}}/choria.conf | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
%define debug_package %{nil} | ||
%define pkgname {{cpkg_name}} | ||
%define version {{cpkg_version}} | ||
%define bindir {{cpkg_bindir}} | ||
%define etcdir {{cpkg_etcdir}} | ||
%define release {{cpkg_release}} | ||
%define dist {{cpkg_dist}} | ||
%define binary {{cpkg_binary}} | ||
%define tarball {{cpkg_tarball}} | ||
|
||
Name: %{pkgname} | ||
Version: %{version} | ||
Release: %{release}.%{dist} | ||
Summary: The Choria Tally Service | ||
License: Apache-2.0 | ||
URL: https://choria.io | ||
Group: System Tools | ||
Packager: R.I.Pienaar <[email protected]> | ||
Source0: %{tarball} | ||
BuildRoot: %{_tmppath}/%{pkgname}-%{version}-%{release}-root-%(%{__id_u} -n) | ||
Requires(pre): /usr/sbin/useradd, /usr/bin/getent | ||
Requires(postun): /usr/sbin/userdel | ||
|
||
%description | ||
A service that passively listen for events on a Choria network and expose the | ||
observed data via a Prometheus compatible exporter. | ||
|
||
%prep | ||
%setup -q | ||
|
||
%build | ||
|
||
%install | ||
rm -rf %{buildroot} | ||
%{__install} -d -m0755 %{buildroot}/etc/sysconfig | ||
%{__install} -d -m0755 %{buildroot}/usr/lib/systemd/system | ||
%{__install} -d -m0755 %{buildroot}/etc/logrotate.d | ||
%{__install} -d -m0755 %{buildroot}%{bindir} | ||
%{__install} -d -m0755 %{buildroot}%{etcdir} | ||
%{__install} -d -m0755 %{buildroot}/var/log/%{pkgname} | ||
%{__install} -m0644 dist/%{pkgname}.service %{buildroot}/usr/lib/systemd/system/%{pkgname}.service | ||
%{__install} -m0644 dist/sysconfig %{buildroot}/etc/sysconfig/%{pkgname} | ||
%{__install} -m0644 dist/%{pkgname}-logrotate %{buildroot}/etc/logrotate.d/%{pkgname} | ||
%{__install} -m0755 %{binary} %{buildroot}%{bindir}/%{pkgname} | ||
%{__install} -m0755 dist/choria.conf %{buildroot}%{etcdir}/choria.conf | ||
|
||
touch %{buildroot}/var/log/%{pkgname}/%{pkgname}.log | ||
|
||
%clean | ||
rm -rf %{buildroot} | ||
|
||
%post | ||
if [ $1 -eq 1 ] ; then | ||
systemctl --no-reload preset %{pkgname} >/dev/null 2>&1 || : | ||
fi | ||
|
||
/bin/systemctl --system daemon-reload >/dev/null 2>&1 || : | ||
|
||
if [ $1 -ge 1 ]; then | ||
/bin/systemctl try-restart %{pkgname} >/dev/null 2>&1 || :; | ||
fi | ||
|
||
%preun | ||
if [ $1 -eq 0 ] ; then | ||
systemctl --no-reload disable --now %{pkgname} >/dev/null 2>&1 || : | ||
/usr/sbin/userdel %{pkgname} || : | ||
fi | ||
|
||
%pre | ||
/usr/bin/getent group %{pkgname} || /usr/sbin/groupadd -r %{pkgname} | ||
/usr/bin/getent passwd %{pkgname} || /usr/sbin/useradd -r -s /sbin/nologin -d /home/%{pkgname} -g %{pkgname} -c "Choria Tally Service" %{pkgname} | ||
|
||
%files | ||
%{bindir}/%{pkgname} | ||
/etc/logrotate.d/%{pkgname} | ||
/usr/lib/systemd/system/%{pkgname}.service | ||
%attr(755, %{pkgname}, %{pkgname})/var/log/%{pkgname} | ||
%config(noreplace) /etc/sysconfig/%{pkgname} | ||
%config(noreplace) %{etcdir} | ||
|
||
%changelog | ||
* Fri Nov 08 2024 R.I.Pienaar <[email protected]> | ||
- Initial Release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
set -x | ||
|
||
TARGET_ARCH="{{cpkg_target_arch}}" | ||
TARBALL="{{cpkg_tarball}}" | ||
|
||
if [ ! -z $TARGET_ARCH ] | ||
then | ||
rpmbuild --target "${TARGET_ARCH}" -ta "${TARBALL}" | ||
else | ||
rpmbuild -ta "${TARBALL}" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# add tally user specific choria configuration |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/var/log/{{cpkg_name}}/*.log { | ||
copytruncate | ||
daily | ||
notifempty | ||
rotate 10 | ||
} |