recipe 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. # Build recipe for linux-libre (generic).
  2. #
  3. # Copyright (c) 2017-2020 Matias Fonzo, <selk@dragora.org>.
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. program=linux
  17. version=5.4.25
  18. release=1
  19. # Set 'outdir' for a nice and well-organized output directory
  20. outdir="${outdir}/${arch}/kernel"
  21. pkgname=kernel-generic
  22. tarname=${program}-libre-${version}-gnu.tar.lz
  23. # Remote source(s)
  24. fetch=http://linux-libre.fsfla.org/pub/linux-libre/releases/${version}-gnu/$tarname
  25. homepage=http://www.gnu.org/software/linux-libre
  26. description="
  27. The Linux kernel image and modules.
  28. This is a generic configuration for the Linux kernel
  29. which intends to run well in all environments.
  30. "
  31. license="GPLv2 only"
  32. build()
  33. {
  34. # Preserve 'srcdir' in order to produce "buildtree-generic", later
  35. keep_srcdir=keep_srcdir
  36. set -e
  37. unpack "${tardir}/$tarname"
  38. cd "$srcdir"
  39. # Set sane permissions
  40. chmod -R u+w,go-w,a+rX-s .
  41. # Support LZIP
  42. patch -p1 < "${worktree}/patches/kernel/linux-5.4.18_lzip-0.diff"
  43. make mrproper
  44. case $arch in
  45. x86_64)
  46. echo "Copying config-x86_64_generic ..."
  47. cp -p "${worktree}/archive/kernel/config-x86_64_generic" .config
  48. kernel_arch=x86_64
  49. ;;
  50. i?86)
  51. echo "Copying config-x86_generic ..."
  52. cp -p "${worktree}/archive/kernel/config-x86_generic" .config
  53. kernel_arch=i386
  54. ;;
  55. armv7a)
  56. echo "Copying config-armv7a ..."
  57. cp -p "${worktree}/archive/kernel/config-armv7a" .config
  58. kernel_arch=arm
  59. ;;
  60. *)
  61. echo "No custom configuration file detected for your architecture." 1>&2
  62. exit 1;
  63. ;;
  64. esac
  65. # An environment variable for config purposes
  66. if test ! -z "$PRESERVE"
  67. then
  68. echo "PRESERVE has been set."
  69. exit 99;
  70. fi
  71. make -j${jobs} ARCH=$kernel_arch bzImage
  72. make -j${jobs} ARCH=$kernel_arch modules
  73. make -j${jobs} ARCH=$kernel_arch \
  74. INSTALL_MOD_PATH="$destdir" modules_install
  75. # To extract the kernel string version
  76. strver="$(ls -d "${destdir}"/lib/modules/*)"
  77. strver="${strver##*/}"
  78. # Install kernel images
  79. mkdir -p "${destdir}/boot"
  80. cp -p .config "${destdir}/boot/config-generic-${strver}"
  81. cp -p System.map "${destdir}/boot/System.map-generic-${strver}"
  82. if test -e "arch/${kernel_arch}/boot/bzImage"
  83. then
  84. cp -p "arch/${kernel_arch}/boot/bzImage" \
  85. "${destdir}/boot/vmlinuz-generic-${strver}"
  86. elif test -e "arch/${kernel_arch}/boot/zImage"
  87. then
  88. cp -p "arch/${kernel_arch}/boot/zImage" \
  89. "${destdir}/boot/vmlinuz-generic-${strver}"
  90. else
  91. echo "${0}: No kernel image found: bzImage or zImage" 1>&2
  92. exit 1;
  93. fi
  94. # Exclude files from the Graft installation,
  95. # this will be copied via post-intall, since
  96. # /boot could be a separated partition
  97. touch "${destdir}/boot/.nograft"
  98. # Insert post-install script manually
  99. # This must be recreated on post-installation
  100. rm -f "${destdir}"/lib/modules/${strver}/build \
  101. "${destdir}"/lib/modules/${strver}/source
  102. mkdir -p "${destdir}/var/lib/qi"
  103. cat << EOF > "${destdir}/var/lib/qi/${full_pkgname}.sh"
  104. # Kernel string version
  105. strver=$strver
  106. # Copy kernel image from 'packagedir' to 'rootdir/boot'
  107. mkdir -p -- "\${rootdir}/boot"
  108. cp -pf -- "\$rootdir${packagedir}/${full_pkgname}/boot/System.map-generic-${strver}" \\
  109. "\${rootdir}/boot/"
  110. cp -pf -- "\$rootdir${packagedir}/${full_pkgname}/boot/config-generic-${strver}" \\
  111. "\${rootdir}/boot/"
  112. cp -pf -- "\$rootdir${packagedir}/${full_pkgname}/boot/vmlinuz-generic-${strver}" \\
  113. "\${rootdir}/boot/"
  114. # Make generic symlinks for this kernel version
  115. srcdir="${srcdir##*/}"
  116. (
  117. cd lib/modules/${strver} || exit 1
  118. rm -f build source
  119. ln -sf /usr/src/${srcdir} build
  120. ln -sf /usr/src/${srcdir} source
  121. )
  122. # Generate or update the module dependency list
  123. chroot . /sbin/depmod -a $strver
  124. EOF
  125. }