
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>
2.9 KiB
Executable File
#!/bin/bash
Create a "bank" of tap network devices that can be used by the
runqemu script. This script needs to be run as root, and will
use the tunctl binary from the build system sysroot. Note: many Linux
distros these days still use an older version of tunctl which does not
support the group permissions option, hence the need to use the build
system provided version.
Copyright (C) 2010 Intel Corp.
SPDX-License-Identifier: GPL-2.0-only
uid=id -u
gid=id -g
if [ -n "$SUDO_UID" ]; then
uid=$SUDO_UID
fi
if [ -n "$SUDO_GID" ]; then
gid=$SUDO_GID
fi
usage() { echo "Usage: sudo $0 <staging_bindir_native>" echo "Where is the numeric user id the tap devices will be owned by" echo "Where is the numeric group id the tap devices will be owned by" echo " is the number of tap devices to create (0 to remove all)" echo " is the path to the build system's native sysroot" echo "For example:" echo "$ bitbake qemu-helper-native" echo "$ sudo $0 $uid $gid 4 tmp/sysroots-components/x86_64/qemu-helper-native/usr/bin" echo "" exit 1 }
if [ $# -ne 4 ]; then echo "Error: Incorrect number of arguments" usage fi
TUID=$1 GID=$2 COUNT=$3 STAGING_BINDIR_NATIVE=$4
TUNCTL=$STAGING_BINDIR_NATIVE/tunctl if ! -x "$TUNCTL" ; then echo "Error: $TUNCTL is not an executable" usage fi
if [ $EUID -ne 0 ]; then echo "Error: This script must be run with root privileges" exit fi
SCRIPT_DIR=dirname $0
RUNQEMU_IFUP="$SCRIPT_DIR/runqemu-ifup"
if [ ! -x "$RUNQEMU_IFUP" ]; then
echo "Error: Unable to find the runqemu-ifup script in $SCRIPT_DIR"
exit 1
fi
IFCONFIG=which ip 2> /dev/null
if [ -z "$IFCONFIG" ]; then
# Is it ever anywhere else?
IFCONFIG=/sbin/ip
fi
if [ ! -x "$IFCONFIG" ]; then
echo "$IFCONFIG cannot be executed"
exit 1
fi
if [ $COUNT -ge 0 ]; then
# Ensure we start with a clean slate
for tap in $IFCONFIG link | grep tap | awk '{ print \$2 }' | sed s/://
; do
echo "Note: Destroying pre-existing tap interface $tap..."
$TUNCTL -d $tap
done
rm -f /etc/runqemu-nosudo
else
echo "Error: Incorrect count: $COUNT"
exit 1
fi
if [ $COUNT -gt 0 ]; then
echo "Creating $COUNT tap devices for UID: $TUID GID: $GID..."
for ((index=0; index < $COUNT; index++)); do
echo "Creating tap$index"
ifup=$RUNQEMU_IFUP $TUID $GID $STAGING_BINDIR_NATIVE 2>&1
if [ $? -ne 0 ]; then
echo "Error running tunctl: $ifup"
exit 1
fi
done
echo "Note: For systems running NetworkManager, it's recommended"
echo "Note: that the tap devices be set as unmanaged in the"
echo "Note: NetworkManager.conf file. Add the following lines to"
echo "Note: /etc/NetworkManager/NetworkManager.conf"
echo "[keyfile]"
echo "unmanaged-devices=interface-name:tap*"
# The runqemu script will check for this file, and if it exists,
# will use the existing bank of tap devices without creating
# additional ones via sudo.
touch /etc/runqemu-nosudo
fi