|
|
发表于 2009-9-10 18:13:50
|
显示全部楼层
编译 pacman 的时候里面有文档。。。
我也写了个关于内核的。。。
一个PKGBUILD 四个包 http://archlive-pkg.googlecode.c ... ce_headers/PKGBUILD
但这种PKGBUILD 好像无法提交到aur
编译好的包 可以从 http://archlive-pkg.googlecode.com/files 下载
或者添加 archlive-pkg 软件源 直接 pacman 来安装
- # Archlive <http://archlive-pkg.googlecode.com>
- pkgname=('kernel26-base-git' 'kernel26-firmware' kernel26-source-git 'kernel-headers')
- pkgbase=""
- pkgver=20090909
- pkgrel=1
- _realpkgname=kernel26
- _configure_as_ARCH_way=y
- _kernelname=${_realpkgname#kernel26}
- ## if you want your own version, such as 2.6.31-archlive, then
- ## "_configure_as_ARCH_way" set to "1" and
- ## "_realpkgname" change to "kernel26-archlive"
- _include_aufs2=y
- _include_squashfs=y
- # 是否保存编译目录
- _keep_build_dir=y
- ## More special selection as below items.
- #
- url="http://www.kernel.org/"
- arch=(i686 x86_64)
- license=('GPL2')
- makedepends=('git' 'gcc')
- backup=(etc/mkinitcpio.d/kernel26.preset)
- source=(kernel26.preset config.{i686,x86_64} \
- logo_linux_{clut224.ppm,mono.pbm,vga16.ppm}
- ## reiserfs4 patch
- http://www.kernel.org/pub/linux/kernel/people/edward/reiser4/reiser4-for-2.6/reiser4-for-2.6.30.patch.gz
- ## Gentoo patches
- 4100_dm-bbr.patch 4202_fbcondecor-0.9.6.patch 4400_alpha-sysctl-uac.patch
- ### Chinese Characters Patches 孙海勇 大侠的 内核中文补丁 http://youbest.cublog.cn/
- #http://zdbr.net.cn/download/utf8-kernel-2.6.29-core-1.patch.bz2
- utf8-kernel-2.6.29-core-1.patch
- http://zdbr.net.cn/download/utf8-kernel-2.6-fonts-2.patch.bz2
- http://zdbr.net.cn/download/utf8-kernel-2.6.28-fbcondecor-1.patch.bz2
- )
- md5sums=()
- _gitroot="git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git"
- _gitname="linux-2.6.git"
- ####################################################################
- # KERNEL CONFIG FILES
- # This PKGBUILD searches for config files in the current directory
- # and will use the first one it finds from the following
- # list as base configuration:
- # config.local
- # config.saved.$CARCH
- # config.$CARCH
- ####################################################################
- # PATCHES
- # This package builds the vanilla git kernel by default,
- # but it is possible to patch the source without modifying
- # this PKGBUILD.
- # Simply create a directory 'patches' in your PKGBUILD
- # directory and _any_ file (dotfiles excluded) in this
- # folder will be applied to the kernel source.
- # Prefixing the patch file names with dots will obviously
- # excluded them from the patching process.
- #############################################################
- # CONFIGURATION
- # Uncomment desired options
- #######
- # Set to menuconfig, xconfig, gconfig or oldconfig
- # If you set it to something else, the
- # (manual) kernel configuration step will
- # be skipped
- _menu_method="menuconfig"
- #######
- # The directory where the kernel should be built
- # Can be useful, for example, if you want to compile on a
- # tmpfs mount, which can speed up the compilation process
- _build_dir="$srcdir"
- #######
- # Stop build process after kernel configuration
- # This option enables _save_config implicitly.
- # _configure_only=1
- #######
- # Save the .config file to package directory
- # as config.saved.$CARCH
- # _save_config=1
- #######
- # Make the kernel build process verbose
- # _verbose=1
- ####################################################################
- extrapatch() {
- msg2 "Add Gentoo patches 加入Gentoo官方基本补丁..."
- for i in $(ls $srcdir/4[0-9][0-9][0-9]*);do
- echo "Applying $(basename $i)"
- patch -Np1 -i $i || return 1
- done
- msg2 "Add the kernel Chinese characters patches 加入孙海勇 大侠的 内核中文补丁 http://youbest.cublog.cn/"
- patch -Np1 -i $srcdir/utf8-kernel-2.6.29-core-1.patch || return 1
- patch -Np1 -i $srcdir/utf8-kernel-2.6.28-fbcondecor-1.patch || return 1
- patch -Np1 -i $srcdir/utf8-kernel-2.6-fonts-2.patch || return 1
- msg2 "Adding reiserfs4 patch reiser4-for-2.6.30.patch"
- patch -Np1 -i ${srcdir}/reiser4-for-2.6.30.patch || return 1
- if [ "${_include_aufs2}" = "y" ]; then
- msg2 "Get aufs2 standalone patch from git tree"
- if [ -d $srcdir/aufs2-standalone ]; then
- cd $srcdir/aufs2-standalone
- git pull origin
- else
- git clone http://git.c3sl.ufpr.br/pub/scm/aufs/aufs2-standalone.git $srcdir/aufs2-standalone || return 1
- fi
- cd $srcdir/aufs2-standalone
- git checkout origin/aufs2
- cp -r $srcdir/aufs2-standalone/{Documentation,fs,include,aufs2-base.patch,aufs2-kbuild.patch,aufs2-standalone.patch} \
- $srcdir/$_gitname-build/
- cd $srcdir/$_gitname-build
- patch -Np1 -i aufs2-kbuild.patch || return 1
- patch -Np1 -i aufs2-base.patch || return 1
- patch -Np1 -i aufs2-standalone.patch || return 1
- fi
- }
- build() {
- KARCH="x86"
- msg "Fetching sources..."
- cd "$startdir"
- if [ -d "$_gitname" ]; then
- msg2 "Updating sources..."
- cd "$_gitname" && git fetch && cd "$OLDPWD" || return 1
- else
- msg2 "Cloning the project..."
- git clone --mirror "$_gitroot" "$_gitname" || return 1
- fi
- msg "Creating build branch..."
- rm -rf "$_build_dir/$_gitname-build"
- git clone "$_gitname" "$_build_dir/$_gitname-build" || return 1
- cd "$_build_dir/$_gitname-build"
- # Add Gentoo patches, Fedora patches, reiserfs4 patch and kernel Chinese characters patches.
- extrapatch
- msg "Adding Archlinux logo..."
- cp "$srcdir/logo_linux_clut224.ppm" drivers/video/logo/ &&
- cp "$srcdir/logo_linux_mono.pbm" drivers/video/logo/ &&
- cp "$srcdir/logo_linux_vga16.ppm" drivers/video/logo/ || return 1
- # Apply other patches
- if [ -d "$startdir/patches" ]; then
- msg "Applying patches..."
- for i in "$startdir/patches/"*; do
- msg2 "Applying ${i##*/}..."
- patch -Np1 -i "$i" || (error "Applying ${i##*/} failed" && return 1)
- done
- fi
- #################
- # CONFIGURATION
- #################
- msg "Loading configuration..."
- for i in local "saved.$CARCH" "$CARCH"; do
- if [ -e "$startdir/config.$i" ]; then
- msg2 "Using kernel config file config.$i..."
- cp -f "$startdir/config.$i" .config || return 1
- break
- fi
- done
- [ ! -e .config ] &&
- warning "No suitable kernel config file was found. You'll have to configure the kernel from scratch."
- ###########################
- # Configure as ARCH way
- ###########################
- if [ "$_configure_as_ARCH_way" = "y" ]; then
- msg "Configure the kernel version as ARCH way, like 2.6.31-ARCH"
- if [ "${_kernelname}" != "" ]; then local_version=${_kernelname}; else local_version="-ARCH"; fi
- sed -i "s|^EXTRAVERSION = .*$|EXTRAVERSION =|g" Makefile
- sed -i "s|.*CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION="${local_version}"|g" .config
- sed -i "s|.*CONFIG_LOCALVERSION_AUTO.*|\# CONFIG_LOCALVERSION_AUTO is not set|g" .config
- fi
- # The default .config without support for squashfs, can change it by set "_include_squashfs" as "y".
- if [ "$_include_squashfs" = "y" ]; then
- msg "Selected squashfs4 included in kernel package."
- if [ "x$(grep "CONFIG_SQUASHFS=m" .config)" = "x" ]; then
- sed -i "s|.*CONFIG_SQUASHFS.*|CONFIG_SQUASHFS=m\
- \n# CONFIG_SQUASHFS_EMBEDDED is not set\
- \nCONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE=3|g" ./.config
- fi
- else
- if [ "x$(grep "CONFIG_SQUASHFS=m" .config)" != "x" ]; then
- sed -i "s|CONFIG_SQUASHFS=m|\# CONFIG_SQUASHFS is not set|g" .config
- fi
- fi
- if [ "${_include_aufs2}" = "y" ]; then
- msg "Selected aufs2 included in kernel package."
- if [ "x$(grep "CONFIG_AUFS_FS=m" .config)" = "x" ]; then
- sed -i "/.*CONFIG_NILFS2_FS.*/ a\
- \CONFIG_AUFS_FS=m\
- \n# CONFIG_AUFS_BRANCH_MAX_127 is not set\
- \n# CONFIG_AUFS_BRANCH_MAX_511 is not set\
- \nCONFIG_AUFS_BRANCH_MAX_1023=y\
- \n# CONFIG_AUFS_BRANCH_MAX_32767 is not set\
- \nCONFIG_AUFS_HINOTIFY=y\
- \nCONFIG_AUFS_EXPORT=y\
- \nCONFIG_AUFS_RDU=y\
- \nCONFIG_AUFS_SHWH=y\
- \nCONFIG_AUFS_BR_RAMFS=y\
- \nCONFIG_AUFS_BR_FUSE=y\
- \n# CONFIG_AUFS_DEBUG is not set\
- \nCONFIG_AUFS_BDEV_LOOP=y\
- \nCONFIG_AUFS_POLL=y" ./.config
- fi
- else
- if [ "x$(grep "CONFIG_AUFS_FS=m" .config)" != "x" ]; then
- sed -i "s|CONFIG_AUFS_FS=m|\# CONFIG_AUFS_FS is not set|g" .config
- fi
- fi
- make prepare
- msg "Update .config Finished"
- ###########################
- # Start the configuration
- ###########################
- msg "Updating configuration..."
- yes "" | make config > /dev/null
- # Save the config file to the package directory
- if [[ -n "$_save_config" || -n "$_configure_only" ]]; then
- msg "Saving configuration..."
- msg2 "Saving $_build_dir/$_gitname-build/.config as $startdir/config.saved.$CARCH"
- cp .config "$startdir/config.saved.$CARCH" || return 1
- fi
- # Stop after configuration if desired
- if [ -n "$_configure_only" ]; then
- rm -rf "$_build_dir/$_gitname-build"
- return 1
- fi
- #################
- # BUILD PROCESS
- #################
- msg "Checking the kernel version..."
- _kernver="$(make kernelrelease)"
- if [ "$_configure_as_ARCH_way" = "y" ]; then
- # Check the _kernver again, if it is your wanted (Special for _configure_as_ARCH_way)
- _localversion=$(grep CONFIG_LOCALVERSION= .config | cut -d """ -f 2)
- if [ "${_kernver#*-}" != ${_localversion#-} ]; then
- msg "There are some errors when get your own kernel version."
- msg "_kernver=${_kernver}, _localversion=${_localversion}."
- exit 1
- else
- msg "Get the right kernel version as ${_kernver}"
- fi
- fi
- msg "Building kernel and modules..."
- make V="$_verbose" bzImage modules || return 1
- msg "Compile finished!"
- }
- package_kernel26-base-git(){
- pkgdesc="The Linux Kernel and modules from Linus' git tree with Gentoo patches, aufs2 and reiserfs4 file system patch, and kernel Chinese characters patches. Linux内核及模块git版,包含内核中文字符支持,Gentoo官方补丁、aufs2补丁、reiser4补丁."
- provides=('kernel26=2.6.31' 'kernel26=2.6.31-ARCH' 'kernel26-git' 'aufs')
- conflicts=('kernel24' 'kernel24-scsi' 'kernel26-scsi' 'kernel26' 'unionfs' 'aufs')
- depends=('coreutils' 'module-init-tools' 'mkinitcpio>=0.5.15')
- install=kernel26.install
- KARCH="x86"
- cd "$_build_dir/$_gitname-build"
- _kernver="$(make kernelrelease)"
- msg "Installing kernel image..."
- install -D -m644 System.map "$pkgdir/boot/System.map26" &&
- install -D -m644 arch/$KARCH/boot/bzImage "$pkgdir/boot/vmlinuz26" &&
- install -D -m644 .config "$pkgdir/boot/kconfig26" || return 1
- msg "Installing kernel modules..."
- make INSTALL_MOD_PATH="$pkgdir" modules_install
- msg "Installing preset file..."
- install -D -m644 "$srcdir/kernel26.preset" \
- "$pkgdir/etc/mkinitcpio.d/kernel26.preset" || return 1
- msg "Generating kernel26.kver..."
- echo -e "# DO NOT EDIT THIS FILE\nALL_kver='$_kernver'" \
- > "$pkgdir/etc/mkinitcpio.d/kernel26.kver" || return 1
- msg "Remove the firmware..."
- rm -rf "$pkgdir/lib/firmware"
- msg "Kernel and modules installing finished."
- }
- package_kernel26-firmware() {
- pkgdesc="The included firmware files of the Linux Kernel, from Linus' git tree."
- provides=('kernel26-firmware')
- conflicts=('kernel26-firmware')
- cd "$_build_dir/$_gitname-build"
- msg "Install the kernel26-firmware..."
- make INSTALL_MOD_PATH="$pkgdir" modules_install
- rm -rf $pkgdir/lib/modules
- msg "kernel firmware installing finished."
- }
- package_kernel26-source-git() {
- pkgdesc="Kernel source from git tree, patched with aufs2 reiser4."
- provides=('kernel26-source')
- conflicts=('kernel26-source')
- KARCH="x86"
- cd "$_build_dir/$_gitname-build"
- _kernver="$(make kernelrelease)"
- msg "Installing the kernel source..."
- # Install configuration and other files...
- install -D -m644 Module.symvers "$pkgdir/usr/src/linux-$_kernver/Module.symvers" &&
- install -D -m644 Makefile "$pkgdir/usr/src/linux-$_kernver/Makefile" &&
- install -D -m644 kernel/Makefile "$pkgdir/usr/src/linux-$_kernver/kernel/Makefile" &&
- install -D -m644 .config "$pkgdir/usr/src/linux-$_kernver/.config" &&
- install -D -m644 .config "$pkgdir/lib/modules/$_kernver/.config" || return 1
- # Install scripts directory and fix permissions on it
- cp -a scripts "$pkgdir/usr/src/linux-$_kernver" &&
- chmod og-w -R "$pkgdir/usr/src/linux-$_kernver" || return 1
- msg "Installing header files..."
- # kernel headers
- msg2 "kernel"
- for i in acpi asm-{generic,$KARCH} config linux math-emu media net pcmcia scsi sound trace video; do
- mkdir -p "$pkgdir/usr/src/linux-$_kernver/include/$i" &&
- cp -a include/$i "$pkgdir/usr/src/linux-$_kernver/include" || return 1
- done
- # lirc headers
- msg2 "lirc"
- mkdir -p "$pkgdir/usr/src/linux-$_kernver/drivers/media/video" &&
- cp drivers/media/video/*.h "$pkgdir/usr/src/linux-$_kernver/drivers/media/video/" || return 1
- for i in bt8xx cpia2 cx25840 cx88 em28xx et61x251 pwc saa7134 sn9c102 usbvideo zc0301; do
- mkdir -p "$pkgdir/usr/src/linux-$_kernver/drivers/media/video/$i" &&
- cp -a drivers/media/video/$i/*.h "$pkgdir/usr/src/linux-$_kernver/drivers/media/video/$i" || return 1
- done
- # md headers
- msg2 "md"
- mkdir -p "$pkgdir/usr/src/linux-$_kernver/drivers/md" &&
- cp drivers/md/*.h "$pkgdir/usr/src/linux-$_kernver/drivers/md" || return 1
- # inotify.h
- msg2 "inotify.h"
- mkdir -p "$pkgdir/usr/src/linux-$_kernver/include/linux" &&
- cp include/linux/inotify.h "$pkgdir/usr/src/linux-$_kernver/include/linux/" || return 1
- # CLUSTERIP file for iptables
- msg2 "CLUSTERIP file for iptables"
- mkdir -p "$pkgdir/usr/src/linux-$_kernver/net/ipv4/netfilter/" &&
- cp net/ipv4/netfilter/ipt_CLUSTERIP.c "$pkgdir/usr/src/linux-$_kernver/net/ipv4/netfilter/" || return 1
- # wireless headers
- msg2 "wireless"
- mkdir -p "$pkgdir/usr/src/linux-$_kernver/net/mac80211/" &&
- cp net/mac80211/*.h "$pkgdir/usr/src/linux-$_kernver/net/mac80211/" || return 1
- # Kconfig files
- msg2 "Kconfig files"
- for i in $(find . -name "Kconfig*"); do
- mkdir -p "$pkgdir/usr/src/linux-$_kernver/${i%/*}" &&
- cp "$i" "$pkgdir/usr/src/linux-$_kernver/$i" || return 1
- done
- # Install architecture dependent files
- msg "Installing architecture files..."
- mkdir -p "$pkgdir/usr/src/linux-$_kernver/arch/$KARCH/kernel" &&
- cp arch/$KARCH/kernel/asm-offsets.s "$pkgdir/usr/src/linux-$_kernver/arch/$KARCH/kernel"
- cp arch/$KARCH/Makefile* "$pkgdir/usr/src/linux-$_kernver/arch/$KARCH"
- cp -r arch/$KARCH/configs "$pkgdir/usr/src/linux-$_kernver/arch/$KARCH"
- # copy arch includes for external modules and fix the nVidia issue
- mkdir -p "$pkgdir/usr/src/linux-$_kernver/arch/$KARCH" &&
- cp -a "arch/$KARCH/include" "$pkgdir/usr/src/linux-$_kernver/arch/$KARCH/" || return 1
- # create a necessary symlink to the arch folder
- cd "$pkgdir/usr/src/linux-$_kernver/arch" || return 1
- if [ "$CARCH" = "x86_64" ]; then
- ln -s $KARCH x86_64 || return 1
- else
- ln -s $KARCH i386 || return 1
- fi
- cd "$OLDPWD" || return 1
- msg "Removing unneeded architectures..."
- for i in "$pkgdir/usr/src/linux-$_kernver/arch/"*; do
- [ "${i##*/}" != "$KARCH" ] && rm -rf "$i"
- done
- msg "Creating important symlinks..."
- cd "$pkgdir/usr/src/linux-$_kernver/include" &&
- ln -s asm-$KARCH asm &&
- cd "$OLDPWD" || return 1
- mkdir -p $pkgdir/lib/modules/$_kernver
- cd "$pkgdir/lib/modules/$_kernver" &&
- rm -rf source build &&
- ln -s ../../../usr/src/linux-$_kernver build &&
- cd "$OLDPWD" || return 1
- msg "Fixing permissions..."
- chown -R root:root "$pkgdir/usr/src/linux-$_kernver" &&
- find "$pkgdir/usr/src/linux-$_kernver" -type d -exec chmod 755 {} \; || return 1
- msg "Kernel source installing finished."
- }
- package_kernel-headers() {
- pkgdesc="Kernel headers sanitized for use in userspace, from git tree."
- provides=('kernel-headers')
- conflicts=('kernel-headers')
- cd "$_build_dir/$_gitname-build"
- _kernver="$(make kernelrelease)"
- msg "Installing the kernel headers..."
- #make mrproper || return 1
- #make headers_check || return 1
- make INSTALL_HDR_PATH="${pkgdir}/usr" headers_install || return 1
- rm -rf "${pkgdir}/usr/include/drm"
- #find ${pkgdir} -type f -name "*.cmd" -exec rm -rf {}\;
- msg "Updating pkgver to ${_kernver%-*}..."
- pkgver=${_kernver%-*}
- if [ "$_keep_build_dir" != "y" ]; then
- # Remove build directory
- rm -rf "$_build_dir/$_gitname-build"
- fi
- msg "kernel headers installed finished."
- }
复制代码 |
|