Skip to content

Commit 50ab41f

Browse files
committed
Fixed package name bug in debian generator
Also fixed up the rosdebian generator and some tests.
1 parent 0d26549 commit 50ab41f

File tree

6 files changed

+64
-56
lines changed

6 files changed

+64
-56
lines changed

bloom/generators/debian/generate_cmd.py

+12-7
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,17 @@ def prepare_arguments(parser):
7676
return parser
7777

7878

79-
def main(args=None):
79+
def get_subs(pkg, os_name, os_version, ros_distro):
80+
return generate_substitutions_from_package(
81+
pkg,
82+
os_name,
83+
os_version,
84+
ros_distro
85+
)
86+
87+
88+
def main(args=None, get_subs_fn=None):
89+
get_subs_fn = get_subs_fn or get_subs
8090
_place_template_files = True
8191
_process_template_files = True
8292
package_path = os.getcwd()
@@ -109,12 +119,7 @@ def main(args=None):
109119
for path, pkg in pkgs_dict.items():
110120
template_files = None
111121
try:
112-
subs = generate_substitutions_from_package(
113-
pkg,
114-
os_name,
115-
os_version,
116-
ros_distro
117-
)
122+
subs = get_subs_fn(pkg, os_name, os_version, ros_distro)
118123
if _place_template_files:
119124
# Place template files
120125
place_template_files(path)

