Merge pull request #248435 from hadilq/androidenv-fix-cmdline-beta-version

androidenv fix cmdline beta versions' problem
This commit is contained in:
Nick Cao 2023-08-13 00:25:14 -06:00 committed by GitHub
commit dbf5978a61
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 7 deletions

View file

@ -1,4 +1,4 @@
{deployAndroidPackage, lib, package, autoPatchelfHook, makeWrapper, os, pkgs, pkgsi686Linux, stdenv, cmdLineToolsVersion, postInstall}:
{deployAndroidPackage, lib, package, autoPatchelfHook, makeWrapper, os, pkgs, pkgsi686Linux, stdenv, postInstall}:
deployAndroidPackage {
name = "androidsdk";
@ -16,7 +16,7 @@ deployAndroidPackage {
export ANDROID_SDK_ROOT="$out/libexec/android-sdk"
# Wrap all scripts that require JAVA_HOME
find $ANDROID_SDK_ROOT/cmdline-tools/${cmdLineToolsVersion}/bin -maxdepth 1 -type f -executable | while read program; do
find $ANDROID_SDK_ROOT/${package.path}/bin -maxdepth 1 -type f -executable | while read program; do
if grep -q "JAVA_HOME" $program; then
wrapProgram $program --prefix PATH : ${pkgs.jdk11}/bin \
--prefix ANDROID_SDK_ROOT : $ANDROID_SDK_ROOT
@ -24,12 +24,12 @@ deployAndroidPackage {
done
# Wrap sdkmanager script
wrapProgram $ANDROID_SDK_ROOT/cmdline-tools/${cmdLineToolsVersion}/bin/sdkmanager \
wrapProgram $ANDROID_SDK_ROOT/${package.path}/bin/sdkmanager \
--prefix PATH : ${lib.makeBinPath [ pkgs.jdk11 ]} \
--add-flags "--sdk_root=$ANDROID_SDK_ROOT"
# Patch all script shebangs
patchShebangs $ANDROID_SDK_ROOT/cmdline-tools/${cmdLineToolsVersion}/bin
patchShebangs $ANDROID_SDK_ROOT/${package.path}/bin
cd $ANDROID_SDK_ROOT
${postInstall}

View file

@ -314,6 +314,8 @@ rec {
'') plugins}
''; # */
cmdline-tools-package = check-version packages "cmdline-tools" cmdLineToolsVersion;
# This derivation deploys the tools package and symlinks all the desired
# plugins that we want to use. If the license isn't accepted, prints all the licenses
# requested and throws.
@ -329,9 +331,9 @@ rec {
by an environment variable for a single invocation of the nix tools.
$ export NIXPKGS_ACCEPT_ANDROID_SDK_LICENSE=1
'' else callPackage ./cmdline-tools.nix {
inherit deployAndroidPackage os cmdLineToolsVersion;
inherit deployAndroidPackage os;
package = check-version packages "cmdline-tools" cmdLineToolsVersion;
package = cmdline-tools-package;
postInstall = ''
# Symlink all requested plugins
@ -375,7 +377,7 @@ rec {
ln -s $i $out/bin
done
find $ANDROID_SDK_ROOT/cmdline-tools/${cmdLineToolsVersion}/bin -type f -executable | while read i; do
find $ANDROID_SDK_ROOT/${cmdline-tools-package.path}/bin -type f -executable | while read i; do
ln -s $i $out/bin
done