[LEDE-DEV] [PATCH] add --do-setup arg and default to squasfs

Yousong Zhou yszhou4tech at gmail.com
Mon May 22 05:13:14 PDT 2017


Hi, Paul

On 18 May 2017 at 03:40, Paul Spooren <paul at spooren.de> wrote:
> scripts/qemustart
>
> the function do_setup is never used except if the script is changed
> manually. It's used to easily setup bridges and traffic forwarding.
> Adding the parameter --do-config simplifies the deployment.
>

I thought about this before and decided that it would be better if
do_setup() only serve as an example.

You can easily prepare a simple script that will do the setup.  It is
only needed at the first run anyway.  But tampering people's machine
by running commands with sudo privileges makes me feel uneasy...  I
have the impression that many people will just run shell scripts
without evaluating the possible consequence, e.g. the popular "curl
https://example.com/install.sh | sudo bash -s".  This is a bad
practice I do not want to promote.

The other thing is that the do_setup() func in its current form is far
from being generic enough to be exposed as a command line argument.
E.g. the hardcoded ip address setting 192.168.1.3/24 for br-lan is
very likely in collision with the default lan network of many home
routers.


> The scripts defaults to the ext4 filesystem which is an unrealistic in
> most cases. Now defaults to the squashfs img if exists.
>

Not quite sure about this, but using combined-squashfs.img with the
current qemu command line will result in "no space left on device"
when touching any file on /.  Do you want to investigate into that?

                yousong

> Signed-off-by: Paul Spooren <paul at spooren.de>
> ---
>  scripts/qemustart | 20 +++++++++++++++-----
>  1 file changed, 15 insertions(+), 5 deletions(-)
>
> diff --git a/scripts/qemustart b/scripts/qemustart
> index 5cadd7d6a8..f77c674a9c 100755
> --- a/scripts/qemustart
> +++ b/scripts/qemustart
> @@ -84,6 +84,7 @@ check_setup() {
>  usage() {
>         cat >&2 <<EOF
>  Usage: $SELF [-h|--help]
> +          $SELF [--do-setup]
>         $SELF <target>
>           [<subtarget> [<extra-qemu-options>]]
>           [--kernel <kernel>]
> @@ -119,6 +120,11 @@ rand_mac() {
>  parse_args() {
>         while [ "$#" -gt 0 ]; do
>                 case "$1" in
> +                       --do-setup)
> +                          echo "running setup"
> +                          do_setup
> +                          exit 0
> +                          ;;
>                         --kernel) o_kernel="$2"; shift 2 ;;
>                         --rootfs) o_rootfs="$2"; shift 2 ;;
>                         --help|-h)
> @@ -216,9 +222,13 @@ start_qemu_x86() {
>         local qemu_exe
>
>         [ -n "$rootfs" ] || {
> -               rootfs="$o_bindir/lede-$o_target-${o_subtarget%-*}-combined-ext4.img"
> -               if [ ! -f "$rootfs" -a -s "$rootfs.gz" ]; then
> -                       gunzip "$rootfs.gz"
> +               rootfs="$o_bindir/lede-$o_target-${o_subtarget%-*}-combined-squashfs.img"
> +               if [ ! -f "$rootfs" ]; then
> +                       rootfs="$o_bindir/lede-$o_target-${o_subtarget%-*}-combined-ext4.img"
> +
> +                       if [ ! -f "$rootfs" -a -s "$rootfs.gz" ]; then
> +                               gunzip "$rootfs.gz"
> +                       fi
>                 fi
>         }
>         #
> @@ -276,6 +286,6 @@ start_qemu() {
>         esac
>  }
>
> -check_setup \
> -       && parse_args "$@" \
> +parse_args "$@" \
> +       && check_setup \
>         && start_qemu
> --
> 2.11.0
>



More information about the Lede-dev mailing list