2 CURL ?= $(shell if test -f /usr/bin/curl ; then echo "curl -H Pragma: -O -R -S --fail --show-error" ; fi)
3 WGET ?= $(shell if test -f /usr/bin/wget ; then echo "wget -nd -m" ; fi)
4 CLIENT ?= $(if $(CURL),$(CURL),$(if $(WGET),$(WGET)))
9 # this is passed on the command line as the full path to <build>/SPECS/kernel.spec
10 SPECFILE = kernel-2.6.spec
12 # Thierry - when called from within the build, PWD is /build
15 # get nevr from specfile.
17 NAME := $(shell rpm $(RPMDEFS) $(DISTDEFS) -q --qf "%{NAME}\n" --specfile $(SPECFILE) | head -1)
20 EPOCH := $(shell rpm $(RPMDEFS) $(DISTDEFS) -q --qf "%{EPOCH}\n" --specfile $(SPECFILE) | head -1 | sed 's/(none)//')
22 ifeq ($(EPOCH),(none))
26 VERSION := $(shell rpm $(RPMDEFS) $(DISTDEFS) -q --qf "%{VERSION}\n" --specfile $(SPECFILE)| head -1)
29 RELEASE := $(shell rpm $(RPMDEFS) $(DISTDEFS) -q --qf "%{RELEASE}\n" --specfile $(SPECFILE)| head -1)
32 define get_sources_sha1
33 $(shell cat sources 2>/dev/null | awk 'gensub("^.*/", "", 1, $$2) == "$@" { print $$1; exit; }')
35 define get_sources_url1
36 $(shell cat sources 2>/dev/null | awk 'gensub("^.*/", "", 1, $$2) == "$@" { print $$2; exit; }')
38 define get_sources_url2
39 $(shell cat sources 2>/dev/null | awk 'gensub("^.*/", "", 1, $$2) == "$@" { print $$3; exit; }')
41 SOURCEFILES := $(shell cat sources 2>/dev/null | awk '{ print gensub("^.*/", "", 1, $$2) }')
42 SOURCE_RPM := $(firstword $(SOURCEFILES))
44 sources: $(SOURCEFILES) $(TARGETS)
46 $(SOURCEFILES): #FORCE
47 @if [ ! -e "$@" ] ; then \
48 { echo Using primary; echo "$(CLIENT) $(get_sources_url1)" ; $(CLIENT) $(get_sources_url1) ; } || \
49 { echo Using secondary; echo "$(CLIENT) $(get_sources_url2)" ; $(CLIENT) $(get_sources_url2) ; } ; fi
50 @if [ ! -e "$@" ] ; then echo "Could not download source file: $@ does not exist" ; exit 1 ; fi
51 @if test "$$(sha1sum $@ | awk '{print $$1}')" != "$(get_sources_sha1)" ; then \
52 echo "sha1sum of the downloaded $@ does not match the one from 'sources' file" ; \
53 echo "Local copy: $$(sha1sum $@)" ; \
54 echo "In sources: $$(grep $@ sources)" ; \
61 @for i in $(SOURCES); do \
62 if [ ! -e "$${i##*/}" ]; then \
63 echo "$(CLIENT) $$i"; \
72 new-sources: download-sources
73 @for i in $(SOURCES); do \
74 echo "$(SHA1SUM) $$i >> sources"; \
75 $(SHA1SUM) $${i##*/} | $(AWK) '{ printf "%s %s\n", $$1, "'"$$i"'" }' >> sources; \
79 RPMDIRDEFS = --define "_sourcedir $(PWD)/SOURCES" --define "_builddir $(PWD)" --define "_srcrpmdir $(PWD)" --define "_rpmdir $(PWD)"
81 rpmbuild $(RPMDIRDEFS) $(RPMDEFS) --nodeps -bp --target $(PREPARCH) $(SPECFILE)
83 # use the stock source rpm, unwrap it,
84 # copy the downloaded material
85 # install our own specfile and patched patches
86 # and patch configs for IPV6
87 # then rewrap with rpm
89 mkdir -p SOURCES SRPMS
90 (cd SOURCES; rpm2cpio ../$(SOURCE_RPM) | cpio -diu; \
91 cp ../$(notdir $(SPECFILE)) . ; cp ../linux-*.patch .; cp ../config-vserver . ; cp ../config-planetlab .; \
92 for downloaded in $(SOURCEFILES) ; do cp ../$$downloaded . ; done ; \
93 cat config-vserver >> config-generic ; \
94 cat config-planetlab >> config-generic)
97 export HOME=$(shell pwd) ; rpmbuild $(RPMDIRDEFS) $(RPMDEFS) --nodeps -bs $(SPECFILE)
99 TARGET ?= $(shell uname -m)
101 rpmbuild $(RPMDIRDEFS) $(RPMDEFS) --nodeps --target $(TARGET) -bb $(SPECFILE)
105 rm -rf BUILDROOT SOURCES SPECS SRPMS kernel-2.6.32 tmp