Skip to content

Commit

Permalink
extract binaries with .exe name on windows
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Jeromy <[email protected]>
  • Loading branch information
whyrusleeping committed Aug 1, 2016
1 parent 149819f commit fca5b34
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 13 additions & 2 deletions repo/fsrepo/migrations/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,18 @@ func init() {

const migrations = "fs-repo-migrations"

func migrationsBinName() string {
switch runtime.GOOS {
case "windows":
return migrations + ".exe"
default:
return migrations
}
}

func RunMigration(newv int) error {
migrateBin := "fs-repo-migrations"
migrateBin := migrationsBinName()

fmt.Println(" => checking for migrations binary...")

var err error
Expand Down Expand Up @@ -78,7 +88,7 @@ func GetMigrations() (string, error) {
return "", fmt.Errorf("tempdir: %s", err)
}

out := filepath.Join(dir, migrations)
out := filepath.Join(dir, migrationsBinName())

err = GetBinaryForVersion(migrations, migrations, DistPath, latest, out)
if err != nil {
Expand Down Expand Up @@ -202,6 +212,7 @@ func GetBinaryForVersion(distname, binnom, root, vers, out string) error {
switch runtime.GOOS {
case "windows":
archive = "zip"
binnom += ".exe"
default:
archive = "tar.gz"
}
Expand Down
2 changes: 1 addition & 1 deletion repo/fsrepo/migrations/unpack.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func unpackZip(dist, binnom, path, out string) error {

var bin io.ReadCloser
for _, fis := range zipr.File {
if fis.Name == dist+"/"+binnom+".exe" {
if fis.Name == dist+"/"+binnom {
rc, err := fis.Open()
if err != nil {
return fmt.Errorf("error extracting binary from archive: %s", err)
Expand Down

0 comments on commit fca5b34

Please sign in to comment.