gnunet-bugreport 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  1. #!/bin/sh
  2. #
  3. # Caveats:
  4. # - checks with textprocessing assuming that system language is English.
  5. # - maybe check last return status instead?
  6. # - Do we need to set awk to which awk becomes available or is awk
  7. # always available as just awk?
  8. #
  9. # Dedicated to the Public Domain.
  10. # SPDX-License-Identifier: 0BSD
  11. progname=${0##*/}
  12. statusmsg()
  13. {
  14. echo " $@"
  15. }
  16. infomsg()
  17. {
  18. statusmsg "INFO: $@"
  19. }
  20. warningmsg()
  21. {
  22. statusmsg "WARNING: $@"
  23. }
  24. errormsg()
  25. {
  26. statusmsg "ERROR: $@"
  27. }
  28. linemsg()
  29. {
  30. statusmsg "========================================="
  31. }
  32. errmsg=''
  33. # Check if shell supports builtin 'type'.
  34. if test -z "$errmsg"; then
  35. if ! (eval 'type type') >/dev/null 2>&1
  36. then
  37. errmsg='Shell does not support type builtin'
  38. exit 1
  39. fi
  40. fi
  41. os_check()
  42. {
  43. OS=`uname -s 2>/dev/null`
  44. infomsg "OS : $OS"
  45. REL=`uname -r 2>/dev/null`
  46. infomsg "OS RELEASE : $REL"
  47. HW=`uname -m 2>/dev/null`
  48. infomsg "HARDWARE : $HW"
  49. }
  50. # We shouldn't use awk to test for awk... but if
  51. # awk isn't there it can't be found.
  52. awk_check()
  53. {
  54. if test -z "`type awk | awk '/not found/'`"; then
  55. infomsg "awk : Found"
  56. else
  57. warningmsg "awk : Not found!"
  58. exit 1
  59. fi
  60. }
  61. gcc_check()
  62. {
  63. if test -z "`type gcc | awk '/not found/' 2>/dev/null`"; then
  64. VERS=`gcc --version 2>/dev/null | head -n 1`
  65. infomsg "gcc : $VERS"
  66. elif test -n "`gcc 2>&1 | tail -1 | awk '{print $1}'`"; then
  67. VERS=`gcc --version 2>/dev/null | head -n 1`
  68. infomsg "gcc : $VERS"
  69. else
  70. warningmsg "gcc : Not Found";
  71. fi
  72. }
  73. cc_check()
  74. {
  75. if test -z "`type cc | awk '/not found/' 2>/dev/null`"; then
  76. VERS=`cc --version 2>/dev/null | head -n 1`
  77. infomsg "cc : $VERS"
  78. else
  79. warningmsg "cc : Not Found";
  80. fi
  81. }
  82. cplusplus_check()
  83. {
  84. if test -z "`type c++ | awk '/not found/' 2>/dev/null`"; then
  85. VERS=`c++ --version 2>/dev/null | head -n 1`
  86. infomsg "c++ : $VERS"
  87. else
  88. warningmsg "c++ : Not Found";
  89. fi
  90. }
  91. clang_check()
  92. {
  93. TEST=`type clang | awk '/not found/' 2>/dev/null`
  94. if test -z "$TEST"; then
  95. VERS=`clang --version 2>/dev/null | head -n 1`
  96. infomsg "clang : $VERS"
  97. elif test -n "`clang 2>&1 | tail -1 | awk '{print $1}'`"; then
  98. VERS=`clang --version 2>/dev/null | head -n 1`
  99. infomsg "clang : $VERS"
  100. else
  101. warningmsg "clang : Not Found";
  102. fi
  103. }
  104. clangplusplus_check()
  105. {
  106. TEST=`type clang++ | awk '/not found/' 2>/dev/null`
  107. if test -n "$TEST"; then
  108. VERS=`clang++ --version 2>/dev/null | head -n 1`
  109. infomsg "clang++ : $VERS"
  110. elif test -n "`clang++ 2>&1 | tail -1 | awk '{print $1}'`"; then
  111. VERS=`clang++ --version 2>/dev/null | head -n 1`
  112. infomsg "clang++ : $VERS"
  113. else
  114. warningmsg "clang++ : Not Found";
  115. fi
  116. }
  117. gmake_check()
  118. {
  119. TEST=`type gmake | awk '/not found/' 2>/dev/null`
  120. if test -z "$TEST" ; then
  121. VER=$(gmake --version 2>/dev/null | awk '/GNU Make/ {print $3}')
  122. infomsg "gmake : $VER"
  123. else
  124. TEST=`make --version 2>/dev/null`
  125. if test -n "$TEST"; then
  126. VER=$(make --version 2>/dev/null | awk '/GNU Make/ {print $3}')
  127. infomsg "gmake : $VER"
  128. else
  129. warningmsg "gmake : Not Found"
  130. fi
  131. fi
  132. }
  133. # Applies at least for NetBSD make. This test is a little awkward,
  134. # we should probably grep the output of 'make -dA'. nbmake identifies,
  135. # NetBSD make from NetBSD (nbmake is portable, external) does not identify.
  136. make_check()
  137. {
  138. TEST=`type make | awk '/not found/' 2>/dev/null`
  139. if test -z "$TEST"; then
  140. VER=$(make --version 2>/dev/null | awk '// {print $0}')
  141. if test -z "$VER"; then
  142. infomsg "make : Found"
  143. else
  144. warningmsg "make : Not Found (unexpected result)"
  145. fi
  146. fi
  147. }
  148. autoconf_check()
  149. {
  150. TEST=`type autoconf | awk '/not found/' 2>/dev/null`
  151. if test -z "$TEST"; then
  152. autoconf --version |\
  153. head -n 1 |\
  154. awk '{\
  155. if (length($4) == 0) {\
  156. print " INFO: autoconf : "$3\
  157. } else {\
  158. print " INFO: autoconf : "$4\
  159. }}'
  160. else
  161. warningmsg "autoconf : Not Found"
  162. fi
  163. }
  164. automake_check()
  165. {
  166. TEST=`type automake | awk '/not found/' 2>/dev/null`
  167. if test -z "$TEST"; then
  168. VER=`automake --version 2>/dev/null | head -n 1 | awk '{print $4}'`
  169. infomsg "automake : $VER"
  170. else
  171. warningmsg "automake : Not Found"
  172. fi
  173. }
  174. # TODO: More libtool variants.
  175. libtool_check()
  176. {
  177. TEST=`type libtoolize | awk '/not found/' 2>/dev/null`
  178. if test -z "$TEST"; then
  179. VER=`libtoolize --version 2>/dev/null | head -n 1 | awk '{print $4}'`
  180. infomsg "libtool : $VER"
  181. else
  182. warningmsg "libtool : Not Found"
  183. fi
  184. }
  185. libextractor_check()
  186. {
  187. TEST=`type extract | awk '/not found/' 2>/dev/null`
  188. if test -z "$TEST"; then
  189. TEST=`strings $(type extract | awk '{print $NF}') | awk '/EXTRACTOR_extract/' 2>/dev/null`
  190. if test -n "$TEST"; then
  191. VER=`extract -v 2>/dev/null | awk '{gsub("v",""); print $NF}'`
  192. infomsg "libextractor : $VER"
  193. else
  194. warningmsg "libextractor : Not Found"
  195. fi
  196. fi
  197. }
  198. gnunet_version_check()
  199. {
  200. # historical, should not be matched
  201. T08=`type gnunetd | awk '/not found/' 2>/dev/null`
  202. if test -z "$T08"; then
  203. VER08=`gnunetd -v | awk '{if(/0.8/) { gsub("v",""); print $2}}'`
  204. infomsg "GNUnet 0.8 : Not Found (good)"
  205. # else
  206. # warningmsg "GNUnet 0.8 : $VER08 (may conflict!)"
  207. fi
  208. TEST=`type gnunet-arm | awk '/not found/' 2>/dev/null`
  209. if test -z "$TEST"; then
  210. gnunet-arm --version |\
  211. awk '{\
  212. if (/not found/) {\
  213. print " INFO: GNUnet : Not found"\
  214. } else if (/[0-9]/) {\
  215. gsub("v",""); print " INFO: GNUnet : "$2\
  216. } else {\
  217. print " INFO: GNUnet : Test failed"\
  218. }}'
  219. else
  220. warningmsg "GNUnet : Not Found"
  221. fi
  222. }
  223. gitcommit_check()
  224. {
  225. TEST=$(type git | awk '/not found/' 2> /dev/null)
  226. if test -z "$TEST"; then
  227. VER=$(git rev-parse HEAD)
  228. infomsg "git commit : $VER"
  229. else
  230. warningmsg "git commit : Not a git checkout"
  231. fi
  232. }
  233. gcrypt_check()
  234. {
  235. TEST=`type libgcrypt-config | awk '/not found/' 2> /dev/null`
  236. if test -z "$TEST"; then
  237. VER=`libgcrypt-config --version 2> /dev/null`
  238. infomsg "libgcrypt : $VER"
  239. else
  240. warningmsg "libgcrypt : Not Found"
  241. fi
  242. }
  243. mysql_check()
  244. {
  245. TEST=`type mysql_config | awk '/not found/' 2> /dev/null`
  246. if test -z "$TEST"; then
  247. VER=`mysql_config --version 2> /dev/null`
  248. infomsg "mysql : $VER"
  249. else
  250. infomsg "mysql : Not Found"
  251. fi
  252. }
  253. pkgconf_check()
  254. {
  255. TEST=`type pkgconf | awk '/not found/' 2> /dev/null`
  256. if test -z "$TEST"; then
  257. pkgconf --version 2> /dev/null | awk '{print " INFO: pkgconf : "$1}'
  258. else
  259. infomsg "pkgconf : Not Found"
  260. fi
  261. TEST=`type pkg-config | awk '/not found/' 2> /dev/null`
  262. if test -z "$TEST"; then
  263. VER=`pkg-config --version 2> /dev/null | awk '{print $1}'`
  264. infomsg "pkg-config : $VER"
  265. else
  266. infomsg "pkg-config : Not Found"
  267. fi
  268. }
  269. glib2_check()
  270. {
  271. TEST=`type pkg-config | awk '/not found/' 2> /dev/null`
  272. if test -z "$TEST"; then
  273. VER=`pkg-config --modversion glib-2.0 2> /dev/null | awk '{print $1}'`
  274. infomsg "glib2 : $VER"
  275. else
  276. infomsg "glib2 : Not Found"
  277. fi
  278. }
  279. gtk_check()
  280. {
  281. TEST=`type pkg-config | awk '/not found/' 2> /dev/null`
  282. if test -z "$TEST"; then
  283. VER=`pkg-config --modversion gtk+-2.0 2> /dev/null | awk '{print $1}'`
  284. if test -n "$VER"; then
  285. infomsg "GTK2 : $VER"
  286. else
  287. infomsg "GTK2 : Not found"
  288. fi
  289. else
  290. infomsg "GTK2 : Not Found"
  291. fi
  292. if test -z "$TEST"; then
  293. VER=`pkg-config --modversion gtk+-3.0 2> /dev/null | awk '{print $1}'`
  294. if test -n "$VER"; then
  295. infomsg "GTK3 : $VER"
  296. else
  297. infomsg "GTK3 : Not found"
  298. fi
  299. else
  300. infomsg "GTK3 : Not Found"
  301. fi
  302. if test -z "$TEST"; then
  303. VER=`pkg-config --modversion gtk+-4.0 2> /dev/null | awk '{print $1}'`
  304. if test -z "$VER"; then
  305. infomsg "GTK4 : $VER"
  306. else
  307. infomsg "GTK4 : Not found"
  308. fi
  309. else
  310. infomsg "GTK4 : Not Found"
  311. fi
  312. }
  313. gmp_check()
  314. {
  315. TEST=`type dpkg | awk '/not found/' 2> /dev/null`
  316. if test -z "$TEST"; then
  317. LINES=`dpkg -s libgmp-dev | grep Version | wc -l 2> /dev/null`
  318. if test "$LINES" = "1"
  319. then
  320. VERSION=`dpkg -s libgmp-dev | grep Version | awk '{print $2}'`
  321. infomsg "GMP : libgmp-dev-$VERSION.deb"
  322. else
  323. errormsg "GMP : dpkg: libgmp-dev not installed"
  324. fi
  325. else
  326. TEST=`type rpm | awk '/not found/' 2> /dev/null`
  327. if test -z "$TEST"; then
  328. rpm -q gmp | sed -e "s/gmp-//" 2> /dev/null | \
  329. infomsg "GMP : $1.rpm"
  330. else
  331. infomsg "GMP : Test not available"
  332. fi
  333. TEST=$(type pkg_info | awk '/not found/' 2> /dev/null)
  334. if test -z "$TEST"; then
  335. VER=$(pkg_info -e gmp)
  336. infomsg "GMP : $VER"
  337. else
  338. infomsg "GMP : Test not available"
  339. fi
  340. fi
  341. }
  342. libunistring_check()
  343. {
  344. TEST=`type dpkg | awk '/not found/' 2> /dev/null`
  345. if test -z "$TEST"; then
  346. LINES=`dpkg -s libunistring-dev | awk '/Version/' | wc -l`
  347. if test "$LINES" = "1"
  348. then
  349. VERSION=`dpkg -s libunistring-dev | awk '/Version/ {print $2}'`
  350. infomsg "libunistring : libunistring3-dev-$VERSION.deb"
  351. else
  352. errormsg "libunistring : dpkg: libunistring3-dev not installed"
  353. fi
  354. else
  355. TEST=`type rpm | awk '/not found/' 2> /dev/null`
  356. if test -z "$TEST"; then
  357. rpm -q unistring | sed -e "s/unistring-//" 2> /dev/null | \
  358. awk '{print "libunistring : "$1.rpm}'
  359. else
  360. infomsg "libunistring : Test not available"
  361. fi
  362. TEST=$(type pkg_info | awk '/not found/' 2> /dev/null)
  363. if test -z "$TEST"; then
  364. VER=$(pkg_info -e libunistring)
  365. infomsg "libunistring : $VER"
  366. else
  367. infomsg "libunistring : Test not available"
  368. fi
  369. fi
  370. }
  371. gnugettext_check()
  372. {
  373. TEST=`type gettext | awk '/not found/'`
  374. if test -z "$TEST"; then
  375. if test -n "$(gettext --version 2>&1 | awk '/unknown option/')"; then
  376. infomsg "GNU gettext : Not found"
  377. else
  378. VER=`gettext --version | awk '/GNU gettext/ {print $4}'`
  379. infomsg "GNU gettext : $VER"
  380. fi
  381. fi
  382. }
  383. gettext_check()
  384. {
  385. if test -z "`type gettext | awk '/not found/'`"; then
  386. infomsg "gettext : Found"
  387. else
  388. infomsg "gettext : Not Found"
  389. fi
  390. }
  391. gnurl_curl_check()
  392. {
  393. TESTCURL=`type curl-config | awk '/not found/' 2> /dev/null`
  394. if test -z "$TESTCURL"; then
  395. VER=`curl-config --version 2> /dev/null | awk '{print $NF}'`
  396. infomsg "libcurl : $VER"
  397. else
  398. infomsg "libcurl : Not found"
  399. fi
  400. TESTGNURL=`type gnurl-config | awk '/not found/' 2> /dev/null`
  401. if test -z "$TESTGNURL"; then
  402. VER=`gnurl-config --version 2>&1 /dev/null | awk '{print $NF}'`
  403. infomsg "libgnurl : $VER"
  404. else
  405. infomsg "libgnurl : Not found"
  406. fi
  407. if test -z "$TESTCURL" -a "$TESTGNURL"; then
  408. warningmsg "libgnurl or libcurl : Not found"
  409. fi
  410. }
  411. libmicrohttpd_check()
  412. {
  413. TMPFILE="bugreport-test_lmhd.c"
  414. cat - >$TMPFILE <<EOF
  415. #include <microhttpd.h>
  416. #include <stdio.h>
  417. int main()
  418. {
  419. fprintf (stdout, "%X\n", MHD_VERSION);
  420. return 0;
  421. }
  422. EOF
  423. if test -x `type gcc | awk '{print $NF}'`; then
  424. gcc $CPPFLAGS $CFLAGS -o "$TMPFILE".bin "$TMPFILE"
  425. VER=`./"$TMPFILE".bin`
  426. elif test -x `type cc | awk '{print $NF}'`; then
  427. cc $CPPFLAGS $CFLAGS -o $TMPFILE.bin $TMPFILE
  428. VER=`./$TMPFILE.bin`
  429. else
  430. VER="Not found"
  431. fi
  432. infomsg "libmicrohttpd : $VER"
  433. rm -f $TMPFILE.c $TMPFILE $TMPFILE.bin
  434. }
  435. glpk_check()
  436. {
  437. TMPFILE="bugreport-glpk_check.c"
  438. cat - >$TMPFILE <<EOF
  439. #include <glpk.h>
  440. #include <stdio.h>
  441. int main()
  442. {
  443. fprintf (stdout, "%u.%u\n", GLP_MAJOR_VERSION, GLP_MINOR_VERSION);
  444. return 0;
  445. }
  446. EOF
  447. if test -x `type gcc | awk '{print $NF}'`; then
  448. gcc $CPPFLAGS $CFLAGS -o "$TMPFILE".bin $TMPFILE
  449. VER=`./$TMPFILE.bin`
  450. elif test -x `type cc | awk '{print $NF}'`; then
  451. cc $CPPFLAGS $CFLAGS -o "$TMPFILE".bin $TMPFILE
  452. VER=`./"$TMPFILE".bin`
  453. else
  454. VER="Not found"
  455. fi
  456. infomsg "GNU GLPK : $VER"
  457. rm -f $TMPFILE.c $TMPFILE $TMPFILE.bin
  458. }
  459. gnutls_check()
  460. {
  461. TMPFILE="bugreport-gnutls_check.c"
  462. cat - >$TMPFILE <<EOF
  463. #include <gnutls/gnutls.h>
  464. #include <stdio.h>
  465. int main()
  466. {
  467. fprintf (stdout, "%s\n", GNUTLS_VERSION);
  468. return 0;
  469. }
  470. EOF
  471. if test -x `type gcc | awk '{print $NF}'`; then
  472. gcc $CPPFLAGS $CFLAGS -o "$TMPFILE".bin $TMPFILE
  473. VER=`./"$TMPFILE".bin`
  474. elif test -x `type cc | awk '{print $NF}'`; then
  475. cc $CPPFLAGS $CFLAGS -o "$TMPFILE".bin $TMPFILE
  476. VER=`./"$TMPFILE".bin`
  477. else
  478. VER="Not found"
  479. fi
  480. infomsg "GnuTLS : $VER"
  481. rm -f $TMPFILE.c $TMPFILE $TMPFILE.bin
  482. }
  483. main()
  484. {
  485. if test -n "$1" -a "$1" = "-h" -o "$1" = "--help"; then
  486. echo "Usage: ${progname} [-h]"
  487. echo "If CPPFLAGS and LDFLAGS are unset, try:"
  488. echo "CPPFLAGS='-I/usr/pkg/include' LDFLAGS='-L/usr/pkg/lib' ${progname}"
  489. return 0
  490. fi
  491. infomsg "${progname} 0.11.0"
  492. infomsg
  493. infomsg "Please submit the following"
  494. infomsg "information with your bug report:"
  495. linemsg
  496. os_check
  497. awk_check
  498. gcc_check
  499. cc_check
  500. cplusplus_check
  501. clang_check
  502. clangplusplus_check
  503. make_check
  504. gmake_check
  505. autoconf_check
  506. automake_check
  507. libtool_check
  508. libextractor_check
  509. gnunet_version_check
  510. gitcommit_check
  511. gcrypt_check
  512. mysql_check
  513. pkgconf_check
  514. glib2_check
  515. gtk_check
  516. gmp_check
  517. libunistring_check
  518. gnugettext_check
  519. gettext_check
  520. gnurl_curl_check
  521. libmicrohttpd_check
  522. glpk_check
  523. gnutls_check
  524. linemsg
  525. infomsg "Bug report saved in ./my_gnunet_bugreport.log"
  526. }
  527. main "$@" 2>&1 | tee "my_gnunet_bugreport.log"