Hi,
I am wondering if it makes sense to strip whitespace
characters from $(EXTRAVERSION) if they exist.
Especially trailing whitespace can easily be introduced
(and overlooked) by mistake by someone who edits
this value in the Makefile.
This is not only a show stopper when it comes to
?make modules_install? but it may also cause data
loss under certain circumstances. E.g. if you
maintain an - admittedly non-standard - directory
tree named /kernel on your system, this tree will be
deleted when you invoke ?make modules_install? with
trailing whitespace in $(EXTRAVERSION) (and thus
in $(MODLIB) as well):
.PHONY: modules_install
modules_install: _modinst_ $(patsubst %, _modinst_%, $(SUBDIRS))
_modinst_post
.PHONY: _modinst_
_modinst_:
@rm -rf $(MODLIB)/kernel
@rm -f $(MODLIB)/build
@mkdir -p $(MODLIB)/kernel
@ln -s $(TOPDIR) $(MODLIB)/build
Similar arguments may hold true for other macros
as well (like $(VERSION), $(PATCHLEVEL) etc.), but
these are much less likely touched by an ordinary
user who just wants to recompile his kernel.
After all, this is not a big issue, but I would like to
know what others think about it.
Just in case, there is a trivial one-liner against
2.4.25 below to remove whitespace from $(EXTRAVERSION) before it
is used elsewhere. Note that there is a space and a tab
inside the sed braces.
(One could also think about proper quoting to allow whitespace
in $(EXTRAVERSION), but I'm not so sure if whitespace makes
much sense in it, anyway.)
Regards - Juergen Salk
--- Makefile-orig Tue Apr 6 14:13:06 2004
+++ Makefile Tue Apr 6 14:45:29 2004
@@ -3,6 +3,7 @@
SUBLEVEL = 25
EXTRAVERSION =
+EXTRAVERSION:=$(shell echo $(EXTRAVERSION) | sed -e 's/[ ]//g')
KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/)
--
GPG A997BA7A | 87FC DA31 5F00 C885 0DC3 E28F BD0D 4B33 A997 BA7A
Juergen Salk <[email protected]> writes:
> --- Makefile-orig Tue Apr 6 14:13:06 2004
> +++ Makefile Tue Apr 6 14:45:29 2004
> @@ -3,6 +3,7 @@
> SUBLEVEL = 25
> EXTRAVERSION =
>
> +EXTRAVERSION:=$(shell echo $(EXTRAVERSION) | sed -e 's/[ ]//g')
EXTRAVERSION := $(strip $(EXTRAVERSION))
Andreas.
--
Andreas Schwab, SuSE Labs, [email protected]
SuSE Linux AG, Maxfeldstra?e 5, 90409 N?rnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
* Andreas Schwab <[email protected]> [040406 17:56]:
> > +EXTRAVERSION := $(shell echo $(EXTRAVERSION) | sed -e 's/[ ]//g')
^ ^
> EXTRAVERSION := $(strip $(EXTRAVERSION))
Ok. I think this still leaves embedded whitespace (which may also
cause some trouble), but this is much harder to to overlook, if
not introduced intentionally, anyway. ;-)
Regards - Juergen
--
GPG A997BA7A | 87FC DA31 5F00 C885 0DC3 E28F BD0D 4B33 A997 BA7A
Juergen Salk <[email protected]> writes:
> (One could also think about proper quoting to allow whitespace
> in $(EXTRAVERSION), but I'm not so sure if whitespace makes
> much sense in it, anyway.)
Quoting could be a good idea in case the EXTRAVERSION should contain
shell meta-characters. Why anyone would do such a thing is beyond my
imagination, but who knows?
--
M?ns Rullg?rd
[email protected]
* M?ns Rullg?rd <[email protected]> [040406 20:23]:
> good idea in case the EXTRAVERSION should contain shell
> meta-characters. Why anyone would do such a thing is beyond my
> imagination, ...
I concur. But you don't even need meta-characters to mess up the
whole system with a badly or just carelessly formatted
EXTRAVERSION.
Imagine what may happen with something like:
EXTRAVERSION = -foo / # my homebrew -foo kernel
Maybe somewhat far-fetched ...
> ... but who knows?
True.
Best regards - Juergen