mkspec 5.6 KB
Newer Older
L
Linus Torvalds 已提交
1 2
#!/bin/sh
#
3 4
#	Output a simple RPM spec file.
#	This version assumes a minimum of RPM 4.0.3.
L
Linus Torvalds 已提交
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
#
#	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>
#

# how we were called determines which rpms we build and how we build them
if [ "$1" = "prebuilt" ]; then
	PREBUILT=true
else
	PREBUILT=false
fi

# starting to output the spec
if [ "`grep CONFIG_DRM=y .config | cut -f2 -d\=`" = "y" ]; then
	PROVIDES=kernel-drm
fi

PROVIDES="$PROVIDES kernel-$KERNELRELEASE"
25
__KERNELRELEASE=`echo $KERNELRELEASE | sed -e "s/-/_/g"`
L
Linus Torvalds 已提交
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41

echo "Name: kernel"
echo "Summary: The Linux Kernel"
echo "Version: $__KERNELRELEASE"
# we need to determine the NEXT version number so that uname and
# rpm -q will agree
echo "Release: `. $srctree/scripts/mkversion`"
echo "License: GPL"
echo "Group: System Environment/Kernel"
echo "Vendor: The Linux Community"
echo "URL: http://www.kernel.org"

if ! $PREBUILT; then
echo "Source: kernel-$__KERNELRELEASE.tar.gz"
fi

42
echo "BuildRoot: %{_tmppath}/%{name}-%{PACKAGE_VERSION}-root"
L
Linus Torvalds 已提交
43 44 45 46 47 48 49
echo "Provides: $PROVIDES"
echo "%define __spec_install_post /usr/lib/rpm/brp-compress || :"
echo "%define debug_package %{nil}"
echo ""
echo "%description"
echo "The Linux Kernel, the operating system core itself"
echo ""
50 51 52 53 54 55 56 57 58 59 60 61
echo "%package headers"
echo "Summary: Header files for the Linux kernel for use by glibc"
echo "Group: Development/System"
echo "Obsoletes: kernel-headers"
echo "Provides: kernel-headers = %{version}"
echo "%description headers"
echo "Kernel-headers includes the C header files that specify the interface"
echo "between the Linux kernel and userspace libraries and programs.  The"
echo "header files define structures and constants that are needed for"
echo "building most standard programs and are also needed for rebuilding the"
echo "glibc package."
echo ""
62 63 64 65 66 67 68 69
echo "%package devel"
echo "Summary: Development package for building kernel modules to match the $__KERNELRELEASE kernel"
echo "Group: System Environment/Kernel"
echo "AutoReqProv: no"
echo "%description -n kernel-devel"
echo "This package provides kernel headers and makefiles sufficient to build modules"
echo "against the $__KERNELRELEASE kernel package."
echo ""
L
Linus Torvalds 已提交
70 71 72 73 74 75 76 77 78 79

if ! $PREBUILT; then
echo "%prep"
echo "%setup -q"
echo ""
fi

echo "%build"

if ! $PREBUILT; then
80
echo "make clean && make %{?_smp_mflags}"
L
Linus Torvalds 已提交
81 82 83 84
echo ""
fi

echo "%install"
85
echo 'KBUILD_IMAGE=$(make image_name)'
86
echo "%ifarch ia64"
87
echo 'mkdir -p $RPM_BUILD_ROOT/boot/efi $RPM_BUILD_ROOT/lib/modules'
88
echo "%else"
89
echo 'mkdir -p $RPM_BUILD_ROOT/boot $RPM_BUILD_ROOT/lib/modules'
90
echo "%endif"
L
Linus Torvalds 已提交
91

92
echo 'INSTALL_MOD_PATH=$RPM_BUILD_ROOT make %{?_smp_mflags} KBUILD_SRC= modules_install'
93 94 95 96
echo "%ifarch ia64"
echo 'cp $KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/efi/vmlinuz-$KERNELRELEASE"
echo 'ln -s '"efi/vmlinuz-$KERNELRELEASE" '$RPM_BUILD_ROOT'"/boot/"
echo "%else"
M
Mike Wolf 已提交
97 98 99 100
echo "%ifarch ppc64"
echo "cp vmlinux arch/powerpc/boot"
echo "cp arch/powerpc/boot/"'$KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/vmlinuz-$KERNELRELEASE"
echo "%else"
L
Linus Torvalds 已提交
101
echo 'cp $KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/vmlinuz-$KERNELRELEASE"
102
echo "%endif"
M
Mike Wolf 已提交
103
echo "%endif"
L
Linus Torvalds 已提交
104

