Advertisement
Guest User

Fixed gnuradio-build for Ubuntu 16.*

a guest
Apr 24th, 2016
792
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 42.19 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.            
  548.         *)
  549.             my_echo Your Mint release must be at least Linux Mint 11 to proceed
  550.             doexit WRONGRELEASE
  551.             ;;
  552.         esac
  553.         for pkg in $PKGLIST; do checkpkg $pkg; done
  554.         for pkg in $PKGLIST
  555.         do
  556.             sudo apt-get -y --ignore-missing install $pkg >>$LOGDEV 2>&1
  557.         done
  558.  
  559.     #
  560.     # It's a Ubuntu system
  561.     #
  562.     elif [ -f /etc/lsb-release -a ! -f /etc/SuSE-release ]
  563.     then
  564.         SYSTYPE=Ubuntu
  565.         sudo apt-get -y purge 'gnuradio-*' >>$LOGDEV 2>&1
  566.         sudo apt-get -y purge 'libgruel-*' >>$LOGDEV 2>&1
  567.         sudo apt-get -y purge 'libgruel*' >>$LOGDEV 2>&1
  568.         sudo apt-get -y purge 'libgruel0*' >>$LOGDEV 2>&1
  569.         sudo apt-get -y purge 'libgnuradio*' >>$LOGDEV 2>&1
  570.         sudo apt-get -y purge 'python-gnuradio*' >>$LOGDEV 2>&1
  571.         case `grep DISTRIB_RELEASE /etc/lsb-release` in
  572.         *16.*)
  573.             PKGLIST="libqwt-dev libfontconfig1-dev libxrender-dev libpulse-dev swig g++
  574.             automake autoconf libtool python-dev libfftw3-dev
  575.             libcppunit-dev libboost-all-dev libusb-dev libusb-1.0-0-dev fort77
  576.             libsdl1.2-dev python-wxgtk3.0 git-core
  577.             libqt4-dev python-numpy ccache python-opengl libgsl0-dev
  578.             python-cheetah python-mako python-lxml doxygen qt4-default qt4-dev-tools libusb-1.0-0-dev
  579.             libqwt-qt5-dev libqwtplot3d-qt4-dev pyqt4-dev-tools python-qwt5-qt4
  580.             cmake git-core wget libxi-dev python-docutils gtk2-engines-pixbuf r-base-dev python-tk
  581.             liborc-0.4-0 liborc-0.4-dev libasound2-dev python-gtk2 libzmq libzmq-dev libzmq1 python-requests
  582.             python-sphinx comedi-dev python-zmq libncurses5 libncurses5-dev"
  583.             CMAKE_FLAG1=-DPythonLibs_FIND_VERSION:STRING="2.7"
  584.             CMAKE_FLAG2=-DPythonInterp_FIND_VERSION:STRING="2.7"
  585.             ;;
  586.  
  587.         *15.*)
  588.             PKGLIST="libqwt6 libfontconfig1-dev libxrender-dev libpulse-dev swig g++
  589.             automake autoconf libtool python-dev libfftw3-dev
  590.             libcppunit-dev libboost-all-dev libusb-dev libusb-1.0-0-dev fort77
  591.             libsdl1.2-dev python-wxgtk2.8 git-core
  592.             libqt4-dev python-numpy ccache python-opengl libgsl0-dev
  593.             python-cheetah python-mako python-lxml doxygen qt4-default qt4-dev-tools libusb-1.0-0-dev
  594.             libqwt5-qt4-dev libqwtplot3d-qt4-dev pyqt4-dev-tools python-qwt5-qt4
  595.             cmake git-core wget libxi-dev python-docutils gtk2-engines-pixbuf r-base-dev python-tk
  596.             liborc-0.4-0 liborc-0.4-dev libasound2-dev python-gtk2 libzmq libzmq-dev libzmq1 libzmq1-dev python-requests
  597.             python-sphinx comedi-dev python-zmq libncurses5 libncurses5-dev"
  598.             CMAKE_FLAG1=-DPythonLibs_FIND_VERSION:STRING="2.7"
  599.             CMAKE_FLAG2=-DPythonInterp_FIND_VERSION:STRING="2.7"
  600.             ;;
  601.                    
  602.         *13.*|*14.*)
  603.             PKGLIST="libfontconfig1-dev libxrender-dev libpulse-dev swig g++
  604.             automake autoconf libtool python-dev libfftw3-dev
  605.             libcppunit-dev libboost-all-dev libusb-dev libusb-1.0-0-dev fort77
  606.             libsdl1.2-dev python-wxgtk2.8 git-core
  607.             libqt4-dev python-numpy ccache python-opengl libgsl0-dev
  608.             python-cheetah python-mako python-lxml doxygen qt4-default qt4-dev-tools libusb-1.0-0-dev
  609.             libqwt5-qt4-dev libqwtplot3d-qt4-dev pyqt4-dev-tools python-qwt5-qt4
  610.             cmake git-core wget libxi-dev python-docutils gtk2-engines-pixbuf r-base-dev python-tk
  611.             liborc-0.4-0 liborc-0.4-dev libasound2-dev python-gtk2 libzmq1 libzmq1-dev libzmq libzmq-dev python-requests
  612.             libncurses5 libncurses5-dev"
  613.             CMAKE_FLAG1=-DPythonLibs_FIND_VERSION:STRING="2.7"
  614.             CMAKE_FLAG2=-DPythonInterp_FIND_VERSION:STRING="2.7"
  615.             ;;
  616.            
  617.         *11.*|*12.10*)
  618.             PKGLIST="libfontconfig1-dev libxrender-dev libpulse-dev swig g++
  619.             automake autoconf libtool python-dev libfftw3-dev
  620.             libcppunit-dev libboost-all-dev libusb-dev libusb-1.0-0-dev fort77
  621.             libsdl1.2-dev python-wxgtk2.8 git-core
  622.             libqt4-dev python-numpy ccache python-opengl libgsl0-dev
  623.             python-cheetah python-mako python-lxml doxygen qt4-dev-tools libusb-1.0-0-dev
  624.             libqwt5-qt4-dev libqwtplot3d-qt4-dev pyqt4-dev-tools python-qwt5-qt4
  625.             cmake git-core wget libxi-dev python-docutils gtk2-engines-pixbuf r-base-dev python-tk
  626.             liborc-0.4-0 liborc-0.4-dev libasound2-dev python-gtk2 libzmq libzmq-dev python-requests"
  627.             CMAKE_FLAG1=-DPythonLibs_FIND_VERSION:STRING="2.7"
  628.             CMAKE_FLAG2=-DPythonInterp_FIND_VERSION:STRING="2.7"
  629.             ;;
  630.        
  631.         *12.04*)
  632.             PKGLIST="libfontconfig1-dev libxrender-dev libpulse-dev swig g++
  633.             automake autoconf libtool python-dev libfftw3-dev
  634.             libcppunit-dev libboost1.48-all-dev libusb-dev libusb-1.0-0-dev fort77
  635.             libsdl1.2-dev python-wxgtk2.8 git-core
  636.             libqt4-dev python-numpy ccache python-opengl libgsl0-dev
  637.             python-cheetah python-mako python-lxml doxygen qt4-dev-tools libusb-1.0-0-dev
  638.             libqwt5-qt4-dev libqwtplot3d-qt4-dev pyqt4-dev-tools python-qwt5-qt4
  639.             cmake git-core wget libxi-dev python-docutils gtk2-engines-pixbuf r-base-dev python-tk
  640.             liborc-0.4-0 liborc-0.4-dev libasound2-dev python-gtk2 libzmq libzmq-dev python-requests"
  641.             ;;
  642.            
  643.         *)
  644.             my_echo Your Ubuntu release must be at least 12.04 to proceed
  645.             doexit WRONGRELEASE
  646.             ;;
  647.         esac
  648.         for pkg in $PKGLIST; do checkpkg $pkg; done
  649.         my_echo Done checking packages
  650.         for pkg in $PKGLIST
  651.         do
  652.             sudo apt-get -y --ignore-missing install $pkg >>$LOGDEV 2>&1
  653.         done
  654.        
  655.     #
  656.     # It's a Debian system
  657.     #
  658.     elif [ -f /etc/debian_version ]
  659.     then
  660.         SYSTYPE=Debian
  661.         sudo apt-get -y purge 'gnuradio-*' >>$LOGDEV 2>&1
  662.         sudo apt-get -y purge 'libgruel-*' >>$LOGDEV 2>&1
  663.         sudo apt-get -y purge 'libgruel*' >>$LOGDEV 2>&1
  664.         sudo apt-get -y purge 'libgruel0*' >>$LOGDEV 2>&1
  665.         sudo apt-get -y purge 'libgnuradio*' >>$LOGDEV 2>&1
  666.         sudo apt-get -y purge 'python-gnuradio*' >>$LOGDEV 2>&1
  667.         case `cat /etc/debian_version` in
  668.         *6.0*|*wheezy*|*sid*|*7.1*|*7.0*|*7.2*|*7.3*|*7.4*|*7.5*|*7.6*|*7.7*)
  669.             PKGLIST="libfontconfig1-dev libxrender-dev libpulse-dev swig g++
  670.             automake autoconf libtool python-dev libfftw3-dev
  671.             libcppunit-dev libboost-all-dev libusb-dev libusb-1.0-0-dev fort77
  672.             libsdl1.2-dev python-wxgtk2.8 git-core
  673.             libqt4-dev python-numpy ccache python-opengl libgsl0-dev
  674.             python-cheetah python-mako python-lxml doxygen qt4-dev-tools libusb-1.0-0-dev
  675.             libqwt5-qt4-dev libqwtplot3d-qt4-dev pyqt4-dev-tools python-qwt5-qt4
  676.             cmake git-core wget libxi-dev python-docutils gtk2-engines-pixbuf r-base-dev python-tk
  677.             liborc-0.4-0 liborc-0.4-dev libasound2-dev python-gtk2 libportaudio2 portaudio19-dev
  678.             ca-certificates libzmq libzmq-dev python-requests libncurses5 libncurses5-dev"
  679.             ;;
  680.         *8.3*)
  681.             PKGLIST="libfontconfig1-dev libxrender-dev libpulse-dev swig g++
  682.             automake autoconf libtool python-dev libfftw3-dev
  683.             libcppunit-dev libboost-all-dev libusb-dev libusb-1.0-0-dev fort77
  684.             libsdl1.2-dev python-wxgtk3.0 git-core
  685.             libqt4-dev python-numpy ccache python-opengl libgsl0-dev
  686.             python-cheetah python-mako python-lxml doxygen qt4-dev-tools libusb-1.0-0-dev
  687.             libqwt5-qt4-dev libqwtplot3d-qt4-dev pyqt4-dev-tools python-qwt5-qt4
  688.             cmake git-core wget libxi-dev python-docutils gtk2-engines-pixbuf r-base-dev python-tk
  689.             liborc-0.4-0 liborc-0.4-dev libasound2-dev python-gtk2 libportaudio2 portaudio19-dev
  690.             ca-certificates libzmq1 libzmq-dev python-requests libncurses5 libncurses5-dev"
  691.             ;;
  692.            
  693.         *)
  694.             my_echo Unsupported Debian version `cat /etc/debian_version`
  695.             doexit WRONGRELEASE
  696.             ;;
  697.         esac
  698.         for pkg in $PKGLIST; do checkpkg $pkg; done
  699.         sudo apt-get -y --ignore-missing install $PKGLIST >>$LOGDEV 2>&1
  700.     elif [ -f /etc/SuSE-release ]
  701.     then
  702.         SYSTYPE=OpenSuSE
  703.         if grep -q 12.1 /etc/SuSE-release
  704.         then
  705.             cool=1
  706.         else
  707.             my_echo Only OpenSuSE 12.1 is supported by this script
  708.             doexit WRONGRELEASE
  709.         fi
  710.         sudo zypper install cmake cppunit-devel doxygen fftw3-devel \
  711.         git gsl-devel libjack-devel libqt4-devel libqwtplot3d-devel \
  712.         libSDL-devel libusb-1_0-devel orc portaudio portaudio-devel \
  713.         python-cheetah python-mako python-devel python-lxml python-wxGTK python-wxWidgets-devel \
  714.         qwt-devel wxWidgets-devel boost-devel xmlto texlive-latex libzmq libzmq-dev  python-requests >>$LOGDEV 2>&1
  715.        
  716.     else
  717.         my_echo This script supports only Ubuntu,Mint,Fedora, Debian and OpenSuse systems
  718.         my_echo Your Fedora system must be at least Fedora 12
  719.         my_echo Your Ubuntu system must be at least Ubuntu 9.04
  720.         my_echo Your Mint system must be at least Mint 11
  721.         my_echo Your Debian system must be release 6
  722.         doexit WRONGSYSTEM
  723.     fi
  724.     PATH=$PATH
  725.     export PATH
  726.  
  727.     checkcmd git
  728.     checkcmd cmake
  729.    
  730.     if [ $SYSTYPE = Fedora ]
  731.     then
  732.         checklib libusb-0 0
  733.         checklib libusb-1 0
  734.     else
  735.         checklib libusb 2
  736.     fi
  737.    
  738.     checklib libboost 5
  739.     checklib libcppunit 0
  740.     checklib libfftw 5
  741.     checklib libgsl 0
  742.    
  743.     my_echo Done
  744. }
  745.  
  746.  
  747. function gitfetch {
  748.     date=`date +%Y%m%d%H%M%S`
  749.     V=3.7/maint
  750.     if [ $MASTER_MODE -eq 1 ]
  751.     then
  752.         V=Master/HEAD
  753.     fi
  754.     if [ $OLD_MODE -eq 1 ]
  755.     then
  756.         V=3.6.5.1
  757.     fi
  758.     echo This script will fetch Gnu Radio version $V from the repositories, along with compatible
  759.     echo  extras.
  760.     echo -n Is this OK?
  761.     read ans
  762.    
  763.     case $ans in
  764.         Y|y|YES|yes|Yes)
  765.             ;;
  766.         *)
  767.             exit
  768.             ;;
  769.     esac
  770.        
  771.  
  772.     my_echo "Fetching various packages (Gnu Radio, UHD, gr-osmosdr, gr-iqbal, etc)"
  773.     my_echo "  via the Internet"
  774.     my_echo "=======> THIS MAY TAKE QUITE SOME TIME <========="
  775.  
  776.     cd $CWD
  777.     for dir in ${PULLED_LIST}
  778.     do
  779.         if [ -d $dir ]
  780.         then
  781.             mv $dir ${dir}.$date
  782.         fi
  783.     done
  784.    
  785.     #
  786.     # GIT the gnu radio source tree
  787.     #
  788.     my_echo -n Fetching Gnu Radio via GIT...
  789.     if [ $JOSHMODE = False ]
  790.     then
  791.         if [ $MASTER_MODE -eq 0 ]
  792.         then
  793.             RECURSE="--recursive"
  794.         else
  795.             RECURSE="--recursive"
  796.         fi
  797.         git clone --progress $RECURSE http://git.gnuradio.org/git/gnuradio.git >>$LOGDEV 2>&1
  798.         if [ ! -d gnuradio/gnuradio-core -a ! -d gnuradio/gnuradio-runtime ]
  799.         then
  800.             my_echo "Could not find gnuradio/gnuradio-{core,runtime} after GIT checkout"
  801.             my_echo GIT checkout of Gnu Radio failed!
  802.             doexit FETCH-GR-FAIL
  803.         fi
  804.         if [ $OLD_MODE -eq 1 ]
  805.         then
  806.             cd gnuradio
  807.             git checkout v3.6.5.1  >>$LOGDEV 2>&1
  808.             cd $CWD
  809.         elif [ $MASTER_MODE -eq 0 ]
  810.         then
  811.             cd gnuradio
  812.             git checkout maint >>$LOGDEV 2>&1
  813.             cd $CWD
  814.         fi
  815.        
  816.         if [ $GTAG != None ]
  817.         then
  818.             cd gnuradio
  819.             git checkout $GTAG >/dev/null 2>&1
  820.             git name-rev HEAD >tmp$$ 2>&1
  821.             if grep -q "$GTAG" tmp$$
  822.             then
  823.                 whee=yes
  824.                 rm -f tmp$$
  825.             else
  826.                 my_echo Could not fetch Gnu Radio tagged $GTAG from GIT
  827.                 rm -f tmp$$
  828.                 doexit FETCH-GR-FAIL-$GTAG
  829.             fi
  830.             cd ..
  831.         fi
  832.     else
  833.         echo Josh mode no longer supported
  834.         doexit FETCH-GR-JOSH-FAIL
  835.     fi
  836.     my_echo Done
  837.  
  838.     #
  839.     # GIT the UHD source tree
  840.     #
  841.     rm -rf uhd
  842.     my_echo -n Fetching UHD via GIT...
  843.     git clone --progress  https://github.com/EttusResearch/uhd >>$LOGDEV 2>&1
  844.  
  845.     if [ ! -d uhd/host ]
  846.     then
  847.         my_echo GIT checkout of UHD FAILED
  848.         rm -f tmp$$
  849.         doexit FETCH-UHD-FAIL
  850.     fi
  851.     if [ $UTAG != None ]
  852.     then
  853.         cd uhd
  854.         git checkout $UTAG >/dev/null 2>&1
  855.         git status >tmp$$ 2>&1
  856.         if grep -q "$UTAG" tmp$$
  857.         then
  858.             whee=yes
  859.             rm -f tmp$$
  860.         else
  861.             my_echo Could not fetch UHD tagged $UTAG from GIT
  862.             rm -f tmp$$
  863.         fi
  864.         cd ..
  865.     fi
  866.    
  867.     #
  868.     # GIT the RTL-SDR source tree
  869.     #
  870.     rm -rf rtl-sdr
  871.     rm -rf gr-osmosdr
  872.     rm  -rf gr-baz
  873.     rm -rf hackrf
  874.     rm -rf bladeRF
  875.     rm -rf airspy
  876.     my_echo Fetching rtl-sdr "(rtl-sdr, gr-osmosdr, gr-iqbal, hackrf, bladeRF and airspy)" via GIT
  877.     git clone --progress git://git.osmocom.org/rtl-sdr >>$LOGDEV 2>&1
  878.     git clone --progress git://git.osmocom.org/gr-osmosdr >>$LOGDEV 2>&1
  879.     git clone --progress git://git.osmocom.org/gr-iqbal.git >>$LOGDEV 2>&1
  880.     git clone https://github.com/Nuand/bladeRF.git >>$LOGDEV 2>&1
  881.     if [ -d gr-iqbal ]
  882.     then
  883.         cd gr-iqbal
  884.         if [ $OLD_MODE -eq 1 ]
  885.         then
  886.             git checkout gr3.6
  887.         fi
  888.         git submodule init  >>$LOGDEV 2>&1
  889.         git submodule update >>$LOGDEV 2>&1
  890.         cd ..
  891.     fi
  892.     git clone --progress https://github.com/mossmann/hackrf.git >>$LOGDEV 2>&1
  893.     (cd $CWD; rm -rf airpsy; mkdir airspy; cd airspy; git clone https://github.com/airspy/host) >>$LOGDEV 2>&1
  894.     my_echo Done
  895. }
  896.  
  897. function uhd_build {
  898.     #
  899.     # UHD build
  900.     #
  901.     sudocheck
  902.     if [ ! -d uhd ]
  903.     then
  904.         my_echo you do not appear to have the \'uhd\' directory
  905.         my_echo you should probably use $0 gitfetch to fetch the appropriate
  906.         my_echo files using GIT
  907.         doexit BUILD-UHD-NOT-THERE
  908.     fi
  909.     if [ $UTAG != None ]
  910.     then
  911.         cd uhd
  912.         git checkout $UTAG >/dev/null 2>&1
  913.         cd ..
  914.     fi
  915.     my_echo Building UHD...
  916.     my_echo "=============> THIS WILL TAKE SOME TIME <============="
  917.     my_echo
  918.     cd uhd/host
  919.     rm -rf build
  920.     if [ ! -d build ]
  921.     then
  922.         mkdir build
  923.     fi
  924.     cd build
  925.     make clean >/dev/null 2>&1
  926.     cmake $CMAKE_FLAG1 $CMAKE_FLAG2 $CMF1 $CMF2  $UCFLAGS ../ >>$LOGDEV 2>&1
  927.     make clean >>$LOGDEV 2>&1
  928.     make $JFLAG >>$LOGDEV 2>&1
  929.     if [ $? -ne 0  ]
  930.     then
  931.         my_echo UHD build apparently failed
  932.         my_echo Exiting UHD build
  933.         doexit UHD-BUILD-FAIL1
  934.     fi
  935.     sudo rm -f /usr/local/lib*/libuhd*
  936.     sudo make $JFLAG install >>$LOGDEV 2>&1
  937.     which uhd_find_devices >/dev/null 2>&1
  938.     x=$?
  939.     if [ $x -ne 0 -a ! -f /usr/local/bin/uhd_find_devices -a ! -f /opt/local/bin/uhd_find_devices ]
  940.     then
  941.         my_echo UHD build/install apparently failed since I cannot find /usr/local/bin/uhd_find_devices
  942.         my_echo after doing make and make install
  943.         my_echo Exiting UHD build
  944.         doexit UHD-BUILD-FAIL2
  945.     fi
  946.     sudo ldconfig >>$LOGDEV 2>&1
  947.     my_echo Done building/installing UHD
  948. }
  949.  
  950. function rtl_build {
  951.     #
  952.     # RTL build
  953.     #
  954.     sudocheck
  955.     cd $CWD
  956.     if [ ! -d rtl-sdr ]
  957.     then
  958.         my_echo you do not appear to have the \'rtl-sdr\' directory
  959.         my_echo you should probably use $0 gitfetch to fetch the appropriate
  960.         my_echo files using GIT
  961.         doexit BUILD-RTL-NOT-THERE
  962.     fi
  963.    
  964.     my_echo -n Building rtl-sdr...
  965.     cd rtl-sdr
  966.     cmake $CMAKE_FLAG1 $CMAKE_FLAG2 $CMF1 $CMF2 . >>$LOGDEV 2>&1
  967.     make clean >>$LOGDEV 2>&1
  968.     make $JFLAG >>$LOGDEV 2>&1
  969.  
  970.     if [ $? -ne 0  ]
  971.     then
  972.         my_echo rtl-sdr build apparently failed
  973.         my_echo Exiting rtl-sdr build
  974.         doexit RTL-BUILD-FAIL1
  975.     fi
  976.     sudo make $JFLAG install >>$LOGDEV 2>&1
  977.     my_echo Done building rtl-sdr
  978.    
  979.     cd $CWD
  980.     if [ -d hackrf ]
  981.     then
  982.         my_echo -n Building hackrf...
  983.         cd hackrf
  984.         cmake $CMAKE_FLAG1 $CMAKE_FLAG2 $CMF1 $CMF2 -DINSTALL_UDEV_RULES=ON host/ >>$LOGDEV 2>&1
  985.         make clean >>$LOGDEV 2>&1
  986.         make >>$LOGDEV 2>&1
  987.         if [ $? -ne 0 ]
  988.         then
  989.             my_echo hackrf build failed
  990.             my_echo Exiting hackrf build
  991.         else
  992.             sudo make install >>$LOGDEV 2>&1
  993.         fi
  994.         my_echo Done building hackrf
  995.         cd $CWD
  996.     fi
  997.     cd $CWD
  998.     if [ -d gr-iqbal ]
  999.     then
  1000.         my_echo -n Building gr-iqbal...
  1001.         cd gr-iqbal
  1002.         mkdir -p build
  1003.         cd build
  1004.         cmake .. $CMAKE_FLAG1 $CMAKE_FLAG2 $CMF1 $CMF2 >>$LOGDEV 2>&1
  1005.         make clean >>$LOGDEV 2>&1
  1006.         make >>$LOGDEV 2>&1
  1007.         if [ $? -ne 0 ]
  1008.         then
  1009.             my_echo gr-iqbal build apparently failed
  1010.             my_echo Exiting gr-iqbal build
  1011.         else
  1012.             sudo make install  >>$LOGDEV 2>&1
  1013.             cd $CWD
  1014.             my_echo Done building gr-iqbal
  1015.         fi
  1016.     fi
  1017.     if [ -d bladeRF  ]
  1018.     then
  1019.         my_echo -n Building bladeRF...
  1020.         cd bladeRF
  1021.         cd host
  1022.         cmake . $CMAKE_FLAG1 $CMAKE_FLAG2 $CMF1 $CMF2 >>$LOGDEV 2>&1
  1023.         make clean >>$LOGDEV 2>&1
  1024.         make >>$LOGDEV 2>&1
  1025.         if [ $? -ne 0 ]
  1026.         then
  1027.             my_echo bladeRF build apparently failed
  1028.             my_echo Exiting bladeRF build
  1029.         else
  1030.             sudo make install >>$LOGDEV 2>&1
  1031.             cd $CWD
  1032.             my_echo Done building bladeRF
  1033.         fi
  1034.     fi
  1035.    
  1036.     if [ -d airspy/host ]
  1037.     then
  1038.         cd airspy/host
  1039.         mkdir build
  1040.         cd build
  1041.         cmake .. $CMAKE_FLAG1 $CMAKE_FLAG2 $CMF1 $CMF2 >>$LOGDEV 2>&1
  1042.         make clean >>$LOGDEV 2>&1
  1043.         make >>$LOGDEV 2>&1
  1044.         if [ $? -ne 0 ]
  1045.         then
  1046.             my_echo airspy build apparently failed
  1047.             my_echo Exiting airspy build
  1048.         else
  1049.             sudo make install >>$LOGDEV 2>&1
  1050.             my_echo Done building airspy
  1051.         fi
  1052.         cd $CWD
  1053.     fi
  1054.    
  1055.  
  1056.     cd $CWD
  1057.     if [ ! -d gr-osmosdr ]
  1058.     then
  1059.         my_echo you do not appear to have the \'gr-osmosdr\' directory
  1060.         my_echo you should probably use $0 gitfetch to fetch the appropriate
  1061.         my_echo files using GIT
  1062.         doexit RTL-BUILD-FAIL2
  1063.     fi
  1064.     cd gr-osmosdr
  1065.     if [ $OLD_MODE -eq 1 ]
  1066.     then
  1067.         git checkout gr3.6 >/dev/null 2>&1
  1068.     fi
  1069.     my_echo -n Building gr-osmosdr...
  1070.     cmake . $CMAKE_FLAG1 $CMAKE_FLAG2 $CMF1 $CMF2 >>$LOGDEV  2>&1
  1071.     make clean >>$LOGDEV 2>&1
  1072.     make $JFLAG >>$LOGDEV 2>&1
  1073.    
  1074.     if [ $? -ne 0 ]
  1075.     then
  1076.         my_echo gr-osmosdr build apparently failed
  1077.         my_echo Exit rtl-sdr/gr-osmosdr build
  1078.         doexit OSMOSDR-BUILD-FAIL
  1079.     fi
  1080.     sudo make $JFLAG install >>$LOGDEV 2>&1
  1081.     my_echo Done building gr-osmosdr
  1082.     sudo ldconfig >>$LOGDEV 2>&1
  1083.    
  1084.     cd $CWD
  1085.     my_echo Done building/installing rtl-sdr/gr-osmosdr
  1086. }
  1087.  
  1088. function firmware {
  1089.     sudocheck
  1090.     FOUND_DOWNLOADER=False
  1091.     dirlist="/usr/local/share /usr/local/lib /usr/local/lib64"
  1092.     prog=uhd_images_downloader
  1093.    
  1094.     PATH=$PATH:/usr/local/bin
  1095.     q=`which $prog 2>/dev/null`
  1096.    
  1097.     if [ @$q@ != @@ ]
  1098.     then
  1099.         sudo -E $q
  1100.     else
  1101.        
  1102.         for dir in $dirlist
  1103.         do
  1104.             if [ -f $dir/uhd/utils/$prog ]
  1105.             then
  1106.                 FOUND_DOWNLOADER=True
  1107.                 DOWNLOADER=$dir/uhd/utils/$prog
  1108.             fi
  1109.         done
  1110.        
  1111.         if [ $FOUND_DOWNLOADER = True ]
  1112.         then
  1113.             sudo -E $DOWNLOADER
  1114.         else
  1115.             my_echo Could not find images downloader: $prog in any of $dirlist
  1116.             doexit UHD-FIRMWARE-FAIL
  1117.         fi
  1118.         my_echo Done downloading firmware to /usr/local/share/uhd/images
  1119.     fi
  1120. }
  1121.  
  1122. function gnuradio_build {
  1123.     sudocheck
  1124.    
  1125.     if [ $JOSHMODE = False ]
  1126.     then
  1127.         if [ ! -d gnuradio ]
  1128.         then
  1129.             my_echo you do not appear to have the \'gnuradio\' directory
  1130.             my_echo you should probably use $0 gitfetch to fetch the appropriate
  1131.             my_echo files using GIT
  1132.             doexit GNURADIO-BUILD-NOT-THERE
  1133.         fi
  1134.         if [ $GTAG != None ]
  1135.         then
  1136.             cd gnuradio
  1137.             git checkout $GTAG >/dev/null 2>&1
  1138.             cd ..
  1139.         fi
  1140.     else
  1141.         echo Josh mode no longer supported
  1142.     fi
  1143.        
  1144.     #
  1145.     # LD stuff
  1146.     #
  1147.     echo /usr/local/lib >tmp$$
  1148.     echo /usr/local/lib64 >>tmp$$
  1149.  
  1150.     if grep -q /usr/local/lib /etc/ld.so.conf.d/*
  1151.     then
  1152.         my_echo /usr/local/lib already in ld.so.conf.d
  1153.     else
  1154.         sudo cp tmp$$ /etc/ld.so.conf.d/local.conf
  1155.     fi
  1156.     rm -f tmp$$
  1157.     my_echo Doing ldconfig...
  1158.     sudo ldconfig >/dev/null 2>&1
  1159.  
  1160.     PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
  1161.    
  1162.     if [ -d /usr/local/lib64/pkgconfig ]
  1163.     then
  1164.         PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig
  1165.     fi
  1166.    
  1167.     export PKG_CONFIG_PATH
  1168.    
  1169.     #
  1170.     # Build Gnuradio
  1171.     #
  1172.     if [ $JOSHMODE = False ]
  1173.     then
  1174.         cd gnuradio
  1175.     else
  1176.         echo Josh mode no longer supported
  1177.         doexit JOSH-MODE-NO
  1178.     fi
  1179.  
  1180.     my_echo Building Gnu Radio...
  1181.     my_echo "=========> THIS WILL TAKE QUITE A WHILE <============="
  1182.     my_echo " "
  1183.     my_echo ...Doing cmake
  1184.     if [ -d build ]
  1185.     then
  1186.         my_echo ...build directory already here
  1187.     else
  1188.         mkdir build
  1189.     fi
  1190.     cd build
  1191.     make clean >/dev/null 2>&1
  1192.     my_echo ...Cmaking
  1193.     cmake -DENABLE_BAD_BOOST=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo $CMAKE_FLAG1 $CMAKE_FLAG2 $CMF1 $CMF2 $GCFLAGS ../ >>$LOGDEV 2>&1
  1194.     my_echo ...Building
  1195.     make $JFLAG clean >>$LOGDEV 2>&1
  1196.     make $JFLAG >>$LOGDEV 2>&1
  1197.     if [ $? -ne 0 ]
  1198.     then
  1199.         my_echo make failed
  1200.         my_echo Exiting Gnu Radio build/install
  1201.         doexit GNURADIO-BUILD-FAIL
  1202.     fi
  1203.     my_echo ...Installing
  1204.     sudo rm -rf /usr/local/include/gnuradio/
  1205.     sudo rm -f /usr/local/lib*/libgnuradio*
  1206.     sudo make $JFLAG install >>$LOGDEV 2>&1
  1207.     sudo ldconfig >>$LOGDEV 2>&1
  1208.     my_echo Done building and installing Gnu Radio
  1209.     my_echo -n GRC freedesktop icons install ...
  1210.     if [ -f /usr/local/libexec/gnuradio/grc_setup_freedesktop ]
  1211.     then
  1212.         sudo chmod 755 /usr/local/libexec/gnuradio/grc_setup_freedesktop
  1213.         sudo /usr/local/libexec/gnuradio/grc_setup_freedesktop install >>$LOGDEV 2>&1
  1214.     fi
  1215.     my_echo Done
  1216. }
  1217.  
  1218. function do_an_extra {
  1219.     if [ -e $1 ]
  1220.     then
  1221.         my_echo Building extra module $1
  1222.         cd $1
  1223.         if [  -f CMakeLists.txt ]
  1224.         then
  1225.             mkdir -p build >>$LOGDEV 2>&1
  1226.             cd build
  1227.             cmake .. $CMAKE_FLAGS1 $CMAKE_FLAGS2 $CMF1 $CMF2 >>$LOGDEV 2>&1
  1228.             make >>$LOGDEV 2>&1
  1229.             sudo make install >>$LOGDEV 2>&1
  1230.             sudo ldconfig
  1231.         elif [ - bootstrap ]
  1232.         then
  1233.             chmod 755 bootstrap
  1234.             ./bootstrap  >>$LOGDEV 2>&1
  1235.             PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig
  1236.             ./configure >>$LOGDEV 2>&1
  1237.             make >>$LOGDEV 2>&1
  1238.             sudo make install >>$LOGDEV 2>&1
  1239.             sudo ldconfig
  1240.         else
  1241.             my_echo Couldnt determine how to make module $1 neither bootstrap nor CmakeLists.txt present
  1242.         fi
  1243.     else
  1244.         my_echo Couldnt build module $1 directory not there
  1245.     fi
  1246. }
  1247.  
  1248. function extras {
  1249.     sudocheck
  1250.     date=`date +%Y%m%d%H%M%S`
  1251.     if [ ! "@$EXTRAS@" = "@@" ]
  1252.     then
  1253.         for module in $EXTRAS
  1254.         do
  1255.             cd $CWD
  1256.             base=`basename $module .git`
  1257.             case $module in
  1258.             git:*|*.git|*github*)
  1259.                 mv $base $base.$date.bgmoved >>$LOGDEV 2>&1
  1260.                 my_echo Doing GIT checkout for extra module $base
  1261.                 git clone $module  >>$LOGDEV 2>&1
  1262.                 do_an_extra $base
  1263.                 ;;
  1264.             htt*:*svn*)
  1265.                 mv $base $base.$date >>$LOGDEV 2>&1
  1266.                 my_echo Doing SVN checkout for extra module $base
  1267.                 svn co $module >>$LOGDEV 2>&1
  1268.                 if [ -e $base/trunk ]
  1269.                 then
  1270.                     do_an_extra $base/trunk
  1271.                 else
  1272.                     do_an_extra $base
  1273.                 fi
  1274.                 ;;
  1275.             *)
  1276.                 my_echo Ignoring malformed extra module $module
  1277.                 ;;
  1278.             esac
  1279.            
  1280.         done
  1281.     fi
  1282.     cd $CWD
  1283. }
  1284.  
  1285. function mod_groups {
  1286.     sudocheck
  1287.     #
  1288.     # Post install stuff
  1289.     #
  1290.     # USRP rules for UDEV and USRP group
  1291.     #
  1292.     #
  1293.     # Check for USRP group, and update if necessary
  1294.     if grep -q usrp /etc/group
  1295.     then
  1296.         my_echo Group \'usrp\' already in /etc/group
  1297.     else
  1298.         sudo /usr/sbin/groupadd usrp
  1299.     fi
  1300.  
  1301.     #
  1302.     # Check that our calling user is in the USRP group, update if necessary
  1303.     #
  1304.     if grep -q usrp.*${USER} /etc/group
  1305.     then
  1306.         my_echo User $USER already in group \'usrp\'
  1307.     else
  1308.         sudo /usr/sbin/usermod -a -G usrp $USER
  1309. cat <<"!EOF!"
  1310. ********************************************************************************
  1311. This script has just modified /etc/group to place your userid '('$USER')' into group 'usrp'
  1312. In order for this change to take effect, you will need to log-out and log back
  1313. in again.  You will not be able to access your USRP1 device until you do this.
  1314.  
  1315. If you wish to allow others on your system to use the USRP1 device, you will need to use:
  1316.  
  1317.   sudo usermod -a -G usrp userid
  1318.  
  1319. For each userid you wish to allow access to the usrp
  1320.  
  1321. ********************************************************************************
  1322.  
  1323. Further
  1324. !EOF!
  1325.     fi
  1326.     if [ "$USERSLIST" = None ]
  1327.     then
  1328.         foo=bar
  1329.     else
  1330.         ul=`echo $USERSLIST|sed -e 's/,/ /g'`
  1331.         for u in $ul
  1332.         do
  1333.             sudo /usr/sbin/usermod -a -G usrp $u
  1334.             my_echo Added $u to group usrp
  1335.         done
  1336.     fi
  1337. }
  1338.  
  1339. function mod_udev {
  1340.     sudocheck
  1341.     #
  1342.     # Check for UHD UDEV rules file, update if exists
  1343.     #
  1344.     if [ -f $CWD/uhd/host/utils/uhd-usrp.rules ]
  1345.     then
  1346.         sudo cp $CWD/uhd/host/utils/uhd-usrp.rules /etc/udev/rules.d/10-usrp.rules
  1347.         sudo chown root /etc/udev/rules.d/10-usrp.rules
  1348.         sudo chgrp root /etc/udev/rules.d/10-usrp.rules
  1349.     fi
  1350.  
  1351.     #
  1352.     # Check for rtl-sdr UDEV rules file, update if exists
  1353.     #
  1354.     rm -f tmp$$
  1355.     if [ -f $CWD/rtl-sdr/rtl-sdr.rules ]
  1356.     then
  1357.         sudo cp $CWD/rtl-sdr/rtl-sdr.rules /etc/udev/rules.d/15-rtl-sdr.rules
  1358.         sudo chown root /etc/udev/rules.d/15-rtl-sdr.rules
  1359.         sudo chgrp root /etc/udev/rules.d/15-rtl-sdr.rules
  1360.     fi
  1361.     sudo killall -HUP udevd
  1362.     sudo udevadm control --reload-rules
  1363. }
  1364.  
  1365. function mod_sysctl {
  1366.     sudocheck
  1367.     #
  1368.     # Modify sysctl.conf as necessary
  1369.     #
  1370.     cat >tmp$$ <<!EOF!
  1371. # Updates for Gnu Radio
  1372. net.core.rmem_max = 1000000
  1373. net.core.wmem_max = 1000000
  1374. kernel.shmmax = 2147483648
  1375. !EOF!
  1376.  
  1377.  
  1378.     if grep -q 'Updates for Gnu Radio' /etc/sysctl.conf
  1379.     then
  1380.         my_echo Required updates to /etc/sysctl.conf already in place
  1381.     else
  1382.         my_echo Applying updates to /etc/sysctl.conf
  1383.         cat /etc/sysctl.conf tmp$$ >tmp2$$
  1384.         chmod 644 tmp2$$
  1385.         sudo mv tmp2$$ /etc/sysctl.conf
  1386.     fi
  1387.  
  1388.     sudo sysctl -w net.core.rmem_max=1000000 >/dev/null 2>&1
  1389.     sudo sysctl -w net.core.wmem_max=1000000 >/dev/null 2>&1
  1390.     sudo sysctl -w kernel.shmmax=2147483648  >/dev/null 2>&1
  1391.      
  1392.     rm -f tmp$$
  1393.     rm -f tmp2$$
  1394.    
  1395.     if grep -q usrp /etc/security/limits.conf
  1396.     then
  1397.         my_echo usrp group already has real-time scheduling privilege
  1398.     else
  1399.         cat >tmp$$ <<!EOF!
  1400. @usrp  - rtprio 50
  1401. !EOF!
  1402.         cat /etc/security/limits.conf tmp$$ >tmp2$$
  1403.         sudo cp tmp2$$ /etc/security/limits.conf
  1404.         sudo chmod 644 /etc/security/limits.conf
  1405.         rm -f tmp$$ tmp2$$
  1406.         my_echo Group \'usrp\' now has real-time scheduling privileges
  1407.         my_echo You will need to log-out and back in again for this to
  1408.         my_echo take effect
  1409.     fi
  1410. }
  1411.  
  1412. function all {
  1413.     my_echo Starting all functions at: `date`
  1414.     cd $CWD
  1415.     prereqs
  1416.     touch -d "15 minutes ago" touch$$
  1417.     if [ -d uhd -a -d gnuradio ]
  1418.     then
  1419.         if [ uhd -ot touch$$ -o gnuradio -ot touch$$ ]
  1420.         then
  1421.             gitfetch
  1422.         else
  1423.             my_echo Skipping git fetch, since \'uhd\' and \'gnuradio\' are new enough
  1424.         fi
  1425.     else
  1426.         gitfetch
  1427.     fi
  1428.     rm -f touch$$
  1429.     for fcn in uhd_build firmware gnuradio_build rtl_build mod_groups mod_udev mod_sysctl pythonpath extras
  1430.     do
  1431.         my_echo Starting function $fcn at: `date`
  1432.         cd $CWD
  1433.         $fcn
  1434.         my_echo Done function $fcn at: `date`
  1435.     done
  1436.     my_echo Done all functions at: `date`
  1437. }
  1438.  
  1439. function pythonpath {
  1440.     for PYVER in 2.6 2.7
  1441.     do
  1442.         for type in "" 64
  1443.         do
  1444.             if [ -d /usr/local/lib${type}/python${PYVER}/site-packages/gnuradio ]
  1445.             then
  1446.                 PYTHONPATH=/usr/local/lib${type}/python${PYVER}/site-packages
  1447.             fi
  1448.             if [ -d /usr/local/lib${type}/python${PYVER}/dist-packages/gnuradio ]
  1449.             then
  1450.                 PYTHONPATH=/usr/local/lib${type}/python${PYVER}/dist-packages
  1451.             fi
  1452.         done
  1453.     done
  1454.     echo
  1455.     echo
  1456.     echo "************************************************************"
  1457.     echo You should probably set your PYTHONPATH to:
  1458.     echo " "
  1459.     echo "    " $PYTHONPATH
  1460.     echo " "
  1461.     echo Using:
  1462.     echo " "
  1463.     echo export PYTHONPATH=$PYTHONPATH
  1464.     echo " "
  1465.     echo in your .bashrc or equivalent file prior to attempting to run
  1466.     echo any Gnu Radio applications or Gnu Radio Companion.
  1467.     echo "*************************************************************"
  1468. }
  1469.  
  1470. function sudocheck {
  1471.     #
  1472.     # Check SUDO privileges
  1473.     #
  1474.     if [ $SUDOASKED = n ]
  1475.     then
  1476.         echo SUDO privileges are required
  1477.         echo -n Do you have SUDO privileges'?'
  1478.         read ans
  1479.         case $ans in
  1480.             y|Y|YES|yes|Yes)
  1481.                 echo Continuing with script
  1482.                 SUDOASKED=y
  1483.                 sudo grep timestamp_timeout /etc/sudoers >tmp$$
  1484.                 timeout=`cat tmp$$|awk '/./ {print $4}'`
  1485.                 rm -f tmp$$
  1486.                 if [ "@@" = "@$timeout@" ]
  1487.                 then
  1488.                     sudo cp /etc/sudoers tmp$$
  1489.                     sudo chown $USER tmp$$
  1490.                     sudo chmod 644 tmp$$
  1491.                     echo "Defaults  timestamp_timeout = 90" >>tmp$$
  1492.                     sudo cp tmp$$ /etc/sudoers
  1493.                     sudo chown root /etc/sudoers
  1494.                     sudo chmod 440 /etc/sudoers
  1495.                 elif [ "$timeout" -lt 90 ]
  1496.                 then
  1497.                     echo You need to have a timestamp_timeout in /etc/sudoers of 90 or more
  1498.                     echo Please ensure that your timestamp_timeout is 90 or more
  1499.                     exit
  1500.                 fi
  1501.                 ;;
  1502.             *)
  1503.                 echo Exiting.  Please ensure that you have SUDO privileges on this system!
  1504.                 exit
  1505.                 ;;
  1506.         esac
  1507.     fi
  1508. }
  1509.  
  1510. PATH=$PATH
  1511. export PATH
  1512. case $# in
  1513.     0)
  1514.         all
  1515.         my_echo All Done
  1516.         doexit SUCCESS
  1517. esac
  1518.  
  1519. for arg in $*
  1520. do
  1521.     cd $CWD
  1522.     $arg
  1523. done
  1524. my_echo All Done
  1525. doexit SUCCESS
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement