recipe 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. # Build recipe for os-prober.
  2. #
  3. # Copyright (c) 2019, 2021 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=os-prober
  19. version=1.79
  20. release=1
  21. # Define a category for the output of the package name
  22. pkgcategory=boot
  23. tarname=${program}_${version}.tar.xz
  24. # Remote source(s)
  25. fetch=https://deb.debian.org/debian/pool/main/o/os-prober/$tarname
  26. description="
  27. Utility to detect other OSes on a set of drives.
  28. This package detects other OSes available on a system and outputs
  29. the results in a generic machine-readable format.
  30. "
  31. homepage=https://joeyh.name/code/os-prober/
  32. license=GPLv2+
  33. # Source documentation
  34. docs="README TODO debian/changelog debian/copyright"
  35. docsdir="${docdir}/${program}-${version}"
  36. # The source directory has a custom name
  37. srcdir=${program}
  38. build()
  39. {
  40. unpack "${tardir}/$tarname"
  41. cd "$srcdir"
  42. # Import patches from Fedora to make os-prober more reliable
  43. patch -Np1 -i "${worktree}/patches/os-prober/os-prober-no-dummy-mach-kernel.patch"
  44. # Sent upstream
  45. patch -Np1 -i "${worktree}/patches/os-prober/os-prober-mdraidfix.patch"
  46. patch -Np1 -i "${worktree}/patches/os-prober/os-prober-btrfsfix.patch"
  47. patch -Np1 -i "${worktree}/patches/os-prober/os-prober-bootpart-name-fix.patch"
  48. patch -Np1 -i "${worktree}/patches/os-prober/os-prober-mounted-partitions-fix.patch"
  49. patch -Np1 -i "${worktree}/patches/os-prober/os-prober-factor-out-logger.patch"
  50. # To be sent upstream
  51. patch -Np1 -i "${worktree}/patches/os-prober/os-prober-factored-logger-efi-fix.patch"
  52. patch -Np1 -i "${worktree}/patches/os-prober/os-prober-umount-fix.patch"
  53. patch -Np1 -i "${worktree}/patches/os-prober/os-prober-grub2-parsefix.patch"
  54. patch -Np1 -i "${worktree}/patches/os-prober/os-prober-grepfix.patch"
  55. patch -Np1 -i "${worktree}/patches/os-prober/os-prober-gentoo-fix.patch"
  56. # Use 'libsuffix' if defined
  57. if test -n "$libSuffix"
  58. then
  59. find . -type f -exec sed -i -e "s|usr/lib|usr/lib${libSuffix}|g" {} \;
  60. fi
  61. # Set sane permissions
  62. chmod -R u+w,go-w,a+rX-s .
  63. make -j${jobs} V=1 CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS -static"
  64. mkdir -p "${destdir}/usr/bin"
  65. cp -p linux-boot-prober "${destdir}/usr/bin"
  66. cp -p os-prober "${destdir}/usr/bin"
  67. chmod 755 "${destdir}/usr/bin"/*
  68. mkdir -p "${destdir}/usr/lib${libSuffix}/os-prober"
  69. cp -p newns "${destdir}/usr/lib${libSuffix}/os-prober"
  70. chmod 755 "${destdir}/usr/lib${libSuffix}/os-prober/newns"
  71. # linux-boot-probes
  72. mkdir -p "${destdir}/usr/lib${libSuffix}/linux-boot-probes/mounted"
  73. cd linux-boot-probes
  74. for file in mounted/common/* mounted/x86/*
  75. do
  76. test -f "$file" || continue
  77. echo "Copying linux-boot-probes/${file} ..."
  78. cp -p $file \
  79. "${destdir}/usr/lib${libSuffix}/linux-boot-probes/mounted/"
  80. chmod 755 \
  81. "${destdir}/usr/lib${libSuffix}/linux-boot-probes/mounted/${file##*/}"
  82. done
  83. unset -v file
  84. cp -p common/50mounted-tests \
  85. "${destdir}/usr/lib${libSuffix}/linux-boot-probes"
  86. chmod 755 \
  87. "${destdir}/usr/lib${libSuffix}/linux-boot-probes/50mounted-tests"
  88. cd ..
  89. # End of linux-boot-probes
  90. # os-probes
  91. mkdir -p "${destdir}/usr/lib${libSuffix}/os-probes/mounted/efi"
  92. cd os-probes
  93. for file in mounted/common/* mounted/x86/*
  94. do
  95. test -f "$file" || continue
  96. echo "Copying os-probes/${file} ..."
  97. cp -p $file \
  98. "${destdir}/usr/lib${libSuffix}/os-probes/mounted/"
  99. chmod 755 \
  100. "${destdir}/usr/lib${libSuffix}/os-probes/mounted/${file##*/}"
  101. done
  102. unset -v file
  103. cp -p mounted/x86/efi/* \
  104. "${destdir}/usr/lib${libSuffix}/os-probes/mounted/efi"
  105. mkdir -p "${destdir}/usr/lib${libSuffix}/os-probes/init"
  106. cp -p init/common/* "${destdir}/usr/lib${libSuffix}/os-probes/init"
  107. cp -p common/50mounted-tests \
  108. "${destdir}/usr/lib${libSuffix}/os-probes"
  109. chmod 755 \
  110. "${destdir}/usr/lib${libSuffix}/os-probes/50mounted-tests"
  111. cp -p mounted/powerpc/20macosx \
  112. "${destdir}/usr/lib${libSuffix}/os-probes/mounted"
  113. chmod 755 "${destdir}/usr/lib${libSuffix}/os-probes/mounted/20macosx"
  114. cd ..
  115. # End of os-probes
  116. mkdir -p "${destdir}/usr/share/os-prober"
  117. cp -p common.sh "${destdir}/usr/share/os-prober"
  118. chmod 755 "${destdir}/usr/share/os-prober/common.sh"
  119. # Create local state directory
  120. mkdir -p "${destdir}/var/lib/os-prober"
  121. # Copy documentation
  122. mkdir -p "${destdir}/$docsdir"
  123. cp -p $docs "${destdir}/$docsdir"
  124. }