summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: ff40ee43ad3e78b1324cd05034e9fb0531a641f5 (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
# Maintainer: Giorgio Gilestro <giorgio at gilest.ro>

pkgname=ethoscope-node
pkgver=r2231.gbf320832
pkgrel=9
pkgdesc="A platform for monitoring animal behaviour in real time from a raspberry pi"
arch=('any')
url="http://lab.gilest.ro/ethoscope"
license=('GPL3')
makedepends=('base-devel' 'git' 'gcc-fortran' 'rsync' 'wget' 'fping' )
depends=('ntp' 'cronie' 'openssh' 'mariadb' 'dnsmasq' 'avahi' 'python-setuptools' 'python-wheel' 'python-pip' 'sshpass' 'cloudflared' 'gcc'
         'python-bottle' 'python-cherrypy' 'python-mysql-connector' 'python-netifaces'
         'python-gitpython' 'python-zeroconf' 'python-numpy' 'python-opencv' 'python-pyserial'
         'python-psutil' 'python-requests' 'python-scipy' 'python-dateutil' 'python-mattermostdriver')
optdepends=('python-picamera2: Raspberry Pi camera support for ethoscope devices')
provides=('ethoscope')
install="ethoscope-node.install"
source=("$pkgname::git+https://github.com/gilestrolab/ethoscope.git"
        "ssh-handler.desktop")
md5sums=('SKIP' 'SKIP')
_git_branch="dev"

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

package() {
  #creating packaging directories
  install -dm0755 $pkgdir/opt
  install -dm0755 $pkgdir/srv/git
  install -dm0755 $pkgdir/usr/lib/systemd/system
  install -dm0755 $pkgdir/ethoscope_data/{results,videos,cache,sensors}
  
  #create bare repo
  git clone --mirror https://github.com/gilestrolab/ethoscope.git "${pkgdir}/srv/git/ethoscope.git"
  
  #configure proper fetch refspec for bare repository
  cd "${pkgdir}/srv/git/ethoscope.git"
  git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
  git fetch origin
  
  #clone working copy from bare repo (avoids git alternates issues)
  cd "${pkgdir}/opt"
  git clone "${pkgdir}/srv/git/ethoscope.git" ethoscope

  #setting python3 branch
  cd "${pkgdir}/opt/ethoscope"
  git checkout ${_git_branch}

  #set remote to local bare repo and clean logs with pkgdir references
  git remote set-url origin /srv/git/ethoscope.git

  #remove git logs that contain pkgdir references
  rm -rf .git/logs
  
  # Install service files as symbolic links
  cd "${pkgdir}/usr/lib/systemd/system/"
  ln -s /opt/ethoscope/services/ethoscope_node.service ./
  ln -s /opt/ethoscope/services/ethoscope_update_node.service ./
  ln -s /opt/ethoscope/services/ethoscope_tunnel.service ./
  ln -s /opt/ethoscope/services/ethoscope_sensor_virtual.service ./
  ln -s /opt/ethoscope/services/ethoscope_backup_mysql.service ./
  ln -s /opt/ethoscope/services/ethoscope_backup_sqlite.service ./
  ln -s /opt/ethoscope/services/ethoscope_backup_unified.service ./
  ln -s /opt/ethoscope/services/ethoscope_backup_video.service ./
  ln -s /opt/ethoscope/services/virtuascope.service ./
  ln -s /opt/ethoscope/services/ethoscope_mirror_fetch.service ./
  ln -s /opt/ethoscope/services/ethoscope_mirror_fetch.timer ./

  # Install ssh:// protocol handler so SSH links in the web UI are clickable
  install -Dm644 "${srcdir}/ssh-handler.desktop" "${pkgdir}/usr/share/applications/ssh-handler.desktop"

  # Note: Python packages are installed via pip in the .install script
  # This generates .egg-info metadata and registers console script entry points
  # Dependencies are provided by pacman packages

}