The script for Installing UHD+GNUradio

来源:互联网 发布:网络集成技术课后答案 编辑:程序博客网 时间:2024/05/17 01:00
#!/bin/bash## Build script for UHD+GnuRadio on Fedora and Ubuntu#### Updates: https://github.com/guruofquality/grextras/wiki# Updates: https://github.com/balint256/gr-baz.git#### Exit function--Id like to be able to upload stats to a website somewhere...#function doexit{cat <<"!EOF!"=======================================================================If you have found this script useful and time-saving, consider a donation to help me keep build-gnuradio, simple_ra, SIDsuite,meteor_detector, simple_fm_rcv, and multimode maintained and up to date.A simple paypal transfer to mleech@ripnet.com is all you need to do.======================================================================!EOF!echo -n "Send success/fail info to sbrac.org?"read anscase $ans iny|Y|YES|yes|Yes)wget http://www.sbrac.org/bgrstats.php?status="$1"?systype=${SYSTYPE}?sysinfo="`uname -a`" >/dev/null 2>&1echo Thanks;;esacexit}function help {cat <<!EOF!Usage: build-gnuradio [--help|-h] [-v|--verbose] [-jN] [-ja]                       [-l|--logfile logfile ] [-u|--users ulist] [-m] funcs-m             - Use HEAD of *master* branch, rather than *maint*.-o             - Use v3.6.5.1-v|--verbose   - turn on verbose logging to stdout-jN            - have make use N concurrent jobs-ja            - have make use N concurrent jobs with auto setting of N                 (based on number of cpu cores on build system)                 -u|--users ul  - add comma-separated users to 'usrp' group in addition                 to calling user ( $USER )                                 -l|--logfile lf - log messages to 'lf'-ut <tag>       - set tag for UHD checkout to <tag>-ucf <ucflags>  - set UHD CMake flags to <ucflags>-gt <tag>       - set tag for Gnu Radio checkout to <tag>-gcf <gcflags>  - set Gnu Radio CMake flags to <gcflags>-e|--extras     - add an item to "extras" to be built after Gnu Radio/UHD/gs-osmosdravailable funcs are:all             - do all functionsprereqs         - install prerequisitesgitfetch        - use GIT to fetch Gnu Radio and UHDuhd_build       - build only UHDfirmware        - fetch firmware/FPGAgnuradio_build  - build only Gnu Radiomod_groups      - modify the /etc/groups and add user to group 'usrp'mod_udev        - add UDEV rule for USRP1mod_sysctl      - modify SYSCTL for larger net buffers!EOF!}if [ $USER = root -o $UID -eq 0 ]thenecho Please run this script as an ordinary userecho   it will acquire root privileges as it needs them via \"sudo\".exitfiVERBOSE=NoJFLAG=""LOGDEV=/dev/nullUSERSLIST=NoneJOSHMODE=FalseUTAG=NoneGTAG=Noneexport LC_LANG=CEXTRAS=""MASTER_MODE=0OLD_MODE=0PULLED_LIST="gnuradio uhd rtl-sdr gr-osmosdr gr-iqbal hackrf gr-baz bladeRF libairspy"which python3 >/dev/null 2>&1if [ $? -eq 0 ]thenCMAKE_FLAG1=-DPythonLibs_FIND_VERSION:STRING="2.7"CMAKE_FLAG2=-DPythonInterp_FIND_VERSION:STRING="2.7"fiwhile : docase $1 in-ja)cnt=`grep 'processor.*:' /proc/cpuinfo|wc -l`cnt=`expr $cnt - 1`if [ $cnt -lt 1 ]thencnt=1fiJFLAG=-j$cntshift;;-j[123456789])JFLAG=$1shift;;-v|--verbose)LOGDEV=/dev/stdoutshift;;-l|--logfile)case $2 in/*)LOGDEV=$2;;*)LOGDEV=`pwd`/$2;;esacshiftshiftrm -f $LOGDEVecho $LOGDEV Starts at: `date` >>$LOGDEV 2>&1;;-u|--users)USERSLIST=$2shiftshift;;-m|--master)MASTER_MODE=1shift;;        -o|--old)            OLD_MODE=1            shift            ;;            -h|--help)helpexit;;-ut)UTAG=$2shiftshift;;-ucf)UCFLAGS=$2shift 2;;-gt)GTAG=$2shiftshift;;-gcf)GCFLAGS=$2shiftshift;;-e|--extras)EXTRAS=$EXTRAS" "$2shift 2;;-*)echo Unrecognized option: $1echohelpexitbreak;;*)break;;esacdoneCWD=`pwd`SUDOASKED=nSYSTYPE=unknowngood_to_go=nofor file in /etc/fedora-release /etc/linuxmint/info /etc/lsb-release /etc/debian_version /etc/redhat-releasedoif [ -f $file ]thengood_to_go=yesfidoneif [ $good_to_go = no ]thenecho Supported systems: Fedora, Ubuntu, Redhat, Debian, Mint, OpenSuseecho You appear to be running none of the above, exitingexitfiecho This script will install Gnu Radio from current GIT sourcesecho You will require Internet access from the computer on which thisecho script runs.  You will also require SUDO access.  You will requireecho approximately 500MB of free disk space to perform the build.echo " "echo This script will, as a side-effect, remove any existing Gnu Radioecho installation that was installed from your Linux distribution packages.echo It must do this to prevent problems due to interference betweenecho a linux-distribution-installed Gnu Radio/UHD and one installed from GIT source.echo " "echo The whole process may take up to two hours to complete, depending on theecho capabilities of your system.echoecho "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"echo NOTE: if you run into problems while running this script, you can re-run it withecho the --verbose option to produce lots of diagnostic output to help debug problems.echo This script has been written to anticipate some of the more common problems one mightecho encounter building ANY large, complex software package.  But it is not pefect, andecho there are certainly some situations it could encounter that it cannot deal withecho gracefully.  Altering the system configuration from something reasonably standard,echo removing parts of the filesystem, moving system libraries around arbitrarily, etc,echo it likely cannot cope with.  It is just a script.  It isn\'t intuitive or artificiallyecho intelligent.  It tries to make life a little easier for you, but at the end of the dayecho if it runs into trouble, a certain amount of knowledge on your part aboutecho system configuration and idiosyncrasies will inevitably be necessary.echoechoecho -n Proceed?read anscase $ans iny|Y|YES|yes|Yes)PROCEED=y;;*)exitesacSPACE=`df $HOME| grep -v blocks|grep '%'`SPACE=`echo $SPACE | awk '/./ {n=NF-2; printf ("%d\n", $n/1.0e3)}'`if [ $SPACE -lt 500 ]thenecho "You don't appear to have enough free disk space on $HOME"echo to complete this build/installecho exitingdoexit DISKSPACEfitotal=0for file in $PULLED_LISTdofound=0for instance in ${file}.20*doif [ -d $instance ]thenfound=1sz=`du -s $instance|awk '{print $1}'`total=`expr $total + $sz`fidonedonetotal=`expr $total '*' 1024`total=`expr $total / 1000000`if [ $total -gt 100 ]thenecho Your old 'uhd.*' and 'gnuradio.*' etc directories are using roughly $total MBecho of disk space:for file in $PULLED_LISTdofor instance in ${file}.20*doif [ -d $instance ]thenls -ld $instancefidonedoneecho " "echo -n Remove them'?'read anscase $ans iny|Y|YES|yes|Yes)for file in $PULLED_LISTdofor instance in ${file}.20*doif [ -d $instance ]thenecho removing ${instance}rm -rf ${instance}fidonedoneecho Done;;esacfirm -rf *.20*.bgmovedfunction my_echo {if [ $LOGDEV = /dev/stdout ]thenecho $*elseecho $*echo $* >>$LOGDEV 2>&1fi}function checkcmd {found=0which $1 >/dev/null 2>&1x=$?if [ $x -eq 0 ]thenfound=1fifor place in /bin /usr/bin /usr/local/bin /sbin /usr/sbin /usr/local/sbin /opt/bin /opt/local/bindoif [ -e $place/$1 ]thenfound=1fidoneif [ $found -eq 0 ]thenwhich $1 >/dev/null 2>&1if [ $? -eq 0 ]thenfound=1fifiif [ $found -eq 0 ]thenmy_echo Failed to find just-installed command \'$1\' after pre-requisite installation.my_echo This very likely indicates that the pre-requisite installation failedmy_echo to install one or more critical pre-requisites for Gnu Radio/UHDdoexit PREREQFAIL-CMD-$1fi}function checklib {found=0my_echo -n Checking for library $1 ...for dir in /lib /usr/lib /usr/lib64 /lib64 /usr/lib/x86_64-linux-gnu /usr/lib/i386-linux-gnu \    /usr/lib/arm-linux-gnueabihf /usr/lib/arm-linux-gnueabidofor file in $dir/${1}*.so*doif [ -e "$file" ]thenfound=1fidonedoneif [ $found -le 0 ]thenmy_echo Failed to find libraries with prefix \'$1\' after pre-requisite installation.my_echo This very likely indicates that the pre-requisite installation failedmy_echo to install one or more critical pre-requisites for Gnu Radio/UHDmy_echo exiting builddoexit PREREQFAIL-LIB-$1elsemy_echo Found library $1fi}function checkpkg {my_echo Checking for package $1if [ `apt-cache search $1 | wc -l` -eq 0 ]thenmy_echo Failed to find package \'$1\' in known package repositoriesmy_echo SOME THINGS MAY NOT BUILD AS A RESULT# doexit PREREQFAIL-PKG-$1fi}function prereqs {sudocheckmy_echo Installing prerequisites.my_echo "====>" THIS MAY TAKE QUITE SOME TIME "<====="## It's a Fedora system#if [ -f /etc/fedora-release ]thenSYSTYPE=Fedoracase `cat /etc/fedora-release` in*12*|*13*|*14*|*15*|*16*|*17*|*18*)sudo yum -y erase 'gnuradio*' >>$LOGDEV 2>&1sudo yum -y erase 'libgruel-*' >>$LOGDEV 2>&1sudo yum -y erase 'libgruel*' >>$LOGDEV 2>&1sudo yum -y groupinstall "Engineering and Scientific" "Development Tools" \"Software Development Tools" "C Development Tools and Libraries" >>$LOGDEV 2>&1sudo yum -y install fftw-devel cppunit-devel wxPython-devel \  boost-devel alsa-lib-devel numpy gsl-devel python-devel pygsl \  python-cheetah python-mako python-lxml PyOpenGL qt-devel qt qt4 qt4-devel \  PyQt4-devel qwt-devel qwtplot3d-qt4-devel libusb-devel libusb \  libusb1 libusb1-devel cmake git wget python-docutils \  PyQwt PyQwt-devel qwt-devel gtk2-engines xmlrpc-c-"*" tkinter orc python-requests \  orc-devel python-sphinx SDL-devel swig libzmq >>$LOGDEV 2>&1;;*19*|*20*|*21*)sudo yum -y erase 'gnuradio*' >>$LOGDEV 2>&1sudo yum -y erase 'libgruel-*' >>$LOGDEV 2>&1sudo yum -y erase 'libgruel*' >>$LOGDEV 2>&1sudo yum -y groupinstall "Engineering and Scientific" "Development Tools" \"Software Development Tools" "C Development Tools and Libraries" >>$LOGDEV 2>&1sudo yum -y install fftw-devel cppunit-devel wxPython-devel \  boost-devel alsa-lib-devel numpy gsl-devel python-devel pygsl \  python-cheetah python-mako python-lxml PyOpenGL qt-devel qt qt4 qt4-devel \  PyQt4-devel qwt-devel qwtplot3d-qt4-devel \  libusbx-devel cmake git wget python-docutils cppzmq-devel \  PyQwt PyQwt-devel qwt-devel gtk2-engines xmlrpc-c-"*" tkinter orc \  orc-devel python-sphinx SDL-devel swig  zeromq2-devel python-zmq comedilib comedilib-devel thrift-devel \  python-thrift scipy >>$LOGDEV 2>&1  ;;*22*|*23*)sudo dnf -y erase 'gnuradio*' >>$LOGDEV 2>&1sudo dnf -y erase 'libgruel-*' >>$LOGDEV 2>&1sudo dnf -y erase 'libgruel*' >>$LOGDEV 2>&1sudo dnf -y groupinstall "Engineering and Scientific" "Development Tools" \"Software Development Tools" "C Development Tools and Libraries" >>$LOGDEV 2>&1sudo dnf -y install fftw-devel cppunit-devel wxPython-devel boost-devel \alsa-lib-devel numpy gsl-devel python-devel pygsl python-cheetah python-mako \python-lxml PyOpenGL qt-devel PyQt4-devel qwt-devel qwtplot3d-qt4-devel \libusbx-devel cmake python-docutils PyQwt PyQwt-devel gtk2-engines xmlrpc-c-"*" \tkinter  orc-devel python-sphinx SDL-devel swig perl-ZMQ-LibZMQ2 perl-ZMQ-LibZMQ2 \zeromq zeromq-devel python-requests \gcc-c++ doxygen zeromq-ada-devel  cppzmq-devel \perl-ZeroMQ    amavisd-new-zeromq amavisd-new-snmp-zeromq    \php-zmq   python-zmq  czmq  uwsgi-logger-zeromq \comedilib comedilib-develpygtk2 ncurses-"*" thrift-devel python-thrift scipy >>$LOGDEV 2>&1;;*)my_echo Only Fedora release 12 - 23 are supported by this scriptdoexit WRONGRELEASE;;esac## It's a RedHat systemelif [ -f /etc/redhat-release ]thenSYSTYPE=Redhatcase `cat /etc/redhat-release` in*elease*6*)sudo yum -y erase 'gnuradio*' >>$LOGDEV 2>&1sudo yum -y erase 'libgruel-*' >>$LOGDEV 2>&1sudo yum -y erase 'libgruel*' >>$LOGDEV 2>&1sudo yum -y groupinstall "Engineering and Scientific" "Development Tools" >>$LOGDEV 2>&1sudo yum -y install fftw-devel cppunit-devel wxPython-devel libusb-devel \  boost-devel alsa-lib-devel numpy gsl-devel python-devel pygsl \  python-cheetah python-mako python-lxml PyOpenGL qt-devel qt qt4 qt4-devel \  PyQt4-devel qwt-devel qwtplot3d-qt4-devel libusb libusb-devel \  libusb1 libusb1-devel cmake git wget python-docutils \  PyQwt PyQwt-devel qwt-devel gtk2-engines xmlrpc-c-"*" libzmq libzmq-dev \  ncurses-"*" tkinter orc python-requests >>$LOGDEV 2>&1;;*elease*7*)sudo yum -y erase 'gnuradio*' >>$LOGDEV 2>&1sudo yum -y erase 'libgruel-*' >>$LOGDEV 2>&1sudo yum -y erase 'libgruel*' >>$LOGDEV 2>&1sudo yum -y install fftw-devel    cppunit-develpython-devellibusb-devel \boost-develalsa-lib-devel    numpy    gsl-devel    python-cheetah    \python-mako    qt-devel    PyOpenGL    PyQt4-devel    libusb1-devel    \cmake    python-docutils    qt-devel gcc-c++ swig >>$LOGDEV 2>&1sudo yum install -y epel-release >>$LOGDEV 2>&1sudo yum -y update >>$LOGDEV 2>&1sudo yum -y install libsphinxclient-devel    php-pecl-sphinx    python-catkin-sphinx    \python-ipython-sphinx git \python-oslo-sphinx    python-sphinx-doc    python-sphinx-theme-openlmi    \python-sphinx_rtd_theme    python-sphinxcontrib-adadomain    \python-sphinxcontrib-cheeseshop    python-sphinxcontrib-httpdomain    \python-sphinxcontrib-issuetracker    python-sphinxcontrib-napoleon    sphinx-java    \sphinx-php      python-cornice-sphinx     python-sphinx    sphinx     libsphinxclient \qwt-devel qwt-doc qwtpolar qwtpolar-devel qwtpolar-doc qwt \cppzmq-devel     perl-ZMQ-Constants     perl-ZMQ-LibZMQ3     czmq    \python-txzmq    python-zmq python-zmq-tests cmake-guiwxPython-devel \ncurses-"*"  >>$LOGDEV 2>&1;;*)my_echo Your Redhat system release must be release 6 or 7 to proceeddoexit WRONGRELEASE;;esac## It's a Mint system#elif [ -f /etc/linuxmint/info ]thenSYSTYPE=Mintsudo apt-get -y purge 'gnuradio-*' >>$LOGDEV 2>&1sudo apt-get -y purge 'libgruel-*' >>$LOGDEV 2>&1sudo apt-get -y purge 'libgruel*' >>$LOGDEV 2>&1sudo apt-get -y purge 'libgruel0*' >>$LOGDEV 2>&1sudo apt-get -y purge 'libgnuradio*' >>$LOGDEV 2>&1sudo apt-get -y purge 'python-gnuradio*' >>$LOGDEV 2>&1case `grep RELEASE /etc/linuxmint/info` in*11*|*12*|*13*|*14*|*15*|*16*|*17*)PKGLIST="libfontconfig1-dev libxrender-dev libpulse-dev swig g++automake autoconf libtool python-dev libfftw3-devlibcppunit-dev libboost-all-dev libusb-dev libusb-1.0-0-dev fort77libsdl1.2-dev python-wxgtk2.8 git-corelibqt4-dev python-numpy ccache python-opengl libgsl0-devpython-cheetah python-mako python-lxml doxygen qt4-dev-tools libusb-1.0-0-devlibqwt5-qt4-dev libqwtplot3d-qt4-dev pyqt4-dev-tools python-qwt5-qt4cmake git-core wget libxi-dev python-docutils gtk2-engines-pixbuf r-base-dev python-tkliborc-0.4-0 liborc-0.4-dev libasound2-dev python-gtk2 libzmq libzmq-dev libzmq1 libzmq1-dev python-requestslibncurses5 libncurses5-dev";;*18*)PKGLIST="libfontconfig1-dev libxrender-dev libpulse-dev swig g++automake autoconf libtool python-dev libfftw3-devlibcppunit-dev libboost-all-dev libusb-dev libusb-1.0-0-dev fort77libsdl1.2-dev python-wxgtk3.0 git-corelibqt4-dev python-numpy ccache python-opengl libgsl0-devpython-cheetah python-mako python-lxml doxygen qt4-dev-tools libusb-1.0-0-devlibqwt5-qt4-dev libqwtplot3d-qt4-dev pyqt4-dev-tools python-qwt5-qt4cmake git-core wget libxi-dev python-docutils gtk2-engines-pixbuf r-base-dev python-tkliborc-0.4-0 liborc-0.4-dev libasound2-dev python-gtk2 libzmq libzmq-dev  python-requestslibncurses5 libncurses5-dev";;*)my_echo Your Mint release must be at least Linux Mint 11 to proceeddoexit WRONGRELEASE;;esacfor pkg in $PKGLIST; do checkpkg $pkg; donefor pkg in $PKGLISTdosudo apt-get -y --ignore-missing install $pkg >>$LOGDEV 2>&1done## It's a Ubuntu system# elif [ -f /etc/lsb-release -a ! -f /etc/SuSE-release ]thenSYSTYPE=Ubuntusudo apt-get -y purge 'gnuradio-*' >>$LOGDEV 2>&1sudo apt-get -y purge 'libgruel-*' >>$LOGDEV 2>&1sudo apt-get -y purge 'libgruel*' >>$LOGDEV 2>&1sudo apt-get -y purge 'libgruel0*' >>$LOGDEV 2>&1sudo apt-get -y purge 'libgnuradio*' >>$LOGDEV 2>&1sudo apt-get -y purge 'python-gnuradio*' >>$LOGDEV 2>&1case `grep DISTRIB_RELEASE /etc/lsb-release` in*15.*|*16.*)PKGLIST="libqwt6 libfontconfig1-dev libxrender-dev libpulse-dev swig g++automake autoconf libtool python-dev libfftw3-devlibcppunit-dev libboost-all-dev libusb-dev libusb-1.0-0-dev fort77libsdl1.2-dev python-wxgtk2.8 git-corelibqt4-dev python-numpy ccache python-opengl libgsl0-devpython-cheetah python-mako python-lxml doxygen qt4-default qt4-dev-tools libusb-1.0-0-devlibqwt5-qt4-dev libqwtplot3d-qt4-dev pyqt4-dev-tools python-qwt5-qt4cmake git-core wget libxi-dev python-docutils gtk2-engines-pixbuf r-base-dev python-tkliborc-0.4-0 liborc-0.4-dev libasound2-dev python-gtk2 libzmq libzmq-dev libzmq1 libzmq1-dev python-requestspython-sphinx comedi-dev python-zmq libncurses5 libncurses5-dev python-wxgtk3.0"CMAKE_FLAG1=-DPythonLibs_FIND_VERSION:STRING="2.7"CMAKE_FLAG2=-DPythonInterp_FIND_VERSION:STRING="2.7";;*13.*|*14.*)PKGLIST="libfontconfig1-dev libxrender-dev libpulse-dev swig g++automake autoconf libtool python-dev libfftw3-devlibcppunit-dev libboost-all-dev libusb-dev libusb-1.0-0-dev fort77libsdl1.2-dev python-wxgtk2.8 git-corelibqt4-dev python-numpy ccache python-opengl libgsl0-devpython-cheetah python-mako python-lxml doxygen qt4-default qt4-dev-tools libusb-1.0-0-devlibqwt5-qt4-dev libqwtplot3d-qt4-dev pyqt4-dev-tools python-qwt5-qt4cmake git-core wget libxi-dev python-docutils gtk2-engines-pixbuf r-base-dev python-tkliborc-0.4-0 liborc-0.4-dev libasound2-dev python-gtk2 libzmq1 libzmq1-dev libzmq libzmq-dev python-requestslibncurses5 libncurses5-dev"CMAKE_FLAG1=-DPythonLibs_FIND_VERSION:STRING="2.7"CMAKE_FLAG2=-DPythonInterp_FIND_VERSION:STRING="2.7";;*11.*|*12.10*)PKGLIST="libfontconfig1-dev libxrender-dev libpulse-dev swig g++automake autoconf libtool python-dev libfftw3-devlibcppunit-dev libboost-all-dev libusb-dev libusb-1.0-0-dev fort77libsdl1.2-dev python-wxgtk2.8 git-corelibqt4-dev python-numpy ccache python-opengl libgsl0-devpython-cheetah python-mako python-lxml doxygen qt4-dev-tools libusb-1.0-0-devlibqwt5-qt4-dev libqwtplot3d-qt4-dev pyqt4-dev-tools python-qwt5-qt4cmake git-core wget libxi-dev python-docutils gtk2-engines-pixbuf r-base-dev python-tkliborc-0.4-0 liborc-0.4-dev libasound2-dev python-gtk2 libzmq libzmq-dev python-requests"CMAKE_FLAG1=-DPythonLibs_FIND_VERSION:STRING="2.7"CMAKE_FLAG2=-DPythonInterp_FIND_VERSION:STRING="2.7";;*12.04*)PKGLIST="libfontconfig1-dev libxrender-dev libpulse-dev swig g++automake autoconf libtool python-dev libfftw3-devlibcppunit-dev libboost1.48-all-dev libusb-dev libusb-1.0-0-dev fort77libsdl1.2-dev python-wxgtk2.8 git-corelibqt4-dev python-numpy ccache python-opengl libgsl0-devpython-cheetah python-mako python-lxml doxygen qt4-dev-tools libusb-1.0-0-devlibqwt5-qt4-dev libqwtplot3d-qt4-dev pyqt4-dev-tools python-qwt5-qt4cmake git-core wget libxi-dev python-docutils gtk2-engines-pixbuf r-base-dev python-tkliborc-0.4-0 liborc-0.4-dev libasound2-dev python-gtk2 libzmq libzmq-dev python-requests";;*)my_echo Your Ubuntu release not supported--cannot proceeddoexit WRONGRELEASE;;esacfor pkg in $PKGLIST; do checkpkg $pkg; donemy_echo Done checking packagesfor pkg in $PKGLISTdosudo apt-get -y --ignore-missing install $pkg >>$LOGDEV 2>&1done## It's a Debian system#elif [ -f /etc/debian_version ]thenSYSTYPE=Debiansudo apt-get -y purge 'gnuradio-*' >>$LOGDEV 2>&1sudo apt-get -y purge 'libgruel-*' >>$LOGDEV 2>&1sudo apt-get -y purge 'libgruel*' >>$LOGDEV 2>&1sudo apt-get -y purge 'libgruel0*' >>$LOGDEV 2>&1sudo apt-get -y purge 'libgnuradio*' >>$LOGDEV 2>&1sudo apt-get -y purge 'python-gnuradio*' >>$LOGDEV 2>&1case `cat /etc/debian_version` in*6.0*|*wheezy*|*sid*|*7.1*|*7.0*|*7.2*|*7.3*|*7.4*|*7.5*|*7.6*|*7.7*)PKGLIST="libfontconfig1-dev libxrender-dev libpulse-dev swig g++automake autoconf libtool python-dev libfftw3-devlibcppunit-dev libboost-all-dev libusb-dev libusb-1.0-0-dev fort77libsdl1.2-dev python-wxgtk2.8 git-corelibqt4-dev python-numpy ccache python-opengl libgsl0-devpython-cheetah python-mako python-lxml doxygen qt4-dev-tools libusb-1.0-0-devlibqwt5-qt4-dev libqwtplot3d-qt4-dev pyqt4-dev-tools python-qwt5-qt4cmake git-core wget libxi-dev python-docutils gtk2-engines-pixbuf r-base-dev python-tkliborc-0.4-0 liborc-0.4-dev libasound2-dev python-gtk2 libportaudio2 portaudio19-devca-certificates libzmq libzmq-dev python-requests libncurses5 libncurses5-dev";;*8.3*)PKGLIST="libfontconfig1-dev libxrender-dev libpulse-dev swig g++automake autoconf libtool python-dev libfftw3-devlibcppunit-dev libboost-all-dev libusb-dev libusb-1.0-0-dev fort77libsdl1.2-dev python-wxgtk3.0 git-corelibqt4-dev python-numpy ccache python-opengl libgsl0-devpython-cheetah python-mako python-lxml doxygen qt4-dev-tools libusb-1.0-0-devlibqwt5-qt4-dev libqwtplot3d-qt4-dev pyqt4-dev-tools python-qwt5-qt4cmake git-core wget libxi-dev python-docutils gtk2-engines-pixbuf r-base-dev python-tkliborc-0.4-0 liborc-0.4-dev libasound2-dev python-gtk2 libportaudio2 portaudio19-devca-certificates libzmq1 libzmq-dev python-requests libncurses5 libncurses5-dev";;*)my_echo Unsupported Debian version `cat /etc/debian_version`doexit WRONGRELEASE;;esacfor pkg in $PKGLIST; do checkpkg $pkg; donesudo apt-get -y --ignore-missing install $PKGLIST >>$LOGDEV 2>&1elif [ -f /etc/SuSE-release ]thenSYSTYPE=OpenSuSEif grep -q 12.1 /etc/SuSE-releasethencool=1elsemy_echo Only OpenSuSE 12.1 is supported by this scriptdoexit WRONGRELEASEfisudo zypper install cmake cppunit-devel doxygen fftw3-devel \git gsl-devel libjack-devel libqt4-devel libqwtplot3d-devel \libSDL-devel libusb-1_0-devel orc portaudio portaudio-devel \python-cheetah python-mako python-devel python-lxml python-wxGTK python-wxWidgets-devel \qwt-devel wxWidgets-devel boost-devel xmlto texlive-latex libzmq libzmq-dev  python-requests >>$LOGDEV 2>&1elsemy_echo This script supports only Ubuntu,Mint,Fedora, Debian and OpenSuse systemsmy_echo Your Fedora system must be at least Fedora 12my_echo Your Ubuntu system must be at least Ubuntu 9.04my_echo Your Mint system must be at least Mint 11my_echo Your Debian system must be release 6doexit WRONGSYSTEMfiPATH=$PATHexport PATHcheckcmd gitcheckcmd cmakeif [ $SYSTYPE = Fedora ]thenchecklib libusb-0 0checklib libusb-1 0elsechecklib libusb 2fichecklib libboost 5checklib libcppunit 0checklib libfftw 5checklib libgsl 0my_echo Done}function gitfetch {date=`date +%Y%m%d%H%M%S`V=3.7/maintif [ $MASTER_MODE -eq 1 ]thenV=Master/HEADfiif [ $OLD_MODE -eq 1 ]thenV=3.6.5.1fiecho This script will fetch Gnu Radio version $V from the repositories, along with compatibleecho  extras.echo -n Is this OK?read anscase $ans inY|y|YES|yes|Yes);;*)exit;;esacmy_echo "Fetching various packages (Gnu Radio, UHD, gr-osmosdr, gr-iqbal, etc)"my_echo "  via the Internet"my_echo "=======> THIS MAY TAKE QUITE SOME TIME <========="cd $CWDfor dir in ${PULLED_LIST}doif [ -d $dir ]thenmv $dir ${dir}.$datefidone## GIT the gnu radio source tree#my_echo -n Fetching Gnu Radio via GIT...if [ $JOSHMODE = False ]thenif [ $MASTER_MODE -eq 0 ]thenRECURSE="--recursive"elseRECURSE="--recursive"figit clone --progress $RECURSE http://git.gnuradio.org/git/gnuradio.git >>$LOGDEV 2>&1if [ ! -d gnuradio/gnuradio-core -a ! -d gnuradio/gnuradio-runtime ]thenmy_echo "Could not find gnuradio/gnuradio-{core,runtime} after GIT checkout"my_echo GIT checkout of Gnu Radio failed!doexit FETCH-GR-FAILfiif [ $OLD_MODE -eq 1 ]thencd gnuradiogit checkout v3.6.5.1  >>$LOGDEV 2>&1cd $CWDelif [ $MASTER_MODE -eq 0 ]thencd gnuradiogit checkout maint >>$LOGDEV 2>&1cd $CWDfiif [ $GTAG != None ]thencd gnuradiogit checkout $GTAG >/dev/null 2>&1git name-rev HEAD >tmp$$ 2>&1if grep -q "$GTAG" tmp$$thenwhee=yesrm -f tmp$$elsemy_echo Could not fetch Gnu Radio tagged $GTAG from GITrm -f tmp$$doexit FETCH-GR-FAIL-$GTAGficd ..fielseecho Josh mode no longer supporteddoexit FETCH-GR-JOSH-FAILfimy_echo Done## GIT the UHD source tree#rm -rf uhdmy_echo -n Fetching UHD via GIT...git clone --progress  https://github.com/EttusResearch/uhd >>$LOGDEV 2>&1if [ ! -d uhd/host ]thenmy_echo GIT checkout of UHD FAILEDrm -f tmp$$doexit FETCH-UHD-FAILfiif [ $UTAG != None ]thencd uhdgit checkout $UTAG >/dev/null 2>&1git status >tmp$$ 2>&1if grep -q "$UTAG" tmp$$thenwhee=yesrm -f tmp$$elsemy_echo Could not fetch UHD tagged $UTAG from GITrm -f tmp$$ficd ..fi## GIT the RTL-SDR source tree#rm -rf rtl-sdrrm -rf gr-osmosdrrm  -rf gr-bazrm -rf hackrfrm -rf bladeRFrm -rf airspymy_echo Fetching rtl-sdr "(rtl-sdr, gr-osmosdr, gr-iqbal, hackrf, bladeRF and airspy)" via GITgit clone --progress git://github.com/patchvonbraun/rtl-sdr >>$LOGDEV 2>&1git clone --progress git://git.osmocom.org/gr-osmosdr >>$LOGDEV 2>&1git clone --progress git://git.osmocom.org/gr-iqbal.git >>$LOGDEV 2>&1git clone https://github.com/Nuand/bladeRF.git >>$LOGDEV 2>&1if [ -d gr-iqbal ]thencd gr-iqbalif [ $OLD_MODE -eq 1 ]thengit checkout gr3.6figit submodule init  >>$LOGDEV 2>&1git submodule update >>$LOGDEV 2>&1cd ..figit clone --progress https://github.com/mossmann/hackrf.git >>$LOGDEV 2>&1(cd $CWD; rm -rf airpsy; mkdir airspy; cd airspy; git clone https://github.com/airspy/host) >>$LOGDEV 2>&1my_echo Done}function uhd_build {## UHD build#sudocheckif [ ! -d uhd ]thenmy_echo you do not appear to have the \'uhd\' directorymy_echo you should probably use $0 gitfetch to fetch the appropriatemy_echo files using GITdoexit BUILD-UHD-NOT-THEREfiif [ $UTAG != None ]thencd uhdgit checkout $UTAG >/dev/null 2>&1cd ..fimy_echo Building UHD...my_echo "=============> THIS WILL TAKE SOME TIME <============="my_echocd uhd/hostrm -rf buildif [ ! -d build ]thenmkdir buildficd buildmake clean >/dev/null 2>&1cmake $CMAKE_FLAG1 $CMAKE_FLAG2 $CMF1 $CMF2  $UCFLAGS ../ >>$LOGDEV 2>&1make clean >>$LOGDEV 2>&1make $JFLAG >>$LOGDEV 2>&1if [ $? -ne 0  ]thenmy_echo UHD build apparently failedmy_echo Exiting UHD builddoexit UHD-BUILD-FAIL1fi    sudo rm -f /usr/local/lib*/libuhd*sudo make $JFLAG install >>$LOGDEV 2>&1which uhd_find_devices >/dev/null 2>&1x=$?if [ $x -ne 0 -a ! -f /usr/local/bin/uhd_find_devices -a ! -f /opt/local/bin/uhd_find_devices ]thenmy_echo UHD build/install apparently failed since I cannot find /usr/local/bin/uhd_find_devicesmy_echo after doing make and make installmy_echo Exiting UHD builddoexit UHD-BUILD-FAIL2fisudo ldconfig >>$LOGDEV 2>&1my_echo Done building/installing UHD}function rtl_build {## RTL build#sudocheckcd $CWDif [ ! -d rtl-sdr ]thenmy_echo you do not appear to have the \'rtl-sdr\' directorymy_echo you should probably use $0 gitfetch to fetch the appropriatemy_echo files using GITdoexit BUILD-RTL-NOT-THEREfimy_echo -n Building rtl-sdr...cd rtl-sdrcmake $CMAKE_FLAG1 $CMAKE_FLAG2 $CMF1 $CMF2 . >>$LOGDEV 2>&1make clean >>$LOGDEV 2>&1make $JFLAG >>$LOGDEV 2>&1if [ $? -ne 0  ]thenmy_echo rtl-sdr build apparently failedmy_echo Exiting rtl-sdr builddoexit RTL-BUILD-FAIL1fisudo make $JFLAG install >>$LOGDEV 2>&1my_echo Done building rtl-sdrcd $CWDif [ -d hackrf ]thenmy_echo -n Building hackrf...cd hackrfcmake $CMAKE_FLAG1 $CMAKE_FLAG2 $CMF1 $CMF2 -DINSTALL_UDEV_RULES=ON host/ >>$LOGDEV 2>&1make clean >>$LOGDEV 2>&1make >>$LOGDEV 2>&1if [ $? -ne 0 ]thenmy_echo hackrf build failedmy_echo Exiting hackrf buildelsesudo make install >>$LOGDEV 2>&1fimy_echo Done building hackrfcd $CWDficd $CWDif [ -d gr-iqbal ]thenmy_echo -n Building gr-iqbal...cd gr-iqbalmkdir -p buildcd buildcmake .. $CMAKE_FLAG1 $CMAKE_FLAG2 $CMF1 $CMF2 >>$LOGDEV 2>&1make clean >>$LOGDEV 2>&1make >>$LOGDEV 2>&1if [ $? -ne 0 ]thenmy_echo gr-iqbal build apparently failedmy_echo Exiting gr-iqbal buildelsesudo make install  >>$LOGDEV 2>&1cd $CWDmy_echo Done building gr-iqbalfifiif [ -d bladeRF  ]thenmy_echo -n Building bladeRF...cd bladeRFcd hostcmake . $CMAKE_FLAG1 $CMAKE_FLAG2 $CMF1 $CMF2 >>$LOGDEV 2>&1make clean >>$LOGDEV 2>&1make >>$LOGDEV 2>&1if [ $? -ne 0 ]thenmy_echo bladeRF build apparently failedmy_echo Exiting bladeRF buildelsesudo make install >>$LOGDEV 2>&1cd $CWDmy_echo Done building bladeRFfifiif [ -d airspy/host ]thencd airspy/hostmkdir buildcd buildcmake .. $CMAKE_FLAG1 $CMAKE_FLAG2 $CMF1 $CMF2 >>$LOGDEV 2>&1make clean >>$LOGDEV 2>&1make >>$LOGDEV 2>&1if [ $? -ne 0 ]thenmy_echo airspy build apparently failedmy_echo Exiting airspy buildelsesudo make install >>$LOGDEV 2>&1my_echo Done building airspyficd $CWDficd $CWDif [ ! -d gr-osmosdr ]thenmy_echo you do not appear to have the \'gr-osmosdr\' directorymy_echo you should probably use $0 gitfetch to fetch the appropriatemy_echo files using GITdoexit RTL-BUILD-FAIL2ficd gr-osmosdrif [ $OLD_MODE -eq 1 ]thengit checkout gr3.6 >/dev/null 2>&1fimy_echo -n Building gr-osmosdr...cmake . $CMAKE_FLAG1 $CMAKE_FLAG2 $CMF1 $CMF2 >>$LOGDEV  2>&1make clean >>$LOGDEV 2>&1make $JFLAG >>$LOGDEV 2>&1if [ $? -ne 0 ]thenmy_echo gr-osmosdr build apparently failedmy_echo Exit rtl-sdr/gr-osmosdr builddoexit OSMOSDR-BUILD-FAILfisudo make $JFLAG install >>$LOGDEV 2>&1my_echo Done building gr-osmosdrsudo ldconfig >>$LOGDEV 2>&1cd $CWDmy_echo Done building/installing rtl-sdr/gr-osmosdr}function firmware {sudocheckFOUND_DOWNLOADER=Falsedirlist="/usr/local/share /usr/local/lib /usr/local/lib64"prog=uhd_images_downloaderPATH=$PATH:/usr/local/binq=`which $prog 2>/dev/null`if [ @$q@ != @@ ]thensudo -E $qelsefor dir in $dirlistdoif [ -f $dir/uhd/utils/$prog ]thenFOUND_DOWNLOADER=TrueDOWNLOADER=$dir/uhd/utils/$progfidoneif [ $FOUND_DOWNLOADER = True ]thensudo -E $DOWNLOADERelsemy_echo Could not find images downloader: $prog in any of $dirlistdoexit UHD-FIRMWARE-FAILfimy_echo Done downloading firmware to /usr/local/share/uhd/imagesfi}function gnuradio_build {sudocheckif [ $JOSHMODE = False ]thenif [ ! -d gnuradio ]thenmy_echo you do not appear to have the \'gnuradio\' directorymy_echo you should probably use $0 gitfetch to fetch the appropriatemy_echo files using GITdoexit GNURADIO-BUILD-NOT-THEREfiif [ $GTAG != None ]thencd gnuradiogit checkout $GTAG >/dev/null 2>&1cd ..fielseecho Josh mode no longer supportedfi## LD stuff#echo /usr/local/lib >tmp$$echo /usr/local/lib64 >>tmp$$if grep -q /usr/local/lib /etc/ld.so.conf.d/*thenmy_echo /usr/local/lib already in ld.so.conf.delsesudo cp tmp$$ /etc/ld.so.conf.d/local.conffirm -f tmp$$my_echo Doing ldconfig...sudo ldconfig >/dev/null 2>&1PKG_CONFIG_PATH=/usr/local/lib/pkgconfigif [ -d /usr/local/lib64/pkgconfig ]thenPKG_CONFIG_PATH=/usr/local/lib64/pkgconfigfiexport PKG_CONFIG_PATH## Build Gnuradio#if [ $JOSHMODE = False ]thencd gnuradioelseecho Josh mode no longer supporteddoexit JOSH-MODE-NOfimy_echo Building Gnu Radio...my_echo "=========> THIS WILL TAKE QUITE A WHILE <============="my_echo " "my_echo ...Doing cmakeif [ -d build ]thenmy_echo ...build directory already hereelsemkdir buildficd buildmake clean >/dev/null 2>&1my_echo ...Cmakingcmake -DENABLE_BAD_BOOST=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo $CMAKE_FLAG1 $CMAKE_FLAG2 $CMF1 $CMF2 $GCFLAGS ../ >>$LOGDEV 2>&1my_echo ...Buildingmake $JFLAG clean >>$LOGDEV 2>&1make $JFLAG >>$LOGDEV 2>&1if [ $? -ne 0 ]thenmy_echo make failedmy_echo Exiting Gnu Radio build/installdoexit GNURADIO-BUILD-FAILfimy_echo ...Installingsudo rm -rf /usr/local/include/gnuradio/sudo rm -f /usr/local/lib*/libgnuradio*sudo make $JFLAG install >>$LOGDEV 2>&1sudo ldconfig >>$LOGDEV 2>&1my_echo Done building and installing Gnu Radiomy_echo -n GRC freedesktop icons install ...if [ -f /usr/local/libexec/gnuradio/grc_setup_freedesktop ]thensudo chmod 755 /usr/local/libexec/gnuradio/grc_setup_freedesktopsudo /usr/local/libexec/gnuradio/grc_setup_freedesktop install >>$LOGDEV 2>&1fimy_echo Done}function do_an_extra {if [ -e $1 ]thenmy_echo Building extra module $1cd $1if [  -f CMakeLists.txt ]thenmkdir -p build >>$LOGDEV 2>&1cd buildcmake .. $CMAKE_FLAGS1 $CMAKE_FLAGS2 $CMF1 $CMF2 >>$LOGDEV 2>&1make >>$LOGDEV 2>&1sudo make install >>$LOGDEV 2>&1sudo ldconfigelif [ - bootstrap ]thenchmod 755 bootstrap./bootstrap  >>$LOGDEV 2>&1PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig./configure >>$LOGDEV 2>&1make >>$LOGDEV 2>&1sudo make install >>$LOGDEV 2>&1sudo ldconfigelsemy_echo Couldnt determine how to make module $1 neither bootstrap nor CmakeLists.txt presentfielsemy_echo Couldnt build module $1 directory not therefi}function extras {sudocheckdate=`date +%Y%m%d%H%M%S`if [ ! "@$EXTRAS@" = "@@" ]thenfor module in $EXTRASdocd $CWD    base=`basename $module .git`case $module ingit:*|*.git|*github*)mv $base $base.$date.bgmoved >>$LOGDEV 2>&1 my_echo Doing GIT checkout for extra module $basegit clone $module  >>$LOGDEV 2>&1do_an_extra $base;;htt*:*svn*)mv $base $base.$date >>$LOGDEV 2>&1my_echo Doing SVN checkout for extra module $basesvn co $module >>$LOGDEV 2>&1if [ -e $base/trunk ]thendo_an_extra $base/trunkelsedo_an_extra $basefi;;*)my_echo Ignoring malformed extra module $module;;esacdoneficd $CWD}function mod_groups {sudocheck## Post install stuff## USRP rules for UDEV and USRP group### Check for USRP group, and update if necessaryif grep -q usrp /etc/groupthenmy_echo Group \'usrp\' already in /etc/groupelsesudo /usr/sbin/groupadd usrpfi## Check that our calling user is in the USRP group, update if necessary#if grep -q usrp.*${USER} /etc/groupthenmy_echo User $USER already in group \'usrp\'elsesudo /usr/sbin/usermod -a -G usrp $USERcat <<"!EOF!"********************************************************************************This script has just modified /etc/group to place your userid '('$USER')' into group 'usrp'In order for this change to take effect, you will need to log-out and log backin again.  You will not be able to access your USRP1 device until you do this.If you wish to allow others on your system to use the USRP1 device, you will need to use:  sudo usermod -a -G usrp userid  For each userid you wish to allow access to the usrp********************************************************************************Further !EOF!fiif [ "$USERSLIST" = None ]thenfoo=barelseul=`echo $USERSLIST|sed -e 's/,/ /g'`for u in $uldosudo /usr/sbin/usermod -a -G usrp $umy_echo Added $u to group usrpdonefi}function mod_udev {sudocheck## Check for UHD UDEV rules file, update if exists#if [ -f $CWD/uhd/host/utils/uhd-usrp.rules ]thensudo cp $CWD/uhd/host/utils/uhd-usrp.rules /etc/udev/rules.d/10-usrp.rulessudo chown root /etc/udev/rules.d/10-usrp.rulessudo chgrp root /etc/udev/rules.d/10-usrp.rulesfi## Check for rtl-sdr UDEV rules file, update if exists#rm -f tmp$$if [ -f $CWD/rtl-sdr/rtl-sdr.rules ]thensudo cp $CWD/rtl-sdr/rtl-sdr.rules /etc/udev/rules.d/15-rtl-sdr.rulessudo chown root /etc/udev/rules.d/15-rtl-sdr.rulessudo chgrp root /etc/udev/rules.d/15-rtl-sdr.rulesfisudo killall -HUP udevdsudo udevadm control --reload-rules}function mod_sysctl {sudocheck## Modify sysctl.conf as necessary#cat >tmp$$ <<!EOF!# Updates for Gnu Radionet.core.rmem_max = 1000000net.core.wmem_max = 1000000kernel.shmmax = 2147483648!EOF!if grep -q 'Updates for Gnu Radio' /etc/sysctl.confthenmy_echo Required updates to /etc/sysctl.conf already in placeelsemy_echo Applying updates to /etc/sysctl.confcat /etc/sysctl.conf tmp$$ >tmp2$$chmod 644 tmp2$$sudo mv tmp2$$ /etc/sysctl.conffisudo sysctl -w net.core.rmem_max=1000000 >/dev/null 2>&1sudo sysctl -w net.core.wmem_max=1000000 >/dev/null 2>&1sudo sysctl -w kernel.shmmax=2147483648  >/dev/null 2>&1 rm -f tmp$$rm -f tmp2$$if grep -q usrp /etc/security/limits.confthenmy_echo usrp group already has real-time scheduling privilegeelsecat >tmp$$ <<!EOF!@usrp  - rtprio 50!EOF!cat /etc/security/limits.conf tmp$$ >tmp2$$sudo cp tmp2$$ /etc/security/limits.confsudo chmod 644 /etc/security/limits.confrm -f tmp$$ tmp2$$my_echo Group \'usrp\' now has real-time scheduling privilegesmy_echo You will need to log-out and back in again for this tomy_echo take effectfi}function all {my_echo Starting all functions at: `date`cd $CWDprereqstouch -d "15 minutes ago" touch$$if [ -d uhd -a -d gnuradio ]thenif [ uhd -ot touch$$ -o gnuradio -ot touch$$ ]thengitfetchelsemy_echo Skipping git fetch, since \'uhd\' and \'gnuradio\' are new enoughfielsegitfetchfirm -f touch$$for fcn in uhd_build firmware gnuradio_build rtl_build mod_groups mod_udev mod_sysctl pythonpath extrasdomy_echo Starting function $fcn at: `date`cd $CWD$fcnmy_echo Done function $fcn at: `date`donemy_echo Done all functions at: `date`}function pythonpath {for PYVER in 2.6 2.7dofor type in "" 64doif [ -d /usr/local/lib${type}/python${PYVER}/site-packages/gnuradio ]thenPYTHONPATH=/usr/local/lib${type}/python${PYVER}/site-packagesfiif [ -d /usr/local/lib${type}/python${PYVER}/dist-packages/gnuradio ]thenPYTHONPATH=/usr/local/lib${type}/python${PYVER}/dist-packagesfidonedoneechoechoecho "************************************************************"echo You should probably set your PYTHONPATH to:echo " "echo "    " $PYTHONPATHecho " "echo Using:echo " "echo export PYTHONPATH=$PYTHONPATHecho " "echo in your .bashrc or equivalent file prior to attempting to runecho any Gnu Radio applications or Gnu Radio Companion.echo "*************************************************************"}function sudocheck {## Check SUDO privileges#if [ $SUDOASKED = n ]thenecho SUDO privileges are required echo -n Do you have SUDO privileges'?'read anscase $ans iny|Y|YES|yes|Yes)echo Continuing with scriptSUDOASKED=ysudo grep timestamp_timeout /etc/sudoers >tmp$$timeout=`cat tmp$$|awk '/./ {print $4}'`rm -f tmp$$if [ "@@" = "@$timeout@" ]thensudo cp /etc/sudoers tmp$$sudo chown $USER tmp$$sudo chmod 644 tmp$$echo "Defaults  timestamp_timeout = 90" >>tmp$$sudo cp tmp$$ /etc/sudoerssudo chown root /etc/sudoerssudo chmod 440 /etc/sudoerselif [ "$timeout" -lt 90 ]thenecho You need to have a timestamp_timeout in /etc/sudoers of 90 or moreecho Please ensure that your timestamp_timeout is 90 or moreexitfi;;*)echo Exiting.  Please ensure that you have SUDO privileges on this system!exit;;esacfi}PATH=$PATHexport PATHcase $# in0)allmy_echo All Donedoexit SUCCESSesacfor arg in $*docd $CWD$argdonemy_echo All Donedoexit SUCCESS
0 0