bloom/generators/debian/generator.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ def generate_substitutions_from_package(
195195
# Debian Increment Number
196196
data['DebianInc'] = deb_inc
197197
# Package name
198-
data['Package'] = package.name
198+
data['Package'] = sanitize_package_name(package.name)
199199
# Installation prefix
200200
data['InstallationPrefix'] = installation_prefix
201201
# Resolve dependencies
@@ -499,10 +499,8 @@ def place_template_files(self, debian_dir='debian'):
499499
execute_command('git add ' + debian_dir)
500500
execute_command('git commit -m "Placing debian template files"')
501501

502-
def generate_debian(self, package, debian_distro):
503-
info("Generating debian for {0}...".format(debian_distro))
504-
# Generate substitution values
505-
subs = generate_substitutions_from_package(
502+
def get_subs(self, package, debian_distro):
503+
return generate_substitutions_from_package(
506504
package,
507505
self.os_name,
508506
debian_distro,
@@ -511,6 +509,11 @@ def generate_debian(self, package, debian_distro):
511509
self.debian_inc,
512510
[p.name for p in self.packages.values()]
513511
)
512+
513+
def generate_debian(self, package, debian_distro):
514+
info("Generating debian for {0}...".format(debian_distro))
515+
# Generate substitution values
516+
subs = self.get_subs(package, debian_distro)
514517
# Handle gbp.conf
515518
subs['release_tag'] = self.get_release_tag(subs)
516519
# Template files

bloom/generators/rosdebian.py

+30-28
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
from __future__ import print_function
22

3-
import os
43
import traceback
54

65
from bloom.generators.debian import DebianGenerator
7-
from bloom.generators.debian import sanitize_package_name
6+
from bloom.generators.debian.generator import generate_substitutions_from_package
7+
from bloom.generators.debian.generate_cmd import main as debian_main
88

99
from bloom.logging import debug
1010
from bloom.logging import error
@@ -41,10 +41,18 @@ def summarize(self):
4141
info("Releasing for rosdistro: " + self.rosdistro)
4242
return ret
4343

44-
def generate_tag_name(self, data):
45-
tag_name = '{Package}_{Version}-{DebianInc}_{Distribution}'
46-
tag_name = 'debian/' + tag_name.format(**data)
47-
return tag_name
44+
def get_subs(self, package, debian_distro):
45+
subs = generate_substitutions_from_package(
46+
package,
47+
self.os_name,
48+
debian_distro,
49+
self.rosdistro,
50+
self.install_prefix,
51+
self.debian_inc,
52+
[p.name for p in self.packages.values()]
53+
)
54+
subs['Package'] = rosify_package_name(subs['Package'], self.rosdistro)
55+
return subs
4856

4957
def generate_branching_arguments(self, package, branch):
5058
deb_branch = 'debian/' + self.rosdistro + '/' + package.name
@@ -70,29 +78,23 @@ def prepare_arguments(parser):
7078
return parser
7179

7280

81+
def rosify_package_name(name, rosdistro):
82+
return 'ros-{0}-{1}'.format(rosdistro, name)
83+
84+
85+
def get_subs(pkg, os_name, os_version, ros_distro):
86+
subs = generate_substitutions_from_package(
87+
pkg,
88+
os_name,
89+
os_version,
90+
ros_distro
91+
)
92+
subs['Package'] = rosify_package_name(subs['Package'])
93+
return subs
94+
95+
7396
def main(args=None):
74-
if args is None:
75-
package_path = os.getcwd()
76-
place_template_files = False
77-
process_template_files = False
78-
else:
79-
package_path = args.package_path or os.getcwd()
80-
place_template_files = args.place_template_files
81-
process_template_files = args.process_template_files
82-
83-
if not place_template_files and not process_template_files:
84-
# Do both
85-
pass
86-
elif place_template_files:
87-
# Just place template files
88-
pass
89-
elif process_template_files:
90-
# Just process existing template files
91-
pass
92-
else:
93-
assert False, "This should not happen..."
94-
95-
print(package_path)
97+
debian_main(args, get_subs)
9698

9799

98100
# This describes this command to the loader

setup.cfg

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ all_files = 1
66
[upload_sphinx]
77
upload-dir = doc/build/html
88

9-
[nosetests]
10-
where=test
9+
# [nosetests]
10+
# where=test
1111
# with-coverage=0
1212
# cover-package=nose
1313
# debug=nose.loader

test/__init__.py

-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +0,0 @@
1-
# Add the scripts folder to the path
2-
3-
import os
4-
if 'PATH' in os.environ:
5-
scripts = os.path.join(os.path.dirname(__file__), '..', 'scripts')
6-
scripts = os.path.abspath(scripts)
7-
os.environ['PATH'] = scripts + ':' + os.environ['PATH']

test/system_tests/test_catkin_release.py

+12-7
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
from bloom.commands.git.patch import import_cmd
3131
from bloom.commands.git.patch import remove_cmd
3232

33+
from bloom.generators.debian.generator import sanitize_package_name
34+
3335

3436
def create_upstream_repository(packages, directory=None):
3537
upstream_dir = 'upstream_repo_groovy'
@@ -115,8 +117,9 @@ def _test_unary_package_repository(release_dir, version, directory=None):
115117
"no patches/release/groovy/foo branch"
116118
# was the release tag created?
117119
ret, out, err = user('git tag', return_io=True)
118-
assert out.count('release/groovy/foo/' + version + '-0') == 1, \
119-
"no release tag created"
120+
expected = 'release/groovy/foo/' + version + '-0'
121+
assert out.count(expected) == 1, \
122+
"no release tag created, expected: '{0}'".format(expected)
120123

121124
###
122125
### Make patch
@@ -189,7 +192,7 @@ def test_multi_package_repository(directory=None):
189192
"""
190193
directory = directory if directory is not None else os.getcwd()
191194
# Setup
192-
pkgs = ['foo', 'bar', 'baz']
195+
pkgs = ['foo', 'bar_ros', 'baz']
193196
upstream_dir = create_upstream_repository(pkgs, directory)
194197
upstream_url = 'file://' + upstream_dir
195198
release_url = create_release_repo(
@@ -289,17 +292,19 @@ def test_multi_package_repository(directory=None):
289292
ret, out, err = user('git tag', return_io=True)
290293
for pkg in pkgs:
291294
for distro in ['oneiric', 'precise', 'quantal']:
295+
pkg_san = sanitize_package_name(pkg)
292296
# Does the debian/distro/pkg branch exist?
293297
assert branch_exists('debian/groovy/' + distro + '/' + pkg), \
294-
"no release/" + pkg + " branch"
298+
"no debian/groovy/" + pkg + " branch"
295299
# Does the patches/debian/distro/pkg branch exist?
296300
patches_branch = 'patches/debian/groovy/' + distro + '/' + pkg
297301
assert branch_exists(patches_branch), \
298-
"no patches/release/" + pkg + " branch"
302+
"no " + patches_branch + " branch"
299303
# Did the debian tag get created?
300-
tag = 'debian/ros-groovy-' + pkg + '_0.1.0-0_' + distro
304+
tag = 'debian/ros-groovy-' + pkg_san + '_0.1.0-0_' + distro
301305
assert out.count(tag) == 1, \
302-
"no release tag created for '" + pkg + "': `" + out + "`"
306+
"no '" + tag + "'' tag created for '" + pkg + "': `\n" + \
307+
out + "\n`"
303308
# Is there a package.xml in the top level?
304309
with inbranch('debian/groovy/' + distro + '/' + pkg):
305310
assert os.path.exists('package.xml'), "release branch invalid"

0 commit comments

Comments
 (0)