Skip to content

Commit

Permalink
Improved all scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoguerri committed Nov 14, 2020
1 parent e3ad919 commit 281ab1f
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 58 deletions.
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ RUN mkdir $home/openembedded/build
COPY --chown=dev:dev layer/local.conf $home/openembedded/build/conf/local.conf
COPY --chown=dev:dev layer/bblayers.conf $home/openembedded/build/conf/bblayers.conf

COPY --chown=dev:dev build_scripts/run_qemu.sh $home
COPY --chown=dev:dev build_scripts/build_image.sh $home
COPY --chown=dev:dev scripts/emulate.sh $home
COPY --chown=dev:dev scripts/build.sh $home

RUN chmod u+x $home/run_qemu.sh
RUN chmod u+x $home/build_image.sh
RUN chmod u+x $home/emulate.sh
RUN chmod u+x $home/build.sh
1 change: 0 additions & 1 deletion layer/recipes-core/images/core-image-minimal.bbappend
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ IMAGE_INSTALL += " \
kernel-modules \
psmisc \
procps \
rtl8192 \
iw \
tmux \
glibc-utils \
Expand Down
35 changes: 35 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash
set -eu

[[ $(whoami) != "root" ]] && echo "Please run this script as root" && exit 1

if docker volume inspect oe_build_volume >& /dev/null; then
echo "Docker volume oe_build_volume already exists..."
else
echo "Creating docker volume"
docker volume create oe_build_volume
fi

if docker inspect c_oe_build >& /dev/null; then
echo "Docker container already exists, restarting..."
docker stop c_oe_build
docker start -ai c_oe_build
else

if ! docker image inspect oe_build >& /dev/null; then
echo "Image does not exist, building it..."
docker build -t oe_build .
fi
echo "Creating container based on oe_build image"
docker run \
--cap-add=ALL \
--cap-add=NET_ADMIN \
--cap-add=SETUID \
--cap-add=SETGID \
--cap-add=AUDIT_WRITE \
-v oe_build_volume:/home/dev/openembedded/build \
--device /dev/net/tun:/dev/net/tun \
-it \
--name c_oe_build oe_build \
/home/dev/build.sh
fi
File renamed without changes.
File renamed without changes.
6 changes: 0 additions & 6 deletions scripts/copy_image.sh

This file was deleted.

47 changes: 27 additions & 20 deletions build_scripts/run_qemu.sh → scripts/emulate.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
#!/bin/bash
set -ex

OE_ROOT="/home/dev/openembedded"

platform=${1}

case "$platform" in
x86_64 ) echo "Starting qemu x86_64"; build=1;;
arm ) echo "Starting qemu arm"; build=0;;
* ) echo "Invalid platform"; exit 1;;
machine=$(grep "^MACHINE" ${OE_ROOT}/build/conf/local.conf | sed 's/[^"]*"\([^"]*\)"/\1/')
case "${machine}" in
qemux86-64)
;;
*arm*)
;;
*)
echo "Machine type not supported: ${machine}"
exit 1
;;
esac

# Container privileges required:
Expand Down Expand Up @@ -36,34 +41,36 @@ esac


# Setup bridge
sudo /sbin/ip link set down dev br0 && /sbin/brctl delbr br0 || true
if ! /sbin/brctl show br0; then
sudo /sbin/ip link add name br0 type bridge
sudo /sbin/ip link set eth0 master br0
fi

sudo /sbin/ip link add name br0 type bridge
sudo /sbin/ip link set eth0 master br0
sudo /sbin/ip addr flush dev eth0
sudo /sbin/ip addr flush dev br0
sudo /sbin/dhclient br0

sudo /sbin/ip link set down dev tap0 && sudo /sbin/ip link delete tap0 || true

# Setup tap device for qemu
sudo /sbin/ip tuntap add tap0 mode tap
sudo /sbin/brctl addif br0 tap0
if ! /sbin/ip link show tap0; then
sudo /sbin/ip tuntap add tap0 mode tap
sudo /sbin/ip link set tap0 master br0
sudo /sbin/ip link set tap0 up
fi

if [[ ${platform} == "x86_64" ]]; then
if [[ ${machine} == "qemux86-64" ]]; then
(
deploy_dir=~dev/openembedded/openembedded-core/build/tmp-glibc/deploy/images/qemux86-64
deploy_dir="${OE_ROOT}/build/tmp-glibc/deploy/images/${machine}"
qemu-system-x86_64 -kernel ${deploy_dir}/bzImage \
--append "console=ttyS0 root=/dev/vda" \
-nographic \
-serial mon:stdio \
-drive file=${deploy_dir}/core-image-minimal-qemux86-64.ext4,if=virtio,format=raw \
-device e1000,macaddr=00:11:22:33:44:55,id=hintf \
-netdev tap,ifname=tap0,id=hintf,script=no

-drive file=${deploy_dir}/core-image-minimal-${machine}.ext4,if=virtio,format=raw \
-netdev tap,id=network0,ifname=tap0,script=no,downscript=no \
-device e1000,netdev=network0,mac=00:11:22:33:44:55
)
else
(
deploy_dir=~dev/openembedded/build/tmp-glibc/deploy/images/raspberrypi2/
deploy_dir="${OE_ROOT}/build/tmp-glibc/deploy/images/raspberrypi2/"
# Note: all the append kernel command line parameters effectively
# overwrite what is written in cmdline.txt (the file used by Rpi bootloader
# to populate kernel command line arguments according to the boot protocol),
Expand Down
27 changes: 0 additions & 27 deletions scripts/run_build_in_container.sh

This file was deleted.

0 comments on commit 281ab1f

Please sign in to comment.