summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 7f26b30b67e28f5a1b7b504e39ea12342bc39ad9 (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
# Maintainer: Luis Aranguren <pizzaman@hotmail.com>
# Contributor: skydrome <skydrome@i2pmail.org>

pkgname='rutorrent-git'
pkgver=4.2.4.r0.gf49d3cb3
pkgrel=1
pkgdesc="Web frontend to rTorrent in PHP designed to resemble uTorrent"
url="https://github.com/Novik/ruTorrent"
license=('GPL')
arch=('any')

install=rutorrent.install
options=(!strip)

depends=('php' 'curl' 'mktorrent')
makedepends=('git')
optdepends=('ffmpeg: enable screenshots plugin'
            'sox: enable spectrogram plugin'
            'mediainfo: enable mediainfo plugin'
            'php-geoip: enable geoip plugin'
            'unrar: enable unpack plugin'
            'unzip: enable unpack plugin'
            'python-cloudscraper: cloudflare plugin requirement')
 
conflicts=('rutorrent' 'rutorrent-plugins')
provides=('rutorrent' 'rutorrent-plugins')

_webdir="usr/share/webapps"
backup=("${_webdir}/rutorrent/conf/config.php"
        "${_webdir}/rutorrent/conf/access.ini"
        "${_webdir}/rutorrent/conf/plugins.ini")

source=("rutorrent::git+https://github.com/Novik/ruTorrent.git#branch=v4.2")

md5sums=('SKIP')

pkgver() {
    cd "$srcdir/rutorrent"
    git describe --long --tags | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g'
}

prepare() {
    cd "$srcdir/rutorrent"

    sed -i conf/config.php \
        -e "s:\$topDirectory .*:\$topDirectory = '/home';:" \
        -e "s:\$XMLRPCMountPoint .*:\$XMLRPCMountPoint = \"/rutorrent/RPC1\";:" \
        -e "s:\$tempDirectory .*:\$tempDirectory = '/${_webdir}/rutorrent/tmp/';:"

    for i in php stat curl id gzip; do
        sed -i conf/config.php \
            -e "s:\"$i\".*=> ''.*:\"$i\"   => \'/usr/bin/$i\',:"
    done

    for i in rar zip unzip unrar tar; do
        sed -i plugins/unpack/conf.php \
            -e "s:\$pathToExternals\['$i'\] = '':\$pathToExternals\['$i'\] = '/usr/bin/$i':"
    done

    sed -i plugins/create/conf.php \
        -e "s:\$useExternal = false:\$useExternal = true:" \
        -e "s:\$pathToCreatetorrent = '':\$pathToCreatetorrent = '/usr/bin/$i':"

    sed -i php/settings.php \
        -e "s:'/tmp:'/${_webdir}/rutorrent/tmp/:"

    _gitrev=$(git rev-parse --short HEAD)
    _gitdate=$(git log -1 --format="%cd" --date=short)
    _gitcount=$(git rev-list --count HEAD)

    sed -i js/webui.js \
        -e "s|version: \"3.*|version: \"3.x-git~${_gitrev} r${_gitcount} ${_gitdate}\",|"
}

package() {
    export LC_ALL=$LANG
    cd "$srcdir/rutorrent/plugins"

    install -dm755 "$pkgdir/$_webdir"

    cd "$pkgdir/$_webdir"

    cp -r "$srcdir/rutorrent" .
    rm -r rutorrent/{.git*,README*}

    cd rutorrent

    mkdir -p tmp
    cp share/.htaccess tmp/
}