recipe 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. # Build recipe for kmod.
  2. #
  3. # Copyright (c) 2017-2019 Matias Fonzo, <selk@dragora.org>.
  4. # Copyright (c) 2021-2022 Matias Fonzo, <selk@dragora.org>.
  5. #
  6. # Licensed under the Apache License, Version 2.0 (the "License");
  7. # you may not use this file except in compliance with the License.
  8. # You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. # Exit immediately on any error
  18. set -e
  19. program=kmod
  20. version=29
  21. release=1
  22. # Define a category for the output of the package name
  23. pkgcategory=kernel
  24. tarname=${program}-${version}.tar.gz
  25. # Remote source(s)
  26. fetch=https://mirrors.edge.kernel.org/pub/linux/utils/kernel/kmod/$tarname
  27. description="
  28. Linux kernel module handling.
  29. kmod is a set of tools to handle common tasks with Linux kernel modules
  30. like insert, remove, list, check properties, resolve dependencies and
  31. aliases.
  32. "
  33. homepage=https://git.kernel.org/?p=utils/kernel/kmod/kmod.git
  34. license=LGPLv2.1
  35. # Source documentation
  36. docs="COPYING NEWS README TODO"
  37. docsdir="${docdir}/${program}-${version}"
  38. build()
  39. {
  40. unpack "${tardir}/$tarname"
  41. cd "$srcdir"
  42. # Set sane permissions
  43. chmod -R u+w,go-w,a+rX-s .
  44. # Add support for Kernel modules compressed with LZIP
  45. patch -p1 < "${worktree}/patches/kmod/kmod-29_lzip-0.diff"
  46. autoreconf -vif
  47. # --enable-static is not supported by kmod
  48. ./configure CPPFLAGS="$QICPPFLAGS" \
  49. CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
  50. lzlib_LIBS="-llz" lzlib_CFLAGS="-llz" \
  51. $configure_args \
  52. --libdir=/usr/lib${libSuffix} \
  53. --infodir=$infodir \
  54. --mandir=$mandir \
  55. --docdir=$docsdir \
  56. --disable-static \
  57. --enable-shared \
  58. --enable-tools \
  59. --with-rootlibdir=/usr/lib${libSuffix} \
  60. --with-openssl \
  61. --with-zlib \
  62. --with-lzlib \
  63. --without-xz \
  64. --build="$(gcc -dumpmachine)"
  65. make -j${jobs} V=1
  66. make -j${jobs} DESTDIR="$destdir" install-strip
  67. # Make symlinks for compatibility
  68. mkdir -p "${destdir}/usr/sbin"
  69. for target in depmod insmod lsmod modinfo modprobe rmmod
  70. do
  71. ( cd "${destdir}/usr/sbin" && ln -sf ../bin/kmod $target )
  72. done
  73. # For user invocation
  74. ( cd "${destdir}/usr/bin" && ln -sf ../bin/kmod lsmod )
  75. # Prepare directories / files for modprobe
  76. mkdir -p "${destdir}/usr/lib${libSuffix}/modprobe.d" \
  77. "${destdir}/etc/modprobe.d"
  78. for file in "${worktree}"/archive/kmod/etc/modprobe.d/*
  79. do
  80. cp -p $file "${destdir}/etc/modprobe.d/"
  81. chmod 644 "${destdir}/etc/modprobe.d/${file##*/}"
  82. done
  83. # To manage (dot) new files
  84. touch "${destdir}/etc/modprobe.d/.graft-config"
  85. # Compress info documents deleting index file for the package
  86. if test -d "${destdir}/$infodir"
  87. then
  88. rm -f "${destdir}/${infodir}/dir"
  89. lzip -9 "${destdir}/${infodir}"/*
  90. fi
  91. # Compress and link man pages (if needed)
  92. if test -d "${destdir}/$mandir"
  93. then
  94. (
  95. cd "${destdir}/$mandir"
  96. find . -type f -exec lzip -9 {} +
  97. find . -type l | while read -r file
  98. do
  99. ln -sf "$(readlink -- "$file").lz" "${file}.lz"
  100. rm -- "$file"
  101. done
  102. )
  103. fi
  104. # Copy documentation
  105. mkdir -p "${destdir}/$docsdir"
  106. cp -p $docs "${destdir}/$docsdir"
  107. }