90linux-distro 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. #!/bin/sh
  2. # Test for linux distributions.
  3. set -e
  4. . /usr/share/os-prober/common.sh
  5. partition="$1"
  6. dir="$2"
  7. type="$3"
  8. # This test is inaccurate, but given separate / and /boot partitions and the
  9. # fact that only some architectures have ld-linux.so, I can't see anything
  10. # better. Make sure this test has a high number so that more accurate tests
  11. # can come first.
  12. # Unless volumes to checked are already mounted, they will be mounted using
  13. # GRUB's own filesystems through FUSE. Since these ATM doesn't support
  14. # symlinks we need to also check in $dir/usr/lib* for distributions that
  15. # moved /lib* to /usr and only left symlinks behind.
  16. # TODO: look for ld-linux.so on arches that have it
  17. if (ls "$dir"/lib*/ld*.so* && [ -d "$dir/boot" ] || ls "$dir"/usr/lib*/ld*.so*) >/dev/null 2>/dev/null; then
  18. if [ -e "$dir/etc/os-release" ]; then
  19. short="$(grep ^NAME= "$dir/etc/os-release" | sed 's/^[^=]*=//; s/^['\''"]\(.*\)['\''"]$/\1/; s/\\\(.\)/\1/g; s/[[:space:]].*//')"
  20. long="$(grep ^PRETTY_NAME= "$dir/etc/os-release" | sed 's/^[^=]*=//; s/^['\''"]\(.*\)['\''"]$/\1/; s/\\\(.\)/\1/g')"
  21. elif [ -e "$dir/etc/debian_version" ]; then
  22. short="Debian"
  23. long="$(printf "Debian GNU/Linux (%s)\n" "$(cat "$dir/etc/debian_version")")"
  24. # RPM derived distributions may also have a redhat-release or
  25. # mandrake-release, so check their files first.
  26. elif [ -e "$dir/etc/altlinux-release" ]; then
  27. short="ALTLinux"
  28. long="$(cat "$dir/etc/altlinux-release")"
  29. elif [ -e "$dir/etc/magic-release" ]; then
  30. short="Magic"
  31. long="$(cat "$dir/etc/magic-release")"
  32. elif [ -e "$dir/etc/blackPanther-release" ]; then
  33. short="blackPanther"
  34. long="$(cat "$dir/etc/blackPanther-release")"
  35. elif [ -e "$dir/etc/ark-release" ]; then
  36. short="Ark"
  37. long="$(cat "$dir/etc/ark-release")"
  38. elif [ -e "$dir/etc/arch-release" ]; then
  39. short="Arch"
  40. long="$(cat "$dir/etc/arch-release")"
  41. elif [ -e "$dir/etc/asplinux-release" ]; then
  42. short="ASPLinux"
  43. long="$(cat "$dir/etc/asplinux-release")"
  44. elif [ -e "$dir/etc/lvr-release" ]; then
  45. short="LvR"
  46. long="$(cat "$dir/etc/lvr-release")"
  47. elif [ -e "$dir/etc/caos-release" ]; then
  48. short="cAos"
  49. long="$(cat "$dir/etc/caos-release")"
  50. elif [ -e "$dir/etc/aurox-release" ]; then
  51. short="Aurox"
  52. long="$(cat "$dir/etc/aurox-release")"
  53. elif [ -e "$dir/etc/engarde-release" ]; then
  54. short="EnGarde"
  55. long="$(cat "$dir/etc/engarde-release")"
  56. elif [ -e "$dir/etc/vine-release" ]; then
  57. short="Vine"
  58. long="$(cat "$dir/etc/vine-release")"
  59. elif [ -e "$dir/etc/whitebox-release" ]; then
  60. short="WhiteBox"
  61. long="$(cat "$dir/etc/whitebox-release")"
  62. elif [ -e "$dir/etc/pld-release" ]; then
  63. short="PLD"
  64. long="$(cat "$dir/etc/pld-release")"
  65. elif [ -e "$dir/etc/startcom-release" ]; then
  66. short="StartCom"
  67. long="$(cat "$dir/etc/startcom-release")"
  68. elif [ -e "$dir/etc/trustix-release" ]; then
  69. short="Trustix"
  70. long="$(cat "$dir/etc/trustix-release")"
  71. elif [ -e "$dir/etc/openna-release" ]; then
  72. short="OpenNA"
  73. long="$(cat "$dir/etc/openna-release")"
  74. elif [ -e "$dir/etc/mageia-release" ]; then
  75. short="Mageia"
  76. long="$(cat "$dir/etc/mageia-release")"
  77. elif [ -e "$dir/etc/conectiva-release" ]; then
  78. short="Conectiva"
  79. long="$(cat "$dir/etc/conectiva-release")"
  80. elif [ -e "$dir/etc/mandrake-release" ]; then
  81. short="Mandrake"
  82. long="$(cat "$dir/etc/mandrake-release")"
  83. elif [ -e "$dir/etc/fedora-release" ]; then
  84. short="Fedora"
  85. long="$(cat "$dir/etc/fedora-release")"
  86. elif [ -e "$dir/etc/redhat-release" ]; then
  87. short="RedHat"
  88. long="$(cat "$dir/etc/redhat-release")"
  89. elif [ -e "$dir/etc/SuSE-release" ]; then
  90. short="SuSE"
  91. long="$(head -n 1 "$dir/etc/SuSE-release")"
  92. elif [ -e "$dir/etc/gentoo-release" ]; then
  93. short="Gentoo"
  94. long="$(cat "$dir/etc/gentoo-release")"
  95. elif [ -e "$dir/etc/cobalt-release" ]; then
  96. short="Cobalt"
  97. long="$(cat "$dir/etc/cobalt-release")"
  98. elif [ -e "$dir/etc/yellowdog-release" ]; then
  99. short="YellowDog"
  100. long="$(cat "$dir/etc/yellowdog-release")"
  101. elif [ -e "$dir/etc/turbolinux-release" ]; then
  102. short="Turbolinux"
  103. long="$(cat "$dir/etc/turbolinux-release")"
  104. elif [ -e "$dir/etc/pardus-release" ]; then
  105. short="Pardus"
  106. long="$(cat "$dir/etc/pardus-release")"
  107. elif [ -e "$dir/etc/kanotix-version" ]; then
  108. short="Kanotix"
  109. long="$(cat "$dir/etc/kanotix-version")"
  110. elif [ -e "$dir/etc/slackware-version" ]; then
  111. short="Slackware"
  112. long="$(printf "Slackware Linux (%s)\n" "$(cat "$dir/etc/slackware-version")")"
  113. elif [ -e "$dir/sbin/pkgtool" ]; then
  114. short="Slackware"
  115. long="Slackware Linux"
  116. elif grep -qs OpenLinux "$dir/etc/issue"; then
  117. short="Caldera"
  118. long="Caldera OpenLinux"
  119. elif [ -e "$dir/etc/frugalware-release" ]; then
  120. short="Frugalware Linux"
  121. long="$(cat "$dir/etc/frugalware-release")"
  122. elif [ -e "$dir/etc/kdemar-release" ]; then
  123. short="K-DEMar"
  124. long="$(printf "K-DEMar GNU/Linux (%s)\n" "$(cat "$dir/etc/kdemar-release")")"
  125. elif [ -e "$dir/etc/lfs-release" ]; then
  126. short="LFS"
  127. long="$(printf "Linux From Scratch (%s)\n" "$(cat "$dir/etc/lfs-release")")"
  128. elif [ -e "$dir/etc/meego-release" ]; then
  129. short="MeeGo"
  130. long="$(head -1 "$dir/etc/meego-release")"
  131. elif [ -e "$dir/etc/4MLinux-version" ]; then
  132. short="4MLinux"
  133. long="4MLinux $(head -1 "$dir/etc/4MLinux-version")"
  134. elif [ -e "$dir/etc/devuan_version" ]; then
  135. short="Devuan"
  136. long="$(printf "Devuan GNU/Linux (%s)\n" "$(cat "$dir/etc/devuan_version")")"
  137. else
  138. short="Linux"
  139. long="unknown Linux distribution"
  140. fi
  141. label="$(count_next_label "$short")"
  142. result "$partition:$long:$label:linux"
  143. exit 0
  144. else
  145. exit 1
  146. fi