Re: [PATCH 1/4] x86, build: Fact out fdimage/isoimage generation commands to standalone script

2017-11-05 Thread Du, Changbin
On Sun, Nov 05, 2017 at 10:32:08AM +0100, Ingo Molnar wrote:
> 
> A few spelling fixes:
> 
> in the title:
> 
> s/Fact out
>  /Factor out
> 
> * changbin...@intel.com  wrote:
> 
> > From: Changbin Du 
> > 
> > The build message for fdimage/isoimage are pretty unstructured. The raw
> > shell command blocks are printed. We can improve them as regular build
> > system messages. Besides, writing commands in shell script is much more
> > easier than in a Makefile.
> 
> s/much more easier
>  /much more easy
> 
> > 
> > See Ingo's suggestion here https://lkml.org/lkml/2017/10/31/124.
> > 
> > This patch fact out the commands used for fdimage/isoimage generation from
> > arch/x86/boot/Makefile to new script arch/x86/boot/genimage.sh. Then add a
> > new kbuild command 'genimage' which invokes the new script. All
> > fdimages/isoimage now is generated by call to 'genimage' with different
> > parameters.
> 
> s/fact out
>  /factors out
> 
> s/to new script
>   to a new script
> 
> s/Then add
>  /Then it adds
> 
> s/a new kbuild command 'genimage'
>  /the new 'genimage' kbuild command
> 
> s/All fdimages/isoimage now is generated by call to
>  /All fdimage/isoimage files are now generated by a call to
> 
Sorry for these grammar errors. I alwyas forgot to write complete sentences in
English. :)

> > +#   $3 - kernel bzImage file
> > +#   $4 - mtool configuration file
> > +#   $5 - kernel cmdline
> > +#   $6 - inird image file
> > +#
> 
> The new script is much easier to read!
> 
> Thanks,
> 
>   Ingo

-- 
Thanks,
Changbin Du


signature.asc
Description: PGP signature


Re: [PATCH 1/4] x86, build: Fact out fdimage/isoimage generation commands to standalone script

2017-11-05 Thread Du, Changbin
On Sun, Nov 05, 2017 at 10:32:08AM +0100, Ingo Molnar wrote:
> 
> A few spelling fixes:
> 
> in the title:
> 
> s/Fact out
>  /Factor out
> 
> * changbin...@intel.com  wrote:
> 
> > From: Changbin Du 
> > 
> > The build message for fdimage/isoimage are pretty unstructured. The raw
> > shell command blocks are printed. We can improve them as regular build
> > system messages. Besides, writing commands in shell script is much more
> > easier than in a Makefile.
> 
> s/much more easier
>  /much more easy
> 
> > 
> > See Ingo's suggestion here https://lkml.org/lkml/2017/10/31/124.
> > 
> > This patch fact out the commands used for fdimage/isoimage generation from
> > arch/x86/boot/Makefile to new script arch/x86/boot/genimage.sh. Then add a
> > new kbuild command 'genimage' which invokes the new script. All
> > fdimages/isoimage now is generated by call to 'genimage' with different
> > parameters.
> 
> s/fact out
>  /factors out
> 
> s/to new script
>   to a new script
> 
> s/Then add
>  /Then it adds
> 
> s/a new kbuild command 'genimage'
>  /the new 'genimage' kbuild command
> 
> s/All fdimages/isoimage now is generated by call to
>  /All fdimage/isoimage files are now generated by a call to
> 
Sorry for these grammar errors. I alwyas forgot to write complete sentences in
English. :)

> > +#   $3 - kernel bzImage file
> > +#   $4 - mtool configuration file
> > +#   $5 - kernel cmdline
> > +#   $6 - inird image file
> > +#
> 
> The new script is much easier to read!
> 
> Thanks,
> 
>   Ingo

-- 
Thanks,
Changbin Du


signature.asc
Description: PGP signature


Re: [PATCH 1/4] x86, build: Fact out fdimage/isoimage generation commands to standalone script

2017-11-05 Thread Ingo Molnar

A few spelling fixes:

in the title:

s/Fact out
 /Factor out

* changbin...@intel.com  wrote:

> From: Changbin Du 
> 
> The build message for fdimage/isoimage are pretty unstructured. The raw
> shell command blocks are printed. We can improve them as regular build
> system messages. Besides, writing commands in shell script is much more
> easier than in a Makefile.

s/much more easier
 /much more easy

> 
> See Ingo's suggestion here https://lkml.org/lkml/2017/10/31/124.
> 
> This patch fact out the commands used for fdimage/isoimage generation from
> arch/x86/boot/Makefile to new script arch/x86/boot/genimage.sh. Then add a
> new kbuild command 'genimage' which invokes the new script. All
> fdimages/isoimage now is generated by call to 'genimage' with different
> parameters.

