diff --git a/Jenkinsfile b/Jenkinsfile index 50d05e6..ac07592 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -40,15 +40,9 @@ pipeline { agent { - dockerfile - { - filename 'packaging/RHEL9.Dockerfile' - } - } - environment - { - DOTNET_CLI_HOME = "/tmp/.dotnet" + dockerfile { filename 'packaging/RHEL9.Dockerfile' } } + environment { DOTNET_CLI_HOME = "/tmp/.dotnet" } when { expression @@ -58,25 +52,19 @@ pipeline } steps { - sh 'rpmbuild -bb packaging/supportchild-nightly.spec --define "_topdir $PWD/.rpmbuild-el9"' + sh 'rpmbuild -bb packaging/supportchild.spec --define "_topdir $PWD/.rpmbuild-el9" --define "dev_build true"' sh 'mkdir linux-x64' - sh 'cp .rpmbuild-el9/RPMS/x86_64/supportchild-nightly-*.el9.x86_64.rpm linux-x64/' - archiveArtifacts(artifacts: 'linux-x64/supportchild-nightly-*.el9.x86_64.rpm', caseSensitive: true) + sh 'cp .rpmbuild-el9/RPMS/x86_64/supportchild-dev-*.el9.x86_64.rpm linux-x64/' + archiveArtifacts(artifacts: 'linux-x64/supportchild-dev-*.el9.x86_64.rpm', caseSensitive: true) } } stage('RHEL8') { agent { - dockerfile - { - filename 'packaging/RHEL8.Dockerfile' - } - } - environment - { - DOTNET_CLI_HOME = "/tmp/.dotnet" + dockerfile { filename 'packaging/RHEL8.Dockerfile' } } + environment { DOTNET_CLI_HOME = "/tmp/.dotnet" } when { expression @@ -86,10 +74,10 @@ pipeline } steps { - sh 'rpmbuild -bb packaging/supportchild-nightly.spec --define "_topdir $PWD/.rpmbuild-el8"' + sh 'rpmbuild -bb packaging/supportchild.spec --define "_topdir $PWD/.rpmbuild-el8" --define "dev_build true"' sh 'mkdir linux-x64' - sh 'cp .rpmbuild-el8/RPMS/x86_64/supportchild-nightly-*.el8.x86_64.rpm linux-x64/' - archiveArtifacts(artifacts: 'linux-x64/supportchild-nightly-*.el8.x86_64.rpm', caseSensitive: true) + sh 'cp .rpmbuild-el8/RPMS/x86_64/supportchild-dev-*.el8.x86_64.rpm linux-x64/' + archiveArtifacts(artifacts: 'linux-x64/supportchild-dev-*.el8.x86_64.rpm', caseSensitive: true) } } } diff --git a/packaging/supportchild-nightly.spec b/packaging/supportchild-nightly.spec deleted file mode 100644 index b8c87f4..0000000 --- a/packaging/supportchild-nightly.spec +++ /dev/null @@ -1,58 +0,0 @@ -%global debug_package %{nil} -%global repo_root %{_topdir}/.. - -Summary: A support ticket Discord bot -Name: supportchild-nightly -Version: %(sed -ne '/Version/{s/.*<Version>\(.*\)<\/Version>.*/\1/p;q;}' < SupportChild.csproj) -Release: %(date "+%%Y%%m%%d%%H%%M%%S")%{?dist} -License: GPLv3 -URL: https://toastielab.dev/toastie-stuff/SupportChild -Source: https://toastielab.dev/toastie-stuff/SupportChild/archive/main.zip -Packager: Toastie_t0ast - -BuildRequires: systemd-rpm-macros -Requires: dotnet-runtime-9.0 -%{?systemd_requires} - -%description -A support ticket Discord bot. Uses a MySQL database for storage of ticket -information. Creates formatted HTML ticket transcripts when tickets are closed. - -%prep -%setup -T -c - -%build -dotnet publish %{repo_root}/SupportChild.csproj -p:PublishSingleFile=true -r linux-x64 -c Release --self-contained false --output %{_builddir}/out - -%install -%{__install} -d %{buildroot}/usr/bin -%{__install} %{_builddir}/out/supportchild %{buildroot}/usr/bin/supportchild -# rpmbuild post-processing using the strip command breaks dotnet binaries, remove the executable bit to avoid it -chmod 644 %{buildroot}/usr/bin/supportchild - -%{__install} -d %{buildroot}/usr/lib/systemd/system -%{__install} %{repo_root}/packaging/supportchild.service %{buildroot}/usr/lib/systemd/system/ - -%{__install} -d %{buildroot}/etc/supportchild/ -%{__install} %{repo_root}/default_config.yml %{buildroot}/etc/supportchild/config.yml - -%pre -getent group supportchild > /dev/null || groupadd supportchild -getent passwd supportchild > /dev/null || useradd -r -s /sbin/nologin -g supportchild supportchild - -%post -%systemd_post supportchild.service - -%preun -%systemd_preun supportchild.service - -%postun -%systemd_postun_with_restart supportchild.service -if [[ "$1" == "0" ]]; then - getent passwd supportchild > /dev/null && userdel supportchild -fi - -%files -%attr(0755,root,root) /usr/bin/supportchild -%attr(0644,root,root) /usr/lib/systemd/system/supportchild.service -%config %attr(0600, supportchild, supportchild) /etc/supportchild/config.yml \ No newline at end of file diff --git a/packaging/supportchild.service b/packaging/supportchild.service index a981d80..350d5cc 100644 --- a/packaging/supportchild.service +++ b/packaging/supportchild.service @@ -6,7 +6,7 @@ Wants=network.target [Service] User=supportchild -ExecStart=/usr/bin/supportchild --config /etc/supportchild/config.yml +ExecStart=/usr/bin/supportchild --config /etc/supportchild/config.yml --transcripts /var/lib/supportboi/transcripts Restart=no Type=exec diff --git a/packaging/supportchild.spec b/packaging/supportchild.spec index 6c60e91..d2c690b 100644 --- a/packaging/supportchild.spec +++ b/packaging/supportchild.spec @@ -1,14 +1,22 @@ %global debug_package %{nil} %global repo_root %{_topdir}/.. +%global base_version %(echo "$(sed -ne '/Version/{s/.*<Version>\\(.*\\)<\\/Version>.*/\\1/p;q;}' < SupportChild.csproj)") -Summary: A support ticket Discord bot +%if %{defined dev_build} +Name: supportchild-dev +Summary: A support ticket Discord bot (dev build) +Version: %{base_version}~%(date "+%%Y%%m%%d%%H%%M%%S")git%(git rev-parse --short HEAD) +Source: https://toastielab.dev/toastie-stuff/SupportChild/archive/%(git rev-parse HEAD).zip +%else Name: supportchild -Version: %(sed -ne '/Version/{s/.*<Version>\(.*\)<\/Version>.*/\1/p;q;}' < SupportChild.csproj) +Summary: A support ticket Discord bot +Version: %{base_version} +Source: https://toastielab.dev/toastie-stuff/SupportChild/archive/%{base_version}.zip +%endif Release: 1%{?dist} License: GPLv3 URL: https://toastielab.dev/toastie-stuff/SupportChild -Source: https://toastielab.dev/toastie-stuff/SupportChild/archive/main.zip -Packager: Toastie_t0ast +Packager: KarlofDuty BuildRequires: systemd-rpm-macros Requires: dotnet-runtime-9.0 @@ -25,20 +33,25 @@ information. Creates formatted HTML ticket transcripts when tickets are closed. dotnet publish %{repo_root}/SupportChild.csproj -p:PublishSingleFile=true -r linux-x64 -c Release --self-contained false --output %{_builddir}/out %install +if [[ -d %{_rpmdir}/%{_arch} ]]; then + %{__rm} %{_rpmdir}/%{_arch}/* +fi + %{__install} -d %{buildroot}/usr/bin -%{__install} %{_builddir}/out/supportchild %{buildroot}/usr/bin/supportchild # rpmbuild post-processing using the strip command breaks dotnet binaries, remove the executable bit to avoid it -chmod 644 %{buildroot}/usr/bin/supportchild +%{__install} -m 644 %{_builddir}/out/supportchild %{buildroot}/usr/bin/supportchild %{__install} -d %{buildroot}/usr/lib/systemd/system -%{__install} %{repo_root}/packaging/supportchild.service %{buildroot}/usr/lib/systemd/system/ +%{__install} -m 644 %{repo_root}/packaging/supportchild.service %{buildroot}/usr/lib/systemd/system/ %{__install} -d %{buildroot}/etc/supportchild/ -%{__install} %{repo_root}/default_config.yml %{buildroot}/etc/supportchild/config.yml +%{__install} -m 600 %{repo_root}/default_config.yml %{buildroot}/etc/supportchild/config.yml + +%{__install} -d %{buildroot}/var/lib/supportchild/transcripts %pre getent group supportchild > /dev/null || groupadd supportchild -getent passwd supportchild > /dev/null || useradd -r -s /sbin/nologin -g supportchild supportchild +getent passwd supportchild > /dev/null || useradd -r -m -d /var/lib/supportchild -s /sbin/nologin -g supportchild supportchild %post %systemd_post supportchild.service @@ -55,4 +68,6 @@ fi %files %attr(0755,root,root) /usr/bin/supportchild %attr(0644,root,root) /usr/lib/systemd/system/supportchild.service -%config %attr(0600, supportchild, supportchild) /etc/supportchild/config.yml \ No newline at end of file +%config %attr(0600, supportchild, supportchild) /etc/supportchild/config.yml +%dir %attr(0700, supportchild, supportchild) /var/lib/supportchild +%dir %attr(0755, supportchild, supportchild) /var/lib/supportchild/transcripts \ No newline at end of file