summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 8f5419451467729b37392fee36112932ce45da38 (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
_gitname="Sonarr"
_gitver="2.0.0"
_gitbranch="develop"

# NB: Only for pull requests in origin
_git_patches=""
_git_patches+="783:mono-process-name "

pkgname="sonarr-git"
pkgver=2.0.0.r6807.2299860
pkgrel=1
pkgdesc="Automated TV series manager and downloader - git branch ${_gitbranch}"
arch=(any)
url="https://sonarr.tv"
license=('GPL3')
groups=()
depends=('mono'
         'libmediainfo'
         'sqlite')
makedepends=('git'
             'npm'
             'nodejs')
optdepends=()
provides=('sonarr')
conflicts=('sonarr'
           'sonarr-develop')
replaces=()
backup=()
options=('!strip')
install='sonarr.install'
changelog=
source=("git://github.com/Sonarr/Sonarr.git#branch=${_gitbranch}"
        "sonarr.sh"
        "sonarr.service")
sha256sums=('SKIP'
            'd594c4d5ad3c1b196a00cb9f005d4917ad4d8bb2ebf501010e8be7f349b3caa6'
            '1ebf903e6199dae6032c7839b00ed20566404daf87cb307ffc9ee8539722a845')


pkgver() {
  cd "${_gitname}"

  printf "%s.r%s.%s" "${_gitver}" "$(git rev-list --count ${_gitbranch})" "$(git rev-parse --short  ${_gitbranch})"
}

prepare() {
  cd "${_gitname}"

  # Install necessary nodejs libraries
  npm install

  # Git complains if user is not already set
  [[ `git config user.email` ]] || git config user.email "you@example.com"
  [[ `git config user.name` ]] || git config user.name "Your Name"

  for patch in ${_git_patches}; do
      id=`echo ${patch} | cut -d \: -f 1`
      name=`echo ${patch} | cut -d \: -f 2`
      msg2 "Patching ${name} from (https://github.com/Sonarr/Sonarr/pull/${id}"
      git fetch origin pull/${id}/head:${name} --force
      git rebase ${name} --force-rebase --ignore-whitespace --quiet
  done

  git submodule update --init
}

build() {
  cd "${_gitname}"

  export MONO_IOMAP=case
  mono ./tools/nuget/nuget.exe restore ./src/NzbDrone.sln
  xbuild ./src/NzbDrone.sln /t:Configuration=Release /t:Build

  node ./node_modules/gulp/bin/gulp.js build
}

package() {
  find "${_gitname}/_output/" \( \
        -name "ServiceUninstall.*" \
     -o -name "ServiceInstall.*" \
     -o -name "sqlite3.*" \
     -o -name "MediaInfo.*" \
     -o -name "NzbDrone.Windows.*" \
   \) -type f -delete

  install -d "${pkgdir}/var/lib/sonarr"

  install -Dm755 "sonarr.sh" "${pkgdir}/usr/bin/sonarr"
  install -Dm644 "sonarr.service" "${pkgdir}/usr/lib/systemd/system/sonarr.service"

  install -d "${pkgdir}/opt/sonarr"
  cp -a "${_gitname}/_output/"* "${pkgdir}/opt/sonarr"
  find "${pkgdir}/opt/sonarr" -type d -exec chmod 755 {} \;
  find "${pkgdir}/opt/sonarr" -type f -exec chmod 644 {} \;
  find "${pkgdir}/opt/sonarr" -name \*.exe -type f -exec chmod 755 {} \;
}