Unverified Commit f55b94f6 authored by Morgan Jones's avatar Morgan Jones Committed by GitHub
Browse files

androidenv: fix autoupdate and custom XMLs (#411999)

parents c697944f 68995ee2
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
# How to update

1. `./fetchrepo.sh`
2. `./mkrepo.sh`
3. Check the `repo.json` diff for new stable versions of `tools`, `platform-tools`, `build-tools`, `emulator` and/or `ndk`
4. Update the relevant argument defaults in `compose-android-packages.nix`
`nix-shell maintainers/scripts/update.nix  --argstr package androidenv.test-suite --argstr commit true`

# How to run tests

You may need to make yourself familiar with [package tests](../../../README.md#package-tests), and [Writing larger package tests](../../../README.md#writing-larger-package-tests), then run tests locally with:

```shell
$ export NIXPKGS_ALLOW_UNFREE=1
$ cd path/to/nixpkgs
$ nix-build -A androidenv.test-suite.tests
$ nix-build -A androidenv.test-suite
```
+3 −2
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ in
    # Reads the repo JSON. If repoXmls is provided, will build a repo JSON into the Nix store.
    if repoXmls != null then
      let
        # Uses mkrepo.rb to create a repo spec.
        # Uses update.rb to create a repo spec.
        mkRepoJson =
          {
            packages ? [ ],
@@ -43,6 +43,7 @@ in
              ruby.withPackages (
                pkgs: with pkgs; [
                  slop
                  curb
                  nokogiri
                ]
              )
@@ -68,7 +69,7 @@ in
            preferLocalBuild = true;
            unpackPhase = "true";
            buildPhase = ''
              ruby ${./mkrepo.rb} ${lib.escapeShellArgs mkRepoRubyArguments} > repo.json
              env ruby -e 'load "${./update.rb}"' -- ${lib.escapeShellArgs mkRepoRubyArguments} --input /dev/null --output repo.json
            '';
            installPhase = ''
              mv repo.json $out
+60 −0
Original line number Diff line number Diff line
{
  # If you want to use the in-tree version of nixpkgs:
  pkgs ? import ../../../../.. {
    config.allowUnfree = true;
  },

  licenseAccepted ? pkgs.callPackage ../license.nix { },
}:

# Tests IFD with androidenv. Needs a folder of `../xml` in your local tree;
# use ../fetchrepo.sh to produce it.
let
  androidEnv = pkgs.callPackage ./.. {
    inherit pkgs licenseAccepted;
  };

  sdkArgs = {
    repoXmls = {
      packages = [ ../xml/repository2-3.xml ];
      images = [
        ../xml/android-sys-img2-3.xml
        ../xml/android-tv-sys-img2-3.xml
        ../xml/google_apis-sys-img2-3.xml
        ../xml/google_apis_playstore-sys-img2-3.xml
        ../xml/android-wear-sys-img2-3.xml
        ../xml/android-wear-cn-sys-img2-3.xml
        ../xml/android-automotive-sys-img2-3.xml
      ];
      addons = [ ../xml/addon2-3.xml ];
    };
  };

  androidComposition = androidEnv.composeAndroidPackages sdkArgs;
  androidSdk = androidComposition.androidsdk;
  platformTools = androidComposition.platform-tools;
  jdk = pkgs.jdk;
in
pkgs.mkShell {
  name = "androidenv-example-ifd-demo";
  packages = [
    androidSdk
    platformTools
    jdk
  ];

  LANG = "C.UTF-8";
  LC_ALL = "C.UTF-8";
  JAVA_HOME = jdk.home;

  # Note: ANDROID_HOME is deprecated. Use ANDROID_SDK_ROOT.
  ANDROID_SDK_ROOT = "${androidSdk}/libexec/android-sdk";

  shellHook = ''
    # Write out local.properties for Android Studio.
    cat <<EOF > local.properties
    # This file was automatically generated by nix-shell.
    sdk.dir=$ANDROID_SDK_ROOT
    EOF
  '';
}
+0 −19
Original line number Diff line number Diff line
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p "ruby.withPackages (pkgs: with pkgs; [ slop nokogiri moreutils ])"

set -e

pushd "$(dirname "$0")" &>/dev/null || exit 1

echo "Writing repo.json" >&2
ruby mkrepo.rb \
    --packages ./xml/repository2-3.xml \
    --images ./xml/android-sys-img2-3.xml \
    --images ./xml/android-tv-sys-img2-3.xml \
    --images ./xml/android-wear-cn-sys-img2-3.xml \
    --images ./xml/android-wear-sys-img2-3.xml \
    --images ./xml/android-automotive-sys-img2-3.xml \
    --images ./xml/google_apis-sys-img2-3.xml \
    --images ./xml/google_apis_playstore-sys-img2-3.xml \
    --addons ./xml/addon2-3.xml <./repo.json
popd &>/dev/null
+1093 −1414

File changed.

Preview size limit exceeded, changes collapsed.

Loading