Merge ~darinmiller/ka:master into ka:master

Proposed by Darin Miller on 2017-03-07
Status: Merged
Merged at revision: 8dd04806023e464efa97301fa5a4f94ef497bb6d
Proposed branch: ~darinmiller/ka:master
Merge into: ka:master
Diff against target: 186 lines (+22/-21)
7 files modified
do-all (+5/-5)
get-kci-tarball (+1/-1)
ka-update-metadata (+2/-2)
kubuntu-create-sru-branches (+1/-1)
staging-upload (+9/-9)
ubuntu-archive-upload (+2/-2)
uploadsource (+2/-1)
Reviewer Review Type Date Requested Status
Jose Manuel Santamaria Lema 2017-03-07 Approve on 2017-03-10
Review via email: mp+319205@code.launchpad.net

Description of the Change

santa_requested a code cleanup-replacing manually built path strings in the ka python scripts with the os.path.join function.

The following grep commands were performed to find scripts with manual path builds:
- grep "\'/\'" *
- grep "\"/\"" *

The following scripts were modified:

        modified: do-all
        modified: get-kci-tarball
        modified: ka-update-metadata
        modified: kubuntu-create-sru-branches
        modified: staging-upload
        modified: ubuntu-archive-upload
        modified: uploadsource

PLEASE double check my edits that I did not extend a path build beyond the parameter in which the path was built. i.e. some functions were passing manually built paths in the function invocation. Since I do not know how or may not have the privilege to run these scripts...

  THESE EDITS ARE UNTESTED!

To post a comment you must log in.

Hi Darin,

I have just read the diff and it seems mostly ok, I plan to use KA with these changes for a while to check everything works as expected. Since you mention that you may or may not have permissions to test the changes yourself, let's see one by one.

do-all:
This command iterates over several directories executing the command given, so if you have a set of clones created with git-clone-all you should be able to test a "do-all ls" against that set of clones.

get-kci-tarball:
This program creates a 'fake' kci tarball when executed from a particular clone, so inside any clone of frameworks/plasma/apps packaging you should be able to execute this and get an orig tarball in the build-area directory. The tarball is created using KDE's git anonymously, so you shouldn't need any kind of privilege to test it.

ka-update-metadata:
This is something we use to execute when providing a new release (see the README.ng) to test this maybe we could mentor you to do something real, like any frameworks/plasma/apps backport we don't have right now or something like that. We could arrange this by IRC. This way you will get more familiar with our KA scriptery.

uploadsource:
This one is just an optional program from KA meant to be a small wrapper around dput/dupload. If I'm not mistaken, you could test it uploading any package from frameworks/plasma/apps to any of your ppas like this:
uploadsource -t <your_ppa>

kubuntu-create-sru-branches, staging-upload, ubuntu-archive-upload:
These ones are the old ugly monolithic scripts which we replaced by UNIX-like git-clone-all/do-all/gbp-* and friends after the "Slice" operation[1]. I would drop the changes on these, since what I'm planning to do is writing a mail to kubuntu-devel mailing list notifying that I'm going to move them to an "attic/" directory as part of the "Fir Tree" operation[2]. This way it would be easier to
know if a script is obsolete or not without removing it completely just in case we want to recycle any code in them.

[1]https://phabricator.kde.org/w/kubuntu/black-operations/slice/
[2]https://phabricator.kde.org/w/kubuntu/black-operations/fir-tree/

Hi,

since we needed to add a new feature to do-all I have just merged into master the proposed changes, they seem to work fine so far. If anything, we could fix it later.

