Merge lp://staging/~schwuk/ubuntu-qa-tools/mirror into lp://staging/ubuntu-qa-tools

Proposed by David Murphy
Status: Merged
Merged at revision: not available
Proposed branch: lp://staging/~schwuk/ubuntu-qa-tools/mirror
Merge into: lp://staging/ubuntu-qa-tools
Diff against target: 100 lines (+19/-14)
1 file modified
dl-ubuntu-test-iso/dl-ubuntu-test-iso (+19/-14)
To merge this branch: bzr merge lp://staging/~schwuk/ubuntu-qa-tools/mirror
Reviewer Review Type Date Requested Status
Steve Beattie Pending
Review via email: mp+15875@code.staging.launchpad.net
To post a comment you must log in.
Revision history for this message
David Murphy (schwuk) wrote :

Added the ability to make (shallow) mirrors using dl-ubuntu-test-iso.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'dl-ubuntu-test-iso/dl-ubuntu-test-iso'
2--- dl-ubuntu-test-iso/dl-ubuntu-test-iso 2009-12-08 22:01:16 +0000
3+++ dl-ubuntu-test-iso/dl-ubuntu-test-iso 2009-12-09 15:10:35 +0000
4@@ -150,7 +150,7 @@
5 try:
6 stat = os.stat(path)
7 except OSError, e:
8- os.mkdir(path)
9+ os.makedirs(path)
10
11 def read_config(pathname):
12 '''Read the config file, using shell syntax for backwards
13@@ -272,10 +272,10 @@
14 raise KeyboardInterrupt
15 return rc == 0
16
17-def do_zsync(config, flavor, uri, isoname):
18+def do_zsync(config, destination, uri, isoname):
19 zsync_uri = uri + '.zsync'
20- zsync_iso = flavor.name + '/' + isoname
21- zsync_local = flavor.name + '/.' + isoname + '.zsync'
22+ zsync_iso = destination + '/' + isoname
23+ zsync_local = destination + '/' + isoname + '.zsync'
24 available, msg = get_status(zsync_uri)
25 if not available:
26 config._log("control file does not exist, skipping zsync: " + msg)
27@@ -307,8 +307,8 @@
28 rc = subprocess.call(command)
29 return rc == 0
30
31-def do_rsync(config, flavor, uri, isoname):
32- rsync_local = flavor.name + '/' + isoname
33+def do_rsync(config, destination, uri, isoname):
34+ rsync_local = destination + '/' + isoname
35 #rc = cmd(['/usr/bin/zsync', '-o', zsync_local, 'http://cdimages.ubuntu.com/' + zsync_uri])
36 return _do_rsync(config, uri, rsync_local)
37
38@@ -329,13 +329,13 @@
39 conn.close()
40 return None, None
41
42-def do_verify(config, flavor, hashsuffix, path, iso):
43+def do_verify(config, destination, hashsuffix, path, iso):
44 alg, hashfunc = lookup_hash(path)
45 if not alg:
46 return False
47
48 uri = path + alg + "SUMS"
49- local = flavor.name + '/' + alg + "SUMS" + hashsuffix
50+ local = destination + '/' + alg + "SUMS" + hashsuffix
51 rc = _do_rsync(config, uri, local)
52 if not rc:
53 return False
54@@ -351,7 +351,7 @@
55 return False
56
57 m = hashfunc()
58- fd = os.open(flavor.name + '/' + iso, os.O_RDONLY)
59+ fd = os.open(destination + '/' + iso, os.O_RDONLY)
60 data = os.read(fd, 16 * 256 * 256)
61 while len(data):
62 m.update(data)
63@@ -373,7 +373,11 @@
64 isoname = release + '-' + variant + '-' + arch + '.iso'
65 hashsuffix = "." + release + '-' + variant
66 path = computepath(wanted, flavor, release, variant)
67- create_dir(flavor.name)
68+ if config.mirror:
69+ destination = path[1:-1]
70+ else:
71+ destination = flavor.name
72+ create_dir(destination)
73 uri = path + isoname
74 #print 'Result for ' + uri + ': ' + str(response.status)
75
76@@ -383,12 +387,12 @@
77 config._log("iso unavailable from server, skipping: " + msg)
78 continue
79
80- if not (config.use_zsync and do_zsync(config, flavor, uri, isoname)):
81- do_rsync(config, flavor, uri, isoname)
82+ if not (config.use_zsync and do_zsync(config, destination, uri, isoname)):
83+ do_rsync(config, destination, uri, isoname)
84 if config.do_verify:
85- config._log("Verifying " + flavor.name + '/' + isoname)
86+ config._log("Verifying " + destination+ '/' + isoname)
87 if not (config.debug or config.no_act):
88- if do_verify(config, flavor, hashsuffix, path, isoname):
89+ if do_verify(config, destination, hashsuffix, path, isoname):
90 config._log("Verification succeeded")
91 else:
92 config._log("!!! Verification failed !!!")
93@@ -481,6 +485,7 @@
94 parser.add_option('--isoroot', default='', action='store', type='string', help='local directory root to store isos; default is %s' %(default['isoroot']))
95 parser.add_option('--config', default=environ['HOME'] + '/.dl-ubuntu-test-iso', action='store', type='string',
96 help='choose alternate config file location, default is %default')
97+ parser.add_option('--mirror', default=False, action='store_true', dest='mirror')
98
99 config, args = parser.parse_args()
100 if len(args) != 0: