Skip to content

Commit

Permalink
charmcraft: 3.2.2 -> 3.4.2 (NixOS#381233)
Browse files Browse the repository at this point in the history
  • Loading branch information
GaetanLepage authored Feb 11, 2025
2 parents a4aadaa + b4c51dc commit 137bd86
Show file tree
Hide file tree
Showing 13 changed files with 160 additions and 57 deletions.
8 changes: 6 additions & 2 deletions pkgs/by-name/ch/charmcraft/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@

python3Packages.buildPythonApplication rec {
pname = "charmcraft";
version = "3.2.2";
version = "3.4.2";

pyproject = true;

src = fetchFromGitHub {
owner = "canonical";
repo = "charmcraft";
tag = version;
hash = "sha256-2MI2cbAohfTgbilxZcFvmxt/iVjR6zJ2o0gequB//hg=";
hash = "sha256-6ucF0iQxQrFFz7jlaktYsB538W8jbX+Sw5hP0/VoYsk=";
};

postPatch = ''
Expand All @@ -35,6 +35,7 @@ python3Packages.buildPythonApplication rec {
humanize
jinja2
jsonschema
pip
pydantic
python-dateutil
pyyaml
Expand All @@ -51,11 +52,14 @@ python3Packages.buildPythonApplication rec {
pythonRelaxDeps = [
"urllib3"
"craft-application"
"pip"
"pydantic"
];

nativeCheckInputs =
with python3Packages;
[
freezegun
hypothesis
pyfakefs
pytest-check
Expand Down
4 changes: 2 additions & 2 deletions pkgs/by-name/ro/rockcraft/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

python3Packages.buildPythonApplication rec {
pname = "rockcraft";
version = "1.7.0";
version = "1.8.0";

src = fetchFromGitHub {
owner = "canonical";
repo = "rockcraft";
rev = version;
hash = "sha256-2Bo3qtpSSfNvqszlt9cCc9/rurDNDMySAaqLbvRmjjw=";
hash = "sha256-v7biDGgJoQO6cKRXG8xosCgd/mlOUEwHrqcgtL2R5L4=";
};

pyproject = true;
Expand Down
13 changes: 0 additions & 13 deletions pkgs/by-name/sn/snapcraft/os-platform.patch

This file was deleted.

10 changes: 3 additions & 7 deletions pkgs/by-name/sn/snapcraft/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,22 @@

python3Packages.buildPythonApplication rec {
pname = "snapcraft";
version = "8.5.1";
version = "8.6.1";

pyproject = true;

src = fetchFromGitHub {
owner = "canonical";
repo = "snapcraft";
tag = version;
hash = "sha256-7kIVWbVj5qse3JIdlCvRtVUfSa/rSjn4e8HJdVY3sOA=";
hash = "sha256-SbxsgvDptkUl8gHAIrJvnzIPOh0/R81n8cgJWBH7BXQ=";
};

patches = [
# Snapcraft is only officially distributed as a snap, as is LXD. The socket
# path for LXD must be adjusted so that it's at the correct location for LXD
# on NixOS. This patch will likely never be accepted upstream.
./lxd-socket-path.patch
# In certain places, Snapcraft expects an /etc/os-release file to determine
# host info which doesn't exist in our test environment. This is a
# relatively naive patch which helps the test suite pass - without it *many*
# of the tests fail. This patch will likely never be accepted upstream.
./os-platform.patch
# Snapcraft will try to inject itself as a snap *from the host system* into
# the build system. This patch short-circuits that logic and ensures that
# Snapcraft is installed on the build system from the snap store - because
Expand Down Expand Up @@ -118,6 +113,7 @@ python3Packages.buildPythonApplication rec {
build-system = with python3Packages; [ setuptools ];

pythonRelaxDeps = [
"craft-parts"
"docutils"
"jsonschema"
"pygit2"
Expand Down
8 changes: 3 additions & 5 deletions pkgs/development/python-modules/craft-application/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,19 @@

buildPythonPackage rec {
pname = "craft-application";
version = "4.8.2";
version = "4.9.0";
pyproject = true;

disabled = pythonOlder "3.10";

src = fetchFromGitHub {
owner = "canonical";
repo = "craft-application";
tag = version;
hash = "sha256-rKeEi9z5eQfjn0Q4FR6CVIz9YDS7Ejg4cqcor5wtz0s=";
hash = "sha256-DprItAuGjw8AACeJDrIa6KIWLSyImuWI0qeROpPohtM=";
};

postPatch = ''
substituteInPlace pyproject.toml \
--replace-fail "setuptools==75.2.0" "setuptools"
--replace-fail "setuptools==75.8.0" "setuptools"
'';

build-system = [ setuptools-scm ];
Expand Down
8 changes: 6 additions & 2 deletions pkgs/development/python-modules/craft-cli/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
fetchFromGitHub,
nix-update-script,
platformdirs,
jinja2,
overrides,
pyyaml,
setuptools-scm,
pytest-check,
Expand All @@ -13,15 +15,15 @@

buildPythonPackage rec {
pname = "craft-cli";
version = "2.13.0";
version = "2.15.0";

pyproject = true;

src = fetchFromGitHub {
owner = "canonical";
repo = "craft-cli";
tag = version;
hash = "sha256-IqK+eU2z63yDMJrHAhETHWoTz5lWK1er9bwYH9Oml18=";
hash = "sha256-L8hOQJhjVAMo/WxEHHEk2QorlSdDFMGdcL/Q3Pv6mT4=";
};

postPatch = ''
Expand All @@ -32,6 +34,8 @@ buildPythonPackage rec {
build-system = [ setuptools-scm ];

dependencies = [
jinja2
overrides
platformdirs
pyyaml
];
Expand Down
90 changes: 74 additions & 16 deletions pkgs/development/python-modules/craft-parts/bash-path.patch
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
diff --git a/craft_parts/executor/step_handler.py b/craft_parts/executor/step_handler.py
index 404df69..f90e2ac 100644
index 5eab915..bc26252 100644
--- a/craft_parts/executor/step_handler.py
+++ b/craft_parts/executor/step_handler.py
@@ -243,8 +243,9 @@ class StepHandler:
print(script, file=script_file)
script_file.flush()
script_file.seek(0)
+ import shutil
process = subprocess.Popen( # pylint: disable=consider-using-with
- ["/bin/bash"],
+ [shutil.which("bash")],
stdin=script_file,
cwd=work_dir,
stdout=self._stdout,
@@ -394,7 +395,8 @@ def _create_and_run_script(
@@ -445,7 +445,8 @@ def _create_and_run_script(
) -> None:
"""Create a script with step-specific commands and execute it."""
with script_path.open("w") as run_file:
Expand All @@ -22,12 +11,28 @@ index 404df69..f90e2ac 100644
+ print(f"#!{shutil.which('bash')}", file=run_file)
print("set -euo pipefail", file=run_file)

if build_environment_script_path:
if environment_script_path:
diff --git a/craft_parts/plugins/java_plugin.py b/craft_parts/plugins/java_plugin.py
index f2b4064..cb4e9e8 100644
--- a/craft_parts/plugins/java_plugin.py
+++ b/craft_parts/plugins/java_plugin.py
@@ -71,9 +71,8 @@ class JavaPlugin(Plugin):
return None, ""

def _find_javac(self) -> list[str]:
- cmd = ["find", "/usr/lib/jvm", "-path", "*/bin/javac", "-print"]
- output = subprocess.check_output(cmd, text=True)
- return [x for x in output.split("\n") if len(x) > 0]
+ import shutil
+ return [shutil.which("javac")]

@override
def get_build_environment(self) -> dict[str, str]:
diff --git a/craft_parts/plugins/validator.py b/craft_parts/plugins/validator.py
index b8d8f11..fce0e72 100644
index 5b4c735..8ff30c2 100644
--- a/craft_parts/plugins/validator.py
+++ b/craft_parts/plugins/validator.py
@@ -142,9 +142,9 @@ class PluginEnvironmentValidator:
@@ -141,9 +141,9 @@ class PluginEnvironmentValidator:
print(self._env, file=env_file)
print(cmd, file=env_file)
env_file.flush()
Expand All @@ -39,3 +44,56 @@ index b8d8f11..fce0e72 100644
check=True,
capture_output=True,
text=True,
diff --git a/tests/unit/executor/test_step_handler.py b/tests/unit/executor/test_step_handler.py
index 4e73c2b..b762fb8 100644
--- a/tests/unit/executor/test_step_handler.py
+++ b/tests/unit/executor/test_step_handler.py
@@ -209,9 +209,10 @@ class TestStepHandlerBuiltins:

assert get_mode(build_script_path) == 0o755
with open(build_script_path) as file:
+ import shutil
assert file.read() == dedent(
f"""\
- #!/bin/bash
+ #!{shutil.which('bash')}
set -euo pipefail
source {environment_script_path}
set -x
diff --git a/tests/unit/utils/test_process.py b/tests/unit/utils/test_process.py
index 84b29ad..dc2d772 100644
--- a/tests/unit/utils/test_process.py
+++ b/tests/unit/utils/test_process.py
@@ -33,7 +33,8 @@ _RUN_TEST_CASES = [

@pytest.mark.parametrize(("out", "err"), _RUN_TEST_CASES)
def test_run(out, err):
- result = process.run(["/usr/bin/sh", "-c", f"echo {out};sleep 0;echo {err} >&2"])
+ import shutil
+ result = process.run([shutil.which("sh"), "-c", f"echo {out};sleep 0;echo {err} >&2"])
assert result.returncode == 0
assert result.stdout == (out + "\n").encode()
assert result.stderr == (err + "\n").encode()
@@ -42,8 +43,9 @@ def test_run(out, err):

@pytest.mark.parametrize(("out", "err"), _RUN_TEST_CASES)
def test_run_devnull(out, err):
+ import shutil
result = process.run(
- ["/usr/bin/sh", "-c", f"echo {out};echo {err} >&2"],
+ [shutil.which("sh"), "-c", f"echo {out};echo {err} >&2"],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
)
@@ -78,9 +80,10 @@ def test_run_selector(out, err, new_dir):

selector.register(sock, selectors.EVENT_READ, accept)

+ import shutil
result = process.run(
[
- "/usr/bin/sh",
+ shutil.which("sh"),
"-c",
f"echo {out};sleep 0;echo {err} >&2; echo -n {out}|socat - UNIX-CONNECT:{new_dir}/test.socket",
],
14 changes: 12 additions & 2 deletions pkgs/development/python-modules/craft-parts/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,25 @@
jsonschema,
git,
squashfsTools,
socat,
setuptools-scm,
stdenv,
ant,
maven,
jdk,
}:

buildPythonPackage rec {
pname = "craft-parts";
version = "2.2.2";
version = "2.6.0";

pyproject = true;

src = fetchFromGitHub {
owner = "canonical";
repo = "craft-parts";
tag = version;
hash = "sha256-6ufcay1C2Qv3nnG0augnPWzwBVDMj1ypRwzHRAhHARA=";
hash = "sha256-SybDzprUrKeL+Jl7Gm4XYLlvmy056D1OtJB7v/W2flY=";
};

patches = [ ./bash-path.patch ];
Expand All @@ -57,14 +61,18 @@ buildPythonPackage rec {
pythonImportsCheck = [ "craft_parts" ];

nativeCheckInputs = [
ant
git
hypothesis
jdk
jsonschema
maven
pytest-check
pytest-mock
pytest-subprocess
pytestCheckHook
requests-mock
socat
squashfsTools
];

Expand All @@ -80,6 +88,8 @@ buildPythonPackage rec {
"test_run_prime"
"test_get_build_packages_with_source_type"
"test_get_build_packages"
# Relies upon certain paths being present that don't make sense on Nix.
"test_java_plugin_jre_not_17"
];

disabledTestPaths =
Expand Down
10 changes: 5 additions & 5 deletions pkgs/development/python-modules/craft-providers/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@
responses,
freezegun,
pytest-subprocess,
pytest-logdog,
logassert,
}:

buildPythonPackage rec {
pname = "craft-providers";
version = "2.1.0";
version = "2.1.1";

pyproject = true;

src = fetchFromGitHub {
owner = "canonical";
repo = "craft-providers";
tag = version;
hash = "sha256-+j3uwvecffl8cK+yNidWbL243VnPkX72DMYv8RXMaXE=";
hash = "sha256-aW3efKy3c7ZGXS4wsvby0ww3Gwjt+1tMKsJCGprkcZo=";
};

patches = [
Expand All @@ -50,7 +50,7 @@ buildPythonPackage rec {
# The urllib3 incompat: https://github.com/msabramo/requests-unixsocket/pull/69
# This is already patched in nixpkgs.
substituteInPlace pyproject.toml \
--replace-fail "setuptools==73.0.1" "setuptools"
--replace-fail "setuptools==75.2.0" "setuptools"
'';

pythonRelaxDeps = [ "requests" ];
Expand All @@ -69,10 +69,10 @@ buildPythonPackage rec {

nativeCheckInputs = [
freezegun
logassert
pytest-check
pytest-mock
pytest-subprocess
pytest-logdog
pytestCheckHook
responses
];
Expand Down
Loading

0 comments on commit 137bd86

Please sign in to comment.