s/fact out
 /factors out

s/to new script
  to a new script

s/Then add
 /Then it adds

s/a new kbuild command 'genimage'
 /the new 'genimage' kbuild command

s/All fdimages/isoimage now is generated by call to
 /All fdimage/isoimage files are now generated by a call to

> +#   $3 - kernel bzImage file
> +#   $4 - mtool configuration file
> +#   $5 - kernel cmdline
> +#   $6 - inird image file
> +#

The new script is much easier to read!

Thanks,

Ingo


Re: [PATCH 1/4] x86, build: Fact out fdimage/isoimage generation commands to standalone script

2017-11-05 Thread Ingo Molnar

A few spelling fixes:

in the title:

s/Fact out
 /Factor out

* changbin...@intel.com  wrote:

> From: Changbin Du 
> 
> The build message for fdimage/isoimage are pretty unstructured. The raw
> shell command blocks are printed. We can improve them as regular build
> system messages. Besides, writing commands in shell script is much more
> easier than in a Makefile.

s/much more easier
 /much more easy

> 
> See Ingo's suggestion here https://lkml.org/lkml/2017/10/31/124.
> 
> This patch fact out the commands used for fdimage/isoimage generation from
> arch/x86/boot/Makefile to new script arch/x86/boot/genimage.sh. Then add a
> new kbuild command 'genimage' which invokes the new script. All
> fdimages/isoimage now is generated by call to 'genimage' with different
> parameters.

s/fact out
 /factors out

s/to new script
  to a new script

s/Then add
 /Then it adds

s/a new kbuild command 'genimage'
 /the new 'genimage' kbuild command

s/All fdimages/isoimage now is generated by call to
 /All fdimage/isoimage files are now generated by a call to

> +#   $3 - kernel bzImage file
> +#   $4 - mtool configuration file
> +#   $5 - kernel cmdline
> +#   $6 - inird image file
> +#

The new script is much easier to read!

Thanks,

Ingo


[PATCH 1/4] x86, build: Fact out fdimage/isoimage generation commands to standalone script

2017-11-05 Thread changbin . du
From: Changbin Du 

The build message for fdimage/isoimage are pretty unstructured. The raw
shell command blocks are printed. We can improve them as regular build
system messages. Besides, writing commands in shell script is much more
easier than in a Makefile.

See Ingo's suggestion here https://lkml.org/lkml/2017/10/31/124.

This patch fact out the commands used for fdimage/isoimage generation from
arch/x86/boot/Makefile to new script arch/x86/boot/genimage.sh. Then add a
new kbuild command 'genimage' which invokes the new script. All
fdimages/isoimage now is generated by call to 'genimage' with different
parameters.

