-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfedora.py
87 lines (73 loc) · 2.78 KB
/
fedora.py
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
#!/usr/bin/python
#encoding:utf-8
import re
__author__ = 'ling'
from common import *
from urlparse import urljoin
def get_all_update_fedora(download=True):
downloaded_pkgs = get_all_pkg_files()
pkg_urls = []
for version in range(7, 24):
if version <= 20:
base_url = 'https://dl.fedoraproject.org/pub/archive/fedora/linux/updates/'
else:
base_url = 'https://archives.fedoraproject.org/pub/fedora/linux/updates/'
if (version == 8) | (version == 9):
pkg_url = urljoin(base_url, str(version)+'/x86_64.newkey/')
else:
pkg_url = urljoin(base_url, str(version)+'/x86_64/')
content = curl(pkg_url)
if content is None:
continue
matches = re.findall('<a href="(glibc-\d[^"]*.rpm)"', content)
print matches
for match in matches:
rpm_file = match
rpm_url = urljoin(pkg_url, rpm_file)
rpm_file = 'fedora-'+rpm_file
if rpm_file in downloaded_pkgs:
continue
if download:
if get_one_rpm(rpm_url, rpm_file):
downloaded_pkgs.append(rpm_file)
else:
print 'get:'+rpm_url
pkg_urls.append(rpm_url)
return pkg_urls
def get_all_release_fedora(download=True):
downloaded_pkgs = get_all_pkg_files()
for version in range(7, 24):
if version <= 20:
base_url = 'https://dl.fedoraproject.org/pub/archive/fedora/linux/releases/'
else:
base_url = 'https://archives.fedoraproject.org/pub/fedora/linux/releases/'
if version == 7:
pkg_urls = [urljoin(base_url, str(version)+'/Everything/x86_64/os/Fedora/')]
elif version <= 16:
pkg_urls = [urljoin(base_url, str(version)+'/Everything/x86_64/os/Packages/')]
else:
pkg_urls = [urljoin(base_url, str(version)+'/Everything/x86_64/os/Packages/g/')]
for pkg_url in pkg_urls:
content = curl(pkg_url)
if content is None:
continue
matches = re.findall('<a href="(glibc-\d[^"]*.rpm)"', content)
print matches
for match in matches:
rpm_file = match
rpm_url = urljoin(pkg_url, rpm_file)
rpm_file = 'fedora-'+rpm_file
if rpm_file in downloaded_pkgs:
continue
if download:
if get_one_rpm(rpm_url, rpm_file):
downloaded_pkgs.append(rpm_file)
else:
print 'get:'+rpm_url
pkg_urls.append(rpm_url)
return pkg_urls
def get_all_fedora():
get_all_update_fedora()
get_all_release_fedora()
if __name__ == '__main__':
get_all_fedora()