summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 095a51592b076f4d5321dbb24817cf8d75d04a3d (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
# Maintainer: Andrew Antle <andrew dot antle at gmail dot com>
# Contributor: Calvin McAnarney <csm@gmx.us>
# Contributor: Julien Pecqueur <jpec@julienpecqueur.com>
# Contributor: Sergiusz Urbaniak <sergiusz.urbaniak@gmail.com>
pkgname=plan9port-git
pkgver=r3523.17329592
pkgrel=1
pkgdesc="A port of many Plan 9 libraries and programs to Unix."
arch=('i686' 'x86_64')
url="https://github.com/9fans/plan9port"
url="http://swtch.com/plan9port/"
license=('custom')
depends=('xorg-server' 'libxt' 'libxext' 'fuse')
optdepends=('python2: for the codereview script')
makedepends=('git' 'gendesk')
provides=('plan9port')
install='plan9.install'
conflicts=('9base' 'plan9port')
options=('!zipman' 'staticlibs')
source=("$pkgname::git+https://github.com/9fans/plan9port"
        plan9.sh acme.sh acme.png acme.desktop)
md5sums=('SKIP'
         'c884c3c90a107f1a178718c304c67d30'
         '0a3d8aaabd7cac1b8189a5551515d63f'
         '266d160d71a2b4f1ec9859b5232c36da'
         '682e9acb44074a4b49b3c2552d6a0a39')

pkgver() {
  cd "$srcdir/$pkgname"
  printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

prepare() {
  cd "$srcdir/"
  # Generate a desktop shortcut for the Acme editor
  gendesk -f \
          --pkgname acme \
          --name Acme \
          --genericname Editor \
          --comment 'Editor from Plan9' \
          --categories 'Application;Development;TextEditor'

  # Fix PATH variable
  sed -i '27s@.*@PATH=$PLAN9/bin:PATH=/bin:/usr/bin:$PATH export PATH@g' $pkgname/INSTALL
}

package() {
  cd "$srcdir/$pkgname"

  # Try the gentoo way for fixing hardcoded paths
  PLAN9=/usr/lib/plan9
  grep --null -l -r '/usr/local/plan9' | xargs --null sed -i "s!/usr/local/plan9!/usr/lib/plan9!g"

  ./INSTALL -b
  install -Dm755 ../plan9.sh "$pkgdir/etc/profile.d/plan9.sh"

  mkdir -p $pkgdir/usr/{lib,share/doc/$pkgname}

  cp -r "$srcdir/$pkgname" "$pkgdir/usr/lib/plan9"
  cd "$pkgdir/usr/lib/plan9"
  ./INSTALL -c -r "$pkgdir/usr/lib/plan9"
  install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  # Package text files
  for i in CHANGES CONTRIBUTORS README.md TODO; do
    install -m644 $i "$pkgdir/usr/share/doc/$pkgname"
    rm -f $i
  done

  # Decompress the plan9 man pages
  for i in $(find $pkgdir/usr/lib/plan9/man -type f); do
    if [ ${i##*.} = "gz" ]; then
      gunzip "$i"
    fi
  done

  grep --null -l -r "$pkgdir/usr/lib/plan9" | xargs --null sed -i "s@$pkgdir/usr/lib/plan9@/usr/lib/plan9@g" || true
  grep --null -l -r "/build/plan9port/pkg/$pkgname/usr/lib/plan9" | xargs --null \
    sed -i "s!/build/plan9port/pkg/$pkgname/usr/lib/plan9!/usr/lib/plan9!g" || true

  cd "$srcdir/"
  install -Dm755 acme.sh $pkgdir/usr/bin/acme
  install -Dm644 acme.png $pkgdir/usr/share/pixmaps/acme.png
  install -Dm644 acme.desktop $pkgdir/usr/share/applications/acme.desktop

  # Clean up
  cd "$pkgdir/usr/lib/plan9"
  rm -rf .git .gitignore config install.log install.sum configure Makefile INSTALL LICENSE
  find . -name '.cvsignore' -print0 | xargs -0 rm -f
}