Disable networking on image with command line option ./build -p -n

This commit is contained in:
Ciro Santilli
2017-12-28 23:03:26 +00:00
parent 32c4ce0291
commit 920afba40a
3 changed files with 32 additions and 6 deletions

9
build
View File

@@ -4,9 +4,10 @@ arch=x86_64
extra_targets=''
qemu_sdl='--enable-sdl --with-sdlabi=2.0'
j="$(($(nproc) - 2))"
post_script_args=''
x11=false
v=0
while getopts 'a:e:j:nSt:v' OPT; do
while getopts 'a:j:p:St:v' OPT; do
case "$OPT" in
a)
arch="$OPTARG"
@@ -14,6 +15,9 @@ while getopts 'a:e:j:nSt:v' OPT; do
j)
j="$OPTARG"
;;
p)
post_script_args="$OPTARG"
;;
S)
qemu_sdl=''
;;
@@ -28,6 +32,7 @@ while getopts 'a:e:j:nSt:v' OPT; do
;;
esac
done
shift $(($OPTIND - 1))
case "$arch" in
x86_64)
defconfig=qemu_x86_64_defconfig
@@ -41,6 +46,7 @@ case "$arch" in
# qemu_arm_vexpress_defconfig required a newer QEMU than 2.0.0 on a Ubuntu host.
# so let's stick to versatile for now.
defconfig=qemu_arm_versatile_defconfig
post_script_args="$post_script_args -n"
;;
aarch64)
defconfig=qemu_aarch64_virt_defconfig
@@ -85,6 +91,7 @@ time \
make \
O="$outdir" \
BR2_JLEVEL="$j" \
BR2_ROOTFS_POST_SCRIPT_ARGS="$post_script_args" \
HOST_QEMU_OPTS="--enable-debug --extra-cflags='-DDEBUG_PL061=1' --enable-trace-backends=simple $qemu_sdl" \
V="$v" \
kernel_module-rebuild \

View File

@@ -31,13 +31,13 @@ Also remember that if your init returns, the kernel will panic, there are just t
- run forever in a loop or long sleep
- `poweroff` the machine
### BusyBox init is fine, but networking timeout gets on my nerves
### Disable networking
I know, right?
The default BusyBox init scripts enable networking, and there is a 15 second timeout in case your network is down or if your kernel / emulator setup does not support it.
Add this line to `rootfs_post_build_script`:
To disable networking, use:
rm -f "${1}/etc/init.d/"S*network
./build -p -n
To restore it, run:

View File

@@ -1,2 +1,21 @@
#!/usr/bin/env bash
#rm "${1}/etc/init.d/"S*network
# This is run as part of:
# make target-finalize
# which gets called by the default target.
# To test it out, arguments can be passed with:
# make BR2_ROOTFS_POST_SCRIPT_ARGS="asdf qwer"
target_dir="$1"
shift
net=true
while getopts 'n' OPT; do
case "$OPT" in
n)
echo asdfqwer
net=false
;;
esac
done
shift $(($OPTIND - 1))
if ! "$net"; then
rm -f "${target_dir}/etc/init.d/"S*network
fi