Add profilesutil.Untar.
Needed by the new nodejs profile.
MultiPart: 2/5
Change-Id: I77ae9ce9164ff89375e0b225d411b875029b8f78
diff --git a/profiles/profilesutil/.api b/profiles/profilesutil/.api
index b7d25d7..a739ac6 100644
--- a/profiles/profilesutil/.api
+++ b/profiles/profilesutil/.api
@@ -4,4 +4,5 @@
pkg profilesutil, func Fetch(*jiri.X, string, string) error
pkg profilesutil, func InstallPackages(*jiri.X, []string) error
pkg profilesutil, func IsFNLHost() bool
+pkg profilesutil, func Untar(*jiri.X, string, string) error
pkg profilesutil, func Unzip(*jiri.X, string, string) error
diff --git a/profiles/profilesutil/util.go b/profiles/profilesutil/util.go
index 4be95c4..c3f73e7 100644
--- a/profiles/profilesutil/util.go
+++ b/profiles/profilesutil/util.go
@@ -159,6 +159,17 @@
return file.Close()
}
+// Untar untars the file in srcFile and puts resulting files in directory dstDir.
+func Untar(jirix *jiri.X, srcFile, dstDir string) error {
+ s := jirix.NewSeq()
+ if err := s.MkdirAll(dstDir, 0755).Done(); err != nil {
+ return err
+ }
+ return s.Output([]string{"untarring " + srcFile + " into " + dstDir}).
+ Pushd(dstDir).
+ Last("tar", "xvf", srcFile)
+}
+
// Unzip unzips the file in srcFile and puts resulting files in directory dstDir.
func Unzip(jirix *jiri.X, srcFile, dstDir string) error {
r, err := zip.OpenReader(srcFile)