summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorRobert Yang <liezhi.yang@windriver.com>2018-12-28 00:58:58 -0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-02-06 16:38:31 +0000
commita849af7f9f6de81c2d904a2e064a94410cc97243 (patch)
tree008b54a7b23e86a3b0d43fb570baccdc60e6cabd /scripts
parent5fe0d8a8d72034ce6aa83d0cf9e550b0a44c4ef7 (diff)
downloadpoky-a849af7f9f6de81c2d904a2e064a94410cc97243.tar.gz
runqemu-gen-tapdevs: Allow run --help without sudo
Then we can get user's UID and GID rather than hardcode to 1000, e.g.: - Without sudo $ runqemu-gen-tapdevs --help [snip] $ sudo ../poky/scripts/runqemu-gen-tapdevs 15220 100 4 tmp/sysroots-components/x86_64/qemu-helper-native/usr/bin [snip] - With sudo $ sudo ../poky/scripts/runqemu-gen-tapdevs --help [snip] $ sudo ../poky/scripts/runqemu-gen-tapdevs 15220 100 4 tmp/sysroots-components/x86_64/qemu-helper-native/usr/bin [snip] (From OE-Core rev: 446e7da7e56f9de3602498b5ef40e9e0f8f71837) (From OE-Core rev: 79471a27018d2e766b349540693e6c196fa75869) Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> Signed-off-by: Armin Kuster <akuster808@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/runqemu-gen-tapdevs27
1 files changed, 19 insertions, 8 deletions
diff --git a/scripts/runqemu-gen-tapdevs b/scripts/runqemu-gen-tapdevs
index 11de318c1a..869fee261d 100755
--- a/scripts/runqemu-gen-tapdevs
+++ b/scripts/runqemu-gen-tapdevs
@@ -22,22 +22,28 @@
22# with this program; if not, write to the Free Software Foundation, Inc., 22# with this program; if not, write to the Free Software Foundation, Inc.,
23# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 24
25uid=`id -u`
26gid=`id -g`
27if [ -n "$SUDO_UID" ]; then
28 uid=$SUDO_UID
29fi
30if [ -n "$SUDO_GID" ]; then
31 gid=$SUDO_GID
32fi
33
25usage() { 34usage() {
26 echo "Usage: sudo $0 <uid> <gid> <num> <staging_bindir_native>" 35 echo "Usage: sudo $0 <uid> <gid> <num> <staging_bindir_native>"
27 echo "Where <uid> is the numeric user id the tap devices will be owned by" 36 echo "Where <uid> is the numeric user id the tap devices will be owned by"
28 echo "Where <gid> is the numeric group id the tap devices will be owned by" 37 echo "Where <gid> is the numeric group id the tap devices will be owned by"
29 echo "<num> is the number of tap devices to create (0 to remove all)" 38 echo "<num> is the number of tap devices to create (0 to remove all)"
30 echo "<native-sysroot-basedir> is the path to the build system's native sysroot" 39 echo "<native-sysroot-basedir> is the path to the build system's native sysroot"
31 echo "e.g. $ bitbake qemu-helper-native" 40 echo "For example:"
32 echo "$ sudo $0 1000 1000 4 tmp/sysroots-components/x86_64/qemu-helper-native/usr/bin" 41 echo "$ bitbake qemu-helper-native"
42 echo "$ sudo $0 $uid $gid 4 tmp/sysroots-components/x86_64/qemu-helper-native/usr/bin"
43 echo ""
33 exit 1 44 exit 1
34} 45}
35 46
36if [ $EUID -ne 0 ]; then
37 echo "Error: This script must be run with root privileges"
38 exit
39fi
40
41if [ $# -ne 4 ]; then 47if [ $# -ne 4 ]; then
42 echo "Error: Incorrect number of arguments" 48 echo "Error: Incorrect number of arguments"
43 usage 49 usage
@@ -54,6 +60,11 @@ if [[ ! -x "$TUNCTL" || -d "$TUNCTL" ]]; then
54 usage 60 usage
55fi 61fi
56 62
63if [ $EUID -ne 0 ]; then
64 echo "Error: This script must be run with root privileges"
65 exit
66fi
67
57SCRIPT_DIR=`dirname $0` 68SCRIPT_DIR=`dirname $0`
58RUNQEMU_IFUP="$SCRIPT_DIR/runqemu-ifup" 69RUNQEMU_IFUP="$SCRIPT_DIR/runqemu-ifup"
59if [ ! -x "$RUNQEMU_IFUP" ]; then 70if [ ! -x "$RUNQEMU_IFUP" ]; then