Create androidenv package with accepted license so build can run with --pure
This commit is contained in:
parent
33621aec7c
commit
b575f5f6a5
|
@ -65,13 +65,6 @@ shim.js
|
||||||
# Desktop build
|
# Desktop build
|
||||||
index.desktop.js
|
index.desktop.js
|
||||||
|
|
||||||
# Docker
|
|
||||||
#
|
|
||||||
docker/*/scripts/
|
|
||||||
docker/*/*.zip
|
|
||||||
docker/*/*.run
|
|
||||||
docker/*/nvm_install.sh
|
|
||||||
|
|
||||||
# Generated by lein voom
|
# Generated by lein voom
|
||||||
#
|
#
|
||||||
/pom.xml
|
/pom.xml
|
||||||
|
@ -166,3 +159,6 @@ conan.cmake
|
||||||
|
|
||||||
# Env
|
# Env
|
||||||
.env.bkp
|
.env.bkp
|
||||||
|
|
||||||
|
# nix
|
||||||
|
/.ran-setup
|
|
@ -16,7 +16,7 @@ def getToolVersion(name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
def nix_sh(cmd) {
|
def nix_sh(cmd) {
|
||||||
def isPure = env.TARGET_OS == 'linux'
|
def isPure = env.TARGET_OS == 'linux' || env.TARGET_OS == 'android'
|
||||||
def pureFlag = isPure ? '--pure' : ''
|
def pureFlag = isPure ? '--pure' : ''
|
||||||
|
|
||||||
sh """
|
sh """
|
||||||
|
|
|
@ -24,6 +24,7 @@ let
|
||||||
useGoogleTVAddOns = false;
|
useGoogleTVAddOns = false;
|
||||||
includeExtras = [ "extras;android;m2repository" "extras;google;m2repository" ];
|
includeExtras = [ "extras;android;m2repository" "extras;google;m2repository" ];
|
||||||
};
|
};
|
||||||
|
licensedAndroidEnv = callPackage ./licensed-android-sdk.nix { inherit androidComposition; };
|
||||||
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
@ -32,32 +33,13 @@ in
|
||||||
buildInputs = [ openjdk gradle ];
|
buildInputs = [ openjdk gradle ];
|
||||||
shellHook = ''
|
shellHook = ''
|
||||||
export JAVA_HOME="${openjdk}"
|
export JAVA_HOME="${openjdk}"
|
||||||
export ANDROID_HOME=~/.status/Android/Sdk
|
export ANDROID_HOME=${licensedAndroidEnv}
|
||||||
export ANDROID_SDK_ROOT="$ANDROID_HOME"
|
export ANDROID_SDK_ROOT="$ANDROID_HOME"
|
||||||
export ANDROID_NDK_ROOT="${androidComposition.androidsdk}/libexec/android-sdk/ndk-bundle"
|
export ANDROID_NDK_ROOT="${androidComposition.androidsdk}/libexec/android-sdk/ndk-bundle"
|
||||||
export ANDROID_NDK_HOME="$ANDROID_NDK_ROOT"
|
export ANDROID_NDK_HOME="$ANDROID_NDK_ROOT"
|
||||||
export ANDROID_NDK="$ANDROID_NDK_ROOT"
|
export ANDROID_NDK="$ANDROID_NDK_ROOT"
|
||||||
export PATH="$ANDROID_HOME/bin:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools:$ANDROID_HOME/build-tools:$PATH"
|
export PATH="$ANDROID_HOME/bin:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools:$ANDROID_HOME/build-tools:$PATH"
|
||||||
'' +
|
|
||||||
## We need to make a writeable copy of the Android SDK so that we can accept the license (which causes files to be written to the SDK folders)
|
|
||||||
## since the nix store is immutable by nature, we can't license the SDK from there.
|
|
||||||
''
|
|
||||||
if ! [ -d $ANDROID_HOME ]; then
|
|
||||||
echo "=> pulling the Android SDK out of the nix store and into a writeable directory"
|
|
||||||
|
|
||||||
mkdir -p $ANDROID_HOME
|
$(git rev-parse --show-toplevel)/scripts/generate-keystore.sh
|
||||||
cp -rL ${androidComposition.androidsdk}/bin $ANDROID_HOME
|
|
||||||
cp -rL ${androidComposition.androidsdk}/libexec/android-sdk/* $ANDROID_HOME/
|
|
||||||
chmod -R 755 $ANDROID_HOME/
|
|
||||||
'' + lib.optionalString config.android_sdk.accept_license ''
|
|
||||||
echo "=> accepting Android SDK licenses"
|
|
||||||
pushd $ANDROID_HOME
|
|
||||||
yes | $PWD/bin/sdkmanager --licenses || if [ $? -ne '141' ]; then exit $?; fi; #Captures SIGPIPE 141 error but still allow repeating "y" to accept all licenses
|
|
||||||
popd
|
|
||||||
'' +
|
|
||||||
''
|
|
||||||
echo "=> generating keystore"
|
|
||||||
$PWD/scripts/generate-keystore.sh
|
|
||||||
fi
|
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
{ config, stdenv, pkgs, androidComposition }:
|
||||||
|
|
||||||
|
with pkgs;
|
||||||
|
|
||||||
|
stdenv.mkDerivation rec {
|
||||||
|
name = "licensed-android-sdk";
|
||||||
|
version = "licensed";
|
||||||
|
phases = [ "installPhase" ];
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p $out/libexec/android-sdk
|
||||||
|
ln -s "${androidComposition.androidsdk}/bin" $out/bin
|
||||||
|
for d in ${androidComposition.androidsdk}/libexec/android-sdk/*; do
|
||||||
|
ln -s $d $out/$(basename $d)
|
||||||
|
done
|
||||||
|
'' + stdenv.lib.optionalString config.android_sdk.accept_license ''
|
||||||
|
mkdir -p $out/licenses
|
||||||
|
echo -e "\n601085b94cd77f0b54ff86406957099ebe79c4d6" > "$out/licenses/android-googletv-license"
|
||||||
|
echo -e "\n24333f8a63b6825ea9c5514f83c2829b004d1fee" > "$out/licenses/android-sdk-license"
|
||||||
|
echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "$out/licenses/android-sdk-preview-license"
|
||||||
|
echo -e "\nd975f751698a77b662f1254ddbeed3901e976f5a" > "$out/licenses/intel-android-extra-license"
|
||||||
|
echo -e "\n33b6a2b64607f11b759f320ef9dff4ae5c47d97a" > "$out/licenses/google-gdk-license"
|
||||||
|
'';
|
||||||
|
}
|
|
@ -22,12 +22,16 @@ if ! command -v "nix" >/dev/null 2>&1; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if command -v "nix" >/dev/null 2>&1; then
|
if command -v "nix" >/dev/null 2>&1; then
|
||||||
echo -e "${GREEN}Configuring Nix shell for target '${TARGET_OS:=all}'...${NC}"
|
|
||||||
if [[ $@ == "ENTER_NIX_SHELL" ]]; then
|
if [[ $@ == "ENTER_NIX_SHELL" ]]; then
|
||||||
|
echo -e "${GREEN}Configuring Nix shell for target '${TARGET_OS:=all}'...${NC}"
|
||||||
exec nix-shell --show-trace --argstr target-os ${TARGET_OS}
|
exec nix-shell --show-trace --argstr target-os ${TARGET_OS}
|
||||||
else
|
else
|
||||||
is_pure=''
|
is_pure=''
|
||||||
[ "${TARGET_OS}" == 'linux' ] && is_pure='--pure'
|
if [ "${TARGET_OS}" == 'linux' ] || [ "${TARGET_OS}" == 'android' ]; then
|
||||||
|
is_pure='--pure'
|
||||||
|
pure_desc='pure '
|
||||||
|
fi
|
||||||
|
echo -e "${GREEN}Configuring ${pure_desc}Nix shell for target '${TARGET_OS:=all}'...${NC}"
|
||||||
exec nix-shell ${is_pure} --show-trace --argstr target-os ${TARGET_OS} --run "$@"
|
exec nix-shell ${is_pure} --show-trace --argstr target-os ${TARGET_OS} --run "$@"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -14,10 +14,10 @@ STATUS_RELEASE_STORE_PASSWORD=$(property_gradle 'STATUS_RELEASE_STORE_PASSWORD')
|
||||||
STATUS_RELEASE_KEY_ALIAS=$(property_gradle 'STATUS_RELEASE_KEY_ALIAS')
|
STATUS_RELEASE_KEY_ALIAS=$(property_gradle 'STATUS_RELEASE_KEY_ALIAS')
|
||||||
STATUS_RELEASE_KEY_PASSWORD=$(property_gradle 'STATUS_RELEASE_KEY_PASSWORD')
|
STATUS_RELEASE_KEY_PASSWORD=$(property_gradle 'STATUS_RELEASE_KEY_PASSWORD')
|
||||||
|
|
||||||
[[ -e "$STORE_FILE" ]] && echo "Keystore $STORE_FILE already exists, please manually remove it if you want to regenerate." && exit 0
|
[[ -e "$STORE_FILE" ]] && exit 0
|
||||||
|
|
||||||
echo "Generating keystore $STORE_FILE"
|
echo "Generating keystore $STORE_FILE"
|
||||||
keydirname="$( dirname "$STORE_FILE" )"
|
keydirname="$( dirname "$STORE_FILE" )"
|
||||||
[ -d $keydirname ] || mkdir -p $keydirname
|
[ -d $keydirname ] || mkdir -p $keydirname
|
||||||
keytool -genkey -v -keystore ${STORE_FILE} -keyalg RSA -keysize 2048 -validity 10000 -alias ${STATUS_RELEASE_KEY_ALIAS} \
|
keytool -genkey -v -keystore ${STORE_FILE} -keyalg RSA -keysize 2048 -validity 10000 -alias ${STATUS_RELEASE_KEY_ALIAS} \
|
||||||
-storepass ${STATUS_RELEASE_STORE_PASSWORD} -keypass ${STATUS_RELEASE_KEY_PASSWORD} -dname "CN=, OU=, O=, L=, S=, C="
|
-storepass ${STATUS_RELEASE_STORE_PASSWORD} -keypass ${STATUS_RELEASE_KEY_PASSWORD} -dname "CN=, OU=, O=, L=, S=, C="
|
|
@ -38,22 +38,9 @@ if [ -z "$IN_NIX_SHELL" ]; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$PLATFORM" == 'android' ]; then
|
if [ "$PLATFORM" == 'ios' ] && [ "$(uname)" != "Darwin" ]; then
|
||||||
if [ ! -d $ANDROID_SDK_ROOT ]; then
|
|
||||||
echo -e "${GREEN}SDK setup not complete, please run 'scripts/setup'!${NC}"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [ ! -d $ANDROID_NDK_ROOT ]; then
|
|
||||||
echo -e "${GREEN}NDK setup not complete, please run 'scripts/setup'!${NC}"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
elif [ "$PLATFORM" == 'ios' ] && [ "$(uname)" != "Darwin" ]; then
|
|
||||||
echo -e "${RED}iOS builds are only possible on macOS hosts${NC}"
|
echo -e "${RED}iOS builds are only possible on macOS hosts${NC}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $PLATFORM == 'setup' ]]; then
|
echo -e "${GREEN}Finished!${NC}"
|
||||||
echo -e "${YELLOW}Finished! Please close your terminal, reopen a new one and type 'nix-shell' before building Status.${NC}"
|
|
||||||
else
|
|
||||||
echo -e "${GREEN}Finished!${NC}"
|
|
||||||
fi
|
|
||||||
|
|
14
shell.nix
14
shell.nix
|
@ -18,7 +18,9 @@ in _mkShell {
|
||||||
# utilities
|
# utilities
|
||||||
bash
|
bash
|
||||||
curl
|
curl
|
||||||
|
file
|
||||||
git
|
git
|
||||||
|
gnumake
|
||||||
jq
|
jq
|
||||||
ncurses
|
ncurses
|
||||||
lsof # used in scripts/start-react-native.sh
|
lsof # used in scripts/start-react-native.sh
|
||||||
|
@ -31,11 +33,13 @@ in _mkShell {
|
||||||
shellHook =
|
shellHook =
|
||||||
''
|
''
|
||||||
set -e
|
set -e
|
||||||
'' +
|
|
||||||
projectDeps.shellHook +
|
${projectDeps.shellHook}
|
||||||
''
|
|
||||||
if [ -n "$ANDROID_SDK_ROOT" ] && [ ! -d "$ANDROID_SDK_ROOT" ]; then
|
STATUS_REACT_HOME=$(git rev-parse --show-toplevel)
|
||||||
./scripts/setup # we assume that if the Android SDK dir does not exist, setup script needs to be run
|
if [ ! -f $STATUS_REACT_HOME/.ran-setup ]; then
|
||||||
|
$STATUS_REACT_HOME/scripts/setup
|
||||||
|
touch $STATUS_REACT_HOME/.ran-setup
|
||||||
fi
|
fi
|
||||||
set +e
|
set +e
|
||||||
'';
|
'';
|
||||||
|
|
Loading…
Reference in New Issue