[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH] build: make linux download more flexible



Hi,

Here is an updated version of this patch for xen-unstable.hg 9960.
Please consider it for inclusion.

-- 
Horms                                           http://www.vergenet.net/~horms/

build: make linux download more flexible

* Allow LINUX_REPO to specify the URL of the repository for the linux kernel,
  - Defaults is: http://www.kernel.org/pub/linux/kernel/     
* Allow LINUX_REPO to be overridden in the environment
* LINUX_REPO it should be the path, trimmed to give a structure
  equivalent to http://www.kernel.org/pub/linux/kernel/
  - The kernel tarball will be downloaded from
    $(LINUX_REPO)/v$(KERNEL_MAJOR).$(KERNEL_MINOR)/
    e.g. http://www.kernel.org/pub/linux/kernel/v2.6
    Where KERNEL_MAJOR and KERNEL_MINOR are calculated at runtime
  - The path of the tarball can be overridden using LINUX_REPO_KERNEL_PATH 
    in the environment, in which case the tarball will be downloaded from
    $(LINUX_REPO)/v$(LINUX_REPO_KERNEL_PATH)/
  - If needed kernel patches will be downloaded from
    $(LINUX_REPO)/v$(KERNEL_MAJOR).$(KERNEL_MINOR)/snapshots
    if present, else
    $(LINUX_REPO)/v$(KERNEL_MAJOR).$(KERNEL_MINOR)/testing
    This will depend on the version of the patch
  - The path of the tarball can be overridden using LINUX_REPO_KERNEL_PATH 
  in the environment, in which case the patch will be downloaded from
    $(LINUX_REPO)/v$(LINUX_REPO_PATCH_PATH)/
  - The intention of LINUX_REPO_KERNEL_PATH and LINUX_REPO_PATCH_PATH
    is to allow for sites that don't follow the directory hierarchy of
    kernel.org, while simplifying the presumably common case where they do
* Previously KERNEL_REPO had similar properties to LINUX_REPO, but
  it was not as flexible, had a somewhat presumptuous name and could
  not be overridden in the environment. It has been removed
* Allow DOWNLOAD_PATH to set a search path for previously downloaded files
  - Use the first element of the path as the directory to save
    downloaded files
  - Default is LINUX_SRC_PATH if set in environment, else .:..
  - Note that kclean-tarball, makedistlcean-* and friends 
    intentionally only remove tarballs in the top level xen directory,
    regardless of the value of this variable. This is to allow
    more persistent storage of tarballs in a specified location,
    which cam be manually cleaned if desired.
* Fix bug introduced by xen-unstable.hg:9931:39fa9a75d84b whereby
  the downloaded kernel source is not removed on mrproper

Signed-Off-By: Horms <horms@xxxxxxxxxxxx>

 Config.mk                     |   12 ++++++++++-
 Makefile                      |   14 +++++++++++++
 buildconfigs/Rules.mk         |   44 ++++++++++++++++++++++++++++++++---------
 buildconfigs/mk.linux-2.6-xen |    4 ++-
 4 files changed, 63 insertions(+), 11 deletions(-)

