Unverified Commit 8bd11992 authored by Morgan Jones's avatar Morgan Jones
Browse files

androidenv: fix autoupdate and custom XMLs

This regression happened during refactoring of mkrepo.rb. Do another
round of it with a focus on fixing the autoupdate and use of custom
repository XMLs.

Add an example to check this behavior (but don't run it in the test
suite, since it requires IFD).
parent 9df023d3
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
+2 −2
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ let
in
stdenv.mkDerivation {
  name = "androidenv-test-suite";
  version = "1";
  buildInputs = lib.mapAttrsToList (name: value: value) all-tests;

  buildCommand = ''
@@ -26,9 +27,8 @@ stdenv.mkDerivation {

  passthru.tests = all-tests;

  # This is the toplevel package, so inherit the update script
  passthru.updateScript = {
    command = [ ./update.sh ];
    command = [ ./update.rb ];
    attrPath = "androidenv.test-suite";
    supportedFeatures = [ "commit" ];
  };
Loading