Advertisement
Guest User

Untitled

a guest
Nov 9th, 2016
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 42.04 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # Build script for UHD+GnuRadio on Fedora and Ubuntu
  4. #
  5. #
  6. #
  7. # Updates: https://github.com/guruofquality/grextras/wiki
  8. # Updates: https://github.com/balint256/gr-baz.git
  9. #
  10. #
  11. #
  12. # Exit function--Id like to be able to upload stats to a website somewhere...
  13. #
  14. function doexit
  15. {
  16. cat <<"!EOF!"
  17.  
  18. =======================================================================
  19. If you have found this script useful and time-saving, consider a
  20. donation to help me keep build-gnuradio, simple_ra, SIDsuite,
  21. meteor_detector, simple_fm_rcv, and multimode maintained and up to date.
  22. A simple paypal transfer to mleech@ripnet.com is all you need to do.
  23. ======================================================================
  24. !EOF!
  25.  
  26. echo -n "Send success/fail info to sbrac.org?"
  27. read ans
  28. case $ans in
  29. y|Y|YES|yes|Yes)
  30. wget http://www.sbrac.org/bgrstats.php?status="$1"?systype=${SYSTYPE}?sysinfo="`uname -a`" >/dev/null 2>&1
  31. echo Thanks
  32. ;;
  33. esac
  34. exit
  35. }
  36.  
  37. function help {
  38. cat <<!EOF!
  39.  
  40. Usage: build-gnuradio [--help|-h] [-v|--verbose] [-jN] [-ja]
  41. [-l|--logfile logfile ] [-u|--users ulist] [-m] funcs
  42.  
  43. -m - Use HEAD of *master* branch, rather than *maint*.
  44. -o - Use v3.6.5.1
  45.  
  46. -v|--verbose - turn on verbose logging to stdout
  47.  
  48. -jN - have make use N concurrent jobs
  49.  
  50. -ja - have make use N concurrent jobs with auto setting of N
  51. (based on number of cpu cores on build system)
  52.  
  53.  
  54. -u|--users ul - add comma-separated users to 'usrp' group in addition
  55. to calling user ( $USER )
  56.  
  57.  
  58. -l|--logfile lf - log messages to 'lf'
  59. -ut <tag> - set tag for UHD checkout to <tag>
  60. -ucf <ucflags> - set UHD CMake flags to <ucflags>
  61. -gt <tag> - set tag for Gnu Radio checkout to <tag>
  62. -gcf <gcflags> - set Gnu Radio CMake flags to <gcflags>
  63. -e|--extras - add an item to "extras" to be built after Gnu Radio/UHD/gs-osmosdr
  64. available funcs are:
  65.  
  66. all - do all functions
  67. prereqs - install prerequisites
  68. gitfetch - use GIT to fetch Gnu Radio and UHD
  69. uhd_build - build only UHD
  70. firmware - fetch firmware/FPGA
  71. gnuradio_build - build only Gnu Radio
  72. mod_groups - modify the /etc/groups and add user to group 'usrp'
  73. mod_udev - add UDEV rule for USRP1
  74. mod_sysctl - modify SYSCTL for larger net buffers
  75. !EOF!
  76.  
  77. }
  78.  
  79. if [ $USER = root -o $UID -eq 0 ]
  80. then
  81. echo Please run this script as an ordinary user
  82. echo it will acquire root privileges as it needs them via \"sudo\".
  83. exit
  84. fi
  85.  
  86. VERBOSE=No
  87. JFLAG=""
  88. LOGDEV=/dev/null
  89. USERSLIST=None
  90. JOSHMODE=False
  91. UTAG=None
  92. GTAG=None
  93. export LC_LANG=C
  94. EXTRAS=""
  95. MASTER_MODE=0
  96. OLD_MODE=0
  97. PULLED_LIST="gnuradio uhd rtl-sdr gr-osmosdr gr-iqbal hackrf gr-baz bladeRF libairspy"
  98. which python3 >/dev/null 2>&1
  99. if [ $? -eq 0 ]
  100. then
  101. CMAKE_FLAG1=-DPythonLibs_FIND_VERSION:STRING="2.7"
  102. CMAKE_FLAG2=-DPythonInterp_FIND_VERSION:STRING="2.7"
  103. fi
  104. while :
  105. do
  106. case $1 in
  107. -ja)
  108. cnt=`grep 'processor.*:' /proc/cpuinfo|wc -l`
  109. cnt=`expr $cnt - 1`
  110. if [ $cnt -lt 1 ]
  111. then
  112. cnt=1
  113. fi
  114. JFLAG=-j$cnt
  115. shift
  116. ;;
  117.  
  118. -j[123456789])
  119. JFLAG=$1
  120. shift
  121. ;;
  122.  
  123. -v|--verbose)
  124. LOGDEV=/dev/stdout
  125. shift
  126. ;;
  127.  
  128. -l|--logfile)
  129. case $2 in
  130. /*)
  131. LOGDEV=$2
  132. ;;
  133. *)
  134. LOGDEV=`pwd`/$2
  135. ;;
  136. esac
  137. shift
  138. shift
  139. rm -f $LOGDEV
  140. echo $LOGDEV Starts at: `date` >>$LOGDEV 2>&1
  141. ;;
  142.  
  143. -u|--users)
  144. USERSLIST=$2
  145. shift
  146. shift
  147. ;;
  148.  
  149. -m|--master)
  150. MASTER_MODE=1
  151. shift
  152. ;;
  153.  
  154. -o|--old)
  155. OLD_MODE=1
  156. shift
  157. ;;
  158.  
  159. -h|--help)
  160. help
  161. exit
  162. ;;
  163.  
  164. -ut)
  165. UTAG=$2
  166. shift
  167. shift
  168. ;;
  169.  
  170. -ucf)
  171. UCFLAGS=$2
  172. shift 2
  173. ;;
  174.  
  175.  
  176. -gt)
  177. GTAG=$2
  178. shift
  179. shift
  180. ;;
  181. -gcf)
  182. GCFLAGS=$2
  183. shift
  184. shift
  185. ;;
  186.  
  187.  
  188. -e|--extras)
  189. EXTRAS=$EXTRAS" "$2
  190. shift 2
  191. ;;
  192.  
  193. -*)
  194. echo Unrecognized option: $1
  195. echo
  196. help
  197. exit
  198. break
  199. ;;
  200. *)
  201. break
  202. ;;
  203. esac
  204. done
  205.  
  206. CWD=`pwd`
  207. SUDOASKED=n
  208. SYSTYPE=unknown
  209. good_to_go=no
  210. for file in /etc/fedora-release /etc/linuxmint/info /etc/lsb-release /etc/debian_version /etc/redhat-release
  211. do
  212. if [ -f $file ]
  213. then
  214. good_to_go=yes
  215. fi
  216. done
  217. if [ $good_to_go = no ]
  218. then
  219. echo Supported systems: Fedora, Ubuntu, Redhat, Debian, Mint, OpenSuse
  220. echo You appear to be running none of the above, exiting
  221. exit
  222. fi
  223.  
  224. echo This script will install Gnu Radio from current GIT sources
  225. echo You will require Internet access from the computer on which this
  226. echo script runs. You will also require SUDO access. You will require
  227. echo approximately 500MB of free disk space to perform the build.
  228. echo " "
  229. echo This script will, as a side-effect, remove any existing Gnu Radio
  230. echo installation that was installed from your Linux distribution packages.
  231. echo It must do this to prevent problems due to interference between
  232. echo a linux-distribution-installed Gnu Radio/UHD and one installed from GIT source.
  233. echo " "
  234. echo The whole process may take up to two hours to complete, depending on the
  235. echo capabilities of your system.
  236. echo
  237. echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
  238. echo NOTE: if you run into problems while running this script, you can re-run it with
  239. echo the --verbose option to produce lots of diagnostic output to help debug problems.
  240. echo This script has been written to anticipate some of the more common problems one might
  241. echo encounter building ANY large, complex software package. But it is not pefect, and
  242. echo there are certainly some situations it could encounter that it cannot deal with
  243. echo gracefully. Altering the system configuration from something reasonably standard,
  244. echo removing parts of the filesystem, moving system libraries around arbitrarily, etc,
  245. echo it likely cannot cope with. It is just a script. It isn\'t intuitive or artificially
  246. echo intelligent. It tries to make life a little easier for you, but at the end of the day
  247. echo if it runs into trouble, a certain amount of knowledge on your part about
  248. echo system configuration and idiosyncrasies will inevitably be necessary.
  249. echo
  250. echo
  251. echo -n Proceed?
  252.  
  253. read ans
  254. case $ans in
  255. y|Y|YES|yes|Yes)
  256. PROCEED=y
  257. ;;
  258. *)
  259. exit
  260. esac
  261.  
  262. SPACE=`df $HOME| grep -v blocks|grep '%'`
  263. SPACE=`echo $SPACE | awk '/./ {n=NF-2; printf ("%d\n", $n/1.0e3)}'`
  264.  
  265.  
  266. if [ $SPACE -lt 500 ]
  267. then
  268. echo "You don't appear to have enough free disk space on $HOME"
  269. echo to complete this build/install
  270. echo exiting
  271. doexit DISKSPACE
  272. fi
  273.  
  274. total=0
  275. for file in $PULLED_LIST
  276. do
  277. found=0
  278. for instance in ${file}.20*
  279. do
  280. if [ -d $instance ]
  281. then
  282. found=1
  283. sz=`du -s $instance|awk '{print $1}'`
  284. total=`expr $total + $sz`
  285. fi
  286. done
  287. done
  288. total=`expr $total '*' 1024`
  289. total=`expr $total / 1000000`
  290. if [ $total -gt 100 ]
  291. then
  292. echo Your old 'uhd.*' and 'gnuradio.*' etc directories are using roughly $total MB
  293. echo of disk space:
  294. for file in $PULLED_LIST
  295. do
  296. for instance in ${file}.20*
  297. do
  298. if [ -d $instance ]
  299. then
  300. ls -ld $instance
  301. fi
  302. done
  303. done
  304. echo " "
  305. echo -n Remove them'?'
  306. read ans
  307.  
  308. case $ans in
  309. y|Y|YES|yes|Yes)
  310. for file in $PULLED_LIST
  311. do
  312. for instance in ${file}.20*
  313. do
  314. if [ -d $instance ]
  315. then
  316. echo removing ${instance}
  317. rm -rf ${instance}
  318. fi
  319. done
  320. done
  321. echo Done
  322. ;;
  323. esac
  324. fi
  325. rm -rf *.20*.bgmoved
  326.  
  327. function my_echo {
  328. if [ $LOGDEV = /dev/stdout ]
  329. then
  330. echo $*
  331. else
  332. echo $*
  333. echo $* >>$LOGDEV 2>&1
  334. fi
  335. }
  336.  
  337. function checkcmd {
  338. found=0
  339. which $1 >/dev/null 2>&1
  340. x=$?
  341. if [ $x -eq 0 ]
  342. then
  343. found=1
  344. fi
  345. for place in /bin /usr/bin /usr/local/bin /sbin /usr/sbin /usr/local/sbin /opt/bin /opt/local/bin
  346. do
  347. if [ -e $place/$1 ]
  348. then
  349. found=1
  350. fi
  351. done
  352. if [ $found -eq 0 ]
  353. then
  354. which $1 >/dev/null 2>&1
  355. if [ $? -eq 0 ]
  356. then
  357. found=1
  358. fi
  359. fi
  360. if [ $found -eq 0 ]
  361. then
  362. my_echo Failed to find just-installed command \'$1\' after pre-requisite installation.
  363. my_echo This very likely indicates that the pre-requisite installation failed
  364. my_echo to install one or more critical pre-requisites for Gnu Radio/UHD
  365. doexit PREREQFAIL-CMD-$1
  366. fi
  367. }
  368.  
  369. function checklib {
  370. found=0
  371. my_echo -n Checking for library $1 ...
  372. for dir in /lib /usr/lib /usr/lib64 /lib64 /usr/lib/x86_64-linux-gnu /usr/lib/i386-linux-gnu \
  373. /usr/lib/arm-linux-gnueabihf /usr/lib/arm-linux-gnueabi
  374. do
  375. for file in $dir/${1}*.so*
  376. do
  377. if [ -e "$file" ]
  378. then
  379. found=1
  380. fi
  381. done
  382. done
  383. if [ $found -le 0 ]
  384. then
  385. my_echo Failed to find libraries with prefix \'$1\' after pre-requisite installation.
  386. my_echo This very likely indicates that the pre-requisite installation failed
  387. my_echo to install one or more critical pre-requisites for Gnu Radio/UHD
  388. my_echo exiting build
  389. doexit PREREQFAIL-LIB-$1
  390. else
  391. my_echo Found library $1
  392. fi
  393. }
  394.  
  395. function checkpkg {
  396. my_echo Checking for package $1
  397. if [ `apt-cache search $1 | wc -l` -eq 0 ]
  398. then
  399. my_echo Failed to find package \'$1\' in known package repositories
  400. my_echo SOME THINGS MAY NOT BUILD AS A RESULT
  401. # doexit PREREQFAIL-PKG-$1
  402. fi
  403. }
  404.  
  405. function prereqs {
  406. sudocheck
  407. my_echo Installing prerequisites.
  408. my_echo "====>" THIS MAY TAKE QUITE SOME TIME "<====="
  409. #
  410. # It's a Fedora system
  411. #
  412. if [ -f /etc/fedora-release ]
  413. then
  414. SYSTYPE=Fedora
  415. case `cat /etc/fedora-release` in
  416. *12*|*13*|*14*|*15*|*16*|*17*|*18*)
  417. sudo yum -y erase 'gnuradio*' >>$LOGDEV 2>&1
  418. sudo yum -y erase 'libgruel-*' >>$LOGDEV 2>&1
  419. sudo yum -y erase 'libgruel*' >>$LOGDEV 2>&1
  420. sudo yum -y groupinstall "Engineering and Scientific" "Development Tools" \
  421. "Software Development Tools" "C Development Tools and Libraries" >>$LOGDEV 2>&1
  422. sudo yum -y install fftw-devel cppunit-devel wxPython-devel \
  423. boost-devel alsa-lib-devel numpy gsl-devel python-devel pygsl \
  424. python-cheetah python-mako python-lxml PyOpenGL qt-devel qt qt4 qt4-devel \
  425. PyQt4-devel qwt-devel qwtplot3d-qt4-devel libusb-devel libusb \
  426. libusb1 libusb1-devel cmake git wget python-docutils \
  427. PyQwt PyQwt-devel qwt-devel gtk2-engines xmlrpc-c-"*" tkinter orc python-requests \
  428. orc-devel python-sphinx SDL-devel swig libzmq >>$LOGDEV 2>&1
  429. ;;
  430.  
  431. *19*|*20*|*21*)
  432. sudo yum -y erase 'gnuradio*' >>$LOGDEV 2>&1
  433. sudo yum -y erase 'libgruel-*' >>$LOGDEV 2>&1
  434. sudo yum -y erase 'libgruel*' >>$LOGDEV 2>&1
  435. sudo yum -y groupinstall "Engineering and Scientific" "Development Tools" \
  436. "Software Development Tools" "C Development Tools and Libraries" >>$LOGDEV 2>&1
  437. sudo yum -y install fftw-devel cppunit-devel wxPython-devel \
  438. boost-devel alsa-lib-devel numpy gsl-devel python-devel pygsl \
  439. python-cheetah python-mako python-lxml PyOpenGL qt-devel qt qt4 qt4-devel \
  440. PyQt4-devel qwt-devel qwtplot3d-qt4-devel \
  441. libusbx-devel cmake git wget python-docutils cppzmq-devel \
  442. PyQwt PyQwt-devel qwt-devel gtk2-engines xmlrpc-c-"*" tkinter orc \
  443. orc-devel python-sphinx SDL-devel swig zeromq2-devel python-zmq comedilib comedilib-devel thrift-devel \
  444. python-thrift scipy >>$LOGDEV 2>&1
  445.  
  446.  
  447. ;;
  448. *22*|*23*)
  449. sudo dnf -y erase 'gnuradio*' >>$LOGDEV 2>&1
  450. sudo dnf -y erase 'libgruel-*' >>$LOGDEV 2>&1
  451. sudo dnf -y erase 'libgruel*' >>$LOGDEV 2>&1
  452. sudo dnf -y groupinstall "Engineering and Scientific" "Development Tools" \
  453. "Software Development Tools" "C Development Tools and Libraries" >>$LOGDEV 2>&1
  454. sudo dnf -y install fftw-devel cppunit-devel wxPython-devel boost-devel \
  455. alsa-lib-devel numpy gsl-devel python-devel pygsl python-cheetah python-mako \
  456. python-lxml PyOpenGL qt-devel PyQt4-devel qwt-devel qwtplot3d-qt4-devel \
  457. libusbx-devel cmake python-docutils PyQwt PyQwt-devel gtk2-engines xmlrpc-c-"*" \
  458. tkinter orc-devel python-sphinx SDL-devel swig perl-ZMQ-LibZMQ2 perl-ZMQ-LibZMQ2 \
  459. zeromq zeromq-devel python-requests \
  460. gcc-c++ doxygen zeromq-ada-devel cppzmq-devel \
  461. perl-ZeroMQ amavisd-new-zeromq amavisd-new-snmp-zeromq \
  462. php-zmq python-zmq czmq uwsgi-logger-zeromq \
  463. comedilib comedilib-devel pygtk2 ncurses-"*" thrift-devel python-thrift scipy >>$LOGDEV 2>&1
  464. ;;
  465. *)
  466. my_echo Only Fedora release 12 - 23 are supported by this script
  467. doexit WRONGRELEASE
  468. ;;
  469. esac
  470.  
  471. #
  472. # It's a RedHat system
  473. elif [ -f /etc/redhat-release ]
  474. then
  475. SYSTYPE=Redhat
  476. case `cat /etc/redhat-release` in
  477. *elease*6*)
  478. sudo yum -y erase 'gnuradio*' >>$LOGDEV 2>&1
  479. sudo yum -y erase 'libgruel-*' >>$LOGDEV 2>&1
  480. sudo yum -y erase 'libgruel*' >>$LOGDEV 2>&1
  481. sudo yum -y groupinstall "Engineering and Scientific" "Development Tools" >>$LOGDEV 2>&1
  482. sudo yum -y install fftw-devel cppunit-devel wxPython-devel libusb-devel \
  483. boost-devel alsa-lib-devel numpy gsl-devel python-devel pygsl \
  484. python-cheetah python-mako python-lxml PyOpenGL qt-devel qt qt4 qt4-devel \
  485. PyQt4-devel qwt-devel qwtplot3d-qt4-devel libusb libusb-devel \
  486. libusb1 libusb1-devel cmake git wget python-docutils \
  487. PyQwt PyQwt-devel qwt-devel gtk2-engines xmlrpc-c-"*" libzmq libzmq-dev \
  488. ncurses-"*" tkinter orc python-requests >>$LOGDEV 2>&1
  489. ;;
  490. *elease*7*)
  491. sudo yum -y erase 'gnuradio*' >>$LOGDEV 2>&1
  492. sudo yum -y erase 'libgruel-*' >>$LOGDEV 2>&1
  493. sudo yum -y erase 'libgruel*' >>$LOGDEV 2>&1
  494.  
  495.  
  496. sudo yum -y install fftw-devel cppunit-devel python-devel libusb-devel \
  497. boost-devel alsa-lib-devel numpy gsl-devel python-cheetah \
  498. python-mako qt-devel PyOpenGL PyQt4-devel libusb1-devel \
  499. cmake python-docutils qt-devel gcc-c++ swig >>$LOGDEV 2>&1
  500. sudo yum install -y epel-release >>$LOGDEV 2>&1
  501. sudo yum -y update >>$LOGDEV 2>&1
  502.  
  503. sudo yum -y install libsphinxclient-devel php-pecl-sphinx python-catkin-sphinx \
  504. python-ipython-sphinx git \
  505. python-oslo-sphinx python-sphinx-doc python-sphinx-theme-openlmi \
  506. python-sphinx_rtd_theme python-sphinxcontrib-adadomain \
  507. python-sphinxcontrib-cheeseshop python-sphinxcontrib-httpdomain \
  508. python-sphinxcontrib-issuetracker python-sphinxcontrib-napoleon sphinx-java \
  509. sphinx-php python-cornice-sphinx python-sphinx sphinx libsphinxclient \
  510. qwt-devel qwt-doc qwtpolar qwtpolar-devel qwtpolar-doc qwt \
  511. cppzmq-devel perl-ZMQ-Constants perl-ZMQ-LibZMQ3 czmq \
  512. python-txzmq python-zmq python-zmq-tests cmake-gui wxPython-devel \
  513. ncurses-"*" >>$LOGDEV 2>&1
  514. ;;
  515.  
  516. *)
  517. my_echo Your Redhat system release must be release 6 or 7 to proceed
  518. doexit WRONGRELEASE
  519. ;;
  520. esac
  521.  
  522. #
  523. # It's a Mint system
  524. #
  525. elif [ -f /etc/linuxmint/info ]
  526. then
  527. SYSTYPE=Mint
  528. sudo apt-get -y purge 'gnuradio-*' >>$LOGDEV 2>&1
  529. sudo apt-get -y purge 'libgruel-*' >>$LOGDEV 2>&1
  530. sudo apt-get -y purge 'libgruel*' >>$LOGDEV 2>&1
  531. sudo apt-get -y purge 'libgruel0*' >>$LOGDEV 2>&1
  532. sudo apt-get -y purge 'libgnuradio*' >>$LOGDEV 2>&1
  533. sudo apt-get -y purge 'python-gnuradio*' >>$LOGDEV 2>&1
  534. case `grep RELEASE /etc/linuxmint/info` in
  535. *11*|*12*|*13*|*14*|*15*|*16*|*17*)
  536. PKGLIST="libfontconfig1-dev libxrender-dev libpulse-dev swig g++
  537. automake autoconf libtool python-dev libfftw3-dev
  538. libcppunit-dev libboost-all-dev libusb-dev libusb-1.0-0-dev fort77
  539. libsdl1.2-dev python-wxgtk2.8 git-core
  540. libqt4-dev python-numpy ccache python-opengl libgsl0-dev
  541. python-cheetah python-mako python-lxml doxygen qt4-dev-tools libusb-1.0-0-dev
  542. libqwt5-qt4-dev libqwtplot3d-qt4-dev pyqt4-dev-tools python-qwt5-qt4
  543. cmake git-core wget libxi-dev python-docutils gtk2-engines-pixbuf r-base-dev python-tk
  544. liborc-0.4-0 liborc-0.4-dev libasound2-dev python-gtk2 libzmq libzmq-dev libzmq1 libzmq1-dev python-requests
  545. libncurses5 libncurses5-dev"
  546. ;;
  547. *18*)
  548. PKGLIST="libfontconfig1-dev libxrender-dev libpulse-dev swig g++
  549. automake autoconf libtool python-dev libfftw3-dev
  550. libcppunit-dev libboost-all-dev libusb-dev libusb-1.0-0-dev fort77
  551. libsdl1.2-dev python-wxgtk3.0 git-core
  552. libqt4-dev python-numpy ccache python-opengl libgsl0-dev
  553. python-cheetah python-mako python-lxml doxygen qt4-dev-tools libusb-1.0-0-dev
  554. libqwt5-qt4-dev libqwtplot3d-qt4-dev pyqt4-dev-tools python-qwt5-qt4
  555. cmake git-core wget libxi-dev python-docutils gtk2-engines-pixbuf r-base-dev python-tk
  556. liborc-0.4-0 liborc-0.4-dev libasound2-dev python-gtk2 libzmq libzmq-dev python-requests
  557. libncurses5 libncurses5-dev"
  558. ;;
  559.  
  560. *)
  561. my_echo Your Mint release must be at least Linux Mint 11 to proceed
  562. doexit WRONGRELEASE
  563. ;;
  564. esac
  565. for pkg in $PKGLIST; do checkpkg $pkg; done
  566. for pkg in $PKGLIST
  567. do
  568. sudo apt-get -y --ignore-missing install $pkg >>$LOGDEV 2>&1
  569. done
  570.  
  571. #
  572. # It's a Ubuntu system
  573. #
  574. elif [ -f /etc/lsb-release -a ! -f /etc/SuSE-release ]
  575. then
  576. SYSTYPE=Ubuntu
  577. sudo apt-get -y purge 'gnuradio-*' >>$LOGDEV 2>&1
  578. sudo apt-get -y purge 'libgruel-*' >>$LOGDEV 2>&1
  579. sudo apt-get -y purge 'libgruel*' >>$LOGDEV 2>&1
  580. sudo apt-get -y purge 'libgruel0*' >>$LOGDEV 2>&1
  581. sudo apt-get -y purge 'libgnuradio*' >>$LOGDEV 2>&1
  582. sudo apt-get -y purge 'python-gnuradio*' >>$LOGDEV 2>&1
  583. case `grep DISTRIB_RELEASE /etc/lsb-release` in
  584. *15.*|*16.*)
  585. PKGLIST="libqwt6 libfontconfig1-dev libxrender-dev libpulse-dev swig g++
  586. automake autoconf libtool python-dev libfftw3-dev
  587. libcppunit-dev libboost-all-dev libusb-dev libusb-1.0-0-dev fort77
  588. libsdl1.2-dev python-wxgtk2.8 git-core
  589. libqt4-dev python-numpy ccache python-opengl libgsl0-dev
  590. python-cheetah python-mako python-lxml doxygen qt4-default qt4-dev-tools libusb-1.0-0-dev
  591. libqwt5-qt4-dev libqwtplot3d-qt4-dev pyqt4-dev-tools python-qwt5-qt4
  592. cmake git-core wget libxi-dev python-docutils gtk2-engines-pixbuf r-base-dev python-tk
  593. liborc-0.4-0 liborc-0.4-dev libasound2-dev python-gtk2 libzmq libzmq-dev libzmq1 libzmq1-dev python-requests
  594. python-sphinx comedi-dev python-zmq libncurses5 libncurses5-dev python-wxgtk3.0"
  595. CMAKE_FLAG1=-DPythonLibs_FIND_VERSION:STRING="2.7"
  596. CMAKE_FLAG2=-DPythonInterp_FIND_VERSION:STRING="2.7"
  597. ;;
  598.  
  599. *13.*|*14.*)
  600. PKGLIST="libfontconfig1-dev libxrender-dev libpulse-dev swig g++
  601. automake autoconf libtool python-dev libfftw3-dev
  602. libcppunit-dev libboost-all-dev libusb-dev libusb-1.0-0-dev fort77
  603. libsdl1.2-dev python-wxgtk2.8 git-core
  604. libqt4-dev python-numpy ccache python-opengl libgsl0-dev
  605. python-cheetah python-mako python-lxml doxygen qt4-default qt4-dev-tools libusb-1.0-0-dev
  606. libqwt5-qt4-dev libqwtplot3d-qt4-dev pyqt4-dev-tools python-qwt5-qt4
  607. cmake git-core wget libxi-dev python-docutils gtk2-engines-pixbuf r-base-dev python-tk
  608. liborc-0.4-0 liborc-0.4-dev libasound2-dev python-gtk2 libzmq1 libzmq1-dev libzmq libzmq-dev python-requests
  609. libncurses5 libncurses5-dev"
  610. CMAKE_FLAG1=-DPythonLibs_FIND_VERSION:STRING="2.7"
  611. CMAKE_FLAG2=-DPythonInterp_FIND_VERSION:STRING="2.7"
  612. ;;
  613.  
  614. *11.*|*12.10*)
  615. PKGLIST="libfontconfig1-dev libxrender-dev libpulse-dev swig g++
  616. automake autoconf libtool python-dev libfftw3-dev
  617. libcppunit-dev libboost-all-dev libusb-dev libusb-1.0-0-dev fort77
  618. libsdl1.2-dev python-wxgtk2.8 git-core
  619. libqt4-dev python-numpy ccache python-opengl libgsl0-dev
  620. python-cheetah python-mako python-lxml doxygen qt4-dev-tools libusb-1.0-0-dev
  621. libqwt5-qt4-dev libqwtplot3d-qt4-dev pyqt4-dev-tools python-qwt5-qt4
  622. cmake git-core wget libxi-dev python-docutils gtk2-engines-pixbuf r-base-dev python-tk
  623. liborc-0.4-0 liborc-0.4-dev libasound2-dev python-gtk2 libzmq libzmq-dev python-requests"
  624. CMAKE_FLAG1=-DPythonLibs_FIND_VERSION:STRING="2.7"
  625. CMAKE_FLAG2=-DPythonInterp_FIND_VERSION:STRING="2.7"
  626. ;;
  627.  
  628. *12.04*)
  629. PKGLIST="libfontconfig1-dev libxrender-dev libpulse-dev swig g++
  630. automake autoconf libtool python-dev libfftw3-dev
  631. libcppunit-dev libboost1.48-all-dev libusb-dev libusb-1.0-0-dev fort77
  632. libsdl1.2-dev python-wxgtk2.8 git-core
  633. libqt4-dev python-numpy ccache python-opengl libgsl0-dev
  634. python-cheetah python-mako python-lxml doxygen qt4-dev-tools libusb-1.0-0-dev
  635. libqwt5-qt4-dev libqwtplot3d-qt4-dev pyqt4-dev-tools python-qwt5-qt4
  636. cmake git-core wget libxi-dev python-docutils gtk2-engines-pixbuf r-base-dev python-tk
  637. liborc-0.4-0 liborc-0.4-dev libasound2-dev python-gtk2 libzmq libzmq-dev python-requests"
  638. ;;
  639.  
  640. *)
  641. my_echo Your Ubuntu release not supported--cannot proceed
  642. doexit WRONGRELEASE
  643. ;;
  644. esac
  645. for pkg in $PKGLIST; do checkpkg $pkg; done
  646. my_echo Done checking packages
  647. for pkg in $PKGLIST
  648. do
  649. sudo apt-get -y --ignore-missing install $pkg >>$LOGDEV 2>&1
  650. done
  651.  
  652. #
  653. # It's a Debian system
  654. #
  655. elif [ -f /etc/debian_version ]
  656. then
  657. SYSTYPE=Debian
  658. sudo apt-get -y purge 'gnuradio-*' >>$LOGDEV 2>&1
  659. sudo apt-get -y purge 'libgruel-*' >>$LOGDEV 2>&1
  660. sudo apt-get -y purge 'libgruel*' >>$LOGDEV 2>&1
  661. sudo apt-get -y purge 'libgruel0*' >>$LOGDEV 2>&1
  662. sudo apt-get -y purge 'libgnuradio*' >>$LOGDEV 2>&1
  663. sudo apt-get -y purge 'python-gnuradio*' >>$LOGDEV 2>&1
  664. case `cat /etc/debian_version` in
  665. *6.0*|*wheezy*|*sid*|*7.1*|*7.0*|*7.2*|*7.3*|*7.4*|*7.5*|*7.6*|*7.7*)
  666. PKGLIST="libfontconfig1-dev libxrender-dev libpulse-dev swig g++
  667. automake autoconf libtool python-dev libfftw3-dev
  668. libcppunit-dev libboost-all-dev libusb-dev libusb-1.0-0-dev fort77
  669. libsdl1.2-dev python-wxgtk2.8 git-core
  670. libqt4-dev python-numpy ccache python-opengl libgsl0-dev
  671. python-cheetah python-mako python-lxml doxygen qt4-dev-tools libusb-1.0-0-dev
  672. libqwt5-qt4-dev libqwtplot3d-qt4-dev pyqt4-dev-tools python-qwt5-qt4
  673. cmake git-core wget libxi-dev python-docutils gtk2-engines-pixbuf r-base-dev python-tk
  674. liborc-0.4-0 liborc-0.4-dev libasound2-dev python-gtk2 libportaudio2 portaudio19-dev
  675. ca-certificates libzmq libzmq-dev python-requests libncurses5 libncurses5-dev"
  676. ;;
  677. *8.3*)
  678. PKGLIST="libfontconfig1-dev libxrender-dev libpulse-dev swig g++
  679. automake autoconf libtool python-dev libfftw3-dev
  680. libcppunit-dev libboost-all-dev libusb-dev libusb-1.0-0-dev fort77
  681. libsdl1.2-dev python-wxgtk3.0 git-core
  682. libqt4-dev python-numpy ccache python-opengl libgsl0-dev
  683. python-cheetah python-mako python-lxml doxygen qt4-dev-tools libusb-1.0-0-dev
  684. libqwt5-qt4-dev libqwtplot3d-qt4-dev pyqt4-dev-tools python-qwt5-qt4
  685. cmake git-core wget libxi-dev python-docutils gtk2-engines-pixbuf r-base-dev python-tk
  686. liborc-0.4-0 liborc-0.4-dev libasound2-dev python-gtk2 libportaudio2 portaudio19-dev
  687. ca-certificates libzmq1 libzmq-dev python-requests libncurses5 libncurses5-dev"
  688. ;;
  689.  
  690. *)
  691. my_echo Unsupported Debian version `cat /etc/debian_version`
  692. doexit WRONGRELEASE
  693. ;;
  694. esac
  695. for pkg in $PKGLIST; do checkpkg $pkg; done
  696. sudo apt-get -y --ignore-missing install $PKGLIST >>$LOGDEV 2>&1
  697. elif [ -f /etc/SuSE-release ]
  698. then
  699. SYSTYPE=OpenSuSE
  700. if grep -q 12.1 /etc/SuSE-release
  701. then
  702. cool=1
  703. else
  704. my_echo Only OpenSuSE 12.1 is supported by this script
  705. doexit WRONGRELEASE
  706. fi
  707. sudo zypper install cmake cppunit-devel doxygen fftw3-devel \
  708. git gsl-devel libjack-devel libqt4-devel libqwtplot3d-devel \
  709. libSDL-devel libusb-1_0-devel orc portaudio portaudio-devel \
  710. python-cheetah python-mako python-devel python-lxml python-wxGTK python-wxWidgets-devel \
  711. qwt-devel wxWidgets-devel boost-devel xmlto texlive-latex libzmq libzmq-dev python-requests >>$LOGDEV 2>&1
  712.  
  713. else
  714. my_echo This script supports only Ubuntu,Mint,Fedora, Debian and OpenSuse systems
  715. my_echo Your Fedora system must be at least Fedora 12
  716. my_echo Your Ubuntu system must be at least Ubuntu 9.04
  717. my_echo Your Mint system must be at least Mint 11
  718. my_echo Your Debian system must be release 6
  719. doexit WRONGSYSTEM
  720. fi
  721. PATH=$PATH
  722. export PATH
  723.  
  724. checkcmd git
  725. checkcmd cmake
  726.  
  727. if [ $SYSTYPE = Fedora ]
  728. then
  729. checklib libusb-0 0
  730. checklib libusb-1 0
  731. else
  732. checklib libusb 2
  733. fi
  734.  
  735. checklib libboost 5
  736. checklib libcppunit 0
  737. checklib libfftw 5
  738. checklib libgsl 0
  739.  
  740. my_echo Done
  741. }
  742.  
  743.  
  744. function gitfetch {
  745. date=`date +%Y%m%d%H%M%S`
  746. V=3.7/maint
  747. if [ $MASTER_MODE -eq 1 ]
  748. then
  749. V=Master/HEAD
  750. fi
  751. if [ $OLD_MODE -eq 1 ]
  752. then
  753. V=3.6.5.1
  754. fi
  755. echo This script will fetch Gnu Radio version $V from the repositories, along with compatible
  756. echo extras.
  757. echo -n Is this OK?
  758. read ans
  759.  
  760. case $ans in
  761. Y|y|YES|yes|Yes)
  762. ;;
  763. *)
  764. exit
  765. ;;
  766. esac
  767.  
  768.  
  769. my_echo "Fetching various packages (Gnu Radio, UHD, gr-osmosdr, gr-iqbal, etc)"
  770. my_echo " via the Internet"
  771. my_echo "=======> THIS MAY TAKE QUITE SOME TIME <========="
  772.  
  773. cd $CWD
  774. for dir in ${PULLED_LIST}
  775. do
  776. if [ -d $dir ]
  777. then
  778. mv $dir ${dir}.$date
  779. fi
  780. done
  781.  
  782. #
  783. # GIT the gnu radio source tree
  784. #
  785. my_echo -n Fetching Gnu Radio via GIT...
  786. if [ $JOSHMODE = False ]
  787. then
  788. if [ $MASTER_MODE -eq 0 ]
  789. then
  790. RECURSE="--recursive"
  791. else
  792. RECURSE="--recursive"
  793. fi
  794. git clone --progress $RECURSE http://git.gnuradio.org/git/gnuradio.git >>$LOGDEV 2>&1
  795. if [ ! -d gnuradio/gnuradio-core -a ! -d gnuradio/gnuradio-runtime ]
  796. then
  797. my_echo "Could not find gnuradio/gnuradio-{core,runtime} after GIT checkout"
  798. my_echo GIT checkout of Gnu Radio failed!
  799. doexit FETCH-GR-FAIL
  800. fi
  801. if [ $OLD_MODE -eq 1 ]
  802. then
  803. cd gnuradio
  804. git checkout v3.6.5.1 >>$LOGDEV 2>&1
  805. cd $CWD
  806. elif [ $MASTER_MODE -eq 0 ]
  807. then
  808. cd gnuradio
  809. git checkout maint >>$LOGDEV 2>&1
  810. cd $CWD
  811. fi
  812.  
  813. if [ $GTAG != None ]
  814. then
  815. cd gnuradio
  816. git checkout $GTAG >/dev/null 2>&1
  817. git name-rev HEAD >tmp$$ 2>&1
  818. if grep -q "$GTAG" tmp$$
  819. then
  820. whee=yes
  821. rm -f tmp$$
  822. else
  823. my_echo Could not fetch Gnu Radio tagged $GTAG from GIT
  824. rm -f tmp$$
  825. doexit FETCH-GR-FAIL-$GTAG
  826. fi
  827. cd ..
  828. fi
  829. else
  830. echo Josh mode no longer supported
  831. doexit FETCH-GR-JOSH-FAIL
  832. fi
  833. my_echo Done
  834.  
  835. #
  836. # GIT the UHD source tree
  837. #
  838. rm -rf uhd
  839. my_echo -n Fetching UHD via GIT...
  840. git clone --progress https://github.com/EttusResearch/uhd >>$LOGDEV 2>&1
  841.  
  842. if [ ! -d uhd/host ]
  843. then
  844. my_echo GIT checkout of UHD FAILED
  845. rm -f tmp$$
  846. doexit FETCH-UHD-FAIL
  847. fi
  848. if [ $UTAG != None ]
  849. then
  850. cd uhd
  851. git checkout $UTAG >/dev/null 2>&1
  852. git status >tmp$$ 2>&1
  853. if grep -q "$UTAG" tmp$$
  854. then
  855. whee=yes
  856. rm -f tmp$$
  857. else
  858. my_echo Could not fetch UHD tagged $UTAG from GIT
  859. rm -f tmp$$
  860. fi
  861. cd ..
  862. fi
  863.  
  864. #
  865. # GIT the RTL-SDR source tree
  866. #
  867. rm -rf rtl-sdr
  868. rm -rf gr-osmosdr
  869. rm -rf gr-baz
  870. rm -rf hackrf
  871. rm -rf bladeRF
  872. rm -rf airspy
  873. my_echo Fetching rtl-sdr "(rtl-sdr, gr-osmosdr, gr-iqbal, hackrf, bladeRF and airspy)" via GIT
  874. git clone --progress git://github.com/patchvonbraun/rtl-sdr >>$LOGDEV 2>&1
  875. git clone --progress git://git.osmocom.org/gr-osmosdr >>$LOGDEV 2>&1
  876. git clone --progress git://git.osmocom.org/gr-iqbal.git >>$LOGDEV 2>&1
  877. git clone https://github.com/Nuand/bladeRF.git >>$LOGDEV 2>&1
  878. if [ -d gr-iqbal ]
  879. then
  880. cd gr-iqbal
  881. if [ $OLD_MODE -eq 1 ]
  882. then
  883. git checkout gr3.6
  884. fi
  885. git submodule init >>$LOGDEV 2>&1
  886. git submodule update >>$LOGDEV 2>&1
  887. cd ..
  888. fi
  889. git clone --progress https://github.com/mossmann/hackrf.git >>$LOGDEV 2>&1
  890. (cd $CWD; rm -rf airpsy; mkdir airspy; cd airspy; git clone https://github.com/airspy/host) >>$LOGDEV 2>&1
  891. my_echo Done
  892. }
  893.  
  894. function uhd_build {
  895. #
  896. # UHD build
  897. #
  898. sudocheck
  899. if [ ! -d uhd ]
  900. then
  901. my_echo you do not appear to have the \'uhd\' directory
  902. my_echo you should probably use $0 gitfetch to fetch the appropriate
  903. my_echo files using GIT
  904. doexit BUILD-UHD-NOT-THERE
  905. fi
  906. if [ $UTAG != None ]
  907. then
  908. cd uhd
  909. git checkout $UTAG >/dev/null 2>&1
  910. cd ..
  911. fi
  912. my_echo Building UHD...
  913. my_echo "=============> THIS WILL TAKE SOME TIME <============="
  914. my_echo
  915. cd uhd/host
  916. rm -rf build
  917. if [ ! -d build ]
  918. then
  919. mkdir build
  920. fi
  921. cd build
  922. make clean >/dev/null 2>&1
  923. cmake $CMAKE_FLAG1 $CMAKE_FLAG2 $CMF1 $CMF2 $UCFLAGS ../ >>$LOGDEV 2>&1
  924. make clean >>$LOGDEV 2>&1
  925. make $JFLAG >>$LOGDEV 2>&1
  926. if [ $? -ne 0 ]
  927. then
  928. my_echo UHD build apparently failed
  929. my_echo Exiting UHD build
  930. doexit UHD-BUILD-FAIL1
  931. fi
  932. sudo rm -f /usr/local/lib*/libuhd*
  933. sudo make $JFLAG install >>$LOGDEV 2>&1
  934. which uhd_find_devices >/dev/null 2>&1
  935. x=$?
  936. if [ $x -ne 0 -a ! -f /usr/local/bin/uhd_find_devices -a ! -f /opt/local/bin/uhd_find_devices ]
  937. then
  938. my_echo UHD build/install apparently failed since I cannot find /usr/local/bin/uhd_find_devices
  939. my_echo after doing make and make install
  940. my_echo Exiting UHD build
  941. doexit UHD-BUILD-FAIL2
  942. fi
  943. sudo ldconfig >>$LOGDEV 2>&1
  944. my_echo Done building/installing UHD
  945. }
  946.  
  947. function rtl_build {
  948. #
  949. # RTL build
  950. #
  951. sudocheck
  952. cd $CWD
  953. if [ ! -d rtl-sdr ]
  954. then
  955. my_echo you do not appear to have the \'rtl-sdr\' directory
  956. my_echo you should probably use $0 gitfetch to fetch the appropriate
  957. my_echo files using GIT
  958. doexit BUILD-RTL-NOT-THERE
  959. fi
  960.  
  961. my_echo -n Building rtl-sdr...
  962. cd rtl-sdr
  963. cmake $CMAKE_FLAG1 $CMAKE_FLAG2 $CMF1 $CMF2 . >>$LOGDEV 2>&1
  964. make clean >>$LOGDEV 2>&1
  965. make $JFLAG >>$LOGDEV 2>&1
  966.  
  967. if [ $? -ne 0 ]
  968. then
  969. my_echo rtl-sdr build apparently failed
  970. my_echo Exiting rtl-sdr build
  971. doexit RTL-BUILD-FAIL1
  972. fi
  973. sudo make $JFLAG install >>$LOGDEV 2>&1
  974. my_echo Done building rtl-sdr
  975.  
  976. cd $CWD
  977. if [ -d hackrf ]
  978. then
  979. my_echo -n Building hackrf...
  980. cd hackrf
  981. cmake $CMAKE_FLAG1 $CMAKE_FLAG2 $CMF1 $CMF2 -DINSTALL_UDEV_RULES=ON host/ >>$LOGDEV 2>&1
  982. make clean >>$LOGDEV 2>&1
  983. make >>$LOGDEV 2>&1
  984. if [ $? -ne 0 ]
  985. then
  986. my_echo hackrf build failed
  987. my_echo Exiting hackrf build
  988. else
  989. sudo make install >>$LOGDEV 2>&1
  990. fi
  991. my_echo Done building hackrf
  992. cd $CWD
  993. fi
  994. cd $CWD
  995. if [ -d gr-iqbal ]
  996. then
  997. my_echo -n Building gr-iqbal...
  998. cd gr-iqbal
  999. mkdir -p build
  1000. cd build
  1001. cmake .. $CMAKE_FLAG1 $CMAKE_FLAG2 $CMF1 $CMF2 >>$LOGDEV 2>&1
  1002. make clean >>$LOGDEV 2>&1
  1003. make >>$LOGDEV 2>&1
  1004. if [ $? -ne 0 ]
  1005. then
  1006. my_echo gr-iqbal build apparently failed
  1007. my_echo Exiting gr-iqbal build
  1008. else
  1009. sudo make install >>$LOGDEV 2>&1
  1010. cd $CWD
  1011. my_echo Done building gr-iqbal
  1012. fi
  1013. fi
  1014. if [ -d bladeRF ]
  1015. then
  1016. my_echo -n Building bladeRF...
  1017. cd bladeRF
  1018. cd host
  1019. cmake . $CMAKE_FLAG1 $CMAKE_FLAG2 $CMF1 $CMF2 >>$LOGDEV 2>&1
  1020. make clean >>$LOGDEV 2>&1
  1021. make >>$LOGDEV 2>&1
  1022. if [ $? -ne 0 ]
  1023. then
  1024. my_echo bladeRF build apparently failed
  1025. my_echo Exiting bladeRF build
  1026. else
  1027. sudo make install >>$LOGDEV 2>&1
  1028. cd $CWD
  1029. my_echo Done building bladeRF
  1030. fi
  1031. fi
  1032.  
  1033. if [ -d airspy/host ]
  1034. then
  1035. cd airspy/host
  1036. mkdir build
  1037. cd build
  1038. cmake .. $CMAKE_FLAG1 $CMAKE_FLAG2 $CMF1 $CMF2 >>$LOGDEV 2>&1
  1039. make clean >>$LOGDEV 2>&1
  1040. make >>$LOGDEV 2>&1
  1041. if [ $? -ne 0 ]
  1042. then
  1043. my_echo airspy build apparently failed
  1044. my_echo Exiting airspy build
  1045. else
  1046. sudo make install >>$LOGDEV 2>&1
  1047. my_echo Done building airspy
  1048. fi
  1049. cd $CWD
  1050. fi
  1051.  
  1052.  
  1053. cd $CWD
  1054. if [ ! -d gr-osmosdr ]
  1055. then
  1056. my_echo you do not appear to have the \'gr-osmosdr\' directory
  1057. my_echo you should probably use $0 gitfetch to fetch the appropriate
  1058. my_echo files using GIT
  1059. doexit RTL-BUILD-FAIL2
  1060. fi
  1061. cd gr-osmosdr
  1062. if [ $OLD_MODE -eq 1 ]
  1063. then
  1064. git checkout gr3.6 >/dev/null 2>&1
  1065. fi
  1066. my_echo -n Building gr-osmosdr...
  1067. cmake . $CMAKE_FLAG1 $CMAKE_FLAG2 $CMF1 $CMF2 >>$LOGDEV 2>&1
  1068. make clean >>$LOGDEV 2>&1
  1069. make $JFLAG >>$LOGDEV 2>&1
  1070.  
  1071. if [ $? -ne 0 ]
  1072. then
  1073. my_echo gr-osmosdr build apparently failed
  1074. my_echo Exit rtl-sdr/gr-osmosdr build
  1075. doexit OSMOSDR-BUILD-FAIL
  1076. fi
  1077. sudo make $JFLAG install >>$LOGDEV 2>&1
  1078. my_echo Done building gr-osmosdr
  1079. sudo ldconfig >>$LOGDEV 2>&1
  1080.  
  1081. cd $CWD
  1082. my_echo Done building/installing rtl-sdr/gr-osmosdr
  1083. }
  1084.  
  1085. function firmware {
  1086. sudocheck
  1087. FOUND_DOWNLOADER=False
  1088. dirlist="/usr/local/share /usr/local/lib /usr/local/lib64"
  1089. prog=uhd_images_downloader
  1090.  
  1091. PATH=$PATH:/usr/local/bin
  1092. q=`which $prog 2>/dev/null`
  1093.  
  1094. if [ @$q@ != @@ ]
  1095. then
  1096. sudo -E $q
  1097. else
  1098.  
  1099. for dir in $dirlist
  1100. do
  1101. if [ -f $dir/uhd/utils/$prog ]
  1102. then
  1103. FOUND_DOWNLOADER=True
  1104. DOWNLOADER=$dir/uhd/utils/$prog
  1105. fi
  1106. done
  1107.  
  1108. if [ $FOUND_DOWNLOADER = True ]
  1109. then
  1110. sudo -E $DOWNLOADER
  1111. else
  1112. my_echo Could not find images downloader: $prog in any of $dirlist
  1113. doexit UHD-FIRMWARE-FAIL
  1114. fi
  1115. my_echo Done downloading firmware to /usr/local/share/uhd/images
  1116. fi
  1117. }
  1118.  
  1119. function gnuradio_build {
  1120. sudocheck
  1121.  
  1122. if [ $JOSHMODE = False ]
  1123. then
  1124. if [ ! -d gnuradio ]
  1125. then
  1126. my_echo you do not appear to have the \'gnuradio\' directory
  1127. my_echo you should probably use $0 gitfetch to fetch the appropriate
  1128. my_echo files using GIT
  1129. doexit GNURADIO-BUILD-NOT-THERE
  1130. fi
  1131. if [ $GTAG != None ]
  1132. then
  1133. cd gnuradio
  1134. git checkout $GTAG >/dev/null 2>&1
  1135. cd ..
  1136. fi
  1137. else
  1138. echo Josh mode no longer supported
  1139. fi
  1140.  
  1141. #
  1142. # LD stuff
  1143. #
  1144. echo /usr/local/lib >tmp$$
  1145. echo /usr/local/lib64 >>tmp$$
  1146.  
  1147. if grep -q /usr/local/lib /etc/ld.so.conf.d/*
  1148. then
  1149. my_echo /usr/local/lib already in ld.so.conf.d
  1150. else
  1151. sudo cp tmp$$ /etc/ld.so.conf.d/local.conf
  1152. fi
  1153. rm -f tmp$$
  1154. my_echo Doing ldconfig...
  1155. sudo ldconfig >/dev/null 2>&1
  1156.  
  1157. PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
  1158.  
  1159. if [ -d /usr/local/lib64/pkgconfig ]
  1160. then
  1161. PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig
  1162. fi
  1163.  
  1164. export PKG_CONFIG_PATH
  1165.  
  1166. #
  1167. # Build Gnuradio
  1168. #
  1169. if [ $JOSHMODE = False ]
  1170. then
  1171. cd gnuradio
  1172. else
  1173. echo Josh mode no longer supported
  1174. doexit JOSH-MODE-NO
  1175. fi
  1176.  
  1177. my_echo Building Gnu Radio...
  1178. my_echo "=========> THIS WILL TAKE QUITE A WHILE <============="
  1179. my_echo " "
  1180. my_echo ...Doing cmake
  1181. if [ -d build ]
  1182. then
  1183. my_echo ...build directory already here
  1184. else
  1185. mkdir build
  1186. fi
  1187. cd build
  1188. make clean >/dev/null 2>&1
  1189. my_echo ...Cmaking
  1190. cmake -DENABLE_BAD_BOOST=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo $CMAKE_FLAG1 $CMAKE_FLAG2 $CMF1 $CMF2 $GCFLAGS ../ >>$LOGDEV 2>&1
  1191. my_echo ...Building
  1192. make $JFLAG clean >>$LOGDEV 2>&1
  1193. make $JFLAG >>$LOGDEV 2>&1
  1194. if [ $? -ne 0 ]
  1195. then
  1196. my_echo make failed
  1197. my_echo Exiting Gnu Radio build/install
  1198. doexit GNURADIO-BUILD-FAIL
  1199. fi
  1200. my_echo ...Installing
  1201. sudo rm -rf /usr/local/include/gnuradio/
  1202. sudo rm -f /usr/local/lib*/libgnuradio*
  1203. sudo make $JFLAG install >>$LOGDEV 2>&1
  1204. sudo ldconfig >>$LOGDEV 2>&1
  1205. my_echo Done building and installing Gnu Radio
  1206. my_echo -n GRC freedesktop icons install ...
  1207. if [ -f /usr/local/libexec/gnuradio/grc_setup_freedesktop ]
  1208. then
  1209. sudo chmod 755 /usr/local/libexec/gnuradio/grc_setup_freedesktop
  1210. sudo /usr/local/libexec/gnuradio/grc_setup_freedesktop install >>$LOGDEV 2>&1
  1211. fi
  1212. my_echo Done
  1213. }
  1214.  
  1215. function do_an_extra {
  1216. if [ -e $1 ]
  1217. then
  1218. my_echo Building extra module $1
  1219. cd $1
  1220. if [ -f CMakeLists.txt ]
  1221. then
  1222. mkdir -p build >>$LOGDEV 2>&1
  1223. cd build
  1224. cmake .. $CMAKE_FLAGS1 $CMAKE_FLAGS2 $CMF1 $CMF2 >>$LOGDEV 2>&1
  1225. make >>$LOGDEV 2>&1
  1226. sudo make install >>$LOGDEV 2>&1
  1227. sudo ldconfig
  1228. elif [ - bootstrap ]
  1229. then
  1230. chmod 755 bootstrap
  1231. ./bootstrap >>$LOGDEV 2>&1
  1232. PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig
  1233. ./configure >>$LOGDEV 2>&1
  1234. make >>$LOGDEV 2>&1
  1235. sudo make install >>$LOGDEV 2>&1
  1236. sudo ldconfig
  1237. else
  1238. my_echo Couldnt determine how to make module $1 neither bootstrap nor CmakeLists.txt present
  1239. fi
  1240. else
  1241. my_echo Couldnt build module $1 directory not there
  1242. fi
  1243. }
  1244.  
  1245. function extras {
  1246. sudocheck
  1247. date=`date +%Y%m%d%H%M%S`
  1248. if [ ! "@$EXTRAS@" = "@@" ]
  1249. then
  1250. for module in $EXTRAS
  1251. do
  1252. cd $CWD
  1253. base=`basename $module .git`
  1254. case $module in
  1255. git:*|*.git|*github*)
  1256. mv $base $base.$date.bgmoved >>$LOGDEV 2>&1
  1257. my_echo Doing GIT checkout for extra module $base
  1258. git clone $module >>$LOGDEV 2>&1
  1259. do_an_extra $base
  1260. ;;
  1261. htt*:*svn*)
  1262. mv $base $base.$date >>$LOGDEV 2>&1
  1263. my_echo Doing SVN checkout for extra module $base
  1264. svn co $module >>$LOGDEV 2>&1
  1265. if [ -e $base/trunk ]
  1266. then
  1267. do_an_extra $base/trunk
  1268. else
  1269. do_an_extra $base
  1270. fi
  1271. ;;
  1272. *)
  1273. my_echo Ignoring malformed extra module $module
  1274. ;;
  1275. esac
  1276.  
  1277. done
  1278. fi
  1279. cd $CWD
  1280. }
  1281.  
  1282. function mod_groups {
  1283. sudocheck
  1284. #
  1285. # Post install stuff
  1286. #
  1287. # USRP rules for UDEV and USRP group
  1288. #
  1289. #
  1290. # Check for USRP group, and update if necessary
  1291. if grep -q usrp /etc/group
  1292. then
  1293. my_echo Group \'usrp\' already in /etc/group
  1294. else
  1295. sudo /usr/sbin/groupadd usrp
  1296. fi
  1297.  
  1298. #
  1299. # Check that our calling user is in the USRP group, update if necessary
  1300. #
  1301. if grep -q usrp.*${USER} /etc/group
  1302. then
  1303. my_echo User $USER already in group \'usrp\'
  1304. else
  1305. sudo /usr/sbin/usermod -a -G usrp $USER
  1306. cat <<"!EOF!"
  1307. ********************************************************************************
  1308. This script has just modified /etc/group to place your userid '('$USER')' into group 'usrp'
  1309. In order for this change to take effect, you will need to log-out and log back
  1310. in again. You will not be able to access your USRP1 device until you do this.
  1311.  
  1312. If you wish to allow others on your system to use the USRP1 device, you will need to use:
  1313.  
  1314. sudo usermod -a -G usrp userid
  1315.  
  1316. For each userid you wish to allow access to the usrp
  1317.  
  1318. ********************************************************************************
  1319.  
  1320. Further
  1321. !EOF!
  1322. fi
  1323. if [ "$USERSLIST" = None ]
  1324. then
  1325. foo=bar
  1326. else
  1327. ul=`echo $USERSLIST|sed -e 's/,/ /g'`
  1328. for u in $ul
  1329. do
  1330. sudo /usr/sbin/usermod -a -G usrp $u
  1331. my_echo Added $u to group usrp
  1332. done
  1333. fi
  1334. }
  1335.  
  1336. function mod_udev {
  1337. sudocheck
  1338. #
  1339. # Check for UHD UDEV rules file, update if exists
  1340. #
  1341. if [ -f $CWD/uhd/host/utils/uhd-usrp.rules ]
  1342. then
  1343. sudo cp $CWD/uhd/host/utils/uhd-usrp.rules /etc/udev/rules.d/10-usrp.rules
  1344. sudo chown root /etc/udev/rules.d/10-usrp.rules
  1345. sudo chgrp root /etc/udev/rules.d/10-usrp.rules
  1346. fi
  1347.  
  1348. #
  1349. # Check for rtl-sdr UDEV rules file, update if exists
  1350. #
  1351. rm -f tmp$$
  1352. if [ -f $CWD/rtl-sdr/rtl-sdr.rules ]
  1353. then
  1354. sudo cp $CWD/rtl-sdr/rtl-sdr.rules /etc/udev/rules.d/15-rtl-sdr.rules
  1355. sudo chown root /etc/udev/rules.d/15-rtl-sdr.rules
  1356. sudo chgrp root /etc/udev/rules.d/15-rtl-sdr.rules
  1357. fi
  1358. sudo killall -HUP udevd
  1359. sudo udevadm control --reload-rules
  1360. }
  1361.  
  1362. function mod_sysctl {
  1363. sudocheck
  1364. #
  1365. # Modify sysctl.conf as necessary
  1366. #
  1367. cat >tmp$$ <<!EOF!
  1368. # Updates for Gnu Radio
  1369. net.core.rmem_max = 1000000
  1370. net.core.wmem_max = 1000000
  1371. kernel.shmmax = 2147483648
  1372. !EOF!
  1373.  
  1374.  
  1375. if grep -q 'Updates for Gnu Radio' /etc/sysctl.conf
  1376. then
  1377. my_echo Required updates to /etc/sysctl.conf already in place
  1378. else
  1379. my_echo Applying updates to /etc/sysctl.conf
  1380. cat /etc/sysctl.conf tmp$$ >tmp2$$
  1381. chmod 644 tmp2$$
  1382. sudo mv tmp2$$ /etc/sysctl.conf
  1383. fi
  1384.  
  1385. sudo sysctl -w net.core.rmem_max=1000000 >/dev/null 2>&1
  1386. sudo sysctl -w net.core.wmem_max=1000000 >/dev/null 2>&1
  1387. sudo sysctl -w kernel.shmmax=2147483648 >/dev/null 2>&1
  1388.  
  1389. rm -f tmp$$
  1390. rm -f tmp2$$
  1391.  
  1392. if grep -q usrp /etc/security/limits.conf
  1393. then
  1394. my_echo usrp group already has real-time scheduling privilege
  1395. else
  1396. cat >tmp$$ <<!EOF!
  1397. @usrp - rtprio 50
  1398. !EOF!
  1399. cat /etc/security/limits.conf tmp$$ >tmp2$$
  1400. sudo cp tmp2$$ /etc/security/limits.conf
  1401. sudo chmod 644 /etc/security/limits.conf
  1402. rm -f tmp$$ tmp2$$
  1403. my_echo Group \'usrp\' now has real-time scheduling privileges
  1404. my_echo You will need to log-out and back in again for this to
  1405. my_echo take effect
  1406. fi
  1407. }
  1408.  
  1409. function all {
  1410. my_echo Starting all functions at: `date`
  1411. cd $CWD
  1412. prereqs
  1413. touch -d "15 minutes ago" touch$$
  1414. if [ -d uhd -a -d gnuradio ]
  1415. then
  1416. if [ uhd -ot touch$$ -o gnuradio -ot touch$$ ]
  1417. then
  1418. gitfetch
  1419. else
  1420. my_echo Skipping git fetch, since \'uhd\' and \'gnuradio\' are new enough
  1421. fi
  1422. else
  1423. gitfetch
  1424. fi
  1425. rm -f touch$$
  1426. for fcn in uhd_build firmware gnuradio_build rtl_build mod_groups mod_udev mod_sysctl pythonpath extras
  1427. do
  1428. my_echo Starting function $fcn at: `date`
  1429. cd $CWD
  1430. $fcn
  1431. my_echo Done function $fcn at: `date`
  1432. done
  1433. my_echo Done all functions at: `date`
  1434. }
  1435.  
  1436. function pythonpath {
  1437. for PYVER in 2.6 2.7
  1438. do
  1439. for type in "" 64
  1440. do
  1441. if [ -d /usr/local/lib${type}/python${PYVER}/site-packages/gnuradio ]
  1442. then
  1443. PYTHONPATH=/usr/local/lib${type}/python${PYVER}/site-packages
  1444. fi
  1445. if [ -d /usr/local/lib${type}/python${PYVER}/dist-packages/gnuradio ]
  1446. then
  1447. PYTHONPATH=/usr/local/lib${type}/python${PYVER}/dist-packages
  1448. fi
  1449. done
  1450. done
  1451. echo
  1452. echo
  1453. echo "************************************************************"
  1454. echo You should probably set your PYTHONPATH to:
  1455. echo " "
  1456. echo " " $PYTHONPATH
  1457. echo " "
  1458. echo Using:
  1459. echo " "
  1460. echo export PYTHONPATH=$PYTHONPATH
  1461. echo " "
  1462. echo in your .bashrc or equivalent file prior to attempting to run
  1463. echo any Gnu Radio applications or Gnu Radio Companion.
  1464. echo "*************************************************************"
  1465. }
  1466.  
  1467. function sudocheck {
  1468. #
  1469. # Check SUDO privileges
  1470. #
  1471. if [ $SUDOASKED = n ]
  1472. then
  1473. echo SUDO privileges are required
  1474. echo -n Do you have SUDO privileges'?'
  1475. read ans
  1476. case $ans in
  1477. y|Y|YES|yes|Yes)
  1478. echo Continuing with script
  1479. SUDOASKED=y
  1480. sudo grep timestamp_timeout /etc/sudoers >tmp$$
  1481. timeout=`cat tmp$$|awk '/./ {print $4}'`
  1482. rm -f tmp$$
  1483. if [ "@@" = "@$timeout@" ]
  1484. then
  1485. sudo cp /etc/sudoers tmp$$
  1486. sudo chown $USER tmp$$
  1487. sudo chmod 644 tmp$$
  1488. echo "Defaults timestamp_timeout = 90" >>tmp$$
  1489. sudo cp tmp$$ /etc/sudoers
  1490. sudo chown root /etc/sudoers
  1491. sudo chmod 440 /etc/sudoers
  1492. elif [ "$timeout" -lt 90 ]
  1493. then
  1494. echo You need to have a timestamp_timeout in /etc/sudoers of 90 or more
  1495. echo Please ensure that your timestamp_timeout is 90 or more
  1496. exit
  1497. fi
  1498. ;;
  1499. *)
  1500. echo Exiting. Please ensure that you have SUDO privileges on this system!
  1501. exit
  1502. ;;
  1503. esac
  1504. fi
  1505. }
  1506.  
  1507. PATH=$PATH
  1508. export PATH
  1509. case $# in
  1510. 0)
  1511. all
  1512. my_echo All Done
  1513. doexit SUCCESS
  1514. esac
  1515.  
  1516. for arg in $*
  1517. do
  1518. cd $CWD
  1519. $arg
  1520. done
  1521. my_echo All Done
  1522. doexit SUCCESS
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement