amd64 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. # Build instructions for GNU Linux-libre (amd64, generic).
  2. #
  3. # Copyright (c) 2017-2024 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. # Exit immediately on any error
  17. set -e
  18. program=linux-libre
  19. version=6.1.23
  20. release=3
  21. # Define a category for the output of the package name
  22. pkgcategory=kernel
  23. tarname=${program}-${version}-gnu.tar.lz
  24. # Remote source(s)
  25. fetch=http://linux-libre.fsfla.org/pub/linux-libre/releases/${version}-gnu/$tarname
  26. homepage=https://www.gnu.org/software/linux-libre
  27. description="
  28. The GNU Linux-libre kernel (image and modules for ${arch}).
  29. GNU Linux-libre is a project to maintain and publish 100% Free distributions
  30. of Linux, suitable for use in Free System Distributions, removing software
  31. that is included without source code, with obfuscated or obscured source
  32. code, under non-Free Software licenses, that do not permit you to change
  33. the software so that it does what you wish, and that induces or requires
  34. you to install additional pieces of non-Free Software.
  35. This is a custom configuration for Dragora, intended to be generic and work
  36. well in all environments.
  37. "
  38. license="GPLv2 only"
  39. # Refresh 'srcdir'
  40. srcdir=linux-${version}
  41. build()
  42. {
  43. unpack "${tardir}/$tarname"
  44. cd "$srcdir"
  45. # Set sane permissions
  46. chmod -R u+w,go-w,a+rX-s .
  47. # Support LZIP (Thanks to the friend of the house "Antonio Diaz Diaz")
  48. patch -p1 < "${worktree}/patches/kernel/linux-6.1.11_lzip-0.diff"
  49. # Support Reiserfs4 (Thanks to "Edward Shishkin")
  50. #patch -p1 < "${worktree}/patches/kernel/reiser4-for-5.16.patch"
  51. make mrproper
  52. echo "Copying config-amd64_generic ..."
  53. cp -p "${worktree}/archive/kernel/config-amd64_generic" .config
  54. # An environment variable for config purposes
  55. if test ! -z "$PRESERVE"
  56. then
  57. echo "PRESERVE has been set."
  58. exit 99;
  59. fi
  60. make -j${jobs} ARCH=x86_64 HOSTCFLAGS="-D_GNU_SOURCE" bzImage
  61. make -j${jobs} ARCH=x86_64 HOSTCFLAGS="-D_GNU_SOURCE" modules
  62. make -j${jobs} ARCH=x86_64 HOSTCFLAGS="-D_GNU_SOURCE" \
  63. INSTALL_MOD_PATH="$destdir" modules_install
  64. # To extract the kernel string version
  65. strver="$(ls -d "${destdir}"/lib/modules/*)"
  66. strver="${strver##*/}"
  67. # Install kernel images
  68. mkdir -p "${destdir}/boot"
  69. cp -p .config "${destdir}/boot/config-${arch}_generic-${strver}"
  70. cp -p System.map "${destdir}/boot/System.map-${arch}_generic-${strver}"
  71. if test -e "arch/x86_64/boot/bzImage"
  72. then
  73. cp -p "arch/x86_64/boot/bzImage" \
  74. "${destdir}/boot/vmlinuz-${arch}_generic-${strver}"
  75. elif test -e "arch/x86_64/boot/zImage"
  76. then
  77. cp -p "arch/x86_64/boot/zImage" \
  78. "${destdir}/boot/vmlinuz-${arch}_generic-${strver}"
  79. else
  80. echo "${0}: No kernel image found: bzImage or zImage" 1>&2
  81. exit 1;
  82. fi
  83. # Exclude files from the Graft installation,
  84. # this will be copied via post-intall, since
  85. # /boot could be a separated partition
  86. touch "${destdir}/boot/.nograft"
  87. # Insert post-install script manually
  88. # This must be recreated on post-installation
  89. rm -f "${destdir}"/lib/modules/${strver}/build \
  90. "${destdir}"/lib/modules/${strver}/source
  91. mkdir -p "${destdir}/var/lib/qi"
  92. cat << EOF > "${destdir}/var/lib/qi/${full_pkgname}.sh"
  93. # Kernel string version
  94. strver=$strver
  95. # Copy kernel image from 'packagedir' to 'rootdir/boot'
  96. mkdir -p -- "\${rootdir}/boot"
  97. cp -pf -- "\$rootdir${packagedir}/${full_pkgname}/boot/System.map-${arch}_generic-${strver}" \\
  98. "\${rootdir}/boot/"
  99. cp -pf -- "\$rootdir${packagedir}/${full_pkgname}/boot/config-${arch}_generic-${strver}" \\
  100. "\${rootdir}/boot/"
  101. cp -pf -- "\$rootdir${packagedir}/${full_pkgname}/boot/vmlinuz-${arch}_generic-${strver}" \\
  102. "\${rootdir}/boot/"
  103. # Make generic symlinks for this kernel version
  104. srcdir="${srcdir##*/}"
  105. (
  106. cd lib/modules/${strver} || exit 1
  107. rm -f build source
  108. ln -sf /usr/src/${srcdir} build
  109. ln -sf /usr/src/${srcdir} source
  110. )
  111. # Generate or update the module dependency list
  112. chroot "\$rootdir" /sbin/depmod -a $strver
  113. EOF
  114. # Preserve 'srcdir' in order to produce "kernel/buildtree-generic"
  115. keep_srcdir=keep_srcdir
  116. # Save 'version' and 'release' number to compose
  117. # variable values for "kernel/buildtree-generic"
  118. kernel_generic_version=$version
  119. kernel_generic_release=$release
  120. export keep_srcdir kernel_generic_version kernel_generic_release
  121. }