Merge ~chad.smith/cloud-init:make-deb-cleanup into cloud-init:master

Proposed by Chad Smith
Status: Merged
Merge reported by: Scott Moser
Merged at revision: not available
Proposed branch: ~chad.smith/cloud-init:make-deb-cleanup
Merge into: cloud-init:master
Diff against target: 175 lines (+40/-64)
2 files modified
Makefile (+4/-0)
packages/bddeb (+36/-64)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve
cloud-init Commiters Pending
Review via email: mp+323076@code.launchpad.net

Commit message

make deb: Add devscripts dependency for make deb. Cleanup packages/bddeb.

Add a simple dependency check to "make deb" target for devscripts. Rework a bit of the logic in package/bddeb to drop superfluous STD_NAMED_PACKAGES to avoid duplication of requirements already listed in (test-)?requirements.txt. All "standard" packages can be assumed to have either python3- or python- prefix if not listed in NONSTD_NAMED_PACKAGES.

This branch also moves logic inside write_debian_folder which is unneeded up in main. Moving the logic inside write_debian_folder helps cut down on the number of parameters we need to paas into the function.

LP: #1685935

Description of the change

make deb: Add dependency on devscripts for make deb and minor cleanup of packages/bddeb script.

Add a simple dependency check to "make deb" target for devscripts. Rework a bit of the logic in package/bddeb to drop superfluous STD_NAMED_PACKAGES to avoid duplication of requirements already listed in (test-)?requiremets.txt. All "standard" packages can be assumed to have either python3- or python- prefix if not listed in NONSTD_NAMED_PACKAGES. This branch also moves logic inside write_debian_folder which is unneeded up in main.

to test:
make deb # will print install instruction on a machine without devscripts

# check final product to make sure dependencies listed haven't changed for the package
dpkg -I cloud-init_all.deb

Note: I didn't address reading build-deps directly from the debian/config.in template as the error message you receive about build-deps seemed fairly straight forward if some build-deps are missing.

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ryan Harper (raharper) wrote :

Some thoughts on this:

1) we don't want users who apt install cloud-init to also pull down python-devel, gcc and have to compile the extension, so please don't change package deps here

2) this is currently an issue for the tox/venv environment, so let's focus on how to enable the SafeLoader library for that path

3) Once we make (2) an optional testing path (env or parameter can trigger the dep install prior to calling tox/venv which triggers the compile during pip install of the module IIUC), we can have two travis paths, one without the library (representing how things work today) and one *with* the library enabled. This allows us to compare results, unittests all pass, and time it takes to complete (some estimate of the improvement it may provide).

4) With results from (3), we may propose changes to the underlying images (server seed, cloud-image seed, etc) which could ensure that the library is present in the default cloud images.

Revision history for this message
Chad Smith (chad.smith) wrote :