Thanks for the patch Darin.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/do-all b/do-all
2index 39ce3f7..f2d908f 100755
3--- a/do-all
4+++ b/do-all
5@@ -84,19 +84,19 @@ n = len(dirs)
6 for directory in dirs:
7 i += 1
8 print("----------------------------------------------------------------------")
9- print("do-all current directory: %s (%s of %s)" % (directory+'/'+subdirectory,i,n))
10+ print("do-all current directory: %s (%s of %s)" % (os.path.join(directory, subdirectory),i,n))
11 print("----------------------------------------------------------------------")
12 sys.stdout.flush()
13 try:
14- os.chdir(old_cwd + '/' + directory + '/' + subdirectory )
15+ os.chdir(os.path.join(old_cwd, directory, subdirectory))
16 except:
17- dirs_not_accessible.append(directory + '/' + subdirectory)
18+ dirs_not_accessible.append(os.path.join(directory, subdirectory))
19 print("directory not accessible, failed to 'cd' into it")
20 continue
21 if directory in skip_list:
22 print("As requested by the configuration file,\n"
23 "the command wasn't executed in this directory")
24- dirs_ignored.append(directory + '/' + subdirectory)
25+ dirs_ignored.append(os.path.join(directory, subdirectory))
26 continue
27 try:
28 returncode = subprocess.call(command)
29@@ -109,7 +109,7 @@ for directory in dirs:
30 #http://www.tldp.org/LDP/abs/html/exitcodes.html
31 returncode = 127
32 if returncode != 0:
33- dirs_failed.append((directory+'/'+subdirectory,returncode))
34+ dirs_failed.append((os.path.join(directory, subdirectory), returncode))
35 sys.stdout.flush()
36
37 #Print summary
38diff --git a/get-kci-tarball b/get-kci-tarball
39index 7675f20..fbf3271 100755
40--- a/get-kci-tarball
41+++ b/get-kci-tarball
42@@ -58,7 +58,7 @@ kde_git_repository_url = "https://anongit.kde.org/%s" % upstream_name
43
44 #Create temporary directory to clone the repository.
45 temp_dir = tempfile.TemporaryDirectory()
46-kde_clone_dir_name = temp_dir.name+"/"+upstream_name
47+kde_clone_dir_name = os.path.join(temp_dir.name, upstream_name)
48
49 #Clone repository
50 returncode = subprocess.call(["git","clone",kde_git_repository_url,kde_clone_dir_name])
51diff --git a/ka-update-metadata b/ka-update-metadata
52index a99c489..dcb6cd1 100755
53--- a/ka-update-metadata
54+++ b/ka-update-metadata
55@@ -77,7 +77,7 @@ for d in dirs:
56 d = d.split("-opensource-src")[0]
57 #Find out source package version
58 changelog = Changelog()
59- changelog_file_name = d + '/' + subdir + '/debian/changelog'
60+ changelog_file_name = os.path.join(d, subdir, 'debian/changelog')
61 try:
62 changelog.parse_changelog(codecs.open(changelog_file_name, 'r', 'utf-8'))
63 except FileNotFoundError:
64@@ -114,7 +114,7 @@ for d in dirs:
65 # With the info parsed from $PWD/*/debian/control populate:
66 # - build_depends_set <- with all the binary packages appearing in Build-Depends[-Indep]
67 # - dev_package_version_map <- with all the binary packages with their versions
68- control_file_name = d + '/' + subdir + '/debian/control'
69+ control_file_name = os.path.join(d, subdir, 'debian/control')
70 try:
71 control_file = deb822.Packages.iter_paragraphs(open(control_file_name, 'r'));
72 except FileNotFoundError:
73diff --git a/kubuntu-create-sru-branches b/kubuntu-create-sru-branches
74index c4bfd13..a71288f 100755
75--- a/kubuntu-create-sru-branches
76+++ b/kubuntu-create-sru-branches
77@@ -58,7 +58,7 @@ for package in packages:
78 print("Branching %s ..." % branch_url)
79 subprocess.check_call(["bzr", "branch", branch_url])
80
81- os.chdir(workdir + "/" + package)
82+ os.chdir(os.path.join(workdir, package))
83 with open("debian/control", "r") as f:
84 control = f.read()
85
86diff --git a/staging-upload b/staging-upload
87index 3e9eb43..57e2842 100755
88--- a/staging-upload
89+++ b/staging-upload
90@@ -186,12 +186,12 @@ for package in packages:
91 continue
92
93 try:
94- os.mkdir(basedir + "/" + package)
95+ os.mkdir(os.path.join(basedir, package))
96 except OSError:
97- print("removing existing " + basedir + "/" + package)
98- shutil.rmtree(basedir + "/" + package)
99- os.mkdir(basedir + "/" + package)
100- os.chdir(basedir + "/" + package)
101+ print("removing existing " os.path.join(basedir, package))
102+ shutil.rmtree(os.path.join(basedir, package))
103+ os.mkdir(os.path.join(basedir, package))
104+ os.chdir(os.path.join(basedir, package))
105 if package in packagingExceptions:
106 upstreamVersion = packagingExceptions[package]
107 else:
108@@ -215,7 +215,7 @@ for package in packages:
109 subprocess.check_call(["rsync", "--progress", "-z", "--copy-links", "--compress-level=9", "-e ssh", remote, "."])
110 except:
111 print("==== Skipping %s, failed to fetch tarball from depot.kde.org, moving to manual/" % (package))
112- shutil.move(basedir + "/" + package, basedir + "/manual/" + package)
113+ shutil.move(os.path.join(basedir, package), os.path.join(basedir, "manual", package))
114 moved.append((package, "failed to fetch tarball from depot"))
115 continue
116 orig = "%s_%s.orig.tar.xz" % (package, upstreamVersion)
117@@ -237,7 +237,7 @@ for package in packages:
118 match = re.match(re.escape(package) + r'_([\d\.a-z]+)-', dscname)
119 if not match:
120 print("==== Skipping %s, version parsing failed, moving to manual/" % (package,))
121- shutil.move(basedir + "/" + package, basedir + "/manual/" + package)
122+ shutil.move(os.path.join(basedir, package), os.path.join(basedir, "manual", package))
123 moved.append((package, "version parsing failed"))
124 continue
125
126@@ -297,7 +297,7 @@ for package in packages:
127
128 if not sanitizeBranch(package):
129 print "==== Skipping %s, git branch has unexpected content, moving to manual/" % (package,)
130- shutil.move(basedir + "/" + package, basedir + "/manual/" + package)
131+ shutil.move(os.path.join(basedir, package), os.path.join(basedir, "manual" , package))
132 moved.append((package, "git unclean or out of sync"))
133 continue
134
135@@ -346,7 +346,7 @@ for package in packages:
136 # package build failed, manual intervention necessary
137 print "==== " + package + " build was interrupted, moving to manual/"
138 shutil.rmtree(basedir + "/manual/" + package, True)
139- shutil.move(basedir + "/" + package, basedir + "/manual/" + package)
140+ shutil.move(os.path.join(basedir, package), os.path.join(basedir, "manual", package))
141 moved.append((package, "build was interrupted"))
142
143 print("\n\n=== Packages are ready for upload in " + uploaddir)
144diff --git a/ubuntu-archive-upload b/ubuntu-archive-upload
145index c32f3f1..591acaa 100755
146--- a/ubuntu-archive-upload
147+++ b/ubuntu-archive-upload
148@@ -126,7 +126,7 @@ for package in packages:
149 except IndexError:
150 print "=== %s not in the archive, new package?" % (package)
151
152- packageDir = basedir + "/" + package
153+ packageDir = os.path.join(basedir, package)
154 try:
155 os.mkdir(packageDir)
156 except OSError:
157@@ -145,7 +145,7 @@ for package in packages:
158 if package == "kde4libs":
159 print "MMM gitName = kde4libs"
160 gitName = "kde4libs" # as an exception this one has git repo named after package
161- subprocess.check_call(["git", "clone", debian_git + "/" + gitName, "git"])
162+ subprocess.check_call(["git", "clone", os.path.join(debian_git, gitName), "git"])
163 os.chdir("git")
164 subprocess.check_call(["git", "checkout", "kubuntu_"+release+"_archive"])
165 else:
166diff --git a/uploadsource b/uploadsource
167index 69a8f83..6ca1df7 100755
168--- a/uploadsource
169+++ b/uploadsource
170@@ -15,6 +15,7 @@ import subprocess
171 import sys
172 import argparse
173 import glob
174+import os
175
176 from debian.changelog import Changelog, Version
177
178@@ -62,7 +63,7 @@ if changelog.debian_revision != None:
179 version += "-" + changelog.debian_revision
180
181 #Find out the filename to upload
182-file_pattern = ka_config['areas']['upload-area'] + "/" + src_pkg + "_" + version + "*_source.changes"
183+file_pattern = os.path.join(ka_config['areas']['upload-area'], src_pkg + "_" + version + "*_source.changes")
184 files = glob.glob(file_pattern)
185
186 if not files:

Subscribers

People subscribed via source and target branches