layout-kernel 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/bin/bash
  2. set -e
  3. # Override using a local kernel build
  4. if [ -e ${DAPPER_SOURCE}/assets/kernel.tar.gz ]; then
  5. echo "copying ${DAPPER_SOURCE}/assets/kernel.tar.gz ${DOWNLOADS}/kernel.tar.gz"
  6. cp ${DAPPER_SOURCE}/assets/kernel.tar.gz ${DOWNLOADS}/kernel.tar.gz
  7. fi
  8. if [ -e ${DOWNLOADS}/kernel.tar.gz ]; then
  9. mkdir -p ${BUILD}/kernel
  10. tar xf ${DOWNLOADS}/kernel.tar.gz -C ${BUILD}/kernel
  11. for i in vmlinuz vmlinux; do
  12. if [ -e ${BUILD}/kernel/boot/${i}-* ]; then
  13. mkdir -p ${ARTIFACTS}
  14. # frustratingly, the vmlinuz versioned filename != the tag name, so we need to do some guessing
  15. # for eg, 4.9-rc8-rancher2 is called vmlinuz-4.9.0-rc8-rancher
  16. echo "Copy ${BUILD}/kernel/boot/${i}-* to ${ARTIFACTS}/vmlinuz-${KERNEL_VERSION}"
  17. cp ${BUILD}/kernel/boot/${i}-* ${ARTIFACTS}/vmlinuz-${KERNEL_VERSION}
  18. # use an unversioned filename for `scripts/run`
  19. cp ${BUILD}/kernel/boot/${i}-* ${BUILD}/kernel/vmlinuz
  20. break
  21. fi
  22. done
  23. # TODO: move these into a separate tar.gz and add to the syslinux initrd line
  24. if [ -d ${BUILD}/kernel/lib ]; then
  25. rm -rf ${INITRD_DIR}/usr/lib
  26. cp -rf ${BUILD}/kernel/lib ${INITRD_DIR}/usr/
  27. depmod -b ${INITRD_DIR}/usr $(basename ${INITRD_DIR}/usr/lib/modules/*)
  28. #TODO:
  29. # new: put the kernel modules into their own initrd file
  30. #mkdir -p ${BUILD}/kernel-fs/usr/
  31. #pushd .
  32. #cp -rf ${BUILD}/kernel/lib ${BUILD}/kernel-fs/usr/
  33. #depmod -b ${BUILD}/kernel-fs/usr $(basename ${BUILD}/kernel-fs/usr/lib/modules/*)
  34. ## and then package it up cpio
  35. #cd ${BUILD}/kernel-fs/
  36. #echo Creating kernel ${ARTIFACTS}/linuxmods-${KERNEL_VERSION}
  37. #if [ "$COMPRESS" == "" ]; then
  38. # COMPRESS="gzip -1"
  39. #fi
  40. #find | cpio -H newc -o | ${COMPRESS} > ${ARTIFACTS}/linuxmods-${KERNEL_VERSION}
  41. #popd
  42. #echo Done creating kernel ${ARTIFACTS}/linuxmods-${KERNEL_VERSION}
  43. ## use an unversioned filename for `scripts/run`
  44. #cp ${ARTIFACTS}/linuxmods-${KERNEL_VERSION} ${BUILD}/kernel/linuxmods
  45. fi
  46. else
  47. if [ "$ARCH" == "amd64" ]; then
  48. echo "no ${DOWNLOADS}/kernel.tar.gz found"
  49. exit 1
  50. fi
  51. fi
  52. if [ "$ARCH" == "amd64" ]; then
  53. ls -lah ${ARTIFACTS}/vmlinuz-*
  54. if [ ! -e "${ARTIFACTS}/vmlinuz-${KERNEL_VERSION}" ]; then
  55. echo "Can't find ${ARTIFACTS}/vmlinuz-${KERNEL_VERSION}"
  56. exit -1
  57. fi
  58. fi