All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 for-4.8] tools/libacpi: fix sed usage
@ 2016-10-31 10:05 Roger Pau Monne
  2016-10-31 10:29 ` Wei Liu
  2016-10-31 11:43 ` Ian Jackson
  0 siblings, 2 replies; 4+ messages in thread
From: Roger Pau Monne @ 2016-10-31 10:05 UTC (permalink / raw)
  To: xen-devel
  Cc: Wei Liu, Boris Ostrovsky, Ian Jackson, Jan Beulich,
	Roger Pau Monne

Current usage of sed in the libacpi Makefile make uses of non-POSIX options,
that are not available on all the OSes supported by the Xen tools.

The '-i' option has slightly different semantics between GNU and BSD sed
implementations, while on the GNU version the suffix is optional, on the BSD
one it is not. Also BSD sed seems to have problems parsing the script
itself, reporting "extra characters at the end of d command".

Fix those issues by using a temporary intermediate file, and replace the
script with a simpler version that achieves the same purpose (removing the
initial license header comment).

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>
---
Changes since v1:
 - Don't pipe awk output into sed, in order to prevent losing error status.
---
 tools/libacpi/Makefile | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/tools/libacpi/Makefile b/tools/libacpi/Makefile
index 18a5cd4..b79db47 100644
--- a/tools/libacpi/Makefile
+++ b/tools/libacpi/Makefile
@@ -47,9 +47,11 @@ $(MK_DSDT): mk_dsdt.c
 
 ifeq ($(GPL),y)
 $(ACPI_BUILD_DIR)/dsdt_anycpu_qemu_xen.asl: dsdt.asl dsdt_acpi_info.asl gpl/mk_dsdt_gpl.sh $(MK_DSDT)
-	awk 'NR > 1 {print s} {s=$$0}' $< > $@.$(TMP_SUFFIX)
+	# Remove last bracket
+	awk 'NR > 1 {print s} {s=$$0}' $< > $@.1.$(TMP_SUFFIX)
 	# Strip license comment
-	sed -i '1,/\*\//{/\/\*/,/\*\//d}' $@.$(TMP_SUFFIX)
+	sed '1,/\*\//d' $@.1.$(TMP_SUFFIX) > $@.$(TMP_SUFFIX)
+	rm -f $@.1.$(TMP_SUFFIX)
 	$(SHELL) gpl/mk_dsdt_gpl.sh >> $@.$(TMP_SUFFIX)
 	cat dsdt_acpi_info.asl >> $@.$(TMP_SUFFIX)
 	$(MK_DSDT) --debug=$(debug) --dm-version qemu-xen >> $@.$(TMP_SUFFIX)
@@ -57,8 +59,11 @@ $(ACPI_BUILD_DIR)/dsdt_anycpu_qemu_xen.asl: dsdt.asl dsdt_acpi_info.asl gpl/mk_d
 
 # NB. awk invocation is a portable alternative to 'head -n -1'
 $(ACPI_BUILD_DIR)/dsdt_%cpu.asl: dsdt.asl dsdt_acpi_info.asl gpl/mk_dsdt_gpl.sh $(MK_DSDT)
-	awk 'NR > 1 {print s} {s=$$0}' $< > $@.$(TMP_SUFFIX)
-	sed -i '1,/\*\//{/\/\*/,/\*\//d}' $@.$(TMP_SUFFIX)
+	# Remove last bracket
+	awk 'NR > 1 {print s} {s=$$0}' $< > $@.1.$(TMP_SUFFIX)
+	# Strip license comment
+	sed '1,/\*\//d' $@.1.$(TMP_SUFFIX) > $@.$(TMP_SUFFIX)
+	rm -f $@.1.$(TMP_SUFFIX)
 	$(SHELL) gpl/mk_dsdt_gpl.sh >> $@.$(TMP_SUFFIX)
 	cat dsdt_acpi_info.asl >> $@.$(TMP_SUFFIX)
 	$(MK_DSDT) --debug=$(debug) --maxcpu $*  >> $@.$(TMP_SUFFIX)
-- 
2.7.4 (Apple Git-66)


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 for-4.8] tools/libacpi: fix sed usage
  2016-10-31 10:05 [PATCH v2 for-4.8] tools/libacpi: fix sed usage Roger Pau Monne