Now 'make isoimage' becomes:
...
Kernel: arch/x86/boot/bzImage is ready  (#30)
  GENIMAGE arch/x86/boot/image.iso
Size of boot image is 4 sectors -> No emulation
 15.37% done, estimate finish Sun Nov  5 23:36:57 2017
 30.68% done, estimate finish Sun Nov  5 23:36:57 2017
 46.04% done, estimate finish Sun Nov  5 23:36:57 2017
 61.35% done, estimate finish Sun Nov  5 23:36:57 2017
 76.69% done, estimate finish Sun Nov  5 23:36:57 2017
 92.00% done, estimate finish Sun Nov  5 23:36:57 2017
Total translation table size: 2048
Total rockridge attributes bytes: 659
Total directory bytes: 0
Path table size(bytes): 10
Max brk space used 0
32608 extents written (63 MB)
Kernel: arch/x86/boot/image.iso is ready

Before:
Kernel: arch/x86/boot/bzImage is ready  (#63)
rm -rf arch/x86/boot/isoimage
mkdir arch/x86/boot/isoimage
for i in lib lib64 share end ; do \
if [ -f /usr/$i/syslinux/isolinux.bin ] ; then \
cp /usr/$i/syslinux/isolinux.bin arch/x86/boot/isoimage ; \
if [ -f /usr/$i/syslinux/ldlinux.c32 ]; then \
cp /usr/$i/syslinux/ldlinux.c32 arch/x86/boot/isoimage 
; \
fi ; \
break ; \
fi ; \
if [ $i = end ] ; then exit 1 ; fi ; \
done
...

Suggested-by: Ingo Molnar 
Signed-off-by: Changbin Du 
Cc: Masahiro Yamada 
---
 arch/x86/boot/Makefile|  59 +-
 arch/x86/boot/genimage.sh | 105 ++
 2 files changed, 116 insertions(+), 48 deletions(-)
 create mode 100644 arch/x86/boot/genimage.sh

diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
index d88a2fd..9b5adae 100644
--- a/arch/x86/boot/Makefile
+++ b/arch/x86/boot/Makefile
@@ -123,63 +123,26 @@ image_cmdline = default linux $(FDARGS) $(if 
$(FDINITRD),initrd=initrd.img,)
 $(obj)/mtools.conf: $(src)/mtools.conf.in
sed -e 's|@OBJ@|$(obj)|g' < $< > $@
 
+quiet_cmd_genimage = GENIMAGE $3
+cmd_genimage = sh $(srctree)/$(src)/genimage.sh $2 $3 $(obj)/bzImage \
+   $(obj)/mtools.conf '$(image_cmdline)' $(FDINITRD)
+
 # This requires write access to /dev/fd0
 bzdisk: $(obj)/bzImage $(obj)/mtools.conf
-   MTOOLSRC=$(obj)/mtools.conf mformat a:  ; sync
-   syslinux /dev/fd0   ; sync
-   echo '$(image_cmdline)' | \
-   MTOOLSRC=$(src)/mtools.conf mcopy - a:syslinux.cfg
-   if [ -f '$(FDINITRD)' ] ; then \
-   MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' a:initrd.img ; \
-   fi
-   MTOOLSRC=$(obj)/mtools.conf mcopy $(obj)/bzImage a:linux; sync
+   $(call cmd,genimage,bzdisk,/dev/fd0)
 
 # These require being root or having syslinux 2.02 or higher installed
 fdimage fdimage144: $(obj)/bzImage $(obj)/mtools.conf
-   dd if=/dev/zero of=$(obj)/fdimage bs=1024 count=1440
-   MTOOLSRC=$(obj)/mtools.conf mformat v:  ; sync
-   syslinux $(obj)/fdimage ; sync
-   echo '$(image_cmdline)' | \
-   MTOOLSRC=$(obj)/mtools.conf mcopy - v:syslinux.cfg
-   if [ -f '$(FDINITRD)' ] ; then \
-   MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' v:initrd.img ; \
-   fi
-   MTOOLSRC=$(obj)/mtools.conf mcopy $(obj)/bzImage v:linux; sync
+   $(call cmd,genimage,fdimage144,$(obj)/fdimage)
+   @$(kecho) 'Kernel: $(obj)/fdimage is ready'
 
 fdimage288: $(obj)/bzImage $(obj)/mtools.conf
-   dd if=/dev/zero of=$(obj)/fdimage bs=1024 count=2880
-   MTOOLSRC=$(obj)/mtools.conf mformat w:  ; sync
-   syslinux $(obj)/fdimage ; sync
-   echo '$(image_cmdline)' | \
-   MTOOLSRC=$(obj)/mtools.conf mcopy - w:syslinux.cfg
-   if [ -f '$(FDINITRD)' ] ; then \
-   MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' w:initrd.img ; \
-   fi
-   MTOOLSRC=$(obj)/mtools.conf mcopy $(obj)/bzImage w:linux; sync
+   $(call cmd,genimage,fdimage288,$(obj)/fdimage)
+   @$(kecho) 'Kernel: $(obj)/fdimage is ready'
 
 isoimage: $(obj)/bzImage
-   -rm -rf $(obj)/isoimage
-   mkdir $(obj)/isoimage
-   for i in lib lib64 share end ; do \
-   if [ -f 

[PATCH 1/4] x86, build: Fact out fdimage/isoimage generation commands to standalone script

2017-11-05 Thread changbin . du
From: Changbin Du 

The build message for fdimage/isoimage are pretty unstructured. The raw
shell command blocks are printed. We can improve them as regular build
system messages. Besides, writing commands in shell script is much more
easier than in a Makefile.

See Ingo's suggestion here https://lkml.org/lkml/2017/10/31/124.

This patch fact out the commands used for fdimage/isoimage generation from
arch/x86/boot/Makefile to new script arch/x86/boot/genimage.sh. Then add a
new kbuild command 'genimage' which invokes the new script. All
fdimages/isoimage now is generated by call to 'genimage' with different
parameters.

Now 'make isoimage' becomes:
...
Kernel: arch/x86/boot/bzImage is ready  (#30)
  GENIMAGE arch/x86/boot/image.iso
Size of boot image is 4 sectors -> No emulation
 15.37% done, estimate finish Sun Nov  5 23:36:57 2017
 30.68% done, estimate finish Sun Nov  5 23:36:57 2017
 46.04% done, estimate finish Sun Nov  5 23:36:57 2017
 61.35% done, estimate finish Sun Nov  5 23:36:57 2017
 76.69% done, estimate finish Sun Nov  5 23:36:57 2017
 92.00% done, estimate finish Sun Nov  5 23:36:57 2017
Total translation table size: 2048
Total rockridge attributes bytes: 659
Total directory bytes: 0
Path table size(bytes): 10
Max brk space used 0
32608 extents written (63 MB)
Kernel: arch/x86/boot/image.iso is ready

Before:
Kernel: arch/x86/boot/bzImage is ready  (#63)
rm -rf arch/x86/boot/isoimage
mkdir arch/x86/boot/isoimage
for i in lib lib64 share end ; do \
if [ -f /usr/$i/syslinux/isolinux.bin ] ; then \
cp /usr/$i/syslinux/isolinux.bin arch/x86/boot/isoimage ; \
if [ -f /usr/$i/syslinux/ldlinux.c32 ]; then \
cp /usr/$i/syslinux/ldlinux.c32 arch/x86/boot/isoimage 
; \
fi ; \
break ; \
fi ; \
if [ $i = end ] ; then exit 1 ; fi ; \
done
...

Suggested-by: Ingo Molnar 
Signed-off-by: Changbin Du 
Cc: Masahiro Yamada 
---
 arch/x86/boot/Makefile|  59 +-
 arch/x86/boot/genimage.sh | 105 ++
 2 files changed, 116 insertions(+), 48 deletions(-)
 create mode 100644 arch/x86/boot/genimage.sh

diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
index d88a2fd..9b5adae 100644
--- a/arch/x86/boot/Makefile
+++ b/arch/x86/boot/Makefile
@@ -123,63 +123,26 @@ image_cmdline = default linux $(FDARGS) $(if 
$(FDINITRD),initrd=initrd.img,)
 $(obj)/mtools.conf: $(src)/mtools.conf.in
sed -e 's|@OBJ@|$(obj)|g' < $< > $@
 
+quiet_cmd_genimage = GENIMAGE $3
+cmd_genimage = sh $(srctree)/$(src)/genimage.sh $2 $3 $(obj)/bzImage \
+   $(obj)/mtools.conf '$(image_cmdline)' $(FDINITRD)
+
 # This requires write access to /dev/fd0
 bzdisk: $(obj)/bzImage $(obj)/mtools.conf
-   MTOOLSRC=$(obj)/mtools.conf mformat a:  ; sync
-   syslinux /dev/fd0   ; sync
-   echo '$(image_cmdline)' | \
-   MTOOLSRC=$(src)/mtools.conf mcopy - a:syslinux.cfg
-   if [ -f '$(FDINITRD)' ] ; then \
-   MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' a:initrd.img ; \
-   fi
-   MTOOLSRC=$(obj)/mtools.conf mcopy $(obj)/bzImage a:linux; sync
+   $(call cmd,genimage,bzdisk,/dev/fd0)
 
 # These require being root or having syslinux 2.02 or higher installed
 fdimage fdimage144: $(obj)/bzImage $(obj)/mtools.conf
-   dd if=/dev/zero of=$(obj)/fdimage bs=1024 count=1440
-   MTOOLSRC=$(obj)/mtools.conf mformat v:  ; sync
-   syslinux $(obj)/fdimage ; sync
-   echo '$(image_cmdline)' | \
-   MTOOLSRC=$(obj)/mtools.conf mcopy - v:syslinux.cfg
-   if [ -f '$(FDINITRD)' ] ; then \
-   MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' v:initrd.img ; \
-   fi
-   MTOOLSRC=$(obj)/mtools.conf mcopy $(obj)/bzImage v:linux; sync
+   $(call cmd,genimage,fdimage144,$(obj)/fdimage)
+   @$(kecho) 'Kernel: $(obj)/fdimage is ready'
 
 fdimage288: $(obj)/bzImage $(obj)/mtools.conf
-   dd if=/dev/zero of=$(obj)/fdimage bs=1024 count=2880
-   MTOOLSRC=$(obj)/mtools.conf mformat w:  ; sync
-   syslinux $(obj)/fdimage ; sync
-   echo '$(image_cmdline)' | \
-   MTOOLSRC=$(obj)/mtools.conf mcopy - w:syslinux.cfg
-   if [ -f '$(FDINITRD)' ] ; then \
-   MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' w:initrd.img ; \
-   fi
-   MTOOLSRC=$(obj)/mtools.conf mcopy $(obj)/bzImage w:linux; sync
+   $(call cmd,genimage,fdimage288,$(obj)/fdimage)
+   @$(kecho) 'Kernel: $(obj)/fdimage is ready'
 
 isoimage: $(obj)/bzImage
-   -rm -rf $(obj)/isoimage
-   mkdir $(obj)/isoimage
-   for i in lib lib64 share end ; do \
-   if [ -f /usr/$$i/syslinux/isolinux.bin ] ; then \
-   cp