mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-28 12:34:26 +01:00
Disable networking on image with command line option ./build -p -n
This commit is contained in:
9
build
9
build
@@ -4,9 +4,10 @@ arch=x86_64
|
|||||||
extra_targets=''
|
extra_targets=''
|
||||||
qemu_sdl='--enable-sdl --with-sdlabi=2.0'
|
qemu_sdl='--enable-sdl --with-sdlabi=2.0'
|
||||||
j="$(($(nproc) - 2))"
|
j="$(($(nproc) - 2))"
|
||||||
|
post_script_args=''
|
||||||
x11=false
|
x11=false
|
||||||
v=0
|
v=0
|
||||||
while getopts 'a:e:j:nSt:v' OPT; do
|
while getopts 'a:j:p:St:v' OPT; do
|
||||||
case "$OPT" in
|
case "$OPT" in
|
||||||
a)
|
a)
|
||||||
arch="$OPTARG"
|
arch="$OPTARG"
|
||||||
@@ -14,6 +15,9 @@ while getopts 'a:e:j:nSt:v' OPT; do
|
|||||||
j)
|
j)
|
||||||
j="$OPTARG"
|
j="$OPTARG"
|
||||||
;;
|
;;
|
||||||
|
p)
|
||||||
|
post_script_args="$OPTARG"
|
||||||
|
;;
|
||||||
S)
|
S)
|
||||||
qemu_sdl=''
|
qemu_sdl=''
|
||||||
;;
|
;;
|
||||||
@@ -28,6 +32,7 @@ while getopts 'a:e:j:nSt:v' OPT; do
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
shift $(($OPTIND - 1))
|
||||||
case "$arch" in
|
case "$arch" in
|
||||||
x86_64)
|
x86_64)
|
||||||
defconfig=qemu_x86_64_defconfig
|
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.
|
# qemu_arm_vexpress_defconfig required a newer QEMU than 2.0.0 on a Ubuntu host.
|
||||||
# so let's stick to versatile for now.
|
# so let's stick to versatile for now.
|
||||||
defconfig=qemu_arm_versatile_defconfig
|
defconfig=qemu_arm_versatile_defconfig
|
||||||
|
post_script_args="$post_script_args -n"
|
||||||
;;
|
;;
|
||||||
aarch64)
|
aarch64)
|
||||||
defconfig=qemu_aarch64_virt_defconfig
|
defconfig=qemu_aarch64_virt_defconfig
|
||||||
@@ -85,6 +91,7 @@ time \
|
|||||||
make \
|
make \
|
||||||
O="$outdir" \
|
O="$outdir" \
|
||||||
BR2_JLEVEL="$j" \
|
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" \
|
HOST_QEMU_OPTS="--enable-debug --extra-cflags='-DDEBUG_PL061=1' --enable-trace-backends=simple $qemu_sdl" \
|
||||||
V="$v" \
|
V="$v" \
|
||||||
kernel_module-rebuild \
|
kernel_module-rebuild \
|
||||||
|
|||||||
8
init.md
8
init.md
@@ -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
|
- run forever in a loop or long sleep
|
||||||
- `poweroff` the machine
|
- `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:
|
To restore it, run:
|
||||||
|
|
||||||
|
|||||||
@@ -1,2 +1,21 @@
|
|||||||
#!/usr/bin/env bash
|
#!/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
|
||||||
|
|||||||
Reference in New Issue
Block a user