forked from ziahamza/webui-aria2
-
Notifications
You must be signed in to change notification settings - Fork 1
/
webui-aria2.spec
143 lines (125 loc) · 4.44 KB
/
webui-aria2.spec
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
134
135
136
137
138
139
140
141
142
143
Name: webui-aria2
Version: master
Release: 1%{?dist}
Summary: Web interface for aria2
License: MIT License
URL: https://codeload.github.com/ziahamza/webui-aria2
Source0: https://codeload.github.com/ziahamza/%{name}/tar.gz/%{name}-%{version}.tar.gz
#Requires: aria2
%description
The aim for this project is to create the worlds best and hottest interface to interact with aria2.
aria2 is the worlds best file downloader, but sometimes the command line brings more power than necessary.
The project was initially created as part of the GSOC scheme, however it has rapidly grown and changed with
tremendous support and feedback from the aria2 community
#%prep
#%setup -q -n %{name}-%{version}
#%build
#%configure
#make %{?_smp_mflags}
%install
tar xvzf %{SOURCE0}
#
mkdir -p $RPM_BUILD_ROOT/usr/share/%{name}
cp -R %{name}-%{version}/css $RPM_BUILD_ROOT/usr/share/%{name}/
cp -R %{name}-%{version}/flags $RPM_BUILD_ROOT/usr/share/%{name}/
cp -R %{name}-%{version}/fonts $RPM_BUILD_ROOT/usr/share/%{name}/
cp -R %{name}-%{version}/img $RPM_BUILD_ROOT/usr/share/%{name}/
cp -R %{name}-%{version}/js $RPM_BUILD_ROOT/usr/share/%{name}/
cp %{name}-%{version}/configuration.js $RPM_BUILD_ROOT/usr/share/%{name}/
cp %{name}-%{version}/favicon.ico $RPM_BUILD_ROOT/usr/share/%{name}/
cp %{name}-%{version}/index.html $RPM_BUILD_ROOT/usr/share/%{name}/
cp %{name}-%{version}/LICENSE $RPM_BUILD_ROOT/usr/share/%{name}/
#
find $RPM_BUILD_ROOT/usr/share/%{name} -type d | xargs chmod 755
find $RPM_BUILD_ROOT/usr/share/%{name} -type f | xargs chmod 644
mkdir -p $RPM_BUILD_ROOT/usr/bin
cat > $RPM_BUILD_ROOT/usr/bin/%{name} <<HERE
#!/usr/bin/env python
import os
import posixpath
import urllib
import BaseHTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler
# modify this to add additional routes
ROUTES = (
## [url_prefix , directory_path]
['', '/usr/share/webui-aria2'], # empty string for the 'default' match
# ['/media', '/var/www/media']
)
class RequestHandler(SimpleHTTPRequestHandler):
def translate_path(self, path):
"""translate path given routes"""
# set default root to cwd
root = os.getcwd()
# look up routes and set root directory accordingly
for pattern, rootdir in ROUTES:
if path.startswith(pattern):
# found match!
path = path[len(pattern):] # consume path up to pattern len
root = rootdir
break
# normalize path and prepend root directory
path = path.split('?',1)[0]
path = path.split('#',1)[0]
path = posixpath.normpath(urllib.unquote(path))
words = path.split('/')
words = filter(None, words)
path = root
for word in words:
drive, word = os.path.splitdrive(word)
head, word = os.path.split(word)
if word in (os.curdir, os.pardir):
continue
path = os.path.join(path, word)
return path
if __name__ == '__main__':
BaseHTTPServer.test(RequestHandler, BaseHTTPServer.HTTPServer)
HERE
#
mkdir -p $RPM_BUILD_ROOT/usr/lib/systemd/system/
cat > $RPM_BUILD_ROOT/usr/lib/systemd/system/%{name}.service <<HERE
[Unit]
Description=WebUI-Aria2
After=network.target
After=aria2.service
[Service]
Type=simple
User=nobody
Group=nobody
ExecStart=/usr/bin/webui-aria2
[Install]
WantedBy=multi-user.target
HERE
#
mkdir -p $RPM_BUILD_ROOT/etc/firewalld/services
cat > $RPM_BUILD_ROOT/etc/firewalld/services/%{name}.xml <<HERE
<?xml version="1.0" encoding="utf-8"?>
<service>
<short>WebUI-Aria2</short>
<description>WebUI for Aria2</description>
<port protocol="tcp" port="8000"/>
</service>
HERE
#
%files
%defattr(-,nobody,nobody)
#
%dir %attr(755,root,root) /usr/share/%{name}
#
%attr(-,nobody,nobody) /usr/share/%{name}/css
%attr(-,nobody,nobody) /usr/share/%{name}/flags
%attr(-,nobody,nobody) /usr/share/%{name}/fonts
%attr(-,nobody,nobody) /usr/share/%{name}/img
%attr(-,nobody,nobody) /usr/share/%{name}/js
%attr(-,nobody,nobody) /usr/share/%{name}/LICENSE
%attr(-,nobody,nobody) /usr/share/%{name}/configuration.js
%attr(-,nobody,nobody) /usr/share/%{name}/favicon.ico
%attr(-,nobody,nobody) /usr/share/%{name}/index.html
#
%attr(644,root,root) /usr/lib/systemd/system/%{name}.service
%attr(644,root,root) /etc/firewalld/services/%{name}.xml
%attr(755,root,root) /usr/bin/%{name}
#
%changelog
* Sun Feb 08 2016 Aleksandr Chernyshev <wmlex@yandex.ru> - pull request #183
- Initial release.