summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 5f666e996cbad25429cea9fed36380d3949071ca (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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# Maintainer: skydrome <skydrome@i2pmail.org>
# Contributor: skydrome <skydrome@i2pmail.org>

pkgname='rutorrent-git'
pkgver=r1974.9191af0c
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=('php-geoip: enable geoip plugin'
            'geoip: enable geoip plugin'
            'unrar: enable unpack plugin'
            'unzip: enable unpack plugin'
            'plowshare: fileupload plugin functionality')

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")

_plugins=('extra/filemanager'
          'extra/fileshare'
          'extra/fileupload'
          'extra/mediastream'
          'titlebar'
          'ratiocolor')

_themes=('MaterialDesign'
         'QuickBox'
         'FlatUI')

source=("plugins.ini"
        "https://raw.githubusercontent.com/weixiyen/jquery-filedrop/master/jquery.filedrop.js"
        "rutorrent::git+https://github.com/Novik/ruTorrent.git"
        "titlebar::git+https://github.com/SanKen/rutorrent-titlebar.git"
        "ratiocolor::git+https://github.com/senki/rutorrent-ratiocolor.git"
        "extra::git+https://github.com/nelu/rutorrent-thirdparty-plugins.git"
        "MaterialDesign::git+https://github.com/Phlooo/ruTorrent-MaterialDesign.git"
        "QuickBox::git+https://github.com/QuickBox/club-QuickBox.git"
        "git+https://github.com/exetico/FlatUI.git")

md5sums=('5c50a738ee4180d63b596519d07d64d5'
         '3e0002fe9ce69f43513152c515944559'
         'SKIP'
         'SKIP'
         'SKIP'
         'SKIP'
         'SKIP'
         'SKIP'
         'SKIP')

pkgver() {
    cd "$srcdir/rutorrent"

    _gitrev=$(git rev-parse --short HEAD)
    _gitcount=$(git rev-list --count HEAD)
    echo "r${_gitcount}.${_gitrev}"
}

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 ../extra/filemanager/conf.php \
            -e "s:\$pathToExternals\['$i'\] = '':\$pathToExternals\['$i'\] = '/usr/bin/$i':"
        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"

    for i in ${_plugins[@]}; do
        rm -rf "$srcdir/$i/.git"
        cp -r  "$srcdir/$i" .
    done

    for i in ${_themes[@]}; do
        rm -rf "$srcdir/$i/.git"
        cp -r  "$srcdir/$i" ./theme/themes
    done

    cp -f  "$srcdir/jquery.filedrop.js" filedrop/jquery.filedrop.js

    install -dm755 "$pkgdir/$_webdir"

    cd "$pkgdir/$_webdir"

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

    cd rutorrent

    install -Dm755 "$srcdir/plugins.ini" conf/plugins.ini
    mkdir -p tmp
    cp share/.htaccess tmp/
}