@ 2016-10-31 10:29 ` Wei Liu
  2016-10-31 10:53   ` Wei Liu
  2016-10-31 11:43 ` Ian Jackson
  1 sibling, 1 reply; 4+ messages in thread
From: Wei Liu @ 2016-10-31 10:29 UTC (permalink / raw)
  To: Roger Pau Monne
  Cc: xen-devel, Boris Ostrovsky, Ian Jackson, Wei Liu, Jan Beulich

On Mon, Oct 31, 2016 at 11:05:20AM +0100, Roger Pau Monne wrote:
> Current usage of sed in the libacpi Makefile make uses of non-POSIX options,
> that are not available on all the OSes supported by the Xen tools.
> 
> The '-i' option has slightly different semantics between GNU and BSD sed
> implementations, while on the GNU version the suffix is optional, on the BSD
> one it is not. Also BSD sed seems to have problems parsing the script
> itself, reporting "extra characters at the end of d command".
> 
> Fix those issues by using a temporary intermediate file, and replace the
> script with a simpler version that achieves the same purpose (removing the
> initial license header comment).
> 
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>

Acked-by: Wei Liu <wei.liu2@citrix.com>

> ---
> Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
> Cc: Jan Beulich <jbeulich@suse.com>
> Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> Cc: Wei Liu <wei.liu2@citrix.com>
> ---
> Changes since v1:
>  - Don't pipe awk output into sed, in order to prevent losing error status.
> ---
>  tools/libacpi/Makefile | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/libacpi/Makefile b/tools/libacpi/Makefile
> index 18a5cd4..b79db47 100644
> --- a/tools/libacpi/Makefile
> +++ b/tools/libacpi/Makefile
> @@ -47,9 +47,11 @@ $(MK_DSDT): mk_dsdt.c
>  
>  ifeq ($(GPL),y)
>  $(ACPI_BUILD_DIR)/dsdt_anycpu_qemu_xen.asl: dsdt.asl dsdt_acpi_info.asl gpl/mk_dsdt_gpl.sh $(MK_DSDT)
> -	awk 'NR > 1 {print s} {s=$$0}' $< > $@.$(TMP_SUFFIX)
> +	# Remove last bracket
> +	awk 'NR > 1 {print s} {s=$$0}' $< > $@.1.$(TMP_SUFFIX)
>  	# Strip license comment
> -	sed -i '1,/\*\//{/\/\*/,/\*\//d}' $@.$(TMP_SUFFIX)
> +	sed '1,/\*\//d' $@.1.$(TMP_SUFFIX) > $@.$(TMP_SUFFIX)
> +	rm -f $@.1.$(TMP_SUFFIX)
>  	$(SHELL) gpl/mk_dsdt_gpl.sh >> $@.$(TMP_SUFFIX)
>  	cat dsdt_acpi_info.asl >> $@.$(TMP_SUFFIX)
>  	$(MK_DSDT) --debug=$(debug) --dm-version qemu-xen >> $@.$(TMP_SUFFIX)
> @@ -57,8 +59,11 @@ $(ACPI_BUILD_DIR)/dsdt_anycpu_qemu_xen.asl: dsdt.asl dsdt_acpi_info.asl gpl/mk_d
>  
>  # NB. awk invocation is a portable alternative to 'head -n -1'
>  $(ACPI_BUILD_DIR)/dsdt_%cpu.asl: dsdt.asl dsdt_acpi_info.asl gpl/mk_dsdt_gpl.sh $(MK_DSDT)
> -	awk 'NR > 1 {print s} {s=$$0}' $< > $@.$(TMP_SUFFIX)
> -	sed -i '1,/\*\//{/\/\*/,/\*\//d}' $@.$(TMP_SUFFIX)
> +	# Remove last bracket
> +	awk 'NR > 1 {print s} {s=$$0}' $< > $@.1.$(TMP_SUFFIX)
> +	# Strip license comment
> +	sed '1,/\*\//d' $@.1.$(TMP_SUFFIX) > $@.$(TMP_SUFFIX)
> +	rm -f $@.1.$(TMP_SUFFIX)
>  	$(SHELL) gpl/mk_dsdt_gpl.sh >> $@.$(TMP_SUFFIX)
>  	cat dsdt_acpi_info.asl >> $@.$(TMP_SUFFIX)
>  	$(MK_DSDT) --debug=$(debug) --maxcpu $*  >> $@.$(TMP_SUFFIX)
> -- 
> 2.7.4 (Apple Git-66)
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 for-4.8] tools/libacpi: fix sed usage
  2016-10-31 10:29 ` Wei Liu
@ 2016-10-31 10:53   ` Wei Liu
  0 siblings, 0 replies; 4+ messages in thread
From: Wei Liu @ 2016-10-31 10:53 UTC (permalink / raw)
  To: Roger Pau Monne
  Cc: xen-devel, Boris Ostrovsky, Ian Jackson, Wei Liu, Jan Beulich

On Mon, Oct 31, 2016 at 10:29:14AM +0000, Wei Liu wrote:
> On Mon, Oct 31, 2016 at 11:05:20AM +0100, Roger Pau Monne wrote:
> > Current usage of sed in the libacpi Makefile make uses of non-POSIX options,
> > that are not available on all the OSes supported by the Xen tools.
> > 
> > The '-i' option has slightly different semantics between GNU and BSD sed
> > implementations, while on the GNU version the suffix is optional, on the BSD
> > one it is not. Also BSD sed seems to have problems parsing the script
> > itself, reporting "extra characters at the end of d command".
> > 
> > Fix those issues by using a temporary intermediate file, and replace the
> > script with a simpler version that achieves the same purpose (removing the
> > initial license header comment).
> > 
> > Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> 
> Acked-by: Wei Liu <wei.liu2@citrix.com>

Applied.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 for-4.8] tools/libacpi: fix sed usage
  2016-10-31 10:05 [PATCH v2 for-4.8] tools/libacpi: fix sed usage Roger Pau Monne
  2016-10-31 10:29 ` Wei Liu
@ 2016-10-31 11:43 ` Ian Jackson
  1 sibling, 0 replies; 4+ messages in thread
From: Ian Jackson @ 2016-10-31 11:43 UTC (permalink / raw)
  To: Roger Pau Monne; +Cc: xen-devel, Boris Ostrovsky, Wei Liu, Jan Beulich

Roger Pau Monne writes ("[PATCH v2 for-4.8] tools/libacpi: fix sed usage"):
> Current usage of sed in the libacpi Makefile make uses of non-POSIX options,
> that are not available on all the OSes supported by the Xen tools.
> 
> The '-i' option has slightly different semantics between GNU and BSD sed
> implementations, while on the GNU version the suffix is optional, on the BSD
> one it is not. Also BSD sed seems to have problems parsing the script
> itself, reporting "extra characters at the end of d command".
> 
> Fix those issues by using a temporary intermediate file, and replace the
> script with a simpler version that achieves the same purpose (removing the
> initial license header comment).

Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-10-31 11:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-31 10:05 [PATCH v2 for-4.8] tools/libacpi: fix sed usage Roger Pau Monne
2016-10-31 10:29 ` Wei Liu
2016-10-31 10:53   ` Wei Liu
2016-10-31 11:43 ` Ian Jackson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.