From 2ac9acdbb8bd06cf880491614733f619dc827aba Mon Sep 17 00:00:00 2001
From: Rune Morling <ermo@serpentos.com>
Date: Thu, 12 Sep 2024 23:28:08 +0200
Subject: [PATCH] Use nuitka-compiled py3 eopkg.bin instead eopkg.py2

In various tests, this is showing a speedup for install operations on the
order of 20-25%.

This is also part of the preparation for dropping the py2 pisi package
(which owns the `eopkg` symlink at the time of this writing).

Signed-off-by: Rune Morling <ermo@serpentos.com>
---
 builder/build.go |  2 +-
 builder/eopkg.go | 10 +++++-----
 builder/index.go |  2 +-
 builder/repos.go |  2 +-
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/builder/build.go b/builder/build.go
index 92d426f..aae495a 100644
--- a/builder/build.go
+++ b/builder/build.go
@@ -382,7 +382,7 @@ func (p *Package) BuildXML(notif PidNotifier, pman *EopkgManager, overlay *Overl
 
 	// Now build the package, ignore-sandbox in case someone is stupid
 	// and activates it in eopkg.conf...
-	cmd := eopkgCommand(fmt.Sprintf("eopkg build --ignore-sandbox --yes-all -O %s %s", wdir, xmlFile))
+	cmd := eopkgCommand(fmt.Sprintf("eopkg.bin build --ignore-sandbox --yes-all -O %s %s", wdir, xmlFile))
 
 	slog.Info("Now starting build", "package", p.Name)
 
diff --git a/builder/eopkg.go b/builder/eopkg.go
index 1c0c887..cd024a2 100644
--- a/builder/eopkg.go
+++ b/builder/eopkg.go
@@ -207,19 +207,19 @@ func (e *EopkgManager) Upgrade() error {
 		"sccache",
 	}
 
-	if err := ChrootExec(e.notif, e.root, eopkgCommand("eopkg upgrade -y")); err != nil {
+	if err := ChrootExec(e.notif, e.root, eopkgCommand("eopkg.bin upgrade -y")); err != nil {
 		return err
 	}
 
 	e.notif.SetActivePID(0)
-	err := ChrootExec(e.notif, e.root, eopkgCommand(fmt.Sprintf("eopkg install -y %s", strings.Join(newReqs, " "))))
+	err := ChrootExec(e.notif, e.root, eopkgCommand(fmt.Sprintf("eopkg.bin install -y %s", strings.Join(newReqs, " "))))
 
 	return err
 }
 
 // InstallComponent will install the named component inside the chroot.
 func (e *EopkgManager) InstallComponent(comp string) error {
-	err := ChrootExec(e.notif, e.root, eopkgCommand(fmt.Sprintf("eopkg install -c %v -y", comp)))
+	err := ChrootExec(e.notif, e.root, eopkgCommand(fmt.Sprintf("eopkg.bin install -c %v -y", comp)))
 	e.notif.SetActivePID(0)
 
 	return err
@@ -325,11 +325,11 @@ func (e *EopkgManager) GetRepos() ([]*EopkgRepo, error) {
 // AddRepo will attempt to add a repo to the filesystem.
 func (e *EopkgManager) AddRepo(id, source string) error {
 	e.notif.SetActivePID(0)
-	return ChrootExec(e.notif, e.root, eopkgCommand(fmt.Sprintf("eopkg add-repo '%s' '%s'", id, source)))
+	return ChrootExec(e.notif, e.root, eopkgCommand(fmt.Sprintf("eopkg.bin add-repo '%s' '%s'", id, source)))
 }
 
 // RemoveRepo will attempt to remove a named repo from the filesystem.
 func (e *EopkgManager) RemoveRepo(id string) error {
 	e.notif.SetActivePID(0)
-	return ChrootExec(e.notif, e.root, eopkgCommand(fmt.Sprintf("eopkg remove-repo '%s'", id)))
+	return ChrootExec(e.notif, e.root, eopkgCommand(fmt.Sprintf("eopkg.bin remove-repo '%s'", id)))
 }
diff --git a/builder/index.go b/builder/index.go
index 6399fa5..1e94f87 100644
--- a/builder/index.go
+++ b/builder/index.go
@@ -76,7 +76,7 @@ func (p *Package) Index(notif PidNotifier, dir string, overlay *Overlay) error {
 
 	slog.Debug("Now indexing")
 
-	command := fmt.Sprintf("cd %s; %s", IndexBindTarget, eopkgCommand("eopkg index --skip-signing ."))
+	command := fmt.Sprintf("cd %s; %s", IndexBindTarget, eopkgCommand("eopkg.bin index --skip-signing ."))
 	if err := ChrootExec(notif, overlay.MountPoint, command); err != nil {
 		slog.Error("Indexing failed", "dir", dir, "err", err)
 		return err
diff --git a/builder/repos.go b/builder/repos.go
index ff5ef3b..55f1a91 100644
--- a/builder/repos.go
+++ b/builder/repos.go
@@ -58,7 +58,7 @@ func (p *Package) addLocalRepo(notif PidNotifier, o *Overlay, pkgManager *EopkgM
 	if repo.AutoIndex {
 		slog.Debug("Reindexing repository", "name", repo.Name)
 
-		command := fmt.Sprintf("cd %s/%s; %s", BindRepoDir, repo.Name, eopkgCommand("eopkg index --skip-signing ."))
+		command := fmt.Sprintf("cd %s/%s; %s", BindRepoDir, repo.Name, eopkgCommand("eopkg.bin index --skip-signing ."))
 		err := ChrootExec(notif, o.MountPoint, command)
 		notif.SetActivePID(0)