Message ID | 20210829173210.39562-2-thuth@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Use meson_options.txt in the configure script | expand |
On Sun, Aug 29, 2021 at 07:32:08PM +0200, Thomas Huth wrote: > To avoid double maintenance between the configure script and > meson_options.txt, add some simple logic in the configure script > to read the options from meson_options.txt. > > Signed-off-by: Thomas Huth <thuth@redhat.com> > --- > configure | 24 +++++++++++++++++++++++- > 1 file changed, 23 insertions(+), 1 deletion(-) > > diff --git a/configure b/configure > index 9a79a004d7..b3e6d51916 100755 > --- a/configure > +++ b/configure > @@ -836,6 +836,8 @@ fi > > werror="" > > +meson_options="" > + > for opt do > optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') > case "$opt" in > @@ -1581,6 +1583,26 @@ for opt do > ;; > --disable-slirp-smbd) slirp_smbd=no > ;; > + --enable-*) > + arg=$(echo "$opt" | sed -e "s/--enable-//" -e "s/-/_/g") configure is a /bin/sh script, which means that using echo on user-supplied arguments is unsafe (a malicious user may provide a backslash, which not all 'echo' implementations treat the same across different sh implementations). What's more, $opt starts with "--enable", and 'echo --enable' may trigger echo to try and warn about an unknown option. To be portable, you want: arg=$(printf %s\\n "$opt" | sed...) > + if ! grep -q "option('$arg', type[ ]*: 'feature'" \ > + $source_path/meson_options.txt; then > + echo "ERROR: unknown option $opt" > + echo "Try '$0 --help' for more information" > + exit 1 > + fi > + meson_options="$meson_options -D$arg=enabled" > + ;; > + --disable-*) > + arg=$(echo "$opt" | sed -e "s/--disable-//" -e "s/-/_/g") And again. > + if ! grep -q "option('$arg', type[ ]*: 'feature'" \ > + $source_path/meson_options.txt; then > + echo "ERROR: unknown option $opt" > + echo "Try '$0 --help' for more information" > + exit 1 > + fi > + meson_options="$meson_options -D$arg=disabled" > + ;; > *) > echo "ERROR: unknown option $opt" > echo "Try '$0 --help' for more information" > @@ -5211,7 +5233,7 @@ if test "$skip_meson" = no; then > -Dvhost_user_blk_server=$vhost_user_blk_server -Dmultiprocess=$multiprocess \ > -Dfuse=$fuse -Dfuse_lseek=$fuse_lseek -Dguest_agent_msi=$guest_agent_msi -Dbpf=$bpf\ > $(if test "$default_feature" = no; then echo "-Dauto_features=disabled"; fi) \ > - -Dtcg_interpreter=$tcg_interpreter \ > + -Dtcg_interpreter=$tcg_interpreter $meson_options \ > $cross_arg \ > "$PWD" "$source_path" Otherwise looks like a nice idea.
diff --git a/configure b/configure index 9a79a004d7..b3e6d51916 100755 --- a/configure +++ b/configure @@ -836,6 +836,8 @@ fi werror="" +meson_options="" + for opt do optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') case "$opt" in @@ -1581,6 +1583,26 @@ for opt do ;; --disable-slirp-smbd) slirp_smbd=no ;; + --enable-*) + arg=$(echo "$opt" | sed -e "s/--enable-//" -e "s/-/_/g") + if ! grep -q "option('$arg', type[ ]*: 'feature'" \ + $source_path/meson_options.txt; then + echo "ERROR: unknown option $opt" + echo "Try '$0 --help' for more information" + exit 1 + fi + meson_options="$meson_options -D$arg=enabled" + ;; + --disable-*) + arg=$(echo "$opt" | sed -e "s/--disable-//" -e "s/-/_/g") + if ! grep -q "option('$arg', type[ ]*: 'feature'" \ + $source_path/meson_options.txt; then + echo "ERROR: unknown option $opt" + echo "Try '$0 --help' for more information" + exit 1 + fi + meson_options="$meson_options -D$arg=disabled" + ;; *) echo "ERROR: unknown option $opt" echo "Try '$0 --help' for more information" @@ -5211,7 +5233,7 @@ if test "$skip_meson" = no; then -Dvhost_user_blk_server=$vhost_user_blk_server -Dmultiprocess=$multiprocess \ -Dfuse=$fuse -Dfuse_lseek=$fuse_lseek -Dguest_agent_msi=$guest_agent_msi -Dbpf=$bpf\ $(if test "$default_feature" = no; then echo "-Dauto_features=disabled"; fi) \ - -Dtcg_interpreter=$tcg_interpreter \ + -Dtcg_interpreter=$tcg_interpreter $meson_options \ $cross_arg \ "$PWD" "$source_path"
To avoid double maintenance between the configure script and meson_options.txt, add some simple logic in the configure script to read the options from meson_options.txt. Signed-off-by: Thomas Huth <thuth@redhat.com> --- configure | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-)