summarylogtreecommitdiffstats
path: root/use-unzip-for-eopkg.patch
blob: 592c3504b760c91093fac3f8d26f58feb00dd0ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
From cfa7b0ad93b5c848ade2beb89ba1b60c597a9a8b Mon Sep 17 00:00:00 2001
From: Ikey Doherty <ikey@solus-project.com>
Date: Wed, 22 Nov 2017 19:12:26 +0000
Subject: [PATCH] explode/eopkg: Use a portable function to explode the eopkg

This function is much like the RPM explosion helper, by using a simple
pipe to get directly to the contents of the package. Here we simply
pipe unzip to tar xf, explicitly passing the `install.tar.xz` payload
to tar. Internally an eopkg is simply a ZIP file with a tarball payload
and some XML data, so this is always going to work.

Signed-off-by: Ikey Doherty <ikey@solus-project.com>
---
 src/explode/eopkg.go | 39 ++++++++++++++++++++++++++++++---------
 1 file changed, 30 insertions(+), 9 deletions(-)

diff --git a/src/explode/eopkg.go b/src/explode/eopkg.go
index cea004d..2ecdca5 100644
--- a/src/explode/eopkg.go
+++ b/src/explode/eopkg.go
@@ -17,20 +17,21 @@
 package explode
 
 import (
+	"io"
 	"io/ioutil"
-	"os"
 	"os/exec"
 	"path/filepath"
 	"strings"
 )
 
-// Eopkg will explode all .eopkg's specified and then return
-// the install/ path inside that exploded tree.
+// Eopkg will explode all eopkgs passed to it and return the path to
+// the "root" to walk.
 func Eopkg(pkgs []string) (string, error) {
 	rootDir, err := ioutil.TempDir("", "abireport-eopkg")
 	if err != nil {
 		return "", err
 	}
+
 	// Ensure cleanup happens
 	OutputDir = rootDir
 
@@ -43,17 +44,37 @@ func Eopkg(pkgs []string) (string, error) {
 		if strings.HasSuffix(archive, ".delta.eopkg") {
 			continue
 		}
-		eopkg := exec.Command("uneopkg", []string{
+
+		eopkg := exec.Command("unzip", []string{
+			"-p",
 			fp,
+			"install.tar.xz",
+		}...)
+		tar := exec.Command("tar", []string{
+			"-xJf",
+			"-",
 		}...)
-		eopkg.Stdout = nil
-		eopkg.Stderr = os.Stderr
-		eopkg.Dir = rootDir
+		// Pipe eopkg into tar
+		r, w := io.Pipe()
+		defer r.Close()
+		eopkg.Stdout = w
+		tar.Stdin = r
+		tar.Stdout = nil
+		tar.Stderr = nil
+		tar.Dir = rootDir
 
-		if err = eopkg.Run(); err != nil {
+		eopkg.Start()
+		tar.Start()
+		go func() {
+			defer w.Close()
+			eopkg.Wait()
+		}()
+		if err := tar.Wait(); err != nil {
+			r.Close()
 			return "", err
 		}
+		r.Close()
 	}
 
-	return filepath.Join(rootDir, "install"), nil
+	return rootDir, nil
 }