Merge branch 'for-next/defenv-2'
This commit is contained in:
commit
bff2e86495
|
@ -508,6 +508,7 @@ config DEFAULT_ENVIRONMENT_GENERIC_NEW
|
|||
select GLOB_SORT
|
||||
select CMD_GLOBAL
|
||||
select CMD_AUTOMOUNT
|
||||
select CMD_BASENAME
|
||||
select FLEXIBLE_BOOTARGS
|
||||
prompt "Generic environment template"
|
||||
|
||||
|
|
|
@ -521,6 +521,8 @@ static int builtin_getopt(struct p_context *ctx, struct child_prog *child,
|
|||
o->optarg = xstrdup(optarg);
|
||||
list_add_tail(&o->list, &ctx->options);
|
||||
}
|
||||
ctx->global_argv += optind - 1;
|
||||
ctx->global_argc -= optind - 1;
|
||||
}
|
||||
|
||||
ctx->options_parsed = 1;
|
||||
|
@ -1899,7 +1901,8 @@ static const __maybe_unused char cmd_getopt_help[] =
|
|||
"hush option parser. <optstring> is a string with valid options. Add\n"
|
||||
"a colon to an options if this option has a required argument or two\n"
|
||||
"colons for an optional argument. The current option is saved in <var>,\n"
|
||||
"arguments are saved in OPTARG.\n";
|
||||
"arguments are saved in OPTARG. After this command additional nonopts\n"
|
||||
"can be accessed starting from $1\n";
|
||||
|
||||
BAREBOX_CMD_START(getopt)
|
||||
.cmd = do_getopt,
|
||||
|
|
|
@ -1,5 +1,38 @@
|
|||
#!/bin/sh
|
||||
|
||||
verbose=
|
||||
dryrun=
|
||||
|
||||
usage="
|
||||
$0 [OPTIONS] [source]\n
|
||||
-v verbose\n
|
||||
-d dryrun\n
|
||||
-l list boot sources\n
|
||||
-h help"
|
||||
|
||||
for i in /env/boot/*; do
|
||||
basename $i s
|
||||
sources="$sources$s "
|
||||
done
|
||||
|
||||
while getopt "vdhl" opt; do
|
||||
if [ ${opt} = v ]; then
|
||||
if [ -n "$verbose" ]; then
|
||||
verbose="-v -v"
|
||||
else
|
||||
verbose="-v"
|
||||
fi
|
||||
elif [ ${opt} = d ]; then
|
||||
dryrun=1
|
||||
elif [ ${opt} = l ]; then
|
||||
echo -e "boot sources:\n$sources"
|
||||
exit 0
|
||||
elif [ ${opt} = h ]; then
|
||||
echo -e "$usage"
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $# = 0 ]; then
|
||||
scr="$global.boot.default"
|
||||
else
|
||||
|
@ -8,11 +41,14 @@ fi
|
|||
|
||||
if [ -n "$scr" ]; then
|
||||
if [ ! -f /env/boot/$scr ]; then
|
||||
echo -e "/env/boot/$scr does not exist.\nValid choices:"
|
||||
ls /env/boot
|
||||
echo -e "/env/boot/$scr does not exist.Valid choices:\n$sources"
|
||||
exit
|
||||
fi
|
||||
/env/boot/$scr
|
||||
fi
|
||||
|
||||
bootm
|
||||
if [ -n "$dryrun" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
bootm $verbose
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
#!/bin/sh
|
||||
|
||||
usage="$0 [OPTIONS]\n -p <partition>\n -t <fstype>"
|
||||
|
||||
while getopt "p:t:h" opt; do
|
||||
if [ ${opt} = p ]; then
|
||||
part=${OPTARG}
|
||||
elif [ ${opt} = t ]; then
|
||||
fstype=${OPTARG}
|
||||
elif [ ${opt} = h ]; then
|
||||
echo -e "$usage"
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -z "${part}" ]; then
|
||||
echo "$0: no partition given"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "${fstype}" ]; then
|
||||
echo "$0: no filesystem type given"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
global.linux.bootargs.root="root=/dev/$part rootfstype=$fstype rootwait"
|
|
@ -2,9 +2,14 @@
|
|||
|
||||
rdinit="/sbin/init"
|
||||
|
||||
while getopt "i:" opt; do
|
||||
usage="$0 [OPTIONS]\n -i <rdinitpath> (/sbin/init)"
|
||||
|
||||
while getopt "i:h" opt; do
|
||||
if [ ${opt} = i ]; then
|
||||
rdinit=${OPTARG}
|
||||
elif [ ${opt} = h ]; then
|
||||
echo -e "$usage"
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
|
||||
|
|
|
@ -1,9 +1,21 @@
|
|||
#!/bin/sh
|
||||
|
||||
while getopt "m:" opt; do
|
||||
mtd=
|
||||
|
||||
usage="$0 [OPTIONS]\n -m <mtd>"
|
||||
|
||||
while getopt "m:h" opt; do
|
||||
if [ ${opt} = m ]; then
|
||||
mtd=${OPTARG}
|
||||
elif [ ${opt} = h ]; then
|
||||
echo -e "$usage"
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -z "$mtd" ]; then
|
||||
echo -e "$usage"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
global.linux.bootargs.root="root=$mtd rootfstype=jffs2"
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
#!/bin/sh
|
||||
|
||||
while getopt "n:s:" opt; do
|
||||
usage="$0 [OPTIONS]\n -n <nfspath>\n -s <serverip>"
|
||||
|
||||
while getopt "n:s:h" opt; do
|
||||
if [ ${opt} = n ]; then
|
||||
nfsroot=${OPTARG}
|
||||
elif [ ${opt} = s ]; then
|
||||
serverip=${OPTARG}
|
||||
elif [ ${opt} = h ]; then
|
||||
echo -e "$usage"
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
|
||||
|
|
|
@ -1,13 +1,24 @@
|
|||
#!/bin/sh
|
||||
|
||||
ubiroot=root
|
||||
mtd=
|
||||
|
||||
while getopt "m:r:" opt; do
|
||||
usage="$0 [OPTIONS]\n -r <ubiroot> (root)\n -m <mtd>"
|
||||
|
||||
while getopt "m:r:h" opt; do
|
||||
if [ ${opt} = r ]; then
|
||||
ubiroot=${OPTARG}
|
||||
elif [ ${opt} = m ]; then
|
||||
mtd=${OPTARG}
|
||||
elif [ ${opt} = h ]; then
|
||||
echo -e "$usage"
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -z "$mtd" ]; then
|
||||
echo -e "$usage"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
global.linux.bootargs.root="root=ubi0:$ubiroot ubi.mtd=$mtd rootfstype=ubifs"
|
||||
|
|
Loading…
Reference in New Issue