diff --git a/README.md b/README.md index 061a4f7..29418f6 100644 --- a/README.md +++ b/README.md @@ -105,7 +105,7 @@ utiliser **Build and upload** avant la vérification du fichier construit. Inspecter le `.wapt` réellement généré : ```powershell -waptpython tools\package_verify.py --wapt .\comi-audit-hardeningkitty_0.9.8-0_all.wapt +waptpython tools\package_verify.py --wapt .\comi-audit-hardeningkitty_0.9.9-0_all.wapt ``` Cette vérification ouvre l’archive ZIP `.wapt` et contrôle les scripts, diff --git a/WAPT/control b/WAPT/control index bda3a97..71d0d68 100644 --- a/WAPT/control +++ b/WAPT/control @@ -1,5 +1,5 @@ package : comi-audit-hardeningkitty -version : 0.9.8-0 +version : 0.9.9-0 architecture : all section : base priority : optional diff --git a/package-manifest.json b/package-manifest.json index af4ee01..d17d62d 100644 --- a/package-manifest.json +++ b/package-manifest.json @@ -1,9 +1,9 @@ { "files": { - "WAPT/control": "ed77db7becfcaf15b7c95b5f169294b1afe320fdcef657f59cb5df2f6b133d14", + "WAPT/control": "2d42c593fb406bf1ce99efdfa61ccfc053eb2cf125a181d12a0725494a11e566", "audit_config.json": "9fc18f556fd491e8e00e3a8b1efd864ad8036682e293a02c1f81f3411304a69b", "runner.ps1": "5e9787f5cc19d0fc4c0ede01a63188ed71de6ef49df596fbce7b2603093231cd", - "setup.py": "e187cbfdd61d96e68b940f124924d2f09ad3d18eb3987116ab55937dea18dc06", + "setup.py": "a7fb150a1c4f3ccb64f68b83fb7670c011b4434634dd7baa62b67d3050d4959e", "vendor/HardeningKitty.psd1": "94378764787cd0c7125c5c3ce928803b46ee7d7d3fe21c2b27ddeb23c11377a7", "vendor/HardeningKitty.psm1": "b799ec1b17de5ce63f7a8ea34af3beba1d24fcaddf7e3774f797096f5c43e2a0", "vendor/LICENSE": "a879ba6ccdcd2ea55da97b999edd2c401c8589ca946f238236bf93aa40e74d56", diff --git a/setup.py b/setup.py index cacb677..71f0050 100644 --- a/setup.py +++ b/setup.py @@ -49,16 +49,19 @@ REQUIRED_VENDOR_FILES = ( def _source_directory(): + """Find package root and return it relative to the current working directory.""" candidates = [] if globals().get('__file__'): candidates.append(os.path.dirname(os.path.abspath(__file__))) for name in ('basedir', 'package_dir'): if globals().get(name): candidates.append(os.path.abspath(globals()[name])) - candidates.append(os.getcwd()) + current_directory = os.getcwd() + candidates.append(current_directory) for candidate in candidates: - if os.path.isfile(os.path.join(candidate, 'WAPT', 'control')): - return candidate + relative_candidate = os.path.relpath(os.path.abspath(candidate), current_directory) + if os.path.isfile(os.path.join(relative_candidate, 'WAPT', 'control')): + return relative_candidate raise RuntimeError('Cannot locate WAPT source directory (WAPT/control not found).') diff --git a/tests/test_package.py b/tests/test_package.py index c1dd366..15f63e0 100644 --- a/tests/test_package.py +++ b/tests/test_package.py @@ -356,7 +356,12 @@ class PackageTests(unittest.TestCase): original_cwd = os.getcwd() try: os.chdir(tmp) - self.assertEqual(updater._source_directory(), ROOT) + source_root = updater._source_directory() + self.assertFalse(os.path.isabs(source_root)) + self.assertTrue((Path(source_root) / 'WAPT' / 'control').is_file()) + self.assertEqual(Path(source_root).resolve(), ROOT) + os.chdir(ROOT) + self.assertEqual(updater._source_directory(), Path('.')) finally: os.chdir(original_cwd) @@ -385,6 +390,19 @@ class PackageTests(unittest.TestCase): updater._load_tool = old_loader self.assertEqual([call[0] for call in calls], ['vendor', 'manifest', 'verify'] * 2) + def test_setup_source_directory_is_relative_to_package_root(self): + original_cwd = os.getcwd() + try: + os.chdir(ROOT) + self.assertEqual(pkg._source_directory(), '.') + with tempfile.TemporaryDirectory() as tmp: + os.chdir(tmp) + source_root = pkg._source_directory() + self.assertFalse(os.path.isabs(source_root)) + self.assertTrue(os.path.isfile(os.path.join(source_root, 'WAPT', 'control'))) + finally: + os.chdir(original_cwd) + def test_offline_updater_requires_expected_archive_hash(self): with tempfile.TemporaryDirectory() as tmp: archive = Path(tmp, 'archive.zip') diff --git a/update_package.py b/update_package.py index e36e414..22495db 100644 --- a/update_package.py +++ b/update_package.py @@ -7,8 +7,8 @@ import sys def _source_directory(): - """Find the package source from this file, independent of the current cwd.""" - source = Path(__file__).resolve().parent + """Find package root and return its path relative to the current directory.""" + source = Path(os.path.relpath(Path(__file__).resolve().parent, Path.cwd())) if not (source / 'WAPT' / 'control').is_file(): raise RuntimeError('update_package.py must be inside a WAPT package source directory.') return source