105
echo 'make %{?_smp_mflags} INSTALL_HDR_PATH=$RPM_BUILD_ROOT/usr KBUILD_SRC= headers_install'
L
Linus Torvalds 已提交
106 107 108
echo 'cp System.map $RPM_BUILD_ROOT'"/boot/System.map-$KERNELRELEASE"

echo 'cp .config $RPM_BUILD_ROOT'"/boot/config-$KERNELRELEASE"
J
Josh Hunt 已提交
109 110

echo "%ifnarch ppc64"
111
echo 'bzip2 -9 --keep vmlinux'
J
Josh Hunt 已提交
112 113 114
echo 'mv vmlinux.bz2 $RPM_BUILD_ROOT'"/boot/vmlinux-$KERNELRELEASE.bz2"
echo "%endif"

115
if ! $PREBUILT; then
116 117
echo 'rm -f $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE/build"
echo 'rm -f $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE/source"
118
echo "mkdir -p "'$RPM_BUILD_ROOT'"/usr/src/kernels/$KERNELRELEASE"
119
echo "EXCLUDES=\"$RCS_TAR_IGNORE --exclude .tmp_versions --exclude=*vmlinux* --exclude=*.o --exclude=*.ko --exclude=*.cmd --exclude=Documentation --exclude .config.old --exclude .missing-syscalls.d\""
120 121 122 123
echo "tar "'$EXCLUDES'" -cf- . | (cd "'$RPM_BUILD_ROOT'"/usr/src/kernels/$KERNELRELEASE;tar xvf -)"
echo 'cd $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE"
echo "ln -sf /usr/src/kernels/$KERNELRELEASE build"
echo "ln -sf /usr/src/kernels/$KERNELRELEASE source"
124
fi
125

L
Linus Torvalds 已提交
126 127
echo ""
echo "%clean"
128
echo 'rm -rf $RPM_BUILD_ROOT'
L
Linus Torvalds 已提交
129
echo ""
130 131
echo "%post"
echo "if [ -x /sbin/installkernel -a -r /boot/vmlinuz-$KERNELRELEASE -a -r /boot/System.map-$KERNELRELEASE ]; then"
132 133
echo "cp /boot/vmlinuz-$KERNELRELEASE /boot/.vmlinuz-$KERNELRELEASE-rpm"
echo "cp /boot/System.map-$KERNELRELEASE /boot/.System.map-$KERNELRELEASE-rpm"
134
echo "rm -f /boot/vmlinuz-$KERNELRELEASE /boot/System.map-$KERNELRELEASE"
135 136
echo "/sbin/installkernel $KERNELRELEASE /boot/.vmlinuz-$KERNELRELEASE-rpm /boot/.System.map-$KERNELRELEASE-rpm"
echo "rm -f /boot/.vmlinuz-$KERNELRELEASE-rpm /boot/.System.map-$KERNELRELEASE-rpm"
137 138
echo "fi"
echo ""
139 140 141 142 143
echo "%preun"
echo "if [ -x /sbin/new-kernel-pkg ]; then"
echo "new-kernel-pkg --remove $KERNELRELEASE --rminitrd --initrdfile=/boot/initramfs-$KERNELRELEASE.img"
echo "fi"
echo ""
144 145 146 147 148
echo "%postun"
echo "if [ -x /sbin/update-bootloader ]; then"
echo "/sbin/update-bootloader --remove $KERNELRELEASE"
echo "fi"
echo ""
L
Linus Torvalds 已提交
149 150 151
echo "%files"
echo '%defattr (-, root, root)'
echo "/lib/modules/$KERNELRELEASE"
152 153
echo "%exclude /lib/modules/$KERNELRELEASE/build"
echo "%exclude /lib/modules/$KERNELRELEASE/source"
L
Linus Torvalds 已提交
154 155
echo "/boot/*"
echo ""
156 157 158 159
echo "%files headers"
echo '%defattr (-, root, root)'
echo "/usr/include"
echo ""
160
if ! $PREBUILT; then
161 162 163 164 165 166
echo "%files devel"
echo '%defattr (-, root, root)'
echo "/usr/src/kernels/$KERNELRELEASE"
echo "/lib/modules/$KERNELRELEASE/build"
echo "/lib/modules/$KERNELRELEASE/source"
echo ""
167
fi