Advertisement
Guest User

Untitled

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