Skip to content
This repository has been archived by the owner on Apr 25, 2024. It is now read-only.

Commit

Permalink
Wails 1.8.0 & very basic packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
lyimmi committed Sep 10, 2020
1 parent b0755b1 commit d77fd00
Show file tree
Hide file tree
Showing 12 changed files with 222 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ yarn-error.log*

vuex-store.data
/laradock-manager
/build/laradock-manager
/build/
/vendor/


Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ In order to use this your current user need to be able to access docker without
dpkg-deb --build build/laradock-manager-0.4.0


![Preview](https://raw.githubusercontent.com/Lyimmi/laradock-manager/master/build/laradock-manager-0.4.0.gif)
![Preview](https://raw.githubusercontent.com/Lyimmi/laradock-manager/master/assets/laradock-manager-0.4.0.gif)
File renamed without changes
4 changes: 4 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
wails build -ldflags="-s -w"
# upx build/laradock-manager
go run ./cmd/package
19 changes: 0 additions & 19 deletions build/laradock-manager-0.4.1/DEBIAN/control

This file was deleted.

Binary file not shown.

This file was deleted.

207 changes: 207 additions & 0 deletions cmd/package/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
package main

import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"os"
"os/exec"
"path"
)

//Version app version
var Version string

//Project is the project json
var Project project

type project struct {
Name string `json:"name"`
Description string `json:"description"`
Author struct {
Name string `json:"name"`
Email string `json:"email"`
} `json:"author"`
Version string `json:"version"`
Binaryname string `json:"binaryname"`
Frontend struct {
Dir string `json:"dir"`
Install string `json:"install"`
Build string `json:"build"`
Bridge string `json:"bridge"`
Serve string `json:"serve"`
} `json:"frontend"`
WailsVersion string `json:"WailsVersion"`
}

func main() {
loadProjectFile()
deleteBuildFolder()
createBuildFolder()
pack()
}

func getMainPath() string {
v := getVersion()
return path.Join("build", "laradock-manager-"+v)
}

func loadProjectFile() {
jsonFile, err := os.Open("./project.json")
defer jsonFile.Close()

if err != nil {
println("Probably not called this in a wrong working dir, try calling it in the laradock-manager's root!")
println(err.Error())
}
j, _ := ioutil.ReadAll(jsonFile)
json.Unmarshal(j, &Project)
}

func getVersion() string {
if Version != "" {
return Version
}

Version = Project.Version
return Version
}

func deleteBuildFolder() {
err := os.RemoveAll(getMainPath())
check(err)
}

func createBuildFolder() {
writeControlFile()
writeDesktop()
copyIcon()
copyBin()
}

func writeControlFile() {
//Control file
fp := path.Join(getMainPath(), "DEBIAN")
err := os.MkdirAll(fp, os.ModePerm)
check(err)

cont :=
`Package: ` + Project.Binaryname + `
Version: ` + getVersion() + `
Section: devel
Priority: optional
Architecture: amd64
Installed-Size: 4800
Maintainer: ` + Project.Author.Name + ` <` + Project.Author.Email + `>
Homepage: https://github.com/Lyimmi/laradock-manager
Description: ` + Project.Name + `
A simple application for managing laradock containers.
Developed and tested only on Ubuntu 20.04/19.04/18.04
.
Made with https://wails.app/ (go & vue.js & vuetify)
.
Usage
In order to use this your current user need to be able to access docker without sudo
Create the docker group: $ sudo groupadd docker
Add your user to the docker group: $ sudo usermod -aG docker $USER
Log out and log back in so that your group membership is re-evaluated. ($ newgrp docker)
`

f, err := os.Create(path.Join(fp, "control"))
check(err)
_, err = f.WriteString(cont)
check(err)
f.Close()
}

func writeDesktop() {
fp := path.Join(getMainPath(), "usr", "share", "applications")
err := os.MkdirAll(fp, os.ModePerm)
check(err)

cont := `[Desktop Entry]
Version=1.1
Type=Application
Name=Laradock Manager
Comment=Simple application for managing laradock containers
Icon=/opt/laradock-manager/laradock-manager.png
Exec=/opt/laradock-manager/laradock-manager
Actions=
Categories=Development;
StartupNotify=true`

f, err := os.Create(path.Join(fp, "laradock-manager.desktop"))
check(err)
_, err = f.WriteString(cont)
check(err)
f.Close()
}

func copyIcon() {
var err error
//Menu icon
fp := path.Join(getMainPath(), "opt", "laradock-manager")
err = os.MkdirAll(fp, os.ModePerm)
check(err)
src := "assets/laradock-manager.png"
dst := path.Join(fp, "laradock-manager.png")
_, err = copy(src, dst)
check(err)
}

func copyBin() {
var err error
fp := path.Join(getMainPath(), "opt", "laradock-manager")
err = os.MkdirAll(fp, os.ModePerm)
check(err)
dst := path.Join(fp, "laradock-manager")
_, err = copy("build/laradock-manager", dst)

c := exec.Command("chmod", "+x", dst)
err = c.Run()
check(err)

}

func copy(src, dst string) (int64, error) {
sourceFileStat, err := os.Stat(src)
if err != nil {
return 0, err
}

if !sourceFileStat.Mode().IsRegular() {
return 0, fmt.Errorf("%s is not a regular file", src)
}

source, err := os.Open(src)
if err != nil {
return 0, err
}
defer source.Close()

destination, err := os.Create(dst)
if err != nil {
return 0, err
}
defer destination.Close()
nBytes, err := io.Copy(destination, source)
return nBytes, err
}

func pack() {
var err error
var out []byte

cmd := exec.Command("dpkg-deb", "--build", "build/laradock-manager-"+getVersion())
// cmd.Dir = d
out, err = cmd.CombinedOutput()
fmt.Println(string(out))
check(err)
}

func check(e error) {
if e != nil {
panic(e)
}
}
2 changes: 1 addition & 1 deletion frontend/package.json.md5
Original file line number Diff line number Diff line change
@@ -1 +1 @@
74bde6ed1300a2b503647a26546f3273
213334c6d33a8d755af08d98d1e722ca
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ require (
github.com/labstack/gommon v0.3.0
github.com/leaanthony/mewn v0.10.7
github.com/mattn/go-colorable v0.1.6 // indirect
github.com/wailsapp/wails v1.7.1
github.com/wailsapp/wails v1.8.0
golang.org/x/text v0.3.2 // indirect
)
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,13 @@ github.com/wailsapp/wails v1.6.0 h1:eOyskbxeEYj/hD1kLWMa7dYfYG3PUz+J8ZCrMsiQtFk=
github.com/wailsapp/wails v1.6.0/go.mod h1:mOltlF9JaTgg90B4Eb54UfGPkSmzVMmIXazItzWdorM=
github.com/wailsapp/wails v1.7.1 h1:ne54tk+OZlXI2KLBYBg1FPhkvGzbfpij4XrQY7LbzFc=
github.com/wailsapp/wails v1.7.1/go.mod h1:isZA4Brn4If9+t6Jv0boECyoZpUjUVTbrDdTyb286G0=
github.com/wailsapp/wails v1.8.0 h1:gnQhpwoGM8s2GD5PZrgMKU1PO3pQ9cdKKJgwtkNz2f4=
github.com/wailsapp/wails v1.8.0/go.mod h1:XFZunea+USOCMMgBlz0A0JHLL3oWrRhnOl4baZlRpxo=
golang.org/x/crypto v0.0.0-20190123085648-057139ce5d2b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/image v0.0.0-20200430140353-33d19683fad8 h1:6WW6V3x1P/jokJBpRQYUJnMHRP6isStQwCozxnU7XQw=
golang.org/x/image v0.0.0-20200430140353-33d19683fad8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190509222800-a4d6f7feada5/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
Expand Down
8 changes: 4 additions & 4 deletions project.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "laradock-manager",
"name": "Laradock Manager",
"description": "A simple desktop application for managing laradock containers",
"author": {
"name": "Zámbó, Levente",
"email": "[email protected]"
},
"version": "0.4.1",
"version": "0.5.0",
"binaryname": "laradock-manager",
"frontend": {
"dir": "frontend",
Expand All @@ -14,5 +14,5 @@
"bridge": "src",
"serve": "npm run serve"
},
"WailsVersion": "v1.7.1"
}
"WailsVersion": "v1.8"
}

0 comments on commit d77fd00

Please sign in to comment.