recipe 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. # Build recipe for kmod.
  2. #
  3. # Copyright (c) 2017-2019 Matias Fonzo, <selk@dragora.org>.
  4. # Copyright (c) 2021 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=27
  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://www.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-27_lzip-0.diff"
  46. autoreconf -vif
  47. # --enable-static is not supported by kmod
  48. ./configure CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
  49. lzlib_LIBS="-llz" lzlib_CFLAGS="-llz" \
  50. $configure_args \
  51. --libdir=/usr/lib${libSuffix} \
  52. --infodir=$infodir \
  53. --mandir=$mandir \
  54. --docdir=$docsdir \
  55. --disable-static \
  56. --enable-shared \
  57. --enable-tools \
  58. --with-rootlibdir=/usr/lib${libSuffix} \
  59. --with-openssl \
  60. --with-zlib \
  61. --with-lzlib \
  62. --without-xz \
  63. --build="$(gcc -dumpmachine)"
  64. make -j${jobs} V=1
  65. make -j${jobs} DESTDIR="$destdir" install-strip
  66. # Make symlinks for compatibility
  67. mkdir -p "${destdir}/usr/sbin"
  68. for target in depmod insmod lsmod modinfo modprobe rmmod
  69. do
  70. ( cd "${destdir}/usr/sbin" && ln -sf ../bin/kmod $target )
  71. done
  72. # For user invocation
  73. ( cd "${destdir}/usr/bin" && ln -sf ../bin/kmod lsmod )
  74. # Prepare directories / files for modprobe
  75. mkdir -p "${destdir}/lib/modprobe.d" "${destdir}/etc/modprobe.d"
  76. for file in "${worktree}"/archive/kmod/etc/modprobe.d/*
  77. do
  78. cp -p $file "${destdir}/etc/modprobe.d/"
  79. chmod 644 "${destdir}/etc/modprobe.d/${file##*/}"
  80. done
  81. # To manage (dot) new files
  82. touch "${destdir}/etc/modprobe.d/.graft-config"
  83. # Compress info documents deleting index file for the package
  84. if test -d "${destdir}/$infodir"
  85. then
  86. rm -f "${destdir}/${infodir}/dir"
  87. lzip -9 "${destdir}/${infodir}"/*
  88. fi
  89. # Compress and link man pages (if needed)
  90. if test -d "${destdir}/$mandir"
  91. then
  92. (
  93. cd "${destdir}/$mandir"
  94. find . -type f -exec lzip -9 {} +
  95. find . -type l | while read -r file
  96. do
  97. ln -sf "$(readlink -- "$file").lz" "${file}.lz"
  98. rm -- "$file"
  99. done
  100. )
  101. fi
  102. # Copy documentation
  103. mkdir -p "${destdir}${docsdir}"
  104. cp -p $docs "${destdir}${docsdir}"
  105. }