Merge lp:~vorlon/ubuntu-archive-tools/kernel-sru-review-simplify into lp:ubuntu-archive-tools

Proposed by Steve Langasek
Status: Merged
Approved by: Łukasz Zemczak
Approved revision: 1107
Merged at revision: 1133
Proposed branch: lp:~vorlon/ubuntu-archive-tools/kernel-sru-review-simplify
Merge into: lp:ubuntu-archive-tools
Diff against target: 101 lines (+34/-40)
1 file modified
kernel-sru-review (+34/-40)
To merge this branch: bzr merge lp:~vorlon/ubuntu-archive-tools/kernel-sru-review-simplify
Reviewer Review Type Date Requested Status
Łukasz Zemczak Approve
Review via email: mp+327224@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Łukasz Zemczak (sil2100) wrote :

Right! Now that we split tarball caching into two options: tarball cache directory to use and switch if new tarballs should be cached or not, it makes sense to just drop those unnecessary checks now. +1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'kernel-sru-review'
2--- kernel-sru-review 2017-07-11 09:42:43 +0000
3+++ kernel-sru-review 2017-07-11 16:02:01 +0000
4@@ -70,48 +70,45 @@
5 def fetch_tarball_from_cache(directory, tardir, source, version, cwd):
6 actual_tardir = None
7 tarballs = []
8- # if a tarball directory is given, try to find the tarball there
9- if tardir:
10- glob_pattern = '%s_%s.orig.tar.*' % (source, version)
11- # first we look in the current working directory where the command was
12- # called from
13- actual_tardir = cwd
14- tarballs = glob.glob(os.path.join(cwd, glob_pattern))
15- if not tarballs:
16- actual_tardir = tardir
17- tarballs = glob.glob(os.path.join(tardir, glob_pattern))
18- if tarballs:
19- target = os.path.join(directory, os.path.basename(tarballs[0]))
20- try:
21- os.link(tarballs[0], target)
22- except FileExistsError:
23- pass
24- except:
25- # if the hard linking fails, do a copy operation
26- shutil.copy(tarballs[0], target)
27- else:
28- actual_tardir = None
29+
30+ glob_pattern = '%s_%s.orig.tar.*' % (source, version)
31+ # first we look in the current working directory where the command was
32+ # called from
33+ actual_tardir = cwd
34+ tarballs = glob.glob(os.path.join(cwd, glob_pattern))
35+ if not tarballs:
36+ actual_tardir = tardir
37+ tarballs = glob.glob(os.path.join(tardir, glob_pattern))
38+ if tarballs:
39+ target = os.path.join(directory, os.path.basename(tarballs[0]))
40+ try:
41+ os.link(tarballs[0], target)
42+ except FileExistsError:
43+ pass
44+ except:
45+ # if the hard linking fails, do a copy operation
46+ shutil.copy(tarballs[0], target)
47+ else:
48+ actual_tardir = None
49 return actual_tardir
50
51
52 def save_tarball_to_cache(directory, tardir, source, version):
53- # if we use a tarball directory and downloaded a new tarball, copy it over
54- if tardir:
55- glob_pattern = '%s_%s.orig.tar.*' % (source, version)
56- to_copy = glob.glob(os.path.join(directory, glob_pattern))
57- for tarball in to_copy:
58- target = os.path.join(tardir, os.path.basename(tarball))
59- try:
60- os.link(tarball, target)
61- except FileExistsError:
62- pass
63- except:
64- # if the hard linking fails, do a copy operation
65- shutil.copy(tarball, target)
66+ glob_pattern = '%s_%s.orig.tar.*' % (source, version)
67+ to_copy = glob.glob(os.path.join(directory, glob_pattern))
68+ for tarball in to_copy:
69+ target = os.path.join(tardir, os.path.basename(tarball))
70+ try:
71+ os.link(tarball, target)
72+ except FileExistsError:
73+ pass
74+ except:
75+ # if the hard linking fails, do a copy operation
76+ shutil.copy(tarball, target)
77
78
79 def process_source_package(source, release, archive, ppa, ubuntu,
80- start_dir, work_dir, tardir=None, tar_cache=False):
81+ start_dir, work_dir, tardir, tar_cache=False):
82 series = ubuntu.getSeries(name_or_version=release)
83
84 ppa_src = ppa.getPublishedSources(order_by_date=True,
85@@ -261,14 +258,11 @@
86 if len(bugs) < 1:
87 parser.error('Need to specify at least one bug number')
88
89- if opts.tardir:
90- tardir = os.path.abspath(opts.tardir)
91- else:
92- tardir = None
93+ tardir = os.path.abspath(opts.tardir)
94
95 if opts.caching:
96 # if we enabled tarball caching, make sure the tarball directory exists
97- if tardir and not os.path.isdir(tardir):
98+ if not os.path.isdir(tardir):
99 try:
100 os.makedirs(tardir)
101 except:

Subscribers

People subscribed via source and target branches