From 04e74e184f55ed3755f39b157f2c71bb3da6296e Mon Sep 17 00:00:00 2001
From: madomado <madonuko@outlook.com>
Date: Wed, 8 May 2024 15:32:50 +0800
Subject: [PATCH 1/2] add: dnf5-default-package-manager

---
 comps.xml                                     |  1 +
 .../dnf5-default-package-manager/anda.hcl     |  5 ++
 .../dnf5-default-package-manager.spec         | 51 +++++++++++++++++++
 3 files changed, 57 insertions(+)
 create mode 100644 ultramarine/dnf5-default-package-manager/anda.hcl
 create mode 100644 ultramarine/dnf5-default-package-manager/dnf5-default-package-manager.spec

diff --git a/comps.xml b/comps.xml
index a6bbfc6..eaafd7e 100644
--- a/comps.xml
+++ b/comps.xml
@@ -30,6 +30,7 @@
       <packagereq type="default">ultramarine-shell-config</packagereq>
       <packagereq type="default">ultramarine-release</packagereq>
       <packagereq type="default">ultramarine-fun</packagereq>
+      <packagereq type="optional">dnf5-default-package-manager</packagereq>
       <packagereq type="default">git</packagereq>
     </packagelist>
   </group>
diff --git a/ultramarine/dnf5-default-package-manager/anda.hcl b/ultramarine/dnf5-default-package-manager/anda.hcl
new file mode 100644
index 0000000..e807dc4
--- /dev/null
+++ b/ultramarine/dnf5-default-package-manager/anda.hcl
@@ -0,0 +1,5 @@
+project pkg {
+  rpm {
+    spec = "dnf5-default-package-manager.spec"
+  }
+}
diff --git a/ultramarine/dnf5-default-package-manager/dnf5-default-package-manager.spec b/ultramarine/dnf5-default-package-manager/dnf5-default-package-manager.spec
new file mode 100644
index 0000000..9406382
--- /dev/null
+++ b/ultramarine/dnf5-default-package-manager/dnf5-default-package-manager.spec
@@ -0,0 +1,51 @@
+%define debug_package %nil
+
+Name:       dnf5-default-package-manager
+Version:    0
+Release:    1%?dist
+Summary:    Package that sets dnf5 as the default package manager
+URL:        https://wiki.ultramarine-linux.org/en/usage/um40-dnf5/
+Requires:   dnf5
+
+%description
+This package contains post-install hooks that symlinks %_bindir/dnf
+to the new dnf5 binary.
+
+%prep
+cat<<EOF > README
+The `%name` package replaces `%_bindir/dnf` and `%_bindir/yum` to
+point to `%_bindir/dnf5`. For more information, please visit:
+%url
+EOF
+
+%build
+
+%install
+
+%posttrans
+if [ $1 -gt 1 ]; then
+  rm %_bindir/{dnf,yum}
+  ln -s %_bindir/dnf5 /usr/bin/dnf
+  ln -s %_bindir/dnf5 /usr/bin/yum
+fi
+
+%preun
+rm %_bindir/{dnf,yum}
+ln -s /usr/bin/dnf-3 /usr/bin/dnf
+ln -s %_bindir/dnf-3 /usr/bin/yum
+
+%triggerin -- dnf
+rm %_bindir/{dnf,yum}
+ln -s %_bindir/dnf5 /usr/bin/dnf
+ln -s %_bindir/dnf5 /usr/bin/yum
+
+%triggerin -- yum
+rm %_bindir/{dnf,yum}
+ln -s %_bindir/dnf5 /usr/bin/dnf
+ln -s %_bindir/dnf5 /usr/bin/yum
+
+%files
+%doc README
+
+%changelog
+%autochangelog

From 7cbd660a8ee7ef1da5c0904ceb6ffece4c25cb6c Mon Sep 17 00:00:00 2001
From: madomado <wboy111@outlook.com>
Date: Wed, 8 May 2024 15:40:06 +0800
Subject: [PATCH 2/2] Update dnf5-default-package-manager.spec

---
 .../dnf5-default-package-manager.spec                            | 1 +
 1 file changed, 1 insertion(+)

diff --git a/ultramarine/dnf5-default-package-manager/dnf5-default-package-manager.spec b/ultramarine/dnf5-default-package-manager/dnf5-default-package-manager.spec
index 9406382..2b4f14c 100644
--- a/ultramarine/dnf5-default-package-manager/dnf5-default-package-manager.spec
+++ b/ultramarine/dnf5-default-package-manager/dnf5-default-package-manager.spec
@@ -4,6 +4,7 @@ Name:       dnf5-default-package-manager
 Version:    0
 Release:    1%?dist
 Summary:    Package that sets dnf5 as the default package manager
+License:    MIT
 URL:        https://wiki.ultramarine-linux.org/en/usage/um40-dnf5/
 Requires:   dnf5