summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 371f3144d79b261459e6dd50db269cfaa49faa5c (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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# Maintainer: EatMyVenom <eat.my.venomm@gmail.com>
# Contributor: Aaron McDaniel (mcd1992) <'aur' at the domain 'fgthou.se'>
# Contributor: Matheus de Alcantara <matheus.de.alcantara@gmail.com>
# Contributor: Brenton Horne <brentonhorne77 at gmail dot com>
# Contributor: Nicola Squartini <tensor5@gmail.com>

_name=atom
pkgname=atom-editor-git
pkgver=1.35.0.r1386.g527af1ad3
pkgrel=1
pkgdesc='Hackable text editor for the 21st Century - git channel'
arch=('x86_64')
url="https://atom.io/"
license=('MIT' 'custom')
depends=('apm' 'electron6' 'libxkbfile' 'ripgrep')
makedepends=('git' 'npm' 'gconf' 'nodejs' 'libsecret' 'python')
optdepends=('ctags: symbol indexing support'
            'git: Git and GitHub integration')
conflicts=('atom')
provides=('atom')
options=(!emptydirs)
source=("git+https://github.com/atom/atom.git"
        'atom.js'
        'dugite-use-system-git.patch'
        'fix-atom-sh.patch'
        'fix-license-path.patch'
        'fix-restart.patch'
        'git-utils.patch'
        'no-unsafe-eval-warning.patch'
        'node-env-production.patch'
        'symbols-view-use-system-ctags.patch'
        'use-system-apm.patch'
        'use-system-electron.patch')
sha256sums=('SKIP')

pkgver() {
    cd ${_name}
    # Remove 'v' prefix on tags; prefix revision with 'r'; replace all '-' with '.'
    git describe --long --tags | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g'
}

prepare() {
  cd ${_name}

  patch -Np1 -i ../fix-atom-sh.patch
  patch -Np1 -i ../use-system-electron.patch
  patch -Np1 -i ../use-system-apm.patch
  patch -Np1 -i ../fix-license-path.patch
  patch -Np1 -i ../fix-restart.patch
  patch -Np1 -i ../node-env-production.patch
  patch -Np1 -i ../no-unsafe-eval-warning.patch
}

build() {
  cd ${_name}

  ATOM_RESOURCE_PATH="${PWD}" \
  npm_config_build_from_source=true \
  npm_config_target=$(< /usr/lib/electron6/version) \
  apm install

  # Use system ctags
  cd node_modules/symbols-view
  patch -Np1 -i "${srcdir}"/symbols-view-use-system-ctags.patch
  rm -r vendor
  cd ../..

  # Use system git
  cd node_modules/dugite
  patch -Np1 -i "${srcdir}"/dugite-use-system-git.patch
  rm -r git
  cd ../..

  # Fix issue with:
  # build/Release/git.node: undefined symbol: git_net_url_is_default_port
  cd node_modules/git-utils
  patch -Np1 -i "${srcdir}"/git-utils.patch
  env \
    npm_config_disturl=https://electronjs.org/headers \
    npm_config_runtime=electron \
    npm_config_target=$(< /usr/lib/electron6/version) \
    node-gyp rebuild
  cd ../..

  cd script
  npm install
  # Hack to avoid using Node > 12 (https://github.com/babel/babel/issues/11216)
  # Set ELECTRON_VERSION (see use-system-electron.patch)
  env \
    ELECTRON_RUN_AS_NODE=1 \
    ELECTRON_VERSION=$(< /usr/lib/electron6/version) \
    electron5 \
    build --no-bootstrap
}

package() {
  cd ${_name}

  install -d -m 755 "${pkgdir}"/usr/lib
  cp -r out/app "${pkgdir}"/usr/lib/atom
  install -m 644 out/startup.js "${pkgdir}"/usr/lib/atom
  install -m 755 "${srcdir}/atom.js" "${pkgdir}"/usr/lib/atom/atom

  ln -sf /usr/bin/rg "${pkgdir}/usr/lib/atom/node_modules/vscode-ripgrep/bin/rg"

  install -d -m 755 "${pkgdir}/usr/share/applications"
  sed -e "s|<%= appName %>|Atom|" \
      -e "s/<%= description %>/${pkgdesc}/" \
      -e "s|<%= installDir %>|/usr|" \
      -e "s|<%= appFileName %>|atom|" \
      -e "s|<%= iconPath %>|atom|" \
      resources/linux/atom.desktop.in > "${pkgdir}/usr/share/applications/atom.desktop"

  for size in 16 24 32 48 64 128 256 512 1024; do
    install -D -m 644 resources/app-icons/stable/png/${size}.png \
            "${pkgdir}"/usr/share/icons/hicolor/${size}x${size}/apps/atom.png
  done
  ln -sf ../../../share/icons/hicolor/1024x1024/apps/atom.png \
      "${pkgdir}"/usr/lib/atom/resources/atom.png

  install -D -m 755 atom.sh "${pkgdir}/usr/bin/atom"

  install -d -m 755 "${pkgdir}/usr/share/licenses/${pkgname}"
  node -e "require('./script/lib/get-license-text')().then((licenseText) => require('fs').writeFileSync('${pkgdir}/usr/share/licenses/${pkgname}/LICENSE.md', licenseText))"

  # Remove useless stuff
  find "${pkgdir}"/usr/lib/atom/node_modules \
      -name "*.a" -exec rm '{}' \; \
      -or -name "*.bat" -exec rm '{}' \; \
      -or -name "*.c" -exec rm '{}' \; \
      -or -name "*.cpp" -exec rm '{}' \; \
      -or -name "*.node" -exec chmod a-x '{}' \; \
      -or -name "benchmark" -prune -exec rm -r '{}' \; \
      -or -name "doc" -prune -exec rm -r '{}' \; \
      -or -name "html" -prune -exec rm -r '{}' \; \
      -or -name "man" -prune -exec rm -r '{}' \; \
      -or -name "scripts" -prune -exec rm -r '{}' \; \
      -or -path "*/less/gradle" -prune -exec rm -r '{}' \; \
      -or -path "*/task-lists/src" -prune -exec rm -r '{}' \;
}