Revision fd38a0e1
Added by koszko over 1 year ago
| src/hydrilla/builder/build.py | ||
|---|---|---|
| 339 | 339 |
|
| 340 | 340 |
def write_package_files(self, dstpath: Path): |
| 341 | 341 |
"""Write package files under 'dstpath' for distribution.""" |
| 342 |
file_dir_path = (dstpath / 'file').resolve() |
|
| 342 |
file_dir_path = (dstpath / 'file' / 'sha256').resolve()
|
|
| 343 | 343 |
file_dir_path.mkdir(parents=True, exist_ok=True) |
| 344 | 344 |
|
| 345 | 345 |
for file_ref in self.files_by_path.values(): |
| 346 | 346 |
if file_ref.include_in_distribution: |
| 347 |
file_name = f'sha256-{file_ref.contents_hash}'
|
|
| 348 |
with open(file_dir_path / file_name, 'wb') as output: |
|
| 349 |
output.write(file_ref.contents) |
|
| 347 |
file_path = file_dir_path / file_ref.contents_hash |
|
| 348 |
file_path.write_bytes(file_ref.contents) |
|
| 350 | 349 |
|
| 351 | 350 |
source_dir_path = (dstpath / 'source').resolve() |
| 352 | 351 |
source_dir_path.mkdir(parents=True, exist_ok=True) |
| src/test/test_hydrilla_builder.py | ||
|---|---|---|
| 298 | 298 |
set([path.name for path in dstdir.iterdir()]) |
| 299 | 299 |
|
| 300 | 300 |
# Verify files under 'file/' |
| 301 |
file_dir = dstdir / 'file' |
|
| 301 |
file_dir = dstdir / 'file' / 'sha256'
|
|
| 302 | 302 |
|
| 303 | 303 |
for fn in settings.dist_filenames: |
| 304 |
dist_file_path = file_dir / f'sha256-{settings.sha256_hashes[fn]}'
|
|
| 304 |
dist_file_path = file_dir / settings.sha256_hashes[fn]
|
|
| 305 | 305 |
assert dist_file_path.is_file() |
| 306 | 306 |
|
| 307 |
with open(dist_file_path, 'rb') as file_handle: |
|
| 308 |
assert file_handle.read() == settings.contents[fn] |
|
| 307 |
assert dist_file_path.read_bytes() == settings.contents[fn] |
|
| 309 | 308 |
|
| 310 | 309 |
sha256_hashes_set = set([settings.sha256_hashes[fn] |
| 311 | 310 |
for fn in settings.dist_filenames]) |
| ... | ... | |
| 313 | 312 |
spdx_report_sha256 = None |
| 314 | 313 |
|
| 315 | 314 |
for path in file_dir.iterdir(): |
| 316 |
assert path.name.startswith('sha256-')
|
|
| 317 |
if path.name[7:] in sha256_hashes_set: |
|
| 315 |
if path.name in sha256_hashes_set: |
|
| 318 | 316 |
continue |
| 319 | 317 |
|
| 320 | 318 |
assert spdx_report_sha256 is None and settings.report_spdx_included |
| ... | ... | |
| 323 | 321 |
spdx_contents = file_handle.read() |
| 324 | 322 |
|
| 325 | 323 |
spdx_report_sha256 = sha256(spdx_contents.encode()).digest().hex() |
| 326 |
assert spdx_report_sha256 == path.name[7:]
|
|
| 324 |
assert spdx_report_sha256 == path.name |
|
| 327 | 325 |
|
| 328 | 326 |
for fn in settings.src_filenames: |
| 329 | 327 |
if not any([n in fn.lower() for n in ('license', 'reuse')]):
|
Also available in: Unified diff
change file path format
From now on we'll be using format 'file/sha256/' instead of 'file/sha256-'.