lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 8 May 2009 23:33:58 +0200
From:	Sam Ravnborg <sam@...nborg.org>
To:	"H. Peter Anvin" <hpa@...or.com>
Cc:	"H. Peter Anvin" <hpa@...ux.intel.com>,
	linux-kernel@...r.kernel.org, vgoyal@...hat.com, hbabu@...ibm.com,
	kexec@...ts.infradead.org, ying.huang@...el.com, mingo@...e.hu,
	tglx@...utronix.de, ebiederm@...ssion.com
Subject: Re: [PATCH 05/14] kbuild: allow compressors (gzip, bzip2, lzma) to take multiple inputs

On Fri, May 08, 2009 at 01:49:57PM -0700, H. Peter Anvin wrote:
> Sam Ravnborg wrote:
> >
> >I did a quick attempt to integrate it in the Makefile - not pretty.
> >So I dropped that idea.
> >
> >It is mainly that we should not fill up scripts/ with small
> >undocumented scripts.
> >
> >Could you add something like this in the top of the file:
> >
> ># Find the sum of the size of all files specified and
> ># output the size as an escaped hex string.
> >#
> ># Sample:
> ># $ ls -l foo
> ># $ -rw-rw-r-- 1 xxx xxx 146 May  8 22:28 foo
> ># $ bin_size foo
> ># $ \\x92\\x00\\x00\\x00
> ># 146 equals 92 hex
> >
> 
> OK, I see your point (especially since that's not what it does.)
> 
> To be honest, how ugly would it be to get a C program in here?  Doing 
> this in shell is horrid, and people tend to whine about Perl (which is 
> perfect for this kind of job.)

Lets just include it in the Makefile and be done with it.
I took our patch and ended up with this - untested - patch.

If you are OK with this you can add my:
Acked-by: Sam Ravnborg <sam@...nborg.org>


I forgot to delete bin_size - it is no longer needed...

	Sam


diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index cba61ca..827ebf6 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -188,20 +188,34 @@ cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@
 # ---------------------------------------------------------------------------
 
 quiet_cmd_gzip = GZIP    $@
-cmd_gzip = gzip -f -9 < $< > $@
+cmd_gzip = (cat $(filter-out FORCE,$^) | gzip -f -9 > $@) || \
+	(rm -f $@ ; false)
 
 
 # Bzip2
 # ---------------------------------------------------------------------------
 
 # Bzip2 does not include size in file... so we have to fake that
-size_append=$(CONFIG_SHELL) $(srctree)/scripts/bin_size
+size_append = $(shell                                             \
+dec_size=0;                                                       \
+for F in $1; do                                                   \
+	fsize=$$(stat -c "%s" $$F);                               \
+	dec_size=$$(expr $$dec_size + $$fsize);                   \
+done;                                                             \
+hex=$$(printf "%08x" $$dec_size |                                 \
+sed 's/\(..\)\(..\)\(..\)\(..\)/\\\\x\4\\\\x\3\\\\x\2\\\\x\1/g'); \
+echo -ne $$hex                                                    \
+)
 
 quiet_cmd_bzip2 = BZIP2    $@
-cmd_bzip2 = (bzip2 -9 < $< && $(size_append) $<) > $@ || (rm -f $@ ; false)
+cmd_bzip2 = (cat $(filter-out FORCE,$^) | \
+	bzip2 -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \
+	(rm -f $@ ; false)
 
 # Lzma
 # ---------------------------------------------------------------------------
 
 quiet_cmd_lzma = LZMA    $@
-cmd_lzma = (lzma -9 -c $< && $(size_append) $<) >$@ || (rm -f $@ ; false)
+cmd_lzma = (cat $(filter-out FORCE,$^) | \
+	lzma -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \
+	(rm -f $@ ; false)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