From 85545da30c80581c3622d467d97f14997d5e89b5 Mon Sep 17 00:00:00 2001
From: Link Dupont
Date: Mon, 8 Jul 2024 11:37:08 -0400
Subject: [PATCH] Initial package (RHEL-29802)
---
.gitignore | 1 +
...d5ac3d5731750c935e1e23e9f4add49bff48.patch | 53 +++++++++++++
sources | 1 +
yggdrasil-worker-package-manager.spec | 77 +++++++++++++++++++
4 files changed, 132 insertions(+)
create mode 100644 8c19d5ac3d5731750c935e1e23e9f4add49bff48.patch
create mode 100644 sources
create mode 100644 yggdrasil-worker-package-manager.spec
diff --git a/.gitignore b/.gitignore
index e69de29..ff0d540 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
+/yggdrasil-worker-package-manager-0.2.2.tar.xz
diff --git a/8c19d5ac3d5731750c935e1e23e9f4add49bff48.patch b/8c19d5ac3d5731750c935e1e23e9f4add49bff48.patch
new file mode 100644
index 0000000..ef3555b
--- /dev/null
+++ b/8c19d5ac3d5731750c935e1e23e9f4add49bff48.patch
@@ -0,0 +1,53 @@
+From 8c19d5ac3d5731750c935e1e23e9f4add49bff48 Mon Sep 17 00:00:00 2001
+From: Link Dupont
+Date: Tue, 24 Oct 2023 20:45:45 -0400
+Subject: [PATCH] refactor: downgrade yggdrasil version to 0.4.1
+
+'latest' contains additional changes to the worker package that aren't
+released in a tagged version yet.
+---
+ go.mod | 2 +-
+ go.sum | 4 ++--
+ main.go | 1 -
+ 3 files changed, 3 insertions(+), 4 deletions(-)
+
+diff --git a/go.mod b/go.mod
+index 683d9d2..95a3e2a 100644
+--- a/go.mod
++++ b/go.mod
+@@ -6,7 +6,7 @@ require (
+ git.sr.ht/~spc/go-log v0.0.0-20210611184941-ce2f05edb627
+ github.com/google/uuid v1.3.1
+ github.com/peterbourgon/ff/v3 v3.1.0
+- github.com/redhatinsights/yggdrasil v0.0.0-20231011123719-5130298ed3ac
++ github.com/redhatinsights/yggdrasil v0.0.0-20230918163727-97cd578cc7c6
+ github.com/sgreben/flagvar v1.10.1
+ github.com/zcalusic/sysinfo v1.0.2
+ )
+diff --git a/go.sum b/go.sum
+index 6420143..5b3b778 100644
+--- a/go.sum
++++ b/go.sum
+@@ -13,8 +13,8 @@ github.com/pelletier/go-toml v1.9.4 h1:tjENF6MfZAg8e4ZmZTeWaWiT2vXtsoO6+iuOjFhEC
+ github.com/pelletier/go-toml v1.9.4/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
+ github.com/peterbourgon/ff/v3 v3.1.0 h1:5JAeDK5j/zhKFjyHEZQXwXBoDijERaos10RE+xamOsY=
+ github.com/peterbourgon/ff/v3 v3.1.0/go.mod h1:XNJLY8EIl6MjMVjBS4F0+G0LYoAqs0DTa4rmHHukKDE=
+-github.com/redhatinsights/yggdrasil v0.0.0-20231011123719-5130298ed3ac h1:rqRkjhJWxnNmmxCjxal5PrGuHtp93OCZn1PHPdQMCDQ=
+-github.com/redhatinsights/yggdrasil v0.0.0-20231011123719-5130298ed3ac/go.mod h1:Rwya3pQvxCNI/2bjNQ9N6cHTMd2YKrRCJ2sENRawoBg=
++github.com/redhatinsights/yggdrasil v0.0.0-20230918163727-97cd578cc7c6 h1:YLX/bTYS5/BwZt7vw8vIAr3vqM8tioJr3vajhSlCpzg=
++github.com/redhatinsights/yggdrasil v0.0.0-20230918163727-97cd578cc7c6/go.mod h1:Rwya3pQvxCNI/2bjNQ9N6cHTMd2YKrRCJ2sENRawoBg=
+ github.com/sgreben/flagvar v1.10.1 h1:ukN3zqVj9T9U7CiKG6owmejxswJYMbAg9Mxkhi1B4tw=
+ github.com/sgreben/flagvar v1.10.1/go.mod h1:AxDmbFDIxZ4dHj2zg8LxuJn5CSwSS28iY/Wy56e+nhI=
+ github.com/zcalusic/sysinfo v1.0.2 h1:nwTTo2a+WQ0NXwo0BGRojOJvJ/5XKvQih+2RrtWqfxc=
+diff --git a/main.go b/main.go
+index 719f304..280e7ce 100644
+--- a/main.go
++++ b/main.go
+@@ -84,7 +84,6 @@ func main() {
+ "package_manager",
+ false,
+ map[string]string{"version": Version},
+- nil,
+ dataRx,
+ nil,
+ )
diff --git a/sources b/sources
new file mode 100644
index 0000000..03cf23f
--- /dev/null
+++ b/sources
@@ -0,0 +1 @@
+SHA512 (yggdrasil-worker-package-manager-0.2.2.tar.xz) = 91a44e6b99c36bf0791f298d6ea2dfc9aacb4098b1f0b6305ef4084f5774eef55a3e309cff99915e0e28cf3a06dba797c66915975fba08fc0423f18f97cd5990
diff --git a/yggdrasil-worker-package-manager.spec b/yggdrasil-worker-package-manager.spec
new file mode 100644
index 0000000..8b84463
--- /dev/null
+++ b/yggdrasil-worker-package-manager.spec
@@ -0,0 +1,77 @@
+%bcond_without check
+
+# https://github.com/redhatinsights/yggdrasil-worker-package-manager
+%global goipath github.com/redhatinsights/yggdrasil-worker-package-manager
+Version: 0.2.2
+%global tag %{version}
+
+%gometa -f
+
+%global common_description %{expand:
+yggdrasil-worker-package-manager is a simple package manager yggd worker. It
+knows how to install and remove packages, add, remove, enable and disable
+repositories, and does rudimentary detection of the host it is running on to
+guess the package manager to use. It only installs packages that match one of
+the provided allow-pattern regular expressions.}
+
+%global golicenses LICENSE
+%global godocs README.md
+
+Name: yggdrasil-worker-package-manager
+Release: 1%{?dist}
+Summary: Package manager worker for yggdrasil
+
+License: GPL-3.0-only
+URL: %{gourl}
+Source: %{url}/releases/download/%{version}/%{name}-%{version}.tar.xz
+
+Patch100: 8c19d5ac3d5731750c935e1e23e9f4add49bff48.patch
+
+BuildRequires: systemd-rpm-macros
+BuildRequires: meson
+BuildRequires: pkgconfig(dbus-1)
+
+%description %{common_description}
+
+%gopkg
+
+%prep
+%goprep %{?rhel:-k}
+%autopatch -p1 %{?rhel:-M 99}
+
+%if %{undefined rhel}
+%generate_buildrequires
+%go_generate_buildrequires
+%endif
+
+%build
+%undefine _auto_set_build_flags
+export %gomodulesmode
+%{?gobuilddir:export GOPATH="%{gobuilddir}:${GOPATH:+${GOPATH}:}%{?gopath}"}
+%meson "-Dgobuildflags=[%(echo %{expand:%gocompilerflags} | sed -e s/"^"/"'"/ -e s/" "/"', '"/g -e s/"$"/"'"/), '-tags', '"rpm_crashtraceback\ ${BUILDTAGS:-}"', '-a', '-v', '-x']" -Dgoldflags='%{?currentgoldflags} -B 0x%(head -c20 /dev/urandom|od -An -tx1|tr -d " \n") -compressdwarf=false -linkmode=external -extldflags "%{build_ldflags} %{?__golang_extldflags}"'
+%meson_build
+
+%install
+%meson_install
+%gopkginstall
+
+%if %{with check}
+%check
+%gocheck
+%endif
+
+%files
+%license LICENSE
+%if %{defined rhel}
+%license vendor/modules.txt
+%endif
+%doc README.md
+%{_libexecdir}/*
+%config(noreplace) %{_sysconfdir}/%{name}
+%{_datadir}/dbus-1/system-services/*
+
+%gopkgfiles
+
+%changelog
+* Mon Jul 8 2024 Link Dupont - 0.2.2-1
+- Initial package (RHEL-29802)