summaryrefslogtreecommitdiffstats
path: root/scripts/Makefile.package
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/Makefile.package')
-rw-r--r--scripts/Makefile.package241
1 files changed, 154 insertions, 87 deletions
diff --git a/scripts/Makefile.package b/scripts/Makefile.package
index 525a2820976f..b941e6341b36 100644
--- a/scripts/Makefile.package
+++ b/scripts/Makefile.package
@@ -3,36 +3,13 @@
include $(srctree)/scripts/Kbuild.include
-# RPM target
-# ---------------------------------------------------------------------------
-# The rpm target generates two rpm files:
-# /usr/src/packages/SRPMS/kernel-2.6.7rc2-1.src.rpm
-# /usr/src/packages/RPMS/i386/kernel-2.6.7rc2-1.<arch>.rpm
-# The src.rpm files includes all source for the kernel being built
-# The <arch>.rpm includes kernel configuration, modules etc.
-#
-# Process to create the rpm files
-# a) clean the kernel
-# b) Generate .spec file
-# c) Build a tar ball, using symlink to make kernel version
-# first entry in the path
-# d) and pack the result to a tar.gz file
-# e) generate the rpm files, based on kernel.spec
-# - Use /. to avoid tar packing just the symlink
-
-# Note that the rpm-pkg target cannot be used with KBUILD_OUTPUT,
-# but the binrpm-pkg target can; for some reason O= gets ignored.
-
-# Remove hyphens since they have special meaning in RPM filenames
KERNELPATH := kernel-$(subst -,_,$(KERNELRELEASE))
-KDEB_SOURCENAME ?= linux-upstream
KBUILD_PKG_ROOTCMD ?="fakeroot -u"
-export KDEB_SOURCENAME
# Include only those top-level files that are needed by make, plus the GPL copy
TAR_CONTENT := Documentation LICENSES arch block certs crypto drivers fs \
include init io_uring ipc kernel lib mm net rust \
samples scripts security sound tools usr virt \
- .config .scmversion Makefile \
+ .config Makefile \
Kbuild Kconfig COPYING $(wildcard localversion*)
MKSPEC := $(srctree)/scripts/package/mkspec
@@ -42,35 +19,77 @@ if test "$(objtree)" != "$(srctree)"; then \
echo >&2; \
echo >&2 " ERROR:"; \
echo >&2 " Building source tarball is not possible outside the"; \
- echo >&2 " kernel source tree. Don't set KBUILD_OUTPUT, or use the"; \
- echo >&2 " binrpm-pkg or bindeb-pkg target instead."; \
+ echo >&2 " kernel source tree. Don't set KBUILD_OUTPUT"; \
echo >&2; \
false; \
fi ; \
-$(srctree)/scripts/setlocalversion --save-scmversion; \
tar -I $(KGZIP) -c $(RCS_TAR_IGNORE) -f $(2).tar.gz \
- --transform 's:^:$(2)/:S' $(TAR_CONTENT) $(3); \
-rm -f $(objtree)/.scmversion
+ --transform 's:^:$(2)/:S' $(TAR_CONTENT) $(3)
+
+# .tmp_filelist .tmp_filelist_exclude
+# ---------------------------------------------------------------------------
+
+scripts/list-gitignored: FORCE
+ $(Q)$(MAKE) -f $(srctree)/Makefile scripts_package
+
+# 1f5d3a6b6532e25a5cdf1f311956b2b03d343a48 removed '*.rej' from .gitignore,
+# but it is definitely a generated file.
+filechk_filelist = \
+ $< --exclude='*.rej' --output=$@_exclude --prefix=./ --rootdir=$(srctree) --stat=-
+
+.tmp_filelist: scripts/list-gitignored FORCE
+ $(call filechk,filelist)
+
+# tarball
+# ---------------------------------------------------------------------------
+
+quiet_cmd_tar = TAR $@
+ cmd_tar = tar -c -f $@ $(tar-compress-opt) $(tar-exclude-opt) \
+ --owner=0 --group=0 --sort=name \
+ --transform 's:^\.:$*:S' -C $(tar-rootdir) .
+
+tar-rootdir := $(srctree)
+
+%.tar:
+ $(call cmd,tar)
+
+%.tar.gz: private tar-compress-opt := -I $(KGZIP)
+%.tar.gz:
+ $(call cmd,tar)
+
+%.tar.bz2: private tar-compress-opt := -I $(KBZIP2)
+%.tar.bz2:
+ $(call cmd,tar)
+
+%.tar.xz: private tar-compress-opt := -I $(XZ)
+%.tar.xz:
+ $(call cmd,tar)
+
+%.tar.zst: private tar-compress-opt := -I $(ZSTD)
+%.tar.zst:
+ $(call cmd,tar)
+
+# Linux source tarball
+# ---------------------------------------------------------------------------
+
+linux.tar.gz: tar-exclude-opt = --exclude=./$@ --exclude-from=$<_exclude
+linux.tar.gz: .tmp_filelist
# rpm-pkg
# ---------------------------------------------------------------------------
PHONY += rpm-pkg
-rpm-pkg:
- $(MAKE) clean
- $(CONFIG_SHELL) $(MKSPEC) >$(objtree)/kernel.spec
- $(call cmd,src_tar,$(KERNELPATH),kernel.spec)
- +rpmbuild $(RPMOPTS) --target $(UTS_MACHINE)-linux -ta $(KERNELPATH).tar.gz \
+rpm-pkg: srpm = $(shell rpmspec --srpm --query --queryformat='%{name}-%{VERSION}-%{RELEASE}.src.rpm' kernel.spec)
+rpm-pkg: srcrpm-pkg
+ +rpmbuild $(RPMOPTS) --target $(UTS_MACHINE)-linux -rb $(srpm) \
--define='_smp_mflags %{nil}'
# srcrpm-pkg
# ---------------------------------------------------------------------------
PHONY += srcrpm-pkg
-srcrpm-pkg:
- $(MAKE) clean
+srcrpm-pkg: linux.tar.gz
$(CONFIG_SHELL) $(MKSPEC) >$(objtree)/kernel.spec
- $(call cmd,src_tar,$(KERNELPATH),kernel.spec)
- +rpmbuild $(RPMOPTS) --target $(UTS_MACHINE)-linux -ts $(KERNELPATH).tar.gz \
- --define='_smp_mflags %{nil}' --define='_srcrpmdir $(srctree)'
+ +rpmbuild $(RPMOPTS) --target $(UTS_MACHINE)-linux -bs kernel.spec \
+ --define='_smp_mflags %{nil}' --define='_sourcedir .' --define='_srcrpmdir .'
# binrpm-pkg
# ---------------------------------------------------------------------------
@@ -81,18 +100,30 @@ binrpm-pkg:
+rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \
$(UTS_MACHINE)-linux -bb $(objtree)/binkernel.spec
+quiet_cmd_debianize = GEN $@
+ cmd_debianize = $(srctree)/scripts/package/mkdebian
+
+debian: FORCE
+ $(call cmd,debianize)
+
+PHONY += debian-orig
+debian-orig: private source = $(shell dpkg-parsechangelog -S Source)
+debian-orig: private version = $(shell dpkg-parsechangelog -S Version | sed 's/-[^-]*$$//')
+debian-orig: private orig-name = $(source)_$(version).orig.tar.gz
+debian-orig: linux.tar.gz debian
+ $(Q)if [ "$(df --output=target .. 2>/dev/null)" = "$(df --output=target $< 2>/dev/null)" ]; then \
+ ln -f $< ../$(orig-name); \
+ else \
+ cp $< ../$(orig-name); \
+ fi
+
PHONY += deb-pkg
-deb-pkg:
- $(MAKE) clean
- $(CONFIG_SHELL) $(srctree)/scripts/package/mkdebian
- $(call cmd,src_tar,$(KDEB_SOURCENAME))
- origversion=$$(dpkg-parsechangelog -SVersion |sed 's/-[^-]*$$//');\
- mv $(KDEB_SOURCENAME).tar.gz ../$(KDEB_SOURCENAME)_$${origversion}.orig.tar.gz
- +dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) $(DPKG_FLAGS) -i.git -us -uc
+deb-pkg: debian-orig
+ +dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) $(DPKG_FLAGS) \
+ --build=source,binary -nc -us -uc
PHONY += bindeb-pkg
-bindeb-pkg:
- $(CONFIG_SHELL) $(srctree)/scripts/package/mkdebian
+bindeb-pkg: debian
+dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) $(DPKG_FLAGS) -b -nc -uc
PHONY += intdeb-pkg
@@ -114,44 +145,77 @@ snap-pkg:
cd $(objtree)/snap && \
snapcraft --target-arch=$(UTS_MACHINE)
-# tarball targets
+# dir-pkg tar*-pkg - tarball targets
# ---------------------------------------------------------------------------
-tar-pkgs := dir-pkg tar-pkg targz-pkg tarbz2-pkg tarxz-pkg tarzst-pkg
-PHONY += $(tar-pkgs)
-$(tar-pkgs):
- $(MAKE) -f $(srctree)/Makefile
- +$(CONFIG_SHELL) $(srctree)/scripts/package/buildtar $@
-# perf-pkg - generate a source tarball with perf source
+tar-pkg-tarball = linux-$(KERNELRELEASE)-$(ARCH).$(1)
+tar-pkg-phony = $(subst .,,$(1))-pkg
+
+tar-install: FORCE
+ $(Q)$(MAKE) -f $(srctree)/Makefile
+ +$(Q)$(srctree)/scripts/package/buildtar $@
+
+PHONY += dir-pkg
+dir-pkg: tar-install
+ @echo "Kernel tree successfully created in $<"
+
+define tar-pkg-rule
+PHONY += $(tar-pkg-phony)
+$(tar-pkg-phony): $(tar-pkg-tarball)
+ @:
+
+$(tar-pkg-tarball): private tar-rootdir := tar-install
+$(tar-pkg-tarball): tar-install
+endef
+
+$(foreach x, tar tar.gz tar.bz2 tar.xz tar.zst, $(eval $(call tar-pkg-rule,$(x))))
+
+# perf-tar*-src-pkg - generate a source tarball with perf source
# ---------------------------------------------------------------------------
-perf-tar=perf-$(KERNELVERSION)
-
-quiet_cmd_perf_tar = TAR
- cmd_perf_tar = \
-git --git-dir=$(srctree)/.git archive --prefix=$(perf-tar)/ \
- HEAD^{tree} $$(cd $(srctree); \
- echo $$(cat tools/perf/MANIFEST)) \
- -o $(perf-tar).tar; \
-mkdir -p $(perf-tar); \
-git --git-dir=$(srctree)/.git rev-parse HEAD > $(perf-tar)/HEAD; \
-(cd $(srctree)/tools/perf; \
-util/PERF-VERSION-GEN $(CURDIR)/$(perf-tar)/); \
-tar rf $(perf-tar).tar $(perf-tar)/HEAD $(perf-tar)/PERF-VERSION-FILE; \
-rm -r $(perf-tar); \
-$(if $(findstring tar-src,$@),, \
-$(if $(findstring bz2,$@),$(KBZIP2), \
-$(if $(findstring gz,$@),$(KGZIP), \
-$(if $(findstring xz,$@),$(XZ), \
-$(if $(findstring zst,$@),$(ZSTD), \
-$(error unknown target $@))))) \
- -f -9 $(perf-tar).tar)
-
-perf-tar-pkgs := perf-tar-src-pkg perf-targz-src-pkg perf-tarbz2-src-pkg \
- perf-tarxz-src-pkg perf-tarzst-src-pkg
-PHONY += $(perf-tar-pkgs)
-$(perf-tar-pkgs):
- $(call cmd,perf_tar)
+perf-tar-src-pkg-tarball = perf-$(KERNELVERSION).$(1)
+perf-tar-src-pkg-phony = perf-$(subst .,,$(1))-src-pkg
+
+quiet_cmd_stage_perf_src = STAGE $@
+ cmd_stage_perf_src = \
+ rm -rf $@; \
+ mkdir -p $@; \
+ tar -c -f - --exclude-from=$<_exclude -C $(srctree) --files-from=$(srctree)/tools/perf/MANIFEST | \
+ tar -x -f - -C $@
+
+.tmp_perf: .tmp_filelist
+ $(call cmd,stage_perf_src)
+
+filechk_perf_head = \
+ if test -z "$(git -C $(srctree) rev-parse --show-cdup 2>/dev/null)" && \
+ head=$$(git -C $(srctree) rev-parse --verify HEAD 2>/dev/null); then \
+ echo $$head; \
+ else \
+ echo "not a git tree"; \
+ fi
+
+.tmp_perf/HEAD: .tmp_perf FORCE
+ $(call filechk,perf_head)
+
+quiet_cmd_perf_version_file = GEN $@
+ cmd_perf_version_file = cd $(srctree)/tools/perf; util/PERF-VERSION-GEN $(dir $(abspath $@))
+
+# PERF-VERSION-FILE and HEAD are independent, but this avoids updating the
+# timestamp of PERF-VERSION-FILE.
+# The best is to fix tools/perf/util/PERF-VERSION-GEN.
+.tmp_perf/PERF-VERSION-FILE: .tmp_perf/HEAD $(srctree)/tools/perf/util/PERF-VERSION-GEN
+ $(call cmd,perf_version_file)
+
+define perf-tar-src-pkg-rule
+PHONY += $(perf-tar-src-pkg-phony)
+$(perf-tar-src-pkg-phony): $(perf-tar-src-pkg-tarball)
+ @:
+
+$(perf-tar-src-pkg-tarball): private tar-rootdir := .tmp_perf
+$(perf-tar-src-pkg-tarball): .tmp_filelist .tmp_perf/HEAD .tmp_perf/PERF-VERSION-FILE
+endef
+
+$(foreach x, tar tar.gz tar.bz2 tar.xz tar.zst, $(eval $(call perf-tar-src-pkg-rule,$(x))))
# Help text displayed when executing 'make help'
# ---------------------------------------------------------------------------
@@ -170,10 +234,13 @@ help:
@echo ' tarbz2-pkg - Build the kernel as a bzip2 compressed tarball'
@echo ' tarxz-pkg - Build the kernel as a xz compressed tarball'
@echo ' tarzst-pkg - Build the kernel as a zstd compressed tarball'
- @echo ' perf-tar-src-pkg - Build $(perf-tar).tar source tarball'
- @echo ' perf-targz-src-pkg - Build $(perf-tar).tar.gz source tarball'
- @echo ' perf-tarbz2-src-pkg - Build $(perf-tar).tar.bz2 source tarball'
- @echo ' perf-tarxz-src-pkg - Build $(perf-tar).tar.xz source tarball'
- @echo ' perf-tarzst-src-pkg - Build $(perf-tar).tar.zst source tarball'
+ @echo ' perf-tar-src-pkg - Build the perf source tarball with no compression'
+ @echo ' perf-targz-src-pkg - Build the perf source tarball with gzip compression'
+ @echo ' perf-tarbz2-src-pkg - Build the perf source tarball with bz2 compression'
+ @echo ' perf-tarxz-src-pkg - Build the perf source tarball with xz compression'
+ @echo ' perf-tarzst-src-pkg - Build the perf source tarball with zst compression'
+
+PHONY += FORCE
+FORCE:
.PHONY: $(PHONY)