diff options
Diffstat (limited to 'scripts/package')
-rw-r--r-- | scripts/package/Makefile | 89 | ||||
-rw-r--r-- | scripts/package/builddeb | 79 | ||||
-rwxr-xr-x | scripts/package/mkspec | 82 |
3 files changed, 250 insertions, 0 deletions
diff --git a/scripts/package/Makefile b/scripts/package/Makefile new file mode 100644 index 000000000000..3b1f2eff2584 --- /dev/null +++ b/scripts/package/Makefile | |||
@@ -0,0 +1,89 @@ | |||
1 | # Makefile for the different targets used to generate full packages of a kernel | ||
2 | # It uses the generic clean infrastructure of kbuild | ||
3 | |||
4 | # Ignore the following files/directories during tar operation | ||
5 | TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn --exclude CVS | ||
6 | |||
7 | |||
8 | # RPM target | ||
9 | # --------------------------------------------------------------------------- | ||
10 | # The rpm target generates two rpm files: | ||
11 | # /usr/src/packages/SRPMS/kernel-2.6.7rc2-1.src.rpm | ||
12 | # /usr/src/packages/RPMS/i386/kernel-2.6.7rc2-1.<arch>.rpm | ||
13 | # The src.rpm files includes all source for the kernel being built | ||
14 | # The <arch>.rpm includes kernel configuration, modules etc. | ||
15 | # | ||
16 | # Process to create the rpm files | ||
17 | # a) clean the kernel | ||
18 | # b) Generate .spec file | ||
19 | # c) Build a tar ball, using symlink to make kernel version | ||
20 | # first entry in the path | ||
21 | # d) and pack the result to a tar.gz file | ||
22 | # e) generate the rpm files, based on kernel.spec | ||
23 | # - Use /. to avoid tar packing just the symlink | ||
24 | |||
25 | # Do we have rpmbuild, otherwise fall back to the older rpm | ||
26 | RPM := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ | ||
27 | else echo rpm; fi) | ||
28 | |||
29 | # Remove hyphens since they have special meaning in RPM filenames | ||
30 | KERNELPATH := kernel-$(subst -,,$(KERNELRELEASE)) | ||
31 | MKSPEC := $(srctree)/scripts/package/mkspec | ||
32 | PREV := set -e; cd ..; | ||
33 | |||
34 | # rpm-pkg | ||
35 | .PHONY: rpm-pkg rpm | ||
36 | |||
37 | $(objtree)/kernel.spec: $(MKSPEC) $(srctree)/Makefile | ||
38 | $(CONFIG_SHELL) $(MKSPEC) > $@ | ||
39 | |||
40 | rpm-pkg rpm: $(objtree)/kernel.spec | ||
41 | $(MAKE) clean | ||
42 | $(PREV) ln -sf $(srctree) $(KERNELPATH) | ||
43 | $(PREV) tar -cz $(RCS_TAR_IGNORE) -f $(KERNELPATH).tar.gz $(KERNELPATH)/. | ||
44 | $(PREV) rm $(KERNELPATH) | ||
45 | |||
46 | set -e; \ | ||
47 | $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version | ||
48 | set -e; \ | ||
49 | mv -f $(objtree)/.tmp_version $(objtree)/.version | ||
50 | |||
51 | $(RPM) --target $(UTS_MACHINE) -ta ../$(KERNELPATH).tar.gz | ||
52 | rm ../$(KERNELPATH).tar.gz | ||
53 | |||
54 | clean-files := $(objtree)/kernel.spec | ||
55 | |||
56 | # binrpm-pkg | ||
57 | .PHONY: binrpm-pkg | ||
58 | $(objtree)/binkernel.spec: $(MKSPEC) $(srctree)/Makefile | ||
59 | $(CONFIG_SHELL) $(MKSPEC) prebuilt > $@ | ||
60 | |||
61 | binrpm-pkg: $(objtree)/binkernel.spec | ||
62 | $(MAKE) | ||
63 | set -e; \ | ||
64 | $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version | ||
65 | set -e; \ | ||
66 | mv -f $(objtree)/.tmp_version $(objtree)/.version | ||
67 | |||
68 | $(RPM) --define "_builddir $(srctree)" --target $(UTS_MACHINE) -bb $< | ||
69 | |||
70 | clean-files += $(objtree)/binkernel.spec | ||
71 | |||
72 | # Deb target | ||
73 | # --------------------------------------------------------------------------- | ||
74 | # | ||
75 | .PHONY: deb-pkg | ||
76 | deb-pkg: | ||
77 | $(MAKE) | ||
78 | $(CONFIG_SHELL) $(srctree)/scripts/package/builddeb | ||
79 | |||
80 | clean-dirs += $(objtree)/debian/ | ||
81 | |||
82 | |||
83 | # Help text displayed when executing 'make help' | ||
84 | # --------------------------------------------------------------------------- | ||
85 | help: | ||
86 | @echo ' rpm-pkg - Build the kernel as an RPM package' | ||
87 | @echo ' binrpm-pkg - Build an rpm package containing the compiled kernel & modules' | ||
88 | @echo ' deb-pkg - Build the kernel as an deb package' | ||
89 | |||
diff --git a/scripts/package/builddeb b/scripts/package/builddeb new file mode 100644 index 000000000000..c279b6310f02 --- /dev/null +++ b/scripts/package/builddeb | |||
@@ -0,0 +1,79 @@ | |||
1 | #!/bin/sh | ||
2 | # | ||
3 | # builddeb 1.2 | ||
4 | # Copyright 2003 Wichert Akkerman <wichert@wiggy.net> | ||
5 | # | ||
6 | # Simple script to generate a deb package for a Linux kernel. All the | ||
7 | # complexity of what to do with a kernel after it is installer or removed | ||
8 | # is left to other scripts and packages: they can install scripts in the | ||
9 | # /etc/kernel/{pre,post}{inst,rm}.d/ directories that will be called on | ||
10 | # package install and removal. | ||
11 | |||
12 | set -e | ||
13 | |||
14 | # Some variables and settings used throughout the script | ||
15 | version=$KERNELRELEASE | ||
16 | tmpdir="$objtree/debian/tmp" | ||
17 | |||
18 | # Setup the directory structure | ||
19 | rm -rf "$tmpdir" | ||
20 | mkdir -p "$tmpdir/DEBIAN" "$tmpdir/lib" "$tmpdir/boot" | ||
21 | |||
22 | # Build and install the kernel | ||
23 | cp System.map "$tmpdir/boot/System.map-$version" | ||
24 | cp .config "$tmpdir/boot/config-$version" | ||
25 | cp $KBUILD_IMAGE "$tmpdir/boot/vmlinuz-$version" | ||
26 | |||
27 | if grep -q '^CONFIG_MODULES=y' .config ; then | ||
28 | INSTALL_MOD_PATH="$tmpdir" make modules_install | ||
29 | fi | ||
30 | |||
31 | # Install the maintainer scripts | ||
32 | for script in postinst postrm preinst prerm ; do | ||
33 | mkdir -p "$tmpdir/etc/kernel/$script.d" | ||
34 | cat <<EOF > "$tmpdir/DEBIAN/$script" | ||
35 | #!/bin/sh | ||
36 | |||
37 | set -e | ||
38 | |||
39 | test -d /etc/kernel/$script.d && run-parts --arg="$version" /etc/kernel/$script.d | ||
40 | exit 0 | ||
41 | EOF | ||
42 | chmod 755 "$tmpdir/DEBIAN/$script" | ||
43 | done | ||
44 | |||
45 | name="Kernel Compiler <$(id -nu)@$(hostname -f)>" | ||
46 | # Generate a simple changelog template | ||
47 | cat <<EOF > debian/changelog | ||
48 | linux ($version) unstable; urgency=low | ||
49 | |||
50 | * A standard release | ||
51 | |||
52 | -- $name $(date -R) | ||
53 | EOF | ||
54 | |||
55 | # Generate a control file | ||
56 | cat <<EOF > debian/control | ||
57 | Source: linux | ||
58 | Section: base | ||
59 | Priority: optional | ||
60 | Maintainer: $name | ||
61 | Standards-Version: 3.6.1 | ||
62 | |||
63 | Package: linux-$version | ||
64 | Architecture: any | ||
65 | Description: Linux kernel, version $version | ||
66 | This package contains the Linux kernel, modules and corresponding other | ||
67 | files version $version. | ||
68 | EOF | ||
69 | |||
70 | # Fix some ownership and permissions | ||
71 | chown -R root:root "$tmpdir" | ||
72 | chmod -R go-w "$tmpdir" | ||
73 | |||
74 | # Perform the final magic | ||
75 | dpkg-gencontrol -isp | ||
76 | dpkg --build "$tmpdir" .. | ||
77 | |||
78 | exit 0 | ||
79 | |||
diff --git a/scripts/package/mkspec b/scripts/package/mkspec new file mode 100755 index 000000000000..6e7a58f145ad --- /dev/null +++ b/scripts/package/mkspec | |||
@@ -0,0 +1,82 @@ | |||
1 | #!/bin/sh | ||
2 | # | ||
3 | # Output a simple RPM spec file that uses no fancy features requring | ||
4 | # RPM v4. This is intended to work with any RPM distro. | ||
5 | # | ||
6 | # The only gothic bit here is redefining install_post to avoid | ||
7 | # stripping the symbols from files in the kernel which we want | ||
8 | # | ||
9 | # Patched for non-x86 by Opencon (L) 2002 <opencon@rio.skydome.net> | ||
10 | # | ||
11 | |||
12 | # how we were called determines which rpms we build and how we build them | ||
13 | if [ "$1" = "prebuilt" ]; then | ||
14 | PREBUILT=true | ||
15 | else | ||
16 | PREBUILT=false | ||
17 | fi | ||
18 | |||
19 | # starting to output the spec | ||
20 | if [ "`grep CONFIG_DRM=y .config | cut -f2 -d\=`" = "y" ]; then | ||
21 | PROVIDES=kernel-drm | ||
22 | fi | ||
23 | |||
24 | PROVIDES="$PROVIDES kernel-$KERNELRELEASE" | ||
25 | __KERNELRELEASE=`echo $KERNELRELEASE | sed -e "s/-//g"` | ||
26 | |||
27 | echo "Name: kernel" | ||
28 | echo "Summary: The Linux Kernel" | ||
29 | echo "Version: $__KERNELRELEASE" | ||
30 | # we need to determine the NEXT version number so that uname and | ||
31 | # rpm -q will agree | ||
32 | echo "Release: `. $srctree/scripts/mkversion`" | ||
33 | echo "License: GPL" | ||
34 | echo "Group: System Environment/Kernel" | ||
35 | echo "Vendor: The Linux Community" | ||
36 | echo "URL: http://www.kernel.org" | ||
37 | |||
38 | if ! $PREBUILT; then | ||
39 | echo "Source: kernel-$__KERNELRELEASE.tar.gz" | ||
40 | fi | ||
41 | |||
42 | echo "BuildRoot: /var/tmp/%{name}-%{PACKAGE_VERSION}-root" | ||
43 | echo "Provides: $PROVIDES" | ||
44 | echo "%define __spec_install_post /usr/lib/rpm/brp-compress || :" | ||
45 | echo "%define debug_package %{nil}" | ||
46 | echo "" | ||
47 | echo "%description" | ||
48 | echo "The Linux Kernel, the operating system core itself" | ||
49 | echo "" | ||
50 | |||
51 | if ! $PREBUILT; then | ||
52 | echo "%prep" | ||
53 | echo "%setup -q" | ||
54 | echo "" | ||
55 | fi | ||
56 | |||
57 | echo "%build" | ||
58 | |||
59 | if ! $PREBUILT; then | ||
60 | echo "make clean && make %{_smp_mflags}" | ||
61 | echo "" | ||
62 | fi | ||
63 | |||
64 | echo "%install" | ||
65 | echo 'mkdir -p $RPM_BUILD_ROOT/boot $RPM_BUILD_ROOT/lib $RPM_BUILD_ROOT/lib/modules' | ||
66 | |||
67 | echo 'INSTALL_MOD_PATH=$RPM_BUILD_ROOT make %{_smp_mflags} modules_install' | ||
68 | echo 'cp $KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/vmlinuz-$KERNELRELEASE" | ||
69 | |||
70 | echo 'cp System.map $RPM_BUILD_ROOT'"/boot/System.map-$KERNELRELEASE" | ||
71 | |||
72 | echo 'cp .config $RPM_BUILD_ROOT'"/boot/config-$KERNELRELEASE" | ||
73 | echo "" | ||
74 | echo "%clean" | ||
75 | echo '#echo -rf $RPM_BUILD_ROOT' | ||
76 | echo "" | ||
77 | echo "%files" | ||
78 | echo '%defattr (-, root, root)' | ||
79 | echo "%dir /lib/modules" | ||
80 | echo "/lib/modules/$KERNELRELEASE" | ||
81 | echo "/boot/*" | ||
82 | echo "" | ||