| #!/bin/sh |
| |
| # Copyright 2014 The Android Open Source Project |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); |
| # you may not use this file except in compliance with the License. |
| # You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| |
| # Include common function definitions. |
| . $(dirname "$0")/common.shi |
| |
| shell_import build-defaults.shi |
| |
| usage () { |
| cat >&2 <<EOF |
| Usage: $(program_name) <destination-path> |
| |
| This script is used to unpack all required support library sources needed |
| by the qemu-android build system. Sources will be extracted at the target |
| destination path, which will be created on demand by this script. |
| EOF |
| exit ${1:-0} |
| } |
| |
| if [ -z "$1" ]; then |
| usage 1 |
| fi |
| |
| DEST_DIR=$1 |
| if [ ! -d "$DEST_DIR" ]; then |
| dump "Creating $DEST_DIR" |
| mkdir -p "$DEST_DIR" || |
| panic "Could not create destination directory: $DEST_DIR" |
| else |
| dump "Cleaning up $DEST_DIR" |
| rm -rf "$DEST_DIR"/* |
| fi |
| |
| # Sanity check. |
| ARCHIVE_DIR=$(program_directory)/../archive |
| if [ ! -d "$ARCHIVE_DIR" ]; then |
| panic "Missing archive directory: $ARCHIVE_DIR" |
| fi |
| ARCHIVE_DIR=$(cd "$ARCHIVE_DIR" && pwd -P) |
| |
| MISSING_PKGS= |
| for PKG in $SOURCES_PACKAGES; do |
| PKG_PATH=$ARCHIVE_DIR/$PKG |
| if [ ! -f "$PKG_PATH" ]; then |
| MISSING_PKGS="$MISSING_PKGS $PKG_PATH" |
| else |
| dump "Unpacking $PKG" |
| unpack_archive "$PKG_PATH" "$DEST_DIR" |
| fi |
| done |
| |
| if [ "$MISSING_PKGS" ]; then |
| panic "Missing packages: $MISSING_PKGS" |
| fi |
| |
| echo "Done!" |