diff --git a/examples/scripts/build-with-docker.sh b/examples/scripts/build-with-docker.sh index dcb246f..b7876b9 100755 --- a/examples/scripts/build-with-docker.sh +++ b/examples/scripts/build-with-docker.sh @@ -159,7 +159,7 @@ EOF mkdir -p "$workdir"/results/ builddir=$(mktemp -p "$PWD" -d .build.XXXXXX) - cp "$sdk" "$builddir"/sdk.zip + cp -ra "$sdk" "$builddir"/sdk cp -ra * "$builddir" docker run --rm \ diff --git a/examples/scripts/clean-build.sh b/examples/scripts/clean-build.sh index 5aec034..4d23437 100755 --- a/examples/scripts/clean-build.sh +++ b/examples/scripts/clean-build.sh @@ -19,8 +19,6 @@ sudo apt-get update -qq sudo apt-get clean cd /work/src -(mkdir -p /work/src/sdk; unzip /work/src/sdk.zip; mv /work/src/anbox-streaming-sdk_*/* /work/src/sdk) - # NOTE: Only build Android example APK on x86_64 host. if [ $(uname -m) = x86_64 ]; then # For Anbox Streaming SDK library(AAR) diff --git a/scripts/build.sh b/scripts/build.sh index bf98d8b..d2d913c 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -5,6 +5,7 @@ # PROXY= +CREATE_TARBALL=false VERSION=$(scripts/gen-version.sh) for p in "$@" @@ -16,11 +17,18 @@ do --version=*) VERSION=${p#*=} ;; + --create-tarball) + CREATE_TARBALL=true + ;; *) echo "unrecognized option $p" esac done +mkdir_cp() { + mkdir -p $2 && cp -av $1 $2 +} + builddir=$(mktemp -d -p $PWD .buildXXXXXX) topdir="$PWD" trap "rm -rf ${builddir}" INT EXIT @@ -53,7 +61,9 @@ for d in `find $sdkdir/examples -name assets -type d`; do mkdir -p $d/js && cp js/anbox-stream-sdk.js $d/js done -(cd "$builddir" ; zip -r "$topdir"/"$sdkname".zip *) +if [ "$CREATE_TARBALL" = true ]; then + (cd "$builddir" ; zip -r "$topdir"/"$sdkname".zip *) +fi # Do a test build of our examples with the generated SDK package ( @@ -68,7 +78,7 @@ done cd examples; \ scripts/build-with-docker.sh --proxy="${PROXY}" \ --version="${VERSION}" \ - --anbox-stream-sdk="$topdir"/"$sdkname".zip; \ + --anbox-stream-sdk="$builddir"; \ # To repack zip taball which includes APKs file later mkdir -p "$sdkname"/examples/android/apks; \ cp results/*.apk "$sdkname"/examples/android/apks; mv results/*.apk "$topdir"; \ @@ -76,10 +86,23 @@ done mkdir -p "$sdkname"/android/libs && cp results/*.aar "$sdkname"/android/libs; \ mkdir -p "$sdkname"/examples/android/enhanced_webview_streaming/app/libs && cp results/*.aar \ "$sdkname"/examples/android/enhanced_webview_streaming/app/libs/; \ - zip -r "$topdir"/"$sdkname".zip "$sdkname"/examples/android/apks/*.apk "$sdkname"/android/libs/*.aar \ - "$sdkname"/examples/android/enhanced_webview_streaming/app/libs/*.aar - # Validate the streaming sdk to ensure we don't accidentally leak unwanted files. - "$topdir"/scripts/validate.sh --sdk-zip-tarball="$topdir"/"$sdkname".zip \ - --allowlist="$topdir"/scripts/streaming-sdk-files.allowlist + if [ "$CREATE_TARBALL" = true ]; then + zip -r "$topdir"/"$sdkname".zip "$sdkname"/examples/android/apks/*.apk "$sdkname"/android/libs/*.aar \ + "$sdkname"/examples/android/enhanced_webview_streaming/app/libs/*.aar + + # Validate the streaming sdk to ensure we don't accidentally leak unwanted files. + "$topdir"/scripts/validate.sh --sdk-zip-tarball="$topdir"/"$sdkname".zip \ + --allowlist="$topdir"/scripts/streaming-sdk-files.allowlist + else + mkdir_cp "$sdkname/examples/android/apks/*.apk" "$sdkdir/examples/android/apks/" + mkdir_cp "$sdkname/android/libs/*.aar" "$sdkdir/android/libs/" + mkdir_cp "$sdkname/examples/android/enhanced_webview_streaming/app/libs/*.aar" \ + "$sdkdir/examples/android/enhanced_webview_streaming/app/libs/" + + "$topdir"/scripts/validate.sh --sdk-path="$sdkdir" \ + --allowlist="$topdir"/scripts/streaming-sdk-files.allowlist + + mv "$builddir" "$topdir"/results + fi ) diff --git a/scripts/validate.sh b/scripts/validate.sh index adc65d5..9ba6f81 100755 --- a/scripts/validate.sh +++ b/scripts/validate.sh @@ -6,6 +6,7 @@ ALLOWLIST="./sdk-files.allowlist" SDK_ZIP_TARBALL="./anbox-streaming-sdk.zip" +SDK_PATH= show_help() { cat <<'EOF' @@ -16,6 +17,7 @@ Validates Anbox Streaming SDK by checking that all included source files are in optional arguments: --allowlist= Path to the file holding the list of allowed files into the sdk (default: ./sdk-files.allowlist) --sdk-zip-tarball= Path to the streaming sdk zip tarball (default: ./anbox-streaming-sdk.zip) + --sdk-path= Path to the folder path that include the Anbox Streaming SDK EOF } @@ -29,6 +31,10 @@ while [ -n "$1" ]; do ALLOWLIST=${1#*=} shift ;; + --sdk-path*) + SDK_PATH=${1#*=} + shift + ;; --sdk-zip-tarball=*) SDK_ZIP_TARBALL=${1#*=} shift @@ -40,8 +46,13 @@ while [ -n "$1" ]; do esac done -if [ ! -f "$SDK_ZIP_TARBALL" ]; then - echo "Anbox Streaming SDK is missing" +if [ ! -f "$SDK_ZIP_TARBALL" ] ; then + if [ ! -d "$SDK_PATH" ] ; then + echo "Anbox Streaming SDK is missing" + exit 1 + fi +elif [ -d "$SDK_PATH" ] ; then + echo "parameter '--sdk-path' and '--sdk-zip-tarbll' are mutually exclusive" exit 1 fi @@ -79,11 +90,15 @@ search_for_remaining_files() { ( tmpfolder=$(mktemp -d) cleanup() { - rm -rf "$tmpfolder" + rm -rf "$tmpfolder" } trap cleanup EXIT INT - unzip -qq "$SDK_ZIP_TARBALL" -d "$tmpfolder" + if [ -d "$SDK_PATH" ]; then + cp -ra "$SDK_PATH" "$tmpfolder" + else + unzip -qq "$SDK_ZIP_TARBALL" -d "$tmpfolder" + fi cd "$tmpfolder"/anbox-streaming-sdk_* sdk_version="$(pwd | cut -d_ -f2)"