Skip to content

Commit 7358f4d

Browse files
author
Gabriel Monroy
committed
fix(update): extract update to root
1 parent 1d629e5 commit 7358f4d

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

updatectl/instance.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
update "github.com/coreos/updatectl/client/update/v1"
1919
"github.com/deis/deisctl/client"
2020
"github.com/deis/deisctl/cmd"
21-
"github.com/deis/deisctl/constant"
21+
_ "github.com/deis/deisctl/constant"
2222
"github.com/deis/deisctl/utils"
2323
)
2424

@@ -134,13 +134,13 @@ func (c *Client) updateservice() {
134134
// post-install hook (make sure upgrade was successful)
135135
}
136136

137-
func (c *Client) downloadFromUrl(url, fileName string) (err error) {
138-
fmt.Printf("Downloading %s to %s", url, fileName)
137+
func (c *Client) downloadFromUrl(url, filePath string) (err error) {
138+
fmt.Printf("Downloading %s to %s", url, filePath)
139139

140140
// TODO: check file existence first with io.IsExist
141-
output, err := os.Create(constant.UnitsDir + fileName)
141+
output, err := os.Create(filePath)
142142
if err != nil {
143-
fmt.Println("Error while creating", fileName, "-", err)
143+
fmt.Println("Error while creating", filePath, "-", err)
144144
return
145145
}
146146
defer output.Close()
@@ -233,8 +233,8 @@ func (c *Client) SetVersion(resp *omaha.Response) {
233233
uc := resp.Apps[0].UpdateCheck
234234
url := c.getCodebaseUrl(uc)
235235
c.MakeRequest("13", "1", false, false)
236-
c.downloadFromUrl(url, "deis.tar.gz")
237-
utils.Extract(constant.UnitsDir+"deis.tar.gz", constant.UnitsDir)
236+
c.downloadFromUrl(url, "/tmp/deis.tar.gz")
237+
utils.Extract("/tmp/deis.tar.gz", "/")
238238
c.MakeRequest("14", "1", false, false)
239239
c.updateservice()
240240
fmt.Println("Installation done")

utils/utils.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func GetMachineID(root string) string {
7474
func GetVersion() string {
7575
id, err := ioutil.ReadFile(constant.Version)
7676
if err != nil {
77-
return os.Getenv("DEISCTL_APP_VERSION")
77+
return "0.0.0"
7878
}
7979
return strings.TrimSpace(string(id))
8080
}
@@ -116,7 +116,7 @@ func Chdir(app string) error {
116116
func Extract(file, dir string) {
117117
var wd, _ = os.Getwd()
118118
_ = os.Chdir(dir)
119-
cmdl := exec.Command("tar", "-xvf", file)
119+
cmdl := exec.Command("tar", "-C", "/", "-xvf", file)
120120
if _, _, err := RunCommandWithStdoutStderr(cmdl); err != nil {
121121
fmt.Printf("Failed:\n%v", err)
122122
} else {

0 commit comments

Comments
 (0)