Skip to content

Commit

Permalink
edk2: fetch submodules manually for 202408
Browse files Browse the repository at this point in the history
Original submodule sources are no longer available, so the submodules are fetched manually,
with unavailable sources replaced by mirrors. (tianocore/edk2#6402)

fix #353769

submodules-202408.nix was generated using the following script.

    #!/usr/bin/env nix-shell
    #!nix-shell -i bash -p coreutils git jq nixfmt-rfc-style nix-prefetch-git

    set -eu -o pipefail

    version=202408
    git_remote=origin
    git_repo=https://github.com/tianocore/edk2
    git_rev=refs/tags/edk2-stable$version

    tmp=$(mktemp -d)
    trap 'rm -rf -- "$tmp"' EXIT

    git_dir=$tmp/git
    git init --bare "$git_dir"
    git -C "$git_dir" remote add "$git_remote" "$git_repo"
    git -C "$git_dir" fetch --depth 1 --filter=blob:none "$git_remote" "$git_rev:$git_rev"
    git -C "$git_dir" show "$git_rev:.gitmodules" > "$tmp/submodules"

    submodules="{}"

    for module in $(git config get -f "$tmp/submodules" --all \
                        --name-only --show-names --regexp '^submodule\.[^.]+\.path$'); do

        module=${module#submodule.}
        module=${module%.path}

        module_path=$(git config get -f "$tmp/submodules" "submodule.$module.path")
        module_url=$(git config get -f "$tmp/submodules" "submodule.$module.url")
        module_rev=$(git -C "$git_dir" ls-tree --object-only "$git_rev" "$module_path")

        # https://github.com/tianocore/edk2/pull/6402/files
        case $module_url in
            https://github.com/Zeex/subhook.git)
                module_url=https://github.com/tianocore/edk2-subhook.git;;
        esac

        module_repo=${module_url#https://github.com/}
        module_repo=${module_repo%.git}
        module_owner=${module_repo%/*}
        module_repo=${module_repo#*/}

        module_hash=$(nix-prefetch-git --fetch-submodules "$module_url" "$module_rev" | jq -r .hash)

        submodules=$(jq --argjson submodules "$submodules" \
                        --arg path "$module_path" \
                        --arg owner "$module_owner" \
                        --arg repo "$module_repo" \
                        --arg rev "$module_rev" \
                        --arg hash "$module_hash" \
                        -n '$submodules + {$path: {"owner": $owner, "repo": $repo, "rev": $rev, "hash": $hash}}')
    done

    echo "$submodules" > "$tmp/result.json"
    nix eval --impure --expr "builtins.fromJSON (builtins.readFile \"$tmp/result.json\")" | \
        nixfmt > submodules-$version.nix
  • Loading branch information
mjoerg committed Nov 6, 2024
1 parent 5d6c33e commit f7533e5
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pkgs/by-name/ed/edk2/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,19 @@ edk2 = stdenv.mkDerivation {
owner = "tianocore";
repo = "edk2";
rev = "edk2-stable${edk2.version}";
fetchSubmodules = true;
hash = "sha256-2odaTqiAZD5xduT0dwIYWj3gY/aFPVsTFbblIsEhBiA=";

# Original submodule sources are no longer available, so the submodules are fetched manually,
# with unavailable sources replaced by mirrors. (https://github.com/tianocore/edk2/pull/6402)
fetchSubmodules = edk2.version != "202408";
postFetch =
lib.optionalString (edk2.version == "202408") lib.pipe (import ./submodules-202408.nix)
[
(lib.mapAttrsToList (
path: src: "cp -r -T ${fetchFromGitHub (src // { fetchSubmodules = true; })} $out/${path}"
))
lib.concatLines
];
};

src = applyPatches {
Expand Down
80 changes: 80 additions & 0 deletions pkgs/by-name/ed/edk2/submodules-202408.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
"ArmPkg/Library/ArmSoftFloatLib/berkeley-softfloat-3" = {
hash = "sha256-Yflpx+mjU8mD5biClNpdmon24EHg4aWBZszbOur5VEA=";
owner = "ucb-bar";
repo = "berkeley-softfloat-3";
rev = "b64af41c3276f97f0e181920400ee056b9c88037";
};
"BaseTools/Source/C/BrotliCompress/brotli" = {
hash = "sha256-pHC3aMcJ+6//x7T/4sU32+KsstmRwbR4JZPGtdjqrMU=";
owner = "google";
repo = "brotli";
rev = "f4153a09f87cbb9c826d8fc12c74642bb2d879ea";
};
"CryptoPkg/Library/MbedTlsLib/mbedtls" = {
hash = "sha256-yb5migP5Tcw99XHFzJkCct4f5R6ztxPR43VQcfTGRtE=";
owner = "ARMmbed";
repo = "mbedtls";
rev = "8c89224991adff88d53cd380f42a2baa36f91454";
};
"CryptoPkg/Library/OpensslLib/openssl" = {
hash = "sha256-gpnSNaqwcA9bw1FWSrQpiTwkBL9ba0C4E7aQW1ExXTI=";
owner = "openssl";
repo = "openssl";
rev = "de90e54bbe82e5be4fb9608b6f5c308bb837d355";
};
"MdeModulePkg/Library/BrotliCustomDecompressLib/brotli" = {
hash = "sha256-pHC3aMcJ+6//x7T/4sU32+KsstmRwbR4JZPGtdjqrMU=";
owner = "google";
repo = "brotli";
rev = "f4153a09f87cbb9c826d8fc12c74642bb2d879ea";
};
"MdeModulePkg/Universal/RegularExpressionDxe/oniguruma" = {
hash = "sha256-rNT+d8mQM76F3i/BsLdZJUQ5IlMU1bLkeS/pRK0Y9vk=";
owner = "kkos";
repo = "oniguruma";
rev = "abfc8ff81df4067f309032467785e06975678f0d";
};
"MdePkg/Library/BaseFdtLib/libfdt" = {
hash = "sha256-BGEWqddR/iUTI+PufhYOswIU86VX9bEuMo4rjD2Zabw=";
owner = "devicetree-org";
repo = "pylibfdt";
rev = "cfff805481bdea27f900c32698171286542b8d3c";
};
"MdePkg/Library/MipiSysTLib/mipisyst" = {
hash = "sha256-6wrzZNravSL/M/g792DVUa63ZWK9ydpTCnBpRBNIsHM=";
owner = "MIPI-Alliance";
repo = "public-mipi-sys-t";
rev = "370b5944c046bab043dd8b133727b2135af7747a";
};
"RedfishPkg/Library/JsonLib/jansson" = {
hash = "sha256-41QQ3PxNnvQQmX2cLBZgAVCJVZofDb6a/i5WpsG6lHo=";
owner = "akheron";
repo = "jansson";
rev = "e9ebfa7e77a6bee77df44e096b100e7131044059";
};
"SecurityPkg/DeviceSecurity/SpdmLib/libspdm" = {
hash = "sha256-GY01N0/bWdWyzDZe1b0qLlmDLz5oxpBdYug8bEs33qg=";
owner = "DMTF";
repo = "libspdm";
rev = "50924a4c8145fc721e17208f55814d2b38766fe6";
};
"UnitTestFrameworkPkg/Library/CmockaLib/cmocka" = {
hash = "sha256-AEOG82bFVSl+BMYf0jdmPBiAHSUAN7XeEC9vWfkBgu8=";
owner = "tianocore";
repo = "edk2-cmocka";
rev = "1cc9cde3448cdd2e000886a26acf1caac2db7cf1";
};
"UnitTestFrameworkPkg/Library/GoogleTestLib/googletest" = {
hash = "sha256-KOGkk5PWSDpCGp85ciULPNrylAW9JNRGyeO9JCZyGq8=";
owner = "google";
repo = "googletest";
rev = "86add13493e5c881d7e4ba77fb91c1f57752b3a4";
};
"UnitTestFrameworkPkg/Library/SubhookLib/subhook" = {
hash = "sha256-0X9JrYh+g39tJxVn8ofTITet9Is3Oe1avWFzdsRkM2Q=";
owner = "tianocore";
repo = "edk2-subhook";
rev = "83d4e1ebef3588fae48b69a7352cc21801cb70bc";
};
}

0 comments on commit f7533e5

Please sign in to comment.