summaryrefslogtreecommitdiffstats
path: root/snap/snapcraft.yaml
blob: b4441805bcc7995b9edbec82ba80c4e9cf9d2c87 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
name: gitea
summary:  Gitea - A painless self-hosted Git service
description: |
  The goal of this project is to make the easiest, fastest, and most painless
  way of setting up a self-hosted Git service. With Go, this can be done with
  an independent binary distribution across ALL platforms that Go supports,
  including Linux, Mac OS X, Windows and ARM.

type: app
icon: public/img/gitea-lg.png
confinement: strict
grade: stable

version: 'git'

apps:
  gitea:
    command: bin/gitea
    plugs: [network, network-bind]
  web:
    command: bin/gitea web
    daemon: simple
    plugs: [network, network-bind]
  serv:
    command: bin/gitea serv
    plugs: [network, network-bind]
  admin:
    command: bin/gitea admin
    plugs: [network, network-bind]
  cert:
    command: bin/gitea cert
  hook:
    command: bin/gitea hook
    plugs: [network, network-bind]
  dump:
    command: bin/gitea dump
    plugs: [home]
  help:
    command: bin/gitea --help
  version:
    command: bin/gitea --version
  sqlite:
    command: usr/bin/sqlite3

parts:
  go:
    source-tag: go1.8.3
    prime:
      - -*

  gitea:
    plugin: nil
    source: .
    source-type: git
    after: [ go ]
    stage-packages: [ git, sqlite3, openssh-client ]
    build-packages: [ libpam0g-dev, libsqlite3-dev]
    prepare: |
      export PATH=$SNAPCRAFT_PART_INSTALL/../../go/install/bin:$PATH
      export GOPATH=$SNAPCRAFT_PART_INSTALL/../go
      export bld=$SNAPCRAFT_PART_INSTALL/../build
      export src=$SNAPCRAFT_PART_INSTALL/../src
      mkdir -p $GOPATH/src/code.gitea.io/gitea
      cp -r $src/* $GOPATH/src/code.gitea.io/gitea
    build: |
      export PATH=$SNAPCRAFT_PART_INSTALL/../go/bin/:$SNAPCRAFT_PART_INSTALL/../../go/install/bin:$PATH
      export GOPATH=$SNAPCRAFT_PART_INSTALL/../go
      cd $GOPATH/src/code.gitea.io/gitea
      TAGS="bindata sqlite sqlite_unlock_notify pam cert" make build
    install: |
      # Set Convenience Variables
      src=$SNAPCRAFT_PART_INSTALL/../go/src/code.gitea.io/gitea
      giteaBase=$SNAPCRAFT_PART_INSTALL/gitea
      scurrent=/var/snap/$SNAPCRAFT_PROJECT_NAME/current
      scommon=/var/snap/$SNAPCRAFT_PROJECT_NAME/common
      # Copy build artifact and necessary files
      mkdir -p $giteaBase/conf
      # Workaround for gitea ignoring APP_DATA_PATH in app.ini after snap update.
      ln -s $scurrent/custom $giteaBase/custom
      ln -s $scommon/data $giteaBase/data
      # Workaround for cmd/certs not knowing how to put files somewhere else
      ln -s $scurrent/cert.pem $giteaBase/cert.pem
      ln -s $scurrent/key.pem $giteaBase/key.pem
      # Copy static content
      mkdir -p $SNAPCRAFT_PART_INSTALL/static
      cp    $src/gitea             $giteaBase/
      cp -r $src/LICENSE \
            $src/templates \
            $src/public \
            $src/scripts \
            $SNAPCRAFT_PART_INSTALL/static/
      cp -r $src/README.md \
            $src/LICENSE  \
            $src/custom \
            $SNAPCRAFT_PART_INSTALL/
    prime:
      - -etc
      - -usr/lib/systemd
      - -usr/lib/gcc
      - -usr/lib/sasl2
      - -usr/lib/x86_64-linux-gnu/krb5
      - -usr/share/apport
      - -usr/share/bash-completion
      - -usr/share/doc
      - -usr/share/git-core/contrib
      - -usr/share/man
      - -usr/share/upstart
      - -var

  helpers:
    plugin: dump
    source: snap/helpers
    organize:
      simple_launcher.sh: bin/gitea
      app.ini: gitea/snapApp.ini
      configuration.sh: bin/gconfig
    prime:
      - bin/gitea
      - bin/gconfig
      - gitea/snapApp.ini