summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 8b43e8b2505ab32202eea1ec0150728d000d51f7 (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
# Maintainer: Slash <demodevil5[at]yahoo[dot]com>
# Contributor: Nathan "Necopinus" <nathan@ecopunk.info>
# Contributor: Sebastian Schäfer <sarek@uliweb.de>

pkgname=tracks
pkgver=2.3.0
pkgrel=1
pkgdesc="Web-based application helping to implement the 'Getting things done' methodology"
arch=('any')
url=("http://www.getontracks.org/")
license=('GPL')
makedepends=('libmariadbclient' 'libxml2' 'libxslt'  'ruby-bundler' 'sqlite')
backup=('usr/share/webapps/tracks/config/database.yml'
        'usr/share/webapps/tracks/config/site.yml'
        'usr/share/webapps/tracks/db/tracks.sqlite3.db')
source=(
    'default_db.patch'
    'tracks.service'
    "tracks.zip::https://github.com/TracksApp/tracks/zipball/v${pkgver}")
install="${pkgname}.install"
sha256sums=('d6a762be317e3753d50aca29a953cd5c8ef0aae6ddabd5807124e2e41ba46f48'
            '31f09cd39b632c91dd47e92780d29e84e2173abe268f0286de14f6126e1ba018'
            'f9e9524e89748f11e797a09f53ea201ec9438a62465fdfa3cfbc4e9cfbb86ce4')
_tracks_archive_path='TracksApp-tracks-f98d32c'

prepare() {
    cd "${srcdir}/${_tracks_archive_path}"

    # Create site.yml from template
    cp config/site.yml.tmpl config/site.yml

    # Create database.yml from template
    cp config/database.yml.tmpl config/database.yml

    # Patch database.yml to use the sqlite default database
    patch -p0 < "${srcdir}/default_db.patch"

    # Configure Tracks to serve static assets via Mongrel
    sed -i \
      's/config.serve_static_assets = false/config.serve_static_assets = true/' \
      config/environments/production.rb
}

build() {
    cd "${srcdir}/${_tracks_archive_path}"

    # Use bundler to install required gems
    bundle install --without development test --path vendor/bundle

    # Initialize the default sqlite Database
    bundle exec rake db:migrate RAILS_ENV=production

    # Precompile static assets
    bundle exec rake assets:precompile RAILS_ENV=production
}

package() {
    cd "${srcdir}"

    # Create destination directories
    install -d "${pkgdir}/etc/webapps/tracks"
    install -d "${pkgdir}/srv/http"
    install -d "${pkgdir}/usr/share/webapps/tracks"

    # Copy Tracks data to destination directory
    cp -r "${srcdir}/${_tracks_archive_path}/". \
        "${pkgdir}/usr/share/webapps/tracks/"

    # Change ownership of files to http:http
    chown -R 33:33 "${pkgdir}/usr/share/webapps/tracks"

    # Symlink configuration files to /etc/
    ln -s /usr/share/webapps/tracks/config/database.yml \
        "${pkgdir}/etc/webapps/tracks/database.yml"

    ln -s /usr/share/webapps/tracks/config/site.yml \
        "${pkgdir}/etc/webapps/tracks/site.yml"

    # Symlink tracks to /srv/http/
    ln -s /usr/share/webapps/tracks/ \
        "${pkgdir}/srv/http/tracks"

    # Install systemd Service File
    install -Dm644 tracks.service \
        "${pkgdir}/usr/lib/systemd/system/tracks.service"
}