Merge pull request #247919 from gilice/flutter-notices

flutter: link notices to all of the artifact directories.
This commit is contained in:
Maciej Krüger 2023-08-11 19:01:38 +02:00 committed by GitHub
commit 3332ba3862
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 49 additions and 1 deletions

View File

@ -6,13 +6,43 @@
, fetchzip
, autoPatchelfHook
, gtk3
, flutterVersion
, unzip
, stdenvNoCC
}:
let
hashes = (import ./hashes.nix).${engineVersion} or
(throw "There are no known artifact hashes for Flutter engine version ${engineVersion}.");
noticeText = stdenvNoCC.mkDerivation (finalAttrs: {
pname = "flutter-notice";
version = engineVersion;
dontUnpack = true;
src = fetchurl {
url = "https://raw.githubusercontent.com/flutter/engine/${engineVersion}/sky/packages/sky_engine/LICENSE";
sha256 = hashes.skyNotice;
};
flutterNotice = fetchurl {
url = "https://raw.githubusercontent.com/flutter/flutter/${flutterVersion}/LICENSE";
sha256 = hashes.flutterNotice;
};
installPhase =
''
SRC_TEXT="$(cat $src)"
FLUTTER_NOTICE_TEXT="$(cat $flutterNotice)"
cat << EOF > $out
This artifact is from the Flutter SDK's engine.
This file carries third-party notices for its dependencies.
See also other files, that have LICENSE in the name, in the artifact directory.
Appendix 1/2: merged sky_engine LICENSE file (also found at ${finalAttrs.src.url})
$SRC_TEXT
Appendix 2/2: Flutter license (also found at ${finalAttrs.flutterNotice.url})
$FLUTTER_NOTICE_TEXT
EOF
'';
});
artifacts =
{
common = {
@ -165,6 +195,17 @@ let
destination = "$out/${if subdirectory == true then archiveBasename else if subdirectory != null then subdirectory else "."}";
in
''
# ship the notice near all artifacts. if the artifact directory is / multiple directories are nested in $src, link it there. If there isn't a directory, link it in root
# this *isn't the same as the subdirectory variable above*
DIR_CNT="$(echo */ | wc -w)"
if [[ "$DIR_CNT" == 0 ]]; then
ln -s ${noticeText} LICENSE.README
else
for dir in */
do
ln -s ${noticeText} "$dir/LICENSE.README"
done
fi
mkdir -p "${destination}"
cp -r . "${destination}"
'';

View File

@ -1,5 +1,7 @@
{
"1a65d409c7a1438a34d21b60bf30a6fd5db59314" = {
skyNotice = "sha256-n9B26rLlfUqdR6s+2+PNK4H/fN95UE0T7/Vic19W6yo=";
flutterNotice = "sha256-pZjblLYpD/vhC17PkRBXtqlDNRxyf92p5fKJHWhwCiA=";
android-arm = {
"artifacts.zip" = "sha256-KDMiI6SQoZHfFV5LJJZ7VOGyEKC4UxzRc777j4BbXgM=";
};
@ -113,6 +115,8 @@
};
};
"45f6e009110df4f34ec2cf99f63cf73b71b7a420" = {
skyNotice = "sha256-n9B26rLlfUqdR6s+2+PNK4H/fN95UE0T7/Vic19W6yo=";
flutterNotice = "sha256-pZjblLYpD/vhC17PkRBXtqlDNRxyf92p5fKJHWhwCiA=";
android-arm = {
"artifacts.zip" = "sha256-NOpUM+iFSPVzr99Dz0DBdDUQnMC0ad1eZnVhtqu9HnU=";
};

View File

@ -56,7 +56,10 @@
}:
let
engineArtifacts = callPackage ./engine-artifacts { inherit (flutter) engineVersion; };
engineArtifacts = callPackage ./engine-artifacts {
inherit (flutter) engineVersion;
flutterVersion = flutter.version;
};
mkCommonArtifactLinkCommand = { artifact }:
''
mkdir -p $out/artifacts/engine/common