aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWojtek Kosior <koszko@koszko.org>2022-05-11 12:33:31 +0200
committerWojtek Kosior <koszko@koszko.org>2022-05-11 12:33:31 +0200
commit496d90f70a58c0040f8493aa8a5e4e2f106bfac7 (patch)
treeaf6ace104ad9a02f2fb15820dd6ea3469d4577d5
parent9e2cd3a25b6ff5addd7109414fdf5a535b9cbce3 (diff)
downloadhydrilla-builder-496d90f70a58c0040f8493aa8a5e4e2f106bfac7.tar.gz
hydrilla-builder-496d90f70a58c0040f8493aa8a5e4e2f106bfac7.zip
make it easier to reuse/cache foreign package files when building a Hydrilla source package multiple times
-rw-r--r--conftest.py11
-rw-r--r--src/hydrilla/builder/local_apt.py8
-rw-r--r--tests/test_build.py12
-rw-r--r--tests/test_local_apt.py24
4 files changed, 33 insertions, 22 deletions
diff --git a/conftest.py b/conftest.py
index 65d13d5..e41a61d 100644
--- a/conftest.py
+++ b/conftest.py
@@ -9,6 +9,8 @@ from pathlib import Path
import pytest
import pkgutil
+from tempfile import TemporaryDirectory
+from typing import Iterable
here = Path(__file__).resolve().parent
sys.path.insert(0, str(here / 'src'))
@@ -67,3 +69,12 @@ def no_gettext(monkeypatch, request):
for module in modules_to_process:
if hasattr(module, '_'):
monkeypatch.setattr(module, '_', lambda message: message)
+
+@pytest.fixture
+def tmpdir() -> Iterable[Path]:
+ """
+ Provide test case with a temporary directory that will be automatically
+ deleted after the test.
+ """
+ with TemporaryDirectory() as tmpdir:
+ yield Path(tmpdir)
diff --git a/src/hydrilla/builder/local_apt.py b/src/hydrilla/builder/local_apt.py
index 1bdc347..3bec08b 100644
--- a/src/hydrilla/builder/local_apt.py
+++ b/src/hydrilla/builder/local_apt.py
@@ -286,7 +286,7 @@ def local_apt(list: SourcesList, keys: [str]) -> Iterable[Apt]:
yield setup_local_apt(td, list, keys)
def download_apt_packages(list: SourcesList, keys: [str], packages: [str],
- destination_dir: Path, with_deps=False) -> [str]:
+ destination_dir: Path, with_deps: bool) -> [str]:
"""
Set up a local APT, update it using the specified sources.list configuration
and use it to download the specified packages.
@@ -380,7 +380,11 @@ def piggybacked_system(piggyback_def: dict, foreign_packages: Optional[Path]) \
if foreign_packages is None:
archives = td / 'archives'
archives.mkdir()
+ else:
+ archives = foreign_packages / 'apt'
+ archives.mkdir(exist_ok=True)
+ if [*archives.glob('*.deb')] == []:
sources_list = SourcesList(piggyback_def.get('sources_list', []),
piggyback_def.get('distribution'))
packages = piggyback_def['packages']
@@ -397,8 +401,6 @@ def piggybacked_system(piggyback_def: dict, foreign_packages: Optional[Path]) \
destination_dir=archives,
with_deps=with_deps
)
- else:
- archives = foreign_packages / 'apt'
for deb in archives.glob('*.deb'):
command = ['dpkg-deb', '-x', str(deb), str(root)]
diff --git a/tests/test_build.py b/tests/test_build.py
index 3d564e3..968ac8d 100644
--- a/tests/test_build.py
+++ b/tests/test_build.py
@@ -176,15 +176,6 @@ expected_source_description = {
expected = [*expected_resources, expected_mapping, expected_source_description]
-@pytest.fixture
-def tmpdir() -> Iterable[str]:
- """
- Provide test case with a temporary directory that will be automatically
- deleted after the test.
- """
- with TemporaryDirectory() as tmpdir:
- yield Path(tmpdir)
-
def run_reuse(command, **kwargs):
"""
Instead of running a 'reuse' command, check if 'mock_reuse_missing' file
@@ -677,10 +668,7 @@ def test_build_error(tmpdir, sample_source, sample_source_make_errors):
error_type, error_regex = sample_source_make_errors
dstdir = Path(tmpdir) / 'dstdir'
- tmpdir = Path(tmpdir) / 'example'
-
dstdir.mkdir(exist_ok=True)
- tmpdir.mkdir(exist_ok=True)
with pytest.raises(error_type, match=error_regex):
build.Build(sample_source, Path('index.json'))\
diff --git a/tests/test_local_apt.py b/tests/test_local_apt.py
index edd47fa..f94ee37 100644
--- a/tests/test_local_apt.py
+++ b/tests/test_local_apt.py
@@ -341,7 +341,7 @@ def test_local_apt_download(mock_cache_dir):
destination.mkdir()
local_apt.download_apt_packages(sources_list, local_apt.default_keys,
- ['libjs-mathjax'], destination)
+ ['libjs-mathjax'], destination, False)
libjs_mathjax_path = destination / 'libjs-mathjax_0%3a2.7.9+dfsg-1_all.deb'
fonts_mathjax_path = destination / 'fonts-mathjax_0%3a2.7.9+dfsg-1_all.deb'
@@ -418,7 +418,7 @@ $\
with pytest.raises(local_apt.AptError, match=error_regex):
local_apt.download_apt_packages(sources_list, local_apt.default_keys,
- ['libjs-mathjax'], destination)
+ ['libjs-mathjax'], destination, False)
assert [*destination.iterdir()] == []
@@ -469,7 +469,7 @@ $\
with pytest.raises(local_apt.AptError, match=error_regex):
local_apt.download_apt_packages(sources_list, local_apt.default_keys,
- ['libjs-mathjax'], destination)
+ ['libjs-mathjax'], destination, False)
assert [*destination.iterdir()] == []
@@ -499,7 +499,7 @@ $\
with pytest.raises(local_apt.AptError, match=error_regex):
local_apt.download_apt_packages(sources_list, local_apt.default_keys,
- ['libjs-mathjax'], destination)
+ ['libjs-mathjax'], destination, False)
assert [*destination.iterdir()] == []
@@ -572,7 +572,8 @@ def mock_download_packages(monkeypatch):
'base_depends': True,
'identity': 'nabia',
'props': {'distribution': 'nabia', 'dependencies': False},
- 'all_keys': local_apt.default_keys
+ 'all_keys': local_apt.default_keys,
+ 'prepared_directory': False
},
{
'with_deps': True,
@@ -586,19 +587,22 @@ def mock_download_packages(monkeypatch):
'depend_on_base_packages': False
},
'all_keys': [*local_apt.default_keys, 'AB' * 20],
+ 'prepared_directory': True
}
])
@pytest.mark.usefixtures('mock_download_packages', 'mock_subprocess_run')
-def test_piggybacked_system_download(params):
+def test_piggybacked_system_download(params, tmpdir):
"""
Verify that the piggybacked_system() function properly downloads and unpacks
APT packages.
"""
+ foreign_packages_dir = tmpdir if params['prepared_directory'] else None
+
with local_apt.piggybacked_system({
'system': 'apt',
**params['props'],
'packages': ['some-bin-package', 'another-package=1.1-2']
- }, None) as piggybacked:
+ }, foreign_packages_dir) as piggybacked:
expected_depends = [{'identifier': 'apt-common-licenses'}] \
if params['base_depends'] else []
assert piggybacked.package_must_depend == expected_depends
@@ -626,6 +630,9 @@ def test_piggybacked_system_download(params):
else:
assert path.read_text() == f'dummy {path.name}'
+ if foreign_packages_dir is not None:
+ assert path.parent == foreign_packages_dir / 'apt'
+
license_files = {*piggybacked.package_license_files}
assert license_files == {
@@ -654,6 +661,9 @@ def test_piggybacked_system_download(params):
assert not root.exists()
+ if foreign_packages_dir:
+ assert [*tmpdir.iterdir()] == [tmpdir / 'apt']
+
@pytest.mark.subprocess_run(local_apt, run_dpkg_deb)
@pytest.mark.usefixtures('mock_subprocess_run')
def test_piggybacked_system_no_download():
(main): Save GUILE_LOAD_PATH and GUILE_LOAD_COMPILED_PATH and unset them. Ludovic Courtès 2020-10-31pack: Relocatable wrapper leaves root available to child processes.•••Fixes <https://bugs.gnu.org/44261>. Reported by Jan Nieuwenhuizen <janneke@gnu.org>. * gnu/packages/aux-files/run-in-namespace.c (exec_in_user_namespace): Add call to 'prctl'. Call 'mount' for NEW_ROOT and define 'is_tmpfs'. When IS_TMPFS is true, call 'umount' and 'rmdir' after 'waitpid'; otherwise, call 'rm_rf' only when 'waitpid' returns -1 the second time. (exec_with_loader): Call 'prctl'. Remove NEW_ROOT only when 'waitpid' returns -1 the second time, otherwise leave it behind. * tests/guix-pack-relocatable.sh (wait_for_file): New function. Add test. Ludovic Courtès 2020-10-30gnu: linux-libre: Update to 5.9.2.•••* gnu/packages/linux.scm (linux-libre-5.9-version): Update to 5.9.2. (deblob-scripts-5.9, linux-libre-5.9-pristine-source): Update hashes. * gnu/packages/aux-files/linux-libre/5.9-arm.conf, gnu/packages/aux-files/linux-libre/5.9-arm64.conf, gnu/packages/aux-files/linux-libre/5.9-i686.conf, gnu/packages/aux-files/linux-libre/5.9-x86_64.conf: Update kernel configurations for 5.9.2. Leo Famulari 2020-10-30guix: pack: Fix offset calculation for store directory mount point.•••Fixes wrapping of non-package things, where the target store directory may differ in length from the original. * guix/scripts/pack.scm (wrapped-package)<build-wrapper>: Define WRAPPER_PROGRAM macro with wrapper's file name. * gnu/packages/aux-files/run-in-namespace.c (main): Offset index by len of that file name. Eric Bavier 2020-10-24gnu: linux-libre: Update to 5.9.1.•••* gnu/packages/aux-files/linux-libre/5.8-arm.conf, gnu/packages/aux-files/linux-libre/5.8-arm64.conf, gnu/packages/aux-files/linux-libre/5.8-i686.conf, gnu/packages/aux-files/linux-libre/5.8-x86_64.conf: Delete files. * gnu/packages/aux-files/linux-libre/5.9-arm.conf, gnu/packages/aux-files/linux-libre/5.9-arm64.conf, gnu/packages/aux-files/linux-libre/5.9-i686.conf, gnu/packages/aux-files/linux-libre/5.9-x86_64.conf: New files. * Makefile.am (AUX_FILES): Adjust accordingly. * gnu/packages/linux.scm (linux-libre-5.8-version, deblob-scripts-5.8, linux-libre-5.8-pristine-source, linux-libre-5.8-source, linux-libre-headers-5.8, linux-libre-5.8): Remove variables. (linux-libre-5.9-version, deblob-scripts-5.9, linux-libre-5.9-pristine-source, linux-libre-5.9-source, linux-libre-headers-5.9, linux-libre-5.9): New variables. (linux-libre-version, linux-libre-pristine-source, linux-libre-source, linux-libre): Point to linux-libre-5.9*. (linux-libre-with-bpf): Use linux-libre-5.9. Leo Famulari 2020-10-15gnu: linux-libre: Enable XDP sockets and their monitoring.•••* gnu/packages/aux-files/linux-libre/4.19-arm.conf: Enable AF_XDP sockets and the associated monitor interface. * gnu/packages/aux-files/linux-libre/4.19-arm64.conf: Likewise * gnu/packages/aux-files/linux-libre/4.19-i686.conf: Likewise * gnu/packages/aux-files/linux-libre/4.19-x86_64.conf: Likewise * gnu/packages/aux-files/linux-libre/5.4-arm.conf: Likewise * gnu/packages/aux-files/linux-libre/5.4-arm64.conf: Likewise * gnu/packages/aux-files/linux-libre/5.4-i686.conf: Likewise * gnu/packages/aux-files/linux-libre/5.4-x86_64.conf: Likewise * gnu/packages/aux-files/linux-libre/5.8-arm.conf: Likewise * gnu/packages/aux-files/linux-libre/5.8-arm64.conf: Likewise * gnu/packages/aux-files/linux-libre/5.8-i686.conf: Likewise * gnu/packages/aux-files/linux-libre/5.8-x86_64.conf: Likewise Tobias Geerinckx-Rice via Guix-patches via 2020-10-05self: Use a 'guile' that doesn't complain about locales.•••Since commit ba48895899a117d6ace2209c3f54411a4a989133, selected UTF-8 locales are bundled. However, because 'guix-command' is itself a Guile script, users would still see Guile's warning, particularly on foreign distros: $ LC_ALL=sdf guix foo guile: warning: failed to install locale hint: Consider installing the `glibc-utf8-locales' [...] User commands would print that warning, but more importantly, each invocation of 'guix substitute' would print it, even though 'guix-daemon.service' explicitly chooses "en_US.utf8", which is in 'glibc-utf8-locales'. This leads to confusion since users would keep seeing this message unless/until they realize they also need to install 'glibc-utf8-locales' in root's profile. This patch gets rid of "guile: warning: ..." for a guix-pulled 'guix' command. * guix/self.scm (specification->package): Add "gcc-toolchain". (quiet-guile): New procedure. (guix-command): Use it. * gnu/packages/aux-files/guile-launcher.c: New file. * Makefile.am (AUX_FILES): Add it. Ludovic Courtès 2020-08-30gnu: Remove linux-libre 5.7.•••The 5.7 kernel series is no longer supported upstream. * gnu/packages/linux.scm (deblob-scripts-5.7, linux-libre-5.7-version, linux-libre-5.7-pristine-source, linux-libre-5.7-source, linux-libre-headers-5.7, linux-libre-5.7) Remove variables. * gnu/packages/aux-files/linux-libre/5.7-arm.conf, gnu/packages/aux-files/linux-libre/5.7-arm64.conf, gnu/packages/aux-files/linux-libre/5.7-i686.conf, gnu/packages/aux-files/linux-libre/5.7-x86_64.conf: Delete files. * Makefile.am (AUX_FILES): Remove them. Leo Famulari 2020-08-27pack: fakechroot: Honor $LD_LIBRARY_PATH.•••Until now, when using the "fakechroot" engine, $LD_LIBRARY_PATH would always be ignored. However, it's useful in some cases to allow users to specify LD_LIBRARY_PATH, so honor it. * gnu/packages/aux-files/run-in-namespace.c (concat_paths): New function. (exec_with_loader): Concatenante $LD_LIBRARY_PATH to the relocated AUDIT_LIBRARY_PATH. Ludovic Courtès 2020-08-27linux-libre: Enable module compression for all versions.•••This is a follow-up of 5fe12be0dd03d1a316343549f8c131d931f21a9a. It enables module compression for all supported Linux versions. * gnu/packages/aux-files/linux-libre/4.14-arm.conf: Enable GZIP module compression. * gnu/packages/aux-files/linux-libre/4.14-i686.conf: Ditto. * gnu/packages/aux-files/linux-libre/4.14-x86_64.conf: Ditto. * gnu/packages/aux-files/linux-libre/4.19-arm.conf: Ditto. * gnu/packages/aux-files/linux-libre/4.19-arm64.conf: Ditto. * gnu/packages/aux-files/linux-libre/4.19-i686.conf: Ditto. * gnu/packages/aux-files/linux-libre/4.19-x86_64.conf: Ditto. * gnu/packages/aux-files/linux-libre/4.4-i686.conf: Ditto. * gnu/packages/aux-files/linux-libre/4.4-x86_64.conf: Ditto. * gnu/packages/aux-files/linux-libre/4.9-i686.conf: Ditto. * gnu/packages/aux-files/linux-libre/4.9-x86_64.conf: Ditto. * gnu/packages/aux-files/linux-libre/5.4-arm.conf: Ditto. * gnu/packages/aux-files/linux-libre/5.4-arm64.conf: Ditto. * gnu/packages/aux-files/linux-libre/5.4-i686.conf: Ditto. * gnu/packages/aux-files/linux-libre/5.4-x86_64.conf: Ditto. * gnu/packages/aux-files/linux-libre/5.7-arm.conf: Ditto. * gnu/packages/aux-files/linux-libre/5.7-arm64.conf: Ditto. * gnu/packages/aux-files/linux-libre/5.7-i686.conf: Ditto. * gnu/packages/aux-files/linux-libre/5.7-x86_64.conf: Ditto. Mathieu Othacehe 2020-08-25linux-libre: Enable module compression.•••This commit enables GZIP compression for linux-libre kernel modules, reducing the size of linux-libre by 63% (165MB). * gnu/packages/aux-files/linux-libre/5.8-arm.conf: Enable GZ compression. * gnu/packages/aux-files/linux-libre/5.8-arm64.conf: Ditto. * gnu/packages/aux-files/linux-libre/5.8-i686.conf: Ditto. * gnu/packages/aux-files/linux-libre/5.8-x86_64.conf: Ditto. Mathieu Othacehe 2020-08-21gnu: linux-libre: Update to 5.8.2.•••* gnu/packages/aux-files/linux-libre/5.8-arm.conf, gnu/packages/aux-files/linux-libre/5.8-arm64.conf, gnu/packages/aux-files/linux-libre/5.8-i686.conf, gnu/packages/aux-files/linux-libre/5.8-x86_64.conf: New files. * Makefile.am (AUX_FILES): Add them. * gnu/packages/linux.scm (linux-libre-5.8): New variable. (linux-libre-version, linux-libre-pristine-source, linux-libre-source, linux-libre): Point to linux-libre-5.8*. Leo Famulari