diff options
author | Sam Ravnborg <sam@ravnborg.org> | 2004-06-20 06:46:32 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2004-06-20 06:46:32 -0700 |
commit | 6474b7f6e308d089ad0d17d20e444b99663a9b75 (patch) | |
tree | 29880bbef6224af138f3a65c46e157763381ffdf /scripts | |
parent | 914352a1083bd3b105be67b6f800509e3f54bc61 (diff) | |
download | history-6474b7f6e308d089ad0d17d20e444b99663a9b75.tar.gz |
[PATCH] kbuild: add deb-pkg target
To prepare kbuild for more kernel packaging formats move all packaging support
to scripts/package.
In top-level Makefile introduce generic support for all package formats using
target names *-pkg. Included the old rpm target for backward compatibility.
A new variable KBUILD_IMAGE is used to specify what kernel image will be part
of the final package, and is to be set by the arch specific makefile.
KBUILD_IMAGE may be overridden from command line or environment. KBUILD_IMAGE
will see wider usage later, mainly when installing kernel images.
Introducing KBUILD_IMAGE allowed arch specific details to be deleted from the
mkspec and builddeb scripts.
While in the process added the deb packet format. Script is From: Wichert
Akkerman <wichert@wiggy.net>
To create a RPM packet use 'make rpm-pkg'.
To create a deb packet use 'make deb-pkg'.
Both targets are included in 'make help'
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/Makefile | 2 | ||||
-rw-r--r-- | scripts/package/Makefile | 71 | ||||
-rw-r--r-- | scripts/package/builddeb | 79 | ||||
-rwxr-xr-x | scripts/package/mkspec (renamed from scripts/mkspec) | 23 |
4 files changed, 158 insertions, 17 deletions
diff --git a/scripts/Makefile b/scripts/Makefile index 8de642c6e8b60..4931b3e361e2b 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -13,7 +13,7 @@ modpost-objs := modpost.o file2alias.o sumversion.o subdir-$(CONFIG_MODVERSIONS) += genksyms # Let clean descend into subdirs -subdir- += basic lxdialog kconfig +subdir- += basic lxdialog kconfig package # dependencies on generated files need to be listed explicitly diff --git a/scripts/package/Makefile b/scripts/package/Makefile new file mode 100644 index 0000000000000..f3df4bc950dcc --- /dev/null +++ b/scripts/package/Makefile @@ -0,0 +1,71 @@ +# Makefile for the different targets used to generate full packages of a kernel +# It uses the generic clean infrastructure of kbuild + +# Ignore the following files/directories during tar operation +TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn --exclude CVS + + +# 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 + +# Do we have rpmbuild, otherwise fall back to the older rpm +RPM := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ + else echo rpm; fi) + +# Remove hyphens since they have special meaning in RPM filenames +KERNELPATH := kernel-$(subst -,,$(KERNELRELEASE)) +MKSPEC := $(srctree)/scripts/package/mkspec +PREV := set -e; cd ..; + +.PHONY: rpm-pkg rpm + +$(objtree)/kernel.spec: $(MKSPEC) + $(CONFIG_SHELL) $(MKSPEC) > $@ + +rpm-pkg rpm: $(objtree)/kernel.spec + $(MAKE) clean + $(PREV) ln -sf $(srctree) $(KERNELPATH) + $(PREV) tar -cz $(RCS_TAR_IGNORE) -f $(KERNELPATH).tar.gz $(KERNELPATH)/. + $(PREV) rm $(KERNELPATH) + + set -e; \ + $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version + set -e; \ + mv -f $(objtree)/.tmp_version $(objtree)/.version + + $(RPM) --target $(UTS_MACHINE) -ta ../$(KERNELPATH).tar.gz + rm ../$(KERNELPATH).tar.gz + +clean-rule += rm -f $(objtree)/kernel.spec + +# Deb target +# --------------------------------------------------------------------------- +# +.PHONY: deb-pkg +deb-pkg: + $(MAKE) + $(CONFIG_SHELL) $(srctree)/scripts/package/builddeb + +clean-rule += && rm -rf $(objtree)/debian/ + + +# Help text displayed when executing 'make help' +# --------------------------------------------------------------------------- +help: + @echo ' rpm-pkg - Build the kernel as an RPM package' + @echo ' deb-pkg - Build the kernel as an deb package' + diff --git a/scripts/package/builddeb b/scripts/package/builddeb new file mode 100644 index 0000000000000..968a0a77da953 --- /dev/null +++ b/scripts/package/builddeb @@ -0,0 +1,79 @@ +#!/bin/sh +# +# builddeb 1.2 +# Copyright 2003 Wichert Akkerman <wichert@wiggy.net> +# +# Simple script to generate a deb package for a Linux kernel. All the +# complexity of what to do with a kernel after it is installer or removed +# is left to other scripts and packages: they can install scripts in the +# /etc/kernel/{pre,post}{inst,rm}.d/ directories that will be called on +# package install and removal. + +set -e + +# Some variables and settings used throughout the script +version="$VERSION.$PATCHLEVEL.$SUBLEVEL$EXTRAVERSION" +tmpdir="$objtree/debian/tmp" + +# Setup the directory structure +rm -rf "$tmpdir" +mkdir -p "$tmpdir/DEBIAN" "$tmpdir/lib" "$tmpdir/boot" + +# Build and install the kernel +cp System.map "$tmpdir/boot/System.map-$version" +cp .config "$tmpdir/boot/config-$version" +cp $KBUILD_IMAGE "$tmpdir/boot/vmlinuz-$version" + +if grep -q '^CONFIG_MODULES=y' .config ; then + INSTALL_MOD_PATH="$tmpdir" make modules_install +fi + +# Install the maintainer scripts +for script in postinst postrm preinst prerm ; do + mkdir -p "$tmpdir/etc/kernel/$script.d" + cat <<EOF > "$tmpdir/DEBIAN/$script" +#!/bin/sh + +set -e + +test -d /etc/kernel/$script.d && run-parts --arg="$version" /etc/kernel/$script.d +exit 0 +EOF + chmod 755 "$tmpdir/DEBIAN/$script" +done + +name="Kernel Compiler <$(id -nu)@$(hostname -f)>" +# Generate a simple changelog template +cat <<EOF > debian/changelog +linux ($version) unstable; urgency=low + + * A standard release + + -- $name $(date -R) +EOF + +# Generate a control file +cat <<EOF > debian/control +Source: linux +Section: base +Priority: optional +Maintainer: $name +Standards-Version: 3.6.1 + +Package: linux-$version +Architecture: any +Description: Linux kernel, version $version + This package contains the Linux kernel, modules and corresponding other + files version $version. +EOF + +# Fix some ownership and permissions +chown -R root:root "$tmpdir" +chmod -R go-w "$tmpdir" + +# Perform the final magic +dpkg-gencontrol -isp +dpkg --build "$tmpdir" .. + +exit 0 + diff --git a/scripts/mkspec b/scripts/package/mkspec index e64429666a896..3ecfc23e09210 100755 --- a/scripts/mkspec +++ b/scripts/package/mkspec @@ -3,18 +3,12 @@ # Output a simple RPM spec file that uses no fancy features requring # RPM v4. This is intended to work with any RPM distro. # -# The only gothic bit here is redefining install_post to avoid +# The only gothic bit here is redefining install_post to avoid # stripping the symbols from files in the kernel which we want # # Patched for non-x86 by Opencon (L) 2002 <opencon@rio.skydome.net> # -# That's the voodoo to see if it's a x86. -ISX86=`echo ${ARCH:=\`arch\`} | grep -ie i.86` -if [ ! -z $ISX86 ]; then - PC=1 -else - PC=0 -fi + # starting to output the spec if [ "`grep CONFIG_DRM=y .config | cut -f2 -d\=`" = "y" ]; then PROVIDES=kernel-drm @@ -46,19 +40,16 @@ echo "%prep" echo "%setup -q" echo "" echo "%build" -echo "make clean all" +echo "make clean && make" echo "" echo "%install" echo 'mkdir -p $RPM_BUILD_ROOT/boot $RPM_BUILD_ROOT/lib $RPM_BUILD_ROOT/lib/modules' + echo 'INSTALL_MOD_PATH=$RPM_BUILD_ROOT make modules_install' -# This is the first disagreement between i386 and most others -if [ $PC = 1 ]; then - echo 'cp arch/i386/boot/bzImage $RPM_BUILD_ROOT'"/boot/vmlinuz-$VERSION.$PATCHLEVEL.$SUBLEVEL$EXTRAVERSION" -else - echo 'cp vmlinux $RPM_BUILD_ROOT'"/boot/vmlinux-$VERSION.$PATCHLEVEL.$SUBLEVEL$EXTRAVERSION" -fi -# Back on track +echo 'cp $KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/vmlinuz-$VERSION.$PATCHLEVEL.$SUBLEVEL$EXTRAVERSION" + echo 'cp System.map $RPM_BUILD_ROOT'"/boot/System.map-$VERSION.$PATCHLEVEL.$SUBLEVEL$EXTRAVERSION" + echo 'cp .config $RPM_BUILD_ROOT'"/boot/config-$VERSION.$PATCHLEVEL.$SUBLEVEL$EXTRAVERSION" echo "" echo "%clean" |