tools/libacpi: fix sed usage
PATCH v2 1/1 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).
---
Cc: Boris Ostrovsky <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Wei Liu <[email protected]>
---
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(-)
tools/libacpi/Makefile +9 -4
@@ -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}' $< > [email protected].$(TMP_SUFFIX) # Strip license comment - sed -i '1,/\*\//{/\/\*/,/\*\//d}' $@.$(TMP_SUFFIX) + sed '1,/\*\//d' [email protected].$(TMP_SUFFIX) > $@.$(TMP_SUFFIX) + rm -f [email protected].$(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}' $< > [email protected].$(TMP_SUFFIX) + # Strip license comment + sed '1,/\*\//d' [email protected].$(TMP_SUFFIX) > $@.$(TMP_SUFFIX) + rm -f [email protected].$(TMP_SUFFIX) $(SHELL) gpl/mk_dsdt_gpl.sh >> $@.$(TMP_SUFFIX) cat dsdt_acpi_info.asl >> $@.$(TMP_SUFFIX) $(MK_DSDT) --debug=$(debug) --maxcpu $* >> $@.$(TMP_SUFFIX)
Signature · 7 lines
2.7.4 (Apple Git-66) _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Quoted 8 lines · Roger Pau Monne
Current usage of sed in the libacpi
Makefilemake 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".
Quoted 5 lines
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é <[email protected]>
Quoted 47 lines
---
Cc: Boris Ostrovsky <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Wei Liu <[email protected]>
---
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(-)tools/libacpi/Makefile +9
-4@@ -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}' $< > [email protected].$(TMP_SUFFIX) # Strip license comment - sed -i '1,/\*\//{/\/\*/,/\*\//d}' $@.$(TMP_SUFFIX) + sed '1,/\*\//d' [email protected].$(TMP_SUFFIX) > $@.$(TMP_SUFFIX) + rm -f [email protected].$(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}' $< > [email protected].$(TMP_SUFFIX) + # Strip license comment + sed '1,/\*\//d' [email protected].$(TMP_SUFFIX) > $@.$(TMP_SUFFIX) + rm -f [email protected].$(TMP_SUFFIX) $(SHELL) gpl/mk_dsdt_gpl.sh >> $@.$(TMP_SUFFIX) cat dsdt_acpi_info.asl >> $@.$(TMP_SUFFIX) $(MK_DSDT) --debug=$(debug) --maxcpu $* >> $@.$(TMP_SUFFIX)Signature · 1 line
2.7.4 (Apple Git-66)
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Wei Liu
AppliedQuoted 9 lines · Wei Liu
Quoted 8 lines · Roger Pau Monne
Current usage of sed in the libacpi
Makefilemake 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".
Quoted 7 lines
Quoted 5 lines
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é <[email protected]>Acked-by Wei Liu <[email protected]>
Applied.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Roger Pau Monne writes ("[PATCH v2 for-4.8] tools/libacpi: fix sed usage"):
Quoted 11 lines
Current usage of sed in the libacpi
Makefilemake 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).
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel