From 8f166b95c9ee10743039d1f2b1c21f9edee5da88 Mon Sep 17 00:00:00 2001 From: Otavio Salvador Date: Thu, 3 Jun 2021 11:24:19 -0300 Subject: [PATCH] gitRepo: Add import to ssl module to avoid runtime error (#125373) Co-authored-by: Ricardo M. Correia --- .../version-management/git-repo/default.nix | 9 ++++-- .../git-repo/import-ssl-module.patch | 28 +++++++++++++++++++ 2 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 pkgs/applications/version-management/git-repo/import-ssl-module.patch diff --git a/pkgs/applications/version-management/git-repo/default.nix b/pkgs/applications/version-management/git-repo/default.nix index 7b29e466160b..75a9fe377649 100644 --- a/pkgs/applications/version-management/git-repo/default.nix +++ b/pkgs/applications/version-management/git-repo/default.nix @@ -1,5 +1,5 @@ { lib, stdenv, fetchFromGitHub, makeWrapper, nix-update-script -, python3, git, gnupg, less +, python3, git, gnupg, less, openssh }: stdenv.mkDerivation rec { @@ -10,9 +10,12 @@ stdenv.mkDerivation rec { owner = "android"; repo = "tools_repo"; rev = "v${version}"; - sha256 = "sha256-3FSkWpHda1jVhy/633B+ippWcbKd83IlQcJYS9Qx5wQ="; + sha256 = "sha256-SuHp6C5ueUErvRiWDQNEmCybFIa7Iu7C/FtnHys9XqU="; }; + # Fix 'NameError: name 'ssl' is not defined' + patches = [ ./import-ssl-module.patch ]; + nativeBuildInputs = [ makeWrapper ]; buildInputs = [ python3 ]; @@ -34,7 +37,7 @@ stdenv.mkDerivation rec { # Important runtime dependencies postFixup = '' wrapProgram $out/bin/repo --prefix PATH ":" \ - "${lib.makeBinPath [ git gnupg less ]}" + "${lib.makeBinPath [ git gnupg less openssh ]}" ''; passthru = { diff --git a/pkgs/applications/version-management/git-repo/import-ssl-module.patch b/pkgs/applications/version-management/git-repo/import-ssl-module.patch new file mode 100644 index 000000000000..efc3d2b1f8a5 --- /dev/null +++ b/pkgs/applications/version-management/git-repo/import-ssl-module.patch @@ -0,0 +1,28 @@ +Fix runtime error due missing import + +Traceback (most recent call last): + File "/nix/store/4qqhr7g9ri3n7v6ik9ahlpvyp18wcn4p-git-repo-2.15.3/bin/.repo-wrapped", line 1339, in + main(sys.argv[1:]) + File "/nix/store/4qqhr7g9ri3n7v6ik9ahlpvyp18wcn4p-git-repo-2.15.3/bin/.repo-wrapped", line 1304, in main + _Init(args, gitc_init=(cmd == 'gitc-init')) + File "/nix/store/4qqhr7g9ri3n7v6ik9ahlpvyp18wcn4p-git-repo-2.15.3/bin/.repo-wrapped", line 607, in _Init + _Clone(url, dst, opt.clone_bundle, opt.quiet, opt.verbose) + File "/nix/store/4qqhr7g9ri3n7v6ik9ahlpvyp18wcn4p-git-repo-2.15.3/bin/.repo-wrapped", line 912, in _Clone + if clone_bundle and _DownloadBundle(url, cwd, quiet, verbose): + File "/nix/store/4qqhr7g9ri3n7v6ik9ahlpvyp18wcn4p-git-repo-2.15.3/bin/.repo-wrapped", line 860, in _DownloadBundle + r = urllib.request.urlopen(url, context=ssl.create_default_context()) +NameError: name 'ssl' is not defined +builder for '/nix/store/4hvds8fv8xmzlm86yg9cf1lj6hrya7sg-amdvlk-src.drv' failed with exit code 1 + +diff --git a/repo b/repo +index 8b05def..f394b3e 100755 +--- a/repo ++++ b/repo +@@ -236,6 +236,7 @@ import optparse + import re + import shutil + import stat ++import ssl + + if sys.version_info[0] == 3: + import urllib.request