i586 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. # Build instructions for GNU Linux-libre (i586+, generic).
  2. #
  3. # Copyright (c) 2022 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=4.14.281
  20. release=1
  21. # Define a category for the output of the package name
  22. pkgcategory=kernel
  23. tarname=${program}-${version}-gnu1.tar.lz
  24. # Remote source(s)
  25. fetch=https://linux-libre.fsfla.org/pub/linux-libre/releases/${version}-gnu1/$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 of
  30. Linux, suitable for use in Free System Distributions, removing software that is
  31. included without source code, with obfuscated or obscured source code, under
  32. non-Free Software licenses, that do not permit you to change the software so
  33. that it does what you wish, and that induces or requires you to install
  34. additional pieces of non-Free Software.
  35. This is a custom configuration for Dragora, which is for uni-processors, is
  36. intended to be or run on Intel 586 family (MMX) machines or higher.
  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-4.14.40_lzip-3.diff"
  49. # Support Reiserfs4 (Thanks to "Edward Shishkin")
  50. #
  51. # TODO: Needs a re-adaptation
  52. #patch -p1 < "${worktree}/patches/kernel/reiser4-for-4.14.1.patch"
  53. make mrproper
  54. echo "Copying config-i586_generic ..."
  55. cp -p "${worktree}/archive/kernel/config-i586_generic" .config
  56. # An environment variable for config purposes
  57. if test ! -z "$PRESERVE"
  58. then
  59. echo "PRESERVE has been set."
  60. exit 99;
  61. fi
  62. make -j${jobs} ARCH=i386 bzImage
  63. make -j${jobs} ARCH=i386 modules
  64. make -j${jobs} ARCH=i386 \
  65. INSTALL_MOD_PATH="$destdir" modules_install
  66. # To extract the kernel string version
  67. strver="$(ls -d "${destdir}"/lib/modules/*)"
  68. strver="${strver##*/}"
  69. # Install kernel images
  70. mkdir -p "${destdir}/boot"
  71. cp -p .config "${destdir}/boot/config-${arch}_generic-${strver}"
  72. cp -p System.map "${destdir}/boot/System.map-${arch}_generic-${strver}"
  73. if test -e "arch/i386/boot/bzImage"
  74. then
  75. cp -p "arch/i386/boot/bzImage" \
  76. "${destdir}/boot/vmlinuz-${arch}_generic-${strver}"
  77. elif test -e "arch/i386/boot/zImage"
  78. then
  79. cp -p "arch/i386/boot/zImage" \
  80. "${destdir}/boot/vmlinuz-${arch}_generic-${strver}"
  81. else
  82. echo "${0}: No kernel image found: bzImage or zImage" 1>&2
  83. exit 1;
  84. fi
  85. # Exclude files from the Graft installation,
  86. # this will be copied via post-intall, since
  87. # /boot could be a separated partition
  88. touch "${destdir}/boot/.nograft"
  89. # Insert post-install script manually
  90. # This must be recreated on post-installation
  91. rm -f "${destdir}"/lib/modules/${strver}/build \
  92. "${destdir}"/lib/modules/${strver}/source
  93. mkdir -p "${destdir}/var/lib/qi"
  94. cat << EOF > "${destdir}/var/lib/qi/${full_pkgname}.sh"
  95. # Kernel string version
  96. strver=$strver
  97. # Copy kernel image from 'packagedir' to 'rootdir/boot'
  98. mkdir -p -- "\${rootdir}/boot"
  99. cp -pf -- "\$rootdir${packagedir}/${full_pkgname}/boot/System.map-${arch}_generic-${strver}" \\
  100. "\${rootdir}/boot/"
  101. cp -pf -- "\$rootdir${packagedir}/${full_pkgname}/boot/config-${arch}_generic-${strver}" \\
  102. "\${rootdir}/boot/"
  103. cp -pf -- "\$rootdir${packagedir}/${full_pkgname}/boot/vmlinuz-${arch}_generic-${strver}" \\
  104. "\${rootdir}/boot/"
  105. # Make generic symlinks for this kernel version
  106. srcdir="${srcdir##*/}"
  107. (
  108. cd lib/modules/${strver} || exit 1
  109. rm -f build source
  110. ln -sf /usr/src/${srcdir} build
  111. ln -sf /usr/src/${srcdir} source
  112. )
  113. # Generate or update the module dependency list
  114. chroot "\$rootdir" /sbin/depmod -a $strver
  115. EOF
  116. # Preserve 'srcdir' in order to produce "kernel/buildtree-generic"
  117. keep_srcdir=keep_srcdir
  118. # Save 'version' and 'release' number to compose
  119. # variable values for "kernel/buildtree-generic"
  120. kernel_generic_version=$version
  121. kernel_generic_release=$release
  122. export keep_srcdir kernel_generic_version kernel_generic_release
  123. }