Skip to content

Commit ad04e8e

Browse files
syuu1228penberg
authored andcommitted
dist/debian: fix renaming debian/scylla-* files rule
Current renaming rule of debian/scylla-* files is buggy, it fails to install some .service files when custom product name specified. Introduce regex based rewriting instead of adhoc renaming, and fixed wrong renaming rule. This is not needed for scylla-python3 since it doesn't use systemd unit, but better to sync same code with scylla main repo. Closes #18
1 parent dead932 commit ad04e8e

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

dist/debian/debian_files_gen.py

+18-4
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@
2323

2424
import string
2525
import os
26-
import glob
2726
import shutil
27+
import re
28+
from pathlib import Path
2829

2930
class DebianFilesTemplate(string.Template):
3031
delimiter = '%'
@@ -46,12 +47,25 @@ class DebianFilesTemplate(string.Template):
4647
with open('build/SCYLLA-RELEASE-FILE') as f:
4748
release = f.read().strip()
4849

49-
shutil.rmtree('build/debian/debian', ignore_errors=True)
50+
if os.path.exists('build/debian/debian'):
51+
shutil.rmtree('build/debian/debian')
5052
shutil.copytree('dist/debian/debian', 'build/debian/debian')
5153

5254
if product != 'scylla':
53-
for p in glob.glob('build/debian/debian/scylla-*'):
54-
shutil.move(p, p.replace('scylla-', '{}-'.format(product)))
55+
for p in Path('build/debian/debian').glob('scylla-*'):
56+
# pat1: scylla-server.service
57+
# -> scylla-enterprise-server.scylla-server.service
58+
# pat2: scylla-server.scylla-fstrim.service
59+
# -> scylla-enterprise-server.scylla-fstrim.service
60+
# pat3: scylla-conf.install
61+
# -> scylla-enterprise-conf.install
62+
63+
if m := re.match(r'^scylla(-[^.]+)\.service$', p.name):
64+
p.rename(p.parent / f'{product}{m.group(1)}.{p.name}')
65+
elif m := re.match(r'^scylla(-[^.]+\.scylla-[^.]+\.[^.]+)$', p.name):
66+
p.rename(p.parent / f'{product}{m.group(1)}')
67+
else:
68+
p.rename(p.parent / p.name.replace('scylla', product, 1))
5569

5670
s = DebianFilesTemplate(changelog_template)
5771
changelog_applied = s.substitute(product=product, version=version, release=release, revision='1', codename='stable')

0 commit comments

Comments
 (0)