poky/scripts/runqemu-extract-sdk
Richard Purdie ffae400179 meta/lib+scripts: Convert to SPDX license headers
This adds SPDX license headers in place of the wide assortment of things
currently in our script headers. We default to GPL-2.0-only except for the
oeqa code where it was clearly submitted and marked as MIT on the most part
or some scripts which had the "or later" GPL versioning.

The patch also drops other obsolete bits of file headers where they were
encoountered such as editor modelines, obsolete maintainer information or
the phrase "All rights reserved" which is now obsolete and not required in
copyright headers (in this case its actually confusing for licensing as all
rights were not reserved).

More work is needed for OE-Core but this takes care of the bulk of the scripts
and meta/lib directories.

The top level LICENSE files are tweaked to match the new structure and the
SPDX naming.

(From OE-Core rev: f8c9c511b5f1b7dbd45b77f345cb6c048ae6763e)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-05-09 16:31:55 +01:00

2.7 KiB
Executable File

#!/bin/bash

This utility extracts an SDK image tarball using pseudo, and stores

the pseudo database in var/pseudo within the rootfs. If you want to

boot QEMU using an nfsroot, you must use this script to create the

rootfs to ensure it is done correctly with pseudo.

Copyright (c) 2010 Intel Corp.

SPDX-License-Identifier: GPL-2.0-only

function usage() { echo "Usage: $0 " }

if [ $# -ne 2 ]; then usage exit 1 fi

SYSROOT_SETUP_SCRIPT=which oe-find-native-sysroot 2> /dev/null if [ -z "$SYSROOT_SETUP_SCRIPT" ]; then echo "Error: Unable to find the oe-find-native-sysroot script" echo "Did you forget to source your build system environment setup script?" exit 1 fi . $SYSROOT_SETUP_SCRIPT meta-ide-support PSEUDO_OPTS="-P $OECORE_NATIVE_SYSROOT/usr"

ROOTFS_TARBALL=$1 SDK_ROOTFS_DIR=$2

if [ ! -e "$ROOTFS_TARBALL" ]; then echo "Error: sdk tarball '$ROOTFS_TARBALL' does not exist" usage exit 1 fi

Convert SDK_ROOTFS_DIR to a full pathname

if ; then SDK_ROOTFS_DIR=$(readlink -f $(pwd)/$SDK_ROOTFS_DIR) fi

TAR_OPTS="" if [[ "ROOTFS_TARBALL" =~ tar\.xz ]]; then TAR_OPTS="--numeric-owner -xJf" fi if [[ "ROOTFS_TARBALL" =~ tar\.bz2 ]]; then TAR_OPTS="--numeric-owner -xjf" fi if [[ "ROOTFS_TARBALL" =~ tar\.gz ]]; then TAR_OPTS="--numeric-owner -xzf" fi if [[ "ROOTFS_TARBALL" =~ \.tar ]]; then TAR_OPTS="--numeric-owner -xf" fi if [ -z "$TAR_OPTS" ]; then echo "Error: Unable to determine sdk tarball format" echo "Accepted types: .tar / .tar.gz / .tar.bz2 / .tar.xz" exit 1 fi

if [ ! -d "$SDK_ROOTFS_DIR" ]; then echo "Creating directory $SDK_ROOTFS_DIR" mkdir -p "$SDK_ROOTFS_DIR" fi

pseudo_state_dir="$SDK_ROOTFS_DIR/../$(basename "$SDK_ROOTFS_DIR").pseudo_state" pseudo_state_dir="$(readlink -f $pseudo_state_dir)"

debug_image="echo $ROOTFS_TARBALL | grep '\-dbg\.tar\.'"

if [ -e "$pseudo_state_dir" -a -z "$debug_image" ]; then echo "Error: $pseudo_state_dir already exists!" echo "Please delete the rootfs tree and pseudo directory manually" echo "if this is really what you want." exit 1 fi

mkdir -p "$pseudo_state_dir" touch "$pseudo_state_dir/pseudo.pid" PSEUDO_LOCALSTATEDIR="$pseudo_state_dir" export PSEUDO_LOCALSTATEDIR

echo "Extracting rootfs tarball using pseudo..." echo "$PSEUDO $PSEUDO_OPTS tar -C "$SDK_ROOTFS_DIR" $TAR_OPTS "$ROOTFS_TARBALL"" $PSEUDO $PSEUDO_OPTS tar -C "$SDK_ROOTFS_DIR" $TAR_OPTS "$ROOTFS_TARBALL"

DIRCHECK=ls -l "$SDK_ROOTFS_DIR" | wc -l if [ "$DIRCHECK" -lt 5 ]; then echo "Warning: I don't see many files in $SDK_ROOTFS_DIR" echo "Please double-check the extraction worked as intended" exit 0 fi

echo "SDK image successfully extracted to $SDK_ROOTFS_DIR"

exit 0