From 8d2b41c0810a9008cb8f0be42ec7b1178326293e Mon Sep 17 00:00:00 2001 From: develar Date: Mon, 5 Mar 2018 08:06:00 +0100 Subject: [PATCH] fix(snap): command.sh is not copied if template and docker are not used Close: https://github.com/electron-userland/electron-builder/issues/2661 --- .gitignore | 3 ++- .idea/dictionaries/develar.xml | 2 ++ app-builder-bin/linux/package.json | 2 +- app-builder-bin/mac/package.json | 2 +- app-builder-bin/package.json | 8 ++++---- app-builder-bin/win/package.json | 2 +- main.go | 2 +- pkg/appimage/appImage.go | 4 ++-- pkg/snap/snap.go | 5 +++++ pkg/util/tempfile.go | 16 ++++++++-------- scripts/build.sh | 2 +- 11 files changed, 28 insertions(+), 20 deletions(-) diff --git a/.gitignore b/.gitignore index 142e7f6..f963431 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ vendor/ app-builder-bin/readme.md app-builder-bin/**/app-builder -app-builder-bin/win/**/app-builder.exe \ No newline at end of file +app-builder-bin/win/**/app-builder.exe +.virtualgo \ No newline at end of file diff --git a/.idea/dictionaries/develar.xml b/.idea/dictionaries/develar.xml index ed6d982..24444a7 100644 --- a/.idea/dictionaries/develar.xml +++ b/.idea/dictionaries/develar.xml @@ -6,11 +6,13 @@ blockmap chunking geoip + goreleaser lintian mksquashfs ostype snapcore umask + virtualgo \ No newline at end of file diff --git a/app-builder-bin/linux/package.json b/app-builder-bin/linux/package.json index ed765e8..82dbd08 100644 --- a/app-builder-bin/linux/package.json +++ b/app-builder-bin/linux/package.json @@ -1,7 +1,7 @@ { "name": "app-builder-bin-linux", "description": "app-builder Linux binary", - "version": "1.5.0", + "version": "1.5.1", "license": "MIT", "repository": "develar/app-builder-bin", "files": [ diff --git a/app-builder-bin/mac/package.json b/app-builder-bin/mac/package.json index 6a18eca..f27bfe1 100644 --- a/app-builder-bin/mac/package.json +++ b/app-builder-bin/mac/package.json @@ -1,7 +1,7 @@ { "name": "app-builder-bin-mac", "description": "app-builder macOS binary", - "version": "1.5.0", + "version": "1.5.1", "license": "MIT", "repository": "develar/app-builder-bin", "files": [ diff --git a/app-builder-bin/package.json b/app-builder-bin/package.json index 69b09d1..baf5369 100644 --- a/app-builder-bin/package.json +++ b/app-builder-bin/package.json @@ -1,7 +1,7 @@ { "name": "app-builder-bin", "description": "app-builder precompiled binaries", - "version": "1.5.0", + "version": "1.5.1", "files": [ "*.js", "index.d.ts" @@ -9,9 +9,9 @@ "license": "MIT", "repository": "develar/app-builder", "optionalDependencies": { - "app-builder-bin-mac": "1.5.0", - "app-builder-bin-win": "1.5.0", - "app-builder-bin-linux": "1.5.0" + "app-builder-bin-mac": "1.5.1", + "app-builder-bin-win": "1.5.1", + "app-builder-bin-linux": "1.5.1" }, "keywords": [ "snap", diff --git a/app-builder-bin/win/package.json b/app-builder-bin/win/package.json index 88a206a..efb17fb 100644 --- a/app-builder-bin/win/package.json +++ b/app-builder-bin/win/package.json @@ -1,7 +1,7 @@ { "name": "app-builder-bin-win", "description": "app-builder Windows binary", - "version": "1.5.0", + "version": "1.5.1", "license": "MIT", "repository": "develar/app-builder-bin", "files": [ diff --git a/main.go b/main.go index bd4c920..6180ab0 100644 --- a/main.go +++ b/main.go @@ -24,7 +24,7 @@ import ( ) var ( - appVersion = "1.5.0" + appVersion = "1.5.1" app = kingpin.New("app-builder", "app-builder").Version(appVersion) buildBlockMap = app.Command("blockmap", "Generates file block map for differential update using content defined chunking (that is robust to insertions, deletions, and changes to input file)") diff --git a/pkg/appimage/appImage.go b/pkg/appimage/appImage.go index 53c3160..0747f5d 100644 --- a/pkg/appimage/appImage.go +++ b/pkg/appimage/appImage.go @@ -16,7 +16,7 @@ import ( ) //noinspection GoSnakeCaseUsage,SpellCheckingInspection -const APPIMAGE_TOOL_SHA512 = "HoPbFchLZwbTGLl47bVoir+NDunpPp5yGbpKtbrET4gUY/SlRYW2GpCNgkaZetO+PExkIzk7X3NHpmM8HwKjiQ==" +const APPIMAGE_TOOL_SHA512 = "at5M33iNSAOzOGEvPpbeMsrULbRpEv8jfKYcRxK+uZ+f3+xT/AUbtuqlnZ+CFTSjUjOqjrJyJAILnVDP0tnpjg==" type AppImageOptions struct { appDir *string @@ -59,7 +59,7 @@ func ConfigureCommand(app *kingpin.Application) { } func GetAppImageToolDir() (string, error) { - dirName := "appimage-9.0.7" + dirName := "appimage-9.0.9" result, err := download.DownloadArtifact("", "https://github.com/electron-userland/electron-builder-binaries/releases/download/"+dirName+"/"+dirName+".7z", APPIMAGE_TOOL_SHA512) if err != nil { return "", errors.WithStack(err) diff --git a/pkg/snap/snap.go b/pkg/snap/snap.go index 93ae35a..f9f0078 100644 --- a/pkg/snap/snap.go +++ b/pkg/snap/snap.go @@ -297,6 +297,11 @@ func buildWithoutDockerAndWithoutTemplate(options SnapOptions) error { return errors.WithStack(err) } + err = fs.CopyUsingHardlink(filepath.Join(stageDir, "command.sh"), filepath.Join(primeDir, "command.sh")) + if err != nil { + return errors.WithStack(err) + } + err = util.Execute(exec.Command("snapcraft", "pack", primeDir, "--output", *options.output), stageDir) if err != nil { return errors.WithStack(err) diff --git a/pkg/util/tempfile.go b/pkg/util/tempfile.go index df9fca3..b6c2c90 100644 --- a/pkg/util/tempfile.go +++ b/pkg/util/tempfile.go @@ -11,7 +11,7 @@ import ( "sync" "time" - "github.com/pkg/errors" + "github.com/develar/errors" ) // Random number state. @@ -19,21 +19,21 @@ import ( // chance the file doesn't exist yet - keeps the number of tries in // TempFile to a minimum. var rand uint32 -var randmu sync.Mutex +var randMutex sync.Mutex func reseed() uint32 { return uint32(time.Now().UnixNano() + int64(os.Getpid())) } func nextPrefix() string { - randmu.Lock() + randMutex.Lock() r := rand if r == 0 { r = reseed() } r = r*1664525 + 1013904223 // constants from Numerical Recipes rand = r - randmu.Unlock() + randMutex.Unlock() return strconv.Itoa(int(1e9 + r%1e9))[1:] } @@ -60,9 +60,9 @@ func TempFile(dir, suffix string) (string, error) { } if nConflict++; nConflict > 10 { - randmu.Lock() + randMutex.Lock() rand = reseed() - randmu.Unlock() + randMutex.Unlock() } } return "", errors.Errorf("cannot find unique file name") @@ -86,9 +86,9 @@ func TempDir(dir, suffix string) (name string, err error) { err = os.Mkdir(try, 0700) if os.IsExist(err) { if nConflict++; nConflict > 10 { - randmu.Lock() + randMutex.Lock() rand = reseed() - randmu.Unlock() + randMutex.Unlock() } continue } diff --git a/scripts/build.sh b/scripts/build.sh index 5ff079c..82fd02f 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -1,4 +1,4 @@ #!/usr/bin/env bash # ln -sf /Users/develar/go/src/github.com/develar/app-builder/dist/darwin_amd64/app-builder /Users/develar/Documents/electron-builder/node_modules/app-builder-bin-mac/app-builder -goreleaser --rm-dist --snapshot --skip-validate \ No newline at end of file +goreleaser --rm-dist --snapshot \ No newline at end of file