build: Add build method for snapcraft

GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3636
This commit is contained in:
Leo Arias 2016-10-20 09:16:30 +00:00 committed by Jakob Borg
parent 173fb97832
commit 31d9750579
2 changed files with 47 additions and 2 deletions

View File

@ -28,6 +28,7 @@ import (
"strconv"
"strings"
"syscall"
"text/template"
"time"
)
@ -275,6 +276,9 @@ func runCommand(cmd string, target target) {
case "deb":
buildDeb(target)
case "snap":
buildSnap(target)
case "clean":
clean()
@ -481,8 +485,8 @@ func buildDeb(target target) {
os.RemoveAll("deb")
// "goarch" here is set to whatever the Debian packages expect. We correct
// "it to what we actually know how to build and keep the Debian variant
// "name in "debarch".
// it to what we actually know how to build and keep the Debian variant
// name in "debarch".
debarch := goarch
switch goarch {
case "i386":
@ -520,6 +524,22 @@ func buildDeb(target target) {
"--license", "MPL-2")
}
func buildSnap(target target) {
tmpl, err := template.ParseFiles("snapcraft.yaml.template")
if err != nil {
log.Fatal(err)
}
f, err := os.Create("snapcraft.yaml")
defer f.Close()
if err != nil {
log.Fatal(err)
}
err = tmpl.Execute(f, map[string]string{"Version": version})
runPrint("snapcraft", "clean")
build(target, []string{"noupgrade"})
runPrint("snapcraft")
}
func copyFile(src, dst string, perm os.FileMode) error {
dstDir := filepath.Dir(dst)
os.MkdirAll(dstDir, 0755) // ignore error

25
snapcraft.yaml.template Normal file
View File

@ -0,0 +1,25 @@
name: syncthing
version: {{.Version}}
summary: Open Source Continuous File Synchronization
description: |
Syncthing replaces proprietary sync and cloud services with something open,
trustworthy and decentralized. Your data is your data alone and you deserve
to choose where it is stored, if it is shared with some third party and how
it's transmitted over the Internet.
grade: devel
confinement: strict
apps:
syncthing:
command: syncthing
plugs: [home, network, network-bind]
parts:
syncthing:
source: .
plugin: dump
stage:
- syncthing
snap:
- syncthing