Advertisement
Guest User

Untitled

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