--- x/Config.mk
+++ x/Config.mk
@@ -69,7 +69,17 @@ LDFLAGS += $(foreach i, $(EXTRA_LIB), -L
 CFLAGS += $(foreach i, $(EXTRA_INCLUDES), -I$(i))
 
 # Choose the best mirror to download linux kernel
-KERNEL_REPO = http://www.kernel.org
+DOWNLOAD_PATH_DEFAULT := .:..
+LINUX_REPO_DEFAULT    := http://www.kernel.org/pub/linux/kernel/
+ifdef LINUX_SRC_PATH
+DOWNLOAD_PATH  ?= $(LINUX_SRC_PATH) # Compatibility
+else
+DOWNLOAD_PATH  ?= $(DOWNLOAD_PATH_DEFAULT)
+endif
+DOWNLOAD_DIR   := $(firstword $(subst :, ,$(DOWNLOAD_PATH)))
+LINUX_REPO     ?= $(LINUX_REPO_DEFAULT)
+# LINUX_REPO_KERNEL_PATH Set in buildconfigs/Rules.mk, if not in environment
+# LINUX_REPO_PATCH_PATH  Set in buildconfigs/Rules.mk, if not in environment
 
 # If ACM_SECURITY = y, then the access control module is compiled
 # into Xen and the policy type can be set by the boot policy file
--- x/Makefile
+++ x/Makefile
@@ -172,6 +172,20 @@ help:
        @echo '                     install into prefix/lib/python<VERSION>'
        @echo '                     instead of <PREFIX>/lib/python'
        @echo '                     true if set to non-empty value, false 
otherwise'
+       @echo '  LINUX_REPO=URL   - Base URL to download linux kernel from'
+       @echo '                     Default: "$(LINUX_REPO_DEFAULT)"'
+       @echo '  LINUX_REPO_KERNEL_PATH=DIRECTORY'
+       @echo '                   - LINUX_REPO assumes that the URL has the 
same directory'
+       @echo '                     structure as $(LINUX_REPO_DEFAULT)'
+       @echo '                     and the rest of the path to the tarball is 
derived.'
+       @echo '                     If set, override the derivation.'
+       @echo '                     Default: ""'
+       @echo '  LINUX_REPO_PATCHL_PATH=DIRECTORY'
+       @echo '                   - LINUX_REPO assumes that the URL has the 
same directory'
+       @echo '                     structure as $(LINUX_REPO_DEFAULT)'
+       @echo '                     and the rest of the path to the patches is 
derived.'
+       @echo '                     If set, override the derivation.'
+       @echo '                     Default: ""'
 
 # Use this target with extreme care!
 .PHONY: uninstall
--- x/buildconfigs/Rules.mk
+++ x/buildconfigs/Rules.mk
@@ -22,32 +22,58 @@ LINUX_SERIES        ?= 2.6
 LINUX_VER      ?= $(shell grep "^LINUX_VER" buildconfigs/mk.linux-2.6-xen | 
sed -e 's/.*=[ ]*//')
 
 # Setup Linux search path
-LINUX_SRC_PATH ?= .:..
-vpath linux-%.tar.bz2 $(LINUX_SRC_PATH)
-vpath patch-%.bz2 $(LINUX_SRC_PATH)
+vpath linux-%.tar.bz2 $(DOWNLOAD_PATH)
+vpath patch-%.bz2 $(DOWNLOAD_PATH)
 
 # download a pristine Linux kernel tarball if there isn't one in LINUX_SRC_PATH
+ifndef LINUX_REPO_KERNEL_PATH
 linux-%.tar.bz2: override _LINUX_VDIR = $(word 1,$(subst ., ,$*)).$(word 
2,$(subst ., ,$*))
+linux-%.tar.bz2: LINUX_REPO_KERNEL_PATH = v$(_LINUX_VDIR)
+endif
 linux-%.tar.bz2:
        @echo "Cannot find $@ in path $(LINUX_SRC_PATH)"
-       wget $(KERNEL_REPO)/pub/linux/kernel/v$(_LINUX_VDIR)/$@ -O./$@
+       wget $(LINUX_REPO)/$(LINUX_REPO_KERNEL_PATH)/$@ -O$(DOWNLOAD_DIR)/$@ \
+               || { rm -f $(DOWNLOAD_DIR)/$@; false; }
 
+ifndef LINUX_REPO_PATCH_PATH
 patch-%.bz2: override _LINUX_VDIR = $(word 1,$(subst ., ,$(*F))).$(word 
2,$(subst ., ,$(*F)))
 patch-%.bz2: override _LINUX_XDIR = $(if $(word 3,$(subst -, 
,$(*F))),snapshots,testing)
+patch-%.bz2: LINUX_REPO_PATCH_PATH = v$(_LINUX_VDIR)/$(_LINUX_XDIR)
+endif
 patch-%.bz2:
        @echo "Cannot find $(@F) in path $(LINUX_SRC_PATH)"
-       wget 
$(KERNEL_REPO)/pub/linux/kernel/v$(_LINUX_VDIR)/$(_LINUX_XDIR)/$(@F) -O./$@
+       wget $(LINUX_REPO)/$(LINUX_REPO_PATCH_PATH)/$(@F) \
+               -O$(DOWNLOAD_DIR)/$@ || { rm -f $(DOWNLOAD_DIR)/$@; false; }
 
 pristine-%: pristine-%/.valid-pristine
        @true
+  
+# unpack-pristine and patch-pristine targets are run in a submake
+# so that vpath is re-evaluated. This is important for the case
+# where the files are dowloaded this time around, and they are downloaded
+# into an alternate directory, as specified by DOWNLOAD_PATH
+
+unpack-pristine-%-X: %
+       tar -C $(UNPACK_DIR) -jxf $<
+
+patch-pristine-%-X: %
+       echo $<
+       bzcat $< | patch -d $(UNPACK_DIR) -p1
+
+.PHONY: patch-pristine-dummy
+patch-pristine-dummy-X:
 
-pristine-%/.valid-pristine: %.tar.bz2
+pristine-%/.valid-pristine: $(LINUX_TARBALL) $(LINUX_PATCHES)
        rm -rf tmp-pristine-$* $(@D)
        mkdir -p tmp-pristine-$*
-       tar -C tmp-pristine-$* -jxf $<
-       -@rm -f tmp-pristine-$*/pax_global_header
+       @# firstword is used to get rid of any whitespace
+       $(MAKE) UNPACK_DIR=tmp-pristine-$* \
+               unpack-pristine-$(firstword $(LINUX_TARBALL))-X
+       -rm -f tmp-pristine-$*/pax_global_header
        mv tmp-pristine-$*/* $(@D)
-       @rm -rf tmp-pristine-$*
+       rm -rf tmp-pristine-$*
+       $(MAKE) KERNELS=linux-2.6-xen UNPACK_DIR=pristine-$* \
+               $(patsubst %, patch-pristine-%-X, dummy $(LINUX_PATCHES))
        touch $(@D)/.hgskip
        touch $@ # update timestamp to avoid rebuild
 
--- x/buildconfigs/mk.linux-2.6-xen
+++ x/buildconfigs/mk.linux-2.6-xen
@@ -1,5 +1,7 @@
 LINUX_SERIES = 2.6
 LINUX_VER    = 2.6.16.13
+LINUX_TARBALL = linux-2.6.16.13.tar.bz2 # Only one makes sense
+#LINUX_PATCHES = patch-2.6.17-rcN.bz2 # Usually zero or one patch
 
 EXTRAVERSION ?= xen
 
@@ -57,4 +59,4 @@ delete: 
 
 .PHONY: mrpropper
 mrpropper:
-       rm -f $(LINUX_SRCS)
+       rm -f $(LINUX_TARBALL) $(LINUX_PATCHES)

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.