Thanks Ryan for the review points, I know you are commenting on the Safeloader proposal which is over here https://code.launchpad.net/~chad.smith/cloud-init/+git/cloud-init/+merge/323088 so I'll copy them over to that proposal and comment over there.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/Makefile b/Makefile
index 5940ed7..a76dac7 100644
--- a/Makefile
+++ b/Makefile
@@ -82,6 +82,10 @@ rpm:
82 ./packages/brpm --distro $(distro)82 ./packages/brpm --distro $(distro)
8383
84deb:84deb:
85 @which debuild || \
86 { echo "Missing devscripts dependency. Install with:"; \
87 echo sudo apt-get install devscripts; exit 1; }
88
85 ./packages/bddeb89 ./packages/bddeb
8690
87.PHONY: test pyflakes pyflakes3 clean pep8 rpm deb yaml check_version91.PHONY: test pyflakes pyflakes3 clean pep8 rpm deb yaml check_version
diff --git a/packages/bddeb b/packages/bddeb
index 79ac976..f415209 100755
--- a/packages/bddeb
+++ b/packages/bddeb
@@ -24,35 +24,17 @@ if "avoid-pep8-E402-import-not-top-of-file":
24 from cloudinit import templater24 from cloudinit import templater
25 from cloudinit import util25 from cloudinit import util
2626
27# Package names that will showup in requires to what we can actually27# Package names that will showup in requires which have unique package names.
28# use in our debian 'control' file, this is a translation of the 'requires'28# Format is '<pypi-name>': {'<python_major_version>': <pkg_name_or_none>, ...}.
29# file pypi package name to a debian/ubuntu package name.
30STD_NAMED_PACKAGES = [
31 'configobj',
32 'coverage',
33 'jinja2',
34 'jsonpatch',
35 'oauthlib',
36 'prettytable',
37 'requests',
38 'six',
39 'httpretty',
40 'mock',
41 'nose',
42 'setuptools',
43 'flake8',
44 'hacking',
45 'unittest2',
46]
47NONSTD_NAMED_PACKAGES = {29NONSTD_NAMED_PACKAGES = {
48 'argparse': ('python-argparse', None),30 'argparse': {'2': 'python-argparse', '3': None},
49 'contextlib2': ('python-contextlib2', None),31 'contextlib2': {'2': 'python-contextlib2', '3': None},
50 'cheetah': ('python-cheetah', None),32 'cheetah': {'2': 'python-cheetah', '3': None},
51 'pyserial': ('python-serial', 'python3-serial'),33 'pyserial': {'2': 'python-serial', '3': 'python3-serial'},
52 'pyyaml': ('python-yaml', 'python3-yaml'),34 'pyyaml': {'2': 'python-yaml', '3': 'python3-yaml'},
53 'six': ('python-six', 'python3-six'),35 'six': {'2': 'python-six', '3': 'python3-six'},
54 'pep8': ('pep8', 'python3-pep8'),36 'pep8': {'2': 'pep8', '3': 'python3-pep8'},
55 'pyflakes': ('pyflakes', 'pyflakes'),37 'pyflakes': {'2': 'pyflakes', '3': 'pyflakes'},
56}38}
5739
58DEBUILD_ARGS = ["-S", "-d"]40DEBUILD_ARGS = ["-S", "-d"]
@@ -68,8 +50,17 @@ def run_helper(helper, args=None, strip=True):
68 return stdout50 return stdout
6951
7052
71def write_debian_folder(root, templ_data, pkgmap, pyver="3",53def write_debian_folder(root, templ_data, is_python2, cloud_util_deps):
72 append_requires=[]):54 """Create a debian package directory with all rendered template files."""
55 print("Creating a debian/ folder in %r" % (root))
56 if is_python2:
57 pyver = "2"
58 python = "python"
59 else:
60 pyver = "3"
61 python = "python3"
62 pkgfmt = "{}-{}"
63
73 deb_dir = util.abs_join(root, 'debian')64 deb_dir = util.abs_join(root, 'debian')
7465
75 # Just copy debian/ dir and then update files66 # Just copy debian/ dir and then update files
@@ -91,21 +82,16 @@ def write_debian_folder(root, templ_data, pkgmap, pyver="3",
91 pypi_test_pkgs = [p.lower().strip() for p in test_reqs]82 pypi_test_pkgs = [p.lower().strip() for p in test_reqs]
9283
93 # Map to known packages84 # Map to known packages
94 requires = append_requires85 requires = ['cloud-utils | cloud-guest-utils'] if cloud_util_deps else []
95 test_requires = []86 test_requires = []
96 lists = ((pypi_pkgs, requires), (pypi_test_pkgs, test_requires))87 lists = ((pypi_pkgs, requires), (pypi_test_pkgs, test_requires))
97 for pypilist, target in lists:88 for pypilist, target in lists:
98 for p in pypilist:89 for p in pypilist:
99 if p not in pkgmap:90 if p in NONSTD_NAMED_PACKAGES:
100 raise RuntimeError(("Do not know how to translate pypi "91 if NONSTD_NAMED_PACKAGES[p][pyver]:
101 "dependency %r to a known package") % (p))92 target.append(NONSTD_NAMED_PACKAGES[p][pyver])
102 elif pkgmap[p]:93 else: # Then standard package prefix
103 target.append(pkgmap[p])94 target.append(pkgfmt.format(python, p))
104
105 if pyver == "3":
106 python = "python3"
107 else:
108 python = "python"
10995
110 templater.render_to_file(util.abs_join(find_root(),96 templater.render_to_file(util.abs_join(find_root(),
111 'packages', 'debian', 'control.in'),97 'packages', 'debian', 'control.in'),
@@ -124,8 +110,8 @@ def read_version():
124 return json.loads(run_helper('read-version', ['--json']))110 return json.loads(run_helper('read-version', ['--json']))
125111
126112
127def main():113def get_parser():
128114 """Setup and return an argument parser for bdeb tool."""
129 parser = argparse.ArgumentParser()115 parser = argparse.ArgumentParser()
130 parser.add_argument("-v", "--verbose", dest="verbose",116 parser.add_argument("-v", "--verbose", dest="verbose",
131 help=("run verbosely"117 help=("run verbosely"
@@ -162,7 +148,11 @@ def main():
162148
163 parser.add_argument("--signuser", default=False, action='store',149 parser.add_argument("--signuser", default=False, action='store',
164 help="user to sign, see man dpkg-genchanges")150 help="user to sign, see man dpkg-genchanges")
151 return parser
152
165153
154def main():
155 parser = get_parser()
166 args = parser.parse_args()156 args = parser.parse_args()
167157
168 if not args.sign:158 if not args.sign:
@@ -177,18 +167,6 @@ def main():
177 if args.verbose:167 if args.verbose:
178 capture = False168 capture = False
179169
180 pkgmap = {}
181 for p in NONSTD_NAMED_PACKAGES:
182 pkgmap[p] = NONSTD_NAMED_PACKAGES[p][int(not args.python2)]
183
184 for p in STD_NAMED_PACKAGES:
185 if args.python2:
186 pkgmap[p] = "python-" + p
187 pyver = "2"
188 else:
189 pkgmap[p] = "python3-" + p
190 pyver = "3"
191
192 templ_data = {'debian_release': args.release}170 templ_data = {'debian_release': args.release}
193 with util.tempdir() as tdir:171 with util.tempdir() as tdir:
194172
@@ -208,16 +186,10 @@ def main():
208 util.subp(cmd, capture=capture)186 util.subp(cmd, capture=capture)
209187
210 xdir = util.abs_join(tdir, "cloud-init-%s" % ver_data['version_long'])188 xdir = util.abs_join(tdir, "cloud-init-%s" % ver_data['version_long'])
211
212 print("Creating a debian/ folder in %r" % (xdir))
213 if args.cloud_utils:
214 append_requires = ['cloud-utils | cloud-guest-utils']
215 else:
216 append_requires = []
217
218 templ_data.update(ver_data)189 templ_data.update(ver_data)
219 write_debian_folder(xdir, templ_data, pkgmap,190
220 pyver=pyver, append_requires=append_requires)191 write_debian_folder(xdir, templ_data, is_python2=args.python2,
192 cloud_util_deps=args.cloud_utils)
221193
222 print("Running 'debuild %s' in %r" % (' '.join(args.debuild_args),194 print("Running 'debuild %s' in %r" % (' '.join(args.debuild_args),
223 xdir))195 xdir))

Subscribers

People subscribed via source and target branches