Skip to content

Commit

Permalink
fix(snap): command.sh is not copied if template and docker are not used
Browse files Browse the repository at this point in the history
  • Loading branch information
develar committed Mar 5, 2018
1 parent d405394 commit 8d2b41c
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 20 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ vendor/

app-builder-bin/readme.md
app-builder-bin/**/app-builder
app-builder-bin/win/**/app-builder.exe
app-builder-bin/win/**/app-builder.exe
.virtualgo
2 changes: 2 additions & 0 deletions .idea/dictionaries/develar.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app-builder-bin/linux/package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down
2 changes: 1 addition & 1 deletion app-builder-bin/mac/package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down
8 changes: 4 additions & 4 deletions app-builder-bin/package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"name": "app-builder-bin",
"description": "app-builder precompiled binaries",
"version": "1.5.0",
"version": "1.5.1",
"files": [
"*.js",
"index.d.ts"
],
"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",
Expand Down
2 changes: 1 addition & 1 deletion app-builder-bin/win/package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
Expand Down
4 changes: 2 additions & 2 deletions pkg/appimage/appImage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions pkg/snap/snap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 8 additions & 8 deletions pkg/util/tempfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,29 @@ import (
"sync"
"time"

"github.com/pkg/errors"
"github.com/develar/errors"
)

// Random number state.
// We generate random temporary file names so that there's a good
// 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:]
}

Expand All @@ -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")
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/build.sh
Original file line number Diff line number Diff line change
@@ -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
goreleaser --rm-dist --snapshot

0 comments on commit 8d2b41c

Please sign in to comment.