summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: ab8a45703813a477c9742039cf3c72db28a356e0 (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
# Maintainer: Nicola Squartini <tensor5@gmail.com>

pkgname=mancy
pkgver=3.2.0
pkgrel=1
pkgdesc='A GUI REPL for Javascript & moreā€¦'
arch=('i686' 'x86_64')
url='http://mancy-re.pl/'
license=('MIT')
depends=('electron' 'nodejs')
makedepends=('git' 'gulp' 'npm')
options=(!emptydirs)
source=("${pkgname}-${pkgver}.tar.gz::https://github.com/princejwesley/Mancy/archive/v${pkgver}.tar.gz"
        'mancy.desktop'
        'mancy.sh')
sha256sums=('7029f8ba85785088d0dfd67f94b386b79876ea38b828759f4bfee6955d96c5ee'
            '0bfeedeb0e4517802e9a1734ba55a9fe00917930a8315d5bf48163522ca8b4f1'
            'ff225cc9d548c338b61621e4b877a3694f92c4c1fc04cfde4f0a652cb9715958')

prepare() {
    cd Mancy-${pkgver}

    sed -e 's/electron-rebuild && //;/electron-prebuilt/d' -i package.json

    _electron_version=$(electron --version)
    sed -e "s/const electronVersion = .*/const electronVersion = '${_electron_version#v}';/" \
        -i gulpfile.babel.js
}

build() {
    cd Mancy-${pkgver}

    _electron_version=$(electron --version)

    if [ "${CARCH}" == 'x86_64' ]; then
        _target=x64
    else
        _target=ia32
    fi

#    export SKIP_SASS_BINARY_DOWNLOAD_FOR_CI=1

    # Electron's version.
    export npm_config_target=${_electron_version#v}
    # The architecture of Electron, can be ia32 or x64.
    export npm_config_arch=${_target}
    # Download headers for Electron.
    export npm_config_disturl=https://atom.io/download/atom-shell
    # Tell node-pre-gyp that we are building for Electron.
    export npm_config_runtime=electron
    # Tell node-pre-gyp to build module from source code.
    export npm_config_build_from_source=true
    # Install all dependencies, and store cache to ~/.electron-gyp.
    HOME=~/.electron-gyp npm install

    npm run build
    npm prune --production
}

package() {
    cd Mancy-${pkgver}

    _appdir=/usr/lib/${pkgname}

    install -d "${pkgdir}"${_appdir}
    cp -r build/* "${pkgdir}"${_appdir}

    install -D -m 755 "${srcdir}"/${pkgname}.sh "${pkgdir}"/usr/bin/${pkgname}
    install -D -m644 "${srcdir}"/${pkgname}.desktop \
            "${pkgdir}"/usr/share/applications/${pkgname}.desktop

    install -d "${pkgdir}"/usr/share/licenses/${pkgname}
    ln -s ../../../lib/${pkgname}/LICENSE \
        "${pkgdir}"/usr/share/licenses/${pkgname}

    # Clean up
    find "${pkgdir}"${_appdir} \
        -name "package.json" \
            -exec sed -e "s|${srcdir}/Mancy-${pkgver}|${_appdir}|" \
                -i {} \; \
        -or -name "*.mk" -exec rm '{}' \; \
        -or -name "binding.gyp" -exec rm '{}' \; \
        -or -path "*/font-manager/src" -prune -exec rm -r '{}' \; \
        -or -name "binding.Makefile" -exec rm '{}' \; \
        -or -name "config.gypi" -exec rm '{}' \; \
        -or -name "deps" -prune -exec rm -r '{}' \; \
        -or -name "Makefile" -exec rm '{}' \; \
        -or -name "obj.target" -prune -exec rm -r '{}' \; \
        -or -name "test" -prune -exec rm -r '{}' \;
}