Now autoupdate parameter works correctly for templates with append="link". fixed #72

master
Иванов Денис 3 years ago
parent 48fa72e999
commit 8d062eaa7c

@ -524,6 +524,7 @@ class TemplateWrapper:
self.contents_matching = (self.parameters.autoupdate
or self.parameters.force)
print(f'contents_matching: {self.contents_matching}')
if not self.protected:
self.contents_matching = True
@ -535,7 +536,8 @@ class TemplateWrapper:
elif self.target_type is None:
# Если целевой файл отсутствует.
if self.target_path in self.target_package:
if (self.target_path in self.target_package and
not self.parameters.autoupdate):
# Проверка -- был ли файл удален.
self.contents_matching = False
pass

@ -4,6 +4,7 @@ import shutil
import hashlib
from pprint import pprint
from stat import ST_MODE
from typing import Optional, List
from calculate.templates.template_processor import DirectoryProcessor,\
TemplateWrapper
from calculate.utils.package import PackageAtomName, Version, Package,\
@ -90,15 +91,29 @@ datavars = Variables({'install': install,
def show_tree(dir_path: str, indent: int = 0,
files_only: bool = False) -> None:
test_names: Optional[List[str]] = None) -> None:
last_names = dict()
if test_names is not None:
for name in test_names:
last_names[name] = 0
print('{}{}/'.format(' ' * 4 * indent, os.path.basename(dir_path)))
indent += 1
for node in os.scandir(dir_path):
if node.is_dir():
if not files_only:
show_tree(node.path, indent=indent)
show_tree(node.path, indent=indent)
else:
print('{}{}'.format(' ' * 4 * indent, node.name))
print('{}{}'.format(' ' * indent, node.name))
pass
if last_names:
for name in test_names:
if node.name.startswith(name):
number = int(node.name[len(name) + 1:])
if number > last_names[name]:
last_names[name] = number
break
return [f"{name}_{number}" for name, number in last_names.items()]
@pytest.mark.directory_processor
@ -1820,9 +1835,27 @@ class TestDirectoryProcessor:
assert os.path.exists(join_paths(CHROOT_PATH, '/etc/file_21'))
assert os.path.exists(join_paths(CHROOT_PATH, '/etc/file_22'))
def test_autoupdate_for_symlink(self):
datavars.main['cl_template_path'] = os.path.join(CHROOT_PATH,
'templates_63')
directory_processor = DirectoryProcessor('install',
datavars_module=datavars)
directory_processor.process_template_directories()
assert os.path.lexists(join_paths(CHROOT_PATH, '/etc/link_4'))
assert os.path.lexists(join_paths(CHROOT_PATH,
'/etc/._cfg0000_link_5'))
def test_view_tree(self):
list_path = join_paths(CHROOT_PATH, '/etc')
show_tree(list_path)
test_names = ['dir', 'file', 'link']
last_names = show_tree(list_path,
test_names=test_names)
if last_names:
print('last names:')
print("\n".join(
[f"{name}: {last}" for name, last in zip(test_names,
last_names)]))
assert True
def test_for_removing_testfile(self):

@ -0,0 +1 @@
claudio monteverdi -- lamento della ninfa: amor

@ -0,0 +1 @@
salem -- i buried my heart inna wounded knee

@ -0,0 +1 @@
{% calculate append = "skip", action = "install", package = "test-category/test-package" %}

@ -0,0 +1 @@
{% calculate append = "link", source = "/etc/file_24", autoupdate %}

@ -0,0 +1 @@
{% calculate append = "link", source = "/etc/file_24" %}

@ -16,3 +16,5 @@ obj /etc/dir_77/file_0 3fd436479300b04370b97f4bcfdc90f7 1592574626
dir /etc/dir_78
obj /etc/dir_78/file_0 3fd436479300b04370b97f4bcfdc90f7 1592574626
obj /etc/dir_78/file_1 3fd436479300b04370b97f4bcfdc90f7 1592574626
sym /etc/link_4 -> /etc/file_24 1553449095
sym /etc/link_5 -> /etc/file_25 1553449095

Loading…
Cancel
Save