summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 7e4b7eed3b62080ae700398d56e6ed6fe093af0c (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
# Maintainer: dryes <joswiseman@cock.li>
pkgname='pyrescene-hg'
pkgver=423.d5037d93293c
pkgrel=1
pkgdesc='pyReScene is a port of ReScene .NET to the Python programming language.'
url='https://bitbucket.org/Gfy/pyrescene'
arch=('any')
license=('MIT', 'Custom')
depends=('python2' 'chromaprint' 'python2-numpy' 'unrar')
makedepends=('mercurial' 'git' 'dos2unix')
conflicts=('awescript' 'rescene-bin' 'resample-bin')

_hgrepo='pyrescene'
_hgroot="${url%/*}"

_gitroot='git://github.com/d2yes/rarlinux.git'
_gitname='rarlinux'

pkgver() {
  cd "$_hgrepo"
  hg tip | head -n1 | tr -d ' ' | cut -d: --output-delimiter=. -f 2,3
}

build() {
  cd "${srcdir}"
  
  msg 'Connecting to hg server...'
  
  if [ -d "${_hgrepo}/.hg" ]; then
    cd "${_hgrepo}" && hg pull -u
  else
    hg clone "${_hgroot}/${_hgrepo}"
  fi
  
  cd "${srcdir}"
  
  msg 'Connecting to GIT server....'
  
  if [ -d "${_gitname}" ] ; then
    cd "${_gitname}" && git pull origin
    msg 'The local files are updated.'
  else
    git clone "${_gitroot}" "${_gitname}"
  fi
  
  msg 'GIT checkout done or server timeout'
}

package() {
  cd "${srcdir}/${_hgrepo}"
  
  cp 'rescene/srr.py' 'rescene/srr.py~'
  sed -i -r 's|(dest=\"rar_executable_dir\",)|\1 default=\"/opt/rarlinux\",|' 'rescene/srr.py'
  python2 'setup.py' install --root="${pkgdir}"
  mv 'rescene/srr.py~' 'rescene/srr.py'

  cp 'rescene/unrar.py' 'rescene/unrar.py~'
  sed -i -r 's/^(from awescript import unrar)/\#\1/' 'rescene/unrar.py'
  sed -i -r 's|(unrar = )locate_unix\(\)|\1\"/usr/bin/unrar"|g' 'rescene/unrar.py'
  mkdir -p "${pkgdir}/opt/rarlinux"
  python2 'bin/preprardir.py' "${srcdir}/rarlinux" "${pkgdir}/opt/rarlinux"
  mv 'rescene/unrar.py~' 'rescene/unrar.py'

  cp 'awescript/awescript.py' 'awescript/awescript.py~'
  sed -i -r 's|/usr/local/bin/sr([rs])|sr\1|ig' 'awescript/awescript.py'
  sed -i -r 's/(print \"glob.glob \" \+ path)/None\#\1/g' 'awescript/awescript.py'
  dos2unix 'awescript/awescript.py'
  install -D -m755 "awescript/awescript.py" "${pkgdir}/usr/bin/awescript"
  mv 'awescript/awescript.py~' 'awescript/awescript.py'
}