julib5432112345

Untitled

Dec 18th, 2015
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 357.60 KB | None | 0 0
  1. #!/bin/bash
  2. ########################################################################
  3. #### Script Name: simple/system graphics installer: sgfxi
  4. #### Debian Sid, Testing, and Stable graphic driver install.
  5. #### New: Ubuntu support in progress. Arch/Fedora Support under development
  6. #### version: 4.24.61
  7. #### Date: 2015-12-09
  8. ########################################################################
  9. #### Copyright (C) Harald Hope 2007-2015
  10. #### Code contributions copyright: Latino 2008
  11. #### Contributors: ati card driver and xorg configuration in general: damentz and d2kx
  12. #### function check_ia32_libs by Steven Barrett (damentz, maintainer of zen/liquorix projects).
  13. #### This program is free software; you can redistribute it and/or modify it under
  14. #### the terms of the GNU General Public License as published by the Free Software
  15. #### Foundation; either version 2 of the License, or (at your option) any later version.
  16. ####
  17. #### This program is distributed in the hope that it will be useful, but WITHOUT
  18. #### ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  19. #### FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  20. ####
  21. #### Get the full text of the GPL here: http://www.gnu.org/licenses/gpl.txt
  22. ########################################################################
  23. #### Script URL: http://smxi.org/sg/sgfxi
  24. #### Script GIT: https://github.com/smxi/sgfxi
  25. #### Script Documentation: http://smxi.org/docs/
  26. #### Script Home page: http://techpatterns.com/forums/about933.html
  27. ########################################################################
  28. #### DEFINE:
  29. #### TRUE: -eq 0; == 'true'; function return 0
  30. #### FALSE: -gt 0; == ''; function return > 0
  31. ########################################################################
  32. #### CONVENTIONS:
  33. #### Indentation: TABS
  34. #### Do not use `....`, those are totally non-reabable, use $(....)
  35. #### Do not use one liner flow controls. The ONLY time you should use ; is in
  36. #### this single case: if [ condition ];then (ie, never: [ condition ] && statement)
  37. ####
  38. #### All new code/methods must be in a function.
  39. #### For all boolean tests, use 'true' / 'false'. Do NOT use 0 or 1 unless
  40. #### it's a function return. Avoid complicated tests in the if condition itself.
  41. ####
  42. #### VARIABLE/FUNCTION NAMING:
  43. #### All variables should explain what they are, except counters like i, j
  44. #### All variables MUST be initialized / declared explicitly
  45. ####, globals UPPER CASE, at top of script, SOME_VARIABLE='' (words separated by _ ).
  46. #### Locals always: local someVariable= (lower case, all except first word started upper case)
  47. #### and at the top of the function. ie: testTrunkData
  48. ####
  49. #### Booleans should start with b_ or B_ and state clearly what is being tested
  50. #### Arrays should start with a_ or A_
  51. #### All functions should follow standard naming, ie, verb adjective noun, get_cpu_data
  52. ########################################################################
  53. #### TESTING FLAGS
  54. #### sgfxi supports advanced testing triggers to do various things, using -! <arg>
  55. #### -! 1 - triggers default B_TESTING_1='true' - triggers testing data function
  56. #### -! 2 - triggers default B_TESTING_2='true' - triggers post test exit
  57. #### -! 3 - triggers default B_SKIP_FUNCTION='true' to turn off functions for script testing
  58. #### -! 4 - triggers B_TESTING_1='true' and B_TESTING_2='true'
  59. #### -! 5 - triggers B_TESTING_1='true', B_TESTING_2='true', and B_SKIP_FUNCTION='true'
  60. #### -! 6 - triggers B_TESTING_3='true' - overrides xorg/kernel support tests
  61. #### -! 7 - triggers B_TESTING_4='true' - overrides patch tests
  62. #### -! 8 - triggers B_TESTING_5='true' - triggers advanced, beta tests for general script
  63. #### -! 9 - triggers B_TESTING_6='true' - triggers new distro development tests
  64. #### -! 10 - triggers an update from the primary dev download server
  65. #### -! 11 - triggers an update from svn branch one - if present, of course
  66. #### -! 12 - triggers an update from svn branch two - if present, of course
  67. #### -! <http://......> - Triggers an update from whatever server you list.
  68. #### -! 20 - uses patch from svn branch one server (must be in branch/one/patches)
  69. #### -! 21 - uses patch from svn branch two server (must be in branch/two/patches)
  70. ########################################################################
  71. #### EXTRA DATA
  72. #### Cross referenced table of package manager commands (apt/yum/pacman etc):
  73. #### https://wiki.archlinux.org/index.php/Pacman_Rosetta
  74. ########################################################################
  75. #### VARIABLES
  76. ########################################################################
  77.  
  78. ## Distro maintainers: set these variables to meet your needs ##
  79. # maintainers can turn this to false to stop allowing script auto updates. Only set
  80. # to false if this script will be packaged and you want to not allow script auto updates
  81. B_ALLOW_AUTO_UPDATE='true'
  82. # maintainers change this to script default path please to keep things simple if different
  83. SCRIPT_HOME='/usr/local/bin'
  84. SCRIPT_NAME='sgfxi'
  85. SCRIPT_WORKING_DIR="/usr/src/$SCRIPT_NAME-downloads"
  86. SM_KERNEL_DOWNLOADS='/usr/src/sm-kernel-downloads'
  87.  
  88. # script global data
  89. NON_DEBIAN_PATTERN='(deb-ats|deb-mep|deb-mm|deb-multimedia|deb-op|deb-sdx|deb-skp|deb-swift|deb-vb|alphagemini|aptosid|byteme|cathbard|debian-multimedia|dotdeb|edevelop|eeepc|freevo|giss.tv|google|java|kanotix|kde|kiberpipa|kplayer|lamaresh|liquorix|lxde|mepis|moblock|opera|noreply|prodeia.de|rarewares|rox4debian|siduction|sidux|skype|swiftfox|tovid|videolan|virtualbox|wine-hq|xadras)'
  90.  
  91. APT_TYPE='apt-get'
  92. CARD='' # card type: fglrx or nvidia
  93. DISTRIB_CODENAME=''
  94. DISTRIB_ID=''
  95. DISTRIB_RELEASE=''
  96. # this is for the run installers, sometimes we may want to pass them an option/arg in specific cases
  97. EXTRA_ARGS=''
  98. FED_KERNEL_PAE=''
  99. NON_FREE_DRIVER=''
  100. SYSTEM_BASE=''
  101. SYSTEM_CODENAME=''
  102. NATIVE_OVERRIDE=''
  103. # this is the actual pattern that will be used to search for this stuff in script
  104. #NATIVE_OVERRIDE_SUPPORTED='ati|i128|i740|i810|i810-modesetting|intel|mga|neomagic|nv|openchrome|radeon|radeonhd|sis|tdfx|vesa|via|vga|voodoo'
  105. # http://blog.mecheye.net/2014/04/xwayland/ - good info on xwayland, and general xorg architecture
  106. NATIVE_OVERRIDE_SUPPORTED='apm|ark|ati|chips|cirrus|fbdev|geode|glide|glint|i128|i740|intel|imstt|mach64|mga|modesetting|neomagic|nsc|openchrome|nouveau|r128|radeon|rendition|s3|s3virge|savage|siliconmotion|sis|sisusb|tdfx|tga|trident|tseng|vesa|vga|via|voodoo|vmware|v4l'
  107. PACKAGE_MANAGER=''
  108. # options: 0 - monochrome; 1 default; more coming?
  109. SCRIPT_COLORS=1
  110. START_OPTIONS_PRINT='' # for output to user of what options they used
  111. START_OPTIONS=''
  112. SUDO_START=''
  113. WITHOUT_RECOMMENDS=''
  114. X_NAME=''
  115.  
  116. ## main script boolean switches
  117. B_AMD='true'
  118. B_AUTORUN='false'
  119. B_BETA_EXISTS='false'
  120. B_BUILD_KERNEL_MODULES='false'
  121. B_CHECK_IA32='false' # if users want, they can disable this feature in config file
  122. B_COMPOSITE='false'
  123. B_DEFAULT_NATIVE_DRIVER='false'
  124. # I cannot figure out the logic here, this must be some old thing that was used for a specific purpose.
  125. # I think it was an option set here to trigger use distro driver flag, but I don't see why that would
  126. # have been done in the first place, it was probably something very specific.
  127. B_DISTRO_FLAG='false'
  128. B_DISPLAY_DEVICES='false'
  129. B_EXPERIMENTAL='false'
  130. B_EXTRA_EXPERIMENTAL='false'
  131. B_FGLRX_DEB_BUILDER='false'
  132. B_FGLRX_DIRECT='true' # raising the white flag of surrender...
  133. B_FORCE_OPTION='false'
  134. B_FORCE_NO_COMPOSITE='false'
  135. B_FORCE_UPDATE='false'
  136. B_GET_LIVE_DRIVERS='false'
  137. B_GUI_MODE='false'
  138. B_IS_APTOSID_KERNEL='false'
  139. B_IS_XEN='false'
  140. B_KERNEL_MODULE_ONLY='false'
  141. B_LAUNCH_FROM_X='false'
  142. B_LOGGING_STARTED='false'
  143. B_MOVE_X_CONF='false'
  144. B_NATIVE_DRIVER='false'
  145. B_NO_XVMC='false'
  146. B_PRINT_VER='false' # utilities for smxi
  147. B_REMOVE_MODELINES='false'
  148. B_RESTORE_DEFAULTS='false'
  149. # B_RENDER_ACCEL='true' # default use, true
  150. B_SET_IGNOREABI='false'
  151. B_SKIP_AUTOSTART='false' # deprecated, not used
  152. B_SKIP_CONFIG='false'
  153. B_SKIP_CONNECT='false' # deprecated, not used
  154. B_SKIP_GRUB_TEST='false'
  155. B_SKIP_INSTALL='false'
  156. B_SKIP_RESTART='false'
  157. B_SKIP_WGET='false'
  158. B_SKIP_X_QUESTION='false'
  159. B_SKIP_X_TEST='false'
  160. B_SM_INSTALL='false' # utilities for smxi
  161. B_SYSTEMD='false'
  162. B_SYSTEMD_GRAPHICAL='false'
  163. B_SYSTEMD_SYSINIT='false'
  164. B_TRIPLE_BUFFER='false'
  165. B_TWINVIEW='false' # deprecated, commented out use
  166. B_UPDATED='false'
  167. B_UPSTART='false'
  168. B_USE_BETA='false'
  169. B_USE_DIRECT_KERNEL_HEADER='false' # deprecated, commented out use
  170. B_USE_DISTRO_DRIVER='false'
  171. # force (for nvidia), using old method of kernel source /m-a module build. New default dkms
  172. B_USE_DISTRO_MODULE_MA='false'
  173. B_USE_EVENTS='true'
  174. B_USE_XVMC='false'
  175. B_XORG_BACKED_UP='false'
  176.  
  177. ## debugger/testing boolean switches
  178. B_SKIP_FUNCTION='false'
  179. B_TESTING_1='false' # triggers testing function
  180. B_TESTING_2='false' # triggers post driver extract/patch exit
  181. B_TESTING_3='false' # overrides testing cases xorg/kernel for driver support
  182. B_TESTING_4='false' # triggers advanced general development testing cases
  183. B_TESTING_5='false' # overrides patch tests
  184. B_TESTING_6='false' # triggers new distro development tests
  185.  
  186. # kernel variables strings are now evaluated in kernel_string_info().
  187. INSTALL_TO_KERNEL=''
  188. KERNEL_ARCH=''
  189. KERNEL_BASE='' # like: 2.6 or 3
  190. KERNEL_MATH='' # like: 19, for math use
  191. KERNEL_NUMBER='' # like: 2.6.19 or 3.19
  192. KERNEL_FULL='' # full kernel name
  193.  
  194. # check for 64 bit first
  195. if [ -n "$( uname -m | grep -o 'x86_64' )" ];then
  196. BITS="64"
  197. else
  198. BITS="32"
  199. fi
  200.  
  201. X_VERSION=''
  202. # this handles the 1.x syntax used by newer xorg versions
  203. # it also handles the change in ID text they did with 1.4
  204. # slicing out parts prior to parentheses: X.Org X Server 1.7.7
  205. # NOTE: grep -o behavior has CHANGED! Now it will slice out separate instances, like:
  206. # 1.11
  207. # 2.902
  208. # from one string, like: 1.11.2.902
  209. if [ -n "$( type -p X )" ];then
  210. X_VERSION=$( X -version 2>&1 | grep -Eis -m 1 '^(X.Org X Server|X Window System)' | cut -d '(' -f 1 | awk '{ print $NF }' | grep -Eo '^[12347]\.[0-9]+(\.[0-9]+)?' )
  211. # some users only want to be running a very light xorg, which won't have X, only Xorg
  212. # Tested and works Debian/Arch
  213. elif [ -n "$( type -p Xorg )" ];then
  214. # X.Org X Server 1.7.7
  215. # xorg-server 2:1.7.7-7 (Julien Cristau <[email protected]>)
  216. X_VERSION=$( Xorg -version 2>&1 | grep -Eis -m 1 '^(X\.org|xorg)' | cut -d ':' -f 2 | cut -d '(' -f 1 | awk '{ print $NF }' | grep -Eo '^[12347]\.[0-9]+' )
  217. fi
  218. CC=''
  219. GL=''
  220. # specific card types
  221. FGLRX='fglrx'
  222. INTEL='intel'
  223. NEOMAGIC='neomagic'
  224. NVIDIA='nvidia'
  225. TDFX='tdfx'
  226.  
  227. # Position matters: 1-latest; 2-middle; 3-older; 4-oldest
  228. VERSIONS=''
  229. OTHER_VERSIONS=''
  230. # main url: ftp://download.nvidia.com/XFree86/
  231. # http://us.download.nvidia.com/XFree86/Linux-x86/latest.txt
  232. # 304.88, 310.44, 313.30 fix buffer overflow issue
  233. NV_VERSIONS='355.11:340.93:304.128:173.14.39:96.43.23:71.86.15'
  234. # in case the new ones don't support 3.10 kernel
  235. # NV_VERSIONS='325.15:304.88:173.14.37:96.43.23:71.86.15'
  236. NV_DEFAULT=$( echo $NV_VERSIONS | cut -d ':' -f 1 ) # >= 6xxx
  237. NV_LEGACY_1=$( echo $NV_VERSIONS | cut -d ':' -f 6 ) # old, tnt etc
  238. NV_LEGACY_2=$( echo $NV_VERSIONS | cut -d ':' -f 5 ) # ge4xx cards
  239. NV_LEGACY_3=$( echo $NV_VERSIONS | cut -d ':' -f 4 ) # 5xxx cards
  240. NV_LEGACY_4=$( echo $NV_VERSIONS | cut -d ':' -f 3 ) # 6/7xxx cards
  241. NV_LEGACY_5=$( echo $NV_VERSIONS | cut -d ':' -f 2 ) # 8xxx/21x cards
  242.  
  243. ## beta drivers
  244. # use null for position (ie, ::) if no newer beta is availablet than current stable
  245. NV_VERSIONS_BETA='358.16:::::'
  246. NV_DEFAULT_BETA=$( echo $NV_VERSIONS_BETA | cut -d ':' -f 1 ) # >= 6xxx
  247. NV_LEGACY_BETA_1=$( echo $NV_VERSIONS_BETA | cut -d ':' -f 6 ) # old, tnt etc
  248. NV_LEGACY_BETA_2=$( echo $NV_VERSIONS_BETA | cut -d ':' -f 5 ) # ge4xx cards
  249. NV_LEGACY_BETA_3=$( echo $NV_VERSIONS_BETA | cut -d ':' -f 4 ) # 5xxx cards
  250. NV_LEGACY_BETA_4=$( echo $NV_VERSIONS_BETA | cut -d ':' -f 3 ) # 6/7xxx cards
  251. NV_LEGACY_BETA_5=$( echo $NV_VERSIONS_BETA | cut -d ':' -f 2 ) # 8xxx/21x cards
  252.  
  253. # latest quad: http://www.nvidia.com/object/linux_display_archive.html
  254. NV_QUAD=$NV_DEFAULT # no more individual quad drivers
  255. # this is what gets tested, and any other beta drivers remaining
  256. NV_BETA="$NV_VERSIONS_BETA:::"
  257. # stable primary: 355.11
  258. # stable primary: 343.36 346.35 346.47 346.59 349.16 346.72 352.21 352.30 352.41
  259. # stable primary: 325.15 331.20 331.38 331.49 334.21 337.25 340.24 340.32 343.22
  260. # stable primary: 304.60 304.64 310.19 313.18 313.26 313.30 319.17 319.23 319.32
  261. # stable primary: 295.49 295.53 295.59 295.71 302.17 304.30 304.37 304.43 304.51
  262. # stable primary: 280.13 285.05.09 290.10 295.20 295.33 295.40
  263. # stable primary: 275.09.07 275.19 275.21
  264. # lt stable primary: 346.72 346.82 346.87 352.41 352.55
  265. # lt stable primary: 331.89 340.24 340.32 340.46 340.58 340.65 346.35 346.47 346.59
  266. # lt stable primary: 319.49 319.60 319.82 319.72 331.20 331.38 331.49 331.67 331.79
  267. # lt stable primary: 304.37 304.43 304.51 310.19 310.32 310.40 310.44 319.17 319.23
  268. # lt stable primary: 275.28 275.36 275.43 295.20 295.40 295.49 295.53 295.59 295.71
  269. # stable primary: 270.41.06 270.41.19
  270. # stable primary: 260.19.12 260.19.21 260.19.29 260.19.36 260.19.44
  271. # stable primary: 256.35 256.44 256.53
  272. # stable primary: 195.36.08 ( bad, recalled ) 195.36.15 195.36.24 195.36.31
  273. # stable primary: 190.42 190.53
  274. # stable primary: 185.18.14 185.18.29 185.18.31 185.18.36
  275. # stable primary: 180.44 180.51 180.60
  276. # stable primary: 177.82
  277. # stable primary: 100.14.19 169.12
  278. # stable legacy 1: 71.86.06 71.86.09 71.86.11 71.86.13 71.86.14 71.86.15
  279. # stable legacy 2: 96.43.11 96.43.13 96.43.14 96.43.16 96.43.18 96.43.19 96.43.20 96.43.23 (ends with xorg 11/12 support)
  280. # stable legacy 3: 173.14.12 173.14.18 173.14.20 173.14.22 173.14.25 173.14.27 173.14.28 173.14.30
  281. # 173.14.31 173.14.35 173.14.36 173.14.37 173.14.38 173.14.39 (ends with xorg 1.15 support)
  282. # stable legacy 4: 304.128
  283. # stable legacy 4: 304.64 304.84 304.88 304.108 304.116 304.117 304.119 304.121 304.123 304.125
  284. # stable legacy 5: 340.24 340.32 340.46 340.58 340.65 340.76 340.93
  285.  
  286. # beta/others: 310.14 313.09 319.12 355.06
  287. ## note: no earlier 302 or 295 drivers offered because they had a security hole
  288. NV_OTHERS='355.11:352.55:352.41:346.87:346.82:343.36:340.93:340.76:337.25:334.21:331.89:325.15:319.72:313.30:310.44:304.128:304.125:295.71:290.10:285.05.09:280.13:275.43:270.41.19:260.19.44:256.53:195.36.31:190.53:185.18.36:180.60:177.82:173.14.37:169.12:100.14.19:96.43.20:71.86.14'
  289.  
  290. # distro legacies (default to Debian packages):
  291. NV_DEBIAN_LEGACY_5='340xx'
  292. NV_DEBIAN_LEGACY_4='304xx'
  293. NV_DEBIAN_LEGACY_3='173xx'
  294. NV_DEBIAN_LEGACY_2='96xx'
  295. NV_DEBIAN_LEGACY_1='71xx'
  296. # arch linux
  297. NV_AR_CURRENT=''
  298. NV_AR_LEGACY_5='340xx'304.128
  299. NV_AR_LEGACY_4='304xx'
  300. NV_AR_LEGACY_3='173xx'
  301. NV_AR_LEGACY_2='96xx'
  302. # ubuntu
  303. NV_UB_CURRENT='343'
  304. NV_UB_LEGACY_5='340'
  305. NV_UB_LEGACY_4='304'
  306. NV_UB_LEGACY_3='173'
  307. NV_UB_LEGACY_2='96'
  308. # fedora
  309. NV_FED_CURRENT="-$NV_DEFAULT" # note this will be out of sync until repo catches up, needs tests
  310. NV_FED_LEGACY_5='-340xx'
  311. NV_FED_LEGACY_4='-304xx'
  312. NV_FED_LEGACY_3='-173xx'
  313. NV_FED_LEGACY_2='-96xx'
  314.  
  315. # set dynamically in fixes, line 529 or so
  316. NVIDIA_DOWNLOAD_SITE=''
  317. # needs dynamic assignment because new drivers won't use this in the string
  318. NV_PKG_NO=''
  319. NV_64_ARCH='' # if nvidia changes file name use this
  320.  
  321. # other options: nothing now
  322. # zip file only: http://support.amd.com/us/gpudownload/embedded/Pages/embedded_linux.aspx
  323. # actual run: http://support.amd.com/us/gpudownload/linux/Pages/radeon_linux.aspx
  324. # IMPORTANT: on function set_download_info the actual path file name is set:
  325. # note, as distressingly usual, amd AGAIN has changed their driver name syntax.
  326. ## Driver data:
  327. # amd has no discipline whatsoever, look at the ridiculous failure to name the f#cking download file
  328. # consistently release to release, clearly this organization is run by incompetents of the highest order.
  329. # hint: use real package numbering and you avoid all this 'legacy/beta' nonsense.
  330. # amd-driver-installer-12-8-x86.x86_64.zip
  331. # amd-driver-installer-catalyst-12.10-x86.x86_64.zip
  332. # amd-driver-installer-catalyst-13.1-linux-x86.x86_64.zip
  333. # amd-driver-installer-catalyst-13.3-beta3-linux-x86.x86_64.zip
  334. # amd-driver-installer-catalyst-13-4-linux-x86.x86_64.zip
  335. # amd-driver-installer-catalyst-13-6-beta-x86.x86_64.zip
  336. # amd-catalyst-13.8-beta1-linux-x86.x86_64.zip
  337. # Linux_AMD_Catalyst_14.3_Beta_V1.0_B22_March12_2014.zip
  338. # www2.ati.com/drivers/legacy/amd-driver-installer-catalyst-13.1-legacy-linux-x86.x86_64.zip
  339. # www2.ati.com/drivers/beta/amd-driver-installer-catalyst-12.11-beta-x86.x86_64.zip
  340. # www2.ati.com/drivers/linux/amd-driver-installer-catalyst-12.10-x86.x86_64.zip
  341. # www2.ati.com/drivers/beta/amd-driver-installer-catalyst-13.2-beta3-linux-x86.x86_64.zip
  342. # www2.ati.com/drivers/beta/amd-driver-installer-catalyst-13-6-beta-x86.x86_64.zip
  343. # www2.ati.com/drivers/beta/amd-driver-installer-catalyst-13-6-beta-x86.x86_64.zip
  344. # www2.ati.com/drivers/beta/amd-catalyst-13.8-beta1-linux-x86.x86_64.zip
  345. # www2.ati.com/drivers/beta/amd-catalyst-13.11-beta-v9.4-linux-x86.x86_64.run.zip
  346. # www2.ati.com/drivers/linux/amd-catalyst-13.12-linux-x86.x86_64.zip
  347. # www2.ati.com/drivers/linux/amd-catalyst-14-4-rev2-linux-x86-x86-64-may6.zip
  348. # www2.ati.com/drivers/linux/linux-amd-catalyst-14.4-rc-v1.0-apr17.zip
  349. # www2.ati.com/drivers/beta/linux-amd-catalyst-14.6-beta-v1.0-may23.zip
  350. FG_VERSIONS='15.11.1:15.9.1:15.7.1'
  351. FG_DEFAULT='15.11.1'
  352. FG_LEGACY_2='' # random releases/xorg support, hard to follow. note as of 2012-1, legacy uses changed paths
  353. # note, the programming supports various formats for these because AMD simply is incapable of
  354. # making a file name format decision and sticking to it. ie: betav1 beta beta6 and so on.
  355. FG_DEFAULT_BETA=''
  356. FG_BETA="$FG_DEFAULT_BETA:"
  357.  
  358. # note: amd release a zip file that contains a space in the name, so I'm not spending
  359. # any more of my time on this group of undisciplined incompetents at this point.
  360. FG_BETA_VERSION='' # legacy, but leaving in case needed in future
  361. #FG_BETA_VERSION='betav1.0'
  362. FGLRX_PACKAGE_PREFIX='' # set to amd or ati, amd is for >= 12-1
  363.  
  364. ### Stable Series: ###
  365. # 13.12.1 14.4.1 14.4.2 14.5.1 14.9.1 14.12.1 15.6.1 15.7.1 15.9.1 15.11.1
  366. # 12-1 12-2 12-3 12-4 12-6 12-7 12.10 13.1 13-4 13.9 13:12
  367. # 11-12 11-11 11-10 11-9 11-8 11-7 11-6 11-5 11-4 11-3 11-2 11-1
  368. # 10-12 10-11 10-10 10-9 10-8 10-7 10-6 10-5 10-4 10-3 10-2 10-1
  369. # 9-12 9-11 9-10 9-9 9-8 9-7 9-6 9-5 9-4 9.2 9-1 8-12 8-11 8-10 8-9 8-8 8-7 8-6 8-5 8-4
  370. ### FG Legacy 2: ###
  371. # 12-6 13.1
  372. ### Beta Series: ###
  373. # 14.3.14 14.5.2 14.7.1
  374. ### Older Betas: ###
  375. # 13.8-beta2
  376. FG_OTHERS='15.11.1:15.9.1:15.7.1:15.6.1:14.12.1:14.9.1:14.5.1:14.4.2:13.12.1:13.12:13.9:13-4:13.1:12.10:12-7:12-6:12-4:12-3:12-2:12-1:11-12:11-11:11-10:11-9:11-8:11-7:11-6:11-5:11-4:11-3:11-2:11-1'
  377.  
  378. # set to sid/lenny/etch
  379. FG_DISTRIB_ID=''
  380. FG_DISTRIB_CODENAME=''
  381. DRIVER_INSTALL=''
  382. DRIVER_DEFAULT=''
  383. DRIVER_OVERRIDE=''
  384. DRIVER_QUAD=''
  385. DRIVER_BETA=''
  386. # 0 - unsupported completely by any non-free driver
  387. # 1 - nvidia oldest card versions supported / fglrx < x2000 cards
  388. # 2 - nvidia midrange legacy card versions supported
  389. # 3 - nvidia 5xxx cards only
  390. # 100 - fully supported with latest driver
  391. LEGACY_LEVEL=''
  392. DRIVER_FILE=''
  393.  
  394. # here we're cutting out both card type and version number for cases with > 1 card
  395. # match this, line starts: xx:xx.0 space bus type 300 (VGA compat)/302 (3D cont)/380 (Display cont)
  396. # 00:02.0 0380: 8086:2572 (rev 02)
  397. # 01:00.0 0300: 10de:0221 (rev a1)
  398. CARD_COUNT=$( lspci -n | grep -cE '^[^[:space:]]+\.0[[:space:]]+(0300|0302|0380)' )
  399. #CARD_DATA=$( lspci -n | grep 0300 | cut -d ':' -f 3-4 | cut -d ' ' -f2 )
  400. CARD_DATA=$( lspci -n | grep -E '^[^[:space:]]+\.0[[:space:]]+(0300|0302|0380)' | \
  401. grep -Eio '[a-f0-9]{4}:[a-f0-9]{4}' )
  402. CARD_NUMBER=''
  403. CARD_BRAND=''
  404. # this is reset for multiple gfx cards in select_card()
  405. # " around CARD_DATA is mandatory for avoiding new grep issue
  406. BUS_ID=$( lspci -n | grep "$CARD_DATA" | \
  407. grep -Eio '^[^[:space:]]+[\.:]0' | sed 's/\./:/')
  408.  
  409. # system paths
  410. EAA='/etc/apt/apt.conf'
  411. EAS='/etc/apt/sources.list'
  412. EXXC='/etc/X11/xorg.conf'
  413. EAR='/etc/arch-release'
  414. EDV='/etc/debian_version'
  415. EDVV='/etc/devuan_version'
  416. EFR='/etc/fedora-release'
  417. EIT='/etc/inittab'
  418. ELR='/etc/lsb-release'
  419. ELRC='/etc/lsb-release-crunchbang'
  420. GRUB1='/boot/grub/menu.lst'
  421. GRUB1_FED='/boot/grub/grub.conf'
  422. GRUB2='/boot/grub/grub.cfg'
  423. GRUBED='/etc/default/grub'
  424. KERNEL_HEADER_DIRECT='/usr/include/linux/kernel.h'
  425. USRS='/usr/src/'
  426.  
  427. INSTALL_DIRECTORY=''
  428. FG_WORKING_DIR='fglrx-install'
  429. # file and patch urls
  430. FG_LIVE_DRIVERS='http://smxi.org/sg/data/fg-drivers'
  431. NV_LIVE_DRIVERS='http://people.freedesktop.org/~aplattner/nvidia-versions'
  432. PATCH_DOWNLOAD='http://smxi.org/sg/'
  433. SCRIPT_DOWNLOAD='http://smxi.org/sg/'
  434. SCRIPT_DOWNLOAD_DATA='http://smxi.org/sg/data/'
  435. # alt for some data
  436. # "http://liquorix.net/sgfxi/"
  437. A_BASE_URLS=(
  438. "http://liquorix.net/sgfxi/"
  439. "$SCRIPT_DOWNLOAD_DATA"
  440. )
  441. BASE_INDEX=$(( $( date +%s ) % ${#A_BASE_URLS[@]} ))
  442. SCRIPT_DOWNLOAD_ALT=${A_BASE_URLS[${BASE_INDEX}]}
  443. SCRIPT_DOWNLOAD_VERSION='http://smxi.org/sm/sm-versions'
  444. SCRIPT_DOWNLOAD_DEV='http://techpatterns.com/downloads/distro/'
  445. SCRIPT_DOWNLOAD_BRANCH_1='https://github.com/smxi/sgfxi/raw/one/'
  446. SCRIPT_DOWNLOAD_BRANCH_2='https://github.com/smxi/sgfxi/raw/one/'
  447.  
  448. ARCH_FGLRX='arch-fglrx'
  449. ARCH_NVIDIA='arch-nvidia'
  450. DEBIAN_FGLRX='debian-fglrx'
  451. DEBIAN_NVIDIA='debian-nvidia'
  452. DISTRO_FGLRX=''
  453. DISTRO_NVIDIA=''
  454. FEDORA_FGLRX='fedora-fglrx'
  455. FEDORA_NVIDIA='fedora-nvidia'
  456. UBUNTU_FGLRX='ubuntu-fglrx'
  457. UBUNTU_NVIDIA='ubuntu-nvidia'
  458.  
  459. LOG_FILE_DIR="/var/log/$SCRIPT_NAME/"
  460. LOG_FILE="$SCRIPT_NAME.log"
  461. LOGPS='log_function_data ps $FUNCNAME "$( echo $@ )"'
  462. LOGPE='log_function_data pe $FUNCNAME'
  463. LOGUS='log_function_data us $FUNCNAME "$( echo $@ )"'
  464. LOGUE='log_function_data ue $FUNCNAME'
  465.  
  466. SCRIPT_ROTATE="/etc/logrotate.d/$SCRIPT_NAME"
  467. SM_VALUES="/usr/local/bin/$SCRIPT_NAME-values"
  468.  
  469. EXPERIMENTAL_XORG_ATI='xserver-xorg-video-ati_6.6.193-1'
  470. EXPERIMENTAL_LIBDRM2='libdrm2_2.4.0~git20070625-1'
  471. EXPERIMENTAL_LIBDRM_DEV='libdrm-dev_2.4.0~git20070625-1'
  472.  
  473. # this handles two cases: 1 where user logged in directly as 'root', and
  474. # 2, where user su to root.
  475. LOGIN_PID=$( ps | grep ' login' )
  476. if [ "$LOGIN_PID" == '' ];then
  477. LOGIN_PID=$( ps | grep ' su' )
  478. fi
  479. LOGIN_PID=$( awk '{print $1}' <<< $LOGIN_PID | grep -Eo "^[0-9]+$" )
  480.  
  481. # do some distro specific tweaks here too. Don't do this if
  482. # distro maintainers have set package defaults above.
  483. if [ -f "$EAR" -a "$B_ALLOW_AUTO_UPDATE" == 'true' ];then
  484. SCRIPT_HOME='/usr/bin'
  485. fi
  486.  
  487. # allow user set globals to override script globals
  488. if [ -f $SM_VALUES ];then
  489. source $SM_VALUES
  490. fi
  491.  
  492. ########################################################################
  493. #### FUNCTIONS: UTILITY TOOLS
  494. ########################################################################
  495.  
  496. ### -------------------------------------------------------------------
  497. ### test data - only for dev/debugging purposes
  498. ### -------------------------------------------------------------------
  499.  
  500. # only for debugging purposes
  501. set_test_data()
  502. {
  503. local username=''
  504.  
  505. if [ "$B_TESTING_1" == 'true' ];then # set testing directories etc
  506. ## NOTE: it's important to start all comments in here at first character for cleanup updater
  507. # # this is required for testing to make sure we always are starting with true
  508. # # latest script versions
  509.  
  510. # # note: devs: double check this output to make sure it's your user name
  511. # username=$( getent passwd 1000|cut -d \: -f1 )
  512. # SCRIPT_HOME="/home/$username/bin/scripts/sgfxi/dev/"
  513. # SCRIPT_WORKING_DIR="/home/$username/bin/scripts/sgfxi/dev"
  514. # # INSTALL_DIRECTORY='' # for stuff like patches etc
  515. # LOG_FILE_DIR="/home/$username/bin/scripts/sgfxi/dev/logs/"
  516. # PATCH_DOWNLOAD='http://smxi.org/sg/'
  517. # cd $SCRIPT_HOME
  518. # rm -f $LOG_FILE_DIR$SCRIPT_NAME.log
  519. # # sgfxi doesn't support any legacy ATI stuff
  520. # CARD_DATA=1002:7280 # fake ati pre x2000 card
  521. # CARD_DATA=1002:9442 # fake ati hd2000-hd4xxx
  522. # CARD_DATA=1002:9805 # fake ati hd 6250 card
  523. # CARD_DATA=10de:0020 # fake nvidia oldest legacy (7x.xx.xx drivers)
  524. # CARD_DATA=10de:0280 # fake nvidia mid legacy (9x.xx.xx drivers)
  525. # CARD_DATA=10de:0322 # fake nvidia 5xxx legacy (173.xx.xx drivers)
  526. # CARD_DATA=10de:0392 # fake nvidia 7xxx legacy (304.xx drivers)
  527. # CARD_DATA=10de:0422 # fake nvidia 8-9xxx- (GS 8400)
  528. # FG_DEFAULT='8-5'
  529. # NV_DEFAULT='177.80'
  530. # # set system bits to test 32/64 specific behaviors
  531. # BITS=64
  532. # # if you want to test for/without aptosid kernels, set to null '' or 'true'
  533. # B_IS_APTOSID_KERNEL='false'
  534. # # to test patches/error handling for a specific kernel major version,
  535. # # ie: 3-7 here
  536. # KERNEL_BASE=3
  537. # KERNEL_MATH=14
  538. # # values: '' or 'true'
  539. # B_IS_XEN='false'
  540. # # check for specific system base tests, can be:
  541. # # 'sid' 'testing' 'stable' 'etch'
  542. # SYSTEM_BASE='debian'
  543. # SYSTEM_CODENAME='testing'
  544. # X_VERSION='1.11' # override for patching etc
  545. # leave this at first character or errors in updater tools will occur
  546. :
  547. fi
  548. }
  549.  
  550. ### -------------------------------------------------------------------
  551. ### driver+kernel support tests, and patch handlers:
  552. ### -------------------------------------------------------------------
  553.  
  554. ## these are first to make it easy to update each new driver release support data
  555.  
  556. # forced overrides for fringe / weird cases, these tests will vary. Note that you can't put this in a subshell
  557. # unless it is only returning a driver, not setting a global flag.
  558. # args: $1 - driver to test
  559. driver_version_hacks()
  560. {
  561. eval $LOGUS
  562. local driverUsed=$1 bReturnDriver='false' results='' testData=''
  563.  
  564. # short term hack because amd hasn't released a stable driver since 13.4 as of 13.11 beta
  565. case $driverUsed in
  566. 13.9)
  567. B_USE_BETA='true'
  568. log_function_data "Forcing beta driver for current with fglrx"
  569. ;;
  570. 331.*)
  571. testData=$( grep -Es '^[[:space:]]*CONFIG_UIDGID_STRICT_TYPE_CHECKS[[:space:]]*=[[:space:]]*y' \
  572. /boot/config-${KERNEL_FULL}* )
  573. # new option for 3.12, we think.
  574. if [ -n "$testData" ];then
  575. EXTRA_ARGS='--no-unified-memory'
  576. fi
  577. log_function_data "testData: $testData\nForcing nvidia installer option: $EXTRA_ARGS"
  578. ;;
  579. esac
  580.  
  581. # make sure that the call either sets globals OR returns a driver, not both.
  582. if [ "$bReturnDriver" == 'true' ];then
  583. log_function_data "Driver returned: $driverUsed"
  584. echo $driverUsed
  585. fi
  586.  
  587. eval $LOGUE
  588. }
  589.  
  590. # args: $1- test type
  591. driver_support_tests()
  592. {
  593. eval $LOGUS
  594. # test for binary only tests here
  595. case $1 in
  596. supported-driver)
  597. case $CARD in
  598. $FGLRX)
  599. # xorg info: http://www.x.org/wiki/Releases/7.4
  600. # first dump if legacy level 1 and pre 9-4
  601. if [ "$LEGACY_LEVEL" -eq 1 -a "$B_USE_DISTRO_DRIVER" != 'true' ];then
  602. case $DRIVER_DEFAULT in
  603. 8-*|9-1|9.2|9-3)
  604. : # these drivers are fine
  605. ;;
  606. *)
  607. if [ "$B_TESTING_3" != 'true' ];then
  608. error_handler 221
  609. fi
  610. ;;
  611. esac
  612. fi
  613. # no hd2xxx-4xxx support now, as of 12-6
  614. if [ "$LEGACY_LEVEL" -eq 2 -a "$B_USE_DISTRO_DRIVER" != 'true' ];then
  615. case $DRIVER_DEFAULT in
  616. 8-*|9-*|10-*|11-*|12-[1-5])
  617. : # these drivers are fine
  618. ;;
  619. *)
  620. if [ "$B_TESTING_3" != 'true' ];then
  621. error_handler 212
  622. fi
  623. ;;
  624. esac
  625. fi
  626. # amd-catalyst-14.1-betav1.3-linux-x86.x86_64.zip
  627. case $DRIVER_DEFAULT in
  628. 14.*|15.*)
  629. FGLRX_PACKAGE_PREFIX='amd-catalyst'
  630. B_AMD='false'
  631. ;;
  632. 13[-.][8-9]|13[-.]1[0-2]|14[-.]*|15[-.]*)
  633. FGLRX_PACKAGE_PREFIX='amd-catalyst'
  634. ;;
  635. 13[-.][4-6])
  636. FGLRX_PACKAGE_PREFIX='amd-driver-installer-catalyst'
  637. ;;
  638. 12[-.]1[0-2]|13[-.][0-3])
  639. FGLRX_PACKAGE_PREFIX='amd-driver-installer-catalyst'
  640. ;;
  641. 12[-.][1-9])
  642. FGLRX_PACKAGE_PREFIX='amd-driver-installer'
  643. ;;
  644. *)
  645. FGLRX_PACKAGE_PREFIX='ati-driver-installer'
  646. ;;
  647. esac
  648. # incredibly, yet another pointless spastic amd file name change
  649. case $DRIVER_DEFAULT in
  650. 13[-.]*|14[-.]*|15[-.]*)
  651. FG_POST='linux-'
  652. ;;
  653. esac
  654. # test for >= xorg 1.6 support, using a whitelist of current drivers
  655. # drivers for now until old driver support is dropped, then change to
  656. # blacklist
  657. case $X_VERSION in
  658. 1.17*|1.16.99*)
  659. case $DRIVER_DEFAULT in
  660. 15.9.*|15.1[0-9].*|$DISTRO_FGLRX)
  661. if [ "$LEGACY_LEVEL" -lt 3 ];then
  662. if [ "$B_TESTING_3" != 'true' ];then
  663. error_handler 212
  664. fi
  665. fi
  666. ;;
  667. *)
  668. if [ "$B_TESTING_3" != 'true' ];then
  669. error_handler 226
  670. fi
  671. ;;
  672. esac
  673. ;;
  674. 1.16*|1.15.99*)
  675. case $DRIVER_DEFAULT in
  676. 15.*|14.12.*|$DISTRO_FGLRX)
  677. if [ "$LEGACY_LEVEL" -lt 3 ];then
  678. if [ "$B_TESTING_3" != 'true' ];then
  679. error_handler 212
  680. fi
  681. fi
  682. ;;
  683. *)
  684. if [ "$B_TESTING_3" != 'true' ];then
  685. error_handler 226
  686. fi
  687. ;;
  688. esac
  689. ;;
  690. 1.15.[0-8].*)
  691. case $DRIVER_DEFAULT in
  692. 15.*|14.*|$DISTRO_FGLRX)
  693. if [ "$LEGACY_LEVEL" -lt 3 ];then
  694. if [ "$B_TESTING_3" != 'true' ];then
  695. error_handler 212
  696. fi
  697. fi
  698. ;;
  699. *)
  700. if [ "$B_TESTING_3" != 'true' ];then
  701. error_handler 226
  702. fi
  703. ;;
  704. esac
  705. ;;
  706. 1.14*)
  707. case $DRIVER_DEFAULT in
  708. 15.*|14.*|13[.-][6-9]|13[.-]1[0-2]|$DISTRO_FGLRX)
  709. if [ "$LEGACY_LEVEL" -lt 3 ];then
  710. if [ "$B_TESTING_3" != 'true' ];then
  711. error_handler 212
  712. fi
  713. fi
  714. ;;
  715. *)
  716. if [ "$B_TESTING_3" != 'true' ];then
  717. error_handler 226
  718. fi
  719. ;;
  720. esac
  721. ;;
  722. 1.13*)
  723. case $DRIVER_DEFAULT in
  724. 15.*|14.*|13[-.][3-9]|13[-.]1[0-2]|$DISTRO_FGLRX)
  725. if [ "$LEGACY_LEVEL" -lt 3 ];then
  726. if [ "$B_TESTING_3" != 'true' ];then
  727. error_handler 212
  728. fi
  729. fi
  730. ;;
  731. *)
  732. if [ "$B_TESTING_3" != 'true' ];then
  733. error_handler 226
  734. fi
  735. ;;
  736. esac
  737. ;;
  738. 1.12*)
  739. case $DRIVER_DEFAULT in
  740. 15.*|14.*|13[.-]*|12[-.][6-9]|12[-.]1[0-2]|$DISTRO_FGLRX)
  741. if [ "$LEGACY_LEVEL" -lt 3 ];then
  742. if [ "$B_TESTING_3" != 'true' ];then
  743. error_handler 212
  744. fi
  745. fi
  746. ;;
  747. *)
  748. if [ "$B_TESTING_3" != 'true' ];then
  749. error_handler 226
  750. fi
  751. ;;
  752. esac
  753. ;;
  754. 1.11*)
  755. case $DRIVER_DEFAULT in
  756. 15.*|14.*|13[.-]*|12[.-]*|11-1[0-2]|$DISTRO_FGLRX)
  757. : # all other drivers fail to support xorg >= 1.9
  758. ;;
  759. *)
  760. if [ "$B_TESTING_3" != 'true' ];then
  761. error_handler 226
  762. fi
  763. ;;
  764. esac
  765. ;;
  766. 1.10*)
  767. case $DRIVER_DEFAULT in
  768. 15.*|14.*|13[.-]*|12[.-]*|11-[4-9]|11-1[0-2]|$DISTRO_FGLRX)
  769. : # all other drivers fail to support xorg >= 1.9
  770. ;;
  771. *)
  772. if [ "$B_TESTING_3" != 'true' ];then
  773. error_handler 226
  774. fi
  775. ;;
  776. esac
  777. ;;
  778. 1.9.*)
  779. case $DRIVER_DEFAULT in
  780. 15.*|14.*|13[.-]*|12[.-]*|11[.-]*|10-1[0-2]|$DISTRO_FGLRX)
  781. : # all other drivers fail to support xorg >= 1.9
  782. ;;
  783. *)
  784. if [ "$B_TESTING_3" != 'true' ];then
  785. error_handler 226
  786. fi
  787. ;;
  788. esac
  789. ;;
  790. 1.8.*|7.6)
  791. case $DRIVER_DEFAULT in
  792. 15.*|14.*|13[.-]*|12[.-]*|11[.-]*|10-[7-9]|10-1[0-2]|$DISTRO_FGLRX) # update when 1.8 is actually supported
  793. : # all other drivers fail to support xorg >= 1.8
  794. ;;
  795. *)
  796. if [ "$B_TESTING_3" != 'true' ];then
  797. error_handler 226
  798. fi
  799. ;;
  800. esac
  801. ;;
  802. 1.7.*|7.5)
  803. case $DRIVER_DEFAULT in
  804. 15.*|14.*|13[.-]*|12[.-]*|11[.-]*|10-[4-9]|10-1[0-2]|$DISTRO_FGLRX)
  805. : # all other drivers fail to support xorg >= 1.7
  806. ;;
  807. *)
  808. if [ "$B_TESTING_3" != 'true' ];then
  809. error_handler 226
  810. fi
  811. ;;
  812. esac
  813. ;;
  814. 1.6.*|7.[3-4])
  815. case $DRIVER_DEFAULT in
  816. 15.*|14.*|13[.-]*|12[.-]*|11[.-]*|10-*|9-[4-9]|9-1[0-2]|$DISTRO_FGLRX)
  817. : # all other drivers fail to support xorg >= 1.6
  818. ;;
  819. *)
  820. if [ "$B_TESTING_3" != 'true' ];then
  821. error_handler 226
  822. fi
  823. ;;
  824. esac
  825. ;;
  826. esac
  827. # handle no aptosid kernel support first for < 2.6.32
  828. # fglrx is working on all Debian/Liquorix kernels
  829. # for testing/debugging set this re:
  830. # http://techpatterns.com/docs/sgfxi-set-test-data.htm
  831. case $KERNEL_BASE in
  832. 2.6)
  833. case $KERNEL_MATH in
  834. 2[5-9]|3[0-1])
  835. if [ "$B_IS_APTOSID_KERNEL" == 'true' ];then
  836. error_handler 229
  837. fi
  838. ;;
  839. esac
  840. ;;
  841. esac
  842.  
  843. # handle libdrm > 2.3 version errors first
  844. case $DRIVER_DEFAULT in
  845. 8-[4-9]|8-1[0-2]|9-1|9.2|9-[3-5])
  846. misc_fixes 'drm-2-x-test'
  847. ;;
  848. esac
  849. # now the main support tests...
  850. case $KERNEL_BASE in
  851. 2.6)
  852. case $KERNEL_MATH in
  853. 26)
  854. case $DRIVER_DEFAULT in
  855. 8-4|8-5)
  856. if [ "$B_TESTING_3" != 'true' ];then
  857. error_handler 234 $KERNEL_NUMBER
  858. fi
  859. ;;
  860. esac
  861. ;;
  862. 27)
  863. case $DRIVER_DEFAULT in
  864. 8-4|8-5|8-6|8-7|8-8|8-9)
  865. if [ "$B_TESTING_" != 'true' ];then
  866. error_handler 234 $KERNEL_NUMBER
  867. fi
  868. ;;
  869. *)
  870. :
  871. ;;
  872. esac
  873. ;;
  874. 28)
  875. case $DRIVER_DEFAULT in
  876. 8-4|8-5|8-6|8-7|8-8|8-9)
  877. if [ "$B_TESTING_3" != 'true' ];then
  878. error_handler 234 $KERNEL_NUMBER
  879. fi
  880. ;;
  881. *)
  882. :
  883. ;;
  884. esac
  885. ;;
  886. 29)
  887. case $DRIVER_DEFAULT in
  888. 15.*|14.*|13[.-]*|12[.-]*|11-*|10-*|9.2|9-[3-9]|9-1[0-2]|$DISTRO_FGLRX)
  889. :
  890. ;;
  891. *)
  892. if [ "$B_TESTING_3" != 'true' ];then
  893. error_handler 234 $KERNEL_NUMBER
  894. fi
  895. ;;
  896. esac
  897. ;;
  898. 30)
  899. case $DRIVER_DEFAULT in
  900. 15.*|14.*|13[.-]*|12[.-]*|11-*|10-*|9-8|9-9|9-1[0-2]|$DISTRO_FGLRX)
  901. :
  902. ;;
  903. *)
  904. if [ "$B_TESTING_3" != 'true' ];then
  905. error_handler 234 $KERNEL_NUMBER
  906. fi
  907. ;;
  908. esac
  909. ;;
  910. 31|32)
  911. case $DRIVER_DEFAULT in
  912. 15.*|14.*|13[.-]*|12[.-]*|11-*|10-*|9-1[0-2]|$DISTRO_FGLRX)
  913. :
  914. ;;
  915. *)
  916. if [ "$B_TESTING_3" != 'true' ];then
  917. error_handler 234 $KERNEL_NUMBER
  918. fi
  919. ;;
  920. esac
  921. ;;
  922. 33)
  923. case $DRIVER_DEFAULT in
  924. 15.*|14.*|13[.-]*|12[.-]*|11-*|10-[2-9]|10-1[0-2]|$DISTRO_FGLRX)
  925. :
  926. ;;
  927. *)
  928. if [ "$B_TESTING_3" != 'true' ];then
  929. error_handler 234 $KERNEL_NUMBER
  930. fi
  931. ;;
  932. esac
  933. ;;
  934. 34)
  935. case $DRIVER_DEFAULT in
  936. 15.*|14.*|13[.-]*|12[.-]*|11-*|10-[5-9]|10-1[0-2]|$DISTRO_FGLRX)
  937. :
  938. ;;
  939. *)
  940. if [ "$B_TESTING_3" != 'true' ];then
  941. error_handler 234 $KERNEL_NUMBER
  942. fi
  943. ;;
  944. esac
  945. ;;
  946. 35)
  947. case $DRIVER_DEFAULT in
  948. 15.*|14.*|13[.-]*|12[.-]*|11-*|10-[8-9]|10-1[0-2]|$DISTRO_FGLRX)
  949. :
  950. ;;
  951. *)
  952. if [ "$B_TESTING_3" != 'true' ];then
  953. error_handler 234 $KERNEL_NUMBER
  954. fi
  955. ;;
  956. esac
  957. ;;
  958. 36|37)
  959. case $DRIVER_DEFAULT in
  960. # note: unknown if -11 will support 36, -10 doesn't, assume -12 will
  961. # patch from Arch works in application, don't know if it really works
  962. 15.*|14.*|13[.-]*|12[.-]*|11-*|10-1[0-2]|$DISTRO_FGLRX)
  963. :
  964. ;;
  965. *)
  966. if [ "$B_TESTING_3" != 'true' ];then
  967. error_handler 234 $KERNEL_NUMBER
  968. fi
  969. ;;
  970. esac
  971. ;;
  972. 38)
  973. case $DRIVER_DEFAULT in
  974. # note: unknown if -11 will support 36, -10 doesn't, assume -12 will
  975. # patch from Arch works in application, don't know if it really works
  976. 15.*|14.*|13[.-]*|12[.-]*|11-*|$DISTRO_FGLRX)
  977. :
  978. ;;
  979. *)
  980. if [ "$B_TESTING_3" != 'true' ];then
  981. error_handler 234 $KERNEL_NUMBER
  982. fi
  983. ;;
  984. esac
  985. ;;
  986. 39)
  987. case $DRIVER_DEFAULT in
  988. 15.*|14.*|13[.-]*|12[.-]*|11-[6-9]|11-1[0-2]|$DISTRO_FGLRX)
  989. :
  990. ;;
  991. *)
  992. if [ "$B_TESTING_3" != 'true' ];then
  993. error_handler 234 $KERNEL_NUMBER
  994. fi
  995. ;;
  996. esac
  997. ;;
  998. esac
  999. # end kernel math
  1000. ;;
  1001. 3)
  1002. case $KERNEL_MATH in
  1003. 0)
  1004. case $DRIVER_DEFAULT in
  1005. 15.*|14.*|13[.-]*|12[.-]*|11-[6-9]|11-1[0-2]|$DISTRO_FGLRX)
  1006. : # do nothing
  1007. ;;
  1008. *) # use 225 for beta testing errors
  1009. if [ "$B_TESTING_3" != 'true' ];then
  1010. error_handler 234 $KERNEL_NUMBER
  1011. fi
  1012. esac
  1013. ;;
  1014. 1)
  1015. case $DRIVER_DEFAULT in
  1016. 15.*|14.*|13[.-]*|12[.-]*|11-[8-9]|11-1[0-2]|$DISTRO_FGLRX)
  1017. : # do nothing
  1018. ;;
  1019. *) # use 225 for beta testing errors
  1020. if [ "$B_TESTING_3" != 'true' ];then
  1021. error_handler 234 $KERNEL_NUMBER
  1022. fi
  1023. esac
  1024. ;;
  1025. 2)
  1026. case $DRIVER_DEFAULT in
  1027. 15.*|14.*|13[.-]*|12[.-]*|$DISTRO_FGLRX)
  1028. : # do nothing
  1029. ;;
  1030. *) # use 225 for beta testing errors
  1031. if [ "$B_TESTING_3" != 'true' ];then
  1032. error_handler 234 $KERNEL_NUMBER
  1033. fi
  1034. esac
  1035. ;;
  1036. 3)
  1037. case $DRIVER_DEFAULT in
  1038. 15.*|14.*|13[.-]*|12-[4-9]|12-1[0-2]|$DISTRO_FGLRX)
  1039. : # do nothing
  1040. ;;
  1041. *) # use 225 for beta testing errors
  1042. if [ "$B_TESTING_3" != 'true' ];then
  1043. error_handler 234 $KERNEL_NUMBER
  1044. fi
  1045. esac
  1046. ;;
  1047. 4)
  1048. case $DRIVER_DEFAULT in
  1049. 15.*|14.*|13[.-]*|12-[7-9]|12-1[0-2]|$DISTRO_FGLRX)
  1050. : # do nothing
  1051. ;;
  1052. *) # use 225 for beta testing errors
  1053. if [ "$B_TESTING_3" != 'true' ];then
  1054. error_handler 234 $KERNEL_NUMBER
  1055. fi
  1056. esac
  1057. ;;
  1058. 5)
  1059. case $DRIVER_DEFAULT in
  1060. 15.*|14.*|13[.-]*|12-9|12-1[0-2]|$DISTRO_FGLRX)
  1061. : # do nothing
  1062. ;;
  1063. *) # use 225 for beta testing errors
  1064. if [ "$B_TESTING_3" != 'true' ];then
  1065. error_handler 234 $KERNEL_NUMBER
  1066. fi
  1067. esac
  1068. ;;
  1069. 6)
  1070. case $DRIVER_DEFAULT in
  1071. 15.*|14.*|13[.-]*|12-9|12-1[0-2]|$DISTRO_FGLRX)
  1072. : # do nothing
  1073. ;;
  1074. *) # use 225 for beta testing errors
  1075. if [ "$B_TESTING_3" != 'true' ];then
  1076. error_handler 234 $KERNEL_NUMBER
  1077. fi
  1078. esac
  1079. ;;
  1080. 7)
  1081. case $DRIVER_DEFAULT in
  1082. # amd release notes say it only supports kernel 3.5, but that's probably wrong
  1083. 15.*|14.*|13[.-][3-9]|13[.-]1[0-2]12.10|$DISTRO_FGLRX)
  1084. : # do nothing
  1085. ;;
  1086. *) # use 225 for beta testing errors
  1087. if [ "$B_TESTING_3" != 'true' ];then
  1088. error_handler 234 $KERNEL_NUMBER
  1089. fi
  1090. esac
  1091. ;;
  1092. 8)
  1093. case $DRIVER_DEFAULT in
  1094. # amd release notes say it only supports kernel 3.5, but that's probably wrong
  1095. 15.*|14.*|13[.-][4-9]|13[.-]1[0-2]|$DISTRO_FGLRX)
  1096. : # do nothing
  1097. ;;
  1098. *) # use 225 for beta testing errors
  1099. if [ "$B_TESTING_3" != 'true' ];then
  1100. error_handler 234 $KERNEL_NUMBER
  1101. fi
  1102. esac
  1103. ;;
  1104. 9)
  1105. case $DRIVER_DEFAULT in
  1106. 15.*|14.*|13[.-][8-9]|13[.-]1[0-2]|$DISTRO_FGLRX)
  1107. : # do nothing
  1108. ;;
  1109. *) # use 225 for beta testing errors
  1110. if [ "$B_TESTING_3" != 'true' ];then
  1111. error_handler 234 $KERNEL_NUMBER
  1112. fi
  1113. esac
  1114. ;;
  1115. 10)
  1116. case $DRIVER_DEFAULT in
  1117. 15.*|14.*|13[.-][8-9]|13[.-]1[0-2]|$DISTRO_FGLRX)
  1118. : # do nothing
  1119. ;;
  1120. *) # use 225 for beta testing errors
  1121. if [ "$B_TESTING_3" != 'true' ];then
  1122. error_handler 234 $KERNEL_NUMBER
  1123. fi
  1124. esac
  1125. ;;
  1126. 11)
  1127. case $DRIVER_DEFAULT in
  1128. 15.*|14.*|13[.-][9]|13[.-]1[0-2]|$DISTRO_FGLRX)
  1129. : # do nothing
  1130. ;;
  1131. *) # use 225 for beta testing errors
  1132. if [ "$B_TESTING_3" != 'true' ];then
  1133. error_handler 234 $KERNEL_NUMBER
  1134. fi
  1135. esac
  1136. ;;
  1137. 12)
  1138. case $DRIVER_DEFAULT in
  1139. 15.*|14.*|13[.-][9]|13[.-]1[0-2]|$DISTRO_FGLRX)
  1140. : # do nothing
  1141. ;;
  1142. *) # use 225 for beta testing errors
  1143. if [ "$B_TESTING_3" != 'true' ];then
  1144. error_handler 234 $KERNEL_NUMBER
  1145. fi
  1146. esac
  1147. ;;
  1148. 13)
  1149. case $DRIVER_DEFAULT in
  1150. 15.*|14.*|13[.-][9]|13[.-]1[0-2]|$DISTRO_FGLRX)
  1151. : # do nothing
  1152. ;;
  1153. *) # use 225 for beta testing errors
  1154. if [ "$B_TESTING_3" != 'true' ];then
  1155. error_handler 234 $KERNEL_NUMBER
  1156. fi
  1157. esac
  1158. ;;
  1159. 14)
  1160. case $DRIVER_DEFAULT in
  1161. 15.*|14.*|$DISTRO_FGLRX)
  1162. : # do nothing
  1163. ;;
  1164. *) # use 225 for beta testing errors
  1165. if [ "$B_TESTING_3" != 'true' ];then
  1166. error_handler 234 $KERNEL_NUMBER
  1167. fi
  1168. esac
  1169. ;;
  1170. 15)
  1171. case $DRIVER_DEFAULT in
  1172. 15.*|14.[5-9].*|14.1[0-2].*|$DISTRO_FGLRX)
  1173. : # do nothing
  1174. ;;
  1175. *) # use 225 for beta testing errors
  1176. if [ "$B_TESTING_3" != 'true' ];then
  1177. error_handler 234 $KERNEL_NUMBER
  1178. fi
  1179. esac
  1180. ;;
  1181. 16)
  1182. case $DRIVER_DEFAULT in
  1183. 15.*|14.9.*|14.1[0-2].*|$DISTRO_FGLRX)
  1184. : # do nothing
  1185. ;;
  1186. *) # use 225 for beta testing errors
  1187. if [ "$B_TESTING_3" != 'true' ];then
  1188. error_handler 234 $KERNEL_NUMBER
  1189. fi
  1190. esac
  1191. ;;
  1192. 17)
  1193. case $DRIVER_DEFAULT in
  1194. 15.*|14.9.*|14.1[0-2].*|$DISTRO_FGLRX)
  1195. : # do nothing
  1196. ;;
  1197. *) # use 225 for beta testing errors
  1198. if [ "$B_TESTING_3" != 'true' ];then
  1199. error_handler 234 $KERNEL_NUMBER
  1200. fi
  1201. esac
  1202. ;;
  1203. 18|19)
  1204. case $DRIVER_DEFAULT in
  1205. 15.*|14.1[0-2].*|$DISTRO_FGLRX)
  1206. : # do nothing
  1207. ;;
  1208. *) # use 225 for beta testing errors
  1209. if [ "$B_TESTING_3" != 'true' ];then
  1210. error_handler 234 $KERNEL_NUMBER
  1211. fi
  1212. esac
  1213. ;;
  1214. esac
  1215. # end kernel math
  1216. ;;
  1217. 4)
  1218. case $KERNEL_MATH in
  1219. 0)
  1220. case $DRIVER_DEFAULT in
  1221. 15.*|$DISTRO_FGLRX)
  1222. : # do nothing
  1223. ;;
  1224. *) # use 225 for beta testing errors
  1225. if [ "$B_TESTING_3" != 'true' ];then
  1226. error_handler 234 $KERNEL_NUMBER
  1227. fi
  1228. esac
  1229. ;;
  1230. 1)
  1231. case $DRIVER_DEFAULT in
  1232. 15.9.*|$DISTRO_FGLRX)
  1233. : # do nothing
  1234. ;;
  1235. *) # use 225 for beta testing errors
  1236. if [ "$B_TESTING_3" != 'true' ];then
  1237. error_handler 234 $KERNEL_NUMBER
  1238. fi
  1239. esac
  1240. ;;
  1241. 2)
  1242. case $DRIVER_DEFAULT in
  1243. 15.9.*|$DISTRO_FGLRX)
  1244. : # do nothing
  1245. ;;
  1246. *) # use 225 for beta testing errors
  1247. if [ "$B_TESTING_3" != 'true' ];then
  1248. error_handler 234 $KERNEL_NUMBER
  1249. fi
  1250. esac
  1251. ;;
  1252. esac
  1253. # end kernel math
  1254. ;;
  1255. esac
  1256. ;;
  1257. $NVIDIA)
  1258. # if [ "$DRIVER_DEFAULT" == "$DISTRO_NVIDIA" -a "$SYSTEM_CODENAME" == 'testing' ];then
  1259. # print_information_continue 'standard' "Your system appears to be Debian Testing based.\nThe $DISTRO_NVIDIA driver cannot build on Debian Testing because of a missing package.\nIf your system is Sid based, continue, otherwise exit now."
  1260. # else
  1261. # test for >= xorg 1.5 support, using a blacklist now of previous
  1262. # drivers rather than whitelisting
  1263. # xorg info: http://www.x.org/wiki/Releases/7.4
  1264. case $X_VERSION in
  1265. 1.[5-9].*|1.10*|2.[0-9]*|7.[4-9])
  1266. case $DRIVER_DEFAULT in
  1267. 169.12|100.14.19)
  1268. if [ "$B_TESTING_3" != 'true' ];then
  1269. error_handler 226
  1270. fi
  1271. ;;
  1272. # 180.*|177.*|173.14.15|96.43.09|71.86.07
  1273. *)
  1274. : ## support should be working, see feedback
  1275. ;;
  1276. esac
  1277. ;;
  1278. esac
  1279. # note: the legacy 1 latest should handle xorg 1.7
  1280. case $X_VERSION in
  1281. 1.18*|1.17.99*)
  1282. case $DRIVER_DEFAULT in
  1283. 358.*|355.*|352.*|349.*|340.[8-9][0-9]|304.1[2-9][0-9]|$DISTRO_NVIDIA)
  1284. :
  1285. ;;
  1286. *)
  1287. if [ "$B_TESTING_3" != 'true' ];then
  1288. error_handler 226
  1289. fi
  1290. ;;
  1291. esac
  1292. ;;
  1293. 1.17*|1.16.99*)
  1294. case $DRIVER_DEFAULT in
  1295. 358.*|355.*|352.*|349.*|346.*|343.[3-9][0-9]|340.[6-9][0-9]|304.1[2-9][0-9]|$DISTRO_NVIDIA)
  1296. :
  1297. ;;
  1298. *)
  1299. if [ "$B_TESTING_3" != 'true' ];then
  1300. error_handler 226
  1301. fi
  1302. ;;
  1303. esac
  1304. ;;
  1305. 1.16*|1.15.99*)
  1306. # note: 173.14.39 is last legacy 3/5xxx card branch release so xorg support cuts off here
  1307. case $DRIVER_DEFAULT in
  1308. 358.*|355.*|352.*|349.*|346.*|343.*|340.*|337.*|304.12[3-9]|304.1[3-9]*|$DISTRO_NVIDIA)
  1309. :
  1310. ;;
  1311. *)
  1312. if [ "$B_TESTING_3" != 'true' ];then
  1313. error_handler 226
  1314. fi
  1315. ;;
  1316. esac
  1317. ;;
  1318. 1.15.[0-8]*)
  1319. # note: 173.14.39 is last legacy 3/5xxx card branch release so xorg support cuts off here
  1320. case $DRIVER_DEFAULT in
  1321. 358.*|355.*|352.*|349.*|346.*|343.*|340.*|337.*|334.*|331.*|304.11[7-9]|304.1[2-9][0-9]|173.14.3[9]|$DISTRO_NVIDIA)
  1322. :
  1323. ;;
  1324. *)
  1325. if [ "$B_TESTING_3" != 'true' ];then
  1326. error_handler 226
  1327. fi
  1328. ;;
  1329. esac
  1330. ;;
  1331. 1.14*)
  1332. case $DRIVER_DEFAULT in
  1333. 358.*|355.*|352.*|349.*|346.*|343.*|340.*|337.*|334.*|331.*|325.*|319.*|313.*|31[4-9].[0-9][0-9]|304.[89][0-9]|304.[1-9][0-9][0-9]|310.[4-9][0-9]|173.14.3[7-9]|$DISTRO_NVIDIA)
  1334. :
  1335. ;;
  1336. *)
  1337. if [ "$B_TESTING_3" != 'true' ];then
  1338. error_handler 226
  1339. fi
  1340. ;;
  1341. esac
  1342. ;;
  1343. 1.13*)
  1344. case $DRIVER_DEFAULT in
  1345. 358.*|355.*|352.*|349.*|346.*|343.*|340.*|337.*|334.*|331.*|325.*|319.*|313.*|310.*|304.[3-9][0-9]|304.[1-9][0-9][0-9]|173.14.3[6-9]|$DISTRO_NVIDIA)
  1346. :
  1347. ;;
  1348. *)
  1349. if [ "$B_TESTING_3" != 'true' ];then
  1350. error_handler 226
  1351. fi
  1352. ;;
  1353. esac
  1354. ;;
  1355. 1.12*)
  1356. case $DRIVER_DEFAULT in
  1357. 358.*|355.*|352.*|349.*|346.*|346.*|343.*|340.*|337.*|334.*|331.*|325.*|319.*|313.*|310.*|304.*|302.*|295.[3-9][0-9]|173.14.[3][4-9]|96.43.2[3-9]|$DISTRO_NVIDIA)
  1358. :
  1359. ;;
  1360. *)
  1361. if [ "$B_TESTING_3" != 'true' ];then
  1362. error_handler 226
  1363. fi
  1364. ;;
  1365. esac
  1366. ;;
  1367. 1.11*)
  1368. case $DRIVER_DEFAULT in
  1369. 358.*|355.*|352.*|349.*|346.*|343.*|340.*|337.*|334.*|331.*|325.*|319.*|313.*|310.*|304.*|302.*|295.*|290.*|285.0[5-9].*|173.14.[3][4-9]|96.43.2[3-9]|$DISTRO_NVIDIA)
  1370. :
  1371. ;;
  1372. 285.03|280.*|275.28)
  1373. B_SET_IGNOREABI='true'
  1374. : # this is speculative but let's see if it works
  1375. ;;
  1376. *)
  1377. if [ "$B_TESTING_3" != 'true' ];then
  1378. error_handler 226
  1379. fi
  1380. ;;
  1381. esac
  1382. ;;
  1383. 1.10*)
  1384. case $DRIVER_DEFAULT in
  1385. # not positive about legacy drivers yet
  1386. 358.*|355.*|352.*|349.*|346.*|343.*|340.*|337.*|334.*|331.*|325.*|319.*|313.*|310.*|304.*|302.*|295.*|290.*|285.*|280.*|275.*|270.*|173.14.3*|96.43.2[0-9]|$DISTRO_NVIDIA)
  1387. : # all other drivers fail to support xorg >= 1.9
  1388. ;;
  1389. *)
  1390. if [ "$B_TESTING_3" != 'true' ];then
  1391. error_handler 226
  1392. fi
  1393. ;;
  1394. esac
  1395. ;;
  1396. 1.9.*)
  1397. case $DRIVER_DEFAULT in
  1398. # not positive about 256 series + 1.9, or 96
  1399. 358.*|355.*|352.*|349.*|346.*|343.*|340.*|337.*|334.*|331.*|325.*|319.*|313.*|310.*|304.*|302.*|295.*|290.*|285.*|280.*|275.*|270.*|260.*|256.*|173.14.3*|173.14.2[89]|96.43.19|96.43.2[0-9]|$DISTRO_NVIDIA)
  1400. : # all other drivers fail to support xorg >= 1.9
  1401. ;;
  1402. *)
  1403. if [ "$B_TESTING_3" != 'true' ];then
  1404. error_handler 226
  1405. fi
  1406. ;;
  1407. esac
  1408. ;;
  1409. 1.8.*)
  1410. case $DRIVER_DEFAULT in
  1411. 358.*|355.*|352.*|349.*|346.*|343.*|340.*|337.*|334.*|331.*|325.*|319.*|313.*|310.*|304.*|302.*|295.*|290.*|285.*|280.*|275.*|270.*|260.*|256.*|195.36.[2-9][0-9]|173.14.3*|173.14.2[789]|96.43.19|96.43.2[0-9]|$DISTRO_NVIDIA)
  1412. : # all other drivers fail to support xorg >= 1.8
  1413. ;;
  1414. *)
  1415. if [ "$B_TESTING_3" != 'true' ];then
  1416. error_handler 226
  1417. fi
  1418. ;;
  1419. esac
  1420. ;;
  1421. 1.7.*|7.[5])
  1422. case $DRIVER_DEFAULT in
  1423. 358.*|355.*|352.*|349.*|346.*|343.*|340.*|337.*|334.*|331.*|325.*|319.*|313.*|310.*|304.*|302.*|295.*|290.*|285.*|280.*|275.*|270.*|260.*|256.*|195.*|190.53|173.14.3*|173.14.2*|96.43.1*|96.43.2*|71.86.1[34567]|$DISTRO_NVIDIA)
  1424. : # all other drivers fail to support xorg >= 1.7
  1425. ;;
  1426. *)
  1427. if [ "$B_TESTING_3" != 'true' ];then
  1428. error_handler 226
  1429. fi
  1430. ;;
  1431. esac
  1432. ;;
  1433. 1.6.*|7.[3-4])
  1434. # 1.[6-9]|2.[0-9]|7.[4-9])
  1435. case $DRIVER_DEFAULT in
  1436. 71.86.11|71.86.09)
  1437. if [ "$B_TESTING_3" != 'true' ];then
  1438. error_handler 226
  1439. fi
  1440. ;;
  1441. *)
  1442. : ## support should be working, see feedback
  1443. ;;
  1444. esac
  1445. ;;
  1446. esac
  1447.  
  1448. # white list of known http downloads, otherwise use ftp, this will be required
  1449. # for any future drivers auto detected beta drivers anyway.
  1450. # driver=71.86.13;wget --spider http://download.nvidia.com/XFree86/Linux-x86/$driver/NVIDIA-Linux-x86-$driver-pkg0.run
  1451. # default download site for nvidia, return http://us.download if problems
  1452. case $DRIVER_DEFAULT in
  1453. 190.53|190.42|185.18.36|180.60|177.82|173.14.2[25]|169.12|100.14.19|96.43.1[46]|71.86.1[134]|71.86.09)
  1454. NVIDIA_DOWNLOAD_SITE='http://download.nvidia.com'
  1455. ;;
  1456. 343.22|340.46|302.17|285.03|280.13|275.*|173.14.39)
  1457. NVIDIA_DOWNLOAD_SITE='http://us.download.nvidia.com'
  1458. ;;
  1459. *)
  1460. NVIDIA_DOWNLOAD_SITE='ftp://download.nvidia.com'
  1461. ;;
  1462. esac
  1463. # ftp://download.nvidia.com/XFree86/Linux-x86/256.35/NVIDIA-Linux-x86-256.35.run
  1464. #ftp://download.nvidia.com/XFree86/Linux-x86_64/256.35/NVIDIA-Linux-x86_64-256.35.run
  1465. #ftp://download.nvidia.com/XFree86/Linux-x86_64/256.35/NVIDIA-Linux-x86-256.35.run
  1466. # white list of old path version drivers
  1467. # new download urls, no -pkgx in file name string
  1468. case $DRIVER_DEFAULT in
  1469. # old download urls, with -pkgx in file name string
  1470. 195.36.*|190.*|185.18.*|180.60|177.82|173.14.*|169.12|100.14.19|96.43.*|71.86.*)
  1471. # this tweak thanks to ajw1980, who pointed out that pkg2 installs
  1472. # 32 bit compatibility libs in 64 bit without further fuss.
  1473. if [ "$BITS" == '64' ];then
  1474. NV_PKG_NO='-pkg2'
  1475. else
  1476. NV_PKG_NO='-pkg0'
  1477. fi
  1478. ;;
  1479. esac
  1480. # handle change to legacy 5xxx level cards
  1481. case $DRIVER_DEFAULT in
  1482. 173.*.*|169.12|100.*.*|96.*.*|71.*.*|$DISTRO_NVIDIA)
  1483. :
  1484. ;;
  1485. # 180.11|180.08|180.06|177.82|177.80
  1486. *)
  1487. if [ "$LEGACY_LEVEL" -eq 3 ];then
  1488. error_handler 227
  1489. fi
  1490. ;;
  1491. esac
  1492. # basic version handling and support tests, unless otherwise reported,
  1493. # $DISTRO_NVIDIA will be supported by default
  1494. case $KERNEL_BASE in
  1495. 2.6)
  1496. case $KERNEL_MATH in
  1497. 24) # going to try just 2.6.24 links, see if any issues appear
  1498. # this doesn't work on debian kernels
  1499. if [ "$B_IS_APTOSID_KERNEL" == 'true' ];then
  1500. misc_fixes nvidia-24-link # this might always be needed, all cases?
  1501. fi
  1502. ;;
  1503. 26)
  1504. case $DRIVER_DEFAULT in
  1505. 358.*|355.*|352.*|349.*|346.*|343.*|340.*|337.*|334.*|331.*|325.*|319.*|313.*|310.*|304.*|302.*|295.*|290.*|285.*|280.*|275.*|270.*|260.*|256.*|195.*|190.*|185.*|180.*|177.*|173.*.*|100.*.*|96.*.*|71.*.*|$DISTRO_NVIDIA)
  1506. : # do nothing
  1507. ;;
  1508. *)
  1509. if [ "$B_TESTING_3" != 'true' ];then
  1510. error_handler 234 $KERNEL_NUMBER
  1511. fi
  1512. ;;
  1513. esac
  1514. ;;
  1515. 27)
  1516. case $DRIVER_DEFAULT in
  1517. 358.*|355.*|352.*|349.*|346.*|343.*|340.*|337.*|334.*|331.*|325.*|319.*|313.*|310.*|304.*|302.*|295.*|290.*|285.*|280.*|275.*|270.*|260.*|256.*|195.*|190.*|185.*|180.*|177.*|173.*.*|100.*.*|96.*.*|71.*.*|$DISTRO_NVIDIA)
  1518. : # do nothing
  1519. ;;
  1520. *)
  1521. if [ "$B_TESTING_3" != 'true' ];then
  1522. error_handler 234 $KERNEL_NUMBER
  1523. fi
  1524. ;;
  1525. esac
  1526. ;;
  1527. 28)
  1528. case $DRIVER_DEFAULT in
  1529. 358.*|355.*|352.*|349.*|346.*|343.*|340.*|337.*|334.*|331.*|325.*|319.*|313.*|310.*|304.*|302.*|295.*|290.*|285.*|280.*|275.*|270.*|260.*|256.*|195.*|190.*|185.*|180.*|177.*|173.14.[23]*|96.43.[12]*|71.86.1*|71.86.09|$DISTRO_NVIDIA)
  1530. : # do nothing
  1531. ;;
  1532. *)
  1533. if [ "$B_TESTING_3" != 'true' ];then
  1534. error_handler 234 $KERNEL_NUMBER
  1535. fi
  1536. ;;
  1537. esac
  1538. ;;
  1539. 29)
  1540. case $DRIVER_DEFAULT in
  1541. 358.*|355.*|352.*|349.*|346.*|343.*|340.*|337.*|334.*|331.*|325.*|319.*|313.*|310.*|304.*|302.*|295.*|290.*|285.*|280.*|275.*|270.*|260.*|256.*|195.*|190.*|185.*|180.*|177.*|173.14.[23]*|96.43.[12]*|71.86.1*|71.86.09|$DISTRO_NVIDIA)
  1542. : # do nothing
  1543. ;;
  1544. *) # use 225 for beta testing errors
  1545. if [ "$B_TESTING_3" != 'true' ];then
  1546. error_handler 234 $KERNEL_NUMBER
  1547. fi
  1548. ;;
  1549. esac
  1550. ;;
  1551. 30)
  1552. case $DRIVER_DEFAULT in
  1553. 358.*|355.*|352.*|349.*|346.*|343.*|340.*|337.*|334.*|331.*|325.*|319.*|313.*|310.*|304.*|302.*|295.*|290.*|285.*|280.*|275.*|270.*|260.*|256.*|195.*|190.*|185.*|173.14.[23]*|96.43.[12]*|71.86.1*|71.86.09|$DISTRO_NVIDIA)
  1554. : # do nothing
  1555. ;;
  1556. *) # use 225 for beta testing errors
  1557. if [ "$B_TESTING_3" != 'true' ];then
  1558. error_handler 234 $KERNEL_NUMBER
  1559. fi
  1560. ;;
  1561. esac
  1562. ;;
  1563. # note: 34 not fully confirmed yet for all drivers/legacy levels
  1564. 31|32|33|34)
  1565. case $DRIVER_DEFAULT in
  1566. 358.*|355.*|352.*|349.*|346.*|343.*|340.*|337.*|334.*|331.*|325.*|319.*|313.*|310.*|304.*|302.*|295.*|290.*|285.*|280.*|275.*|270.*|260.*|256.*|195.*|190.*|185.*|173.14.[23]*|96.43.[12]*|71.86.1*|$DISTRO_NVIDIA)
  1567. : # do nothing
  1568. ;;
  1569. *) # use 225 for beta testing errors
  1570. if [ "$B_TESTING_3" != 'true' ];then
  1571. error_handler 234 $KERNEL_NUMBER
  1572. fi
  1573. ;;
  1574. esac
  1575. ;;
  1576. 35|36|37|38)
  1577. # we'll assume the older drivers don't work here
  1578. case $DRIVER_DEFAULT in
  1579. 358.*|355.*|352.*|349.*|346.*|343.*|340.*|337.*|334.*|331.*|325.*|319.*|313.*|310.*|304.*|302.*|295.*|290.*|285.*|280.*|275.*|270.*|260.*|173.14.[23]*|96.43.[12]*|71.86.1*|$DISTRO_NVIDIA)
  1580. : # do nothing
  1581. ;;
  1582. *) # use 225 for beta testing errors
  1583. if [ "$B_TESTING_3" != 'true' ];then
  1584. error_handler 234 $KERNEL_NUMBER
  1585. fi
  1586. ;;
  1587. esac
  1588. ;;
  1589. 39)
  1590. # we'll assume the older drivers don't work here
  1591. case $DRIVER_DEFAULT in
  1592. # note that the current 96xx can be patched if xorg version
  1593. # is old, 1.7, but that's an unusual case
  1594. 358.*|355.*|352.*|349.*|346.*|343.*|340.*|337.*|334.*|331.*|325.*|319.*|313.*|310.*|304.*|302.*|295.*|290.*|285.*|280.*|275.*|270.*|173.14.[3]*|96.43.[2]*|$DISTRO_NVIDIA)
  1595. : # do nothing
  1596. ;;
  1597. *) # use 225 for beta testing errors
  1598. if [ "$B_TESTING_3" != 'true' ];then
  1599. error_handler 234 $KERNEL_NUMBER
  1600. fi
  1601. ;;
  1602. esac
  1603. ;;
  1604. esac # end KERNEL_MATH
  1605. ;;
  1606. 3)
  1607. case $KERNEL_MATH in
  1608. 0)
  1609. case $DRIVER_DEFAULT in
  1610. 358.*|355.*|352.*|349.*|346.*|343.*|340.*|337.*|334.*|331.*|325.*|319.*|313.*|310.*|304.*|302.*|295.*|290.*|285.*|280.*|275.*|270.*|173.14.[3]*|96.43.[2]*|$DISTRO_NVIDIA)
  1611. : # do nothing
  1612. ;;
  1613. *) # use 225 for beta testing errors
  1614. if [ "$B_TESTING_3" != 'true' ];then
  1615. error_handler 234 $KERNEL_NUMBER
  1616. fi
  1617. ;;
  1618. esac
  1619. ;;
  1620. 1)
  1621. case $DRIVER_DEFAULT in
  1622. 358.*|355.*|352.*|349.*|346.*|343.*|340.*|337.*|334.*|331.*|325.*|319.*|313.*|310.*|304.*|302.*|295.*|290.*|285.*|173.14.[3]*|96.43.[2]*|$DISTRO_NVIDIA)
  1623. : # do nothing
  1624. ;;
  1625. *) # use 225 for beta testing errors
  1626. if [ "$B_TESTING_3" != 'true' ];then
  1627. error_handler 234 $KERNEL_NUMBER
  1628. fi
  1629. ;;
  1630. esac
  1631. ;;
  1632. 2)
  1633. case $DRIVER_DEFAULT in
  1634. 358.*|355.*|352.*|349.*|346.*|343.*|340.*|337.*|334.*|331.*|325.*|319.*|313.*|310.*|304.*|302.*|295.*|290.*|285.05.09|173.14.[3][0-9]|96.43.[2]*|$DISTRO_NVIDIA)
  1635. : # do nothing
  1636. ;;
  1637. *) # use 225 for beta testing errors
  1638. if [ "$B_TESTING_3" != 'true' ];then
  1639. error_handler 234 $KERNEL_NUMBER
  1640. fi
  1641. ;;
  1642. esac
  1643. ;;
  1644. 3)
  1645. case $DRIVER_DEFAULT in
  1646. # note that patches are needed for rc 3.3 kernels, we'll wait
  1647. # http://weltall.heliohost.org/wordpress/2012/01/20/linux-kernel-3-3-rc1-and-nvidia-drivers/
  1648. 358.*|355.*|352.*|349.*|346.*|343.*|340.*|337.*|334.*|331.*|325.*|319.*|313.*|310.*|304.*|302.*|295.*|173.14.[3][4-9]|96.43.23|$DISTRO_NVIDIA)
  1649. : # do nothing
  1650. ;;
  1651. *) # use 225 for beta testing errors
  1652. if [ "$B_TESTING_3" != 'true' ];then
  1653. error_handler 234 $KERNEL_NUMBER
  1654. fi
  1655. ;;
  1656. esac
  1657. ;;
  1658. 4)
  1659. case $DRIVER_DEFAULT in
  1660. 358.*|355.*|352.*|349.*|346.*|343.*|340.*|337.*|334.*|331.*|325.*|319.*|313.*|310.*|304.*|302.*|295.*|173.14.[3][4-9]|96.43.23|$DISTRO_NVIDIA)
  1661. : # do nothing
  1662. ;;
  1663. *) # use 225 for beta testing errors
  1664. if [ "$B_TESTING_3" != 'true' ];then
  1665. error_handler 234 $KERNEL_NUMBER
  1666. fi
  1667. ;;
  1668. esac
  1669. ;;
  1670. 5)
  1671. case $DRIVER_DEFAULT in
  1672. 358.*|355.*|352.*|349.*|346.*|343.*|340.*|337.*|334.*|331.*|325.*|319.*|313.*|310.*|304.*|302.*|173.14.[3][4-9]|96.43.23|$DISTRO_NVIDIA)
  1673. : # do nothing
  1674. ;;
  1675. *) # use 225 for beta testing errors
  1676. if [ "$B_TESTING_3" != 'true' ];then
  1677. error_handler 234 $KERNEL_NUMBER
  1678. fi
  1679. ;;
  1680. esac
  1681. ;;
  1682. 6)
  1683. case $DRIVER_DEFAULT in
  1684. 358.*|355.*|352.*|349.*|346.*|343.*|340.*|337.*|334.*|331.*|325.*|319.*|313.*|310.*|304.*|173.14.[3][6-9]|96.43.23|$DISTRO_NVIDIA)
  1685. : # do nothing
  1686. ;;
  1687. *) # use 225 for beta testing errors
  1688. if [ "$B_TESTING_3" != 'true' ];then
  1689. error_handler 234 $KERNEL_NUMBER
  1690. fi
  1691. ;;
  1692. esac
  1693. ;;
  1694. 7)
  1695. case $DRIVER_DEFAULT in
  1696. # note: 173 probably does not work with 3.7 kernel but wait for error reports.
  1697. 358.*|355.*|352.*|349.*|346.*|343.*|340.*|337.*|334.*|331.*|325.*|319.*|313.*|310.*|304.[689][0-9]|304.[1-9][0-9][0-9]|173.14.[3][6-9]|$DISTRO_NVIDIA)
  1698. : # do nothing
  1699. ;;
  1700. *) # use 225 for beta testing errors
  1701. if [ "$B_TESTING_3" != 'true' ];then
  1702. error_handler 234 $KERNEL_NUMBER
  1703. fi
  1704. ;;
  1705. esac
  1706. ;;
  1707. 8)
  1708. case $DRIVER_DEFAULT in
  1709. 358.*|355.*|352.*|349.*|346.*|343.*|340.*|337.*|334.*|331.*|325.*|319.*|313.*|310.*|304.[89][0-9]|304.[1-9][0-9][0-9]|173.14.[3][6-9]|$DISTRO_NVIDIA)
  1710. : # do nothing
  1711. ;;
  1712. *) # use 225 for beta testing errors
  1713. if [ "$B_TESTING_3" != 'true' ];then
  1714. error_handler 234 $KERNEL_NUMBER
  1715. fi
  1716. ;;
  1717. esac
  1718. ;;
  1719. 9)
  1720. case $DRIVER_DEFAULT in
  1721. 358.*|355.*|352.*|349.*|346.*|343.*|340.*|337.*|334.*|331.*|325.*|319.*|313.*|310.*|304.[89][0-9]|304.[1-9][0-9][0-9]|173.14.[3-9][6-9]|$DISTRO_NVIDIA)
  1722. : # do nothing
  1723. ;;
  1724. *) # use 225 for beta testing errors
  1725. if [ "$B_TESTING_3" != 'true' ];then
  1726. error_handler 234 $KERNEL_NUMBER
  1727. fi
  1728. ;;
  1729. esac
  1730. ;;
  1731. 10)
  1732. case $DRIVER_DEFAULT in
  1733. 358.*|355.*|352.*|349.*|346.*|343.*|340.*|337.*|334.*|331.*|325.*|319.[4-9][0-9]|304.[89][0-9]|304.[1-9][0-9][0-9]|173.14.[3-9][0-9]|$DISTRO_NVIDIA)
  1734. : # do nothing
  1735. ;;
  1736. *) # use 225 for beta testing errors
  1737. if [ "$B_TESTING_3" != 'true' ];then
  1738. error_handler 234 $KERNEL_NUMBER
  1739. fi
  1740. ;;
  1741. esac
  1742. ;;
  1743. 11)
  1744. case $DRIVER_DEFAULT in
  1745. 358.*|355.*|352.*|349.*|346.*|343.*|340.*|337.*|334.*|331.*|325.*|319.[4-9][0-9]|304.1[0-9][0-9]|173.14.[3-9][0-9]|$DISTRO_NVIDIA)
  1746. # trigger installer flag if needed
  1747. driver_version_hacks "$DRIVER_DEFAULT"
  1748. ;;
  1749. *) # use 225 for beta testing errors
  1750. if [ "$B_TESTING_3" != 'true' ];then
  1751. error_handler 234 $KERNEL_NUMBER
  1752. fi
  1753. ;;
  1754. esac
  1755. ;;
  1756. 12)
  1757. case $DRIVER_DEFAULT in
  1758. 358.*|355.*|352.*|349.*|346.*|343.*|340.*|337.*|334.*|331.*|325.*|319.[6-9][0-9]|304.1[0-9][0-9]|173.14.[3-9][0-9]|$DISTRO_NVIDIA)
  1759. # trigger installer flag if needed
  1760. driver_version_hacks "$DRIVER_DEFAULT"
  1761. ;;
  1762. *) # use 225 for beta testing errors
  1763. if [ "$B_TESTING_3" != 'true' ];then
  1764. error_handler 234 $KERNEL_NUMBER
  1765. fi
  1766. ;;
  1767. esac
  1768. ;;
  1769. 13)
  1770. # echo driver default $DRIVER_DEFAULT
  1771. case $DRIVER_DEFAULT in
  1772. # waiting for patches and confirmations
  1773. 358.*|355.*|352.*|349.*|346.*|343.*|340.*|337.*|334.*|331.3[89]|331.[4-9][0-9]|304.119|304.[1-9][2-9][0-9]|$DISTRO_NVIDIA)
  1774. # trigger installer flag if needed
  1775. driver_version_hacks "$DRIVER_DEFAULT"
  1776. ;;
  1777. 331.*|319.[6-9][0-9]|304.1[0-9][0-9]|173.14.[3-9][0-9]|$DISTRO_NVIDIA)
  1778. # trigger installer flag if needed
  1779. echo "${M}Waiting for a full working ${C}3.13 kernel${M} driver patch!${N}"
  1780. if [ "$B_TESTING_3" != 'true' ];then
  1781. error_handler 234 $KERNEL_NUMBER
  1782. fi
  1783. driver_version_hacks "$DRIVER_DEFAULT"
  1784. ;;
  1785. *) # use 225 for beta testing errors
  1786. if [ "$B_TESTING_3" != 'true' ];then
  1787. error_handler 234 $KERNEL_NUMBER
  1788. fi
  1789. ;;
  1790. esac
  1791. ;;
  1792. 14)
  1793. # echo driver default $DRIVER_DEFAULT
  1794. case $DRIVER_DEFAULT in
  1795. # waiting for patches and confirmations
  1796. 358.*|355.*|352.*|349.*|346.*|343.*|340.*|337.*|334.*|331.[4-9][0-9]|304.[1-9][2-9][0-9]|$DISTRO_NVIDIA)
  1797. # trigger installer flag if needed
  1798. driver_version_hacks "$DRIVER_DEFAULT"
  1799. ;;
  1800. *) # use 225 for beta testing errors
  1801. if [ "$B_TESTING_3" != 'true' ];then
  1802. error_handler 234 $KERNEL_NUMBER
  1803. fi
  1804. ;;
  1805. esac
  1806. ;;
  1807. 15)
  1808. # echo driver default $DRIVER_DEFAULT
  1809. case $DRIVER_DEFAULT in
  1810. # waiting for patches and confirmations
  1811. 358.*|355.*|352.*|349.*|346.*|343.*|340.*|304.[1-9][2-9][0-9]|$DISTRO_NVIDIA)
  1812. # trigger installer flag if needed
  1813. driver_version_hacks "$DRIVER_DEFAULT"
  1814. ;;
  1815. *) # use 225 for beta testing errors
  1816. if [ "$B_TESTING_3" != 'true' ];then
  1817. error_handler 234 $KERNEL_NUMBER
  1818. fi
  1819. ;;
  1820. esac
  1821. ;;
  1822. 16|17)
  1823. # echo driver default $DRIVER_DEFAULT
  1824. case $DRIVER_DEFAULT in
  1825. # waiting for patches and confirmations
  1826. 358.*|355.*|352.*|349.*|346.*|343.*|340.*|304.[1-9][2-9][0-9]|$DISTRO_NVIDIA)
  1827. # trigger installer flag if needed
  1828. driver_version_hacks "$DRIVER_DEFAULT"
  1829. ;;
  1830. *) # use 225 for beta testing errors
  1831. if [ "$B_TESTING_3" != 'true' ];then
  1832. error_handler 234 $KERNEL_NUMBER
  1833. fi
  1834. ;;
  1835. esac
  1836. ;;
  1837. 18)
  1838. # echo driver default $DRIVER_DEFAULT
  1839. case $DRIVER_DEFAULT in
  1840. # waiting for patches and confirmations
  1841. 358.*|355.*|352.*|349.*|346.*|343.*|340.[6-9][0-9]|340.[1-9][0-9][0-9]|304.[1-9][2-9][0-9]|$DISTRO_NVIDIA)
  1842. # trigger installer flag if needed
  1843. driver_version_hacks "$DRIVER_DEFAULT"
  1844. ;;
  1845. *) # use 225 for beta testing errors
  1846. if [ "$B_TESTING_3" != 'true' ];then
  1847. error_handler 234 $KERNEL_NUMBER
  1848. fi
  1849. ;;
  1850. esac
  1851. ;;
  1852. 19)
  1853. # echo driver default $DRIVER_DEFAULT
  1854. case $DRIVER_DEFAULT in
  1855. # waiting for patches and confirmations
  1856. 358.*|355.*|352.*|349.*|346.*|340.[7-9][0-9]|340.[1-9][0-9][0-9]|304.[1-9][2-9][0-9]|$DISTRO_NVIDIA)
  1857. # trigger installer flag if needed
  1858. driver_version_hacks "$DRIVER_DEFAULT"
  1859. ;;
  1860. *) # use 225 for beta testing errors
  1861. if [ "$B_TESTING_3" != 'true' ];then
  1862. error_handler 234 $KERNEL_NUMBER
  1863. fi
  1864. ;;
  1865. esac
  1866. ;;
  1867. esac
  1868. # end KERNEL_MATH
  1869. ;;
  1870. 4)
  1871. case $KERNEL_MATH in
  1872. 0)
  1873. case $DRIVER_DEFAULT in
  1874. 358.*|355.*|352.*|349.*|346.*|340.[7-9][0-9]|340.[1-9][0-9][0-9]|304.[1-9][2-9][0-9]|$DISTRO_NVIDIA)
  1875. : # do nothing
  1876. ;;
  1877. *) # use 225 for beta testing errors
  1878. if [ "$B_TESTING_3" != 'true' ];then
  1879. error_handler 234 $KERNEL_NUMBER
  1880. fi
  1881. ;;
  1882. esac
  1883. ;;
  1884. 1) # reports build failure with 340.46 AND 340.93 but some work with 340.93
  1885. case $DRIVER_DEFAULT in
  1886. 358.*|355.*|352.*|340.93|340.[1-9][0-9][0-9]|304.12[89]|304.1[3-9][0-9]|$DISTRO_NVIDIA)
  1887. : # do nothing
  1888. ;;
  1889. *) # use 225 for beta testing errors
  1890. if [ "$B_TESTING_3" != 'true' ];then
  1891. error_handler 234 $KERNEL_NUMBER
  1892. fi
  1893. ;;
  1894. esac
  1895. ;;
  1896. 2) # reports build failure with 340.46 AND 340.93
  1897. case $DRIVER_DEFAULT in
  1898. 358.*|355.*|352.*|340.93|340.[1-9][0-9][0-9]|304.12[89]|304.1[3-9][0-9]|$DISTRO_NVIDIA)
  1899. : # do nothing
  1900. ;;
  1901. *) # use 225 for beta testing errors
  1902. if [ "$B_TESTING_3" != 'true' ];then
  1903. error_handler 234 $KERNEL_NUMBER
  1904. fi
  1905. ;;
  1906. esac
  1907. ;;
  1908. 3) # reports build failure with 340.46
  1909. case $DRIVER_DEFAULT in
  1910. 358.*|355.*|352.*|340.[1-9][0-9][0-9]|304.12[89]|304.1[3-9][0-9]|$DISTRO_NVIDIA)
  1911. : # do nothing
  1912. ;;
  1913. *) # use 225 for beta testing errors
  1914. if [ "$B_TESTING_3" != 'true' ];then
  1915. error_handler 234 $KERNEL_NUMBER
  1916. fi
  1917. ;;
  1918. esac
  1919. ;;
  1920. 4) # reports build failure with 340.46
  1921. case $DRIVER_DEFAULT in
  1922. 358.*|355.*|340.[1-9][0-9][0-9]|$DISTRO_NVIDIA)
  1923. : # do nothing
  1924. ;;
  1925. *) # use 225 for beta testing errors
  1926. if [ "$B_TESTING_3" != 'true' ];then
  1927. error_handler 234 $KERNEL_NUMBER
  1928. fi
  1929. ;;
  1930. esac
  1931. ;;
  1932. esac
  1933. # end KERNEL_MATH
  1934. ;;
  1935. esac
  1936. # fi
  1937. ;;
  1938. esac
  1939. ;;
  1940. nvidia-supported-driver)
  1941. :
  1942. ;;
  1943. ati-supported-driver)
  1944. :
  1945. ;;
  1946. esac
  1947. eval $LOGUE
  1948. }
  1949.  
  1950. # these patch calls used to be in lib files but this is cleaner/simpler long term
  1951. # args: $1 - [optional] standard (implied)/test
  1952. check_patch_driver()
  1953. {
  1954. eval $LOGPS
  1955. local patchFile=''
  1956.  
  1957. case $CARD in
  1958. $NVIDIA)
  1959. case $KERNEL_BASE in
  1960. 2.6)
  1961. case $KERNEL_MATH in
  1962. 28)
  1963. case $DRIVER_DEFAULT in
  1964. 177.80)
  1965. # post 21:http://www.nvnews.net/vbulletin/showthread.php?t=121790
  1966. patchFile='NVIDIA_2.6.28-177.80-2990799.diff'
  1967. apply_patch_file $patchFile "$1"
  1968. ;;
  1969. 177.82)
  1970. # post 44: http://www.nvnews.net/vbulletin/showthread.php?t=121790&page=2
  1971. patchFile='NVIDIA_2.6.28-177.82.diff'
  1972. apply_patch_file $patchFile "$1"
  1973. ;;
  1974. esac
  1975. ;;
  1976. 30)
  1977. case $DRIVER_DEFAULT in
  1978. 71.86.09)
  1979. # post 1: http://www.nvnews.net/vbulletin/showthread.php?t=133990
  1980. # alt: http://www.nvnews.net/vbulletin/showthread.php?p=1984486
  1981. patchFile='NVIDIA_96.43.11-2.6.30.diff'
  1982. apply_patch_file $patchFile "$1"
  1983. ;;
  1984. 185.18.*)
  1985. #http://www.nvnews.net/vbulletin/showthread.php?t=133112
  1986. patchFile='NVIDIA-185.18.14-2.6.30.diff'
  1987. apply_patch_file $patchFile "$1"
  1988. ;;
  1989. esac
  1990. ;;
  1991. 31)
  1992. case $DRIVER_DEFAULT in
  1993. 185.18.*)
  1994. #http://www.nvnews.net/vbulletin/showthread.php?t=133112
  1995. patchFile='NVIDIA-185.18.14-2.6.30.diff'
  1996. apply_patch_file $patchFile "$1"
  1997. ;;
  1998. esac
  1999. ;;
  2000. 32|33)
  2001. # test if the /generated directory exists, if it does, then use patch.
  2002. if [ -n "$( misc_fixes linux-generated-patch )" -o "$B_TESTING_4" == 'true' ];then
  2003. case $DRIVER_DEFAULT in
  2004. # this is fixed in newest beta, it does auto testing for /generated/
  2005. 195.30)
  2006. # http://www.nvnews.net/vbulletin/showthread.php?t=142794&page=2#20
  2007. patchFile='NVIDIA-195-2.6.33.diff'
  2008. apply_patch_file $patchFile "$1"
  2009. ;;
  2010. 190.53) # won't be needed for new version, it will be fixed
  2011. # http://www.nvnews.net/vbulletin/showthread.php?t=142794&page=2#20
  2012. patchFile='NVIDIA-190.53-2.6.33.diff'
  2013. apply_patch_file $patchFile "$1"
  2014. ;;
  2015. esac
  2016. fi
  2017. ;;
  2018. esac
  2019. ;;
  2020. 3)
  2021. case $KERNEL_MATH in
  2022. 7)
  2023. case $DRIVER_DEFAULT in
  2024. # patch from kmathern: http://techpatterns.com/forums/about2234-10.html
  2025. # current live patch: https://447566.bugs.gentoo.org/attachment.cgi?id=336106
  2026. 173.14.36)
  2027. run_prepatch_fixes '3.7-path-fix'
  2028. # patchFile='NVIDIA_173.14.36_3.7.patch'
  2029. patchFile='NVIDIA_173.14.36_3.7.patch'
  2030. apply_patch_file $patchFile "$1"
  2031. ;;
  2032. #patch url: http://www.lwfinger.com/nvidia_patches/patch_nvidia_304_60.run_for_3.7
  2033. # current patch: https://447566.bugs.gentoo.org/attachment.cgi?id=338262
  2034. 304.6[04])
  2035. run_prepatch_fixes '3.7-path-fix'
  2036. patchFile='NVIDIA_304_60_3.7.patch'
  2037. apply_patch_file $patchFile "$1"
  2038. ;;
  2039. # requires patch to run on kernels > 3.7.5 but 313.18 patch does not work
  2040. 310.*)
  2041. run_prepatch_fixes '3.7-path-fix'
  2042. #patchFile='NVIDIA-uapi-313.18_kernel-3.7-8.patch'
  2043. # apply_patch_file $patchFile
  2044. ;;
  2045. # patch url: https://bugs.gentoo.org/show_bug.cgi?id=447566
  2046. 313.18)
  2047. run_prepatch_fixes '3.7-path-fix'
  2048. # patchFile='NVIDIA-uapi-310-313_kernel-3.7.patch'
  2049. patchFile='NVIDIA_313.18-3.8.patch' "$1"
  2050. apply_patch_file $patchFile
  2051. ;;
  2052. esac
  2053. ;;
  2054. 8)
  2055. case $DRIVER_DEFAULT in
  2056. # patch from kmathern: http://techpatterns.com/forums/about2234-10.html
  2057. # current live patch: https://447566.bugs.gentoo.org/attachment.cgi?id=336106
  2058. 173.14.36)
  2059. run_prepatch_fixes '3.7-path-fix'
  2060. # patchFile='NVIDIA_173.14.36_3.7.patch'
  2061. patchFile='NVIDIA-173.14.36-3.8.patch'
  2062. apply_patch_file $patchFile "$1"
  2063. ;;
  2064. #patch url: http://www.lwfinger.com/nvidia_patches/patch_nvidia_304_60.run_for_3.7
  2065. # current patch: https://447566.bugs.gentoo.org/attachment.cgi?id=338262
  2066. 304.6[04])
  2067. run_prepatch_fixes '3.7-path-fix'
  2068. patchFile='NVIDIA_304.64-3.8.patch'
  2069. apply_patch_file $patchFile "$1"
  2070. ;;
  2071. # patch url: https://bugs.gentoo.org/show_bug.cgi?id=447566
  2072. 313.18)
  2073. run_prepatch_fixes '3.7-path-fix'
  2074. patchFile='NVIDIA_313.18-3.8.patch'
  2075. apply_patch_file $patchFile "$1"
  2076. ;;
  2077. esac
  2078. ;;
  2079. 10)
  2080. case $DRIVER_DEFAULT in
  2081. # patch from kmathern:
  2082. # current live patch: http://techpatterns.com/forums/about2308.html
  2083. 173.14.37)
  2084. #run_prepatch_fixes '3.7-path-fix'
  2085. # patchFile='NVIDIA_173.14.36_3.7.patch'
  2086. patchFile='NVIDIA-173.14.37-3.10.patch'
  2087. apply_patch_file $patchFile "$1"
  2088. ;;
  2089. #patch url: https://devtalk.nvidia.com/default/topic/549532/linux-3-10-incompatibility-in-function-lsquo-nv_i2c_del_adapter-rsquo-error-void-value-not-igno/
  2090. # rjmx post 13
  2091. 304.88)
  2092. #run_prepatch_fixes '3.7-path-fix'
  2093. patchFile='NVIDIA-304.88-3.10.patch'
  2094. apply_patch_file $patchFile "$1"
  2095. ;;
  2096. #patch url: https://bugzilla.kernel.org/attachment.cgi?id=102881
  2097. 319.32)
  2098. #run_prepatch_fixes '3.7-path-fix'
  2099. patchFile='NVIDIA-319.32-3.10.patch'
  2100. apply_patch_file $patchFile "$1"
  2101. ;;
  2102. # patch url: https://devtalk.nvidia.com/cmd/default/download-comment-attachment/58795/
  2103. 325.08)
  2104. #run_prepatch_fixes '3.7-path-fix'
  2105. patchFile='NVIDIA-325.08-3.10.patch'
  2106. apply_patch_file $patchFile "$1"
  2107. ;;
  2108. esac
  2109. ;;
  2110. 11|12)
  2111. case $DRIVER_DEFAULT in
  2112. # old patch url: https://devtalk.nvidia.com/default/topic/616962/331-13-beta-drivers-feedback-thread/?offset=15
  2113. # old patch: NVIDIA-331.13-3.11.patch
  2114. ## new patch url: https://devtalk.nvidia.com/default/topic/628864/unix-graphics-announcements-and-news/num_physpages-and-support-for-3-11-and-later-kernels
  2115. 331.13|331.17|325.15)
  2116. patchFile='NVIDIA-3.11-get_num_physpages_325-331.patch'
  2117. apply_patch_file $patchFile "$1"
  2118. ;;
  2119. # patch url: http://cvs.rpmfusion.org/viewvc/*checkout*/rpms/nvidia-kmod/devel/kernel_v3.11.patch?revision=1.2&root=nonfree
  2120. # https://devtalk.nvidia.com/default/topic/602829/-solved-nvidia-linux-3-11-compatibility-error-lsquo-num_physpages-rsquo-undeclared-first-use-i/
  2121. # old patch: NVIDIA_325.19-3.11.patch
  2122. 319.60|319.49)
  2123. #run_prepatch_fixes '3.7-path-fix'
  2124. patchFile='NVIDIA-3.11-get_num_physpages_319.patch'
  2125. apply_patch_file $patchFile "$1"
  2126. ;;
  2127. 304.108)
  2128. #run_prepatch_fixes '3.7-path-fix'
  2129. # old patch: NVIDIA_304.108-3.11.patch
  2130. patchFile='NVIDIA-3.11-get_num_physpages_304.patch'
  2131. apply_patch_file $patchFile "$1"
  2132. ;;
  2133. esac
  2134. ;;
  2135. 13)
  2136. case $DRIVER_DEFAULT in
  2137. ## patch url: https://devtalk.nvidia.com/default/topic/686157/linux/334-16-won-t-compile-for-linux-v3-13-patch-included-/2/
  2138. 334.16)
  2139. patchFile='NVIDIA-334.16-3.0-3.14.patch'
  2140. apply_patch_file $patchFile "$1"
  2141. ;;
  2142. ## patch url: http://cvs.rpmfusion.org/viewvc/rpms/nvidia-kmod/devel/nvidia_3.13_kernel.patch?revision=1.3&root=nonfree&view=markup
  2143. 331.38)
  2144. patchFile='NVIDIA-331.38-3.13.patch'
  2145. apply_patch_file $patchFile "$1"
  2146. ;;
  2147. 304.119)
  2148. patchFile='NVIDIA-304.119-3.13.patch'
  2149. apply_patch_file $patchFile "$1"
  2150. ;;
  2151. esac
  2152. ;;
  2153. 14)
  2154. case $DRIVER_DEFAULT in
  2155. # patch url: https://devtalk.nvidia.com/default/topic/699422/nvidia-linux-334-21-drivers/?offset=4
  2156. 334.21|331.49)
  2157. patchFile='NVIDIA-334.21-3.14.patch'
  2158. apply_patch_file $patchFile "$1"
  2159. ;;
  2160. ## patch url: https://devtalk.nvidia.com/default/topic/686157/linux/334-16-won-t-compile-for-linux-v3-13-patch-included-/2/
  2161. 334.16)
  2162. patchFile='NVIDIA-334.16-3.0-3.14.patch'
  2163. apply_patch_file $patchFile "$1"
  2164. ;;
  2165. ## patch url: http://cvs.rpmfusion.org/viewvc/rpms/nvidia-kmod/devel/nvidia_3.13_kernel.patch?revision=1.3&root=nonfree&view=markup
  2166. 331.38)
  2167. patchFile='NVIDIA-331.38-3.13.patch'
  2168. apply_patch_file $patchFile "$1"
  2169. ;;
  2170. 304.119)
  2171. patchFile='NVIDIA-304.119-3.13.patch'
  2172. apply_patch_file $patchFile "$1"
  2173. ;;
  2174. esac
  2175. ;;
  2176. 15)
  2177. case $DRIVER_DEFAULT in
  2178. # patch url: https://devtalk.nvidia.com/default/topic/699422/nvidia-linux-334-21-drivers/?offset=4
  2179. 334.21|331.49)
  2180. patchFile='NVIDIA-334.21-3.14.patch'
  2181. apply_patch_file $patchFile "$1"
  2182. ;;
  2183. 304.119)
  2184. patchFile='NVIDIA-304.119-3.13.patch'
  2185. apply_patch_file $patchFile "$1"
  2186. ;;
  2187. esac
  2188. ;;
  2189. esac
  2190. ;;
  2191. esac
  2192. ;;
  2193. $FGLRX)
  2194. case $KERNEL_BASE in
  2195. 2.6)
  2196. case $KERNEL_MATH in
  2197. 25|26)
  2198. case $DRIVER_DEFAULT in
  2199. # 8-4|8-5)
  2200. # # debian kernls work normally, no patch required
  2201. # # note: due to concerns raised, this patch is not going to be used
  2202. # if [ "$B_IS_APTOSID_KERNEL" == 'true' ]
  2203. # then
  2204. # # pre patch link required, just to keep the information for future reference:
  2205. # ln -s arch/x86/usr/X11R6/lib/libfglrx_gamma.so.1.0 arch/x86/usr/X11R6/lib/libfglrx_gamma.so.1
  2206. # ln -s arch/x86_64/usr/X11R6/lib64/libfglrx_gamma.so.1.0 arch/x86_64/usr/X11R6/lib64/libfglrx_gamma.so.1
  2207. # patchFile=''
  2208. # #apply_patch_file $patchFile
  2209. # fi
  2210. # ;;
  2211. 8-6)
  2212. patchFile='0001-catalyst-8.6-linux-2.6.26.patch'
  2213. apply_patch_file $patchFile "$1"
  2214. patchFile='0002-catalyst-8.6-linux-2.6.26.patch'
  2215. apply_patch_file $patchFile "$1"
  2216. patchFile='0003-catalyst-8.6-linux-2.6.26.patch'
  2217. apply_patch_file $patchFile "$1"
  2218. ;;
  2219. 8-7)
  2220. # patch url: http://bugs.gentoo.org/attachment.cgi?id=161335
  2221. # found at: http://bugs.gentoo.org/show_bug.cgi?id=232609
  2222. patchFile='FGLRX-8.7-2.6.26.patch'
  2223. # this one is crap, bad hunks
  2224. #patchFile='FGLRX-0004-Linux-2.6.26.x-kernels-support.patch'
  2225. apply_patch_file $patchFile "$1"
  2226. ;;
  2227. esac
  2228. ;;
  2229. 29)
  2230. case $DRIVER_DEFAULT in
  2231. 9.2|9-3|9-4|9-5|9-6|9-7)
  2232. # src: http://www.phoronix.com/forums/showthread.php?t=15165
  2233. patchFile='FGLRX-2.6.29-9.2-5.diff'
  2234. apply_patch_file $patchFile "$1"
  2235. :
  2236. ;;
  2237. esac
  2238. ;;
  2239. 30)
  2240. case $DRIVER_DEFAULT in
  2241. 9-6)
  2242. if [ "$B_TESTING_3" == 'true' ];then
  2243. patchFile='FGLRX-2.6.30-9-6.diff'
  2244. apply_patch_file $patchFile "$1"
  2245. fi
  2246. ;;
  2247. esac
  2248. ;;
  2249. 32)
  2250. case $DRIVER_DEFAULT in
  2251. 9-11|9-12)
  2252. patchFile='FGLRX-2.6.32-9-11.diff'
  2253. apply_patch_file $patchFile "$1"
  2254. ;;
  2255. esac
  2256. ;;
  2257. 33)
  2258. # these handle that /generated/ path change in kernel headers
  2259. # test if the /generated directory exists, if it does, then use patch.
  2260. if [ -n "$( misc_fixes linux-generated-patch )" -o "$B_TESTING_4" == 'true' ];then
  2261. case $DRIVER_DEFAULT in
  2262. 10-2)
  2263. patchFile='FGLRX-2.6.33-10-2.diff'
  2264. apply_patch_file $patchFile "$1"
  2265. ;;
  2266. 10-[3-5])
  2267. patchFile='FGLRX-2.6.33-10-x.diff'
  2268. apply_patch_file $patchFile "$1"
  2269. ;;
  2270. esac
  2271. fi
  2272. ;;
  2273. 34)
  2274. # these handle that /generated/ path change in kernel headers
  2275. # test if the /generated directory exists, if it does, then use patch.
  2276. if [ -n "$( misc_fixes linux-generated-patch )" -o "$B_TESTING_4" == 'true' ];then
  2277. case $DRIVER_DEFAULT in
  2278. 10-[4-5])
  2279. patchFile='FGLRX-2.6.33-10-x.diff'
  2280. apply_patch_file $patchFile "$1"
  2281. patchFile='FGLRX-2.6.34-rc4-10-4.diff'
  2282. apply_patch_file $patchFile "$1"
  2283. ;;
  2284. 10-[6])
  2285. # patchFile='FGLRX-2.6.33-10-x.diff' # fails
  2286. # apply_patch_file $patchFile
  2287. patchFile='FGLRX-2.6.34-rc4-10-4.diff' # works
  2288. apply_patch_file $patchFile "$1"
  2289. ;;
  2290. esac
  2291. fi
  2292. ;;
  2293. 36|37)
  2294. case $DRIVER_DEFAULT in
  2295. 10-1[0-2]) # run this for -11 too maybe it will work
  2296. patchFile='FGLRX-2.6.36-10-10.diff'
  2297. apply_patch_file $patchFile "$1"
  2298. patchFile='FGLRX-2.6.36-10-10-makefile-compat.diff'
  2299. apply_patch_file $patchFile "$1"
  2300. ;;
  2301. esac
  2302. ;;
  2303. esac
  2304. ;;
  2305. 3)
  2306. case $KERNEL_MATH in
  2307. 7|8)
  2308. case $DRIVER_DEFAULT in
  2309. #patch url: http://catalyst.apocalypsus.net/files/arch-fglrx-3.7.patch
  2310. 12.10|13.1)
  2311. run_prepatch_fixes '3.7-path-fix'
  2312. patchFile='FGLRX-12.10-3.7.patch'
  2313. apply_patch_file $patchFile "$1"
  2314. ;;
  2315. esac
  2316. :
  2317. ;;
  2318. 10)
  2319. case $DRIVER_DEFAULT in
  2320. #patch url: http://catalyst.apocalypsus.net/files/arch-fglrx-3.7.patch
  2321. 13.9)
  2322. # run_prepatch_fixes '3.7-path-fix'
  2323. patchFile='FGLRX_13.9-3.10.patch'
  2324. apply_patch_file $patchFile "$1"
  2325. ;;
  2326. esac
  2327. ;;
  2328. 11)
  2329. case $DRIVER_DEFAULT in
  2330. #patch url: http://catalyst.apocalypsus.net/files/arch-fglrx-3.7.patch
  2331. 13.9)
  2332. # run_prepatch_fixes '3.7-path-fix'
  2333. patchFile='FGLRX_13.9-3.10.patch'
  2334. apply_patch_file $patchFile "$1"
  2335. ;;
  2336. # patch url: http://phoronix.com/forums/showthread.php?91885-AMD-Catalyst-13-12-GPU-Driver-For-Linux-Released&p=381943#post381943
  2337. 13.12)
  2338. patchFile='FGLRX_13.12-3.11-3.13.patch'
  2339. apply_patch_file $patchFile "$1"
  2340. ;;
  2341. esac
  2342. ;;
  2343. 12|13)
  2344. case $DRIVER_DEFAULT in
  2345. # patch url: http://phoronix.com/forums/showthread.php?91885-AMD-Catalyst-13-12-GPU-Driver-For-Linux-Released&p=381943#post381943
  2346. 13.12)
  2347. patchFile='FGLRX_13.12-3.11-3.13.patch'
  2348. apply_patch_file $patchFile "$1"
  2349. ;;
  2350. esac
  2351. ;;
  2352. 1[4-9])
  2353. case $DRIVER_DEFAULT in
  2354. # patch url: http://www.forums.fedoraforum.org/showpost.php?p=1696887&postcount=117
  2355. 14.[45].*|14.7.1)
  2356. patchFile='FGLRX-14.5-3.14.patch'
  2357. apply_patch_file $patchFile "$1"
  2358. ;;
  2359. esac
  2360. ;;
  2361. esac
  2362. ;;
  2363. esac
  2364. ;;
  2365. esac
  2366.  
  2367. # this is for dev testing of patches or fixes
  2368. if [ "$B_TESTING_4" == 'true' ];then
  2369. : # doing nothing for now
  2370. fi
  2371. eval $LOGPE
  2372. }
  2373.  
  2374. # ln -s /usr/src/linux/include/generated/uapi/linux/version.h /usr/src/linux/include/linux/version.h
  2375. # arg: $1 - which fix to run
  2376. run_prepatch_fixes()
  2377. {
  2378. eval $LOGPS
  2379. local path1='' path2='' file1='' file2='' outcome=''
  2380.  
  2381. # assume that distro drivers have the fixes done
  2382. if [ "$B_USE_DISTRO_DRIVER" != 'true' ];then
  2383. case $1 in
  2384. 3.7-path-fix)
  2385. file1='version.h'
  2386. path1="/usr/src/linux-headers-$KERNEL_FULL/include/generated/uapi/linux/$file1"
  2387. path2="/usr/src/linux-headers-$KERNEL_FULL/include/linux/"
  2388. echo "${S}Running pre-install patch for kernel header ${C}uapi${S} path tweak...${N}"
  2389. if [ -e $path1 ];then
  2390. if [ -d $path2 ];then
  2391. if [ ! -e $path2$file1 ];then
  2392. ln -s $path1 $path2$file1
  2393. outcome="${S}Link created here: ${C}$path2$file1${N}"
  2394. else
  2395. outcome="${S}Target file exists: ${C}$path2$file1${S}${N}"
  2396. fi
  2397. else
  2398. outcome="${E}Target directory ${C}$path2${E} not found.\nUnable to patch for ${C}uapi${E}!!${N}"
  2399. fi
  2400. else
  2401. outcome="${E}Path ${C}$path1${E} not found.\nDriver install may fail!!${N}"
  2402. fi
  2403. log_function_data "$outcome"
  2404. echo -e "$outcome"
  2405. ;;
  2406. esac
  2407. fi
  2408. eval $LOGPE
  2409. }
  2410.  
  2411. # not used currently
  2412. # arg: $1 - pre/post
  2413. run_patch_fixes()
  2414. {
  2415. eval $LOGPS
  2416. local lmkv="/lib/modules/$KERNEL_FULL"
  2417.  
  2418. # the debian sid nvidia drivers are now working fine with xen enabled sid kernels
  2419. if [ "$B_USE_DISTRO_DRIVER" != 'true' ] && [ -d "$lmkv" -a "$B_IS_XEN" == 'true' ];then
  2420. # patch source: http://blog.creonfx.com/linux/how-to-install-nvidia-driver-on-2625-2-debian-kernel-with-xen
  2421. cd $lmkv
  2422. case $1 in
  2423. pre)
  2424. echo "${S}Running pre-install module patches (this might take a while)...${N}"
  2425. grep 'CONFIG_XEN' . -Rl 2> /dev/null | xargs -i sed -i -e 's/CONFIG_XEN/CONFIG_LUPO/g' {}
  2426. export IGNORE_XEN_PRESENCE=1
  2427. ;;
  2428. post)
  2429. echo "${S}Reverting pre-install module patches (this might take a while)...${N}"
  2430. grep 'CONFIG_LUPO' . -Rl 2> /dev/null | xargs -i sed -i -e 's/CONFIG_LUPO/CONFIG_XEN/g' {}
  2431. ;;
  2432. esac
  2433. cd $SCRIPT_WORKING_DIR/$INSTALL_DIRECTORY
  2434. fi
  2435. eval $LOGPE
  2436. }
  2437.  
  2438. ### -------------------------------------------------------------------
  2439. ### primary startup - colors
  2440. ### -------------------------------------------------------------------
  2441.  
  2442. # set global color variables
  2443. # options: 0 - turns off all colors; 1 - defaults
  2444. set_script_colors()
  2445. {
  2446. # set colors
  2447. case $SCRIPT_COLORS in
  2448. 0)
  2449. W='' # red: Warning message
  2450. E='' # yellow: script Error
  2451. S='' # green: Standard message
  2452. Q='' # CYAN: Questions
  2453. M='' # CYAN: Message
  2454. B='' # BLUE: Message
  2455. C='' # MAGENTA: Command or Path
  2456. N='' # default system console color: Normal :: make last in colors
  2457. ;;
  2458. 1)
  2459. W="" # red: Warning message
  2460. E="" # yellow: script Error
  2461. S="" # green: Standard message
  2462. Q="" # CYAN: Questions
  2463. M="" # CYAN: Message
  2464. B="" # BLUE: Message
  2465. C="" # MAGENTA: Command or Path
  2466. N="" # default system console color: Normal :: make last in colors
  2467. ;;
  2468. 2)
  2469. W="" # red: Warning message
  2470. E="" # yellow: script Error
  2471. S="" # Standard message
  2472. Q="" # CYAN: Questions
  2473. M="" # CYAN: Message
  2474. B="" # BLUE: Message
  2475. C="" # MAGENTA: Command or Path
  2476. N="" # default system console color: Normal :: make last in colors
  2477. ;;
  2478. 3)
  2479. W="" # red: Warning message
  2480. E="" # magenta: script Error
  2481. S="" # brown
  2482. Q="" # light blue: Questions
  2483. M="" # cyan: Message
  2484. B="" # brown: Message
  2485. C="" # green: Command or Path
  2486. N="" # default system console color: Normal :: make last in colors
  2487. ;;
  2488. 4)
  2489. W="" # red: Warning message
  2490. E="" # brown: script Error
  2491. S="" # blue: Standard message
  2492. Q="" # dark gray: Questions
  2493. M="" # dark gray: Message
  2494. B="" # blue: Message
  2495. C="" # purple: Command or Path
  2496. N="" # default system console color: Normal :: make last in colors
  2497. ;;
  2498. esac
  2499.  
  2500. CALLER_DEF=${S} # will switch default output color to the calling script's
  2501. S=${B} # this is slightly tricky, making standard blue AFTER the caller def is set.
  2502. PLINE='- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -'
  2503. LINE="${S}$PLINE${N}"
  2504. ELINE="${E}$PLINE${N}"
  2505. MLINE="${M}$PLINE${N}"
  2506. WLINE="${W}$PLINE${N}"
  2507. }
  2508.  
  2509. ### -------------------------------------------------------------------
  2510. ### Error handling
  2511. ### -------------------------------------------------------------------
  2512. # args: $1 - error number; $2 error extra data, optional
  2513. error_handler()
  2514. {
  2515. local errorCode=$1 # error number
  2516. local errorExtra=$2 # this is secondary info, like failed package name
  2517. local errorData='' errorData2=''
  2518. local ErrorMessage=''
  2519.  
  2520. case $errorCode in
  2521. # general system checks
  2522. 254)
  2523. errorData="No supported $CARD card found!"
  2524. ;;
  2525. 253)
  2526. errorData="No supported $CARD card found!\nYou can use this script to install the native Xorg drivers: $SCRIPT_NAME -n"
  2527. ;;
  2528. 252)
  2529. errorData="This does not appear to be a Debian/Ubuntu/Arch based system! If you know that it is\nand received this error, please let the maintainer know and he'll try to correct the\ndistro identification failure. Post on the script forums: http://techpatterns.com/forums/forum-33.html\nwith your system information, including the contents of these files, if present:\n/etc/issue\n/etc/debian_version\n/etc/lsb-release"
  2530. ;;
  2531. 251)
  2532. errorData="You must be logged in as root to run this script."
  2533. ;;
  2534. 250)
  2535. errorData="You must be out of X/Desktop (like KDE, Gnome, Flux, LXDE etc) to run this feature."
  2536. ;;
  2537. 249)
  2538. errorData="Your system does not have the correct version of X, $EXXC"
  2539. ;;
  2540. 248)
  2541. errorData="Sorry, Ubuntu isn't supported by this script"
  2542. ;;
  2543. 247)
  2544. errorData="You can't use the composite option with this driver: $DRIVER_DEFAULT"
  2545. ;;
  2546. 246)
  2547. errorData="The driver: $DRIVER_DEFAULT is not currently supported for kernel version $KERNEL_NUMBER"
  2548. ;;
  2549. 245)
  2550. errorData2=''
  2551. if [ "$CARD" == "$FGLRX" -a "$B_FGLRX_DIRECT" != 'true' ];then
  2552. errorData2="\nYou might want to try installing without the -D (formerly -F) option instead, which will do a\ndirect (no debs) binary install from the FGLRX run package.\nThis works more reliably for some systems (especially 64 bit)."
  2553. fi
  2554. errorData="The $CARD installer exited with the error: $errorExtra$errorData2\nA copy of this driver installer error log is also here: $LOG_FILE"
  2555. ;;
  2556. 244)
  2557. errorData="Xorg does not appear to be installed."
  2558. ;;
  2559. 243)
  2560. errorData="Your kernel type $KERNEL_BASE is not supported for these drivers."
  2561. ;;
  2562. 242)
  2563. errorData="This script requires X.org 7.1 or greater to be installed on your system."
  2564. ;;
  2565. 241)
  2566. errorData="This script does not support the $CARD driver: $errorExtra\nPlease make sure to enter a supported driver when using the -o option."
  2567. ;;
  2568. 240)
  2569. errorData="This script does not support the $CARD driver: $errorExtra"
  2570. ;;
  2571. 239)
  2572. errorData="This script does not support installing $CARD drivers in livemode."
  2573. ;;
  2574. 238)
  2575. errorData="There does not appear to be a live connection, or $SCRIPT_NAME script server is down.\nIf you are sure you have a connection, restart script with -Z option to cancel connection test."
  2576. ;;
  2577. 237)
  2578. errorData="The native xorg driver you selected: $errorExtra is not supported."
  2579. ;;
  2580. 236)
  2581. errorData="An ATI $CARD error makes them not support your Xorg version $errorExtra\n If you are using less than R500 type card, you can install native radeon drivers with this script.\nUse this syntax to install those and reconfigure xorg.conf: $SCRIPT_NAME -N radeon"
  2582. ;;
  2583. 235)
  2584. errorData="The driver $DRIVER_DEFAULT requires the 2.6.$errorExtra kernel to run.\nYou are running the $KERNEL_NUMBER kernel. Please update your kernel now."
  2585. ;;
  2586. 234)
  2587. errorData="The driver $DRIVER_DEFAULT does not support the $errorExtra kernel.\nYou are running the $KERNEL_FULL kernel. Unable to install your $DRIVER_DEFAULT driver.\nYou can override this test with -! 6 option. If install works, let maintainer know."
  2588. ;;
  2589. 233) errorData="Creating the fix: $errorExtra for your $DRIVER_DEFAULT and kernel $KERNEL_FULL failed."
  2590. ;;
  2591. 232)
  2592. errorData="The kernel for -K option: $errorExtra does not appear to be installed in your system."
  2593. ;;
  2594. 231)
  2595. errorData="The file: $errorExtra appears to be corrupted. Please try to update again."
  2596. ;;
  2597. 230)
  2598. errorData="Could not detect gcc version: $errorExtra, or it is not installed.\nPlease let the script maintainer know, this may be a bug in the script."
  2599. ;;
  2600. 229)
  2601. errorData="The driver: $DRIVER_DEFAULT does not work on aptosid/sidux kernels.\nYou are trying to install it to this kernel: $KERNEL_FULL\nCurrently $FGLRX only works on new non-aptosid kernels."
  2602. ;;
  2603. 228)
  2604. errorData="The option you selected: $errorExtra is not supported."
  2605. ;;
  2606. 227)
  2607. errorData="The newest $CARD drivers ( >= 177.167 ) no longer support your $CARD GeForce 5xxx card.\nYou must use the $NV_LEGACY_3 driver or lower.\nThat is the default driver when you run this script."
  2608. ;;
  2609. 226)
  2610. errorData="The driver you selected: $DRIVER_DEFAULT does not support your current Xorg version: $X_VERSION\nIf this is wrong, please let the script maintainer know.\nYou can override this test with -! 6 option. If install works, let maintainer know."
  2611. ;;
  2612. # this is only for nvidia latest kernel + beta errors
  2613. 225)
  2614. errorData="The driver $DRIVER_DEFAULT does not support the 2.6.$errorExtra kernel.\nYou are installing the driver to kernel: $KERNEL_FULL\nPlease try the beta driver instead. Use this command to install beta drivers\nto either non-current kernel: $SCRIPT_NAME -cB -K $KERNEL_FULL\nor to current kernel: $SCRIPT_NAME -cB"
  2615. ;;
  2616. 224)
  2617. errorData="Your system is missing the required kernel header package: $errorExtra\n and it is not currently available in your repos. Cannot continue.\nPlease either update your kernel and kernel headers,\nor find and install kernel headers for $KERNEL_FULL\nYou can override this test with -! 6 option. If install works, let maintainer know."
  2618. ;;
  2619. 223)
  2620. errorData="The install of the missing deb from your $SM_KERNEL_DOWNLOADS directory:\n$extraData\nhas failed for unknown reasons. Sorry, we did our best."
  2621. ;;
  2622. 222)
  2623. errorData="The Xorg driver $extraData you are trying to install is not available\nfor your version of $DISTRIB_ID: $DISTRIB_CODENAME"
  2624. ;;
  2625. 221)
  2626. errorData="AMD/ATI had dropped fglrx non-free driver support for your card type as of driver release 9-4\nOnly cards x2000 or newer are now supported by AMD/ATI for this driver.\nIf you know your card is supported, please let the $SCRIPT_NAME maintainer know.\nYou can override this test with -! 6 option. If install works, let maintainer know."
  2627. ;;
  2628. 220)
  2629. errorData="The Driver you are trying to install does not work with libdrm2 version 2.4.x less than 2.4.11.\nYour installed version of libdrm2 is: $errorExtra\n\nIf you are using Debian Sid, you must upgrade your libdrm2 to 2.4.11 or greater."
  2630. ;;
  2631. 219)
  2632. errorData="Fglrx direct driver install method does not allow you to install the\ndriver to another kernel, using the -K option, sorry. You must be booted into\nthe kernel you are installing the driver to for this driver method to work."
  2633. ;;
  2634. 218)
  2635. errorData="Something went wrong in the creation of your new $EXXC file\nPlease let the script maintainer know."
  2636. ;;
  2637. 217)
  2638. errorData="No supported $CARD card found for the distro driver (-d - formerly -s) installer option!\nYou can use this script to install the native Xorg drivers: $SCRIPT_NAME -n"
  2639. ;;
  2640. 216)
  2641. errorData="You are using Ubuntu but you do not appear to have the 'restricted' repos enabled.\nPlease enable them before continuing, thank you."
  2642. ;;
  2643. 215)
  2644. errorData="Your new $EXXC is missing, or is not located where expected.\nPlease let the script maintainer know."
  2645. ;;
  2646. 214)
  2647. errorData="Cannot create your new $EXXC because X cannot be killed.\nPlease let the script maintainer know."
  2648. ;;
  2649. 213)
  2650. errorData="$SCRIPT_NAME cannot locate any /boot/grub/ config files. Unable to continue.\n$SCRIPT_NAME requires grub config files: /boot/grub/menu.lst or /boot/grub/grub.cfg\n$SCRIPT_NAME does not support lilo or unmounted /boot partitions.\nThe action: $errorExtra cannot be done without an active Grub on your system."
  2651. ;;
  2652. 212)
  2653. errorData="AMD has dropped Catalyst/FGLRX support for HD2xxx-4xxx series cards as of 12-6.\nYou should have bought Nvidia if you wanted a long term working non free driver, sorry.\nIf you know your card is supported, please let the $SCRIPT_NAME maintainer know.\nYou can override this test with -! 6 option. If install works, let maintainer know."
  2654. ;;
  2655. 211)
  2656. errorData="You cannot start $SCRIPT_NAME with sudo. Please start $SCRIPT_NAME \nproperly as root (use either 'sudo su -' (note the '-' at the end) \nto become root, or login as root directly). If 'sudo su -' does not \nwork, please let the $SCRIPT_NAME maintainer know, and if your system \nhas root locked (why would anyone do that?) then you will have to \nunlock root. \n\nSee your distro manuals or help pages to fix this issue in that \ncase, and also make sure to update any documentation or how-to's \nfor running $SCRIPT_NAME with your distro. This means you, Ubuntu/Mint users!\n\nTypical signs of sudo failures are respawnings of your desktop while \n$SCRIPT_NAME is running, or failures to create directories.\n"
  2657. ;;
  2658. # specific install issues
  2659. 200)
  2660. errorData="The package: $errorExtra failed to install, please check apt for any problems."
  2661. ;;
  2662. 199) # replaced by 231
  2663. errorData="The file: $errorExtra failed to download - wget reports success."
  2664. ;;
  2665. 198)
  2666. errorData="The url/file: $errorExtra\nfailed to download - wget error."
  2667. ;;
  2668. 197)
  2669. errorData="The graphics driver installer: $errorExtra failed to download - wget error."
  2670. ;;
  2671. 196)
  2672. errorData="The driver package: $errorExtra failed to extract and has been deleted."
  2673. ;;
  2674. 195)
  2675. errorData="dkpg -i failed for package: $errorExtra"
  2676. ;;
  2677. 194)
  2678. errorData="m-a build failed for package: $errorExtra"
  2679. ;;
  2680. 193)
  2681. errorData="m-a install failed for package: $errorExtra"
  2682. ;;
  2683. 192)
  2684. errorData="The $CARD driver uninstaller exited with this error: $errorExtra"
  2685. ;;
  2686. 191)
  2687. errorData="This script cannot proceed if you leave $errorExtra installed."
  2688. ;;
  2689. 190)
  2690. errorData="Removing package $errorExtra failed."
  2691. ;;
  2692. 189)
  2693. errorData="Downloading the experimental driver $errorExtra failed."
  2694. ;;
  2695. 188)
  2696. errorData="The experimental driver $errorExtra package is empty."
  2697. ;;
  2698. 187)
  2699. errorData="The experimental driver package $errorExtra is not available currently, sorry."
  2700. ;;
  2701. 186)
  2702. errorData="The package $errorExtra was not created. Cannot continue with install."
  2703. ;;
  2704. 185)
  2705. errorData="m-a prepare failed for package: $errorExtra"
  2706. ;;
  2707. 184)
  2708. errorData="m-a update failed for package: $errorExtra"
  2709. ;;
  2710. 183)
  2711. errorData="depmod -a failed for package: $errorExtra"
  2712. ;;
  2713. 182)
  2714. errorData="m-a clean failed for package: $errorExtra"
  2715. ;;
  2716. 181)
  2717. errorData="Patch file: $errorExtra failed to download."
  2718. ;;
  2719. 180)
  2720. errorData="wget error: Patch file: $errorExtra failed to download."
  2721. ;;
  2722. 179)
  2723. errorData="Patching error: file: $errorExtra failed."
  2724. ;;
  2725. 178)
  2726. errorData="Unsupported testing option argument: -! $errorExtra"
  2727. ;;
  2728. 177)
  2729. errorData="Used -z command but no X application is present in system."
  2730. ;;
  2731. 176)
  2732. errorData="Whoops, how did this happen? It appears you are not running a supported Distro for distro driver install."
  2733. ;;
  2734. 175)
  2735. errorData="You are using the -k (build kernel module only) option, but required file: $errorExtra\nis not found in $SCRIPT_WORKING_DIR\nNote: if your installed driver is NOT the default $SCRIPT_NAME offers, you have to\nuse either the -o <driver number> OR the -B option (if you are using current beta driver)\nplus the -! 40 option. EG: to install beta to all kernels: $SCRIPT_NAME -B -! 40"
  2736. ;;
  2737. 174)
  2738. errorData="The -k option cannot be used if you are using distribution packaged nVidia drivers."
  2739. ;;
  2740. 173)
  2741. errorData="The -k option only supports nVidia cards, sorry."
  2742. ;;
  2743. 172)
  2744. errorData="The -k option can only be used to install to the same driver that is running.\nYour system is running $errorExtra but you are building the module for: $DRIVER_DEFAULT\nYou can use the -o <driver version> option to override the defaults."
  2745. ;;
  2746. 171)
  2747. errorData="The kernel module build failed with error code: $errorExtra\nPlease check /var/log/nvidia-installer.log for more information about the failure.\nA copy of this nvidia error log is also here: $LOG_FILE\nPlease try to reinstall the driver using: sgfxi -f (force override module build)\nbecause sometimes modules cannot be built to new kernels without the source\nbeing patched first, which requires a driver reinstall."
  2748. ;;
  2749. 170)
  2750. errorData="An nvidia module already exists for $KERNEL_FULL at path:\n/lib/modules/$KERNEL_FULL/kernel/drivers/video/nvidia.ko\nYou must either remove this manually, or install a new driver with $SCRIPT_NAME.\nInstalling a driver will remove all previous modules, then you can\nrebuild them with the -! 40 option (see $SCRIPT_NAME -h for more information on that method)."
  2751. ;;
  2752. 169)
  2753. errorData="No previous $NVIDIA $SCRIPT_NAME run package install detected for -k option module build."
  2754. ;;
  2755. 168)
  2756. errorData="An Xorg update overwrote $NVIDIA run package files. You must reinstall $NVIDIA driver.\nUnable to build -k option module."
  2757. ;;
  2758. 167)
  2759. errorData="You have used the -! 33 override option but the $errorExtra module action reports as failed\n.$SCRIPT_NAME is unable to continue in this scenario.\nPlease blacklist/unblacklist your $errorExtra manually then run $SCRIPT_NAME again."
  2760. ;;
  2761. 166)
  2762. errorData="The options ($errorExtra) you used are not compatible, and create internal $SCRIPT_NAME conflicts.\nPlease correct this error and start again."
  2763. ;;
  2764. 165)
  2765. errorData="Extraction of zip file: $errorExtra failed."
  2766. ;;
  2767. 100)
  2768. errorData="The function: $errorExtra exited through user action."
  2769. ;;
  2770. *)
  2771. errorData="Unexpected Error !"
  2772. ;;
  2773. esac
  2774. ErrorMessage="ERROR: ($errorCode) $errorData"
  2775. echo -e ${E}$ErrorMessage${N}
  2776. if [ -f $LOG_FILE -a "$B_LOGGING_STARTED" == 'true' ];then
  2777. log_function_data "$ErrorMessage"
  2778. echo
  2779. echo "${S}Log file is located here: $LOG_FILE"
  2780. fi
  2781. echo "${M}Exiting script now.${N}"
  2782.  
  2783. exit $errorCode
  2784. }
  2785.  
  2786. ### -------------------------------------------------------------------
  2787. ### card type/version detections
  2788. ### -------------------------------------------------------------------
  2789.  
  2790. # this only runs if card count > 1
  2791. select_card()
  2792. {
  2793. #cardData=$(echo "00:0d.0 VGA compatible controller [0300]: nVidia Corporation GeForce 6100 nForce 405 [10de:03d1] (rev a2)
  2794. #02:00.0 VGA compatible controller [0300]: nVidia Corporation G71 [GeForce 7300 G S] [10de:01df] (rev a1)" | grep -E 'VGA' | cut -d ':' -f 3-4 | cut -d ' ' -f 2-50 | tr ' ' '-' )
  2795. #tester="00:0d.0 0300: 10de:03d1 (rev a2)
  2796. #02:00.0 0300: 10de:01df (rev a1) "
  2797. # not using: |3D[[:space:]]controller ]|Display[[:space:]]controller - may cause dual id of same device
  2798. # NOTE: we have to confirm it's a real card, we do that by checking: xx:xx.0 structure on pcibus id string.
  2799. local cardData=$( lspci -nn | \
  2800. grep -iE '(VGA compatible controller|3D controller|Display controller)' | \
  2801. grep -E '(^[^:]+:[^:\.]+[:\.]0)[[:space:]]' | \
  2802. cut -d ':' -f 3-4 | cut -d ' ' -f 2-50 | tr ' ' '-' )
  2803. local cards='' card='' singleCardId=''
  2804. local options='' opt='' bFound='false'
  2805. local timeStampXorg=$EXXC-bu-$( date +%Y-%m-%d-%H:%M:%S )
  2806.  
  2807. echo $MLINE
  2808. echo "${S}The script detected more than one video card in your system:"
  2809. echo "${C}$cardData"
  2810. echo
  2811. if [ "$B_SKIP_CONFIG" != 'true' ];then
  2812. echo "${M}If you want to preserve your current ${C}xorg.conf${M}, for example if you use dual"
  2813. echo "card setup, and your system is working fine with the driver you are installing,"
  2814. echo "please restart ${C}$SCRIPT_NAME${M} with extra ${C}-C${M} option and it will not change xorg.conf."
  2815. echo
  2816. echo "${C}$SCRIPT_NAME${S} will adjust your xorg.conf busID. For typical, single monitor/dual card setups, this is desirable,"
  2817. echo "but for rare cases of dual card, dual monitor setups, you may want to start with ${C}-C${S} (exit here to do so) "
  2818. echo
  2819.  
  2820. echo "If you proceed without ${C}-C${S}, a copy of your current ${C}xorg.conf${S} will be made here: ${C}$timeStampXorg"
  2821. else
  2822. echo "${S}Because you started with ${C}-C${S} option, ${C}$SCRIPT_NAME${S} will NOT change your ${C}xorg.conf${S} here"
  2823. echo "but will simply set which card to use for the automatic driver selection. Just pick the card"
  2824. echo "you want ${C}$SCRIPT_NAME${S} to use as the main card and ${C}$SCRIPT_NAME${S} will continue to installing the proper driver."
  2825. fi
  2826. echo
  2827. echo "${S}Please select which card you want to install a driver for now to proceed:"
  2828. echo $MLINE
  2829.  
  2830. options="$cardData exit"
  2831. select opt in $options
  2832. do
  2833. for card in $options
  2834. do
  2835. if [ "$opt" == "$card" ];then
  2836. if [ "$card" == 'exit' ];then
  2837. echo "${S}Exiting script now.${N}"
  2838. exit 0
  2839. else
  2840. singleCardId=$( echo $card | grep -Eo -i '[a-z0-9]{4}:[a-z0-9]{4}' )
  2841. echo "${S}You have elected to install drivers for this video card:"
  2842. echo "${C}$card${N}"
  2843. # override the global values and handle this explicitly
  2844. # note that we need to do this whether or not -C is used
  2845. CARD_DATA=$singleCardId
  2846.  
  2847. if [ "$B_SKIP_CONFIG" != 'true' ];then
  2848. if [ ! -e $timeStampXorg ];then
  2849. cp $EXXC $timeStampXorg
  2850. fi
  2851. log_function_data "xorg.conf was backed up to: $timeStampXorg"
  2852. B_XORG_BACKED_UP='true'
  2853. # set correct bus id as last step, note you have to check for . in PCI string:
  2854. # like this: O1:00.0 and change it to O1:00:0
  2855. BUS_ID=$( lspci -n | grep "$CARD_DATA" | grep -Eio '^[0-9]{1,2}:[0-9a-z]{1,2}(\.|:)[0-9]' | sed 's/\./:/')
  2856.  
  2857. # handle explicit assignment of busid to avoid errors
  2858. echo "${S}Updating ${C}xorg.conf${S} to use the card with this BusID: ${C}$BUS_ID${N}"
  2859. if [ -n "$BUS_ID" ];then
  2860. # create a dummy in case it's needed by new xorg system
  2861. create_section_device
  2862. pcibusid_hex_to_dec # need to get rid of hex due to xorg error
  2863. # this is redundant if set above but easier to do for all cases
  2864. sed -i -r 's/\s*#*\s*BusID.*/\tBusID\t"PCI:'$BUS_ID'"/' $EXXC
  2865. fi
  2866. fi
  2867. fi
  2868. bFound='true'
  2869. break
  2870. else
  2871. bFound='false'
  2872. fi
  2873. done
  2874. break
  2875. done
  2876. if [ "$bFound" != "true" ];then
  2877. echo "${E}Please select one of the numbers for your choices!${N}"
  2878. select_card
  2879. fi
  2880. }
  2881. #select_card;exit
  2882.  
  2883. # this is separated from detect card because it will be used for nv/ati basic card tests
  2884. set_card()
  2885. {
  2886. local bCardFound='false' card=''
  2887.  
  2888. # note: select_card has already handled multiple cards on box, so no need to loop it
  2889. CARD_BRAND=$( echo $CARD_DATA | cut -d ':' -f1 )
  2890. case $CARD_BRAND in
  2891. 10de|12d2)
  2892. CARD=$NVIDIA
  2893. bCardFound='true'
  2894. B_DEFAULT_NATIVE_DRIVER='true'
  2895. ;;
  2896. 1002)
  2897. CARD=$FGLRX
  2898. bCardFound='true'
  2899. B_DEFAULT_NATIVE_DRIVER='true'
  2900. ;;
  2901. 8086)
  2902. CARD=$INTEL
  2903. bCardFound='true'
  2904. B_DEFAULT_NATIVE_DRIVER='true'
  2905. ;;
  2906. 10c8)
  2907. CARD=$NEOMAGIC
  2908. bCardFound='true'
  2909. B_DEFAULT_NATIVE_DRIVER='true'
  2910. ;;
  2911. 121a)
  2912. CARD=$TDFX
  2913. bCardFound='true'
  2914. B_DEFAULT_NATIVE_DRIVER='true'
  2915. ;;
  2916. *)
  2917. # this is required to handle unknown card types when forced override is used
  2918. if [ -n "$NATIVE_OVERRIDE" ];then
  2919. bCardFound='true'
  2920. fi
  2921. ;;
  2922. esac
  2923. if [ "$bCardFound" != 'true' ];then
  2924. error_handler 254
  2925. fi
  2926. }
  2927. ## card support information:
  2928. # nvidia: http://us.download.nvidia.com/XFree86/Linux-x86/1.0-9755/README/appendix-a.html
  2929. ## pick out the id string for nvidia/fglrx, set all the master variables for nv/fg
  2930. detect_card_version()
  2931. {
  2932. local foundVersion='' version='' card='' cardBrand='' cardNumber=''
  2933. local isQuad='' is8xxx=''
  2934.  
  2935. # note: select_card has already handled multiple cards on box, so no need to loop it
  2936. cardBrand=$( echo $CARD_DATA | cut -d ':' -f1 )
  2937. cardNumber=$( echo $CARD_DATA | cut -d ':' -f2 )
  2938. case $cardBrand in
  2939. 10de|12d2)
  2940. # these will also assign dynamic betas to $NV_BETA prior to sending it
  2941. # to the master DRIVER_BETA for support tests right after
  2942. DRIVER_DEFAULT=$( assign_standard_or_beta_driver 'default' 'driver' )
  2943. B_BETA_EXISTS=$( assign_standard_or_beta_driver 'default' 'set-exists' )
  2944. DRIVER_BETA=$NV_BETA
  2945. VERSIONS=$NV_VERSIONS
  2946. OTHER_VERSIONS=$NV_OTHERS
  2947. CARD_NUMBER=$cardNumber
  2948. # do some card specific tests to determine generic classes
  2949. # |3D[[:space:]]controller |Display[[:space:]]controller
  2950. isQuad=$( lspci | \
  2951. grep -E '([[:space:]]VGA[[:space:]])' | \
  2952. grep -i -o 'quadro' )
  2953. is8xxx=$( lspci | \
  2954. grep -E '[[:space:]]VGA[[:space:]]' | \
  2955. grep -Eo '8[0-9]{3}' )
  2956. case $cardNumber in
  2957. # http://listing.driveragent.com/pci/10de/?q=94c3 # later series
  2958. # http://listing.driveragent.com/pci/12d2/?q=94c3 # full legacy
  2959. # http://www.nvidia.com/object/linux-amd64-display-archive.html
  2960. 0008|0009|0010|0018|0019)
  2961. error_handler 253 # if card in this list exit
  2962. LEGACY_LEVEL=0
  2963. ;;
  2964. 0020|0028|0029|002c|002d|00a0|0100|0101|0103|0150|0151|0152|0153|0170)
  2965. DRIVER_INSTALL=$( assign_standard_or_beta_driver 'legacy-1' 'driver' )
  2966. B_BETA_EXISTS=$( assign_standard_or_beta_driver 'legacy-1' 'set-exists' )
  2967. # B_RENDER_ACCEL='' # set default to false
  2968. LEGACY_LEVEL=1
  2969. # buntu doesn't have 71xxx drivers in package pool since they don't support
  2970. # new xorg
  2971. case $SYSTEM_BASE in
  2972. ubuntu)
  2973. if [ "$B_USE_DISTRO_DRIVER" == 'true' ];then
  2974. error_handler 217 # if card in this list exit
  2975. fi
  2976. ;;
  2977. esac
  2978. ;;
  2979. 0110|0111|0112|0113|0170|0171|0172|0173|0174|0175|0176|0177|0178|0179|017a|017c|017d|0180|0181|0182|0183|0185|0186|0187|0188|018a|018b|018c|01a0|01f0|0200|0201|0202|0203|0250|0251|0253|0258|0259|025b|0280|0281|0282|0286|0288|0289|028c)
  2980. DRIVER_INSTALL=$( assign_standard_or_beta_driver 'legacy-2' 'driver' )
  2981. B_BETA_EXISTS=$( assign_standard_or_beta_driver 'legacy-2' 'set-exists' )
  2982. LEGACY_LEVEL=2
  2983. # B_RENDER_ACCEL='' # set default to false
  2984. if [ "$B_FORCE_NO_COMPOSITE" != 'true' ];then
  2985. B_COMPOSITE='true'
  2986. fi
  2987. ;;
  2988. # This is for the GeForce FX 5xxx series. Not sure about the quadro fx series:
  2989. # 004d 004e 09d0 009d 00cd 00ce 00fe 019d 019e
  2990. # http://www.nvidia.com/object/IO_32667.html
  2991. # gawk '{t=t tolower($NF) "|"}END{gsub(/0x/,"",t);print t}'
  2992. 00fa|00fb|00fc|00fd|00fe|0301|0302|0308|0309|0311|0312|0314|031a|031b|031c|0320|0321|0322|0323|0324|0325|0326|0327|0328|032a|032b|032c|032d|0330|0331|0332|0333|0334|0338|033f|0341|0342|0343|0344|0347|0348|034c|034e)
  2993. DRIVER_INSTALL=$( assign_standard_or_beta_driver 'legacy-3' 'driver' )
  2994. B_BETA_EXISTS=$( assign_standard_or_beta_driver 'legacy-3' 'set-exists' )
  2995. LEGACY_LEVEL=3
  2996. if [ "$B_FORCE_NO_COMPOSITE" != 'true' ];then
  2997. B_COMPOSITE='true'
  2998. fi
  2999. ;;
  3000. # list of 6/7xxx devices: http://nvidia.custhelp.com/app/answers/detail/a_id/3142
  3001. # http://www.nvidia.com/object/IO_32667.html
  3002. # gawk '{t=t tolower($NF) "|"}END{gsub(/0x/,"",t);print t}'
  3003. 0040|0041|0042|0043|0044|0045|0046|0047|0048|004e|0090|0091|0092|0093|0095|0098|0099|009d|00c0|00c1|00c2|00c3|00c8|00c9|00cc|00cd|00ce|00f1|00f2|00f3|00f4|00f5|00f6|00f8|00f9|0140|0141|0142|0143|0144|0145|0146|0147|0148|0149|014a|014c|014d|014e|014f|0160|0161|0162|0163|0164|0165|0166|0167|0168|0169|016a|01d0|01d1|01d2|01d3|01d6|01d7|01d8|01da|01db|01dc|01dd|01de|01df|0211|0212|0215|0218|0221|0222|0240|0241|0242|0244|0245|0247|0290|0291|0292|0293|0294|0295|0297|0298|0299|029a|029b|029c|029d|029e|029f|02e0|02e1|02e2|02e3|02e4|038b|0390|0391|0392|0393|0394|0395|0397|0398|0399|039c|039e|03d0|03d1|03d2|03d5|03d6|0531|0533|053a|053b|053e|07e0|07e1|07e2|07e3|07e5)
  3004. DRIVER_INSTALL=$( assign_standard_or_beta_driver 'legacy-4' 'driver' )
  3005. B_BETA_EXISTS=$( assign_standard_or_beta_driver 'legacy-4' 'set-exists' )
  3006. LEGACY_LEVEL=4
  3007. if [ "$B_FORCE_NO_COMPOSITE" != 'true' ];then
  3008. B_COMPOSITE='true'
  3009. fi
  3010. ;;
  3011. # 8/9xxx gt100-300 series
  3012. # http://www.nvidia.com/object/IO_32667.html
  3013. # gawk '{t=t tolower($NF) "|"}END{gsub(/0x/,"",t);print t}'
  3014. 0191|0193|0194|0197|019d|019e|0400|0401|0402|0403|0404|0405|0406|0407|0408|0409|040a|040b|040c|040d|040e|040f|0410|0420|0421|0422|0423|0424|0425|0426|0427|0428|0429|042a|042b|042c|042d|042e|042f|05e0|05e1|05e2|05e3|05e6|05e7|0595|068f|0697|0714|0743|05ea|05eb|05ed|05f8|05f9|05fd|05fe|05ff|0600|0601|0602|0603|0604|0605|0606|0607|0608|0609|00a7|060a|060b|060c|060d|060f|0610|0611|0612|0613|0614|0615|0617|0618|0619|061a|061b|061c|061d|061e|061f|0621|0622|0623|0625|0626|0627|0628|062a|062b|062c|062d|062e|0605|0630|0631|0632|0635|0637|0638|063a|0640|0641|0643|0644|0645|0646|0647|0648|0649|202d|064a|064b|064c|0651|0652|0850|0653|0654|14a2|14d2|0633|0693|0658|0659|065a|065b|065c|06e0|06e1|06e2|06e3|06e4|06e5|06e6|06e7|06e8|360b|06e9|06ea|06eb|06ec|06ef|06f1|06f8|06f9|060d|06fa|06fb|06fd|06ff|0711|0840|0844|0845|0846|0847|0848|0849|084a|084b|084c|084d|084f|0860|0861|0862|0863|0864|0865|0866|00b1|0867|0868|0869|086a|086c|086d|086e|086f|0870|0871|0872|1c42|0873|1c52|0874|0876|087a|087d|087e|087f|08a0|08a2|08a3|08a4|08a5|0a20|0a22|0a23|0a26|0a27|0a28|0a29|0a2a|0a2b|0a2c|0a2d|0a32|0a34|0a35|0a38|0a3c|0a60|0a62|0a63|0a64|0a65|0a66|0a67|0a68|0a69|0a6a|0a6c|0a6e|3607|0a6f|0a70|3605|3617|0a71|0a72|0a73|3607|3610|0a74|903a|0a75|3605|0a76|0a78|0a7a|0003|3950|397d|3980|8006|90b4|aa51|aa58|ac71|ac82|0a7c|0ca0|0ca2|0ca3|0ca4|0ca5|0ca7|0ca8|0ca9|0cac|0caf|0cb0|0cb1|0cbc|10c0|10c3|10c5|10d8)
  3015. DRIVER_INSTALL=$( assign_standard_or_beta_driver 'legacy-5' 'driver' )
  3016. B_BETA_EXISTS=$( assign_standard_or_beta_driver 'legacy-5' 'set-exists' )
  3017. LEGACY_LEVEL=5
  3018. if [ "$B_FORCE_NO_COMPOSITE" != 'true' ];then
  3019. B_COMPOSITE='true'
  3020. fi
  3021. ;;
  3022. *)
  3023. # set flags for fully supported non-legacy cards
  3024. B_USE_XVMC='true'
  3025. LEGACY_LEVEL=100
  3026. if [ "$B_FORCE_NO_COMPOSITE" != 'true' ];then
  3027. B_COMPOSITE='true'
  3028. fi
  3029. ;;
  3030. esac
  3031. # this handles 8xxx xvmc issue
  3032. if [ -n "$is8xxx" ];then
  3033. B_USE_XVMC='false'
  3034. fi
  3035. # this handles quad cards, whose driver supports both nv legacy and standard cards
  3036. if [ -n "$isQuad" ];then
  3037. : # now quad driver is just latest
  3038. #DRIVER_QUAD=$NV_QUAD
  3039. #DRIVER_INSTALL=$NV_QUAD
  3040. fi
  3041. ;;
  3042. 1002)
  3043. DRIVER_DEFAULT=$FG_DEFAULT
  3044. # if a hack / driver change is required, this will trigger it
  3045. driver_version_hacks "$DRIVER_DEFAULT"
  3046. DRIVER_BETA=$FG_BETA
  3047. VERSIONS=$FG_VERSIONS
  3048. OTHER_VERSIONS=$FG_OTHERS
  3049. CARD_NUMBER=$cardNumber
  3050. case $cardNumber in
  3051. # fireGL cards, temp no support in fglrx
  3052. # http://wiki.cchtml.com/index.php/Hardware
  3053. # note: 4e50 should work with 8.4 driver
  3054. 3154|3e54|4147|4154|4a4d|4e47|4e4b|4e54|5464|5550|5551|564a|564b|5b64|5d49|5e48|5e49|71C4)
  3055. LEGACY_LEVEL=0
  3056. error_handler 253
  3057. ;;
  3058. # http://listing.driveragent.com/pci/1002/?q=94c3
  3059. 0544)
  3060. LEGACY_LEVEL=0
  3061. error_handler 253
  3062. ;;
  3063. # removed from list: 4337 - laptop chip
  3064. 4136|4137|4237|4242|4243|4336|4337|4354|4358|4437|4554|4654|4742|4744|4747|4749|474c|474d|474e|474f|4750|4751|4752|4753|4754|4755|4756|4757|4758|4759|475a|4964|4965|4966|4967|496e|496f|4c42|4c44|4c45|4c46|4c47|4c49|4c4d|4c4e|4c50|4c51|4c52|4c53|4c54|4c57|4c58|4c59|4c5a|4c64|4c65|4c66|4c67|4c6e|4c6f|4d46|4d4c|4f72|4f73)
  3065. LEGACY_LEVEL=0
  3066. error_handler 253
  3067. ;;
  3068. 5041|5042|5043|5044|5045|5046|5047|5048|5049|504a|504b|504c|504d|504e|504f|5050|5051|5052|5053|5054|5055|5056|5057|5058|5144|5145|5146|5147|5148|5149|514a|514b|514c|514d|514e|514f|5154|5155|5157|5158|5159|515a|515e|515f|5168|5169|516a|516b|516c|516d|516f|5245|5246|5247|524b|524c|5345|5346|5347|5348|534b|534c|534d|534e|5354|5446|544c|5452|5453|5454|5455|5654|5655|5656|5833|5834|5835|5838|5854|5874|5940|5941|5942|5944|5960|5961|5962|5964|5965|5969|5c41|5c43|5c61|5c63|5d44)
  3069. LEGACY_LEVEL=0
  3070. error_handler 253
  3071. ;;
  3072. 7c37|728c|7834|7835)
  3073. LEGACY_LEVEL=0
  3074. error_handler 253
  3075. ;;
  3076. # a few cards of the 7xxx numbering are actuall x2xxx cards
  3077. # sadly, this doesn't build the module, so leaving it commented out, x series fail
  3078. # 718a|7188|7210|7211)
  3079. # LEGACY_LEVEL=100
  3080. # if [ "$B_DISTRO_FLAG" == 'true' ];then
  3081. # B_USE_DISTRO_DRIVER='true'
  3082. # fi
  3083. # ;;
  3084. # this is going to handle all pre hd/x2000 cards, any exceptions will be added
  3085. # to an explicit whitelist above this if required
  3086. 3*|4*|5*|7*)
  3087. LEGACY_LEVEL=1
  3088. # error should occur but on off chance that legacy smxi users are running very old install
  3089. # I'll leave it for now. Otherwise sgfxi will handle this itself later on.
  3090. # 2014-03-02: turned on, no point in leaving support
  3091. error_handler 253
  3092. # going to leave this in for now until debian kernels and
  3093. # xorgs catch up, but will permit by default for non legacy 0 cards
  3094. if [ "$B_DISTRO_FLAG" == 'true' ];then
  3095. B_USE_DISTRO_DRIVER='true'
  3096. fi
  3097. ;;
  3098. # these should cover most of the hd2xxx-hd4xxx series with discontinued support
  3099. 94*|95*|97*)
  3100. LEGACY_LEVEL=2
  3101. ;;
  3102. *)
  3103. # if no working driver via standard ati installer. Here we're also handling
  3104. # the monthly releases, so users can do an experimental test if needed
  3105. # if [ "$B_DISTRO_FLAG" == 'true' -a "$B_TESTING_1" != 'true' ]
  3106. LEGACY_LEVEL=100
  3107. # this will reset the globals for betas/default drivers. Must not run in subshell
  3108. assign_standard_or_beta_driver 'default' 'driver'
  3109.  
  3110. # echo 'dd: ' $DRIVER_DEFAULT
  3111. B_BETA_EXISTS=$( assign_standard_or_beta_driver 'default' 'set-exists' )
  3112. # echo 'be: ' $B_BETA_EXISTS
  3113. if [ "$B_DISTRO_FLAG" == 'true' ];then
  3114. B_USE_DISTRO_DRIVER='true'
  3115. fi
  3116. if [ "$B_FORCE_NO_COMPOSITE" != 'true' ];then
  3117. B_COMPOSITE='true'
  3118. fi
  3119. ;;
  3120. esac
  3121. ;;
  3122. # set B_NATIVE_DRIVER so script fires correctly
  3123. # intel | neomagic | 3dfx
  3124. 8086|10c8|121a)
  3125. CARD_NUMBER=$cardNumber
  3126. B_NATIVE_DRIVER='true'
  3127. ;;
  3128. esac
  3129. #echo $cardNumber
  3130. }
  3131.  
  3132. # note that for fglrx we need to just change the global values, not run this as subshell for driver tests
  3133. # args: $1 - default/legacy-[1-4]; $2 - set-exists/driver
  3134. assign_standard_or_beta_driver()
  3135. {
  3136. local betaDriver='' stableDriver='' liveBetas='' betaVersion=''
  3137. local betaCurrent='' beta340='' beta304='' beta173='' beta96='' beta71=''
  3138.  
  3139. case $CARD in
  3140. $NVIDIA)
  3141. # only run this the first time it's called
  3142. if [ "$B_USE_BETA" == 'true' -a "$1" == 'default' -a "$2" == 'driver' ];then
  3143. liveBetas=$( get_live_beta_drivers )
  3144. betaCurrent=$( cut -d ':' -f 1 <<< "$liveBetas" )
  3145. beta340=$( cut -d ':' -f 2 <<< "$liveBetas" )
  3146. beta304=$( cut -d ':' -f 3 <<< "$liveBetas" )
  3147. beta173=$( cut -d ':' -f 4 <<< "$liveBetas" )
  3148. beta96=$( cut -d ':' -f 5 <<< "$liveBetas" )
  3149. beta71=$( cut -d ':' -f 6 <<< "$liveBetas" )
  3150. ## assign live defaults if required
  3151. if [ -n "$betaCurrent" ];then
  3152. if [ -z "$NV_DEFAULT_BETA" -o "$( compare_numbers $betaCurrent $NV_DEFAULT_BETA )" -eq 0 ];then
  3153. NV_DEFAULT_BETA=$betaCurrent
  3154. NV_BETA="$NV_BETA:$betaCurrent"
  3155. fi
  3156. fi
  3157. if [ -n "$beta340" ];then
  3158. if [ -z "$NV_LEGACY_BETA_5" -o "$( compare_numbers $beta340 $NV_LEGACY_BETA_5 )" -eq 0 ];then
  3159. NV_LEGACY_BETA_5=$beta340
  3160. NV_BETA="$NV_BETA:$beta340"
  3161. fi
  3162. fi
  3163. if [ -n "$beta304" ];then
  3164. if [ -z "$NV_LEGACY_BETA_4" -o "$( compare_numbers $beta304 $NV_LEGACY_BETA_4 )" -eq 0 ];then
  3165. NV_LEGACY_BETA_4=$beta304
  3166. NV_BETA="$NV_BETA:$beta304"
  3167. fi
  3168. fi
  3169. if [ -n "$beta173" ];then
  3170. if [ -z "$NV_LEGACY_BETA_3" -o "$( compare_numbers $beta173 $NV_LEGACY_BETA_3 )" -eq 0 ];then
  3171. NV_LEGACY_BETA_3=$beta173
  3172. NV_BETA="$NV_BETA:$beta173"
  3173. fi
  3174. fi
  3175. if [ -n "$beta96" ];then
  3176. if [ -z "$NV_LEGACY_BETA_2" -o "$( compare_numbers $beta96 $NV_LEGACY_BETA_2 )" -eq 0 ];then
  3177. NV_LEGACY_BETA_2=$beta96
  3178. NV_BETA="$NV_BETA:$beta96"
  3179. fi
  3180. fi
  3181. if [ -n "$beta71" ];then
  3182. if [ -z "$NV_LEGACY_BETA_1" -o "$( compare_numbers $beta71 $NV_LEGACY_BETA_1 )" -eq 0 ];then
  3183. NV_LEGACY_BETA_1=$beta71
  3184. NV_BETA="$NV_BETA:$beta71"
  3185. fi
  3186. fi
  3187. fi
  3188.  
  3189. case $1 in
  3190. default)
  3191. betaDriver=$NV_DEFAULT_BETA
  3192. stableDriver=$NV_DEFAULT
  3193. ;;
  3194. legacy-1)
  3195. betaDriver=$NV_LEGACY_BETA_1
  3196. stableDriver=$NV_LEGACY_1
  3197. ;;
  3198. legacy-2)
  3199. betaDriver=$NV_LEGACY_BETA_2
  3200. stableDriver=$NV_LEGACY_2
  3201. ;;
  3202. legacy-3)
  3203. betaDriver=$NV_LEGACY_BETA_3
  3204. stableDriver=$NV_LEGACY_3
  3205. ;;
  3206. legacy-4)
  3207. betaDriver=$NV_LEGACY_BETA_4
  3208. stableDriver=$NV_LEGACY_4
  3209. ;;
  3210. legacy-5)
  3211. betaDriver=$NV_LEGACY_BETA_5
  3212. stableDriver=$NV_LEGACY_5
  3213. ;;
  3214. esac
  3215. ;;
  3216. $FGLRX)
  3217. local defaultBetaWorking='' defaultBetaVersion='' betaCurrentWorking='' betaCurrentVersionWorking=''
  3218. local bDebugger='false'
  3219.  
  3220. if [ "$B_USE_BETA" == 'true' -a "$1" == 'default' -a "$2" == 'driver' ];then
  3221. ### NOTE: not used anymore
  3222. # liveBetas=$( get_live_beta_drivers )
  3223. if [ "$bDebugger" == 'true' ];then
  3224. echo
  3225. echo "Start assign_standard_or_beta_driver"
  3226. echo "lb:$liveBetas:"
  3227. fi
  3228.  
  3229. if [ -n "$liveBetas" ];then
  3230. # check for spastic amd version numbering here, 13-6 vs 13.4
  3231. # note, make sure to use [[ for null cases here
  3232. if [[ -n $( grep -E '^[0-9]+-[0-9]+' <<< "$liveBetas" ) ]];then
  3233. betaCurrent=$( cut -d '-' -f 1,2 <<< "$liveBetas" )
  3234. betaVersion=$( cut -d '-' -f 3 <<< "$liveBetas" )
  3235. elif [[ -n $( grep -E '^[0-9]+\.[0-9]+' <<< "$liveBetas" ) ]];then
  3236. betaCurrent=$( cut -d '-' -f 1 <<< "$liveBetas" )
  3237. betaVersion=$( cut -d '-' -f 2 <<< "$liveBetas" )
  3238. fi
  3239. # http://www2.ati.com/drivers/beta/amd-catalyst-13.11-betav1-linux-x86.x86_64.zip
  3240. # now convert to numbered
  3241. betaCurrentWorking=$( sed 's/-/./g' <<< "$betaCurrent" )
  3242. if [ -n "$( grep -E 'beta[v]?[0-9]' <<< "$liveBetas" )" ];then
  3243. betaCurrentVersionWorking=$( sed -r 's/.*-beta[v]?([0-9\.]+)/\1/' <<< "$liveBetas" )
  3244. fi
  3245. defaultBetaWorking=$( sed 's/-/./g' <<< $FG_DEFAULT_BETA )
  3246. if [ -n "$( grep -E 'beta[v]?[0-9]' <<< "$FG_BETA_VERSION" )" ];then
  3247. defaultBetaVersion=$( sed -r 's/beta[v]?([0-9\.]+)/\1/' <<< "$FG_BETA_VERSION" )
  3248. fi
  3249. if [ "$bDebugger" == 'true' ];then
  3250. echo ""
  3251. echo "bc:$betaCurrent:"
  3252. echo "bv:$betaVersion:"
  3253. echo "bcw:$betaCurrentWorking:"
  3254. echo "bcvw:$betaCurrentVersionWorking:"
  3255. echo "dbw:$defaultBetaWorking:"
  3256. echo "dbv:$defaultBetaVersion:"
  3257. fi
  3258. # echo $FG_DEFAULT_BETA $defaultBetaWorking
  3259. if [ -z "$FG_DEFAULT_BETA" \
  3260. -o "$( compare_numbers $betaCurrent $defaultBetaWorking )" -eq 0 ] || \
  3261. [ -n "$betaCurrentVersionWorking" \
  3262. -a -n "$defaultBetaVersion" -a "$( compare_numbers $betaCurrentVersionWorking $defaultBetaVersion )" -eq 0 ];then
  3263. FG_DEFAULT_BETA=$betaCurrent
  3264. FG_BETA_VERSION=$betaVersion
  3265. # echo yest1
  3266. fi
  3267. fi
  3268. fi
  3269. # two cases, if the remote beta version is greater than default driver, or if local version is graater than default
  3270. if [ -n "$defaultBetaWorking" -a "$( compare_numbers $defaultBetaWorking $FG_DEFAULT )" -eq 0 ] || \
  3271. [ -n "$FG_DEFAULT_BETA" -a "$( compare_numbers $FG_DEFAULT_BETA $FG_DEFAULT )" -eq 0 ];then
  3272. betaDriver=$FG_DEFAULT_BETA
  3273. # echo yest2
  3274. fi
  3275. if [ "$bDebugger" == 'true' ];then
  3276. echo "dbw > fd: $( compare_numbers $defaultBetaWorking $FG_DEFAULT )"
  3277. echo "fdb > fd: $( compare_numbers $FG_DEFAULT_BETA $FG_DEFAULT )"
  3278. echo "FDB:$FG_DEFAULT_BETA:"
  3279. echo "FBV:$FG_BETA_VERSION:"
  3280. echo "FD:$FG_DEFAULT:"
  3281. echo "bd:$betaDriver:"
  3282. echo "End assign_standard_or_beta_driver"
  3283. fi
  3284. stableDriver=$FG_DEFAULT
  3285. ;;
  3286. esac
  3287.  
  3288. if [ "$2" == 'driver' ];then
  3289. if [ -n "$betaDriver" -a "$B_USE_BETA" == 'true' ];then
  3290. case $CARD in
  3291. $NVIDIA)
  3292. echo $betaDriver
  3293. ;;
  3294. $FGLRX)
  3295. DRIVER_DEFAULT=$betaDriver
  3296. ;;
  3297. esac
  3298. elif [ -z "$betaDriver" -o "$B_USE_BETA" != 'true' ];then
  3299. case $CARD in
  3300. $NVIDIA)
  3301. echo $stableDriver
  3302. ;;
  3303. $FGLRX)
  3304. DRIVER_DEFAULT=$stableDriver
  3305. # explicitly unset these to clear out any sgfxi attempt to use beta stuff internally
  3306. FG_BETA_VERSION=''
  3307. ### NOTE: legacy, not used as of 14.x
  3308. # B_USE_BETA='false'
  3309. ;;
  3310. esac
  3311. fi
  3312. else
  3313. if [ -n "$betaDriver" -a "$B_USE_BETA" == 'true' ];then
  3314. echo 'true'
  3315. else
  3316. echo 'false'
  3317. fi
  3318. fi
  3319. }
  3320.  
  3321. get_live_beta_drivers()
  3322. {
  3323. local driverList='' betaCurrent='' beta340='' beta304='' beta173='' beta96='' beta71=''
  3324.  
  3325. # get data
  3326. if [ "$B_SKIP_WGET" != 'true' ];then
  3327. case $CARD in
  3328. $NVIDIA)
  3329. driverList="$( wget -T 3 -t 2 -qO - $NV_LIVE_DRIVERS )"
  3330. # get beta drivers
  3331. betaCurrent=$( awk '/^curr.*beta/ {print $3}' <<< "$driverList" )
  3332. beta340=$( awk '/^340.*beta/ {print $3}' <<< "$driverList" )
  3333. beta304=$( awk '/^304.*beta/ {print $3}' <<< "$driverList" )
  3334. beta173=$( awk '/^173.*beta/ {print $3}' <<< "$driverList" )
  3335. beta96=$( awk '/^96.*beta/ {print $3}' <<< "$driverList" )
  3336. beta71=$( awk '/^71.*beta/ {print $3}' <<< "$driverList" )
  3337. driverList="$betaCurrent:$beta173:$beta96:$beta71"
  3338. ;;
  3339. $FGLRX)
  3340. driverList="$( wget -T 3 -t 2 -qO - $FG_LIVE_DRIVERS )"
  3341. betaCurrent=$( grep 'beta' <<< "$driverList" )
  3342. driverList=$betaCurrent
  3343. # echo 'bc^'$betaCurrent'^'
  3344. ;;
  3345. esac
  3346. fi
  3347.  
  3348. #return processed betas
  3349. echo $driverList
  3350. }
  3351.  
  3352. # this is to get the live data for print out only, for apps that might use this
  3353. # this is only for -p script printout, and is triggered by: -p -! 121
  3354. reset_using_live_driver_data()
  3355. {
  3356. if [ "$B_SKIP_WGET" != 'true' ];then
  3357. local uaFull="-U s-tools/sgfxi-data.tool-data"
  3358. local driverList="$( wget $uaFull -T 3 -t 2 -qO - http://smxi.org/sg/data/sg-drivers-23 )"
  3359. local nvidiaDefault=$( grep -iA 1 'NVidia Default Stable' <<< "$driverList" | grep 'DEFAULT' )
  3360. local nvidiaBeta=$( grep -iA 1 'Nvidia Beta Drivers' <<< "$driverList" | grep 'DEFAULT' )
  3361. local fglrxDefault=$( grep -iA 1 'Fglrx Main Drivers' <<< "$driverList" | grep 'DEFAULT' )
  3362.  
  3363. # reset script locals with remote values, but only if wget succeeded, otherwise use script
  3364. # local values as an acceptable failsafe default.
  3365. if [ -n "$driverList" ];then
  3366. # DEFAULT: 306.23 :: LEGACY 4: 304.23 :: LEGACY 3: 173.14.27 :: LEGACY 2: 96.43.18 :: LEGACY 1: 71.86.14
  3367. NV_DEFAULT=$( awk '{print $2}' <<< "$nvidiaDefault" )
  3368. NV_LEGACY_1=$( awk '{print $6}' <<< "$nvidiaDefault" ) # old, tnt etc
  3369. NV_LEGACY_2=$( awk '{print $10}' <<< "$nvidiaDefault" ) # ge4xx cards
  3370. NV_LEGACY_3=$( awk '{print $14}' <<< "$nvidiaDefault" ) # 5xxx cards
  3371. NV_LEGACY_4=$( awk '{print $18}' <<< "$nvidiaDefault" ) # 6/7xxx cards
  3372. NV_LEGACY_5=$( awk '{print $22}' <<< "$nvidiaDefault" ) # 8/9xxx/21x cards
  3373. NV_VERSIONS=$( awk '{print $2 ":" $6 ":" $10 ":" $14 ":" $18 ":" $22 }' <<< "$nvidiaDefault" )
  3374.  
  3375. # DEFAULT: 260.19.06 :: LEGACY 3: N/A :: LEGACY 2: N/A :: LEGACY 1: N/A
  3376. ## beta drivers
  3377. NV_DEFAULT_BETA=$( awk '{print $2}' <<< "$nvidiaBeta" ) # >= 6xxx
  3378. NV_LEGACY_BETA_1=$( awk '{print $6}' <<< "$nvidiaBeta" ) # old, tnt etc
  3379. NV_LEGACY_BETA_2=$( awk '{print $10}' <<< "$nvidiaBeta" ) # ge4xx cards
  3380. NV_LEGACY_BETA_3=$( awk '{print $14}' <<< "$nvidiaBeta" ) # 5xxx cards
  3381. NV_LEGACY_BETA_4=$( awk '{print $18}' <<< "$nvidiaBeta" ) # 5xxx cards
  3382. NV_LEGACY_BETA_5=$( awk '{print $22}' <<< "$nvidiaBeta" ) # 5xxx cards
  3383.  
  3384. # DEFAULT: 10-9 :: PREVIOUS 1: 10-8 :: PREVIOUS 2: 9-3
  3385. # fglrx drivers
  3386. FG_DEFAULT=$( awk '{print $2}' <<< "$fglrxDefault" )
  3387. FG_VERSIONS=$( awk '{print $2 ":" $6 ":" $10 }' <<< "$fglrxDefault" )
  3388. fi
  3389. fi
  3390. }
  3391.  
  3392. ### -------------------------------------------------------------------
  3393. ### general script utilities
  3394. ### -------------------------------------------------------------------
  3395.  
  3396. # args: $1 - get/set; $2 - prefname
  3397. get_set_prefs()
  3398. {
  3399. eval $LOGUS
  3400. local etcsm='/etc/smxi.conf' retValue='' name='' value=''
  3401.  
  3402. case $1 in
  3403. get)
  3404. retValue=$( grep -s $2 $etcsm )
  3405. echo $retValue
  3406. log_function_data "Return value: $retValue"
  3407. ;;
  3408. set)
  3409. touch $etcsm
  3410. # test = first, this will handle the base name and anything else
  3411. name=$( cut -d '=' -f 1 <<< $2 )
  3412. # check to see if it's there, if it is, it must be a = type thing
  3413. if [ -z "$( grep -s $name $etcsm )" ];then
  3414. echo $2 >> $etcsm
  3415. log_function_data "Added $2 to $etcsm"
  3416. else
  3417. sed -i "s/$name.*/$2/" $etcsm
  3418. log_function_data "Updated $name to $2 in $etcsm"
  3419. fi
  3420. ;;
  3421. esac
  3422. eval $LOGUE
  3423. }
  3424.  
  3425. # handles bug in stub installer that leaves tempfiles uncleaned
  3426. cleanup_update_files()
  3427. {
  3428. eval $LOGUS
  3429. local all_files="" slxorg='sgfxi-lib-xorg'
  3430.  
  3431. # Note: if * is in "" the wildcard does not work
  3432. # /dev/null handles case where no temp or original file exists
  3433. all_files=$( ls "${SCRIPT_NAME}."* 2> /dev/null )
  3434. # make sure stuff exists, rm files
  3435. if [ -n "$all_files" ];then
  3436. rm -f $all_files
  3437. fi
  3438. if [ -f $slxorg ];then
  3439. rm -f $slxorg # clean up old xorg lib file
  3440. fi
  3441. if [ -d /usr/src/kernel-downloads -a ! -d $SM_KERNEL_DOWNLOADS ];then
  3442. mv -f /usr/src/kernel-downloads $SM_KERNEL_DOWNLOADS
  3443. fi
  3444.  
  3445. eval $LOGUE
  3446. }
  3447.  
  3448. # make the default locations for driver run package files
  3449. create_data_storage()
  3450. {
  3451. local nvidiaPackages='' fglrxPackages='' bMoved='false'
  3452. # don't run this in case of user set test paths
  3453. if [ ! -d "$SCRIPT_WORKING_DIR" -a "$B_TESTING_1" != 'true' ];then
  3454. echo $LINE
  3455. echo "${S}Creating ${C}$SCRIPT_WORKING_DIR${S} to store driver downloads in...${N}"
  3456. mkdir -p $SCRIPT_WORKING_DIR
  3457. rm -f ${USRS}nohup.out &>/dev/null # sometimes these get left over...
  3458. rm -rf /usr/src/nvidia-installer &>/dev/null # this can cause weirdness so dump it
  3459. nvidiaPackages=$( ls ${USRS} 2>/dev/null | grep -Esi '^nvidia' )
  3460. nvidiaPackages=$( echo $nvidiaPackages )
  3461. fglrxPackages=$( ls ${USRS} 2>/dev/null | grep -Esi '^(amd-driver-|ati-driver-|fglrx)' )
  3462. fglrxPackages=$( echo $fglrxPackages )
  3463. log_function_data "nvidiaPackages:\n$nvidiaPackages"
  3464. log_function_data "fglrxPackages:\n$fglrxPackages"
  3465. if [ -n "$nvidiaPackages" ];then
  3466. echo "${S}Moving all existing ${C}nVidia${S} data files to ${C}$SCRIPT_WORKING_DIR${S}...${N}"
  3467. for i in $nvidiaPackages
  3468. do
  3469. if [ -e "${USRS}$i" ];then
  3470. mv -f ${USRS}$i $SCRIPT_WORKING_DIR 2>/dev/null
  3471. fi
  3472. done
  3473. bMoved='true'
  3474. fi
  3475. if [ -n "$fglrxPackages" ];then
  3476. echo "${S}Moving all existing ${C}ATI/fglrx${S} data files to ${C}$SCRIPT_WORKING_DIR${S}...${N}"
  3477. for i in $fglrxPackages
  3478. do
  3479. if [ -e "${USRS}$i" ];then
  3480. mv -f ${USRS}$i $SCRIPT_WORKING_DIR 2>/dev/null
  3481. fi
  3482. done
  3483. bMoved='true'
  3484. fi
  3485. if [ "$bMoved" == 'true' ];then
  3486. echo "${S}Please take note of the updated location for the downloaded drivers.${N}"
  3487. print_hec
  3488. fi
  3489. fi
  3490. }
  3491.  
  3492. clean_script_data()
  3493. {
  3494. check_root
  3495. cd $SCRIPT_HOME
  3496.  
  3497. local downloadDirectorySize='' backupFiles='' backupFilesCount=''
  3498. local opt='' bRepeat='false'
  3499. local options="remove-video-driver-downloads delete-xorg.conf-backup-files uninstall-$SCRIPT_NAME quit"
  3500.  
  3501. echo $MLINE
  3502. echo "${M}$SCRIPT_NAME cleanup tool"
  3503. echo $MLINE
  3504. echo "${S}Calculating cleanup data....${N}"
  3505. echo $LINE
  3506. downloadDirectorySize=$( du -ch $SCRIPT_WORKING_DIR 2>/dev/null | grep 'total' )
  3507. backupFiles=$( ls $EXXC-bu* $EXXC.1st* 2>/dev/null )
  3508. backupFilesCount=$( wc -w <<< $backupFiles )
  3509. echo "${S}The following ${C}$SCRIPT_NAME${S} data exists for possible cleanup in your system"
  3510. echo "$SCRIPT_WORKING_DIR: ${C}$downloadDirectorySize${S}"
  3511. echo "$EXXC-bu* backup files: ${C}$backupFilesCount${S}"
  3512. echo $LINE
  3513. echo "${C}1 - remove-video-driver-downloads${S} - Delete ALL video driver downloads."
  3514. echo "${C}2 - delete-xorg.conf-backup-files${S} - Delete ALL xorg.conf backup files."
  3515. echo "${C}3 - uninstall-$SCRIPT_NAME${S} - Removes ALL pieces of $SCRIPT_NAME. Cannot be undone."
  3516. echo " Will confirm your choice before proceeding."
  3517.  
  3518. echo "${C}4 - quit${S} - Exit now."
  3519. echo $LINE
  3520. select opt in $options
  3521. do
  3522. case $opt in
  3523. remove-video-driver-downloads)
  3524. if [ -d $SCRIPT_WORKING_DIR ];then
  3525. rm -rf $SCRIPT_WORKING_DIR
  3526. echo "${C}$SCRIPT_WORKING_DIR${S} deleted. ${C}$downloadDirectorySize${S} cleaned up.${N}"
  3527. else
  3528. echo "${M}No ${C}$SCRIPT_WORKING_DIR${M} directory present so nothing deleted.${N}"
  3529. fi
  3530. bRepeat='true'
  3531. ;;
  3532. delete-xorg.conf-backup-files)
  3533. if [ -n "$backupFiles" ];then
  3534. rm -f $backupFiles
  3535. echo "${C}$backupFilesCount $EXXC-bu*${S} back-up files deleted.${N}"
  3536. else
  3537. echo "${M}No ${C}$EXXC-bu*${M} back-up files present so none deleted.${N}"
  3538. fi
  3539. bRepeat='true'
  3540. ;;
  3541. uninstall-$SCRIPT_NAME)
  3542. uninstall_script
  3543. ;;
  3544. quit)
  3545. echo "${S}Ok, quitting now.${N}"
  3546. exit 0
  3547. ;;
  3548. *) print_error 'opt'
  3549. bRepeat='true'
  3550. ;;
  3551. esac
  3552. break
  3553. done
  3554.  
  3555. if [ "$bRepeat" == 'true' ];then
  3556. clean_script_data
  3557. fi
  3558. }
  3559.  
  3560. uninstall_script()
  3561. {
  3562. local opt=''
  3563. local options="yes-uninstall-everything return-main-menu"
  3564. echo $LINE
  3565. echo "${S}Are you sure you want to totally uninstall ${C}$SCRIPT_NAME${S}"
  3566. echo "This will remove $SCRIPT_NAME and all its components permanently!"
  3567. echo $LINE
  3568. echo "${S}Enter a number for your selection and hit enter"
  3569. echo $LINE
  3570. echo "${C}1 - yes-uninstall-everything${S} - Completely uninstall $SCRIPT_NAME and its related."
  3571. echo " components, logs, and configurations."
  3572. echo "${C}2 - return-main-menu${S} - Go back to main menu, skip the uninstall."
  3573. echo $LINE
  3574. select opt in $options
  3575. do
  3576. case $opt in
  3577. yes-uninstall-everything)
  3578. echo "${S}Ok, removing all the pieces now...${N}"
  3579. rm -rf /var/log/${SCRIPT_NAME}*
  3580. rm -f $EXXC-bu* $EXXC.1st*
  3581. rm -f /etc/logrotate.d/${SCRIPT_NAME}*
  3582. rm -rf $SCRIPT_WORKING_DIR
  3583. rm -f $SCRIPT_HOME/video_support_* $SCRIPT_HOME/sg-drivers*
  3584. rm -f $SCRIPT_HOME/${SCRIPT_NAME}*
  3585. rm -f /etc/modprobe.d/kms-sg-blacklist.conf
  3586. echo "${S}Ok, everything is removed. Exiting since $SCRIPT_NAME is now gone.${N}"
  3587. exit 0
  3588. ;;
  3589. return-main-menu)
  3590. echo "${S}Ok, going back to cleanup menu now.${N}"
  3591. ;;
  3592. esac
  3593. break
  3594. done
  3595.  
  3596. if [ "$bRepeat" == 'true' ];then
  3597. uninstall_script
  3598. fi
  3599. }
  3600. ### -------------------------------------------------------------------
  3601. ### kernel data and header testing
  3602. ### -------------------------------------------------------------------
  3603.  
  3604. kernel_string_info()
  3605. {
  3606. # The kernel variables stuff needs to be in a separate function to get data from
  3607. # either the running kernel or the new installed kernel
  3608. if [ -n "$INSTALL_TO_KERNEL" ];then
  3609. KERNEL_FULL=$INSTALL_TO_KERNEL
  3610. else
  3611. KERNEL_FULL=$( uname -r ) # full kernel name
  3612. fi
  3613.  
  3614. if [ -n "$( echo $KERNEL_FULL | grep -sE "[\.|-]slh\(64\)\?[\.|-]" )" ];then
  3615. B_IS_APTOSID_KERNEL='true'
  3616. fi
  3617. if [ -n "$( grep -si 'CONFIG_XEN=y' /boot/config-$KERNEL_FULL )" ];then
  3618. B_IS_XEN='true'
  3619. fi
  3620. # note the extra cut -d '-' -f 1 test is to dump the doubled 2.6.24 in legacy kernel strings.
  3621. # check for new single number syntax, like 3.19
  3622. if [ -n "$( grep -Es '^[3-9]\.' <<< $KERNEL_FULL )" ];then
  3623. KERNEL_BASE=$( echo $KERNEL_FULL | cut -d '.' -f 1 ) # like: 3
  3624. KERNEL_NUMBER=$( echo $KERNEL_FULL | cut -d '-' -f 1 | cut -d '.' -f 1-2 ) # like: 3.19
  3625. KERNEL_MATH=$( echo $KERNEL_FULL | cut -d '-' -f 1 | cut -d '.' -f 2 ) # like: 19
  3626. # else check for old 2.6.19 style
  3627. else
  3628. KERNEL_BASE=$( echo $KERNEL_FULL | cut -d '.' -f 1-2 ) # like: 2.6
  3629. KERNEL_NUMBER=$( echo $KERNEL_FULL | cut -d '-' -f 1 | cut -d '.' -f 1-3 ) # like: 2.6.19
  3630. KERNEL_MATH=$( echo $KERNEL_FULL | cut -d '-' -f 1 | cut -d '.' -f 3 ) # like: 19
  3631. fi
  3632. if [ -n "$( grep -is "PAE" <<< $KERNEL_FULL )" ];then
  3633. FED_KERNEL_PAE='-PAE'
  3634. fi
  3635. }
  3636.  
  3637. # The best test I've found so far to check whether the kernel exists or not:
  3638. test_install_kernel_version()
  3639. {
  3640. if [ ! -d /lib/modules/$INSTALL_TO_KERNEL ];then
  3641. echo "${S}These are your currently installed kernels:${C}"
  3642. ls /lib/modules
  3643. echo ${N}
  3644. error_handler 232 $INSTALL_TO_KERNEL
  3645. #comment the line above to debug the kernel_string_info function - Also uncomment the debug lines in that function
  3646. # it passed the test
  3647. else
  3648. kernel_string_info
  3649. fi
  3650. }
  3651.  
  3652. # this handles a case where there's a kernel header mismatch or
  3653. # when they are simply missing, the former is strange, the latter normal
  3654. check_kernel_headers()
  3655. {
  3656. eval $LOGUS
  3657. local headerName=''
  3658. local headerPresent=''
  3659. local headerInstalled='' testKernel=''
  3660.  
  3661. case $SYSTEM_BASE in
  3662. debian|ubuntu)
  3663. headerName="linux-headers-$KERNEL_FULL"
  3664. headerPresent="$( ls ${USRS}$headerName/ 2>/dev/null )"
  3665. headerInstalled=$( check_package_status "$headerName" 'i' )
  3666. # want to make sure it's available, and not merely referenced
  3667. local headerAvailable=$( check_package_status "$headerName" 'c' )
  3668. local headerFile="$( ls ${SM_KERNEL_DOWNLOADS}/$KERNEL_FULL/$headerName*.deb 2>/dev/null )"
  3669.  
  3670. log_function_data "headerPresent: $headerPresent\nheaderName: $headerName\nheaderInstalled: $headerInstalled\nheaderAvailable: $headerAvailable\nheaderFile: $headerFile"
  3671.  
  3672. # first try direct apt install, then dpkg from smxi downloads, then give up
  3673. if [ -n "$headerPresent" ];then
  3674. : # do nothing, it's there
  3675. elif [ -z "$headerInstalled" -a -n "$headerAvailable" ];then
  3676. echo "${S}Installing missing kernel header package ${C}$headerName${S} before proceeding...${N}"
  3677. install_package "$headerName"
  3678. elif [ -z "$headerInstalled" -a -n "$headerFile" -a -f "$headerFile" ];then
  3679. echo "${S}Installing missing kernel header package ${C}$headerName${S}"fse
  3680. echo "using your archived header package: ${C}$headerFile${N}"
  3681. dpkg -i $headerFile || error_handler 223 "$headerFile"
  3682. elif [ -z "$headerInstalled" -a -z "$headerAvailable" -a "$B_TESTING_5" != 'true' ];then
  3683. error_handler 224 "$headerName"
  3684. fi
  3685. ;;
  3686. fedora)
  3687. # fedora 12 headers: /usr/src/kernels/$(uname -r)
  3688. # kernel-PAE-devel-2.6.31.5-127.fc12.i686.rpm
  3689. local kernelDevel='' develPresent='' kernelWorking=''
  3690. # need to slice off .PAE from working kernel name/headers name
  3691. kernelWorking=$( sed -r 's/\.PAE//' <<< $KERNEL_FULL )
  3692. headerName="kernel-headers-$kernelWorking"
  3693. headerPresent="$( ls ${USRS}kernels/$KERNEL_FULL/ 2>/dev/null )"
  3694. # rpm is reporting two names here I think, we'll see, if it's got the
  3695. # kernel name in it, we'll call it installed.
  3696. headerInstalled=$( check_package_status "$headerName" 'i' | grep $kernelWorking )
  3697. # if [ -z "$headerPresent" -a -z "$headerInstalled" ];then
  3698. if [ -z "$headerInstalled" ];then
  3699. install_package "$headerName"
  3700. fi
  3701. kernelDevel="kernel$FED_KERNEL_PAE-devel-$kernelWorking"
  3702. develPresent=$( check_package_status "$kernelDevel" 'i' )
  3703. if [ -z "$develPresent" ];then
  3704. install_package "$kernelDevel"
  3705. fi
  3706. ;;
  3707. # fresh arch installs do not have the kernel header in /usr/src but this test
  3708. # is highly erratic, arch is not using consistent methods, requires more testing
  3709. arch)
  3710. headerName="linux-headers"
  3711. headerPresent="$( ls /lib/modules/$KERNEL_FULL/build/ 2>/dev/null )"
  3712. testKernel=$( grep -Esi '^(2\.6|[3-9]\.[0-9]+)\.[0-9]+-ARCH$' <<< $KERNEL_FULL )
  3713. # 2.6.32-ARCH
  3714. if [ -z "$headerPresent" ];then
  3715. # if it's a custom kernel, no package available so die
  3716. if [ -n "$testKernel" ];then
  3717. error_handler 224 "$headerName"
  3718. # otherwise let's test for the default, and install it if its missing
  3719. else
  3720. headerInstalled=$( check_package_status "$headerName" 'i' )
  3721. if [ -n "$( check_package_status "$headerName" 'c' )" ];then
  3722. install_package "$headerName"
  3723. else
  3724. error_handler 224 "$headerName"
  3725. fi
  3726. fi
  3727. fi
  3728. ;;
  3729. esac
  3730. eval $LOGUE
  3731. }
  3732.  
  3733. # Nvidia requires for 64 bit ia32 libs installed for 64 bit
  3734. # This will satisfy the nVidia driver and also let the installer
  3735. # place the 32-bit compatibility files in the correct location,
  3736. # letting 32-bit applications run properly that depend on OpenGL acceleration.
  3737. # args: $1 - full/test
  3738. check_ia32_libs()
  3739. {
  3740. eval $LOGUS
  3741.  
  3742. local returnValue='false'
  3743.  
  3744. if [ "$BITS" == '64' -a "$CARD" == "$NVIDIA" ];then
  3745. local ia32Name='' ia32Path=''
  3746. local ia32Supported='' ia32Present='' ia32Available=''
  3747. local ia32Installed='' testKernel=''
  3748. local kernelDevel='' develPresent='' kernelWorking=''
  3749. # dpkg -l | grep -E '^ii libc6:i386'
  3750. case $SYSTEM_BASE in
  3751. debian|ubuntu)
  3752. ia32Name='ia32-libs-i386:i386'
  3753. ia32Path='/emul/ia32-linux'
  3754.  
  3755. if [ "$1" != 'test' ];then
  3756. echo "${S}Checking for ${C}ia32-lib multiarch${S} support for ${C}nVidia 32-bit compatibility layer${S}...${N}"
  3757. fi
  3758. # first verify that we can do this, ie, that the base system supports architectures. Debian Lenny does not have this capability
  3759. ia32Supported=$( dpkg --print-foreign-architectures 2>/dev/null || echo 'false' )
  3760.  
  3761. if [ "$ia32Supported" != 'false' ];then
  3762. ia32Present=$( dpkg --print-foreign-architectures | grep -o 'i386' )
  3763. ia32Installed=$( check_package_status "$ia32Name" 'i' )
  3764. fi
  3765.  
  3766. if [ "$ia32Present" == 'i386' -a "$( readlink -f $ia32Path/usr/lib )" == '/usr/lib/i386-linux-gnu' \
  3767. -a -n "$ia32Installed" ];then
  3768. if [ "$1" != 'test' ];then
  3769. echo "${M}Your system is compatible with ${C}nVidia's${M} proprietary driver ${C}32-bit compatibility layer${M}.${N}"
  3770. fi
  3771. log_function_data "32 bit nvidia compat already present and configured"
  3772. elif [ "$ia32Supported" != 'false' -a "$1" == 'test' ];then
  3773. returnValue='true'
  3774. log_function_data "32 bit nvidia supported. Showing install option."
  3775. elif [ "$ia32Supported" != 'false' -a "$1" == 'full' ];then
  3776. ###############################
  3777. # Check all the requirements for 32-bit support for nVidia drivers in 64-bit
  3778. # one by one, correcting any discrepancies if found.
  3779. ###############################
  3780. # add i386 multi-arch support if missing
  3781. if [ "$ia32Present" != 'i386' ]; then
  3782. echo "${S}Missing ${C}i386 multiarch${S} support, adding...${N}"
  3783. dpkg --add-architecture i386
  3784. # force reset to grab the new arch i386 repo data
  3785. B_UPDATED='false'
  3786. update_package_manager 'update'
  3787. log_function_data "added i386 multiarch support and updated."
  3788. fi
  3789. # then check that i386 package exists
  3790. ia32Available=$( check_package_status "$ia32Name" 'c' )
  3791.  
  3792. # since ia23 has too many dependencies that can break in sid, and have, we need to confirm that
  3793. # it is working for real even if apt-cache policy reports an install candidate
  3794. if [ "$( apt-get -s install $ia32Name &>/dev/null || echo 'bad' )" != 'bad' ];then
  3795. # install ia32-libs if missing
  3796. if [ -z "$ia32Installed" -a -n "$ia32Available" ]; then
  3797. echo "${S}Installing missing package ${C}$ia32Name${S}...${N}"
  3798. install_package "$ia32Name"
  3799. fi
  3800. # confirm that package is installed, some weird system glitches made install fail
  3801. ia32Installed=$( check_package_status "$ia32Name" 'i' )
  3802. if [ -n "$ia32Installed" ];then
  3803. # create required /emul directory if missing
  3804. if [ ! -d "$ia32Path/usr" ]; then
  3805. echo "${S}Missing ${C}$ia32Path${S}, creating...${N}"
  3806. mkdir -p $ia32Path/usr
  3807. log_function_data "Created missing $ia32Path/usr directory."
  3808. fi
  3809. # fix symlink to multiarch i386 folder if wrong
  3810. if [ ! -L "$ia32Path/usr/lib" ] && \
  3811. [ "$(readlink -f $ia32Path/usr/lib)" != '/usr/lib/i386-linux-gnu' ]; then
  3812. if [ -e "$ia32Path/usr/lib" ]; then
  3813. echo "${M}Not sure what ${C}${ia32Path}/usr/lib${M} is, removing it.${N}"
  3814. rm -rf $ia32Path/usr/lib
  3815. log_function_data "Removed mysterious $ia32Path/usr/lib directory."
  3816. fi
  3817. ln -s /usr/lib/i386-linux-gnu $ia32Path/usr/lib
  3818. echo "${S}Created symlink at ${C}$ia32Path/usr/lib${S}.${N}"
  3819. log_function_data "Created sym link $ia32Path/usr/lib"
  3820. fi
  3821. echo "${S}Your system is now compatible with ${C}nVidia's${S} proprietary driver ${C}32-bit compatibility layer${S}.${N}"
  3822. else
  3823. echo "${W}No ${C}$ia32Name${W} installed or present in ${C}APT${W}. Please let the ${C}$SCRIPT_NAME${W} maintainer know."
  3824. echo "Unable to complete ${C}$NVIDIA 32 bit compatibility layer${W} setup. Continuing to driver install.${N}"
  3825. log_function_data "Missing $ia32Name package, not installed."
  3826. fi
  3827. else
  3828. echo "${M}There is a problem in ${C}APT${M} currently. Unable to install ${C}$ia32Name${M}. Continuing"
  3829. echo "Try running ${C}$SCRIPT_NAME${M} again in a day or two and the issue should be resolved.${N}"
  3830. log_function_data "APT reported error on attempt to -s install $ia32Name."
  3831. fi
  3832. else
  3833. if [ "$1" != 'test' ];then
  3834. echo "${M}Your system ${C}$SYSTEM_BASE $SYSTEM_CODENAME${M} is ${C}NOT${M} compatible with ${C}$ia32Name${M}. Continuing with driver install.${N}"
  3835. fi
  3836. log_function_data "No dpkg -add-architecture supported."
  3837. fi
  3838. ;;
  3839. # fedora)
  3840. # # fedora 12 headers: /usr/src/kernels/$(uname -r)
  3841. # # kernel-PAE-devel-2.6.31.5-127.fc12.i686.rpm
  3842. #
  3843. # # need to slice off .PAE from working kernel name/headers name
  3844. # kernelWorking=$( sed -r 's/\.PAE//' <<< $KERNEL_FULL )
  3845. # ia32Name="kernel-headers-$kernelWorking"
  3846. # ia32Present="$( ls ${USRS}kernels/$KERNEL_FULL/ 2>/dev/null )"
  3847. # # rpm is reporting two names here I think, we'll see, if it's got the
  3848. # # kernel name in it, we'll call it installed.
  3849. # ia32Installed=$( check_package_status "$ia32Name" 'i' | grep $kernelWorking )
  3850. # # if [ -z "$ia32Present" -a -z "$ia32Installed" ];then
  3851. # if [ -z "$ia32Installed" ];then
  3852. # install_package "$ia32Name"
  3853. # fi
  3854. # kernelDevel="kernel$FED_KERNEL_PAE-devel-$kernelWorking"
  3855. # develPresent=$( check_package_status "$kernelDevel" 'i' )
  3856. # if [ -z "$develPresent" ];then
  3857. # install_package "$kernelDevel"
  3858. # fi
  3859. # ;;
  3860. # # fresh arch installs do not have the kernel header in /usr/src but this test
  3861. # # is highly erratic, arch is not using consistent methods, requires more testing
  3862. # arch)
  3863. # ia32Name=""
  3864. # ia32Present=""
  3865. # testKernel=$( grep -Esi '^2\.6\.[0-9]{2}-ARCH$' <<< $KERNEL_FULL )
  3866. # # 2.6.32-ARCH
  3867. # if [ -z "$ia32Present" ];then
  3868. # # if it's a custom kernel, no package available so die
  3869. # if [ -n "$testKernel" ];then
  3870. # error_handler 224 "$ia32Name"
  3871. # # otherwise let's test for the default, and install it if its missing
  3872. # else
  3873. # ia32Installed=$( check_package_status "$ia32Name" 'i' )
  3874. # if [ -n "$( check_package_status "$ia32Name" 'c' )" ];then
  3875. # install_package "$ia32Name"
  3876. # else
  3877. # error_handler 224 "$ia32Name"
  3878. # fi
  3879. # fi
  3880. # fi
  3881. # ;;
  3882. esac
  3883. fi
  3884.  
  3885. if [ "$1" == 'test' ];then
  3886. echo $returnValue
  3887. fi
  3888. eval $LOGUE
  3889. }
  3890.  
  3891. ### -------------------------------------------------------------------
  3892. ### startup and tools testing
  3893. ### -------------------------------------------------------------------
  3894.  
  3895. # note that we want this to print with no root error
  3896. check_root()
  3897. {
  3898. if [ "$B_PRINT_VER" != 'true' ];then
  3899. # if started with sudo, this will pass
  3900. if [ "$( whoami )" != 'root' ];then
  3901. error_handler 251
  3902. fi
  3903. #Check if started with sudo, not root
  3904. if [ -n "$SUDO_USER" ] ; then
  3905. error_handler 211
  3906. fi
  3907. # this can detect 'sudo su -' if required
  3908. local startPPID=$( ps -j -fp $PPID 2>/dev/null | awk '/root/ {print $3}' )
  3909. local startPPPID=$( ps -j -fp $startPPID 2>/dev/null | awk '/root/ {print $3}' )
  3910. local sudoBase=$( ps -j -fp $startPPPID 2>/dev/null | grep -Eos 'sudo su.*' )
  3911. # log_function_data "startPPID: $startPPID\nstartPPPID: $startPPPID\nsudoBase: $sudoBase"
  3912. if [ -n "$sudoBase" ];then
  3913. echo "${M}Information: Starting $SCRIPT_NAME with: ${C}$sudoBase${N}"
  3914. SUDO_START=$sudoBase
  3915. fi
  3916. fi
  3917. }
  3918.  
  3919. basic_startup_tests()
  3920. {
  3921. ## basic execute requirements
  3922. cd $SCRIPT_HOME
  3923. check_root
  3924. # this allows users to update in x, for example, to see latest drivers
  3925. if [ "$B_FORCE_UPDATE" == 'true' ];then
  3926. check_update_script "$SCRIPT_NAME" "$SCRIPT_DOWNLOAD" 'default server'
  3927. fi
  3928. check_set_distro
  3929. # initial systemd handling
  3930. if [ -n "$( type -p systemctl )" ];then
  3931. B_SYSTEMD='true'
  3932. #systemdData="$( systemctl list-units --type=target 2>/dev/null)"
  3933. #if [ -n "$( grep -sE '^sysinit.target.*[[:space:]]active' <<< "$systemdData" )" ];then
  3934. # this is totally reliable, shows systemd or init
  3935. systemdData="$( cat /proc/1/comm 2>/dev/null)"
  3936. if [ -n "$( grep 'systemd' <<< "$systemdData" )" ];then
  3937. B_SYSTEMD_SYSINIT='true'
  3938. fi
  3939. systemdData="$( systemctl status graphical.target 2>/dev/null )"
  3940. if [ -n "$( grep -Eis '^[[:space:]]*Loaded:[[:space:]]*loaded' <<< "$systemdData" )" ];then
  3941. B_SYSTEMD_GRAPHICAL='true'
  3942. fi
  3943. fi
  3944. # not making this elif for now because who knows what ubuntu will actually do with upstart
  3945. if [ -n "$( type -p initctl )" ];then
  3946. B_UPSTART='true'
  3947. fi
  3948. # make sure Xorg is installed
  3949. if [ -z "$( which Xorg )" ];then
  3950. error_handler 244
  3951. fi
  3952. # make sure xorg.conf exists, with xorg > 1.4 exception to handle null xorg.conf
  3953. if [ ! -f $EXXC -a -z "$( echo $X_VERSION | grep -E '[1-4]\.[0-9]+(\.[0-9]+)?' )" ];then
  3954. error_handler 249
  3955. fi
  3956. # double check only 2.6 or newer series kernels, note double [[ and <
  3957. if [[ "$KERNEL_BASE" < 2.6 ]];then
  3958. error_handler 243
  3959. fi
  3960.  
  3961. cleanup_update_files
  3962. check_script_depends
  3963.  
  3964. # only support current systems, xorg >= 7.1/1.x
  3965. if [ -z "$X_VERSION" ];then
  3966. error_handler 242
  3967. fi
  3968. # this corrects a stupid mistake I made
  3969. rm -f *-sgfxi.log # was creating log files in /usr/local/bin
  3970. # test to see if any dm is running, we'll shutdown all wm later though
  3971. if [ -n "$DISPLAY" -a "$B_SKIP_X_TEST" != 'true' -a "$B_KERNEL_MODULE_ONLY" != 'true' \
  3972. -a "$B_PRINT_VER" != 'true' -a "$B_LAUNCH_FROM_X" != 'true' ];then
  3973. error_handler 250
  3974. fi
  3975. case $SYSTEM_BASE in
  3976. ubuntu)
  3977. # we need to confirm that restricted repos are enabled before continuing
  3978. if [ "$B_USE_DISTRO_DRIVER" == 'true' ];then
  3979. update_to_nonfree_sources
  3980. fi
  3981. ;;
  3982. esac
  3983. }
  3984.  
  3985. get_current_runlevel()
  3986. {
  3987. local currentRunlevel=$( echo $(runlevel) | awk '{print $NF}' )
  3988. echo $currentRunlevel
  3989. }
  3990.  
  3991. # this is a quick / dirty check so sgfxi can know if a user system
  3992. # has a live connection or not. This is mainly for logging/debugging
  3993. check_connection()
  3994. {
  3995. local checkUrl=${SCRIPT_DOWNLOAD_DATA}connection-test result=0
  3996. local ua='-U s-tools/sgfxi-data.connection-test'
  3997.  
  3998. wget $ua -q -t 1 -T 2 --spider $checkUrl || result=$?
  3999. echo $result
  4000. }
  4001.  
  4002. ## basic system requirements for this script to run, first so user doesn't
  4003. ## have to be root or out of x to get basic failure information
  4004. check_set_distro()
  4005. {
  4006. local lsbOsrData='' workingId=''
  4007. local isStable='' isTesting='' isUnstable=''
  4008. local etcIssue=$( cat /etc/issue 2>/dev/null )
  4009.  
  4010. # make sure that it's a debian/arch/ubuntu based system
  4011. # note that mint/ubuntu have file /etc/debian_version so we need to be careful here
  4012. if [ -n "$( grep -si 'buntu' <<< $etcIssue )" ];then
  4013. workingId='ubuntu'
  4014. # mint test, note that for new lmde we are treating it as pure debian
  4015. elif [ -n "$( grep -si 'mint' <<< $etcIssue )" -a -z "$( grep -si 'Linux Mint Debian' <<< $etcIssue )" ];then
  4016. workingId='linuxmint'
  4017. # debian defaults, might miss other ubuntu derived distros but those will
  4018. # be handled as we find them, empirically.
  4019. elif [ -f "$EDV" -o -f "$EDVV" ];then # edvv is devuan
  4020. # set files to ram first, no need to keep reading them
  4021. local edvContent='' easContent='' eaaContent='' edvFile=''
  4022.  
  4023. if [ -f "$EDV" ];then
  4024. edvFile=$EDV
  4025. elif [ -f "$EDVV" ];then
  4026. edvFile=$EDVV
  4027. fi
  4028.  
  4029. workingId='debian'
  4030.  
  4031. if [ -n "$( grep -si 'Linux Mint Debian' <<< $etcIssue )" ];then
  4032. workingId='linuxmint-debian'
  4033. fi
  4034.  
  4035. if [ -f "$edvFile" ];then
  4036. edvContent="$( cat $edvFile )"
  4037. fi
  4038. if [ -f "$EAS" -o -d "$EAS.d" ];then
  4039. easContent="$( cat $EAS $EAS.d/*.list 2>/dev/null )"
  4040. fi
  4041. if [ -f "$EAA" ];then
  4042. eaaContent="$( cat $EAA )"
  4043. fi
  4044.  
  4045. # these tests will be improved over time, but are ok for now
  4046. local isEtch=$( grep -is '^4.' <<< "$edvContent" )
  4047. local isLenny=$( grep -is '^5.' <<< "$edvContent" )
  4048. local isSqueeze=$( grep -Eis '^(squeeze|6\.)' <<< "$edvContent" )
  4049. local isWheezy=$( grep -Eis '^(wheezy|7\.)' <<< "$edvContent" )
  4050. local isJessie=$( grep -Eis '^(jessie|8\.)' <<< "$edvContent" )
  4051. local isStretch=$( grep -Eis '^(stretch|9\.)' <<< "$edvContent" )
  4052.  
  4053. # first tests sources
  4054. local isStable=$( grep -Esiw '^[[:space:]]*deb' <<< "$easContent" | grep -Eiv "$NON_DEBIAN_PATTERN" | grep -Eicw '(stable|wheezy|squeeze|lenny|etch|jesse)' )
  4055. local isTesting=$( grep -Esiw '^[[:space:]]*deb' <<< "$easContent" | grep -Eiv "$NON_DEBIAN_PATTERN" | grep -Eicw '(stretch|testing)' )
  4056. local isUnstable=$( grep -Esiw '^[[:space:]]*deb' <<< "$easContent" | grep -Eiv "$NON_DEBIAN_PATTERN" | grep -Eicw '(sid|unstable)' )
  4057.  
  4058. # then test conf for default version
  4059. local isStableDefault=$( grep -Esi 'APT::Default-Release[[:space:]]"(stable|etch|lenny|squeeze|wheezy|jesse)"' <<< "$eaaContent" )
  4060. local isTestingDefault=$( grep -Esi 'APT::Default-Release[[:space:]]"(testing|stretch)"' <<< "$eaaContent" )
  4061. local isUnstableDefault=$( grep -Esi 'APT::Default-Release[[:space:]]"(sid|unstable)"' <<< "$eaaContent" )
  4062. # arch tests
  4063. elif [ -f "$EAR" ] || [ -n "$( grep -si '^arch' <<< $etcIssue )" ];then
  4064. workingId='arch'
  4065. elif [ -f "$EFR" ] || [ -n "$( grep -si '^fedora' <<< $etcIssue )" ];then
  4066. workingId='fedora'
  4067. else
  4068. error_handler 252
  4069. fi
  4070.  
  4071. # ideally all distros would use lsb/os-release, but sadly they don't.
  4072. if [ -s $ELR ];then
  4073. lsbOsrData="$( cat $ELR )"
  4074. DISTRIB_CODENAME=$( grep 'DISTRIB_CODENAME' <<< "$lsbOsrData" | cut -d '=' -f 2 | tr '[A-Z]' '[a-z]' )
  4075. DISTRIB_ID=$( grep 'DISTRIB_ID' <<< "$lsbOsrData" | cut -d '=' -f 2 | tr '[A-Z]' '[a-z]' )
  4076. DISTRIB_RELEASE=$( grep 'DISTRIB_RELEASE' <<< "$lsbOsrData" | cut -d '=' -f 2 | tr '[A-Z]' '[a-z]' )
  4077. # elif [ -s $EOR ];then
  4078. # lsbOsrData="$( cat $EOR )"
  4079. # # DISTRIB_CODENAME=$( grep 'DISTRIB_CODENAME' <<< "$lsbOsrData" | cut -d '=' -f 2 | tr '[A-Z]' '[a-z]' )
  4080. # DISTRIB_ID=$( grep '^ID' <<< "$lsbOsrData" | cut -d '=' -f 2 | tr '[A-Z]' '[a-z]' | tr '/' '-' )
  4081. # DISTRIB_RELEASE=$( grep '^PRETTY_NAME' <<< "$lsbOsrData" | awk '{print $NF}' | tr '[A-Z]' '[a-z]' | tr '/' '-' )
  4082. fi
  4083.  
  4084. case $workingId in
  4085. arch)
  4086. APT_TYPE='pacman'
  4087. DISTRO_FGLRX=$ARCH_FGLRX
  4088. DISTRO_NVIDIA=$ARCH_NVIDIA
  4089. SYSTEM_BASE='arch'
  4090. SYSTEM_CODENAME='arch'
  4091. SCRIPT_HOME='/usr/bin'
  4092. X_NAME='Xorg'
  4093. ;;
  4094. debian|linuxmint-debian)
  4095. DISTRO_FGLRX=$DEBIAN_FGLRX
  4096. DISTRO_NVIDIA=$DEBIAN_NVIDIA
  4097. FG_DISTRIB_ID='Debian'
  4098. SYSTEM_BASE='debian' # debian not using elr file yet
  4099. if [ "$workingId" == 'linuxmint-debian' ];then
  4100. APT_TYPE='apt-get'
  4101. fi
  4102. # set system type. This test will never be perfect, but it's a good approximation
  4103. if [ -n "$isEtch" -o -n "$isLenny" -o -n "$isSqueeze" -o -n "$isWheezy" -o -n "$isJessie" -o -n "$isStableDefault" ] || [ "$isStable" -gt 0 -a "$isUnstable" -eq 0 -a "$isTesting" -eq 0 ];then
  4104. if [ -n "$isEtch" ];then
  4105. FG_DISTRIB_CODENAME='etch'
  4106. SYSTEM_CODENAME='etch'
  4107. elif [ -n "$isLenny" ];then
  4108. FG_DISTRIB_CODENAME='lenny' # note: 'stable' breaks the installer
  4109. SYSTEM_CODENAME='lenny'
  4110. elif [ -n "$isSqueeze" ];then
  4111. FG_DISTRIB_CODENAME='squeeze' # note: 'stable' breaks the installer
  4112. SYSTEM_CODENAME='squeeze'
  4113. elif [ -n "$isWheezy" ];then
  4114. FG_DISTRIB_CODENAME='wheezy' # note: 'stable' breaks the installer
  4115. SYSTEM_CODENAME='wheezy'
  4116. elif [ -n "$isJesse" ];then
  4117. FG_DISTRIB_CODENAME='jesse' # note: 'stable' breaks the installer
  4118. SYSTEM_CODENAME='jesse'
  4119. else
  4120. FG_DISTRIB_CODENAME='stable'
  4121. SYSTEM_CODENAME='stable'
  4122. fi
  4123. elif [ "$isUnstable" -eq 0 -o -n "$isTestingDefault" ] && [ -n "$isStretch" -o "$isTesting" -gt 0 ];then
  4124. FG_DISTRIB_CODENAME='sid'
  4125. SYSTEM_CODENAME='testing'
  4126. else
  4127. FG_DISTRIB_CODENAME='sid'
  4128. SYSTEM_CODENAME='sid'
  4129. fi
  4130. X_NAME='X'
  4131. # these will be used for various advanced tests in some components
  4132. # commented out because debian now uses os-release by default
  4133. # if [ -z "$DISTRIB_ID" ];then
  4134. if [ -f /etc/siduction-version ];then
  4135. DISTRIB_ID='siduction'
  4136. elif [ -f /etc/aptosid-version ];then
  4137. DISTRIB_ID='aptosid'
  4138. elif [ -f /etc/sidux-version ];then
  4139. DISTRIB_ID='sidux'
  4140. elif [ -f /etc/antix-version ];then
  4141. DISTRIB_ID='antix'
  4142. elif [ -f /etc/lsb-release-crunchbang ];then
  4143. DISTRIB_ID='crunchbang'
  4144. fi
  4145. # fi
  4146. ;;
  4147. fedora)
  4148. APT_TYPE='yum'
  4149. DISTRO_FGLRX=$FEDORA_FGLRX
  4150. DISTRO_NVIDIA=$FEDORA_NVIDIA
  4151. FG_DISTRIB_ID='Fedora'
  4152. FG_DISTRIB_CODENAME=''
  4153. SYSTEM_BASE='fedora'
  4154. if [ -f "$EFR" ];then
  4155. DISTRIB_CODENAME=$( grep '^DISTRIB_CODENAME' $EFR | cut -d '=' -f 2 | tr '[A-Z]' '[a-z]' | awk '{print $1}' )
  4156. SYSTEM_CODENAME=$DISTRIB_CODENAME
  4157. # DISTRIB_CODENAME=$( grep -si 'Fedora' $EFR | sed -r 's/Fedora.*\((.*)\)/\1/i' )
  4158. # SYSTEM_CODENAME=$( grep -si 'Fedora' $EFR | sed -r 's/Fedora.*[[:space:]]([0-9]+)[[:space:]]\(.*\)/\1/i' )
  4159. fi
  4160. X_NAME='X'
  4161. ;;
  4162. linuxmint)
  4163. APT_TYPE='apt-get'
  4164. DISTRO_FGLRX=$UBUNTU_FGLRX
  4165. DISTRO_NVIDIA=$UBUNTU_NVIDIA
  4166. FG_DISTRIB_ID='Ubuntu'
  4167. SYSTEM_BASE='ubuntu'
  4168. # need to double check here for fglrx deb builder
  4169. case $DISTRIB_RELEASE in
  4170. 6) FG_DISTRIB_CODENAME='intrepid'
  4171. SYSTEM_CODENAME='intrepid'
  4172. ;;
  4173. 7) FG_DISTRIB_CODENAME='jaunty'
  4174. SYSTEM_CODENAME='jaunty'
  4175. ;;
  4176. 8) FG_DISTRIB_CODENAME='karmic'
  4177. SYSTEM_CODENAME='karmic'
  4178. ;;
  4179. 9) FG_DISTRIB_CODENAME='lucid'
  4180. SYSTEM_CODENAME='lucid'
  4181. ;;
  4182. 10)FG_DISTRIB_CODENAME='maverick'
  4183. SYSTEM_CODENAME='maverick'
  4184. ;;
  4185. 11)FG_DISTRIB_CODENAME='natty'
  4186. SYSTEM_CODENAME='natty'
  4187. ;;
  4188. esac
  4189. X_NAME='X'
  4190. ;;
  4191. ubuntu)
  4192. DISTRO_FGLRX=$UBUNTU_FGLRX
  4193. DISTRO_NVIDIA=$UBUNTU_NVIDIA
  4194. FG_DISTRIB_ID='Ubuntu'
  4195. FG_DISTRIB_CODENAME=$DISTRIB_CODENAME
  4196. SYSTEM_BASE='ubuntu'
  4197. SYSTEM_CODENAME=$DISTRIB_CODENAME
  4198. X_NAME='X'
  4199. if [ -f /etc/lsb-release-crunchbang ];then
  4200. DISTRIB_ID='crunchbang-ubuntu'
  4201. fi
  4202. ;;
  4203. *)
  4204. ## basic system requirements for this script to run, first so user doesn't
  4205. ## have to be root or out of x to get basic failure information
  4206. # make sure that it's a debian based system
  4207. error_handler 252
  4208. ;;
  4209. esac
  4210. if [ -z "$DISTRIB_ID" ];then
  4211. DISTRIB_ID=$SYSTEM_BASE
  4212. fi
  4213. if [ -z "$DISTRIB_CODENAME" ];then
  4214. DISTRIB_CODENAME=$SYSTEM_CODENAME
  4215. fi
  4216. SIS=$DISTRIB_ID-$DISTRIB_CODENAME-$BITS
  4217. }
  4218.  
  4219. check_run_package_tools()
  4220. {
  4221. eval $LOGPS
  4222. local makePath=$( type -p make )
  4223. local patchPath=$( type -p patch )
  4224.  
  4225. if [ -z "$makePath" ];then
  4226. if [ -n "$( check_package_status 'make' 'c' )" ];then
  4227. install_package 'make'
  4228. fi
  4229. fi
  4230. if [ -z "$patchPath" ];then
  4231. if [ -n "$( check_package_status 'patch' 'c' )" ];then
  4232. install_package 'patch'
  4233. fi
  4234. fi
  4235.  
  4236. eval $LOGPE
  4237. }
  4238.  
  4239. check_script_depends()
  4240. {
  4241. eval $LOGPS
  4242. local wgetPath=$( type -p wget )
  4243. local logrotatePath=$( type -p logrotate )
  4244.  
  4245. if [ -z "$wgetPath" ];then
  4246. if [ -n "$( check_package_status 'wget' 'c' )" ];then
  4247. install_package 'wget'
  4248. fi
  4249. fi
  4250. if [ -z "$logrotatePath" ];then
  4251. if [ -n "$( check_package_status 'logrotate' 'c' )" ];then
  4252. install_package 'logrotate'
  4253. fi
  4254. fi
  4255. eval $LOGPE
  4256. }
  4257.  
  4258. check_driver_install_tools()
  4259. {
  4260. eval $LOGPS
  4261.  
  4262. local fakerootPath=$( type -p fakeroot )
  4263.  
  4264. # nvidia and fglrx tools check_package_status
  4265. case $SYSTEM_BASE in
  4266. debian|ubuntu)
  4267. if [ -z "$( check_package_status 'module-assistant' 'i' )" ];then
  4268. if [ -n "$( check_package_status 'module-assistant' 'c' )" ];then
  4269. install_package 'module-assistant'
  4270. fi
  4271. fi
  4272. if [ -z "$( check_package_status 'build-essential' 'i' )" ];then
  4273. if [ -n "$( check_package_status 'build-essential' 'c' )" ];then
  4274. install_package 'build-essential'
  4275. fi
  4276. fi
  4277.  
  4278. ;;
  4279. # arch)
  4280. # if [ -z "$( check_package_status 'gcc' 'i' )" ];then
  4281. # if [ -n "$( check_package_status 'gcc' 'c' )" ];then
  4282. # install_package 'gcc'
  4283. # fi
  4284. # fi
  4285. # ;;
  4286. esac
  4287.  
  4288. if [ -z "$fakerootPath" ];then
  4289. if [ -n "$( check_package_status 'fakeroot' 'c' )" ];then
  4290. install_package 'fakeroot'
  4291. fi
  4292. fi
  4293. # note wget test needs to be in first main test function
  4294.  
  4295. if [ "$CARD" == $NVIDIA ];then
  4296. :
  4297. # fglrx tools and tests
  4298. elif [ "$CARD" == $FGLRX ];then
  4299. case $SYSTEM_BASE in
  4300. debian|ubuntu)
  4301. if [ -z "$( check_package_status 'debhelper' 'i' )" ];then
  4302. if [ -n "$( check_package_status 'debhelper' 'c' )" ];then
  4303. install_package 'debhelper'
  4304. fi
  4305. fi
  4306. # presence of this package will break fglrx install
  4307. if [ -n "$( check_package_status 'dpkg-cross' 'i' )" ];then
  4308. remove_package 'dpkg-cross' "$CARD"
  4309. fi
  4310. if [ -z "$( check_package_status 'libstdc++5' 'i' )" ];then
  4311. if [ -n "$( check_package_status 'libstdc++5' 'c' )" ];then
  4312. install_package 'libstdc++5'
  4313. fi
  4314. fi
  4315. if [ -z "$( check_package_status 'libstdc++6' 'i' )" ];then
  4316. if [ -n "$( check_package_status 'libstdc++6' 'c' )" ];then
  4317. install_package 'libstdc++6'
  4318. fi
  4319. fi
  4320. if [ -z "$( check_package_status 'unzip' 'i' )" ];then
  4321. if [ -n "$( check_package_status 'unzip' 'c' )" ];then
  4322. install_package 'unzip'
  4323. fi
  4324. fi
  4325. ;;
  4326. arch)
  4327. if [ -z "$( check_package_status 'unzip' 'i' )" ];then
  4328. if [ -n "$( check_package_status 'unzip' 'c' )" ];then
  4329. install_package 'unzip'
  4330. fi
  4331. fi
  4332. ;;
  4333. esac
  4334. fi
  4335.  
  4336. eval $LOGPE
  4337. }
  4338.  
  4339. # compare 2 dot [5.34.6] or 1/0 dot [3.45, 3] version numbers
  4340. # return codes: 0 - $1 > $2; 1 - $1 == $2; 2 - $1 < $2
  4341. # note: this also works for one dot, like 3.4, and for 0 dot, like 3
  4342. # note: this function will always be sent . type numbers, and it handles any
  4343. # localization re decimal indicators internally, otherwise it's too much of a pain.
  4344. # Handles cases like 13.10 > 13.9 as well, ie, 10>9
  4345. # Make sure all numbers passed to this function only contain numbers/dots, like: 195.23.23
  4346. # if any non numeric values are encountered the function will return 3, which means one of the
  4347. # numbers was not numeric almost certainly.
  4348. compare_numbers()
  4349. {
  4350. eval $LOGUS
  4351.  
  4352. # first we need to determine what the base system is using for decimal indicator
  4353. local returnValue=''
  4354. local oneTwo=0 oneThree=0 twoTwo=0 twoThree=0
  4355. local b_debug='false'
  4356. # local decimalType=$( echo 1 | awk '{total = 1 / 2; print total}' | grep -Eo '(\.|,)' )
  4357.  
  4358. # next we'll get the raw data and transate it into separate numbers, this also handles cases
  4359. # like 13.10 is greater than 13.9 for versions
  4360. local oneOne=$( cut -d '.' -f 1 <<< $1 )
  4361. local twoOne=$( cut -d '.' -f 1 <<< $2 )
  4362. if [ -z "$oneOne" ];then
  4363. oneOne=0
  4364. fi
  4365. if [ -z "$twoOne" ];then
  4366. twoOne=0
  4367. fi
  4368.  
  4369. returnValue=$( number_compare $oneOne $twoOne )
  4370. # only do more tests if first numbers are equal
  4371. if [ "$returnValue" -eq 1 ];then
  4372. oneTwo=$( cut -d '.' -f 2 <<< $1 )
  4373. twoTwo=$( cut -d '.' -f 2 <<< $2 )
  4374. if [ -z "$oneTwo" ];then
  4375. oneTwo=0
  4376. fi
  4377. if [ -z "$twoTwo" ];then
  4378. twoTwo=0
  4379. fi
  4380.  
  4381. returnValue=$( number_compare $oneTwo $twoTwo )
  4382. # only do more tests if second numbers are equal
  4383. if [ "$returnValue" -eq 1 ];then
  4384. oneThree=$( cut -d '.' -f 3 <<< $1 )
  4385. twoThree=$( cut -d '.' -f 3 <<< $2 )
  4386. if [ -z "$oneThree" ];then
  4387. oneThree=0
  4388. fi
  4389. if [ -z "$twoThree" ];then
  4390. twoThree=0
  4391. fi
  4392. returnValue=$( number_compare $oneThree $twoThree )
  4393. fi
  4394. fi
  4395.  
  4396. if [ "$b_debug" == 'true' ];then
  4397. echo "oneOne: $oneOne"
  4398. echo "oneTwo: $oneTwo"
  4399. echo "oneThree: $oneThree"
  4400. echo "twoOne: $twoOne"
  4401. echo "twoTwo: $twoTwo"
  4402. echo "twoThree: $twoThree"
  4403. echo "returnValue $returnValue"
  4404. fi
  4405.  
  4406. echo $returnValue
  4407. log_function_data "returnValue: $returnValue"
  4408. eval $LOGUE
  4409. }
  4410. # args: $1 first number; $2 -second number
  4411. number_compare()
  4412. {
  4413. local compareValue=3 # 3 will be used for debugging of non numberic numbers etc
  4414.  
  4415. if [ "$1" -gt "$2" ];then
  4416. compareValue=0
  4417. elif [ "$1" -eq "$2" ];then
  4418. compareValue=1
  4419. elif [ "$1" -lt "$2" ];then
  4420. compareValue=2
  4421. fi
  4422. echo $compareValue
  4423. }
  4424. ## DEBUGGER
  4425. # compare_numbers 13.101.233 13.101.222 ;exit
  4426.  
  4427. # for smxi launch in X
  4428. launch_from_X()
  4429. {
  4430. if [ "$B_LAUNCH_FROM_X" == 'true' ];then
  4431. if [ "$( tty | grep pts )" ];then
  4432. #TERM=linux
  4433. TERM=1
  4434. exec openvt -s bash -c "$SCRIPT_NAME $@; bash"
  4435. fi
  4436. fi
  4437. }
  4438.  
  4439. ### -------------------------------------------------------------------
  4440. ### package manager tools
  4441. ### -------------------------------------------------------------------
  4442.  
  4443. check_apt_aptitude()
  4444. {
  4445. eval $LOGUS
  4446. local opt='' managers='apt-get aptitude quit'
  4447. local aptPref=$( get_set_prefs 'get' 'apt-type' | cut -d '=' -f 2 | grep -E '^(apt-get|aptitude)$' )
  4448.  
  4449. # always override first of all
  4450. if [ -n "$aptPref" ];then
  4451. APT_TYPE=$aptPref
  4452. else
  4453. if [ -f /var/log/aptitude ];then
  4454. case $SYSTEM_BASE in
  4455. debian)
  4456. # leave mint debian using apt-get
  4457. if [ -z "$( type -P apt )" ];then
  4458. echo $LINE
  4459. echo "${S}It appears you are using aptitude. It is not good to mix apt-get and aptitude."
  4460. echo "Please pick your preferred package manager before you continue, or exit now."
  4461. echo
  4462. echo "Your selection (for example: ${C}apt-type=apt-get${S}) will be stored in ${C}/etc/smxi.conf${S}"
  4463. echo "${C}smxi${S} will also use this choice for its default package manager, so make sure it's correct."
  4464. echo $LINE
  4465.  
  4466. select opt in $managers
  4467. do
  4468. case $opt in
  4469. apt-get|aptitude)
  4470. APT_TYPE=$opt
  4471. log_function_data "Selected package manager: $opt"
  4472. get_set_prefs 'set' "apt-type=$opt"
  4473. ;;
  4474. quit)
  4475. echo "${S}Ok, figure it out and try again later...${N}"
  4476. exit 0
  4477. ;;
  4478. *)
  4479. echo "${E}You have to pick one before you can continue!${N}"
  4480. ask_apt_aptitude
  4481. ;;
  4482. esac
  4483. break
  4484. done
  4485. else
  4486. log_function_data "Derived Mint Debian using apt wrapper - default to apt-get."
  4487. fi
  4488. ;;
  4489. ubuntu)
  4490. # going to ignore linuxmint's apt wrapper method
  4491. if [ -z "$( type -P apt )" ];then
  4492. APT_TYPE='aptitude'
  4493. log_function_data "Ubuntu hardset to aptitude. If not ubuntu then error."
  4494. else
  4495. log_function_data "Derived Ubuntu using apt wrapper - default to apt-get."
  4496. fi
  4497. ;;
  4498. esac
  4499. fi
  4500. fi
  4501.  
  4502. case $APT_TYPE in
  4503. aptitude)
  4504. WITHOUT_RECOMMENDS='--without-recommends'
  4505. ;;
  4506. apt-get)
  4507. WITHOUT_RECOMMENDS='--no-install-recommends'
  4508. ;;
  4509. esac
  4510.  
  4511. eval $LOGUE
  4512. }
  4513.  
  4514. # Returns null if package is not available in user system apt.
  4515. # args: $1 - package to test; $2 c/i
  4516. check_package_status()
  4517. {
  4518. eval $LOGUS
  4519. local packageVersion='' statusType='' cacheData=''
  4520. local poolPackageCount=0
  4521.  
  4522. case $2 in
  4523. c) statusType='Candidate:'
  4524. ;;
  4525. i) statusType='Installed:'
  4526. ;;
  4527. esac
  4528. case $APT_TYPE in
  4529. apt-get|aptitude)
  4530. LC_ALL= LC_CTYPE= LC_MESSAGES= LANG= cacheData="$( apt-cache policy $1 2>/dev/null )"
  4531.  
  4532. # we need to filter out all cases were the only instance in apt is the locally installed
  4533. # version, ie: *** 2.13 0 \ 100 /var/lib/dpkg/status is the only value returned
  4534. poolPackageCount=$( grep -Es "^[[:space:]]*[0-9]{3}" <<< "$cacheData" | grep -vcE "^[[:space:]]*100[[:space:]]" )
  4535.  
  4536. packageVersion=$( awk '
  4537. /'$statusType'/ && !/(\(None\)|\(none\))/ {print $2}' <<< "$cacheData" )
  4538.  
  4539. # if either none found, or only a local apt version available, return null
  4540. if [ "$statusType" == 'Candidate:' -a "$poolPackageCount" -eq 0 ];then
  4541. packageVersion=''
  4542. fi
  4543. ;;
  4544. pacman)
  4545. case $2 in
  4546. c)
  4547. LC_ALL= LC_CTYPE= LC_MESSAGES= LANG= packageVersion=$( pacman -Si "$1" 2>/dev/null | grep -i '^Version' | awk '{print $3}' )
  4548. ;;
  4549. i)
  4550. LC_ALL= LC_CTYPE= LC_MESSAGES= LANG= packageVersion=$( pacman -Q "$1" 2>/dev/null | awk '{print $2}' )
  4551. ;;
  4552. esac
  4553. ;;
  4554. yum)
  4555. case $2 in
  4556. c)
  4557. LC_ALL= LC_CTYPE= LC_MESSAGES= LANG= packageVersion=$( yum list "$1" 2>/dev/null | grep -Esvi '(presto|packagekit|packages)'| awk '{print $2}' )
  4558. ;;
  4559. i)
  4560. LC_ALL= LC_CTYPE= LC_MESSAGES= LANG= packageVersion=$( rpm -qa 2>/dev/null | grep -Esvi '(presto|packagekit|packages)' | grep -is "$1" )
  4561. ;;
  4562. esac
  4563. ;;
  4564. esac
  4565.  
  4566. echo $packageVersion
  4567. log_function_data "Package Version: $packageVersion"
  4568. eval $LOGUE
  4569. }
  4570.  
  4571. # arg: $1 - package name; $2 - /experimental/unstable/testing/stable; $3 - reinstall
  4572. # optional args. Note that if you use 3, you have to set 2 by '' if blank.
  4573. install_package()
  4574. {
  4575. eval $LOGUS
  4576. local distroVersion='' optionalArgs=''
  4577. local useUntrusted='' install=''
  4578. local packageInstalled=''
  4579. local update='' install='' doYes='' useUntrusted=''
  4580.  
  4581. case $APT_TYPE in
  4582. aptitude)
  4583. doYes=''
  4584. install='install'
  4585. update='update'
  4586. if [ "$SYSTEM_CODENAME" == 'etch' ];then
  4587. useUntrusted='' # etch aptitude doesn't support this
  4588. else
  4589. useUntrusted='--allow-untrusted'
  4590. fi
  4591. ;;
  4592. apt-get)
  4593. doYes='-y'
  4594. install='install'
  4595. update='update'
  4596. useUntrusted='--allow-unauthenticated'
  4597. ;;
  4598. pacman)
  4599. doYes=''
  4600. update='-Sy'
  4601. install='-S'
  4602. useUntrusted=''
  4603. ;;
  4604. yum)
  4605. doYes='' # note: -y is used, but for debugging we'll wait to add that.
  4606. update=''
  4607. install='install'
  4608. useUntrusted='' # check later
  4609. ;;
  4610. esac
  4611. if [ -n "$update" ];then # yum has no update repo data command, it does it automatically
  4612. update_package_manager "$update"
  4613. fi
  4614.  
  4615. # this will force install of sid to get rid of experimental if required
  4616. case $SYSTEM_BASE in
  4617. debian)
  4618. if [ -n "$2" ];then
  4619. distroVersion="/$2" # --force-yes requird to avoid apt downgrade error
  4620. fi
  4621. ;;
  4622. esac
  4623. # only do reinstall if arg is set and package is installed
  4624. case "$3" in
  4625. reinstall)
  4626. packageInstalled=$( check_package_status "$1" 'i' )
  4627. if [ -n "$packageInstalled" ];then
  4628. case $APT_TYPE in
  4629. aptitude)
  4630. optionalArgs=''
  4631. install='reinstall'
  4632. ;;
  4633. apt-get)
  4634. optionalArgs=' --reinstall '
  4635. ;;
  4636. pacman)
  4637. optionalArgs=''
  4638. ;;
  4639. yum)
  4640. optionalArgs=''
  4641. install='reinstall'
  4642. ;;
  4643. esac
  4644. fi
  4645. ;;
  4646. *)
  4647. case $APT_TYPE in
  4648. pacman)
  4649. optionalArgs=$3
  4650. ;;
  4651. esac
  4652. ;;
  4653. esac
  4654. # then install the package with all options
  4655. log_function_data "Install command for $APT_TYPE: $install;optionalArgs: $optionalArgs;UseUntrusted: $useUntrusted;WithoutRecommends: $WITHOUT_RECOMMENDS;doYes: $doYes; packages: $1$distroVersion"
  4656. echo "${S}Updating required package ${C}$1${S} now...${N}"
  4657. $APT_TYPE $install $useUntrusted $WITHOUT_RECOMMENDS $doYes $optionalArgs $1$distroVersion || error_handler 200 "$1"
  4658. eval $LOGUE
  4659. }
  4660.  
  4661. # args: $1 - update type / name
  4662. update_package_manager()
  4663. {
  4664. eval $LOGUS
  4665. if [ "$B_UPDATED" != 'true' ];then
  4666. $APT_TYPE $1
  4667. # for now not going to exit with real error, just want failures logged
  4668. if [ "$?" -eq 0 ];then
  4669. echo "${C}$APT_TYPE $1 ${S}successful. Continuing...${N}"
  4670. B_UPDATED='true'
  4671. log_function_data "Update $APT_TYPE successful"
  4672. else
  4673. echo "${C}$APT_TYPE $1 ${E}Failed. Continuing anyway...${N}"
  4674. log_function_data "Update $APT_TYPE error: $?"
  4675. fi
  4676. fi
  4677. eval $LOGUE
  4678. }
  4679.  
  4680. # args: $1 - package to test for; $2 - excludes from list
  4681. list_installed_packages()
  4682. {
  4683. eval $LOGUS
  4684. local packageList='' excludes=$2
  4685. if [ -z "$excludes" ];then
  4686. excludes='blanketyblank'
  4687. fi
  4688.  
  4689. case $APT_TYPE in
  4690. apt-get|aptitude)
  4691. packageList=$( dpkg -l | awk '{print $2}' | grep -Ei "$1" | grep -Ev "$excludes" )
  4692. ;;
  4693. pacman)
  4694. packageList=$( pacman -Q | awk '{print $1}' | grep -Ei "$1" | grep -Ev "$excludes" )
  4695. ;;
  4696. yum)
  4697. packageList=$( rpm -qa | awk '{print $1}' | grep -Ei "$1" | grep -Ev "$excludes" )
  4698. ;;
  4699. esac
  4700. log_function_data "packageList: $packageList"
  4701. echo $packageList
  4702. eval $LOGUE
  4703. }
  4704.  
  4705. # $1 - package(s) to remove; $2 - extra information; $3 - no-loop: remove all at once
  4706. # $4 optional: extra args
  4707. remove_package()
  4708. {
  4709. eval $LOGUS
  4710. local response='' package='' purge='' extraInfo="$2" doYes=''
  4711. case $APT_TYPE in
  4712. aptitude|apt-get)
  4713. purge='purge'
  4714. case $4 in
  4715. yes) doYes='-y'
  4716. ;;
  4717. esac
  4718. ;;
  4719. pacman)
  4720. purge='-R'
  4721. ;;
  4722. yum)
  4723. purge='erase'
  4724. ;;
  4725. esac
  4726.  
  4727. if [ -n "$extraInfo" ];then
  4728. extraInfo=" $extraInfo"
  4729. fi
  4730.  
  4731. echo $MLINE
  4732. echo "${M}You will need to remove the following package(s): ${C}$1"
  4733. echo "${M}in order to proceed with your${C}$extraInfo${M} driver install${N}"
  4734. echo $MLINE
  4735. if [ "$3" == 'no-loop' ];then
  4736. echo "${S}Removing ${C}$1${S}...${N}"
  4737. $APT_TYPE $purge $doYes $1 || error_handler 190 "$1"
  4738. else
  4739. for package in $1
  4740. do
  4741. if [ -n "$( check_package_status "$package" 'i' )" ];then
  4742. echo "${S}Removing ${C}$package${S}...${N}"
  4743. $APT_TYPE $purge $doYes $package || error_handler 190 "$package"
  4744. else
  4745. echo "${S}The package ${C}$package${S} is not installed, continuing...${N}"
  4746. fi
  4747. done
  4748. fi
  4749. echo "${S}Package(s) removed successfully, continuing with driver install.${N}"
  4750. eval $LOGUE
  4751. }
  4752.  
  4753. # args: $1 - package to hold. sets hold for apt-get/aptitude
  4754. hold_package()
  4755. {
  4756. eval $LOGUS
  4757. # first set for aptitude syntax
  4758. case $APT_TYPE in
  4759. aptitude|apt-get)
  4760. if [ "$APT_TYPE" == 'aptitude' ];then
  4761. $APT_TYPE hold $1
  4762. fi
  4763. # then set hold into dpkg
  4764. echo $1 hold | dpkg --set-selections
  4765. ;;
  4766. pacman)
  4767. :
  4768. ;;
  4769. yum)
  4770. :
  4771. ;;
  4772. esac
  4773. eval $LOGUE
  4774. }
  4775.  
  4776. update_to_nonfree_sources()
  4777. {
  4778. eval $LOGPS
  4779.  
  4780. local isFree=0 i='' counter=0
  4781. local eas='/etc/apt/sources.list'
  4782. local easdl='/etc/apt/sources.list.d/debian.list'
  4783. local eassl='/etc/apt/sources.list.d/aptosid.list'
  4784. local aptProx=''
  4785. local ubRestricted='' ubMultiverse='' ubUniverse=''
  4786. local yumFreeRepo='' yumNonFreeRepo='' yumList='' bRepoAdded='false'
  4787.  
  4788. if [ "$B_USE_DISTRO_DRIVER" == 'true' ];then
  4789. case $SYSTEM_BASE in
  4790. debian)
  4791. # loop through possible files to update
  4792. for i in $eas $easdl $eassl
  4793. do
  4794. if [ -f "$i" ];then
  4795. counter=$( grep -Ec 'deb.*(debian\.org|peer1\.net).*(contrib.*non-free|non-free.*contrib)' $i )
  4796. isFree=$(( $counter + $isFree ))
  4797. fi
  4798. done
  4799. log_function_data "Debian contrib non free listed: $counter\nisFree: $isFree"
  4800. if [ "$isFree" -eq 0 ];then
  4801. for i in $eas $easdl
  4802. do
  4803. if [ -f "$i" ];then
  4804. # I'm going to assume if the user has proxy stuff set up, they know what
  4805. # they are doing here.
  4806. aptProx=$( grep -Esi '^[[:space:]]*deb.*:9999/' $i )
  4807. if [ -z "$aptProx" ];then
  4808. echo "${S}Updating your ${C}$i${S} to use non-free / contrib now...${N}"
  4809. sed -i -r 's%(#?deb.*(debian\.org|peer1\.net|sidux\.com|sidux\.net|debian\.tu-bs\.de|mirrorservice\.org|heanet\.ie|spline\.de|sunsite\.utk\.edu|leg\.uct\.ac\.za|mirror\.aarnet\.edu\.au).*\s(main|fix\.main))(\s*)(non-free.*|contrib.*)*%\1 contrib non-free%' $i
  4810. # the second test requires the results of the first to work
  4811. # note that spaces are required for this to work more reliably for most patterns
  4812. sed -i -r 's%(#?deb.*(sidux\.com|sidux\.net|debian\.tu-bs\.de|mirrorservice\.org|heanet\.ie|spline\.de|sunsite\.utk\.edu|ftp-mirror\.internap\.com|ftp\.tw.debian\.org|leg\.uct\.ac\.za|mirror\.aarnet\.edu\.au).*\snon-free)%\1 firmware fix.contrib fix.non-free %' $i
  4813. fi
  4814. fi
  4815. done
  4816. $APT_TYPE update && B_UPDATED='true' # need to refresh
  4817. fi
  4818. ;;
  4819. ubuntu)
  4820. # just to make sure, want to get out fast
  4821. ubRestricted=$( grep -siE '^[[:space:]]*deb[[:space:]].*ubuntu.*restricted' $eas $eas.d/*.list )
  4822. if [ -z "$ubRestricted" ];then
  4823. error_handler 216
  4824. fi
  4825. ;;
  4826. fedora)
  4827. yumList="$( yum repolist )"
  4828. yumFreeRepo=$( grep -Eis '^rpmfusion-free.*enabled' <<< "$yumList" )
  4829. yumNonFreeRepo=$( grep -Eis '^rpmfusion-nonfree.*enabled' <<< "$yumList" )
  4830. echo -n "${S}Checking for ${C}rpmfusion free${S} repos.... ${N}"
  4831. if [ -z "$yumFreeRepo" ];then
  4832. echo "${S}Adding${N}"
  4833. rpm -Uvh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm
  4834. bRepoAdded='true'
  4835. else
  4836. echo "${S}Present${N}"
  4837. fi
  4838. echo -n "${S}Checking for ${C}rpmfusion non-free${S} repos.... ${N}"
  4839. if [ -z "$yumNonFreeRepo" ];then
  4840. echo "${S}Adding${N}"
  4841. rpm -Uvh http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm
  4842. bRepoAdded='true'
  4843. else
  4844. echo "${S}Present${N}"
  4845. fi
  4846. if [ "$bRepoAdded" == 'true' ];then
  4847. echo "${S}Please note that you will be asked during the distro driver install to accept the"
  4848. echo "repo ${C}GPG keys${S} for the repos you just added. Make sure to enter ${C}y${S} for this question.${N}"
  4849. print_hec
  4850. fi
  4851. ;;
  4852. esac
  4853. fi
  4854. eval $LOGPE
  4855. }
  4856.  
  4857. # if null, this will trigger a first run update, maybe in the future can also
  4858. # add time of last update tests, we'll see. For now returns size in MB for tests
  4859. check_package_manager_updated()
  4860. {
  4861. eval $LOGUS
  4862. local dpkguf='/var/cache/apt/pkgcache.bin'
  4863. local sizeWorking=0
  4864.  
  4865. case $SYSTEM_BASE in
  4866. debian|ubuntu)
  4867. # this covers the case of first install, no apt update yet, which
  4868. # makes the following c tests all fail. This will never be true from
  4869. # sm fired sessions since smxi always updates first. Or updates
  4870. # if apt cache file is less than 5mB
  4871. if [ -f $dpkguf ];then
  4872. # dpkgUpdate=$( ls -l --time-style=+%Y-%m-%d-%H:%M $dpkguf | grep -Eo "20[0-9]{2}-[0-9]{2}-[0-9]{2}-[0-9]{2}:[0-9]{2}" )
  4873. sizeWorking=$( du -B M $dpkguf | grep -Eo '^[0-9]+' )
  4874. fi
  4875. log_function_data "sizeWorking: $sizeWorking"
  4876. if [ "$sizeWorking" -lt 4 ];then
  4877. update_package_manager 'update'
  4878. fi
  4879. ;;
  4880. esac
  4881.  
  4882. eval $LOGUE
  4883. }
  4884.  
  4885.  
  4886. ### -------------------------------------------------------------------
  4887. ### script updating / patch file install tools
  4888. ### -------------------------------------------------------------------
  4889.  
  4890. # args: $1 script to get/check; $2 - which download source to use
  4891. # $3 - extra message; $4 - repeat, to only retest download failure once
  4892. check_update_script()
  4893. {
  4894. local fileDataTemp='' isGood='' extraText='' bRunUpdate='false'
  4895. local versionTest=0 versionData='' localVersion='' remoteVersion=''
  4896. local downloadUrl=$2 uArgs='up' ua="-U s-tools/$SCRIPT_NAME"
  4897. local origXorg='/etc/X11/xorg-conf-orig-sg'
  4898.  
  4899. if [ -n "$( grep -E '(dev|svn|alt)' <<< $3 )" ];then
  4900. extraText="${C}$3:\n$2${S}"
  4901. else
  4902. extraText="${C}$3${S}"
  4903. fi
  4904. cd $SCRIPT_HOME # make sure we're in the right place
  4905. # download / replace requested file
  4906. case $1 in
  4907. $SCRIPT_NAME)
  4908. if [ "$B_FORCE_UPDATE" == 'true' ];then
  4909. uArgs='ufr'
  4910. bRunUpdate='true'
  4911. elif [ "$4" == 'repeat' ];then
  4912. uArgs='rep'
  4913. bRunUpdate='true'
  4914. # uncomment if you need this to not trigger for dev purposes
  4915. # elif [ "$B_TESTING_5" == 'true' ];then
  4916. # uArgs='dev'
  4917. # bRunUpdate='true'
  4918. else
  4919. echo -n "${S}Checking ${C}$SCRIPT_NAME${S} versions.... ${N}"
  4920. # 0: same versionp; 1 - different version; 2 - download error
  4921. versionData=$( check_script_version )
  4922. versionTest="$?"
  4923. localVersion=$( cut -d ':' -f 1 <<< "$versionData" )
  4924. remoteVersion=$( cut -d ':' -f 2 <<< "$versionData" )
  4925. if [ "$versionTest" -eq 0 ];then
  4926. echo "${S}local and remote versions match. Continuing...${N}"
  4927. bRunUpdate='false'
  4928. elif [ "$versionTest" -eq 1 ];then
  4929. echo "${M}update required:${S} local: ${C}$localVersion${S} - remote: ${C}$remoteVersion${N}"
  4930. bRunUpdate='true'
  4931. else
  4932. echo "${E}Failed to aquire remote version data. ${S}Will try direct download instead.${N}"
  4933. bRunUpdate='true'
  4934. fi
  4935. fi
  4936. # this will try to download again, the version tester itself isn't going to do any
  4937. # kind of error handling
  4938. if [ "$bRunUpdate" == 'true' ];then
  4939. ua="$ua.$uArgs.$SIS"
  4940. echo -e "${S}Updating ${C}$SCRIPT_NAME${S} now using the $extraText${N}"
  4941. fileDataTemp="$( wget $ua -q -O - $downloadUrl$1 )" || error_handler 198 $1
  4942. # all smxi files have this string as last line, if there, the file should usually
  4943. # run fine, except for weird fringe cases where the ascii file is corrupted partially
  4944. isGood=$( grep -si '##\*\*EOF\*\*##' <<< "$fileDataTemp" )
  4945. if [ -n "$isGood" ];then
  4946. echo "$fileDataTemp" > $1
  4947. chmod 705 $1
  4948. if [ "$B_FORCE_UPDATE" != 'true' ];then
  4949. exec ./$1 -R$START_OPTIONS
  4950. else
  4951. print_information
  4952. echo "${C}$SCRIPT_NAME${S} was successfully updated. Please start the script again to access"
  4953. echo "the latest features and drivers. Remember that ${C}$SCRIPT_NAME${S} always updates itself"
  4954. echo "automatically when it starts so usually ${C}-U${S} is not required."
  4955. echo
  4956. echo "To see the latest drivers or support features, use the ${C}-L${S} option. You can"
  4957. echo "run this option in X, and you don't need to be root to use it. Features:"
  4958. echo "Show all currently supported drivers: ${C}$SCRIPT_NAME -L d${S}"
  4959. echo "Show current nVidia support status: ${C}$SCRIPT_NAME -L n${S}"
  4960. echo "Show current ATI/Fglrx support status: ${C}$SCRIPT_NAME -L f${S}"
  4961. echo "Show current local/remote ${C}$SCRIPT_NAME${S} versions: ${C}$SCRIPT_NAME -L v${S}"
  4962. print_hec
  4963. echo "${S}Update completed. Exiting now.${N}"
  4964. fi
  4965. exit 0
  4966. else
  4967. if [ "$4" != 'repeat' ];then
  4968. # let's try this once again to make sure it wasn't just a temp problem
  4969. echo -e "${E}The file ${C}$1${E} did not download correctly from:\n$2\nRetrying download now...${N}"
  4970. check_update_script "$1" "$2" "$3" 'repeat'
  4971. else
  4972. error_handler 231 $1
  4973. fi
  4974. fi
  4975. fi
  4976. ;;
  4977. # I'm only going to load this stuff one time per file so I won't
  4978. # have to worry about rechecking and multi downloads etc
  4979. *)
  4980. if [ "$B_SKIP_WGET" != 'true' ];then
  4981. fileDataTemp="$( wget -q -O - $downloadUrl$1 )" || error_handler 198 $2$1
  4982. fi
  4983. # run fine, except for weird fringe cases where the ascii file is corrupted partially
  4984. isGood=$( grep '##\*\*EOF\*\*##' <<< "$fileDataTemp" )
  4985. if [ -n "$isGood" ];then
  4986. case $1 in
  4987. *xorg-conf)
  4988. echo "${S}Updating ${C}$EXXC${S} to new ${C}$1${S} version now...${N}"
  4989. if [ ! -f $origXorg ];then
  4990. echo "${S}Backing up your original ${C}$EXXC${S} to ${C}$origXorg${S}...${N}"
  4991. mv -f $EXXC $origXorg
  4992. else
  4993. echo "${S}Your original ${C}$EXXC${S} has already been backed up to ${C}$origXorg${S}"
  4994. fi
  4995. echo "${S}Replacing your ${C}$EXXC${S} with ${C}$1${S} now...${N}"
  4996. echo "$fileDataTemp" > $EXXC
  4997. chmod 604 $EXXC
  4998. echo "${S}All done with the ${C}$EXXC${S} update."
  4999. echo "Try running ${C}$SCRIPT_NAME${S} again and see if your driver install works this time.${N}"
  5000. ;;
  5001. *)
  5002. echo "$fileDataTemp" > $1
  5003. chmod 604 $EXXC
  5004. source ./$1 # load the library file
  5005. ;;
  5006. esac
  5007. else
  5008. error_handler 199 $1 # if corrupted file, exit with file name + error
  5009. fi
  5010. ;;
  5011. esac
  5012. }
  5013. # return values: # 0: same versionp; 1 - different version; 2 - download error
  5014. check_script_version()
  5015. {
  5016. local returnValue=0 wgetError=0 validated='' versionData=''
  5017. local ua="-U s-tools/$SCRIPT_NAME-updater.$SIS"
  5018. local localVersion='' remoteVersion=''
  5019. if [ "$B_SKIP_WGET" == 'true' ];then
  5020. returnValue=2
  5021. else
  5022. versionData="$( wget $ua -qO - $SCRIPT_DOWNLOAD_VERSION )" || wgetError="$?"
  5023. if [ "$wgetError" -eq 0 ];then
  5024. validated=$( grep -Esi '#\*\*EOF\*\*#' <<< "$versionData" )
  5025. if [ -n "$validated" ];then
  5026. localVersion=$( awk '/^#.*[[:space:]]version:/ {print $3}' $SCRIPT_HOME/$SCRIPT_NAME )
  5027. remoteVersion=$( grep 'sgfxi' <<< "$versionData" | cut -d '=' -f 2 | cut -d ':' -f 1 )
  5028. if [ "$localVersion" == "$remoteVersion" ];then
  5029. returnValue=0
  5030. else
  5031. returnValue=1
  5032. fi
  5033. echo "$localVersion:$remoteVersion"
  5034. else
  5035. returnValue=2
  5036. fi
  5037. else
  5038. returnValue=2
  5039. fi
  5040. fi
  5041. return $returnValue
  5042. }
  5043.  
  5044. # args: $1 patch file to apply; $2 - [optional] standard (implied)/test
  5045. apply_patch_file()
  5046. {
  5047. eval $LOGUS
  5048. # this is just for test, set the global to force build so it can get patched
  5049. if [ "$2" == 'test' ];then
  5050. B_FORCE_OPTION='true'
  5051. return 0;
  5052. fi
  5053. local patchFile=$1
  5054. ## this can be changed to branches with -! 20 or -! 21
  5055. local patchUrl="${PATCH_DOWNLOAD}patches/$patchFile" ua="-U s-tools/$SCRIPT_NAME-data.patches.$patchFile"
  5056. local patchFileDataTemp=''
  5057.  
  5058. cd $SCRIPT_WORKING_DIR/$INSTALL_DIRECTORY # first change to the correct directory
  5059. log_function_data "Patch File Dir: $SCRIPT_WORKING_DIR/$INSTALL_DIRECTORY"
  5060. log_function_data "Patch URL: $patchUrl"
  5061.  
  5062. echo "${S}Retrieving patch ${C}$patchFile${S}...${N}"
  5063. # get patch file, set to variable
  5064. patchFileDataTemp="$( wget $ua -q -O - $patchUrl 2>/dev/null )" || error_handler 180 $patchFile
  5065. if [ -n "$patchFileDataTemp" ];then
  5066. echo "${S}Running patch ${C}$patchFile${S}...${N}"
  5067. patch -p 0 <<< "$patchFileDataTemp" || error_handler 179 $patchFile
  5068. echo "${S}Patching completed...${N}"
  5069. else
  5070. error_handler 181 $patchFile
  5071. fi
  5072. eval $LOGUE
  5073. }
  5074.  
  5075. ### -------------------------------------------------------------------
  5076. ### print data functions
  5077. ### -------------------------------------------------------------------
  5078.  
  5079. print_information()
  5080. {
  5081. local scriptVersion=$( grep -Eo -m 1 "(version:).*" $SCRIPT_HOME/$SCRIPT_NAME | cut -d ' ' -f 2 )
  5082. local scriptDate=$( grep -Eo -m 1 '(Date:).*' $SCRIPT_HOME/$SCRIPT_NAME | cut -d ' ' -f 2-4 )
  5083. #local cardInfo=$( lspci | awk -F': ' '/VGA compatible controller.*: / { print $NF }' | sed -r 's%(ATI\sTechnologies\sInc\s|nVidia\sCorporation\s)(.*)%\2%' )
  5084. # |3D controller|Display controller
  5085. local cardInfo=$( lspci | \
  5086. awk -F': ' '/VGA compatible controller.*: / { print $NF }' | \
  5087. sed -r 's%(ATI\s|nVidia\s|Intel\s)(Technologies\sInc\s|Corporation\s|Unknown\sdevice){1,2}(.*)%\1\3%g' )
  5088. local cardRam='' cardVendor='' busId=''
  5089.  
  5090. # we need the real busid, not the xorg one
  5091. busId=$( lspci -n | grep "$CARD_DATA" | grep -Eio '^[0-9]{1,2}:[0-9a-z]{1,2}(\.|:)[0-9]' )
  5092.  
  5093. if [ -n "$busId" ];then
  5094. cardRam=$( lspci -v -s $busId 2>/dev/null | grep -E '.*Memory[[:space:]].*[[:space:]]prefetchable.*\[size=([0-9\.]+[KMG])\]' | sed -r 's/.*Memory[[:space:]].*[[:space:]]prefetchable.*\[size=([0-9\.]+[KMG])\]/\1/' )
  5095. cardVendor=$( lspci -v -s $busId 2>/dev/null | grep -E '.*Subsystem:[[:space:]]*(.*)' | sed -r 's/.*Subsystem:[[:space:]]*(.*)/\1/' | sed 's/[dD]evice.*$//g' | sed 's/[uU]nknown//g' )
  5096. fi
  5097. echo $MLINE
  5098. echo " ${M}$SCRIPT_NAME${S} :: version: ${C}$scriptVersion${S} :: last updated: ${C}$scriptDate"
  5099. echo $MLINE
  5100. echo " ${S}graphics card information:"
  5101. echo " ${S}series: ${C}$cardInfo"
  5102. if [ -n "$cardVendor" ];then
  5103. echo " ${S}vendor: ${C}$cardVendor"
  5104. fi
  5105. if [ -n "$cardRam" ];then
  5106. echo " ${S}ram: ${C}$cardRam ${S}(note: not accurate for built in graphics)"
  5107. fi
  5108. echo $MLINE
  5109. }
  5110. #print_information
  5111.  
  5112. # args: $1 testing or standard; $2 function/feature name; $3 function name
  5113. print_information_continue()
  5114. {
  5115. eval $LOGUS
  5116. local response='' bShowIa32='false'
  5117.  
  5118. case $1 in
  5119. standard|info)
  5120. echo -e "${S}$2"
  5121. ;;
  5122. esac
  5123.  
  5124. if [ "$1" == 'standard' ];then
  5125. if [ "$B_AUTORUN" != 'true' ];then
  5126. # this checks to see if it's a supported card/system, and that ia32 stuff is not already installed
  5127. # only in case where it's supported and not installed / configured will user see this message
  5128. bShowIa32=$( check_ia32_libs 'test' )
  5129. echo "${M}Please select from the following options:${N}"
  5130. echo "${C}<enter>${M} - hit enter key to continue with ${C}$CARD${M} driver install (${C}default${M})"
  5131. if [ "$bShowIa32" == 'true' ];then
  5132. echo "${C}i + <enter>${M} - add/configure ${C}ia32-libs-i386${M} before doing the driver install. This lets things"
  5133. echo " like ${C}openGL 32 bit${M} apps and ${C}Steam${M} work smoothly with your ${C}64 bit $CARD${M} driver.${N}"
  5134. fi
  5135. echo "${C}x + <enter>${M} - exit now if there is an error.${N}"
  5136. read response
  5137. case $response in
  5138. i|I)
  5139. B_CHECK_IA32='true'
  5140. ;;
  5141. x|X)
  5142. error_handler 100 $FUNCNAME
  5143. ;;
  5144. esac
  5145. fi
  5146. fi
  5147. eval $LOGUE
  5148. }
  5149.  
  5150. # this is the hit enter to continue blurb...
  5151. print_hec()
  5152. {
  5153. local response=''
  5154.  
  5155. if [ "$AUTORUN" != 'true' ];then
  5156. echo $MLINE
  5157. # halt the script so people can read the advice
  5158. echo "${Q}Please hit ${C}enter${Q} to continue${N}"
  5159. echo $MLINE
  5160. read response
  5161. fi
  5162. }
  5163.  
  5164. ### -------------------------------------------------------------------
  5165. ### logging/debugging tools
  5166. ### -------------------------------------------------------------------
  5167.  
  5168. create_log()
  5169. {
  5170. local cardString=$( lspci | grep -i 'vga ' | cut -d ':' -f 3 )
  5171. local sgfxiVersion=$( grep 'version:' $SCRIPT_NAME | grep -o "[0-9]*\.[0-9]*\.[0-9]*" )
  5172. local installToKernel='' smValues=''
  5173.  
  5174. if [ -n "$INSTALL_TO_KERNEL" ];then
  5175. installToKernel="\nRunning install from Kernel: $(uname -r)\n"
  5176. fi
  5177. # it's important to log these in case there's some issue or bug in the values
  5178. if [ -f $SM_VALUES ];then
  5179. smValues="\nBegin User Set $SM_VALUES:\n$( cat $SM_VALUES)\nEnd User Set Values\n"
  5180. fi
  5181.  
  5182. # check and create log file:
  5183. if [ ! -d $LOG_FILE_DIR ];then
  5184. mkdir $LOG_FILE_DIR
  5185. fi
  5186. # cleanup legacy logs
  5187. rm -f ${LOG_FILE_DIR}200*-sgfxi.log
  5188. # check and create logfile:
  5189. LOG_FILE=$LOG_FILE_DIR$LOG_FILE
  5190.  
  5191. if [ ! -f $SCRIPT_ROTATE ];then
  5192. echo "$LOG_FILE {
  5193. rotate 8
  5194. create
  5195. size 10k
  5196. }
  5197. " > $SCRIPT_ROTATE
  5198. else
  5199. # update if needed
  5200. if [ -n "$( grep ' 120k' $SCRIPT_ROTATE )" ];then
  5201. sed -i 's/rotate[[:space:]]4/rotate 8/' $SCRIPT_ROTATE
  5202. sed -i 's/size[[:space:]]120k/size 10k/' $SCRIPT_ROTATE
  5203. fi
  5204. fi
  5205. touch $LOG_FILE # make sure there's one there for rotate to look at
  5206. if [ -n "$( which logrotate )" ];then
  5207. logrotate $SCRIPT_ROTATE
  5208. fi
  5209.  
  5210. touch $LOG_FILE # and if rotated, need a new one
  5211. # sudo start will only show as information to check for 'sudo su -' starts, all others
  5212. # have exited with error
  5213. echo -e "=========================================================
  5214. START $SCRIPT_NAME LOGGING:
  5215. =========================================================
  5216. Script started: $( date +%Y-%m-%d-%H:%M:%S )
  5217. Video Card Information:$cardString
  5218. Video Card Type: $CARD_BRAND
  5219. Video Card Number: $CARD_NUMBER
  5220. Xorg Version: $X_VERSION
  5221. Installing driver to kernel: $KERNEL_FULL$installToKernel
  5222. $SCRIPT_NAME script version: $sgfxiVersion
  5223. $SCRIPT_NAME start options: $START_OPTIONS
  5224. SYSTEM_BASE: $SYSTEM_BASE
  5225. SYSTEM_CODENAME: $SYSTEM_CODENAME
  5226. DISTRIB_CODENAME: $DISTRIB_CODENAME
  5227. DISTRIB_ID: $DISTRIB_ID
  5228. DISTRIB_RELEASE: $DISTRIB_RELEASE
  5229. SIS: $SIS
  5230. BITS: $BITS
  5231. FG_DISTRIB_CODENAME: $FG_DISTRIB_CODENAME
  5232. FG_DISTRIB_ID: $FG_DISTRIB_ID
  5233. APT_TYPE: $APT_TYPE
  5234. LOGIN_PID: $LOGIN_PID
  5235. SUDO_START: $SUDO_START
  5236. B_SYSTEMD: $B_SYSTEMD
  5237. B_SYSTEMD_GRAPHICAL: $B_SYSTEMD_GRAPHICAL
  5238. B_SYSTEMD_SYSINIT: $B_SYSTEMD_SYSINIT
  5239. B_UPSTART: $B_UPSTART
  5240. =========================================================
  5241. X is Running: $( x_is_running )
  5242. Current Runlevel: $( get_current_runlevel )
  5243. Connection is live (0=true): $( check_connection )
  5244. =========================================================$smValues
  5245. INSTALL_TO_KERNEL: $INSTALL_TO_KERNEL
  5246. KERNEL_FULL: $KERNEL_FULL
  5247. KERNEL_BASE: $KERNEL_BASE
  5248. KERNEL_NUMBER: $KERNEL_NUMBER
  5249. KERNEL_MATH: $KERNEL_MATH
  5250. B_IS_XEN: $B_IS_XEN" >> $LOG_FILE
  5251.  
  5252. B_LOGGING_STARTED='true'
  5253. }
  5254.  
  5255. # $1 type or data; $2 is function; $3 - function args, optional
  5256. log_function_data()
  5257. {
  5258. local funcInfo='' logSpacer=' '
  5259.  
  5260. if [ "$B_PRINT_VER" != 'true' ];then
  5261. case $1 in
  5262. ps)
  5263. funcInfo="Function: $2 - Primary: Start"
  5264. ;;
  5265. pe)
  5266. funcInfo="Function: $2 - Primary: End"
  5267. ;;
  5268. us)
  5269. funcInfo="Function: $2 - Utility: Start"
  5270. ;;
  5271. ue)
  5272. funcInfo="Function: $2 - Utility: End"
  5273. ;;
  5274. esac
  5275.  
  5276. if [ -n "$funcInfo" ];then
  5277. log_writer "$funcInfo"
  5278. else
  5279. log_writer "${logSpacer}$1"
  5280. fi
  5281.  
  5282. if [ -n "$3" ];then
  5283. log_writer "${logSpacer}Args: $3"
  5284. fi
  5285. fi
  5286. }
  5287.  
  5288. log_driver_installer_failure()
  5289. {
  5290. local nvidiaLog='/var/log/nvidia-installer.log'
  5291. local atiLog='/usr/share/ati/fglrx- install.log'
  5292. local errorLog=''
  5293.  
  5294. case $CARD in
  5295. $FGLRX)
  5296. errorLog=$atiLog
  5297. ;;
  5298. $NVIDIA)
  5299. errorLog=$nvidiaLog
  5300. ;;
  5301. esac
  5302. echo $PLINE >> $LOG_FILE
  5303. echo "Error logs from $CARD install: $errorFileData" >> $LOG_FILE
  5304. echo $PLINE >> $LOG_FILE
  5305. if [ -f "$errorLog" ];then
  5306. cat $errorLog >> $LOG_FILE
  5307. else
  5308. echo "No error logs found from the run package installer!" >> $LOG_FILE
  5309. fi
  5310. echo $PLINE >> $LOG_FILE
  5311. }
  5312.  
  5313. # args: $1 - data to write to logfile. Note that the function is always logged
  5314. # via function_logging first, and other relevant globals are set there as well
  5315. log_writer()
  5316. {
  5317. # this handles first line indents, all other indents must be set in message data
  5318. # like so: message="some problem... \n${LOG_INDENT}more problem stuff..."
  5319. if [ "$B_LOGGING_STARTED" == 'true' ];then
  5320. # strip out escape color code, if any. Method by dzz, thanks ;-)
  5321. echo -e "$1" | sed 's/\x1b\[[0-9]\{1,2\}\(;[0-9]\{1,2\}\)\{0,2\}m//g' >> $LOG_FILE
  5322. fi
  5323. }
  5324.  
  5325. debugger_data_collector()
  5326. {
  5327. local debug_data_home="$HOME/${SCRIPT_NAME}-data/" b_uploaded='false' xiin_download=''
  5328. local xorg_d_files='' xorg_file='' data='' data2='' xiin_file='xiin.py'
  5329. local ftp_upload='ftp.techpatterns.com/incoming' b_run_xiin='false' root_string=''
  5330. local host=$( tr '[A-Z]' '[a-z]' <<< "$HOSTNAME" )
  5331. if [[ -n $host ]];then
  5332. host=${host// /-}
  5333. else
  5334. host="-no-host"
  5335. fi
  5336. if [[ $( whoami ) == 'root' ]];then
  5337. root_string='-root'
  5338. fi
  5339. local debug_data_dir="$SCRIPT_NAME-$(date +%Y-%m-%d-%H%M%S)$host$root_string"
  5340. local debug_gz_file="$debug_data_dir.tar.gz"
  5341. echo "Starting $SCRIPT_NAME debugging data collection..."
  5342. if [ ! -d $debug_data_home ];then
  5343. mkdir $debug_data_home
  5344. echo "Created data directory here: $debug_data_home"
  5345. fi
  5346. cd $debug_data_home
  5347. if [ -d $debug_data_dir ];then
  5348. rm -rf $debug_data_dir
  5349. else
  5350. mkdir $debug_data_dir
  5351. fi
  5352. if type -p shopt &>/dev/null;then
  5353. shopt -s nullglob;a_distro_ids=(/etc/*[-_]{release,version});shopt -u nullglob;echo ${a_distro_ids[@]} &> $debug_data_dir/etc-distro-files.txt
  5354. for distro_file in ${a_distro_ids[@]} /etc/issue
  5355. do
  5356. if [[ -f $distro_file ]];then
  5357. cat $distro_file &> $debug_data_dir/distro-file${distro_file//\//-}
  5358. fi
  5359. done
  5360. fi
  5361. cat /etc/modules &> $debug_data_dir/etc-modules.txt
  5362. readlink /usr/lib/libGL.so.1 &> $debug_data_dir/readlink-usr-lib-libgl.so.1.txt
  5363. readlink /usr/lib/xorg/modules/extensions/libglx.so &> $debug_data_dir/readlink-lib-xorg-modules-extensions-libglx.so.txt
  5364. ls -R /boot &> $debug_data_dir/boot-ls-files.txt
  5365. echo $(get_active_grub_files) &> $debug_data_dir/grub-files-active.txt
  5366. cat /boot/grub/grub.cfg &> $debug_data_dir/boot-grub-grub-cfg.txt
  5367. ls /etc/modprobe.d/*.conf &> $debug_data_dir/ls-etc-modprobe-d.txt
  5368. for item in $( ls /etc/modprobe.d/*.conf )
  5369. do
  5370. data=${item#/}
  5371. cat $item &> $debug_data_dir/${data//\//-}
  5372. done
  5373. ls -R /var/lib/dkms/ &> $debug_data_dir/var-lib-dkms-ls-files.txt
  5374. ls -R /etc/dkms/ &> $debug_data_dir/etc-dkms-ls-files.txt
  5375. ls -R /usr/src/*/dkms.conf &> $debug_data_dir/usr-src-ls-dkms-files.txt
  5376. ls -R /usr/src/*/dkms.conf | grep -iE '(catalyst|fglrx|nvidia)' &> $debug_data_dir/usr-src-ls-dkms-video-files.txt
  5377.  
  5378. ps aux &> $debug_data_dir/ps-aux.txt
  5379. ps -e &> $debug_data_dir/ps-e.txt
  5380. ps -p 1 &> $debug_data_dir/ps-p-1.txt
  5381. cat /proc/1/comm &> $debug_data_dir/proc-1-comm.txt
  5382. runlevel &> $debug_data_dir/runlevel.txt
  5383.  
  5384. if [ -f /etc/modprobe.d/dkms.conf ];then
  5385. cat /etc/modprobe.d/dkms.conf &> $debug_data_dir/etc-modprobe-dkms.conf.txt
  5386. else
  5387. touch $debug_data_dir/etc-modprobe-dkms.conf-absent
  5388. fi
  5389. for item in $( ls -R /usr/src/*/dkms.conf | grep -iE '(catalyst|fglrx|nvidia)' )
  5390. do
  5391. data=${item#/}
  5392. cat $item &> $debug_data_dir/${data//\//-}
  5393. done
  5394. if dpkg &>/dev/null;then
  5395. dpkg -l | grep -iE '(nvidia|fglrx|catalyst)' &> $debug_data_dir/dpkg-l-grep-driver-files.txt
  5396. else
  5397. touch dpkg-absent
  5398. fi
  5399. glxinfo &> $debug_data_dir/glxinfo.txt
  5400. xdpyinfo &> $debug_data_dir/xdpyinfo.txt
  5401. xrandr &> $debug_data_dir/xrandr.txt
  5402. X -version &> $debug_data_dir/x-version.txt
  5403. Xorg -version &> $debug_data_dir/xorg-version.txt
  5404. xprop -root &> $debug_data_dir/xprop-root.txt
  5405. echo $GNOME_DESKTOP_SESSION_ID &> $debug_data_dir/gnome-desktop-session-id.txt
  5406. # kde 3 id
  5407. echo $KDE_FULL_SESSION &> $debug_data_dir/kde3-ful-session.txt
  5408. echo $KDE_SESSION_VERSION &> $debug_data_dir/kde456-session-version.txt
  5409. echo "$(kded$KDE_SESSION_VERSION --version )" &> $debug_data_dir/kde-version-data.txt
  5410. echo $XDG_CURRENT_DESKTOP &> $debug_data_dir/xdg-current-desktop.txt
  5411. lspci &> $debug_data_dir/lspci.txt
  5412. lspci -k &> $debug_data_dir/lspci-k.txt
  5413. lspci -knn &> $debug_data_dir/lspci-knn.txt
  5414. lspci -n &> $debug_data_dir/lspci-n.txt
  5415. lspci -nn &> $debug_data_dir/lspci-nn.txt
  5416. lspci -mm &> $debug_data_dir/lspci-mm.txt
  5417. lspci -mmnn &> $debug_data_dir/lspci-mmnn.txt
  5418. lspci -mmnnv &> $debug_data_dir/lspci-mmnnv.txt
  5419. lspci -v &> $debug_data_dir/lspci-v.txt
  5420. sensors &> $debug_data_dir/sensors.txt
  5421. if type -p inxi &>/dev/null;then
  5422. inxi -rfv7 -c 0 &> $debug_data_dir/inxi-rfv7.txt
  5423. else
  5424. touch $debug_data_dir/inxi-absent
  5425. fi
  5426. cat /var/log/Xorg.0.log &> $debug_data_dir/xorg.0.log
  5427. cat /var/log/Xorg.1.log &> $debug_data_dir/xorg.1.log
  5428. cat /var/log/Xorg.2.log &> $debug_data_dir/xorg.2.log
  5429. if [ -f /var/log/sgfxi/sgfxi.log ];then
  5430. cat /var/log/sgfxi/sgfxi.log &> $debug_data_dir/sgfxi.log
  5431. else
  5432. touch $debug_data_dir/sgfxi.log-file-absent
  5433. fi
  5434. if [ -f /var/log/sgfxi/sgfxi.log.1 ];then
  5435. cat /var/log/sgfxi/sgfxi.log.1 &> $debug_data_dir/sgfxi.1.log
  5436. else
  5437. touch $debug_data_dir/sgfxi.log.1-file-absent
  5438. fi
  5439. if [ -f /var/log/sgfxi/sgfxi.log.2 ];then
  5440. cat /var/log/sgfxi/sgfxi.log.2 &> $debug_data_dir/sgfxi.2.log
  5441. else
  5442. touch $debug_data_dir/sgfxi.log.2-file-absent
  5443. fi
  5444. if [[ -e /etc/X11/xorg.conf ]];then
  5445. cat /etc/X11/xorg.conf &> $debug_data_dir/xorg-conf.txt
  5446. else
  5447. touch $debug_data_dir/xorg-conf-file-absent
  5448. fi
  5449. if [[ -n $( ls /etc/X11/xorg.conf.d/ 2>/dev/null ) ]];then
  5450. ls /etc/X11/xorg.conf.d &> $debug_data_dir/ls-etc-x11-xorg-conf-d.txt
  5451. xorg_d_files=$(ls /etc/X11/xorg.conf.d)
  5452. for xorg_file in $xorg_d_files
  5453. do
  5454. cat /etc/X11/xorg.conf.d/$xorg_file &> $debug_data_dir/xorg-conf-d-$xorg_file.txt
  5455. done
  5456. else
  5457. touch $debug_data_dir/xorg-conf-d-files-absent
  5458. fi
  5459. if [[ -f /usr/share/ati/fglrx-install.log ]];then
  5460. cat /usr/share/ati/fglrx-install.log &> $debug_data_dir/usr-share-ati-fglrx-install.log
  5461. else
  5462. touch $debug_data_dir/usr-share-ati-fglrx-install-log-absent
  5463. fi
  5464. if [[ -f /var/log/catalyst-install.log ]];then
  5465. cat /var/log/catalyst-install.log &> $debug_data_dir/var/log/catalyst-install.log
  5466. else
  5467. touch $debug_data_dir/catalyst-install-log-absent
  5468. fi
  5469. # ubuntu tool
  5470. if [[ -f /var/log/jockey.log ]];then
  5471. cat /var/log/jockey.log &> $debug_data_dir/var/log/jockey.log
  5472. else
  5473. touch $debug_data_dir/jockey-installer-log-absent
  5474. fi
  5475. if [[ -f /var/log/nvidia-installer.log ]];then
  5476. cat /var/log/nvidia-installer.log &> $debug_data_dir/nvidia-installer.log
  5477. else
  5478. touch $debug_data_dir/nvidia-installer-log-absent
  5479. fi
  5480. data=$( ls /etc/apt/sources.list /etc/apt/sources.list.d/*.list )
  5481. if [[ -n $data ]];then
  5482. for aptFile in $data
  5483. do
  5484. data2=${aptFile#/}
  5485. cat $aptFile &> $debug_data_dir/${data2//\//-}
  5486. done
  5487. else
  5488. touch $debug_data_dir/etc-apt-source-files-absent
  5489. fi
  5490. echo "Data collection completed."
  5491. echo 'Creating tar.gz compressed file of this material now. Contents:'
  5492. echo $LINE
  5493. tar -cvzf $debug_gz_file $debug_data_dir
  5494. echo $LINE
  5495. echo 'Cleaning up leftovers...'
  5496. rm -rf $debug_data_dir
  5497. echo 'Testing gzip file integrity...'
  5498. gzip -t $debug_gz_file
  5499. if [[ $? -gt 0 ]];then
  5500. rm -f $debug_gz_file
  5501. echo 'Data in gz is corrupted, removed gzip file, try running data collector again.'
  5502. exit 1
  5503. else
  5504. echo $LINE
  5505. echo 'All done with debugger data collection.'
  5506. echo "$SCRIPT_NAME will now try to upload this data to the script server..."
  5507. echo $LINE
  5508. # -Nc is creating really weird download anomolies, so using -O instead
  5509. xiin_download="$( wget -q -O - https://github.com/smxi/inxi/raw/xiin/$xiin_file )"
  5510. # if nothing got downloaded kick out error, otherwise we'll use an older version
  5511. if [[ $? -gt 0 && ! -f $xiin_file ]];then
  5512. echo -e "ERROR: Failed to download ftp uploader file: $xiin_file\nMaybe the remote site is down or your networking is broken?"
  5513. elif [[ -n $( grep -s '# EOF' <<< "$xiin_download" ) || -f $xiin_file ]];then
  5514. if [[ -n $( grep -s '# EOF' <<< "$xiin_download" ) ]];then
  5515. echo "Updating $xiin_file from remote location"
  5516. echo "$xiin_download" > $xiin_file
  5517. else
  5518. echo "Using local $xiin_file due to download failure"
  5519. fi
  5520. b_run_xiin='true'
  5521. else
  5522. echo -e "ERROR: $xiin_file downloaded but the program file data is corrupted. Unable to do ftp upload."
  5523. fi
  5524. if [[ $b_run_xiin == 'true' ]];then
  5525. echo "Doing automatic upload of data to remote server $ftp_upload now..."
  5526. python ./$xiin_file -u $debug_data_home$debug_gz_file $ftp_upload 1>/dev/null
  5527. if [[ $? -gt 0 ]];then
  5528. echo $Line
  5529. echo "Error: looks like the automatic ftp upload failed. Error number: $?"
  5530. else
  5531. b_uploaded='true'
  5532. fi
  5533. else
  5534. echo 'Unable to run the automoatic ftp upload because of an error with the xiin download.'
  5535. fi
  5536. if [ "$b_uploaded" != 'true' ];then
  5537. echo "Please attach the gz file to a forum support thread, if the forum supports file attachments,"
  5538. echo "OR simply copy it over to: ftp.techpatterns.com/incoming"
  5539. echo "You can do this using a file manager like Dolphin, Konqueror, or any other one that lets"
  5540. echo "you type in the ftp address in the location bar then connect to it."
  5541. echo "After you do that, you can just drag in the gz file to the remote site."
  5542. else
  5543. echo "The upload worked! You are done with the debugger process. Thank you."
  5544. fi
  5545. echo $LINE
  5546. echo "It's all good apparently. You can find a copy of the data here:"
  5547. echo "$debug_data_home$debug_gz_file"
  5548. exit 0
  5549. fi
  5550. }
  5551.  
  5552. ########################################################################
  5553. #### FUNCTIONS: CORE GRAPHIC DRIVER INSTALLER TOOLS
  5554. ########################################################################
  5555.  
  5556. ### -------------------------------------------------------------------
  5557. ### Native Driver installer section
  5558. ### -------------------------------------------------------------------
  5559.  
  5560. # this bypasses core binary installers and just runs the required pieces
  5561. install_native_driver()
  5562. {
  5563. eval $LOGPS
  5564. local xorgBase='' xorgNv='nouveau' xorgAti='ati' xorgIntel='intel'
  5565. local xorgDriver='' driver='' currentlyInstalled='' xorgCore=''
  5566. local driverInstall='' experimentalText='' libMesaGlx=''
  5567. local extraAtiPackage1='' bSkipInstall='false'
  5568.  
  5569. # we're going to force this behavior for the default restore option by setting
  5570. # explicit native override values, which will trigger the desired actions below
  5571. if [ "$B_RESTORE_DEFAULTS" == 'true' ];then
  5572. # need to do this for -! 5 flag testing, to set: SYSTEM_BASE etc
  5573. if [ "$B_SKIP_FUNCTION" == 'true' ];then
  5574. check_set_distro
  5575. fi
  5576. case $CARD in
  5577. $NVIDIA)
  5578. NATIVE_OVERRIDE='nouveau'
  5579. ;;
  5580. $FGLRX)
  5581. NATIVE_OVERRIDE='radeon'
  5582. ;;
  5583. esac
  5584. fi
  5585.  
  5586. # xserver-xorg-video-intel
  5587. # libgl1-mesa-glx
  5588. # libgl1-mesa-dri
  5589. case $SYSTEM_BASE in
  5590. debian|ubuntu)
  5591. xorgBase='xserver-xorg-video-'
  5592. xorgCore='xserver-xorg-core'
  5593. libMesaGlx='libgl1-mesa-glx'
  5594. ;;
  5595. arch)
  5596. extraAtiPackage1="install_package 'ati-dri' '' 'reinstall'"
  5597. xorgBase='xf86-video-'
  5598. xorgCore='xorg-server'
  5599. libMesaGlx='libgl'
  5600. if [ "$NATIVE_OVERRIDE" == 'radeon' ];then
  5601. NATIVE_OVERRIDE=$xorgAti
  5602. fi
  5603. ;;
  5604. fedora)
  5605. xorgBase='xorg-x11-drv-'
  5606. xorgCore='xorg-x11-server-Xorg'
  5607. libMesaGlx='libMesaGlx=' # I think, check this: yum list *mesa*
  5608. ;;
  5609. esac
  5610.  
  5611. if [ "$B_EXPERIMENTAL" == 'true' ];then
  5612. experimentalText=' experimental'
  5613. fi
  5614. #
  5615. if [ "$B_DEFAULT_NATIVE_DRIVER" == 'true' -o -n "$NATIVE_OVERRIDE" ];then
  5616. eval $LOGPS
  5617. # assign defaults from earlier CARD assignments in -n
  5618. xorgDriver=$CARD
  5619. # then do special case handling
  5620. case $CARD in
  5621. $NVIDIA)
  5622. xorgDriver=$xorgNv
  5623. ;;
  5624. # note: use default ati here and only override to radeon/radeonhd for native override
  5625. $FGLRX)
  5626. xorgDriver=$xorgAti
  5627. ;;
  5628. $INTEL)
  5629. xorgDriver=$xorgIntel
  5630. ;;
  5631. esac
  5632.  
  5633. # driverInstall is just for output text for user to know what driver script installs
  5634. driverInstall=$xorgDriver
  5635. # replace with override if it's been set
  5636. if [ -n "$NATIVE_OVERRIDE" ];then
  5637. xorgDriver=$NATIVE_OVERRIDE
  5638. driverInstall=$NATIVE_OVERRIDE
  5639. fi
  5640. # this is mostly for cases where no default xorg driver is found
  5641. # this will apply to -! 32 option mostly
  5642. if [ -z "$xorgDriver" ];then
  5643. bSkipInstall='true'
  5644. driverInstall='no-driver-listed'
  5645. fi
  5646. # driver is the actual driver xorg will use
  5647. driver=$xorgBase$xorgDriver
  5648.  
  5649. if [ "$B_PRINT_VER" == 'true' ];then
  5650. exit 0 # this is required for smxi native driver tests
  5651. else
  5652. # if [ "$B_SM_INSTALL" != 'true' -a -n "$START_OPTIONS_PRINT" ];then
  5653. # print_information_continue 'info' "You are using the following options:\n$START_OPTIONS_PRINT"
  5654. # fi
  5655. # make sure the driver is available for the user's debian version
  5656. # is it true? nouveau pulled out of xorg? what the hell?
  5657. if [ "$bSkipInstall" != 'true' -a -z "$( check_package_status $driver 'c' )" ];then
  5658. # if [ "$NATIVE_OVERRIDE" != 'nouveau' ];then
  5659. error_handler 222 "$driver"
  5660. # else
  5661. # bSkipInstall='true'
  5662. # fi
  5663. fi
  5664. if [ "$B_RESTORE_DEFAULTS" == 'true' ];then
  5665. print_information_continue 'standard' "The graphics installer will be cleaning out all previous drivers\nmoving ${C}$EXXC${S} to ${C}$EXXC-bu-$( date +%Y-%m-%d-%H:%M:%S )${S}\nIt will remove all $NATIVE_OVERRIDE nomodeset and blacklists in grub and /etc/modules,\nand will install Free xorg${S} driver: ${C}$driverInstall\n${S}This should more or less restore your system to the native, no xorg.conf state.${N}"
  5666. else
  5667. print_information_continue 'standard' "The graphics installer will be installing the${C}$experimentalText Free xorg${S} driver: ${C}$driverInstall${N}"
  5668. fi
  5669. fi
  5670. x_start_stop_master stop
  5671.  
  5672. ## cleanup up old stuff
  5673. pre_extract_clean_set_up
  5674. preinstall_cleanup
  5675. # this is required to do radeon xorg driver
  5676. native_driver_install_keep
  5677. if [ -n "$xorgCore" ];then
  5678. # aptitude doesn't download missing package for reinstall
  5679. case $SYSTEM_BASE in
  5680. debian|ubuntu)
  5681. install_package "$xorgCore" '' ''
  5682. ;;
  5683. esac
  5684. install_package "$xorgCore" '' 'reinstall'
  5685. fi
  5686. # need an override for this
  5687. if [ "$CARD" == "$FGLRX" -a "$B_TESTING_5" != 'true' ];then
  5688. install_package "$libMesaGlx" '' 'reinstall'
  5689. fi
  5690.  
  5691. if [ "$CARD" == "$FGLRX" -a "$B_EXPERIMENTAL" == 'true' ];then
  5692. echo "${S}Installing experimental driver ${C}$driver${S} now...${N}"
  5693. native_driver_experimental "$driver"
  5694. else
  5695. if [ "$bSkipInstall" != 'true' ];then
  5696. # aptitude doesn't download missing package for reinstall
  5697. case $SYSTEM_BASE in
  5698. debian|ubuntu)
  5699. install_package "$driver" '' ''
  5700. ;;
  5701. esac
  5702. install_package $driver '' 'reinstall'
  5703. fi
  5704. if [ "$CARD" == "$FGLRX" ];then
  5705. eval $extraAtiPackage1
  5706. fi
  5707. fi
  5708. # we'll need this to determine whether to do a reboot for radeon/nouveau
  5709. NON_FREE_DRIVER=$( grep -Esi 'Driver[[:space:]]+"(fglrx|nvidia)"' $EXXC | grep -oEs "(nvidia|fglrx)" )
  5710. ## clean / update xorg, this is only to change driver to ati/nv, no full xorg conf yet.
  5711. if [ "$B_RESTORE_DEFAULTS" == 'false' ];then
  5712. update_xorg
  5713. fi
  5714. process_xvmc # this will restore xvmc defaults if nvidia stuff was being used
  5715.  
  5716. case $NATIVE_OVERRIDE in
  5717. nouveau|radeon)
  5718. case $SYSTEM_BASE in
  5719. arch|fedora|debian|ubuntu)
  5720. add_module "$NATIVE_OVERRIDE"
  5721. ;;
  5722. esac
  5723. set_modesetting_on $NATIVE_OVERRIDE
  5724. ;;
  5725. esac
  5726.  
  5727. eval $LOGPE
  5728. ## and finish it up
  5729. x_start_stop_master start
  5730. exit 0 # just exit here in case something weird goes wrong with xorg start
  5731. else
  5732. error_handler 254 # this is redundant, but I'm leaving it as a fail safe
  5733. fi
  5734. eval $LOGPE
  5735. }
  5736.  
  5737. native_driver_install_keep()
  5738. {
  5739. eval $LOGUS
  5740. local lgmd='libgl1-mesa-dri' ldrm='libdrm2'
  5741.  
  5742. if [ "$NATIVE_OVERRIDE" == 'radeon' ];then
  5743. if [ -z "$( check_package_status "$lgmd" 'i' )" ];then
  5744. install_package $lgmd
  5745. fi
  5746. if [ -z "$( check_package_status "$ldrm" 'i' )" ];then
  5747. install_package $ldrm
  5748. fi
  5749. if [ -n "$( type -P deborphan )" ];then
  5750. # doing one at a time because if one is already on keep,
  5751. # trying to add both will fail
  5752. deborphan --add-keep $lgmd > /dev/null
  5753. deborphan --add-keep $ldrm > /dev/null
  5754. fi
  5755. fi
  5756. eval $LOGUE
  5757. }
  5758.  
  5759. # args: $1 $driver; $2 $currentlyInstalled
  5760. native_driver_experimental()
  5761. {
  5762. eval $LOGPS
  5763. if [ "$CARD" == $FGLRX ];then
  5764. # step one, check and install basic drivers
  5765. if [ -n "$EXPERIMENTAL_XORG_ATI" ];then
  5766. echo "${S}Starting experimental driver ${C}$1${S} install now...${N}"
  5767. download_install_package freedesktop-ati
  5768. unset packageExists
  5769. else
  5770. error_handler 187 exp-xorg-ati
  5771. fi
  5772. # step 2, if required, check and install extra packages
  5773. if [ "$B_EXTRA_EXPERIMENTAL" == 'true' -a -n "$EXPERIMENTAL_LIBDRM2" ];then
  5774. echo "${S}Adding experimental components for ${C}$1${S} now...${N}"
  5775. download_install_package freedesktop-ati-drm2
  5776. download_install_package freedesktop-ati-drm-dev
  5777. unset packageExists
  5778. else
  5779. error_handler 187 exp-drm2
  5780. fi
  5781. fi
  5782. eval $LOGPE
  5783. }
  5784.  
  5785. # this is for non-standard debs, and other stuff, for experimental use primarily
  5786. download_install_package()
  5787. {
  5788. eval $LOGUS
  5789. local packageToInstall='' url='' systemType='_i386.deb' shortPackage=''
  5790. if [ "$BITS" == '64' ];then
  5791. systemType='_amd64.deb'
  5792. fi
  5793.  
  5794. case $1 in
  5795. freedesktop-ati)
  5796. packageToInstall=$EXPERIMENTAL_XORG_ATI$systemType
  5797. ;;
  5798. freedesktop-ati-drm2)
  5799. packageToInstall=$EXPERIMENTAL_LIBDRM2$systemType
  5800. ;;
  5801. freedesktop-ati-drm-dev)
  5802. packageToInstall=$EXPERIMENTAL_LIBDRM_DEV$systemType
  5803. ;;
  5804. esac
  5805.  
  5806. url=$SCRIPT_DOWNLOAD'ati-drivers/'$packageToInstall
  5807. if [ -z "$packageToInstall" ];then
  5808. error_handler 187 download-package
  5809. fi
  5810. # slice out first part of name for package display purposes
  5811. shortPackage=$( echo $packageToInstall | cut -d '_' -f 1 )
  5812.  
  5813. echo "${S}Downloading Experimental package ${C}$shortPackage${S} now...${N}"
  5814. wget -Nc $url || error_handler 189 $packageToInstall
  5815.  
  5816. if [ -s "$packageToInstall" ];then
  5817. echo "${S}Experimental package ${C}$shortPackage${S} downloaded successfully, installing now.${N}"
  5818. dpkg -i $packageToInstall
  5819. rm -f $packageToInstall
  5820. else
  5821. #rm -f $packageToInstall
  5822. error_handler 188 $packageToInstall
  5823. fi
  5824. eval $LOGUE
  5825. }
  5826.  
  5827. prep_native_driver()
  5828. {
  5829. eval $LOGUS
  5830. local xxva='xserver-xorg-video-ati' ldrmd='libdrm-dev'
  5831. local packageList=''
  5832.  
  5833. case $CARD in
  5834. $FGLRX)
  5835. packageList="$xxva $ldrmd"
  5836. ;;
  5837. esac
  5838. eval $LOGUE
  5839. remove_package "$packageList" "$xxva"
  5840. }
  5841.  
  5842. ### -------------------------------------------------------------------
  5843. ### KMS Tools - Modesetting On/Off, Blacklist On/Off, Initramfs set
  5844. ### -------------------------------------------------------------------
  5845.  
  5846. # $1 - module to be handled; $2 - optional: failed (triggers reboot requirement)
  5847. set_modesetting_off()
  5848. {
  5849. eval $LOGPE
  5850. local bShowMessage='false' retValue=1 # default false
  5851.  
  5852. case $1 in
  5853. nouveau|radeon)
  5854. case $SYSTEM_BASE in
  5855. # note that the nvidia installer now requires blacklisting a priori, so
  5856. # just treat arch like the other distros
  5857. # arch)
  5858. # if [ "$2" == 'failed' ];then
  5859. # echo $LINE
  5860. # echo "${S}Please note: Arch users: you can proceed with your driver install, but you must ${S}reboot${S}"
  5861. # echo "at the end of ${C}$SCRIPT_NAME${S} when the install is completed before the driver will work."
  5862. # echo "This is because its not possible to remove ${C}$1${S} from a running system.${N}"
  5863. # print_hec
  5864. # fi
  5865. # ;;
  5866. *)
  5867. # only act if blacklist/nomodeset was added
  5868. add_grub_nomodeset_blacklist_item $1
  5869. retValue=$?
  5870. if [ "$retValue" -eq 0 ];then
  5871. bShowMessage='true'
  5872. fi
  5873. add_modprobe_d_blacklist_item $1
  5874. retValue=$?
  5875. if [ "$retValue" -eq 0 ];then
  5876. bShowMessage='true'
  5877. fi
  5878. if [ "$bShowMessage" == 'true' ];then
  5879. update_initramfs "remove-$1"
  5880. fi
  5881.  
  5882. if [ "$bShowMessage" == 'true' -a "$2" == 'failed' ];then
  5883. # note: we don't want nouveau to try to restart on reboot, so we're changing
  5884. # xorg.conf to use vesa here.
  5885. NATIVE_OVERRIDE='vesa'
  5886. B_NATIVE_DRIVER='true'
  5887. echo "${S}Setting ${C}$EXXC${S} to use ${C}Xorg vesa driver${S} temporarily..... ${N}"
  5888. update_xorgconf_driver_version
  5889. reboot_now_question "$1" 'modeset-off'
  5890. fi
  5891. ;;
  5892. esac
  5893. ;;
  5894. esac
  5895. eval $LOGPS
  5896. }
  5897.  
  5898. # $1 - module to be handled; $2 - optional: failed (triggers reboot requirement)
  5899. set_modesetting_on()
  5900. {
  5901. eval $LOGPS
  5902. local bShowMessage='false'
  5903.  
  5904. case $1 in
  5905. modesetting|nouveau|radeon)
  5906. # only act if blacklist/nomodeset was removed
  5907. remove_grub_nomodeset_blacklist_item $1
  5908. if [ "$?" -eq 0 ];then
  5909. bShowMessage='true'
  5910. fi
  5911. remove_modprobe_d_blacklist_item $1
  5912. if [ "$?" -eq 0 ];then
  5913. bShowMessage='true'
  5914. fi
  5915. if [ "$bShowMessage" == 'true' ];then
  5916. update_initramfs "add-$1"
  5917. fi
  5918. if [ "$bShowMessage" == 'true' -a "$2" == 'failed' ] || [ -n "$NON_FREE_DRIVER" ];then
  5919. reboot_now_question "$1" 'modeset-on'
  5920. fi
  5921. ;;
  5922. esac
  5923. eval $LOGPE
  5924. }
  5925.  
  5926. get_active_grub_files()
  5927. {
  5928. eval $LOGUS
  5929. local grubFiles=''
  5930.  
  5931. if [ -f "$GRUB1_FED" ];then
  5932. grubFiles="$GRUB1_FED"
  5933. else
  5934. if [ -f "$GRUB1" ];then
  5935. grubFiles="$GRUB1"
  5936. fi
  5937. if [ -f "$GRUB2" ];then
  5938. grubFiles="$grubFiles $GRUB2"
  5939. fi
  5940. if [ -f "$GRUBED" ];then
  5941. grubFiles="$grubFiles $GRUBED"
  5942. fi
  5943. fi
  5944. log_function_data "grub files: $grubFiles"
  5945.  
  5946. if [ -z "$grubFiles" ];then
  5947. error_handler 213 "modesetting-on-off"
  5948. else
  5949. echo $grubFiles
  5950. fi
  5951. eval $LOGUE
  5952. }
  5953.  
  5954. # args: $1 - radeon/nouveau
  5955. add_grub_nomodeset_blacklist_item()
  5956. {
  5957. eval $LOGUS
  5958.  
  5959. local returnValue=1 activeFile='No'
  5960. local noModesetString='nomodeset'
  5961. local noModesetString2="$1.modeset=0"
  5962. local moduleSearch1="nomodeset|rdblacklist=nouveau|rdblacklist=radeon|nouveau.blacklist=1|radeon.blacklist=1"
  5963. local moduleSearch2="nouveau.modeset=0|radeon.modeset=0"
  5964. local grubFiles=$( get_active_grub_files )
  5965.  
  5966. case $SYSTEM_BASE in
  5967. fedora)
  5968. noModesetString="rdblacklist=$1 nomodeset"
  5969. ;;
  5970. esac
  5971.  
  5972. if [ -n "$grubFiles" ];then
  5973. if [ -z "$( grep -Eis '('$moduleSearch1')' $grubFiles )" -o -z "$( grep -Eis '('$moduleSearch2')' $grubFiles )" ];then
  5974. echo -n "${S}Adding ${C}$grubFiles $noModesetString/$noModesetString2${S} for ${C}$1${S} blacklist${S} items..... ${N}"
  5975. if [ -f "$GRUB1" ];then
  5976. if [ -z "$( grep -Eis 'kernel.*root=.*('$moduleSearch1')' $GRUB1 )" ];then
  5977. sed -i "/kernel.* root=/s|$| $noModesetString|" $GRUB1
  5978. activeFile=$GRUB1
  5979. fi
  5980. if [ -z "$( grep -Eis 'kopt.*root=.*('$moduleSearch1')' $GRUB1 )" ];then
  5981. sed -i "/kopt.*root=/s|$| $noModesetString|" $GRUB1
  5982. activeFile=$GRUB1
  5983. fi
  5984. if [ -z "$( grep -Eis 'kernel.*root=.*('$moduleSearch2')' $GRUB1 )" ];then
  5985. sed -i "/kernel.* root=/s|$| $noModesetString2|" $GRUB1
  5986. activeFile=$GRUB1
  5987. fi
  5988. if [ -z "$( grep -Eis 'kopt.*root=.*('$moduleSearch2')' $GRUB1 )" ];then
  5989. sed -i "/kopt.*root=/s|$| $noModesetString2|" $GRUB1
  5990. activeFile=$GRUB1
  5991. fi
  5992. fi
  5993. if [ -f "$GRUB2" ];then
  5994. if [ -z "$( grep -Eis 'linux.*root=.*('$moduleSearch1')' $GRUB2 )" ];then
  5995. sed -i "/linux.* root=/s|$| $noModesetString|" $GRUB2
  5996. activeFile=$GRUB2
  5997. fi
  5998. if [ -z "$( grep -Eis 'linux.*root=.*('$moduleSearch2')' $GRUB2 )" ];then
  5999. sed -i "/linux.* root=/s|$| $noModesetString2|" $GRUB2
  6000. activeFile=$GRUB2
  6001. fi
  6002. fi
  6003. if [ -f "$GRUB1_FED" -a ! -f "$GRUB2" ];then
  6004. if [ -z "$( grep -Eis 'kernel.*root=.*('$moduleSearch1')' $GRUB1_FED )" ];then
  6005. sed -i "/kernel.* root=/s|$| $noModesetString|" $GRUB1_FED
  6006. activeFile=$GRUB1_FED
  6007. fi
  6008. fi
  6009.  
  6010. log_function_data "$activeFile file updated to add $1 nomodeset: $grubFiles"
  6011. echo "${S}Added${N}"
  6012. returnValue=0
  6013. fi
  6014. fi
  6015. if [ -f "$GRUBED" ];then
  6016. if [ -z "$( grep -Eis "^GRUB_CMDLINE_LINUX_DEFAULT=.*$moduleSearch1" $GRUBED )" ];then
  6017. echo -n "${S}Adding ${C}$GRUBED $noModesetString${S} for ${C}$1${S} blacklist${S} items..... ${N}"
  6018. sed -r -i 's|GRUB_CMDLINE_LINUX_DEFAULT="(.*)"|GRUB_CMDLINE_LINUX_DEFAULT="\1 '$noModesetString'"|' $GRUBED
  6019. echo "${S}Added${N}"
  6020. log_function_data "File $GRUBED updated to add $1 $noModesetString: $GRUBED"
  6021. returnValue=0
  6022. fi
  6023. if [ -z "$( grep -Eis "^GRUB_CMDLINE_LINUX_DEFAULT=.*$moduleSearch2" $GRUBED )" ];then
  6024. echo -n "${S}Adding ${C}$GRUBED $noModesetString2${S} for ${C}$1${S} blacklist${S} items..... ${N}"
  6025. sed -r -i 's|GRUB_CMDLINE_LINUX_DEFAULT="(.*)"|GRUB_CMDLINE_LINUX_DEFAULT="\1 '$noModesetString2'"|' $GRUBED
  6026. echo "${S}Added${N}"
  6027. log_function_data "File $GRUBED updated to add $1 $noModesetString2: $GRUBED"
  6028. returnValue=0
  6029. fi
  6030. fi
  6031. case $SYSTEM_BASE in
  6032. fedora)
  6033. if [ -f "$GRUB1_FED" -a ! -f "$GRUB2" ];then
  6034. if [ -z "$( grep -si 'vmalloc=' $GRUB1_FED )" ];then
  6035. echo -n "${S}Adding ${C}$GRUB1_FED vmalloc=256m${S} item..... ${N}"
  6036. sed -i '/kernel.* root=/s|$| vmalloc=256m|' $GRUB1_FED
  6037. log_function_data "File $GRUB1_FED updated to add vmalloc=256m: $GRUB1_FED"
  6038. echo "${S}Added${N}"
  6039. fi
  6040. # also make system bootable to init 3 easily with grub, otherwise you can
  6041. # literally not be able to access tty OR desktop in some cases
  6042. if [ -n "$( grep -Eis '^[[:space:]]*(hiddenmenu|timeout=0)' $GRUB1_FED )" ];then
  6043. echo -n "${S}Unhiding grub menu and adding ${C}timeout=3${S} to ${C}$GRUB1_FED${S}..... ${N}"
  6044. sed -i 's|^[[:space:]]*hiddenmenu|#hiddenmenu|' $GRUB1_FED
  6045. sed -i 's|^[[:space:]]*timeout=0|timeout=3|' $GRUB1_FED
  6046. log_function_data "File $GRUB1_FED updated to restore grub timeout/unhide menu: $GRUB1_FED"
  6047. echo "${S}Modified${N}"
  6048. fi
  6049. fi
  6050. ;;
  6051. esac
  6052.  
  6053. eval $LOGUE
  6054. return $returnValue
  6055. }
  6056.  
  6057. # args: $1 - radeon/nouveau
  6058. remove_grub_nomodeset_blacklist_item()
  6059. {
  6060. eval $LOGUS
  6061.  
  6062. local returnValue=1
  6063. local searchReplace1="nomodeset|$1.modeset=0|rdblacklist=$1|$1.blacklist=1"
  6064. local grubFiles=$( get_active_grub_files )
  6065.  
  6066. if [ -n "$grubFiles" ];then
  6067. if [ -n "$( grep -Eis '('$searchReplace1')' $grubFiles )" ];then
  6068. echo -n "${S}Removing ${C}$grubFiles $1 blacklist${S} items..... ${N}"
  6069. sed -ri 's/[[:space:]]('$searchReplace1')//ig' $grubFiles
  6070. log_function_data "file updated to remove $1 blacklist: $grubFiles"
  6071. echo "${S}Removed${N}"
  6072. returnValue=0
  6073. fi
  6074. elif [ "$B_SKIP_GRUB_FILE" == 'true' ];then
  6075. echo "${M}Skipping grub file removal due to ${C}-! 33${M} option being used. Make sure to remove all blacklists"
  6076. echo "and then reboot before you proceed!${N}"
  6077. returnValue=0
  6078. fi
  6079.  
  6080. eval $LOGUE
  6081. return $returnValue
  6082. }
  6083.  
  6084. # args: $1 - nouveau/radeon
  6085. add_modprobe_d_blacklist_item()
  6086. {
  6087. eval $LOGUS
  6088. local empksb='/etc/modprobe.d/kms-sg-blacklist.conf'
  6089. local returnValue=1
  6090.  
  6091. if [ -d /etc/modprobe.d ];then
  6092. if [ -z "$( grep -Es "^[[:space:]]*blacklist[[:space:]]+$1" /etc/modprobe.d/*.conf )" ];then
  6093. echo "${S}Creating ${C}$empksb $1 blacklist${S} item...${N}"
  6094. if [ -f $empksb ];then
  6095. echo -e "blacklist $1" >> $empksb
  6096. else
  6097. echo -e "blacklist $1" > $empksb
  6098. fi
  6099. returnValue=0
  6100. log_function_data "file updated to add $1 blacklist: $empksb"
  6101. fi
  6102. fi
  6103. eval $LOGUE
  6104. return $returnValue
  6105. }
  6106.  
  6107. # args: $1 - nouveau/radeon
  6108. remove_modprobe_d_blacklist_item()
  6109. {
  6110. eval $LOGUS
  6111. local returnValue=1
  6112. local empksb='/etc/modprobe.d/kms-sg-blacklist.conf'
  6113.  
  6114. if [ -d /etc/modprobe.d ];then
  6115. # first dump sgfxi created file if present, not going to use this for now
  6116. if [ -f "$empksb" ];then
  6117. rm -f $empksb
  6118. log_function_data "$empksb deleted from /etc/modprobe.d/"
  6119. fi
  6120. # then edit anything that remains to get rid of that blacklist item
  6121. if [ -n "$( grep -Es '^[[:space:]]*blacklist[[:space:]]+'$1'' /etc/modprobe.d/*.conf )" ];then
  6122. echo "${S}Removed $1 blacklisting from /etc/modprobe.d/*.conf${N}"
  6123. sed -i "s/^[[:space:]]*blacklist[[:space:]]\+$1//i" /etc/modprobe.d/*.conf 2>/dev/null
  6124. returnValue=0
  6125. log_function_data "$1 blacklist removed from /etc/modprobe.d/*.conf"
  6126. fi
  6127. fi
  6128. eval $LOGUE
  6129. return $returnValue
  6130. }
  6131.  
  6132. # 1 - add-nouveau|radeon/remove-nouveau|radeon;
  6133. update_initramfs()
  6134. {
  6135. eval $LOGPS
  6136. local storedNouveau="/boot/initramfs-$KERNEL_FULL-nouveau.img"
  6137. local storedRadeon="/boot/initramfs-$KERNEL_FULL-radeon.img"
  6138. local startingInitram="/boot/initramfs-$KERNEL_FULL.img"
  6139. case $SYSTEM_BASE in
  6140. debian|ubuntu)
  6141. case $1 in
  6142. remove-nouveau|remove-radeon)
  6143. if [ -n "$( type -p update-initramfs )" ];then
  6144. echo "${S}Running ${C}update-initramfs -u${S} to remove Nouveau/Radeon from initrd... ${N}"
  6145. update-initramfs -u -k $KERNEL_FULL
  6146. fi
  6147. ;;
  6148. esac
  6149. ;;
  6150. fedora)
  6151. case $1 in
  6152. remove-nouveau)
  6153. if [ -n "$( type -p dracut )" ];then
  6154. echo "${S}Updating ${C}initramfs${S} to get rid of ${C}nouveau${S} now...${N}"
  6155. mv -f $startingInitram $storedNouveau
  6156. dracut $startingInitram $KERNEL_FULL
  6157. fi
  6158. ;;
  6159. remove-radeon)
  6160. if [ -n "$( type -p dracut )" ];then
  6161. echo "${S}Updating ${C}initramfs${S} to get rid of ${C}radeon${S} now...${N}"
  6162. mv -f $startingInitram $storedRadeon
  6163. dracut $startingInitram $KERNEL_FULL
  6164. fi
  6165. ;;
  6166. add-nouveau)
  6167. if [ -f "$storedNouveau" ];then
  6168. echo "${S}Restoring ${C}initramfs${S} with ${C}nouveau${S} now...${N}"
  6169. mv -f $storedNouveau $startingInitram
  6170. elif [ -n "$( type -p dracut )" ];then
  6171. echo "${S}Building ${C}initramfs${S} with ${C}nouveau${S} now...${N}"
  6172. dracut $startingInitram $KERNEL_FULL
  6173. fi
  6174. ;;
  6175. add-radeon)
  6176. if [ -f "$storedRadeon" ];then
  6177. echo "${S}Restoring ${C}initramfs${S} with ${C}radeon${S} now...${N}"
  6178. mv -f $storedRadeon $startingInitram
  6179. elif [ -n "$( type -p dracut )" ];then
  6180. echo "${S}Building ${C}initramfs${S} with ${C}radeon${S} now...${N}"
  6181. dracut $startingInitram $KERNEL_FULL
  6182. fi
  6183. ;;
  6184. esac
  6185. ;;
  6186. esac
  6187. eval $LOGPE
  6188. }
  6189.  
  6190. # args: $1 - module; $2 - modeset-on/modeset-off
  6191. reboot_now_question()
  6192. {
  6193. eval $LOGPS
  6194. local opt='' options='' initText='' initLevel=''
  6195.  
  6196. case $DISTRIB_ID in
  6197. fedora|aptosid|sidux|mepis|antix|siduction)
  6198. initLevel=3
  6199. ;;
  6200. *)
  6201. initLevel='no-init'
  6202. ;;
  6203. esac
  6204.  
  6205. case $initLevel in
  6206. 2|3|4)
  6207. initText="(use init ${C}$initLevel${M} to start, or use ${C}$initLevel${M} at grub)"
  6208. ;;
  6209. *)
  6210. initText="(use ctrl+alt+F1 to enter console after reboot)"
  6211. ;;
  6212. esac
  6213.  
  6214. echo $MLINE
  6215. if [ "$2" == 'modeset-off' ];then
  6216. echo "${M}Since ${C}$1${M} is running in the kernel, you will need to restart your computer before"
  6217. echo "your ${C}$CARD${M} install is completed, and you may need to reboot again if it errors out,"
  6218. echo "then you can run ${C}$SCRIPT_NAME${M} again and it should work."
  6219. echo
  6220. echo "${S}For best results, select the ${C}shutdown${S} option, let the computer sit for a minute, then restart it."
  6221.  
  6222. echo $MLINE
  6223. echo "${S}Not everyone's systems are having problems getting rid of ${C}$1${S}, but to make the process"
  6224. echo "more consistently safe and reliable this step seems to be a good idea. Once you reboot,"
  6225. echo "the ${C}$1${S} module will not be loaded, and no conflicts or issues should occur."
  6226. echo "You only need to do this one time, since after that the ${C}$1${S} module will not load"
  6227. elif [ "$2" == 'modeset-on' ];then
  6228. echo "${M}To make your new ${C}$1 Xorg / Kernel modules${S} fully functional, you will need to reboot first"
  6229. echo
  6230. echo "${W}The ${C}$1${W} drivers have very unreliable support for newer ${C}nVidia/ATI${W} cards!"
  6231. echo
  6232. echo "${S}If your desktop fails to start properly after you reboot, you may need to do one of two things:"
  6233. echo "1 - move your xorg.conf file to a temporary new file name, like: "
  6234. echo " ${C}mv /etc/X11/xorg.conf /etc/X11/xorg.conf-holder${S}"
  6235. echo " then restart your desktop login manager (like gdm,xdm,kdm). If X then starts, you're fine."
  6236. echo "2 - Add the grub kernel option: ${C}nomodeset${S}"
  6237. echo " at grub load, using the edit (e) method in grub, then boot with that. This will allow"
  6238. echo " you to at least run $SCRIPT_NAME to install the non-free driver."
  6239. fi
  6240. echo $MLINE
  6241. echo "${M}Remember, to install ${C}$CARD${M} drivers, you'll need to run ${C}$SCRIPT_NAME${M} again."
  6242. echo "after you have restarted $initText"
  6243. echo $LINE
  6244. echo "${C}1 - shutdown${S} - Shutdown, wait 30 seconds, then restart manually (${M}RECOMMENDED!${S}).${N}"
  6245. echo "${C}2 - reboot${S} - Reboot. This may not let some data unload from your memory.${N}"
  6246. echo "${C}3 - quit${S} - Exit script, do other things (then restart system to install nvidia).${N}"
  6247. echo $LINE
  6248. options="shutdown reboot quit"
  6249. select opt in $options
  6250. do
  6251. case $opt in
  6252. shutdown)
  6253. echo "${S}Shutting down now...${N}"
  6254. handle_shutdowns 'halt'
  6255. exit 0
  6256. ;;
  6257. reboot)
  6258. echo "${S}Rebooting now...${N}"
  6259. handle_shutdowns 'reboot'
  6260. exit 0
  6261. ;;
  6262. quit)
  6263. echo "${S}Ok, remember you need to reboot before the $1 changes are live.${N}"
  6264. exit 100 # need to exit with 100 to not trigger root pid kill in smxi
  6265. ;;
  6266. *)
  6267. echo "${W}Please select one of the options in the list, thank you.${N}"
  6268. bRepeat='true'
  6269. ;;
  6270. esac
  6271. break
  6272. done
  6273. eval $LOGPE
  6274. if [ "$bRepeat" == 'true' ];then
  6275. reboot_now_question "$@"
  6276. fi
  6277. }
  6278.  
  6279. # args: $1 - shutdown/reboot
  6280. handle_shutdowns()
  6281. {
  6282. eval $LOGUS
  6283.  
  6284. local command='' realCommand=$1
  6285.  
  6286. if [ "$B_SYSTEMD_SYSINIT" == 'true' ];then
  6287. case $realCommand in
  6288. halt)
  6289. realCommand='poweroff'
  6290. ;;
  6291. esac
  6292. # should handle case where mutant systemd systems fail because it is actually running sysvnit
  6293. command="systemctl $realCommand 2>>$LOG_FILE || $1"
  6294. else
  6295. command=$1
  6296. fi
  6297. log_function_data "command: $command"
  6298.  
  6299. eval $LOGUE
  6300. eval $command
  6301. }
  6302.  
  6303. ### -------------------------------------------------------------------
  6304. ### Non-free Driver installer section
  6305. ### -------------------------------------------------------------------
  6306.  
  6307. set_cpu_data()
  6308. {
  6309. eval $LOGUS
  6310. case $CARD in
  6311. $NVIDIA)
  6312. if [ "$BITS" == '64' ];then
  6313. KERNEL_ARCH='_64'
  6314. NV_64_ARCH='_64'
  6315. fi
  6316. ;;
  6317. $FGLRX)
  6318. # this is legacy, no longer needed but in case ati changes again leave it
  6319. KERNEL_ARCH='i386' # default value
  6320. if [ "$BITS" == '64' ];then
  6321. KERNEL_ARCH='amd64'
  6322. fi
  6323. ;;
  6324. esac
  6325.  
  6326. if [ "$B_PRINT_VER" != 'true' ];then
  6327. log_function_data "BITS: $BITS - arch: $KERNEL_ARCH"
  6328. fi
  6329. eval $LOGUE
  6330. }
  6331.  
  6332. ## test if the driver to be installed is in the list of supported drivers
  6333. ## advanced tests occur in driver_support_tests, patches set in check_patch_driver
  6334. check_supported_driver()
  6335. {
  6336. eval $LOGUS
  6337. local isGood='' pattern='[0-9]{4}'
  6338. local drivers="$DRIVER_DEFAULT:$VERSIONS:$DRIVER_BETA:$OTHER_VERSIONS:$DRIVER_QUAD"
  6339.  
  6340. if [ -n "$DRIVER_OVERRIDE" ];then
  6341. isGood=$( echo $drivers | grep "$DRIVER_OVERRIDE" )
  6342. if [ -z "$isGood" ];then
  6343. error_handler 241 $DRIVER_OVERRIDE
  6344. fi
  6345. fi
  6346. if [ "$1" == 'last-check' ];then
  6347. isGood=$( echo $drivers | grep "$DRIVER_DEFAULT" )
  6348. if [ -z "$isGood" ];then
  6349. error_handler 240 $DRIVER_DEFAULT
  6350. fi
  6351. fi
  6352. eval $LOGUE
  6353. }
  6354.  
  6355. set_driver_install_version()
  6356. {
  6357. eval $LOGPS
  6358. local response='' printDriver='' newKernelText='' betaDriverText=''
  6359. local moduleOrInstall='installing' extraBetaInfo=''
  6360. local bDebugger='false'
  6361.  
  6362. # I'm forcing special cases to override the defaults so the data
  6363. # printed out will show what drivers are supported
  6364. if [ -n "$DRIVER_INSTALL" ];then
  6365. DRIVER_DEFAULT=$DRIVER_INSTALL
  6366. fi
  6367.  
  6368. # this is only for du output :: this has to go before assigning -o version number
  6369. if [ "$B_PRINT_VER" == 'true' ];then
  6370. # echo the basic list:
  6371. if [ "$B_USE_DISTRO_DRIVER" != 'true' ];then
  6372. echo $DRIVER_DEFAULT':'$VERSIONS
  6373. else
  6374. # note: because sometimes I'm turning off fglrx run install due to failure
  6375. # that leaves only debian fglrx to install
  6376. echo $DISTRO_FGLRX
  6377. fi
  6378. exit 0
  6379. fi
  6380. # need to puke and die here, not earlier because of print out
  6381. if [ -n "$INSTALL_TO_KERNEL" -a "$B_FGLRX_DIRECT" == 'true' -a "$CARD" == $FGLRX -a "$( uname -r )" != "$INSTALL_TO_KERNEL" ];then
  6382. error_handler 219
  6383. fi
  6384.  
  6385. if [ -n "$DRIVER_OVERRIDE" ];then
  6386. DRIVER_DEFAULT=$DRIVER_OVERRIDE
  6387. fi
  6388. # error_handler 246 $DRIVER_DEFAULT # for unsupported cards
  6389. if [ "$B_USE_DISTRO_DRIVER" != 'true' ];then
  6390. check_supported_driver last-check
  6391. else
  6392. case $CARD in
  6393. $FGLRX)
  6394. DRIVER_DEFAULT=$DISTRO_FGLRX
  6395. ;;
  6396. $NVIDIA)
  6397. DRIVER_DEFAULT=$DISTRO_NVIDIA
  6398. ;;
  6399. esac
  6400. fi
  6401.  
  6402. if [ "$B_SM_INSTALL" != 'true' -a -n "$START_OPTIONS_PRINT" ];then
  6403. print_information_continue 'info' "You are using the following options:\n$START_OPTIONS_PRINT"
  6404. elif [ "$B_SM_INSTALL" == 'true' -a -n "$INSTALL_TO_KERNEL" ];then
  6405. newKernelText="\n${S}onto the kernel: ${C}$INSTALL_TO_KERNEL${N}"
  6406. fi
  6407. # this is only true if use beta flag true and beta driver exists
  6408. if [ "$B_USE_BETA" == 'true' ];then
  6409. case $CARD in
  6410. $NVIDIA|$FGLRX)
  6411. if [ "$B_BETA_EXISTS" == 'true' ];then
  6412. if [ "$bDebugger" == 'true' ];then
  6413. echo "FDB:$FG_DEFAULT_BETA:"
  6414. echo "FBV:$FG_BETA_VERSION:"
  6415. echo "bd:$betaDriver:"
  6416. echo "End assign_standard_or_beta_driver"
  6417. fi
  6418. betaDriverText="\n${M}This is the latest ${C}$CARD Beta driver${M} for your card type.${N}\n"
  6419. if [ "$CARD" == $FGLRX -a -n "$FG_BETA_VERSION" ];then
  6420. extraBetaInfo=" ($FG_BETA_VERSION) "
  6421. fi
  6422. else
  6423. betaDriverText="\n${M}There is ${C}no current beta driver${M} for your ${C}$CARD${M} card type.\n${S}Using the current ${C}stable driver${S} instead.${N}\n"
  6424. fi
  6425. # echo bdt: $betaDriverText
  6426. ;;
  6427. *)
  6428. betaDriverText="\n${M}There is no ${C}beta driver${M} for your ${C}$CARD${M} card.\n${S}Using the current ${C}stable driver${S} instead.${N}\n"
  6429. ;;
  6430. esac
  6431. fi
  6432. if [ "$B_KERNEL_MODULE_ONLY" == 'true' ];then
  6433. moduleOrInstall='building a module for'
  6434. fi
  6435. print_information_continue 'standard' "The graphics installer will be $moduleOrInstall the ${C}$CARD${S} driver: ${C}$DRIVER_DEFAULT$extraBetaInfo${N}$betaDriverText$newKernelText"
  6436.  
  6437. log_function_data "Installing this driver: $DRIVER_DEFAULT$extraBetaInfo"
  6438.  
  6439. eval $LOGPE
  6440. # test for support
  6441. driver_support_tests supported-driver
  6442. }
  6443.  
  6444. # args: $1 - which fix. Holds miscellaneous highly specific fixes, created as needed
  6445. misc_fixes()
  6446. {
  6447. eval $LOGUS
  6448. local outcome=''
  6449. case $1 in
  6450. nvidia-24-link)
  6451. local headersDir="${USRS}linux-headers-$KERNEL_FULL/include"
  6452. # I don't know why the -e/f tests fail, I thought -e means exists at all...
  6453. if [ -L "$headersDir/asm" -o -e "$headersDir/asm" ];then
  6454. rm -f $headersDir/asm
  6455. fi
  6456.  
  6457. echo "${S}Creating symbolic link ${C}asm-x86 asm${S}...${N}"
  6458.  
  6459. ln -sf $headersDir/asm-x86 $headersDir/asm || error_handler 233 "link -s asm-x86 asm"
  6460.  
  6461. if [ ! -e $headersDir/asm-i386 -a "$BITS" == '32' ];then
  6462. log_function_data "Creating soft link asm-x86 asm-i386 in $headersDir"
  6463. echo "${S}Creating symbolic link ${C}asm-x86 asm-i386${S}...${N}"
  6464.  
  6465. ln -s $headersDir/asm-x86 $headersDir/asm-i386 || error_handler 233 "link -s asm-x86 asm-i386"
  6466. log_function_data "Link successfully created."
  6467. else
  6468. log_function_data "link asm-x86 asm-i386 in $headersDir already exists"
  6469. fi
  6470. ;;
  6471. linux-generated-patch)
  6472. local generated1="${USRS}$KERNEL_FULL/include/generated/"
  6473. local generated2="/lib/modules/$KERNEL_FULL/build/include/generated/"
  6474. outcome="$generated1 or $generated2 do not exist"
  6475. if [ -d "$generated1" -o -d "$generated2" ];then
  6476. echo 'true'
  6477. outcome="$generated1 or $generated2 exist"
  6478. fi
  6479. log_function_data "outcome: $outcome"
  6480. ;;
  6481. drm-2-x-test)
  6482. local drmVersion=$( check_package_status 'libdrm2' 'i' )
  6483. local isFixedVersion='' isLessThan=''
  6484. # set to 0 if null to avoid math errors
  6485. if [ -z "$drmVersion" ];then
  6486. drmVersion=0
  6487. fi
  6488. # returns 0 for true/ 1 for false
  6489. dpkg --compare-versions $drmVersion gt 2.4.10
  6490. isFixedVersion=$?
  6491. dpkg --compare-versions $drmVersion lt 2.4
  6492. isLessThan=$?
  6493. log_function_data "isFixedVersion: $isFixedVersion :: isLessThan: $isLessThan"
  6494. if [ "$isFixedVersion" -ne 0 -a "$isLessThan" -ne 0 ];then
  6495. error_handler '220' "$drmVersion"
  6496. fi
  6497. ;;
  6498. esac
  6499. eval $LOGUE
  6500. }
  6501.  
  6502. set_download_info()
  6503. {
  6504. eval $LOGPS
  6505. local packageName='' downloadUrl='' response='' moduleTest=0 fgBetaVersion=''
  6506. # http://us.download.nvidia.com/XFree86/Linux-x86/275.19/NVIDIA-Linux-x86-275.19.run
  6507. case $CARD in
  6508. $NVIDIA)
  6509. # set the package name, .run is added to it when it's needed
  6510. DRIVER_FILE="NVIDIA-Linux-x86$NV_64_ARCH-$DRIVER_DEFAULT$NV_PKG_NO"
  6511. downloadUrl="$NVIDIA_DOWNLOAD_SITE/XFree86/Linux-x86$KERNEL_ARCH/$DRIVER_DEFAULT/"
  6512. ;;
  6513. $FGLRX)
  6514. # set driver package name
  6515. # DRIVER_FILE="ati-driver-installer-$DRIVER_DEFAULT-$CPU"
  6516. if [ "$B_USE_BETA" == 'true' ];then
  6517. # note: need beta* because amd releases numbered betas within a month release
  6518. # # http://www2.ati.com/drivers/beta/amd-driver-installer-catalyst-13.3-beta3-linux-x86.x86_64.zip
  6519. # http://www2.ati.com/drivers/beta/amd-driver-installer-catalyst-13-6-beta-x86.x86_64.zip
  6520. # amd-catalyst-13.6-beta-linux-x86.x86_64.run
  6521. if [ -n "$FG_BETA_VERSION" ];then
  6522. fgBetaVersion="-$FG_BETA_VERSION"
  6523. fi
  6524. if [ "$B_AMD" == 'true' ];then
  6525. downloadUrl='http://www2.ati.com/drivers/beta/'
  6526. else
  6527. downloadUrl=$SCRIPT_DOWNLOAD_ALT
  6528. fi
  6529. # note, amd changed this AGAIN!!! for their damned betas
  6530. # www2.ati.com/drivers/beta/amd-catalyst-13.8-beta1-linux-x86.x86_64.zip
  6531. # www2.ati.com/drivers/beta/amd-driver-installer-catalyst-13-6-beta-x86.x86_64.zip
  6532. # DO NOT BUY AMD CARDS if you want competent nonfree video driver support!!!
  6533. if [ "$DRIVER_DEFAULT" == '13.6' ];then
  6534. FG_POST=''
  6535. fi
  6536. else
  6537. if [ "$B_AMD" == 'true' ];then
  6538. downloadUrl='http://www2.ati.com/drivers/linux/'
  6539. else
  6540. downloadUrl=$SCRIPT_DOWNLOAD_ALT
  6541. fi
  6542. fi
  6543. DRIVER_FILE="$FGLRX_PACKAGE_PREFIX-$DRIVER_DEFAULT$fgBetaVersion-${FG_POST}x86.x86_64"
  6544. ;;
  6545. esac
  6546.  
  6547. log_function_data "download url: $downloadUrl - driver file: $DRIVER_FILE"
  6548.  
  6549. eval $LOGPE
  6550.  
  6551. # absolute override
  6552. if [ "$B_KERNEL_MODULE_ONLY" == 'true' ];then
  6553. : # do nothing
  6554. # otherwise if -f used, force install
  6555. elif [ "$B_FORCE_OPTION" == 'true' ];then
  6556. download_extract_driver $downloadUrl $DRIVER_FILE
  6557. else
  6558. case $CARD in
  6559. $NVIDIA)
  6560. # leaving in test flags in case something goes wrong in early tests
  6561. # if [ "$B_TESTING_5" == 'true' ];then
  6562. test_module_build_ok 'return'
  6563. moduleTest="$?"
  6564. if [ "$moduleTest" -eq 0 ];then
  6565. build_kernel_module_only 'build' 'silent'
  6566. else
  6567. echo $LINE
  6568. echo "${S}Unable to rebuild module from previous driver install. Reinstalling driver instead.${N}"
  6569. if [ -n "$DISPLAY" -a "$B_TESTING_2" != 'true' -a "$B_SKIP_X_TEST" != 'true' -a "$B_LAUNCH_FROM_X" != 'true' ];then
  6570. echo "${W}Sorry, installing the ${C}nVidia${W} driver can't be done in ${C}X${W}.${N}"
  6571. error_handler 250
  6572. fi
  6573. download_extract_driver $downloadUrl $DRIVER_FILE
  6574. fi
  6575. # else
  6576. # download_extract_driver $downloadUrl $DRIVER_FILE
  6577. # fi
  6578. ;;
  6579. $FGLRX)
  6580. download_extract_driver $downloadUrl $DRIVER_FILE
  6581. ;;
  6582. esac
  6583. fi
  6584. }
  6585.  
  6586. # arg: $1 install package to remove
  6587. pre_extract_clean_set_up()
  6588. {
  6589. eval $LOGUS
  6590. # this is only made for binary run packge installs
  6591. if [ -d "$SCRIPT_WORKING_DIR" ];then
  6592. cd $SCRIPT_WORKING_DIR
  6593. fi
  6594. if [ "$B_NATIVE_DRIVER" != 'true' ];then
  6595. rm -rf $1 # this removes nvidia install dir if present
  6596. fi
  6597.  
  6598. # clean up any old stuff that might be left from last install, fglrx stuff
  6599. # note: with 8.35.x ati switched to a randomly generated directory name
  6600. # using the format fgrlx-install.FRGDXE
  6601. rm -rf $FG_WORKING_DIR* /tmp/fglrx*
  6602. rm -f /etc/fglrxrc /etc/fglrxprofiles.csv fglrx*
  6603. eval $LOGUE
  6604. }
  6605.  
  6606. # args: $1 download url; $2 package name
  6607. download_extract_driver()
  6608. {
  6609. eval $LOGPS
  6610. local runPackage=$2'.run' errorTemp='' atiRef='' downloadPackage=$2 extension=''
  6611. local zipPackage=$2'.zip' runZipPackage=$2'.run.zip' extractError=0
  6612. local uA='Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:24.0) Gecko/20100101 Firefox/24.0'
  6613. local downloadFrom=" from ${C}$1${S}"
  6614.  
  6615. pre_extract_clean_set_up $2 ## $2 will only apply to nvidia install dir removal
  6616.  
  6617. # test for existing downloaded version, then download, error if download fails
  6618. # have to keep it in a clean if to avoid error
  6619. if [ ! -f $runPackage -a ! -f $zipPackage -a ! -f $runZipPackage ];then
  6620. case $CARD in
  6621. $NVIDIA)
  6622. downloadPackage=$runPackage
  6623. ;;
  6624. $FGLRX)
  6625. # this was needed to avoid some test from ati... still needed due to inconsistent amd site
  6626. atiRef='--referer=support.ati.com '
  6627. # atiRef='' $uA
  6628. # 12-8 was released, maybe on purpose, who knows, with a zipped .run file, why? who knows
  6629. # if wget -q --spider $uA $atiRef $1$runZipPackage;then
  6630. # echo "${S}Run package using .run.zip format. Preparing for zip/unzip procedure...${N}"
  6631. # downloadPackage=$runZipPackage
  6632. # extension='zip'
  6633. if [ "$B_AMD" == 'true' ];then
  6634. if wget -q --spider -U "$uA" $atiRef $1$zipPackage;then
  6635. echo "${S}Run package using .zip format. Preparing for zip/unzip procedure...${N}"
  6636. downloadPackage=$zipPackage
  6637. extension='zip'
  6638. else
  6639. downloadPackage=$runPackage
  6640. fi
  6641. else
  6642. downloadPackage=$zipPackage
  6643. atiRef=''
  6644. extension='zip'
  6645. uA="s-tools/sgfxi-data.driver-$DRIVER_DEFAULT$fgBetaVersion"
  6646. downloadFrom=' This can sometimes take a while'
  6647. fi
  6648. ;;
  6649. esac
  6650. echo "${S}Downloading ${C}$downloadPackage${S}$downloadFrom...${N}"
  6651. wget -Nc -U "$uA" $atiRef $1$downloadPackage || error_handler 197 $downloadPackage
  6652. else
  6653. case $CARD in
  6654. $FGLRX)
  6655. if [ -f $zipPackage ];then
  6656. extension='zip'
  6657. downloadPackage=$zipPackage
  6658. elif [ -f $runZipPackage ];then
  6659. extension='zip'
  6660. downloadPackage=$runZipPackage
  6661. elif [ -f $runPackage ];then
  6662. downloadPackage=$runPackage
  6663. fi
  6664. esac
  6665. echo "${S}Using the previously downloaded installer package: ${C}$downloadPackage${N}"
  6666. fi
  6667.  
  6668. echo "${S}Extracting ${C}$downloadPackage${S}...${N}"
  6669. case $CARD in
  6670. $NVIDIA)
  6671. # extract it, on error delete and call error handling
  6672. bash ./$runPackage --extract-only 1>> $LOG_FILE 2>> $LOG_FILE
  6673. errorTemp="$?"
  6674. ;;
  6675. $FGLRX)
  6676. # here we want to end up with a directory name like: fglrx-install-9-6
  6677. if [ "$extension" == 'zip' ];then
  6678. # note, contents of zip file are not named the same as say version 12-8, rather: 8.982
  6679. # typical amd inconsistentencies force further testing to make sure the thing that downloaded actually
  6680. # is a real zip file.
  6681. # rm this so we always have the new one
  6682. if [ "$B_AMD" != 'true' ];then
  6683. rm -f amdLICENSE.txt 2>/dev/null
  6684. fi
  6685. unzip -l ./$downloadPackage &>>$LOG_FILE || extractError="$?"
  6686. # note, amd is clearly being run by total incompetents at this stage, the -v9.4 beta has this file name:
  6687. # "amd-catalyst-13.11-beta V9.4-linux-x86.x86_64.run" clearly amd is using either budget outsourced labor
  6688. # or they have no adults in charge (note the space, the upper case V, etc, total lack of any attempt
  6689. # at basic discipline, really pathetic, sell your amd stock is my advice).
  6690. if [ "$extractError" -eq 0 ];then
  6691. runPackage=$( unzip -l ./$downloadPackage | grep -E 'amd-(catalyst|driver-installer)?.*.run$' | sed 's/beta[[:space:]]V/beta-v/' | awk '{print $NF}' )
  6692. else
  6693. log_function_data "fglrx zip extraction -l action failed."
  6694. fi
  6695. # echo $runPackage run
  6696. if [ ! -f $runPackage ];then
  6697. if [ "$extractError" -eq 0 ];then
  6698. unzip ./$downloadPackage 2>>$LOG_FILE || extractError="$?"
  6699. if [ "$extractError" -eq 0 ];then
  6700. echo "${S}Run package ${C}$runPackage${S} extracted from: ${C}$downloadPackage${N}"
  6701. log_function_data "fglrx zip extraction of run file succeeded."
  6702. fi
  6703. fi
  6704. else
  6705. echo "${S}Run package already extracted, using: ${C}$runPackage${N}"
  6706. fi
  6707. if [ "$extractError" -gt 0 ];then
  6708. echo "${M}Removing bad zip package:${C}$downloadPackage${N}"
  6709. rm -f $downloadPackage
  6710. error_handler 165 "$downloadPackage"
  6711. else
  6712. log_function_data "fglrx zip extraction of run file successful."
  6713. fi
  6714. # rm -f ./$downloadPackage
  6715. fi
  6716. LC_ALL= LC_CTYPE= LC_MESSAGES= LANG= bash ./$runPackage --extract $FG_WORKING_DIR-$DRIVER_DEFAULT 1>> $LOG_FILE 2>> $LOG_FILE
  6717. errorTemp="$?"
  6718. if [ -f $zipPackage -o -f $runZipPackage ];then
  6719. rm -f $runPackage
  6720. fi
  6721. ;;
  6722. esac
  6723.  
  6724. if [ "$errorTemp" -gt 0 -a "$B_TESTING_2" != 'true' ];then
  6725. rm -f $runPackage
  6726. error_handler 196 $runPackage
  6727. fi
  6728.  
  6729. eval $LOGPE
  6730. }
  6731.  
  6732. prep_install()
  6733. {
  6734. eval $LOGPS
  6735. local gccVersion=$( grep -Eio 'gcc[[:space:]]*version[[:space:]]*[4-7]\.[0-9]{1,2}' /proc/version | grep -Eo '[4-7]\.[0-9]{1,2}' )
  6736. local gccPackage="gcc-$gccVersion"
  6737. local libMesaGlx='' ubgv='' bUpdateGcc='false'
  6738.  
  6739. case $SYSTEM_BASE in
  6740. arch)
  6741. gccPackage='gcc'
  6742. libMesaGlx='libgl'
  6743. # -n "$gccVersion" -a
  6744. if [ -n "$gccVersion" -a -z "$( check_package_status "$gccPackage" 'i' | grep "$gccVersion" )" ];then
  6745. bUpdateGcc='true'
  6746. fi
  6747. ;;
  6748. debian)
  6749. libMesaGlx='libgl1-mesa-glx'
  6750. # it looks like maybe as of gcc 5 debian dropped the decimal
  6751. if [ -n "$gccVersion" -a -n "$( grep -E '^[5-9]' <<< $gccVersion)" ];then
  6752. gccVersion=$(grep -Eo '^[5-9]' <<< $gccVersion )
  6753. gccPackage="gcc-$gccVersion"
  6754. fi
  6755. ;;
  6756. ubuntu)
  6757. libMesaGlx='libgl1-mesa-glx'
  6758. if [ -n "$gccVersion" -a -n "$( grep -E '^[5-9]' <<< $gccVersion)" ];then
  6759. gccVersion=$(grep -Eo '^[5-9]' <<< $gccVersion )
  6760. gccPackage="gcc-$gccVersion"
  6761. fi
  6762. ;;
  6763. fedora)
  6764. gccPackage='gcc'
  6765. if [ -n "$gccVersion" -a -z "$( check_package_status "$gccPackage" 'i' | grep "$gccVersion" )" ];then
  6766. bUpdateGcc='true'
  6767. fi
  6768. ;;
  6769. esac
  6770. ubgv="/usr/bin/$gccPackage"
  6771.  
  6772. case $CARD in
  6773. $FGLRX)
  6774. if [ "$B_TESTING_5" != 'true' ];then
  6775. install_package "$libMesaGlx" '' 'reinstall'
  6776. fi
  6777. ;;
  6778. esac
  6779.  
  6780. # We now need to do active detection of fglrx-install directory name due to
  6781. # silly random directory naming schema ati just started with 8.35.5
  6782. # Note: you can set --extract $FG_WORKING_DIR to hard code this name
  6783.  
  6784. echo "${S}Preparing driver install...${N}"
  6785. # this is causing aptitude to queue some signals that then make aptitude
  6786. # try to reinstall all of the debian packages next time: aptitude install
  6787. # is run, for example, on smxi kernel install. So turning that off for now.
  6788. # if [ "$B_TESTING_6" != 'true' ];then
  6789. # if [ -f $EDV -a ! -f /etc/sidux-version -a ! -f /etc/aptosid-version ];then
  6790. # m-a -i prepare
  6791. # fi
  6792. # fi
  6793.  
  6794. if [ -x "$ubgv" -a "$bUpdateGcc" != 'true' ];then
  6795. export CC=$ubgv
  6796. else
  6797. # going to try to update gcc to kernel version first before error exit.
  6798. if [ -n "$( check_package_status "$gccPackage" 'c' )" ];then
  6799. install_package "$gccPackage"
  6800. # this may not be needed, we'll see how it goes.
  6801. # if [ "$( check_package_status "g++-$gccVersion" 'c' )" ];then
  6802. # install_package "g++-$gccVersion"
  6803. # fi
  6804. export CC=$ubgv
  6805. else
  6806. if [ "$SYSTEM_BASE" != 'fedora' ];then #for fedora dev only
  6807. error_handler 230 "$ubgv"
  6808. fi
  6809. fi
  6810. fi
  6811. eval $LOGPE
  6812. }
  6813.  
  6814. set_install_directory()
  6815. {
  6816. case $CARD in
  6817. $NVIDIA)
  6818. INSTALL_DIRECTORY=$DRIVER_FILE
  6819. ;;
  6820. $FGLRX)
  6821. INSTALL_DIRECTORY=$( ls | grep "$FG_WORKING_DIR" )
  6822. ;;
  6823. esac
  6824. cd $SCRIPT_WORKING_DIR/$INSTALL_DIRECTORY
  6825. log_function_data "Function: set_install_directory - set to: $SCRIPT_WORKING_DIR/$INSTALL_DIRECTORY"
  6826. }
  6827.  
  6828. preinstall_cleanup()
  6829. {
  6830. eval $LOGPS
  6831. local oldNvidia='' divertedPackages='' installer='nvidia-installer' oldFglrx=''
  6832. local fglrxUninstaller='/usr/share/ati/fglrx-uninstall.sh' useForce=''
  6833. local bNvidiaError='false' bFglrxError='false' nvidiaGlxExtras='' extraPackageBan=''
  6834.  
  6835. # yep, you guessed it, another stupid pointless amd/ati change. Discipline guys....
  6836. if [ -e /usr/share/ati/amd-uninstall.sh ];then
  6837. fglrxUninstaller='/usr/share/ati/amd-uninstall.sh'
  6838. useForce='--force'
  6839. fi
  6840.  
  6841. echo "${S}Running preinstall cleanup...${N}"
  6842.  
  6843. # this is not set as a path if native driver install
  6844. if [ "$B_NATIVE_DRIVER" != 'true' ];then
  6845. cd $SCRIPT_WORKING_DIR/$INSTALL_DIRECTORY
  6846. fi
  6847. # some legacy cleanup gunk, this can probably be dumped
  6848. if [ -f /etc/modutils/1alsa ];then
  6849. mv /lib/modules/extra/alsa /lib/modules/$KERNEL_FULL/
  6850. rm -f /etc/modutils/1alsa
  6851. if [ -n "$( type -p depmod )" ];then
  6852. depmod $KERNEL_FULL -a
  6853. fi
  6854. fi
  6855.  
  6856. ## nvidia uninstallers, for systems where nvidia has been installed once at least
  6857. # both files should be present in case of previous nvidia install
  6858. if [ -x /usr/bin/$installer ];then
  6859. log_function_data 'Using nvidia uninstaller: /usr/bin/'$installer
  6860. /usr/bin/$installer --uninstall -s -N 1>> $LOG_FILE 2>> $LOG_FILE || installError="$?"
  6861. elif [ -f /usr/lib/libnvidia-tls.so.1 ];then
  6862. log_function_data 'Using local nvidia uninstaller'
  6863. # some cases this will not be present, like to native ati/nv conversion
  6864. if [ -f ./$installer ];then
  6865. ./$installer --uninstall -s -N 1>> $LOG_FILE 2>> $LOG_FILE || installError="$?"
  6866. fi
  6867. fi
  6868. ## NVIDIA removal...
  6869. log_function_data "Pre Remove: nvidia.ko files: \n$( ls /lib/modules/*/kernel/drivers/video/nvidia.ko 2>/dev/null )"
  6870.  
  6871. if [ -n "$installError" ];then
  6872. error_handler 192 $installError
  6873. fi
  6874. # ubuntu-desktop depends on nvidia-common
  6875. case $SYSTEM_BASE in
  6876. ubuntu)
  6877. extraPackageBan='|nvidia-common'
  6878. ;;
  6879. esac
  6880. ## this is just to check after the above un-installer runs, this must be here or the
  6881. ## above packages won't be present, better to let nvidia handle uninstalling itself
  6882. # also can clean out install-binary-gfx packages or nvidia-glx if present
  6883.  
  6884. oldNvidia=$( list_installed_packages 'nvidia' "(libkwinnvidiahack|libgl1-nvidia-glx-ia32|libgl1-nvidia-glx:386|modalias|libvdpau|nvidia-bl-dkms|nvidia-cg-toolkit${extraPackageBan})" )
  6885. # messy, aptitude at least fails to remove these, which makes the uninstall fail
  6886. if [ -n "$( grep 'nvidia-installer-cleanup' <<< $oldNvidia )" ];then
  6887. nvidiaGlxExtras=$( list_installed_packages '(glx-alternative-mesa|glx-diversions)' )
  6888. fi
  6889.  
  6890. if [ -n "$oldNvidia" ];then
  6891. if [ -n "$nvidiaGlxExtras" ];then
  6892. oldNvidia="$oldNvidia $nvidiaGlxExtras"
  6893. fi
  6894. # if [ "$B_TESTING_6" == 'true' ];then
  6895. # this is present in some installs, debian squeeze for example
  6896. # this is also a bug in debian:
  6897. # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=594737
  6898. # http://forums.debian.net/viewtopic.php?f=10&t=55518
  6899. # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=597443
  6900. case $SYSTEM_BASE in
  6901. debian)
  6902. if [ "$SYSTEM_CODENAME" != 'testing' -a "$SYSTEM_CODENAME" != 'sid' ];then
  6903. GL='/usr/lib/xorg/modules/extensions/libglx.so'
  6904. for package in $( dpkg-divert --list | grep "diversion of $GL" | awk '{print $7}' | grep -v -e fglrx-driver -e xorg-driver-fglrx )
  6905. do
  6906. echo "${S}Running diversion removal for: ${C}$package${N}"
  6907. dpkg-divert --package $package --remove $GL 1>> $LOG_FILE 2>> $LOG_FILE
  6908. done
  6909. fi
  6910. ;;
  6911. esac
  6912. # fi
  6913. case $SYSTEM_BASE in
  6914. # libgl will break the removal of nvidia, odd packaging decision, so need to reinstall it.
  6915. # this is a weird way to handle the nvidia/libgl dependency, it's almost a loop if you
  6916. # dont' use the --nodeps flag..
  6917. arch)
  6918. # "$B_USE_DISTRO_DRIVER" != 'true' -a
  6919. if [ -z "$( check_package_status 'libgl' 'i' )" ];then
  6920. if [ -n "$( check_package_status 'libgl' 'c' )" ];then
  6921. install_package 'libgl' '' '--nodeps'
  6922. # redo list because nvidia-utils is removed
  6923. oldNvidia=$( list_installed_packages 'nvidia' '(modalias|libvdpau)' )
  6924. fi
  6925. fi
  6926. ;;
  6927. esac
  6928. case $APT_TYPE in
  6929. apt-get|aptitude)
  6930. # note: aptitude fails to note the removal of these packages if dpkg is used
  6931. # this is a new behavior, relatively, but it means that the same tool that
  6932. # installs package must remove it.
  6933. # if [ "$B_TESTING_6" == 'true' ];then
  6934. # dpkg --purge $oldNvidia 1>> $LOG_FILE 2>> $LOG_FILE || bNvidiaError='true'
  6935. # else
  6936. remove_package "$oldNvidia" '' 'no-loop' 'yes'
  6937. # fi
  6938. ;;
  6939. pacman|yum)
  6940. remove_package "$oldNvidia" '' 'no-loop'
  6941. ;;
  6942. esac
  6943. fi
  6944. if [ "$bNvidiaError" == 'true' ];then
  6945. error_handler 190 "$oldNvidia"
  6946. fi
  6947. # if [ "$B_TESTING_6" != 'true' ];then
  6948. log_function_data "Post Purge/Remove: nvidia.ko files: \n$( ls /lib/modules/*/kernel/drivers/video/nvidia.ko 2>/dev/null )"
  6949. #rm -f /lib/modules/$KERNEL_FULL/kernel/drivers/video/nvidia.ko 1>> $LOG_FILE 2>> $LOG_FILE
  6950. # for real driver installs, we need to remove ALL the existing nvidia driver .ko files
  6951. rm -f /lib/modules/*/kernel/drivers/video/nvidia.ko 1>> $LOG_FILE 2>> $LOG_FILE
  6952. # this is legacy stuff, not currently present
  6953. rm -f /lib/modules/*/volatile/nvidia.ko >/dev/null 1>> $LOG_FILE 2>> $LOG_FILE
  6954. rm -f /usr/local/bin/nvidia-settings /usr/local/bin/nvidia-xconfig 1>> $LOG_FILE 2>> $LOG_FILE
  6955. rm -f /tmp/.X0-lock
  6956. # double check, clean up anything left after uninstaller runs
  6957. rm -rf ${USRS}nvidia* 1>> $LOG_FILE 2>> $LOG_FILE
  6958. rm -rf ${SCRIPT_WORKING_DIR}/nvidia* 1>> $LOG_FILE 2>> $LOG_FILE
  6959. rm -rf ${USRS}modules/nvidia* 1>> $LOG_FILE 2>> $LOG_FILE
  6960. # fi
  6961. # this might need more work to not remove if X failed to stop
  6962. remove_module 'nvidia'
  6963. if [ "$B_NATIVE_DRIVER" != 'true' -a "$CARD" == "$NVIDIA" ];then
  6964. remove_module 'nouveau'
  6965. fi
  6966. ## FGLRX removal...
  6967. # this is for manually installed amdccle removal
  6968. if [ -f /usr/local/bin/amdccle ];then
  6969. rm -f /usr/local/bin/amdccle
  6970. fi
  6971.  
  6972. oldFglrx=$( list_installed_packages 'fglrx' 'modalias' )
  6973. if [ -n "$oldFglrx" ];then
  6974. case $APT_TYPE in
  6975. apt-get|aptitude)
  6976. # if [ "$B_TESTING_6" != 'true' ];then
  6977. # dpkg --purge $oldFglrx 1>> $LOG_FILE 2>> $LOG_FILE || bFglrxError='true'
  6978. # else
  6979. remove_package "$oldFglrx" '' 'no-loop' 'yes'
  6980. # fi
  6981. ;;
  6982. pacman|yum)
  6983. remove_package "$oldFglrx" '' 'no-loop'
  6984. ;;
  6985. esac
  6986. fi
  6987. if [ "$bFglrxError" == 'true' ];then
  6988. error_handler 190 "$oldFglrx"
  6989. fi
  6990. # this is present in some installs, debian etch default for instance
  6991. case $SYSTEM_BASE in
  6992. debian|ubuntu)
  6993. GL='/usr/X11R6/lib/libGL.so.1.2'
  6994. for package in $( dpkg-divert --list | grep "diversion of $GL" | awk '{print $7}' | grep -v -e fglrx-driver -e xorg-driver-fglrx )
  6995. do
  6996. dpkg-divert --package $package --remove $GL 1>> $LOG_FILE 2>> $LOG_FILE
  6997. done
  6998. ;;
  6999. esac
  7000. # then confirm that it's truly not installed in case of manual direct install
  7001. if [ -f "$fglrxUninstaller" ];then
  7002. log_function_data "Using fglrx uninstaller: $fglrxUninstaller force: $useForce"
  7003. bash $fglrxUninstaller $useForce
  7004. fi
  7005. remove_module 'fglrx'
  7006. # this should no longer be required with new dkms, which removes itself fine above,
  7007. # but leaving this here for now for legacy dkms
  7008. # if [ "$B_TESTING_6" != 'true' ];then
  7009. clean_dkms
  7010. # fi
  7011. eval $LOGPE
  7012. }
  7013.  
  7014. ## run patch module, then install
  7015. run_driver_installer()
  7016. {
  7017. eval $LOGPS
  7018. local installError=0 installerArgs='' nothing=''
  7019. local xModPath='/usr/lib/xorg/modules'
  7020. local xLibPath='/usr/lib'
  7021. local installer='nvidia-installer'
  7022. local distroId='' fglrxNumber='1'
  7023. local distroCodeName=''
  7024.  
  7025. # this was set in prep_install()
  7026. cd $SCRIPT_WORKING_DIR/$INSTALL_DIRECTORY
  7027. echo "${S}Running driver installer for ${C}$DRIVER_DEFAULT${S} (this might take a while)...${N}"
  7028.  
  7029. log_function_data "driver: $DRIVER_DEFAULT"
  7030.  
  7031. # run the card installers
  7032. case $CARD in
  7033. $NVIDIA)
  7034. if [ -d $xModPath -a -d $xLibPath ];then
  7035. # --x-library-path=$xLibPath
  7036. installerArgs="-s -N --x-module-path=$xModPath --x-library-path=$xLibPath"
  7037.  
  7038. else
  7039. installerArgs="-s -N"
  7040. fi
  7041. if [ "$B_GUI_MODE" == 'true' ];then
  7042. installerArgs="$installerArgs --no-x-check"
  7043. fi
  7044. # note: handles change from older /emul libs in Debian
  7045. # http://www.nvnews.net/vbulletin/showthread.php?t=135332
  7046. # note that lenny can be assumed to not need, this, so wait til squeeze stable
  7047. if [ "$BITS" == '64' ];then
  7048. # note: it appears that 256.xx changed something here for 64 bit paths, and
  7049. # this is an attempt to fix that, not sure if it will work
  7050. # http://forum.xbmc.org/showthread.php?t=57885
  7051. ## Update: 2010-11-27, apparently this was reverted by nvidia in 260.xx
  7052. # further: --compat32-prefix= with no data seems to cause nvidia installer error
  7053. # and --compat32-chroot=/usr/lib32 seems to also cause undesired location
  7054. case $SYSTEM_BASE in
  7055. debian)
  7056. if [ "$SYSTEM_CODENAME" == 'sid' -o "$SYSTEM_CODENAME" == 'testing' ];then
  7057. # installerArgs="$installerArgs --compat32-prefix= --compat32-libdir= --compat32-chroot=/usr/lib32"
  7058. # installerArgs="$installerArgs --compat32-prefix=/usr --compat32-libdir=lib32 --compat32-chroot=/usr/lib32"
  7059. : # nothing happening now
  7060. fi
  7061. ;;
  7062. ubuntu)
  7063. # installerArgs="$installerArgs --compat32-prefix= --compat32-libdir= --compat32-chroot=/usr/lib32"
  7064. # installerArgs="$installerArgs --compat32-prefix=/usr --compat32-libdir=lib32 --compat32-chroot=/usr/lib32"
  7065. : # nothing happening now
  7066. ;;
  7067. esac
  7068. fi
  7069.  
  7070. installerArgs="$installerArgs -k $KERNEL_FULL $EXTRA_ARGS "
  7071. # fresh arch installs may have the single file but no headers in /usr/src
  7072. # note that this didn't work even though the target file existed
  7073. # if [ "$B_USE_DIRECT_KERNEL_HEADER" == 'true' ];then
  7074. # installerArgs="$installerArgs --kernel-source-path=$KERNEL_HEADER_DIRECT"
  7075. # fi
  7076. ./$installer $installerArgs 1>> $LOG_FILE 2>> $LOG_FILE || installError="$?"
  7077. install_libvdpau
  7078. # only do a final removal of nouveau if the install succeeded
  7079. # remove_module 'nouveau'
  7080. ;;
  7081. $FGLRX)
  7082. distroId=$FG_DISTRIB_ID
  7083. distroCodeName=$FG_DISTRIB_CODENAME
  7084. installer='ati-installer.sh'
  7085. if [ "$B_FGLRX_DIRECT" != 'true' ];then
  7086. installerArgs="$DRIVER_DEFAULT --buildpkg $distroId/$distroCodeName"
  7087. log_function_data "dist-id/dist-codename: $distroId/$distroCodeName"
  7088. fglrxNumber='2'
  7089. else
  7090. echo $MLINE
  7091. echo "${M}NOTE: When the ${C}FGLRX${M} direct installer runs, it will ask you a series of questions."
  7092. echo "Simply hit ${C}<enter>${M} for each question the installer asks you, the defaults are good."
  7093. echo "${M}If the first question asks you which driver method, type the number ${C}$fglrxNumber${M}"
  7094. echo "and then hit ${C}<enter>${M}, then continue to the other questions."
  7095. echo
  7096. echo "${S}Hit ${C}<enter>${S} now to start the direct installer."
  7097. echo $MLINE
  7098. read nothing
  7099. installerArgs="$DRIVER_DEFAULT --install"
  7100. log_function_data "direct fglrx install - no debs: options: $installerArgs"
  7101. fi
  7102.  
  7103. # tell fglrx installer correct x version
  7104. # if [ -n "$( echo $X_VERSION | grep -E '[1-2]\.[4-9]' )" ]
  7105. # then
  7106. # export XVERSION=$X_VERSION
  7107. # export XTYPE='X.Org'
  7108. # fi
  7109. # note: there's a bug in fglrx that apparently will show no error return on failure
  7110. # LC_ALL= LC_CTYPE= LC_MESSAGES= LANG= bash ./$installer $installerArgs 1>> $LOG_FILE 2>> $LOG_FILE
  7111. # ati just made the installer interactive, so can't log the data for now...
  7112. LC_ALL= LC_CTYPE= LC_MESSAGES= LANG= bash ./$installer $installerArgs
  7113. installError="$?"
  7114. ;;
  7115. esac
  7116.  
  7117. if [ "$installError" -gt 0 ];then
  7118. log_driver_installer_failure
  7119. error_handler 245 $installError
  7120. fi
  7121. case $CARD in
  7122. $FGLRX)
  7123. :
  7124. ;;
  7125. esac
  7126. eval $LOGPE
  7127. }
  7128.  
  7129. # nvidia new only
  7130. install_libvdpau()
  7131. {
  7132. local libVdPau=''
  7133.  
  7134. case $SYSTEM_BASE in
  7135. arch)
  7136. # libVdPau='libvdpau'
  7137. libVdPau=''
  7138. ;;
  7139. # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=558369
  7140. # note: until the sid break for nvidia-libvdpau1/nvidia-libvdpau1-driver is fixed...
  7141. # debian)
  7142. # libVdPau='nvidia-libvdpau1-driver'
  7143. # ;;
  7144. esac
  7145.  
  7146. if [ "$B_TESTING_5" != 'true' -a -n "$libVdPau" -a "$LEGACY_LEVEL" -gt 3 ];then
  7147. if [ -z "$( check_package_status "$libVdPau" 'i' )" ];then
  7148. if [ -n "$( check_package_status "$libVdPau" 'c' )" ];then
  7149. install_package "$libVdPau"
  7150. fi
  7151. fi
  7152. fi
  7153. }
  7154.  
  7155. post_installer_steps()
  7156. {
  7157. eval $LOGPS
  7158. local ema='/etc/modutils/aliases' oldFglrx=''
  7159.  
  7160. echo "${S}Running post installer steps...${N}"
  7161.  
  7162. cd $SCRIPT_WORKING_DIR
  7163.  
  7164. rm -rf $INSTALL_DIRECTORY # remove the extracted driver install directory in /usr/src
  7165.  
  7166. ## this I think I will combine into one, just cleanup everything, that will handle
  7167. ## card brand changes more robustly, and leave less cruft in the system
  7168. case $CARD in
  7169. $NVIDIA)
  7170. rm -f /etc/modutils/nvidia
  7171. if [ -f $ema ];then
  7172. perl -pi -e 's|.*char-major-195.*[\n]?||' $ema
  7173. perl -pi -e 's|[\n]?$|\n|' $ema
  7174. echo "alias char-major-195 nvidia" >> $ema
  7175. fi
  7176. ;;
  7177. $FGLRX)
  7178. clean_up_fglrx_junk
  7179. rm -f fglrx-installer_*.changes
  7180. case $SYSTEM_BASE in
  7181. arch)
  7182. if [ -z "$( check_package_status 'mesa' 'i' )" ];then
  7183. if [ -n "$( check_package_status 'mesa' 'c' )" ];then
  7184. install_package 'mesa'
  7185. fi
  7186. fi
  7187. ;;
  7188. esac
  7189. ;;
  7190. esac
  7191. eval $LOGPE
  7192. }
  7193.  
  7194. ### -------------------------------------------------------------------
  7195. ### module tools
  7196. ### -------------------------------------------------------------------
  7197.  
  7198. # $1 - direct/build; $2 - silent [optional]
  7199. build_kernel_module_only()
  7200. {
  7201. eval $LOGPS
  7202. local installedDriver='' moduleResult=0 driverModule='' silent=' '
  7203. local runPackage="$DRIVER_FILE.run"
  7204.  
  7205. # double check that target kernel, or current one, has stuff in /lib/modules
  7206. case $CARD in
  7207. $NVIDIA)
  7208. B_SKIP_INSTALL='true'
  7209. remove_module 'nouveau'
  7210. if [ "$1" == 'direct' ];then
  7211. test_install_kernel_version
  7212. test_module_build_ok 'error'
  7213. fi
  7214. if [ -z "$DISPLAY" -a "$B_KERNEL_MODULE_ONLY" != 'true' ];then
  7215. x_start_stop_master stop
  7216. fi
  7217. echo $LINE
  7218. echo "${S}Building kernel module ${C}$DRIVER_DEFAULT${S} for kernel ${C}$KERNEL_FULL${S} now (can take a while)...${N}"
  7219. if [ "$2" != 'silent' ];then
  7220. bash $SCRIPT_WORKING_DIR/$runPackage $silent -N --kernel-name=$KERNEL_FULL --kernel-module-only -a || moduleResult=$?
  7221. else
  7222. silent=' -s'
  7223. bash $SCRIPT_WORKING_DIR/$runPackage $silent -N --kernel-name=$KERNEL_FULL --kernel-module-only -a 1>> $LOG_FILE 2>> $LOG_FILE || moduleResult=$?
  7224. fi
  7225. if [ "$moduleResult" -ne 0 ];then
  7226. log_driver_installer_failure
  7227. error_handler 171 "$moduleResult"
  7228. else
  7229. echo "${S}Build of module ${C}$DRIVER_DEFAULT${S} for kernel ${C}$KERNEL_FULL${S} was a success!"
  7230. if [ "$B_KERNEL_MODULE_ONLY" == 'true' ];then
  7231. echo "Script will exit now and you can do what you want, the module is working for that kernel.${N}"
  7232. exit 0
  7233. else
  7234. x_start_stop_master start
  7235. fi
  7236. fi
  7237. ;;
  7238. *)
  7239. error_handler 173
  7240. ;;
  7241. esac
  7242.  
  7243. eval $LOGPE
  7244. }
  7245.  
  7246. # $1 - error/return
  7247. test_module_build_ok()
  7248. {
  7249. eval $LOGPS
  7250. local runPackage="$DRIVER_FILE.run" returnValue=0 nvidiaPackages=''
  7251. local libGlNvidia='' xorgNvidia='' logData=''
  7252. echo $LINE
  7253. echo "${S}Starting ${C}$NVIDIA module${S} build process checks for kernel: ${C}$KERNEL_FULL${N}"
  7254. echo -n " ${S}Checking for driver run package ${C}$DRIVER_FILE${S}.... ${N}"
  7255. if [ ! -f "$SCRIPT_WORKING_DIR/$runPackage" ];then
  7256. echo "${W}NOT FOUND${N}"
  7257. returnValue=1
  7258. logData="No Driver Run Package: "
  7259. if [ "$1" == 'error' ];then
  7260. error_handler 175 "$runPackage"
  7261. fi
  7262. else
  7263. echo "${S}File Exists${N}"
  7264. fi
  7265. if [ "$returnValue" -eq 0 ];then
  7266. echo -n " ${S}Checking for distribution ${C}nVidia${S} driver packages.... ${N}"
  7267. nvidiaPackages=$( list_installed_packages 'nvidia' '(libkwinnvidiahack|libgl1-nvidia-glx-ia32|libgl1-nvidia-glx:386|modalias|libvdpau)' )
  7268. if [ -n "$nvidiaPackages" ];then
  7269. echo "${W}PRESENT${N}"
  7270. returnValue=2
  7271. logData="${logData}Distro Nvidia Package: "
  7272. if [ "$1" == 'error' ];then
  7273. error_handler 174
  7274. fi
  7275. else
  7276. echo "${S}None Detected${N}"
  7277. fi
  7278. fi
  7279. if [ "$returnValue" -eq 0 ];then
  7280. # really readlink /usr/lib/$( readlink /usr/lib/libGL.so )
  7281. libGlNvidia=$( readlink /usr/lib/libGL.so.1 | grep -Eois '[0-9]{2,3}\.[0-9]{2,3}(\.[0-9]+)?' )
  7282. echo -n " ${S}Checking for installed ${C}nVidia${S} driver.... ${N}"
  7283. if [ -z "$libGlNvidia" ];then
  7284. echo "${W}No $SCRIPT_NAME ${C}nVidia${W} Driver Detected${N}"
  7285. returnValue=3
  7286. logData="${logData}No Installed Nvidia: "
  7287. if [ "$1" == 'error' ];then
  7288. error_handler 169
  7289. fi
  7290. else
  7291. echo "${S}Driver Installed${N}"
  7292. fi
  7293. fi
  7294. if [ "$returnValue" -eq 0 ];then
  7295. echo -n " ${S}Checking installed driver ${C}$libGlNvidia${S} matches requested driver ${C}$DRIVER_DEFAULT${S}.... ${N}"
  7296. if [ "$libGlNvidia" != "$DRIVER_DEFAULT" ];then
  7297. echo "${W}MISMATCH${N}"
  7298. returnValue=4
  7299. logData="${logData}Driver Mismatch $libGlNvidia/$DRIVER_DEFAULT: "
  7300. if [ "$1" == 'error' ];then
  7301. error_handler 172 "$installedDriver"
  7302. fi
  7303. else
  7304. echo "${S}Drivers Match${N}"
  7305. fi
  7306. fi
  7307. if [ "$returnValue" -eq 0 ];then
  7308. echo -n " ${S}Checking to make sure ${C}Xorg${S} has not been updated since last ${C}nVidia${S} install.... ${N}"
  7309. # this file belongs to xserver-xorg but is overwritten by nvidia, so if above test
  7310. # is true and this is null, then xorg has been renewed
  7311. xorgNvidia=$( readlink /usr/lib/xorg/modules/extensions/libglx.so | grep -Eois '[0-9]{2,3}\.[0-9]{2,3}(\.[0-9]+)?' )
  7312. # installedDriver=$( bash $SCRIPT_WORKING_DIR/$runPackage -N --driver-info | grep -Eio 'version:[[:space:]]*[0-9\.]+' | grep -oE '[0-9\.]+' )
  7313. if [ -z "$xorgNvidia" ];then
  7314. echo "${C}Xorg${W} Updated${N}"
  7315. returnValue=5
  7316. logData="${logData}Xorg updated: "
  7317. if [ "$1" == 'error' ];then
  7318. error_handler 168
  7319. fi
  7320. else
  7321. echo "${S}Xorg Not Updated${N}"
  7322. fi
  7323. fi
  7324. # echo "${S}Checking that installed driver is the same as the driver you are having"
  7325. # echo -n "${C}$SCRIPT_NAME${S} build a kernel module for: ${C}$DRIVER_DEFAULT${S}.... ${N}"
  7326. # installedDriver=$( bash $SCRIPT_WORKING_DIR/$runPackage -N --driver-info | grep -Eio 'version:[[:space:]]*[0-9\.]+' | grep -oE '[0-9\.]+' )
  7327. # if [ "$installedDriver" != "$DRIVER_DEFAULT" ];then
  7328. # echo "${W}MISMATCH${N}"
  7329. # returnValue=1
  7330. # if [ "$1" == 'error' ];then
  7331. # error_handler 172 "$installedDriver"
  7332. # fi
  7333. # else
  7334. # echo "${S}Drivers Match${N}"
  7335. # fi
  7336. if [ "$returnValue" -eq 0 ];then
  7337. echo -n " ${S}Checking for previous ${C}nVidia${S} driver module for ${C}$KERNEL_FULL${S}.... ${N}"
  7338. if [ -f "/lib/modules/$KERNEL_FULL/kernel/drivers/video/nvidia.ko" ];then
  7339. echo "${W}PRESENT${N}"
  7340. returnValue=6
  7341. logData="${logData}Nvidia module exists: "
  7342. if [ "$1" == 'error' ];then
  7343. error_handler 170
  7344. fi
  7345. else
  7346. echo "${S}None Detected${N}"
  7347. fi
  7348. fi
  7349. log_function_data "returnValue: $returnValue\nError Data: $logData"
  7350. return "$returnValue"
  7351. eval $LOGPE
  7352. }
  7353.  
  7354. install_modules_to_all_kernels()
  7355. {
  7356. check_root
  7357. local kernels=$(ls /lib/modules | grep -v "$( uname -r )" )
  7358. local otherDriver='' kernel='' grubFile='' kernelInGrub='' kernelsConfirmed=''
  7359. if [ -f "$GRUB2" ];then
  7360. grubFile=$GRUB2
  7361. elif [ -f "$GRUB1_FED" ];then
  7362. grubFile=$GRUB1_FED
  7363. elif [ -f "$GRUB1" ];then
  7364. grubFile=$GRUB1
  7365. fi
  7366. if [ -z "$grubFile" ];then
  7367. error_handler 213 "kernel-module-installer"
  7368. fi
  7369. # this isn't a great test, but it's better than no test, and should avoid a lot of false
  7370. # kernel ids
  7371. case $SYSTEM_BASE in
  7372. debian|ubuntu|fedora)
  7373. echo $LINE
  7374. echo "${S}Confirming full kernel list from ${C}/lib/modules${S}...${N}"
  7375. # make sure the kernels are real, not fake as found in /lib/modules vmware added...
  7376. for kernel in $kernels
  7377. do
  7378. echo -n "${S}Checking ${C}$kernel${S} in ${C}$grubFile${S}.... ${N}"
  7379. kernelInGrub=$( grep -Eis "^[[:space:]]*(kernel|linux).*$kernel" $grubFile )
  7380. if [ -n "$kernelInGrub" ];then
  7381. echo "${M}Confirmed${N}"
  7382. kernelsConfirmed="$kernelsConfirmed $kernel"
  7383. else
  7384. echo "${W}Invalid${N}"
  7385. fi
  7386. done
  7387. ;;
  7388. arch)
  7389. # arch has unreliable kernel naming, not following uname -r, ie: kernel26.img
  7390. kernelsConfirmed=$kernels
  7391. ;;
  7392. esac
  7393. if [ -n "$kernelsConfirmed" ];then
  7394. # support other drivers being used if desired
  7395. if [ -n "$DRIVER_OVERRIDE" ];then
  7396. otherDriver=" -o $DRIVER_OVERRIDE"
  7397. fi
  7398. if [ "$B_USE_BETA" == 'true' ];then
  7399. otherDriver=" -B"
  7400. fi
  7401. echo $LINE
  7402. echo "${S}OK, installing modules to all confirmed kernels now...${N}"
  7403. for i in $kernelsConfirmed
  7404. do
  7405. sgfxi $otherDriver -R -A -k -K $i
  7406. done
  7407. echo $LINE
  7408. echo "${S}Hey, did it work? Great! Bye for now.${N}"
  7409. else
  7410. echo "${S}No kernels found to create modules for. Exiting script now.${N}"
  7411. fi
  7412. exit 0
  7413. }
  7414.  
  7415. # note: for
  7416. # args: $1 - which module; for nouveau used, post nvidia install with no errors
  7417. # use: $2 - nvidia-post - clean grub/module files of nouveau blacklists
  7418. remove_module()
  7419. {
  7420. eval $LOGPS
  7421.  
  7422. local outcome='unset'
  7423.  
  7424. if [ -n "$( lsmod | grep "^$1" )" ];then
  7425. echo -n "${S}Removing module${C} $1${S}...... ${N}"
  7426. modprobe -r $1 1>> $LOG_FILE 2>> $LOG_FILE
  7427. if [ "$?" -ne 0 ];then
  7428. echo "${W}FAILED${N}"
  7429. echo "${M}Error removing ${C}$1${M} module for pre-install cleanup operation."
  7430. echo "Please investigate this further since it may make your $CARD driver install fail.${N}"
  7431. outcome='failed'
  7432. else
  7433. # working that if removal fails, module should not be removed, this might not be
  7434. # correct though. Especially not for future nouveau, radeonhd,
  7435. if [ -f /etc/modules ];then
  7436. perl -pi -e "s/^[[:space:]]*$1.*\n?//" /etc/modules
  7437. fi
  7438. echo "${S}Removed${N}"
  7439. outcome='removed'
  7440. fi
  7441. fi
  7442. log_function_data "operation outcome: $outcome"
  7443. # going to run this for all cases, not just failure, maybe that will work better
  7444. # also, there is an override to skip grub tests, but user has to have handled nouveau/
  7445. # kms blacklisting manually
  7446. if [ "$B_SKIP_GRUB_TEST" == 'true' ];then
  7447. if [ "$outcome" == 'failed' ];then
  7448. error_handler 167 "remove-$1"
  7449. else
  7450. echo "${M}Skipping modesetting section because of user requested ${C}-! 33${M} case.${N}"
  7451. fi
  7452. else
  7453. case $1 in
  7454. nouveau|radeon)
  7455. set_modesetting_off "$1" "$outcome"
  7456. ;;
  7457. esac
  7458. fi
  7459. # if [ "$outcome" == 'failed' ];then
  7460. # set_modesetting_off "$1"
  7461. # fi
  7462.  
  7463. eval $LOGPE
  7464. }
  7465.  
  7466. # args: $1 - module to add or process
  7467. # do some extra processing here for nouveau
  7468. add_module()
  7469. {
  7470. eval $LOGPS
  7471.  
  7472. local outcome='unset'
  7473.  
  7474. echo -n "${S}Adding module${C} $1${S}...... ${N}"
  7475. modprobe $1 1>> $LOG_FILE 2>> $LOG_FILE
  7476. if [ "$?" -ne 0 ];then
  7477. echo "${W}FAILED${N}"
  7478. echo "${M}Error adding ${C}$1${M} module after installation."
  7479. echo "Please investigate this further since it may make your $CARD driver install fail.${N}"
  7480. outcome='failed'
  7481. else
  7482. if [ -z "$( grep "^$1" /etc/modules )" ];then
  7483. echo "$1" >> /etc/modules
  7484. fi
  7485. echo "${S}Added${N}"
  7486. outcome='added'
  7487. fi
  7488. log_function_data "operation outcome: $outcome"
  7489. # going to run this for all cases, not just failure, maybe that will work better
  7490. # handle the no grub file explicitly in this one
  7491. case $1 in
  7492. nouveau|radeon)
  7493. set_modesetting_on "$1" "$outcome"
  7494. ;;
  7495. esac
  7496.  
  7497. # if [ "$outcome" == 'failed' ];then
  7498. # set_modesetting_on "$1"
  7499. # fi
  7500.  
  7501. eval $LOGPE
  7502. }
  7503.  
  7504. # this should in theory all be gone but not necessarily in fact
  7505. # note that fglrx isn't working well here at all...
  7506. # further: 2014-05-05: --debugger dkms data shows individual driver directories top level in dkms
  7507. # this is a change from previous /dkms/nvidia/ style. Update may resolve the lingering failures.
  7508. clean_dkms()
  7509. {
  7510. eval $LOGPS
  7511. local eddma='/etc/default/dmakms'
  7512. if [ -n "$( ls /var/lib/dkms/ | grep -i fglrx )" ];then
  7513. log_function_data "fglrx dkms directories found and deleted:\n$(ls /var/lib/dkms/ | grep -i fglrx)"
  7514. echo "${M}Found and deleted ${C}fglrx dkms${M} material${N}"
  7515. rm -rf /var/lib/dkms/fglrx* 1>> $LOG_FILE 2>> $LOG_FILE
  7516. fi
  7517. if [ -n "$( ls /var/lib/dkms/ | grep -i catalyst )" ];then
  7518. log_function_data "amd-catalyst dkms directories found and deleted:\n$(ls /var/lib/dkms/ | grep -i catalyst)"
  7519. echo "${M}Found and deleted ${C}catalyst dkms${M} material${N}"
  7520. rm -rf /var/lib/dkms/catalyst* 1>> $LOG_FILE 2>> $LOG_FILE
  7521. fi
  7522. if [ -n "$( ls /var/lib/dkms/ | grep -i nvidia )" ];then
  7523. echo "${M}Found and deleted ${C}nvidia dkms${M} material${N}"
  7524. log_function_data "nvidia dkms directories found and deleted:\n$(ls /var/lib/dkms/ | grep -i nvidia)"
  7525. rm -rf /var/lib/dkms/nvidia* 1>> $LOG_FILE 2>> $LOG_FILE
  7526. fi
  7527. # handle the dmakms stuff too if present
  7528. if [ -f "$eddma" ];then
  7529. if [ -n "$( grep -Esi '^[[:space:]]*nvidia-kernel-source' $eddma )" ];then
  7530. log_function_data "nvidia dmakms entry found and commented out"
  7531. sed -i 's/nvidia-kernel-source/#nvidia-kernel-source/' $eddma
  7532. fi
  7533. if [ -n "$( grep -Esi '^[[:space:]]*fglrx-kernel-source' $eddma )" ];then
  7534. log_function_data "fglrx dmakms entry found and commented out"
  7535. sed -i 's/fglrx-kernel-source/#fglrx-kernel-source/' $eddma
  7536. fi
  7537. fi
  7538. eval $LOGPE
  7539. }
  7540.  
  7541. ### -------------------------------------------------------------------
  7542. ### distro fglrx/nvidia driver installer
  7543. ### -------------------------------------------------------------------
  7544.  
  7545. install_distro_drivers()
  7546. {
  7547. eval $LOGPS
  7548. local nvidiaGlx='' nvidiaSource='' nvidiaModal='' nvidiaUtils=''
  7549. local akmodNvidia='' nvidiaDriver='' nvidiaDriver2='' ubGlx='-glx' nvidiaSettings=''
  7550. local fglrxSettings='' fglrxDriver='' fglrxSource=''
  7551.  
  7552. clean_up_fglrx_junk
  7553.  
  7554. case $CARD in
  7555. $NVIDIA)
  7556. case $SYSTEM_BASE in
  7557. arch)
  7558. # dependencies handle the rest of this.
  7559. # nvidia driver package includes nvidia settings
  7560. case $LEGACY_LEVEL in
  7561. 1) :
  7562. # this has already been error handled.
  7563. ;;
  7564. 2) nvidiaDriver="nvidia-$NV_AR_LEGACY_2"
  7565. nvidiaUtils="nvidia-$NV_AR_LEGACY_2-utils"
  7566. ;;
  7567. 3) nvidiaDriver="nvidia-$NV_AR_LEGACY_3"
  7568. nvidiaUtils="nvidia-$NV_AR_LEGACY_3-utils"
  7569. ;;
  7570. 4) nvidiaDriver="nvidia-$NV_AR_LEGACY_4"
  7571. nvidiaUtils="nvidia-$NV_AR_LEGACY_4-utils"
  7572. ;;
  7573. 5) nvidiaDriver="nvidia-$NV_AR_LEGACY_5"
  7574. nvidiaUtils="nvidia-$NV_AR_LEGACY_5-utils"
  7575. ;;
  7576. *) nvidiaDriver="nvidia"
  7577. nvidiaUtils="nvidia-utils"
  7578. ;;
  7579. esac
  7580. echo "${S}Installing ${C}$DISTRO_NVIDIA${S} components...${N}"
  7581. install_package "$nvidiaDriver"
  7582. # conflicts with libgl and removes it
  7583. # install_package "$nvidiaUtils"
  7584. ;;
  7585. debian)
  7586. case $LEGACY_LEVEL in
  7587. # note, changed position of '-kernel' string in package name, not sure which debian stable
  7588. # this happened in, I'll double check. nvidia-glx is not in debian anymore.
  7589. 1) # nvidiaGlx='nvidia-glx-legacy'
  7590. # nvidiaSource='nvidia-kernel-legacy-source'
  7591. # if the two lines below don't work, comment them and uncomment the ones above
  7592. nvidiaDriver="nvidia-legacy-$NV_DEBIAN_LEGACY_1-driver"
  7593. nvidiaGlx="nvidia-glx-legacy-$NV_DEBIAN_LEGACY_1"
  7594. nvidiaSettings="nvidia-settings-legacy-$NV_DEBIAN_LEGACY_1"
  7595. nvidiaSource="nvidia-legacy-$NV_DEBIAN_LEGACY_1-kernel-source"
  7596. ;;
  7597. 2) nvidiaDriver="nvidia-legacy-$NV_DEBIAN_LEGACY_2-driver"
  7598. nvidiaGlx="nvidia-glx-legacy-$NV_DEBIAN_LEGACY_2"
  7599. nvidiaSettings="nvidia-settings-legacy-$NV_DEBIAN_LEGACY_2"
  7600. nvidiaSource="nvidia-legacy-$NV_DEBIAN_LEGACY_2-kernel-source"
  7601. ;;
  7602. 3) nvidiaDriver="nvidia-legacy-$NV_DEBIAN_LEGACY_3-driver"
  7603. nvidiaGlx="nvidia-glx-legacy-$NV_DEBIAN_LEGACY_3"
  7604. nvidiaSettings="nvidia-settings-legacy-$NV_DEBIAN_LEGACY_3"
  7605. nvidiaSource="nvidia-legacy-$NV_DEBIAN_LEGACY_3-kernel-source"
  7606. ;;
  7607. 4) nvidiaDriver="nvidia-legacy-$NV_DEBIAN_LEGACY_4-driver"
  7608. nvidiaGlx="nvidia-glx-legacy-$NV_DEBIAN_LEGACY_4"
  7609. nvidiaSettings="nvidia-settings-legacy-$NV_DEBIAN_LEGACY_4"
  7610. nvidiaSource="nvidia-legacy-$NV_DEBIAN_LEGACY_4-kernel-source"
  7611. ;;
  7612. 5) nvidiaDriver="nvidia-legacy-$NV_DEBIAN_LEGACY_5-driver"
  7613. nvidiaGlx="nvidia-glx-legacy-$NV_DEBIAN_LEGACY_5"
  7614. nvidiaSettings="nvidia-settings-legacy-$NV_DEBIAN_LEGACY_5"
  7615. nvidiaSource="nvidia-legacy-$NV_DEBIAN_LEGACY_5-kernel-source"
  7616. ;;
  7617. *) nvidiaDriver="nvidia-driver"
  7618. nvidiaGlx='nvidia-glx'
  7619. nvidiaSettings="nvidia-settings"
  7620. nvidiaSource='nvidia-kernel-source'
  7621. ;;
  7622. esac
  7623. # start the install/73xx not supported for a while now. Note that this is actually set
  7624. # in the card/xorg version handling, so I don't really need this legacy level test
  7625. if [ "$LEGACY_LEVEL" -gt 2 ];then
  7626. if [ "$B_USE_DISTRO_MODULE_MA" == 'true' ];then
  7627. echo "${S}Installing ${C}$DISTRO_NVIDIA${S} components for ${C}m-a module build${S}...${N}"
  7628. install_package 'nvidia-kernel-common'
  7629. install_package "$nvidiaSettings"
  7630. install_package "$nvidiaSource"
  7631. echo "${S}Creating ${C}$DISTRO_NVIDIA${S} kernel module for kernel ${C}$KERNEL_FULL${S}...${N}"
  7632. # m-a --text-mode --non-inter -f -l ${KERNEL_FULL} a-i $nvidiaSource
  7633. m-a update 1>> $LOG_FILE 2>> $LOG_FILE || error_handler 184 $DISTRO_NVIDIA
  7634. m-a prepare $nvidiaSource 1>> $LOG_FILE 2>> $LOG_FILE || error_handler 185 $DISTRO_NVIDIA
  7635. m-a clean $nvidiaSource 1>> $LOG_FILE 2>> $LOG_FILE || error_handler 182 $DISTRO_NVIDIA
  7636. m-a build -t -f -l $KERNEL_FULL $nvidiaSource 1>> $LOG_FILE 2>> $LOG_FILE || error_handler 194 $DISTRO_NVIDIA
  7637. m-a install -t -f -l $KERNEL_FULL $nvidiaSource 1>> $LOG_FILE 2>> $LOG_FILE || error_handler 193 $DISTRO_NVIDIA
  7638.  
  7639. #m-a prepare && m-a qa-i nvidia
  7640. #nvidiaGlx has dependences problems. Workaround is to build-install the driver before install nvidiaglx
  7641. # echo "${S}Installing ${C}$nvidiaGlx${S} now...${N}"
  7642. # install_package "$nvidiaGlx"
  7643. echo "${M}Please report failure to $SCRIPT_NAME maintainer, I'm not sure this feature works.${N}"
  7644. add_module 'nvidia'
  7645. else
  7646. echo "${S}Installing ${C}$DISTRO_NVIDIA dkms driver${S} components...${N}"
  7647. install_package "$nvidiaSettings $nvidiaDriver"
  7648. add_module 'nvidia'
  7649. fi
  7650. fi
  7651. ;;
  7652. fedora)
  7653. # dependencies handle the rest of this
  7654. # kmod-nvidia xorg-x11-drv-nvidia-libs.i586 xorg-x11-drv-nvidia-libs.x86_64
  7655. # kmod-nvidia-PAE xorg-x11-drv-nvidia-libs.i586 xorg-x11-drv-nvidia-libs.x86_64
  7656. # akmod-nvidia-173xx xorg-x11-drv-nvidia-173xx-libs.i586 xorg-x11-drv-nvidia-173xx-libs.x86_64
  7657. # akmod-nvidia-96xx xorg-x11-drv-nvidia-96xx-libs
  7658. local archExt='i686' archExt64='x86_64'
  7659. if [ "$BITS" == '64' ];then
  7660. archExt=$archExt64
  7661. fi
  7662. case $LEGACY_LEVEL in
  7663. 1) :
  7664. # this has already been error handled.
  7665. ;;
  7666. 2) akmodNvidia="akmod-nvidia$NV_FED_LEGACY_2"
  7667. nvidiaDriver="xorg-x11-drv-nvidia$NV_FED_LEGACY_2-libs.$archExt"
  7668. if [ "$BITS" == '64' ];then
  7669. nvidiaDriver2="xorg-x11-drv-nvidia$NV_FED_LEGACY_2-libs.$archExt64"
  7670. fi
  7671. ;;
  7672. 3) akmodNvidia="akmod-nvidia$NV_FED_LEGACY_3"
  7673. nvidiaDriver="xorg-x11-drv-nvidia$NV_FED_LEGACY_3-libs.$archExt"
  7674. if [ "$BITS" == '64' ];then
  7675. nvidiaDriver2="xorg-x11-drv-nvidia$NV_FED_LEGACY_3-libs.$archExt64"
  7676. fi
  7677. ;;
  7678. 4) akmodNvidia="akmod-nvidia$NV_FED_LEGACY_4"
  7679. nvidiaDriver="xorg-x11-drv-nvidia$NV_FED_LEGACY_4-libs.$archExt"
  7680. if [ "$BITS" == '64' ];then
  7681. nvidiaDriver2="xorg-x11-drv-nvidia$NV_FED_LEGACY_4-libs.$archExt64"
  7682. fi
  7683. ;;
  7684. 5) akmodNvidia="akmod-nvidia$NV_FED_LEGACY_5"
  7685. nvidiaDriver="xorg-x11-drv-nvidia$NV_FED_LEGACY_5-libs.$archExt"
  7686. if [ "$BITS" == '64' ];then
  7687. nvidiaDriver2="xorg-x11-drv-nvidia$NV_FED_LEGACY_5-libs.$archExt64"
  7688. fi
  7689. ;;
  7690. *) akmodNvidia="akmod-nvidia"
  7691. nvidiaDriver="xorg-x11-drv-nvidia-libs.$archExt"
  7692. if [ "$BITS" == '64' ];then
  7693. nvidiaDriver2="xorg-x11-drv-nvidia-libs.$archExt64"
  7694. fi
  7695. ;;
  7696. esac
  7697.  
  7698. echo "${S}Installing ${C}$DISTRO_NVIDIA${S} components...${N}"
  7699. install_package "$akmodNvidia $nvidiaDriver $nvidiaDriver2"
  7700. # only do a final removal of nouveau if the install succeeded
  7701. # remove_module 'nouveau'
  7702.  
  7703. if [ -x /usr/sbin/akmods ];then
  7704. echo "${S}Forcing initial module build of ${C}$akmodNvidia${S} kernel module...${N}"
  7705. /usr/sbin/akmods --force
  7706. fi
  7707. ;;
  7708. ubuntu)
  7709. # note: new ubuntus dropped the -glx string, and current nvidia is
  7710. # just called 'current'
  7711. if [ -n "$( check_package_status 'nvidia-current' 'c' )" ];then
  7712. ubGlx=''
  7713. NV_UB_CURRENT='current'
  7714. fi
  7715. # dependencies handle the rest of this
  7716. case $LEGACY_LEVEL in
  7717. 1) :
  7718. # this has already been error handled.
  7719. ;;
  7720. 2) nvidiaDriver="nvidia${ubGlx}-$NV_UB_LEGACY_2"
  7721. nvidiaSettings="nvidia-settings-$NV_UB_LEGACY_2"
  7722. nvidiaModal="nvidia-$NV_UB_LEGACY_2-modaliases"
  7723. ;;
  7724. 3) nvidiaDriver="nvidia${ubGlx}-$NV_UB_LEGACY_3"
  7725. nvidiaModal="nvidia-$NV_UB_LEGACY_3-modaliases"
  7726. nvidiaSettings="nvidia-settings-$NV_UB_LEGACY_3"
  7727. ;;
  7728. 4) nvidiaDriver="nvidia${ubGlx}-$NV_UB_LEGACY_4"
  7729. nvidiaModal="nvidia-$NV_UB_LEGACY_4-modaliases"
  7730. nvidiaSettings="nvidia-settings-$NV_UB_LEGACY_4"
  7731. ;;
  7732. 5) nvidiaDriver="nvidia${ubGlx}-$NV_UB_LEGACY_5"
  7733. nvidiaModal="nvidia-$NV_UB_LEGACY_5-modaliases"
  7734. nvidiaSettings="nvidia-settings-$NV_UB_LEGACY_5"
  7735. ;;
  7736. *) nvidiaDriver="nvidia${ubGlx}-$NV_UB_CURRENT"
  7737. nvidiaModal="nvidia-$NV_UB_CURRENT-modaliases"
  7738. nvidiaSettings="nvidia-settings"
  7739. ;;
  7740. esac
  7741. echo "${S}Installing ${C}$DISTRO_NVIDIA${S} components...${N}"
  7742. # handle legacy ubuntus
  7743. if [ -n "$ubGlx" ];then
  7744. install_package "$nvidiaModal"
  7745. fi
  7746. install_package "$nvidiaSettings"
  7747. install_package "$nvidiaDriver"
  7748. ;;
  7749. *)
  7750. error_handler 176
  7751. ;;
  7752. esac
  7753. ;;
  7754. $FGLRX)
  7755. case $SYSTEM_BASE in
  7756. arch)
  7757. echo "${S}Installing ${C}$DISTRO_FGLRX${S} components...${N}"
  7758. install_package "catalyst"
  7759. install_package "catalyst-utils"
  7760. ;;
  7761. debian)
  7762. case $LEGACY_LEVEL in
  7763. # fglrx-glx is not in debian anymore.
  7764. 0|1)
  7765. :
  7766. ;;
  7767. 2) fglrxDriver="fglrx-legacy-driver"
  7768. fglrxGlx="fglrx-glx-legacy-glx"
  7769. fglrxSettings="fglrx-legacy-control"
  7770. fglrxSource='fglrx-legacy-source'
  7771. ;;
  7772. *) fglrxDriver="fglrx-driver"
  7773. fglrxGlx='fglrx-glx'
  7774. fglrxSettings="fglrx-control"
  7775. fglrxSource='fglrx-source'
  7776. ;;
  7777. esac
  7778. # start the install/hd2000-4000 not supported; check main legacy level to update this
  7779. if [ "$LEGACY_LEVEL" -gt 1 ];then
  7780. if [ "$B_USE_DISTRO_MODULE_MA" == 'true' ];then
  7781. echo "${S}Installing ${C}$DISTRO_FGLRX m-a module${S} components...${N}"
  7782. # install_package "$fglrxDriver"
  7783. install_package "$fglrxSettings"
  7784. # install_package 'fglrx-amdcccle'
  7785. install_package "$fglrxSource"
  7786. echo "${S}Creating ${C}$DISTRO_FGLRX${S} kernel module for kernel ${C}$KERNEL_FULL${S}...${N}"
  7787.  
  7788. # damentz suggestion to make sure old module is used
  7789. # m-a a-i -f fglrx-kernel-src
  7790. # kelmo: m-a --text-mode --non-inter -f -l ${KERNEL_FULL} a-i fglrx
  7791. m-a update 1>> $LOG_FILE 2>> $LOG_FILE || error_handler 184 $DISTRO_FGLRX
  7792. m-a prepare fglrx 1>> $LOG_FILE 2>> $LOG_FILE || error_handler 185 $DISTRO_FGLRX
  7793. m-a clean fglrx 1>> $LOG_FILE 2>> $LOG_FILE || error_handler 182 $DISTRO_FGLRX
  7794. m-a build -f -l $KERNEL_FULL fglrx 1>> $LOG_FILE 2>> $LOG_FILE || error_handler 194 $DISTRO_FGLRX
  7795. m-a install -f -l $KERNEL_FULL fglrx 1>> $LOG_FILE 2>> $LOG_FILE || error_handler 193 $DISTRO_FGLRX
  7796. else
  7797. echo "${S}Installing ${C}$DISTRO_FGLRX dkms driver${S} components...${N}"
  7798. install_package "$fglrxSettings $fglrxDriver"
  7799. add_module 'fglrx'
  7800. fi
  7801. fi
  7802. ;;
  7803. fedora)
  7804. echo "${S}Installing ${C}$DISTRO_FGLRX${S} components...${N}"
  7805. install_package "akmod-catalyst" # installs both driver and amdcccle
  7806. ;;
  7807. ubuntu)
  7808. echo "${S}Installing ${C}$UBUNTU_FGLRX${S} components...${N}"
  7809. # legacy stuff
  7810. if [ -n "$( check_package_status 'fglrx-modaliases' 'c' )" ];then
  7811. install_package 'fglrx-modaliases'
  7812. fi
  7813. if [ -n "$( check_package_status 'xorg-driver-fglrx' 'c' )" ];then
  7814. install_package 'xorg-driver-fglrx'
  7815. fi
  7816. if [ -n "$( check_package_status 'fglrx-driver' 'c' )" ];then
  7817. install_package 'fglrx-driver'
  7818. fi
  7819. # current, as of T release, 2014
  7820. if [ -n "$( check_package_status 'fglrx' 'c' )" ];then
  7821. install_package 'fglrx'
  7822. fi
  7823. if [ -n "$( check_package_status 'fglrx-amdcccle' 'c' )" ];then
  7824. install_package 'fglrx-amdcccle'
  7825. fi
  7826. ;;
  7827. *)
  7828. error_handler 176
  7829. ;;
  7830. esac
  7831. ;;
  7832. esac
  7833. eval $LOGPE
  7834. }
  7835.  
  7836. ### -------------------------------------------------------------------
  7837. ### ATI fglrx specific stuff
  7838. ### -------------------------------------------------------------------
  7839.  
  7840. clean_up_fglrx_junk()
  7841. {
  7842. eval $LOGUS
  7843. # note that these can't be removed or 3d dies in direct -f install
  7844. if [ "$B_FGLRX_DIRECT" != 'true' ];then
  7845. rm -f /lib/modules/$KERNEL_FULL/kernel/drivers/char/drm/fglrx.*o
  7846. rm -f /lib/modules/$KERNEL_FULL/volatile/fglrx.*o
  7847. # this removes some config stuff that might cause watermarking issues
  7848. # but this breaks direct install systems so don't remove it in direct install
  7849. rm -rf /etc/ati
  7850. fi
  7851.  
  7852. if [ -d /usr/lib/opengl ];then
  7853. rm -rf /usr/lib/opengl
  7854. ldconfig
  7855. log_function_data 'Note: cleanup usr/lib/opengl'
  7856. fi
  7857.  
  7858. eval $LOGUE
  7859. }
  7860.  
  7861. # this is only for fgrlx
  7862. install_fglrx_debs()
  7863. {
  7864. # ati change this syntax too much... hope they stabilize
  7865. # fglrx-amdcccle_8.443.1-1_i386.deb
  7866. # fglrx-driver_8.443.1-1_i386.deb
  7867. # fglrx-driver-dev_8.443.1-1_i386.deb
  7868. # fglrx-installer_8.443.1-1_i386.changes
  7869. # fglrx-kernel-src_8.443.1-1_i386.deb
  7870. if [ "$CARD" == $FGLRX ];then
  7871. eval $LOGPS
  7872. local fgAmd='fglrx-amdcccle_'
  7873. local fgDri='fglrx-driver_'
  7874. local fgKsc='fglrx-kernel-src_'
  7875. local fgDriver="$fgDri$DRIVER_DEFAULT-1_*.deb"
  7876. local fgKsrc='fglrx-kernel-src'
  7877. local fgAmdcccle="$fgAmd$DRIVER_DEFAULT-1_*.deb"
  7878. local fgKernelSrc="$fgKsc$DRIVER_DEFAULT-1_*.deb"
  7879. local fgAlias='' libAmdXv=''
  7880.  
  7881. case $SYSTEM_BASE in
  7882. ubuntu)
  7883. fgDri='xorg-driver-fglrx_'
  7884. fgKsc='fglrx-kernel-source_'
  7885. fgKsrc='fglrx-kernel-source'
  7886. fgDriver="$fgDri*.deb"
  7887. fgAmdcccle="$fgAmd*.deb"
  7888. fgKernelSrc="$fgKsc*.deb"
  7889. libAmdXv='libamdxvb*.deb'
  7890. fgAlias='fglrx-modaliases_*.deb'
  7891. ;;
  7892. esac
  7893.  
  7894. local availableDebs=$( ls *fglrx*.deb )
  7895. local usunf='/usr/sbin/unfreeze-rc.d'
  7896. local frozen=0 forceIt=''
  7897.  
  7898. case $SYSTEM_BASE in
  7899. ubuntu)
  7900. if [ -z "$( check_package_status 'dkms' 'i' )" ];then
  7901. if [ -n "$( check_package_status 'dkms' 'c' )" ];then
  7902. install_package 'dkms'
  7903. fi
  7904. fi
  7905. ;;
  7906. esac
  7907.  
  7908. # this is slightly excessive, but may handle a case where extra debs exist
  7909. # due to weird user action. Also protects against new ati randomness.
  7910. if [ -f $fgDriver ];then
  7911. :
  7912. elif [ -f $fgDri*.deb ];then
  7913. fgDriver=$( ls $fgDri*.deb )
  7914. else
  7915. error_handler 186 $fgDri
  7916. fi
  7917.  
  7918. if [ -f $fgKernelSrc ];then
  7919. :
  7920. elif [ -f $fgKsc*.deb ];then
  7921. fgKernelSrc=$( ls $fgKsc*.deb )
  7922. else
  7923. error_handler 186 $fgKsc
  7924. fi
  7925.  
  7926. if [ -f $fgAmdcccle ];then
  7927. :
  7928. elif [ -f $fgAmd*.deb ];then
  7929. fgAmdcccle=$( ls $fgAmd*.deb )
  7930. else
  7931. error_handler 186 $fgAmd
  7932. fi
  7933.  
  7934. # if [ "$SYSTEM_CODENAME" != 'unstable' ];then
  7935. # forceIt='--force-overwrite'
  7936. # fi
  7937. if [ "$B_TESTING_5" == 'true' ];then
  7938. forceIt='--force-all'
  7939. fi
  7940.  
  7941. log_function_data "These installation debs have been created: $availableDebs"
  7942.  
  7943. echo "${S}Installing fglrx debs for kernel ${C}$KERNEL_FULL${S}...${N}"
  7944. # unfreeze/freeze stuff may be required for some legacy type systems
  7945. if [ -f /etc/frozen-rc.d ];then
  7946. frozen=1
  7947. fi
  7948. if [ -x $usunf ];then
  7949. $usunf
  7950. fi
  7951.  
  7952. log_function_data "Actual driver packages to install:\nfgDriver: $fgDriver\nfgAmdcccle: $fgAmdcccle\nfgKernelSrc: $fgKernelSrc"
  7953.  
  7954. # due to problems with config file questions, trying no logging of 1>> now
  7955. dpkg -i $forceIt $fgKernelSrc 2>> $LOG_FILE || error_handler 195 $fgKernelSrc
  7956. dpkg -i $forceIt $fgDriver 2>> $LOG_FILE || error_handler 195 $fgDriver
  7957. dpkg -i $forceIt $fgAmdcccle 2>> $LOG_FILE || error_handler 195 $fgAmdcccle
  7958.  
  7959. case $SYSTEM_BASE in
  7960. ubuntu)
  7961. if [ -n "$libAmdXv" ];then
  7962. dpkg -i $forceIt $libAmdXv 2>> $LOG_FILE || error_handler 195 $libAmdXv
  7963. else
  7964. echo "${E}ERROR: Missing ${C}$libAmdXv${E} but continuing...${N}"
  7965. fi
  7966. if [ -n "$fgAlias" ];then
  7967. dpkg -i $forceIt $fgAlias 2>> $LOG_FILE || error_handler 195 $libAmdXv
  7968. else
  7969. echo "${E}ERROR: Missing ${C}$fgAlias${E} but continuing...${N}"
  7970. fi
  7971. ;;
  7972. debian)
  7973. log_function_data "Done installing debs created, now to: m-a build -l $KERNEL_FULL -f $fgKsrc:"
  7974. CC=$CC m-a build -l $KERNEL_FULL -f $fgKsrc 1>> $LOG_FILE 2>> $LOG_FILE || error_handler 194 $fgKsrc
  7975. log_function_data "Now to: m-a install -l $KERNEL_FULL -f $fgKsrc:"
  7976. m-a install -l $KERNEL_FULL -f $fgKsrc 1>> $LOG_FILE 2>> $LOG_FILE || error_handler 193 $fgKsrc
  7977.  
  7978. # note: note with dkms
  7979. :
  7980. # log_function_data "Done installing debs created, now to: m-a build fglrx:"
  7981. # CC=$CC m-a build fglrx-kernel 1>> $LOG_FILE 2>> $LOG_FILE || error_handler 194 fglrx-kernel
  7982. # log_function_data "Now to: m-a install fglrx:"
  7983. # m-a install fglrx-kernel 1>> $LOG_FILE 2>> $LOG_FILE || error_handler 193 fglrx-kernel
  7984. ;;
  7985. esac
  7986.  
  7987. # restore freeze state
  7988. if [ "$frozen" -eq 1 -a -x $usunf ];then
  7989. $usunf
  7990. fi
  7991. case $SYSTEM_BASE in
  7992. debian)
  7993. # put packages on hold fglrx-amdcccle, fglrx-driver, fglrx module
  7994. echo "${S}Placing ATI packages on hold to avoid dist-upgrade issues with Debian fglrx drivers...${N}"
  7995. hold_package 'fglrx-control'
  7996. hold_package 'fglrx-driver'
  7997. ;;
  7998. ubuntu)
  7999. echo "${S}Placing ATI packages on hold to avoid upgrade issues with $DISTRIB_ID fglrx drivers...${N}"
  8000. hold_package 'fglrx-amdcccle'
  8001. hold_package 'xorg-driver-fglrx'
  8002. ;;
  8003. esac
  8004.  
  8005. eval $LOGPE
  8006. fi
  8007. }
  8008.  
  8009. ### -------------------------------------------------------------------
  8010. ### Finalizing steps
  8011. ### -------------------------------------------------------------------
  8012.  
  8013. # this only runs for non free driver installs, so no need to check for xorg stuff
  8014. final_install_steps()
  8015. {
  8016. eval $LOGPS
  8017. local fgModules='' fgModule=''
  8018.  
  8019. echo "${S}Finalizing install...${N}"
  8020. process_xvmc
  8021. depmod $KERNEL_FULL -a # Probe all modules
  8022.  
  8023. case $CARD in
  8024. $NVIDIA)
  8025. # this needs to be cleaned up a bit
  8026. if [ -e /etc/udev/nvidia.rules ];then
  8027. rm -f /etc/udev/nvidia.rules
  8028. fi
  8029. if [ -e /etc/udev/rules.d/nvidia.rules ];then
  8030. rm -f /etc/udev/rules.d/nvidia.rules
  8031. fi
  8032. ldconfig # Configure Dynamic Linker Run Time Bindings.
  8033. # remove_module 'nouveau'
  8034. ;;
  8035. $FGLRX)
  8036. ## clean up install parts
  8037. rm -rf ${USRS}modules/fglrx
  8038. rm -rf /tmp/fglrx* fglrx*
  8039. add_module 'fglrx'
  8040. # note, since ubuntu uses dkms we don't want to purge the kernel source
  8041. case $SYSTEM_BASE in
  8042. arch)
  8043. fgModules='radeon drm'
  8044. ;;
  8045. debian)
  8046. dpkg --purge fglrx-kernel-src 1>> $LOG_FILE 2>> $LOG_FILE
  8047. fgModules='radeon drm'
  8048. ;;
  8049. ubuntu)
  8050. fgModules='radeon drm'
  8051. ;;
  8052. esac
  8053. # test for, then remove if present
  8054. for fgModule in $fgModules
  8055. do
  8056. remove_module "$fgModule"
  8057. done
  8058. ;;
  8059. esac
  8060.  
  8061. sync # Force changed blocks to disk, update the super block
  8062. echo $MLINE
  8063. echo "${S}Congratulations! It looks like your new ${C}$DRIVER_DEFAULT $CARD${S} driver installed successfully!${N}"
  8064. eval $LOGPE
  8065. }
  8066.  
  8067. process_xvmc()
  8068. {
  8069. eval $LOGUS
  8070. local lxvmcN='libXvMCNVIDIA_dynamic.so.1' lxvmc='libXvMC.so.1' exxv='/etc/X11/XvMCConfig'
  8071.  
  8072. # xvmc information here: http://www.mythtv.org/wiki/index.php/XvMC
  8073. if [ "$B_USE_XVMC" == 'true' -a "$B_NO_XVMC" != 'true' -a -x /usr/lib/$lxvmcN ];then
  8074. echo $lxvmcN > $exxv
  8075. else
  8076. echo $lxvmc > $exxv
  8077. fi
  8078. eval $LOGUE
  8079. }
  8080.  
  8081. ########################################################################
  8082. #### FUNCTIONS: XORG TOOLS
  8083. ########################################################################
  8084.  
  8085. ### -------------------------------------------------------------------
  8086. ### Stop / Start Xorg handling section
  8087. ### -------------------------------------------------------------------
  8088.  
  8089. x_start_stop_master()
  8090. {
  8091. eval $LOGPS
  8092. case $1 in
  8093. stop)
  8094. if [ "$B_SKIP_FUNCTION" != 'true' -a "$B_SM_INSTALL" != 'true' -a "$B_SKIP_X_TEST" != 'true' -a "$B_AUTORUN" != 'true' ];then
  8095. launch_from_X
  8096. start_stop_x stop
  8097. # testing this, only with trigger option
  8098.  
  8099. fi
  8100. ;;
  8101. start)
  8102. if [ "$B_AUTORUN" != 'true' ];then
  8103. if [ "$B_SKIP_X_QUESTION" == 'true' ];then
  8104. start_stop_x start
  8105. else
  8106. # no point in starting x unless required
  8107. if [ -z "$DISPLAY" ];then
  8108. start_x_question
  8109. # handles case where sgfxi is run in X
  8110. else
  8111. # almost no cases will X be running except a module build to another
  8112. # kernel, since driver install shuts down X. Maybe distro-driver can do this.
  8113. if [ -n "$INSTALL_TO_KERNEL" -a "$INSTALL_TO_KERNEL" != "$( uname -r )" ];then
  8114. echo "${S}All done with driver install. Remember, you have to reboot to kernel ${C}$INSTALL_TO_KERNEL${S}"
  8115. echo "for the driver module you just updated to be active.${N}"
  8116. else
  8117. echo "${S}All done with driver install. Remember, you have to restart X (your desktop)"
  8118. echo "before your new driver is active.${N}"
  8119. fi
  8120. fi
  8121. fi
  8122. fi
  8123. ;;
  8124. esac
  8125. eval $LOGPE
  8126. }
  8127.  
  8128. start_x_question()
  8129. {
  8130. eval $LOGPS
  8131. local opt='' options='' bRepeat='false' package=''
  8132. local ia32libs='ia32-libs' iaOpt='install-ia32libs'
  8133. local ia32Alert='echo -e "\n${M}You should probably (re)install ${C}$ia32libs${M} (even if already installed)\nif you use applications that depend on them in your ${C}64 bit${M} system,\nfor example ${C}Wine${M}.${N}"'
  8134. local ia32Install='echo -e "${C}$iaOpt${M} - Install ${C}$ia32libs${M} libs."'
  8135. local fgGlxOpt='' fgGlx='' fgGlxAlert='' fgGlxInstall=''
  8136. local nvGlxOpt='' nvGlx='' nvGlxAlert='' nvGlxInstall=''
  8137. local startXopt='' startXText='' rebootOpt='' rebootText=''
  8138.  
  8139. case $BITS in
  8140. 32)
  8141. ia32Alert=''
  8142. ia32Install=''
  8143. iaOpt=''
  8144. ;;
  8145. 64)
  8146. case $CARD in
  8147. $FGLRX)
  8148. fgGlxOpt='install-fglrx-glx'
  8149. fgGlx='fglrx-glx fglrx-glx-ia32'
  8150. fgGlxAlert='echo -e "\n${M}You might want to (re)install ${C}$fgGlx${M} (even if already installed)\nif you have problems with your ${C}64 bit ATI/fglrx${M} driver/apps.${N}"'
  8151. fgGlxInstall='echo -e "${C}$fgGlxOpt${M} - Install ${C}$fgGlx${M}."'
  8152. ;;
  8153. $NVIDIA)
  8154. # not using this now until issue is confirmed by user
  8155. # note, as of 2013-07-05 this issue occurs on install of: libgl1-nvidia-glx:i386
  8156. # when trying to install that package apt tries to install nvidia installer cleaner
  8157. # or cleanup
  8158. # nvGlxOpt='install-nvidia-glx'
  8159. # # note, this was the old package name
  8160. # # nvGlx='libgl1-nvidia-glx-ia32'
  8161. # nvGlx='libgl1-nvidia-glx:i386'
  8162. # nvGlxAlert='echo -e "\n${M}You might want to (re)install ${C}$nvGlx${M} (even if already installed)\nif you have problems with your ${C}64 bit nVidia${M} driver/apps.${N}"'
  8163. # nvGlxInstall='echo -e "${C}$nvGlxOpt${M} - Install ${C}$nvGlx${M}."'
  8164. :
  8165. ;;
  8166. esac
  8167. ;;
  8168. esac
  8169. ia32Alert=''
  8170. ia32Install=''
  8171. iaOpt=''
  8172. fgGlx=''
  8173. fgGlxOpt=''
  8174. fgGlxAlert=''
  8175. fgGlxInstall=''
  8176.  
  8177. if [ "$B_SKIP_INSTALL" == 'true' -o -z "$INSTALL_TO_KERNEL" -o "$INSTALL_TO_KERNEL" == "$( uname -r )" ];then
  8178. startXopt='start-desktop'
  8179. startXText='echo -e "${C}$startXopt${M} - All finished, (re-)start desktop now."'
  8180. fi
  8181. if [ -n "$INSTALL_TO_KERNEL" -a "$INSTALL_TO_KERNEL" != "$( uname -r )" ];then
  8182. rebootOpt='reboot-now'
  8183. rebootText='echo -e "${C}$rebootOpt${M} - You must reboot to use the driver for ${C}$INSTALL_TO_KERNEL${M}."'
  8184. fi
  8185.  
  8186. echo $MLINE
  8187. echo "${S}Your driver install is now finished. You have the following options:"
  8188. eval $ia32Alert
  8189. eval $fgGlxAlert
  8190. eval $nvGlxAlert
  8191. echo $LINE
  8192. eval $ia32Install
  8193. eval $fgGlxInstall
  8194. eval $nvGlxInstall
  8195. eval $startXText
  8196. eval $rebootText
  8197. echo "${C}quit${M} - Quit now, to do something else before starting your desktop.${N}"
  8198. echo $LINE
  8199. options="$iaOpt $fgGlxOpt $nvGlxOpt $startXopt $rebootOpt quit"
  8200. select opt in $options
  8201. do
  8202. case $opt in
  8203. install-ia32libs)
  8204. if [ "$BITS" == '64' ];then
  8205. echo "${S}Installing the package ${C}$ia32libs${S} now...${N}"
  8206. install_package $ia32libs '' 'reinstall'
  8207. log_function_data "Final Step: Installed: $ia32libs"
  8208. else
  8209. echo "${E}The package ${C}$ia32libs${E} is only available for ${C}64 bit${E} systems.${N}"
  8210. fi
  8211.  
  8212. # repeat the question for users so they can start x now if they want.
  8213. bRepeat='true'
  8214. ;;
  8215. install-fglrx-glx)
  8216. if [ "$BITS" == '64' -a "$CARD" == $FGLRX ];then
  8217. echo "${S}Installing packages ${C}$fgGlx${S} now...${N}"
  8218. for package in $fgGlx
  8219. do
  8220. install_package $package '' 'reinstall'
  8221. done
  8222.  
  8223. log_function_data "Final Step: Installed: $fgGlx"
  8224. else
  8225. echo "${E}The packages ${C}$fgGlx${E} are only installable in ${C}64 bit + ATI fglrx${E} systems.${N}"
  8226. fi
  8227. # repeat the question for users so they can start x now if they want.
  8228. bRepeat='true'
  8229. ;;
  8230. install-nvidia-glx)
  8231. if [ "$BITS" == '64' -a "$CARD" == $NVIDIA ];then
  8232. echo "${S}Installing packages ${C}$nvGlx${S} now...${N}"
  8233. for package in $nvGlx
  8234. do
  8235. install_package $package '' 'reinstall'
  8236. done
  8237.  
  8238. log_function_data "Final Step: Installed: $nvGlx"
  8239. else
  8240. echo "${E}The packages ${C}$nvGlx${E} are only installable in ${C}64 bit + nvidia${E} systems.${N}"
  8241. fi
  8242. # repeat the question for users so they can start x now if they want.
  8243. bRepeat='true'
  8244. ;;
  8245. start-desktop)
  8246. echo "${S}Ok, starting your desktop now, thanks for using this script.${N}"
  8247. log_function_data "Final Step: start-desktop"
  8248. start_stop_x start
  8249. ;;
  8250. reboot-now)
  8251. echo "${S}Ok, rebooting into kernel ${C}$INSTALL_TO_KERNEL${S} and your"
  8252. echo "${C}$DRIVER_DEFAULT${S} video driver. Thanks for using this script.${N}"
  8253. log_function_data "Final Step: reboot to kernel: $INSTALL_TO_KERNEL"
  8254. handle_shutdowns 'reboot'
  8255. exit 100 # need to exit with 100 to not trigger root pid kill in smxi
  8256. ;;
  8257. quit)
  8258. echo "${S}Ok, exiting now, thanks for using this script.${N}"
  8259. # this is to send calling script message that it should not do its success action
  8260. log_function_data "Final Step: quit"
  8261. exit 100 # need to exit with 100 to not trigger pid root kill in smxi
  8262. ;;
  8263. *)
  8264. echo "${W}Please select one of the options in the list, thank you.${N}"
  8265. bRepeat='true'
  8266. ;;
  8267. esac
  8268. break
  8269. done
  8270.  
  8271. if [ "$bRepeat" == 'true' ];then
  8272. start_x_question
  8273. fi
  8274. eval $LOGPE
  8275. }
  8276. # start_x_question
  8277.  
  8278. # takes one argument, stop or start
  8279. start_stop_x()
  8280. {
  8281. eval $LOGUS
  8282. local displayManagers='entrance gdm gdm3 kdm kdm-trinity lightdm lxdm mdm nodm sddm slim wdm xdm' dman='' success=''
  8283. # setting the default will handle cases like default 2 while still handling 3/5
  8284. # also note, future systems will probably not use inittab, ubuntu doesn't, but
  8285. # they will read it, so we'll always use this as default to respect user changes
  8286. local defaultRunlevel=''
  8287. if [ -f $EIT ];then
  8288. defaultRunlevel=$( grep -Es '^id.*:initdefault:' $EIT | grep -Eo '[0-5]' )
  8289. fi
  8290. # default, this prevents errors when these don't exist in for ex. fedora
  8291. local serviceControl='/etc/init.d/' startPath='/etc/init.d/' bSkipXKill='false'
  8292. local noHup='nohup' xActionString='' finalXKill='' dmanCommand=''
  8293. local gdmCommand='' bSkipLoop='false' ttyKill=0
  8294. local action=$1
  8295.  
  8296. local defaultDM=$( get_default_display_manager )
  8297. if [ -z "$defaultDM" ];then
  8298. defaultDM=$( do_display_manager_pid_test )
  8299. fi
  8300. local currentRunlevel=$( get_current_runlevel )
  8301.  
  8302. if [ -z "$DISPLAY" -a "$1" == 'stop' ];then
  8303. noHup=''
  8304. fi
  8305. # note that init.d does not take a space, but service does,for the first parameter like kdm
  8306. if [ -n "$( type -p service )" ];then
  8307. serviceControl='service '
  8308. fi
  8309. # note, both fedora and arch have moved to systemd so most of this is only for legacy systems
  8310. case $SYSTEM_BASE in
  8311. arch)
  8312. serviceControl='/etc/rc.d/'
  8313. bSkipXKill='true' # STARTS X when you KILL X...
  8314. startPath='/etc/rc.d/'
  8315. ;;
  8316. fedora)
  8317. serviceControl='' # no /etc/init.d, it's in /usr/sbin
  8318. bSkipLoop='true'
  8319. bSkipXKill='true' # STARTS X when you KILL X...
  8320. case $1 in
  8321. start)
  8322. success='true' # go straight to init 5 start up
  8323. ;;
  8324. stop)
  8325. gdmCommand='init 3'
  8326. ;;
  8327. esac
  8328. defaultDM='gdm'
  8329. ;;
  8330. esac
  8331. log_function_data "default runlevel: $defaultRunlevel\ncurrent runlevel: $currentRunlevel"
  8332. ## restart x if this is not being run by smxi
  8333. if [ "$B_SYSTEMD_INIT" == 'true' ];then
  8334. echo "${M}Using ${C}systemd/systemctl${M} to try to ${C}$action${M} your desktop.${N}"
  8335. fi
  8336. if [ "$B_UPSTART" == 'true' ];then
  8337. echo "${M}Using ${C}upstart/initctl${M} to try to ${C}$action${M} your desktop.${N}"
  8338. fi
  8339.  
  8340. if [ -z "$defaultDM" -a "$bSkipLoop" != 'true' ];then
  8341. for dman in $displayManagers
  8342. do
  8343. # upstart, systemd
  8344. if [ -n "$( type -p $dman )" ];then
  8345. if [ "$B_SYSTEMD_INIT" == 'true' ];then
  8346. dmanCommand="systemctl $action $dman.service"
  8347. elif [ "$B_UPSTART" == 'true' ];then
  8348. dmanCommand="initctl $action $dman"
  8349. elif [ -x "$startPath$dman" ];then
  8350. dmanCommand="$serviceControl$dman $action"
  8351. fi
  8352. defaultDM=$dman
  8353. break
  8354. # sysvinit
  8355. elif [ -x $startPath$dman ];then
  8356. if [ "$B_SYSTEMD_INIT" == 'true' ];then
  8357. dmanCommand="systemctl $action $dman.service"
  8358. elif [ "$B_UPSTART" == 'true' ];then
  8359. dmanCommand="initctl $action $dman"
  8360. else
  8361. dmanCommand="$serviceControl$dman $action"
  8362. fi
  8363. defaultDM=$dman
  8364. break
  8365. fi
  8366. done
  8367. else
  8368. # have to retest dm for null for fedora here
  8369. # upstart in ubuntu, commands like: start gdm; stop gdm; restart gdm
  8370. if [ -n "$defaultDM" ];then
  8371. if [ "$B_SYSTEMD_INIT" == 'true' ];then
  8372. dmanCommand="systemctl $action $defaultDM.service"
  8373. elif [ "$B_UPSTART" == 'true' ];then
  8374. dmanCommand="initctl $action $defaultDM"
  8375. elif [ -x "$startPath$defaultDM" ];then
  8376. dmanCommand="$serviceControl$defaultDM $action"
  8377. fi
  8378. elif [ -n "$gdmCommand" ];then
  8379. dmanCommand=$gdmCommand # init 3 for fedora
  8380. defaultDM=$gdmCommand
  8381. else
  8382. dmanCommand=''
  8383. fi
  8384. fi
  8385. # testing for systemd and graphical loaded, fallback if dm was not found
  8386. if [ -z "$dmanCommand" -a "$B_SYSTEMD_GRAPHICAL" == 'true' ];then
  8387. case $action in
  8388. stop)
  8389. dmanCommand="systemctl isolate multi-user.target"
  8390. ;;
  8391. start)
  8392. dmanCommand="systemctl isolate graphical.target"
  8393. ;;
  8394. esac
  8395. fi
  8396. log_function_data "dmanCommand: $dmanCommand"
  8397. if [ -n "$dmanCommand" ];then
  8398. # nohup is required to make sure dm is fully stopped, and pids removed
  8399. echo "${S}Attempting to ${C}$action${S} display manager ${C}$defaultDM${S} now... ${N}"
  8400. dmanCommand="$noHup $dmanCommand 2>>$LOG_FILE && success='true'"
  8401. eval $dmanCommand
  8402. if [ -z "$noHup" ];then
  8403. if [ "$success" == 'true' ];then
  8404. echo "${S}Display manager ${C}$action${S} sucessful.${N}"
  8405. else
  8406. echo "${W}Display manager ${C}$action${S} failed${N}"
  8407. fi
  8408. log_function_data "Display manager $action status: $success"
  8409. fi
  8410. fi
  8411. log_function_data "Reached post dmancommand: $dmanCommand"
  8412. # this handles cases where somehow X is still running
  8413. # startx x starts can for example bypass kdm tests, etc
  8414. if [ "$1" == 'stop' ];then
  8415. if [ "$( x_is_running )" == 'true' -a "$bSkipXKill" != 'true' ];then
  8416. echo "${M}Note: display manager shutdown failed... shutting down X directly instead... ${N}"
  8417. xActionString="$noHup killall Xorg && finalXKill='true'"
  8418. eval $xActionString
  8419. log_function_data "Final X kill reports worked: $finalXKill"
  8420. if [ -z "$noHup" ];then
  8421. if [ "$finalXKill" == 'true' ];then
  8422. echo "${S}X shutdown successful.${N}"
  8423. else
  8424. echo "${W}X shutdown failed.${N}"
  8425. fi
  8426. fi
  8427. # log the result
  8428. if [ "$( x_is_running )" == 'true' ];then
  8429. log_function_data "The final X kill has failed."
  8430. fi
  8431. fi
  8432. fi
  8433. # this will exit the root shell on successful run of start x
  8434. if [ "$1" == 'start' -a "$success" == 'true' ];then
  8435. # trying to bypass this because smxi is failing to restart x after driver install, so
  8436. # I will make smxi exit after running sgfxi
  8437. # if [ "$B_SM_INSTALL" != 'true' ];then
  8438. # the failure case handels a weird thing when kill gives error
  8439. if [ -n "$LOGIN_PID" ];then
  8440. log_function_data "Kill login PID for dm start: $LOGIN_PID"
  8441. # too many oddities with systemd kill root/tty, so not doing anything for now
  8442. if [ "$B_SYSTEMD" == 'true' ];then
  8443. #kill_systemd_tty || ttyKill=$?
  8444. #if [ "$ttyKill" -gt 0 ];then
  8445. kill $LOGIN_PID && exit 0 || exit 1
  8446. exit 0
  8447. #fi
  8448. elif [ -n "$defaultRunlevel" ];then
  8449. init $INIT_LEVEL && kill $LOGIN_PID && exit 0 || exit 1
  8450. else
  8451. kill $LOGIN_PID && exit 0 || exit 1
  8452. fi
  8453. else
  8454. log_function_data "No login PID found, trying default runlevel: $defaultRunlevel"
  8455. if [ -n "$defaultRunlevel" ];then
  8456. echo "${E}No login Pid found to kill, starting init $defaultRunlevel and leaving root logged in.${N}"
  8457. init $defaultRunlevel && exit 0 || exit 1
  8458. else
  8459. echo "${E}No login Pid found to kill, leaving root logged in.${N}"
  8460. exit 0
  8461. fi
  8462. fi
  8463. #else
  8464. # exit 0 # smxi will handle the pid root kill
  8465. # fi
  8466. fi
  8467. eval $LOGUE
  8468. }
  8469.  
  8470. # this has weird consequences, not a good thing to use possibly, but I'll check it out
  8471. kill_systemd_tty()
  8472. {
  8473. eval $LOGUS
  8474. local returnValue=1 ttyStatus=''
  8475. local scriptTTY=$(get_current_tty)
  8476.  
  8477. # verify we have an actual tty valid type
  8478. if [ -n "$scriptTTY" -a -n "$( grep -E '^tty[0-9]+$' <<< $scriptTTY )" ];then
  8479. ttyStatus="$( systemctl status getty@$scriptTTY.service )"
  8480. log_function_data "ttyStatus:\n$ttyStatus"
  8481. # double check it's the tty running script, then make sure that tty is actually active
  8482. if [ -n "$( grep "$SCRIPT_NAME" <<< "$ttyStatus" )" ];then
  8483. if "$( grep -Esi 'Active:[[:space:]]*active' <<< "$ttyStatus" )" ];then
  8484. echo "${M}Systemd being used to attempt to exit tty${N}"
  8485. systemctl stop getty@$scriptTTY.service
  8486. returnValue=$?
  8487. fi
  8488. fi
  8489. fi
  8490. # in theory this should not be running anymore so nothing to log, but we'll do it for errors
  8491. log_function_data "returnValue: $returnValue"
  8492. return $returnValue
  8493. eval $LOGUE
  8494. }
  8495.  
  8496. get_current_tty()
  8497. {
  8498. eval $LOGUS
  8499.  
  8500. local term=$( tty )
  8501. term=$( basename $term )
  8502.  
  8503. log_function_data "term: $term"
  8504. echo $term
  8505.  
  8506. eval $LOGUE
  8507. }
  8508.  
  8509. x_is_running()
  8510. {
  8511. eval $LOGUS
  8512. local returnVal=''
  8513. # we'll do one final X is running test here, note, handling a bunch of
  8514. # different possible X detections in etch, lenny, and sid, then filtering out the grep
  8515. local xIsRunning=$( ps aux | grep -E '/usr.*/X([[:space:]]|$)' | grep -v 'grep' )
  8516.  
  8517. if [ -z "$xIsRunning" -a "$B_SYSTEMD" == 'true' ];then
  8518. xIsRunning=$( systemd_dm_test )
  8519. fi
  8520.  
  8521. log_function_data "X ps aux: $xIsRunning"
  8522.  
  8523. if [ -n "$xIsRunning" ];then
  8524. returnVal='true'
  8525. else
  8526. returnVal='false'
  8527. fi
  8528. echo $returnVal
  8529. log_function_data "returnVal: $returnVal"
  8530. eval $LOGUE
  8531. }
  8532. # in some cases X will be off but dm is still on, which breaks restarts of desktop
  8533. systemd_dm_test()
  8534. {
  8535. local dm=$( do_display_manager_pid_test )
  8536. local unit=''
  8537. if [ -n "$dm" ];then
  8538. unit=$( systemctl list-units | grep -E "^[[:space:]]*$dm\.service[[:space:]]+(loaded|active|running)[[:space:]](loaded|active|running)" )
  8539. fi
  8540. echo $unit
  8541. }
  8542.  
  8543. # get active pid for dm. Note: for systemd, this doesn't matter since dm is loaded but not active (ACtive: inactive)
  8544. do_display_manager_pid_test()
  8545. {
  8546. eval $LOGUS
  8547. local dmIdList='entranced.pid gdm.pid gdm3.pid kdm.pid lightdm.pid lxdm.pid mdm.pid nodm.pid sddm.pid sddm slim.lock wdm.pid xdm.pid' dmId='' dmInstance=''
  8548.  
  8549. for dmId in $dmIdList
  8550. do
  8551. # trim off extension of dm
  8552. if [ -f /run/$dmId -o -f /run/${dmId%.*}/$dmId -o -f /var/run/$dmId -o -f /var/run/${dmId%.*}/$dmId ];then
  8553. dmInstance=${dmId%.*}
  8554. fi
  8555. done
  8556.  
  8557. echo $dmInstance
  8558.  
  8559. log_function_data "dmInstance: $dmInstance"
  8560. echo $dmInstance
  8561. eval $LOGUE
  8562. }
  8563.  
  8564. # just return the dm or null if missing
  8565. get_default_display_manager()
  8566. {
  8567. eval $LOGUS
  8568. local defaultDM=''
  8569.  
  8570. # for systemd, if I read this right, this isn't necessarily set on the systemd system, but it can be
  8571. # usually graphical.target will handle this automatically.
  8572. if [ "$B_SYSTEMD" == 'true' ];then
  8573. # slice out last part of link
  8574. if [ -h /etc/systemd/system/display-manager.service ];then
  8575. defaultDM=$( ls -l /etc/systemd/system/display-manager.service 2>/dev/null | awk '{print $NF}' | sed 's/\.service$//' )
  8576. fi
  8577. fi
  8578. # whether or not it's systemd, let's check anyway for a default here
  8579. if [ -z "$defaultDM" ];then
  8580. defaultDM=$( cat /etc/X11/default-display-manager 2>/dev/null )
  8581. fi
  8582. if [ -n "$defaultDM" ];then
  8583. defaultDM=$( basename $defaultDM 2>/dev/null )
  8584. fi
  8585.  
  8586. if [ "$defaultDM" == 'entranced' ];then
  8587. defaultDM='entrance'
  8588. fi
  8589.  
  8590. echo $defaultDM
  8591. log_function_data "defaultDM: $defaultDM"
  8592. eval $LOGUE
  8593. }
  8594.  
  8595.  
  8596. ### -------------------------------------------------------------------
  8597. ### xorg configuration (previously in sgfxi-lib-xorg)
  8598. ### -------------------------------------------------------------------
  8599.  
  8600. fix_xorg_device_id()
  8601. {
  8602. eval $LOGUS
  8603. if [ -n "$( grep -s 'Card0' $EXXC )" ];then
  8604. echo "${S}Updating ${C}$EXXC${S} syntax. Changing ${C}Card[x]${S} to ${C}Device[x]${S}${N}"
  8605. sed -r -i 's/Card([0-9]+)/Device\1/g' $EXXC
  8606. #sed -i 's/Identifier[[:space:]]*"Card/Identifier "Device/' $EXXC
  8607. #sed -i 's/Device[[:space:]]*"Card/Device "Device/' $EXXC
  8608. log_function_data "$EXXC updated. CardX changed to DeviceX."
  8609. else
  8610. log_function_data "No CardX in $EXXC."
  8611. fi
  8612. eval $LOGUE
  8613. }
  8614.  
  8615. move_x_conf()
  8616. {
  8617. eval $LOGUS
  8618. local x_full_bu="$EXXC-bu-$( date +%Y-%m-%d-%H:%M:%S )"
  8619. local message1="${S}Continuing to ${C}$EXXC${S} creation...${N}"
  8620.  
  8621. if [ "$B_RESTORE_DEFAULTS" == 'true' ];then
  8622. message1=''
  8623. fi
  8624.  
  8625. if [ -n "$( which $X_NAME )" ];then
  8626. if [ "$B_RESTORE_DEFAULTS" != 'true' -a "$( x_is_running )" == 'true' ];then
  8627. start_stop_x 'stop'
  8628. fi
  8629. if [ -f $EXXC ];then
  8630. echo "${M}Moving ${C}$EXXC${M} to ${C}$x_full_bu${M}...${N}"
  8631. mv -f $EXXC $x_full_bu
  8632. echo "$message1"
  8633. else
  8634. if [ "$B_RESTORE_DEFAULTS" != 'true' ];then
  8635. echo "${M}No ${C}$EXXC${M} file exists, continuing to ${C}$EXXC${M} creation...${N}"
  8636. fi
  8637. fi
  8638. else
  8639. if [ "$B_RESTORE_DEFAULTS" != 'true' ];then
  8640. log_function_data "A rebuild of xorg.conf is requested, but there is no X application to rebuild it with."
  8641. error_handler 177
  8642. fi
  8643. fi
  8644. eval $LOGUE
  8645. }
  8646.  
  8647. # newest xorg will have no xorg.conf file
  8648. create_x_conf()
  8649. {
  8650. eval $LOGPS
  8651.  
  8652. local bRepeat='false' opt='' options=''
  8653.  
  8654. if [ ! -f $EXXC -a -n "$( echo $X_VERSION | grep -E '[1-4]\.[0-9]+(\.[0-9]+)?' )" -a -n "$( which $X_NAME )" ];then
  8655. log_function_data "xorg is present, no xorg.conf file"
  8656.  
  8657. echo $LINE
  8658. if [ "$B_MOVE_X_CONF" == 'true' ];then
  8659. echo "${S}Now it's time to make your new replacement ${C}$EXXC${S} file. "
  8660. else
  8661. echo "${S}You are running a new version of X but you have no ${C}$EXXC${S} file. "
  8662. fi
  8663. echo "${M}Would you like to create it now (uses ${C}X -configure${M} command)?"
  8664. echo $LINE
  8665. echo "${C}1 - yes-create-xorg-conf-file${M} - Create file and proceed.${N}"
  8666. echo "${C}2 - quit${M} - Quit now, not sure if I should do this.${N}"
  8667. echo $LINE
  8668. options="yes-create-xorg-conf-file quit"
  8669. select opt in $options
  8670. do
  8671. case $opt in
  8672. yes-create-xorg-conf-file)
  8673. echo "${S}Ok, creating your new ${C}$EXXC${S} file now...${N}"
  8674. # X has already been stopped in this case ideally from move, but
  8675. # checking again to make sure. X command cannot be run with X running
  8676. if [ "$( x_is_running )" == 'true' ];then
  8677. start_stop_x 'stop'
  8678. fi
  8679. # now double check and kill with precise errors to try to catch the cause
  8680. # of failing xorg.conf generation
  8681. if [ "$( x_is_running )" == 'true' ];then
  8682. error_handler 214
  8683. fi
  8684. $X_NAME -configure 2>>$LOG_FILE
  8685.  
  8686. # getting error reports of missing file or error on file creation
  8687. if [ -f /root/xorg.conf.new ];then
  8688. echo "${S}Moving newly created ${C}xorg.conf${S} to ${C}$EXXC${S} now...${N}"
  8689. mv -f /root/xorg.conf.new $EXXC
  8690. log_function_data "xorg.conf created and mv to /etc/X11/"
  8691. else
  8692. # temporary debugger logging
  8693. # ls /root/xorg* >> $LOG_FILE
  8694. # ls /usr/local/bin/xorg* >> $LOG_FILE
  8695. # ls $(pwd)/xorg* >> $LOG_FILE
  8696. # error_handler 215
  8697.  
  8698. # this is a short term hack, only required until X/xserver-xorg package
  8699. # is fixed to be able to create an xorg.conf file.. In theory this should
  8700. # simply vanish as soon as the xorg.conf is generated again, since this
  8701. # case would then never exist.
  8702. if [ ! -f $EXXC ];then
  8703. log_function_data "touch created xorg.conf file because it was missing, X -configure error."
  8704. touch $EXXC
  8705. fi
  8706. fi
  8707.  
  8708. # this handles the case where nouveau was running, sgfxi was started,
  8709. # no xorg.conf was found, and the X -configure command defaults to nv
  8710. if [ "$B_TESTING_5" == 'true' -a -n "$( lsmod | grep '^nouveau' )" ];then
  8711. NATIVE_OVERRIDE='nouveau'
  8712. update_xorgconf_driver_version
  8713. fi
  8714. if [ -f $EXXC ];then
  8715. echo "${S}Ok, all done, continuing...${N}"
  8716. log_function_data "xorg xorg.conf file generated"
  8717. else
  8718. error_handler 218
  8719. fi
  8720. ;;
  8721. quit)
  8722. echo "${S}Ok, you'll have to figure out what to do manually then if you want to run $SCRIPT_NAME.${N}"
  8723. exit 100 # need to exit with 100 to not trigger pid root kill in smxi
  8724. ;;
  8725. *)
  8726. echo "${W}Please select one of the options in the list, thank you.${N}"
  8727. bRepeat='true'
  8728. ;;
  8729. esac
  8730. break
  8731. done
  8732.  
  8733. if [ "$bRepeat" == 'true' ];then
  8734. create_x_conf
  8735. fi
  8736. elif [ ! -f $EXXC -a -z "$( which X )" ];then
  8737. log_function_data "There is no xorg.conf file, and no X command to build one with."
  8738. error_handler 244
  8739. else
  8740. log_function_data "xorg is present with xorg.conf file"
  8741. fi
  8742. eval $LOGPE
  8743. }
  8744.  
  8745. # create required section device:
  8746. create_section_device()
  8747. {
  8748. eval $LOGUS
  8749. # if this section is not present, create it
  8750. if [ "$( grep -Esic 'Section[ \t]*"Device"' $EXXC )" -eq 0 ];then
  8751. echo >> $EXXC
  8752. echo -e 'Section "Device"' >> $EXXC
  8753. echo -e '\tIdentifier "Device0"' >> $EXXC
  8754. # the vesa is a just a failsafe, the actual driver will be set in driver version
  8755. # echo -e '\tDriver "vesa"' >> $EXXC
  8756. # echo -e '\tBusID "PCI:'$BUS_ID'"' >> $EXXC
  8757. echo 'EndSection' >> $EXXC
  8758. echo >> $EXXC
  8759. fi
  8760. # now fill it if needed
  8761. eval $LOGUE
  8762. create_driver_entry
  8763. }
  8764.  
  8765. create_section_extensions()
  8766. {
  8767. eval $LOGUS
  8768. # if this section is not present, create it
  8769. if [ "$( grep -Esc 'Section[ \t]*"Extensions"' $EXXC )" -eq 0 ];then
  8770. echo >> $EXXC
  8771. echo -e '\nSection "Extensions"' >> $EXXC
  8772. echo 'EndSection' >> $EXXC
  8773. fi
  8774. eval $LOGUE
  8775. }
  8776.  
  8777. create_section_serverflags()
  8778. {
  8779. eval $LOGUS
  8780. # if this section is not present, create it
  8781. if [ "$( grep -Esic 'Section[ \t]*"ServerFlags"' $EXXC )" -eq 0 ];then
  8782. echo >> $EXXC
  8783. echo -e 'Section "ServerFlags"' >> $EXXC
  8784. echo 'EndSection' >> $EXXC
  8785. echo >> $EXXC
  8786. fi
  8787. eval $LOGUE
  8788. }
  8789.  
  8790. # args: $1 - the flag to set
  8791. set_server_flag()
  8792. {
  8793. eval $LOGUS
  8794. create_section_serverflags
  8795. if [ -z "$( grep -Eis '^[[:space:]]*Option[[:space:]]+"'$1'"[[:space:]]+' $EXXC )" ];then
  8796. perl -pi -e 's/^([\s]*Section\s*"ServerFlags")/\1\n\tOption "'$1'"\t"true"\n/' $EXXC
  8797. fi
  8798. eval $LOGUE
  8799. }
  8800.  
  8801. # some rough code, will write driver / pciid if required,this is mainly for systems
  8802. # that are using the new xorg, and may not have a driver/busid entry.
  8803. # if all goes well, will only create a driver / busid entry if missing
  8804. create_driver_entry()
  8805. {
  8806. eval $LOGUS
  8807. # since this is set in the above function, it must exist, but I'll check to make sure
  8808. local deviceLineNu=$( grep -Eisn 'Section[[:space:]]*"Device"' $EXXC | cut -d ':' -f 1 )
  8809.  
  8810. # echo deviceLineNu: $deviceLineNu
  8811. # make sure it's numeric, and that only one device section number was returned (space)
  8812. if [ -n "$( grep -E '^[0-9]+$' <<< $deviceLineNu )" ];then
  8813. # this is a trick to only grep within a block delimited by start/EndSection
  8814. local isDriver=$( sed -n ''$deviceLineNu',/EndSection/ p' $EXXC | grep -Ei 'Driver[[:space:]]*".*"' )
  8815. local isBusId=$( sed -n ''$deviceLineNu',/EndSection/ p' $EXXC | grep -Ei 'BusID[[:space:]]*".*"' )
  8816.  
  8817. # echo isBusId: $isBusId
  8818. # echo isDriver: $isDriver
  8819.  
  8820. # the vesa is a just a failsafe, the actual driver will be set in driver version
  8821. # this logic is complicated but seems to work, check the range in section device
  8822. # line number to EndSection, then update the driver and busid if needed, as per
  8823. # tests above already done
  8824. # I'm not sure why -r didn't work, but it didn't in this case.
  8825. if [ -z "$isDriver" ];then
  8826. sed -i ''${deviceLineNu}',/EndSection/ s/Section[[:space:]]*"Device"/&\
  8827. \tDriver "vesa"/' $EXXC
  8828. fi
  8829. # only adding busid if driver is missing, otherwise mistakes will happen
  8830. # xorg has a bug with bus id with hex, this is now handled in sgfxi
  8831. # commented unless required by dual card presence, then uncommented
  8832. if [ -z "$isBusId" ];then
  8833. pcibusid_hex_to_dec
  8834. sed -i ''${deviceLineNu}',/EndSection/ s/Driver[[:space:]]".*"/&\
  8835. \t#BusID "PCI:'${BUS_ID}'"/' $EXXC
  8836. fi
  8837. fi
  8838. eval $LOGUE
  8839. }
  8840.  
  8841. # this will reset any hex in bus id string to avoid that new xorg failure to handle hex
  8842. pcibusid_hex_to_dec()
  8843. {
  8844. eval $LOGUS
  8845.  
  8846. local pt1=$( cut -d ':' -f 1 <<< $BUS_ID )
  8847. local pt2=$( cut -d ':' -f 2 <<< $BUS_ID )
  8848. local pt3=$( cut -d ':' -f 3 <<< $BUS_ID )
  8849. local tempPt1='' tempPt2='' tempPt3=''
  8850.  
  8851. let tempPt1=0x$pt1
  8852. let tempPt2=0x$pt2
  8853. let tempPt3=0x$pt3
  8854.  
  8855. BUS_ID="$tempPt1:$tempPt2:$tempPt3"
  8856. eval $LOGUE
  8857. }
  8858.  
  8859. # this will handle cases where user is changing from one card to another
  8860. update_xorgconf_driver_version()
  8861. {
  8862. eval $LOGUS
  8863. local driverName=$CARD
  8864.  
  8865. if [ "$B_NATIVE_DRIVER" == 'true' ];then
  8866. case $CARD in
  8867. $FGLRX)
  8868. driverName='radeon'
  8869. ;;
  8870. $INTEL)
  8871. driverName='intel'
  8872. ;;
  8873. $NVIDIA)
  8874. driverName='nouveau'
  8875. ;;
  8876. esac
  8877.  
  8878. # this handles hard overrides to specific driver
  8879. if [ -n "$NATIVE_OVERRIDE" ];then
  8880. driverName=$NATIVE_OVERRIDE
  8881. fi
  8882. fi
  8883.  
  8884. # not converting: i810-modesetting i740 i128: note openchrome just released in sid
  8885. # previous: (i810|nvidia|nv|fglrx|ati|radeon|apm|iftv|fbdev|vesa)
  8886. # these are all known xserver-xorg-video-xxxx drivers, plus nvidia and fglrx
  8887. sed -i -r 's%^\s*Driver\s*"(apm|ark|ati|chips|cirrus|cyrix|fbdev|fglrx|glint|iftv|ivtv|i128|i740|i810|imstt|intel|mach64|mesa|mga|modesetting|neomagic|newport|nouveau|nsc|nv|nvidia|openchrome|radeon|radeonhd|rendition|s3virge|s3|savage|siliconmotion|sis|sisusb|tdfx|tga|trident|tseng|v4l|vboxvideo|vesa|vga|via|vmware|voodoo)"%\tDriver\t"'$driverName'"%' $EXXC
  8888. # confirm that it got written, if they add other driver names etc, like modesetting, it will fail until
  8889. # sgfxi is updated with those new names.
  8890. if [[ -z $( grep "\"$driverName\"" $EXXC ) ]];then
  8891. echo "${M}Driver ${C}$driverName${M} failed to get written to ${C}$EXXC${M}."
  8892. echo "Probable cause for failure loading desktop/X. Please alert $SCRIPT_NAME maintainer.${N}"
  8893. log_function_data "Driver $driverName failed to get written to $EXXC. Probable cause for failure."
  8894. else
  8895. log_function_data "Driver $driverName written to $EXXC. This component worked."
  8896. fi
  8897. eval $LOGUE
  8898. }
  8899.  
  8900. # if required, create the Extensions section, then set it to what is needed for
  8901. # each specific argument/driver combination
  8902. check_extensions()
  8903. {
  8904. eval $LOGUS
  8905. local stateOn='enable' stateOff='disable' # default for nvidia
  8906. local turnOff='' rendState=$stateOff compState=$stateOff aiglxString=''
  8907. local compComment='#' rendComment='#'
  8908.  
  8909. # for composite to be active, fglrx composite must be set to 0, not 1
  8910. case $CARD in
  8911. $FGLRX)
  8912. #stateOn='Enable' # check into enable/disable syntax for fglrx/ati/radeon here
  8913. #stateOff='Disable'
  8914. rendState=$stateOff
  8915. compState=$stateOff
  8916. # this stuff needs to be Disabled explicitly, no comments for fglrx only.
  8917. if [ "$B_NATIVE_DRIVER" != 'true' ];then
  8918. rendComment='#'
  8919. compComment=''
  8920. #aiglxString='\n\tOption\t"AIGLX"\t"'$stateOff'"'
  8921. if [ "$B_COMPOSITE" == 'true' ];then
  8922. compState=$stateOn
  8923. else
  8924. compState=$stateOff
  8925. fi
  8926. fi
  8927. ;;
  8928. $NVIDIA|$INTEL)
  8929. if [ "$B_COMPOSITE" == 'true' ];then
  8930. compState=$stateOn
  8931. compComment=''
  8932. else
  8933. compState=$stateOff
  8934. fi
  8935. ;;
  8936. esac
  8937.  
  8938. # clear out all previous extension stuff: note: fglrx composite, aiglx, render: off
  8939. perl -pi -e 's/^[\s]*#*[\s]*Option\s*"Composite".*\n?//;
  8940. s/^[\s]*#*[\s]*Option\s*"RENDER".*\n?//;
  8941. s/^[\s]*#*[\s]*Option\s*"Render".*\n?//;
  8942. s/^[\s]*#*[\s]*Option\s*"AIGLX".*\n?//;
  8943. s/^[\s]*#*[\s]*Option\s*"Aiglx".*\n?//' $EXXC
  8944.  
  8945. create_section_extensions
  8946.  
  8947. # rebuild the extensions now
  8948. perl -pi -e 's/^([\s]*Section\s*"Extensions")/\1\n'$compComment'\tOption "Composite"\t"'$compState'"\n'$rendComment'\tOption "RENDER"\t"'$rendState'"'$aiglxString'/' $EXXC
  8949. eval $LOGUE
  8950. }
  8951.  
  8952. # resets xorg to basics, strips out all fglrx/nvidia specific stuff
  8953. clear_prep_xorg()
  8954. {
  8955. eval $LOGUS
  8956. perl -pi -e 's/^[\s]*Load\s*"GLcore"/#\tLoad\t"GLcore"/;
  8957. s/^[\s]*Load\s*"dri"/#\tLoad\t"dri"/;
  8958. s/^[\s]*#*[\s]*Load\s*"glx"/\tLoad\t"glx"/;
  8959. s/^.*Load\s*"speedo".*\n?//;
  8960. s/DefaultColorDepth.*/DefaultColorDepth 24/;
  8961. s/^[\s]*Option\s*"sw_cursor"/\t#Option "sw_cursor"/;
  8962. s/^[\s]*#*[\s]*Option\s*"Composite".*/#\tOption\t"Composite"\t"1"/;
  8963. s/^.*UseInternalAGPGART.*\n?//;
  8964. s/^.*VideoOverlay.*\n?//;
  8965. s/^.*OpenGLOverlay.*\n?//;
  8966. s/^.*MonitorLayout.*\n?//;
  8967. s/^.*IgnoreDisplayDevices.*\n?//;
  8968. s/^.*Coolbits.*\n?//;
  8969. s/^.*RenderAccel.*\n?//;
  8970. s/^.*AllowGLXWithComposite.*\n?//;
  8971. s/^.*RandRRotation.*\n?//;
  8972. s/^.*AddARGBGLXVisuals.*\n?//;
  8973. s/^.*DisableGLXRootClipping.*\n?//;
  8974. s/^.*TripleBuffer.*\n?//;
  8975. s/^.*OnDemandVBlankInterrupts.*\n?//;
  8976. s/^.*UseEvents.*\n?//;
  8977. s/^.*UseEDID.*\n?//;
  8978. s/^.*UseEdidFreqs.*\n?//;
  8979. s/^.*DynamicTwinView.*\n?//;
  8980. s/^.*AGPFastWrite.*\n?//;
  8981. s/^.*AGPMode.*\n?//;
  8982. s/^.*DynamicClocks.*\n?//;
  8983. s/^.*ColorTiling.*\n?//;
  8984. s/^.*EnablePageFlip.*\n?//;
  8985. s/^.*TexturedXrender.*\n?//;
  8986. s/^.*ignoreABI.*\n?//;
  8987. s/^.*AccelMethod.*\n?//' $EXXC
  8988.  
  8989. # turn on dri again for fglrx/intel, it's off for nvidia
  8990. case $CARD in
  8991. $FGLRX|$INTEL)
  8992. perl -pi -e 's/^[\s]*#*[\s]*Load\s*"dri"/\tLoad\t"dri"/' $EXXC
  8993. ;;
  8994. esac
  8995. eval $LOGUE
  8996. }
  8997.  
  8998. remove_modelines()
  8999. {
  9000. eval $LOGUS
  9001. local removeThem='false'
  9002.  
  9003. ## this handles standard cases, always for fglrx, never for native ati/nv
  9004. # and whenever required by argument. I'll see if native ever needs them removed
  9005. if [ "$CARD" == $FGLRX -o "$B_REMOVE_MODELINES" == 'true' ];then
  9006. if [ "$B_NATIVE_DRIVER" == 'true' -a "$B_REMOVE_MODELINES" == 'true' ];then
  9007. removeThem='true'
  9008. elif [ "$B_NATIVE_DRIVER" != 'true' ];then
  9009. removeThem='true'
  9010. fi
  9011. fi
  9012. if [ "$removeThem" == 'true' ];then
  9013. perl -pi -e 's/^.*Mode.ine.*\n?//g' $EXXC
  9014. fi
  9015. eval $LOGUE
  9016. }
  9017.  
  9018. update_xorg()
  9019. {
  9020. eval $LOGPS
  9021. # this to second time stamp should help fix that old repeated .1st bug
  9022. local timeStampXorg=$EXXC-bu-$( date +%Y-%m-%d-%H:%M:%S )
  9023. local stateOn='enable' stateOff='disable' stateTrue='true' stateFalse='false'
  9024. # nvidia stuff
  9025. local rend=$stateOn twin=$stateTrue triple=$stateFalse
  9026. # note: putting a space in these subsitution patterns breaks perl -e
  9027. local ignoreDisplay='Option\t"IgnoreDisplayDevices"\t"TV"\n\t'
  9028. # fglrx stuff, we're using default agpart 'on' now instead
  9029. local agpart='on' layout='AUTO,AUTO' allowGlx='' useEvents=$stateFalse
  9030.  
  9031. # this is set in rare cases of dual card early copy of xorg.conf
  9032. if [ "$B_XORG_BACKED_UP" != 'true' ];then
  9033. if [ ! -e $timeStampXorg ];then
  9034. cp $EXXC $timeStampXorg
  9035. fi
  9036. log_function_data "xorg.conf was backed up to: $timeStampXorg"
  9037. echo "${S}Backup copy of your previous version: ${C}$timeStampXorg${N}"
  9038. fi
  9039. echo "${S}Updating your ${C}$EXXC${S} file now...${N}"
  9040. create_section_device # create section "device" if missing
  9041. update_xorgconf_driver_version # will set to correct version
  9042. clear_prep_xorg # bring xorg.conf to default condition
  9043. check_extensions
  9044. remove_modelines
  9045. fix_xorg_device_id # fix the CardX change to DeviceX
  9046. if [ "$B_SET_IGNOREABI" == 'true' ];then
  9047. set_server_flag 'ignoreABI'
  9048. fi
  9049.  
  9050. if [ "$B_NATIVE_DRIVER" != 'true' ];then
  9051. case $CARD in
  9052. $NVIDIA)
  9053. # set any custom stuff here
  9054. #[ "$B_RENDER_ACCEL" != 'true' ] && rend=$stateOff
  9055. # switching off this, making default always off, watch for user feedback
  9056. # if [ "$B_DISPLAY_DEVICES" == 'true' ];then
  9057. # ignoreDisplay=''
  9058. # fi
  9059. # UseEvents can reduce the cpu usage of Xorg on nVidia cards at the cost
  9060. # of instability on old versions of Xorg. Since Xorg development has
  9061. # stabilizied and all the big distributions run the latest Xserver, this
  9062. # is safe to turn on.
  9063. if [ "$B_USE_EVENTS" ]; then
  9064. useEvents=$stateTrue
  9065. fi
  9066. # this is legacy, new default is on
  9067. #[ "$B_TWINVIEW" == 'true' ] && twin=$stateOn
  9068. # triplebuffer can reduce 3d performance on cards with low graphics memory
  9069. # 64 mb or less. Default is off/disable/0
  9070. if [ "$B_TRIPLE_BUFFER" == 'true' ];then
  9071. triple=$stateTrue
  9072. fi
  9073. # this should let 3D work again for older cards, 400 etc:
  9074. # u
  9075. # if [ "$DRIVER_DEFAULT" == "$NV_LEGACY_1" ];then
  9076. # allowGlx='Option\t"AllowGLXWithComposite"\t"'$stateTrue'"\n\t'
  9077. # fi
  9078. # note: coolbits requires an integer value
  9079. # \n\tOption "RandRRotation"\t"'$stateTrue'"
  9080. # \n\tOption "DynamicTwinView"\t"'$twin'"
  9081. # perl -pi -e 's/^([\s]*Driver\s*"nvidia")/\1\n\t'$ignoreDisplay$allowGlx'Option "Coolbits"\t"1"\n\tOption "AddARGBGLXVisuals"\t"'$stateTrue'"\n\tOption "TripleBuffer"\t"'$triple'"/' $EXXC
  9082. ## NOTE: ignoreDisplay makes 352 series fail to start x;
  9083. ## xorg reports: 15.059] (WW) NVIDIA(0): Option "UseEvents" is not used
  9084. # perl -pi -e 's/^([\s]*Driver\s*"nvidia")/\1\n\t'$ignoreDisplay$allowGlx'Option "Coolbits"\t"8"\n\tOption "TripleBuffer"\t"'$triple'"\n\tOption "UseEvents"\t"'$useEvents'"/' $EXXC
  9085. perl -pi -e 's/^([\s]*Driver\s*"nvidia")/\1\n\t'$allowGlx'Option "Coolbits"\t"8"\n\tOption "TripleBuffer"\t"'$triple'"\n/' $EXXC
  9086. ;;
  9087. $FGLRX)
  9088. # set any custom stuff here
  9089. # only use fglrx internal agpart if not in system and never for 64 bit
  9090. #[ "$( lsmod | grep -c 'agpgart' )" -gt 0 -o "$BITS" == '64' ] && agpart='no'
  9091.  
  9092. # this is only for laptops
  9093. # if [ -n "$(find /proc/acpi/battery/ -mindepth 1 -type d 2>/dev/null)" ]
  9094. # then
  9095. # layout='LVDS,AUTO' # no space in string
  9096. # fi
  9097.  
  9098. # \n\tOption "UseInternalAGPGART" "'$agpart'"
  9099. # \n\tOption "VideoOverlay" "on"
  9100. # \n\tOption "MonitorLayout" "'$layout'
  9101. perl -pi -e 's/^([\s]*Load\s*"extmod")/#\1\n\tSubSection "extmod"\n\t Option "omit xfree86-dga"\n\tEndSubSection/' $EXXC
  9102.  
  9103. #s/^([\s]*Driver\s*"fglrx")/\1\n\tOption "UseInternalAGPGART" "'$agpart'"\n\tOption "TexturedXrender"/
  9104. ;;
  9105. esac
  9106. ## Native ati/nv specific stuff
  9107. else
  9108. if [ "$CARD" == $INTEL ];then
  9109. :
  9110. # note: changed XAA to EXA
  9111. elif [ "$NATIVE_OVERRIDE" == 'radeon' ];then
  9112. # removed: Option "AGPFastWrite" "off"\n\tOption "AGPMode" "4"\n\tOption "ColorTiling" "on"
  9113. perl -pi -e 's/^([\s]*Driver\s*"radeon")/\1\n\t\n\tOption "DynamicClocks" "on"\n\tOption "EnablePageFlip" "on"\n\tOption "AccelMethod" "EXA"/' $EXXC
  9114. fi
  9115. fi
  9116. eval $LOGPE
  9117. }
  9118.  
  9119. ########################################################################
  9120. #### OPTION HANDLER
  9121. ########################################################################
  9122.  
  9123. # args: $1 - d (driver); f (fglrx data); n (nvidia data)
  9124. show_extra_data()
  9125. {
  9126. local fullUrl='' ua='-U s-tools/sgfxi-data' uaFull='' dataFull='' dataType=''
  9127. local scriptVersion='' scriptDate='' scriptRemoteVersion='' scriptRemoteDate=''
  9128. local dataWorking='' bSysInfo='false'
  9129.  
  9130. case $1 in
  9131. d)
  9132. fullUrl='http://smxi.org/sg/data/sg-drivers-23'
  9133. uaFull="$ua.driver-data"
  9134. dataType='Supported Drivers List'
  9135. ;;
  9136. f)
  9137. fullUrl='http://smxi.org/sm/upgrade-data/video_support_fglrx'
  9138. uaFull="$ua.fglrx-status"
  9139. dataType='FGLRX Status'
  9140. bSysInfo='true'
  9141. ;;
  9142. n)
  9143. fullUrl='http://smxi.org/sm/upgrade-data/video_support_nvidia'
  9144. uaFull="$ua.nvidia-status"
  9145. dataType='Nvidia Status'
  9146. bSysInfo='true'
  9147. ;;
  9148. v)
  9149. fullUrl=$SCRIPT_DOWNLOAD_VERSION
  9150. uaFull="$ua.version-data"
  9151. dataType="(latest) $SCRIPT_NAME version information"
  9152. ;;
  9153. esac
  9154. if [ "$bSysInfo" == 'true' ];then
  9155. echo "${S}System Information :: Xorg Version: ${N}$X_VERSION ${S}:: Kernel: ${N}$( uname -r )"
  9156. fi
  9157. echo -n "${S}Retrieving live data... ${N}"
  9158. dataFull="$( wget -q $uaFull -O - $fullUrl 2>/dev/null )"
  9159. case $1 in
  9160. v)
  9161. # # don't need to run this if distro maintainer has set path
  9162. # if [ "$B_ALLOW_AUTO_UPDATE" == 'true' ];then
  9163. # check_set_distro
  9164. # fi
  9165. dataWorking=$( grep 'sgfxi=' <<< "$dataFull" | cut -d '=' -f 2 )
  9166.  
  9167. if [ -f $SCRIPT_HOME/$SCRIPT_NAME ];then
  9168. scriptVersion=$( grep -Eo -m 1 "(version:).*" $SCRIPT_HOME/$SCRIPT_NAME | cut -d ' ' -f 2-4 )
  9169. scriptDate=$( grep -Eo -m 1 '(Date:).*' $SCRIPT_HOME/$SCRIPT_NAME | cut -d ' ' -f 2-4 )
  9170. else
  9171. scriptVersion="Error: wrong path for $SCRIPT_NAME"
  9172. scriptDate="Error: wrong path for $SCRIPT_NAME"
  9173. fi
  9174. scriptRemoteVersion=$( cut -d ':' -f 1 <<< $dataWorking )
  9175. scriptRemoteDate=$( cut -d ':' -f 2 <<< $dataWorking )
  9176. if [ "$scriptVersion" == "$scriptRemoteVersion" ];then
  9177. dataFull="Remote Version: $scriptRemoteVersion is the same as Local Version: $scriptVersion"
  9178. else
  9179. dataFull="The remote and local script versions are different:\nRemote Version: $scriptRemoteVersion\nRemote Date: $scriptRemoteDate\n\nLocal Version: $scriptVersion\nLocal Date: $scriptDate"
  9180. fi
  9181. ;;
  9182. esac
  9183. if [ -n "$dataFull" ];then
  9184. echo "${S}Success! Here is the current $dataType:${N}"
  9185. echo $LINE
  9186. echo -e "$dataFull"
  9187. else
  9188. echo "${W}Failed!!${N}"
  9189. echo $WLINE
  9190. echo "${W}Unable to access the remote data file, exiting now, sorry."
  9191. echo "This feature requires a working internet connection.${N}"
  9192. fi
  9193. }
  9194.  
  9195. # keep this above getopts to keep it readable
  9196. # args: $1 if err or not, $2 extra data
  9197. show_options()
  9198. {
  9199. local xVersion=$X_VERSION
  9200. if [ -z "$X_VERSION" ];then
  9201. xVersion="${W}NO SUPPORTED XORG!${N}"
  9202. fi
  9203. #local pattern='(1\.0-)?([0-9]{4}|1[0-9]{2}\.[0-9]{2}\.?[0-9]{0,2}):?'
  9204. #local nvDefault=$( echo $NV_DEFAULT | sed -r 's/'$pattern'/\2 /g')
  9205. local nvDefaults=$( echo $NV_VERSIONS | tr ':' ' ' | sed 's/1.0-//g' )
  9206. #local nvVersions=$( echo "$NV_VERSIONS:$NV_OTHERS" | sed -r 's/'$pattern'/\2 /g')
  9207. local nvVersions=$( echo "$NV_OTHERS" | tr ':' ' ' | sed 's/1.0-//g')
  9208. #local nvQuadText='' nvQuad=$( echo $NV_QUAD | sed -r 's/'$pattern'/\2 /g')
  9209. local nvQuadText='' nvQuad=$( echo $NV_QUAD | tr ':' ' ' | sed 's/1.0-//g')
  9210. local fgDefault=$FG_DEFAULT
  9211. local fgVersions=$( echo "$FG_VERSIONS:$FG_OTHERS" | sed 's/:/ /g')
  9212. local nativeVersions=$( echo $NATIVE_OVERRIDE_SUPPORTED | sed 's/|/ /g' )
  9213. local fgBeta='' nvBeta='' betaText='' fgDebianSid=''
  9214. local counter=0 driverCount=0 bSkipOutput=''
  9215. driverCount=$( wc -w <<< $nativeVersions )
  9216.  
  9217. if [ "$B_DISTRO_FLAG" == 'true' ];then
  9218. fgDebianSid='echo -e "'${W}'ATI: installer package '$fgDefault' is currently broken in Debian (works in Ubuntu). Script will default to: '$DISTRO_FGLRX${N}'"'
  9219. else
  9220. fgDebianSid='echo -e "fglrx: default: '$fgDefault' supported-drivers: '$fgVersions'"'
  9221. fi
  9222.  
  9223. if [ -n "$NV_BETA" -a "$NV_BETA" != "$NV_DEFAULT" ];then
  9224. nvBeta='echo -e "nvidia: '$( echo $NV_BETA | tr ':' ' ' | sed 's/[[:space:]][[:space:]]/ /g' )'"'
  9225. fi
  9226. if [ -n "$FG_DEFAULT_BETA" -a "$FG_DEFAULT_BETA" != "$FG_DEFAULT" ];then
  9227. fgBeta='echo -e "fgrlx:\t'$FG_DEFAULT_BETA'"'
  9228. fi
  9229. if [ -n "$fgBeta" -o -n "$nvBeta" ];then
  9230. betaText='echo "The following beta drivers are available:"'
  9231. fi
  9232. if [ -n "$NV_QUAD" -a "$NV_QUAD" != "$NV_DEFAULT" ];then
  9233. nvQuadText='echo -e "Nvidia Quadroplex driver (automatically selected if you have a Quad card): '$nvQuad'"'
  9234. fi
  9235.  
  9236. if [ "$1" == 'err' ];then
  9237. echo "${W}Sorry, one of your arguments is not a supported option.${N}"
  9238. echo "Please check the following options and try again."
  9239. echo $PLINE
  9240. fi
  9241. if [ -n "$DISPLAY" ];then
  9242. echo "${W}While you can run this script in X, we recommend you run it in terminal.${N}"
  9243. echo $PLINE
  9244. fi
  9245. echo "Script Requirements: Debian/Ubuntu/Arch/Fedora based systems."
  9246. echo "Xorg version required: 7.1/1.1 or greater - Your X version: $xVersion"
  9247. echo "Linux Kernel required: 2.6.18 or greater - Your kernel: $(uname -r)"
  9248. echo $PLINE
  9249. echo "'default(s):' - The driver installed automatically by $SCRIPT_NAME unless it is not supported by"
  9250. echo "your card. Some older cards will force an override of this basic default. Script will"
  9251. echo "print out what driver it will install when you start it up, with option to exit."
  9252. echo
  9253. echo "'supported-drivers:' choices require -o <see -o for correct syntax> to install>."
  9254. echo "Fglrx: default: $fgDefault"
  9255. echo -n "Other supported-drivers: "
  9256. counter=0
  9257. driverCount=$( wc -w <<< $fgVersions )
  9258. for i in $fgVersions
  9259. do
  9260. (( counter++ ))
  9261. case $counter in
  9262. 12|28)
  9263. echo "$i "
  9264. echo -n ""
  9265. ;;
  9266. $driverCount)
  9267. echo "$i "
  9268. ;;
  9269. *)
  9270. echo -n "$i "
  9271. ;;
  9272. esac
  9273. done
  9274. #echo "fglrx: default: $fgDefault supported-drivers: $fgVersions"
  9275. echo "Nvidia: defaults (current + legacy - 3 2 1): $nvDefaults"
  9276. echo -n "Other supported-drivers: "
  9277. counter=0
  9278. driverCount=$( wc -w <<< $nvVersions )
  9279. for i in $nvVersions
  9280. do
  9281. (( counter++ ))
  9282. case $counter in
  9283. 7|17)
  9284. echo "$i "
  9285. echo -n ""
  9286. ;;
  9287. $driverCount)
  9288. echo "$i "
  9289. ;;
  9290. *)
  9291. echo -n "$i "
  9292. ;;
  9293. esac
  9294. done
  9295. eval $nvQuadText
  9296. eval $betaText
  9297. eval $nvBeta
  9298. eval $fgBeta
  9299. echo $PLINE
  9300. echo "Script Options:"
  9301. echo "-A Run the install non-interactively. Will not restart x at end. Expert users only! Requires testing."
  9302. echo "-b Enable tripleBuffer (nvidia only). triplebuffer can reduce 3d performance on cards"
  9303. echo " with low graphics memory (64 mB or less). Default is disabled/off."
  9304. echo "-B Use latest Beta Driver for your card type. Autodetects card type/beta driver (nVidia/AMD cards only)."
  9305. echo " If no beta driver is available, the current stable driver for your card type is used."
  9306. echo " (Also checks for live latest beta information, and replaces script defaults with newer if present)"
  9307. echo "-c Force use of Xorg composite mode. Beryl/Compiz requires this for 3d. Old nvidia/ATI/Intel "
  9308. echo " cards not supported. Composite is default ON for newer nVidia/ATI cards (-c not required)."
  9309. echo "-C Skip Xorg configuration. Only use this if your Xorg is already working with your driver."
  9310. echo " Main use is if you have dual card output and don't want xorg.conf changed."
  9311. echo "-d Installs distro packaged nVidia/fglrx drivers. ATI/nVidia cards only (formerly -s)."
  9312. echo "-D Build Distro (Debian/Ubuntu only) packages for fglrx with FGLRX binary run package,"
  9313. echo " then install them (formerly -F). Not recommended. Because of constant package"
  9314. echo " builder failures, the direct install method is now default."
  9315. # echo "-e Use experimental drivers (currently: xorg ati only)."
  9316. # echo "-E Adds extra experimental driver features. Currently libdrm2 things for ati."
  9317. echo "-f Force option. Forces (re)install of your driver, bypasses default module check/build/rebuild (nVidia only)."
  9318. echo " Note; -f cannot be used with -k because they contradict each other!"
  9319. echo "-h View this help menu."
  9320. echo "-j Alternate text/output script colors. Requires this syntax: -j 0 (sets to monochrome )"
  9321. echo " -j 1 (default); -j 2 (pale); -j 3 (earthy); -j 4 (dark - for light console background)"
  9322. echo "-k Build kernel module either for current kernel or another kernel (with -K <kernel version)"
  9323. echo " Can be run in X (if not in X and installing to current kernel). Simply builds the kernel"
  9324. echo " module for that kernel, and does not remove any other modules or drivers, or update $EXXC."
  9325. echo " Requires previous install with $SCRIPT_NAME of the same driver to work. This feature only"
  9326. echo " supports nVidia drivers. $SCRIPT_NAME defaults to building modules for kernels automatically."
  9327. echo " The -f option overrides this default behavior and forces a full reinstall of the driver."
  9328. echo " Hint: sgfxi -! 40 will install modules to all your non-running kernels automatically!"
  9329. echo "-K Installs nVidia/fglrx driver for another kernel. Syntax: $SCRIPT_NAME -K 2.6.25-2"
  9330. echo " $SCRIPT_NAME will double check that the kernel exists (Debian/Ubuntu only). "
  9331. echo "-L List current live driver or status data then exit. Requires extra argument: d to show current drivers;"
  9332. echo " n to show current nvidia support status; f to show current fglrx support status;"
  9333. echo " v to show current latest local + remote $SCRIPT_NAME svn/server version information."
  9334. echo "-m Overrides default (-d) dkms driver method, uses $SCRIPT_NAME's old method, kernel-source + m-a build"
  9335. echo " of module. Use only if you want to avoid dkms (fglrx/nvidia only). Triggers -d as well."
  9336. echo "-n Automatically installs correct native xorg nvidia, intel, or ati/amd driver for your system."
  9337. echo " Cleans up old binary driver stuff, updates xorg.conf with new driver information,"
  9338. echo " and cleans nvidia and fgrlx stuff out of xorg.conf. For radeon/noveau, also preps."
  9339. echo "-N Force install of specific xorg driver. Syntax: $SCRIPT_NAME -N <driver> Ex: $SCRIPT_NAME -N radeon"
  9340. echo -n " Supported Xorg drivers: "
  9341. counter=0
  9342. driverCount=$( wc -w <<< $nativeVersions )
  9343. for i in $nativeVersions
  9344. do
  9345. (( counter++ ))
  9346. case $counter in
  9347. 12|25)
  9348. echo " $i"
  9349. echo -n " "
  9350. ;;
  9351. $driverCount)
  9352. echo " $i"
  9353. ;;
  9354. *)
  9355. echo -n " $i"
  9356. ;;
  9357. esac
  9358. done
  9359. echo " Also configures xorg.conf as required. Full radeon xorg 3d configuration automatically."
  9360. echo "-o Override default: install a specific driver, this is an absolute override - syntax:"
  9361. echo " -o 177.68 (for nVidia) or: -o 8-6 (for fglrx)"
  9362. echo "-q Turns off composite mode. Default is ON for newer nVidia/ATI cards."
  9363. echo "-Q Skip start X Question, automatically start X post driver install."
  9364. echo "-r Remove mode lines from xorg.conf"
  9365. # echo "-t Enables dynamic twinview (nVidia only) - LEGACY, unused now. Default is on, enabled."
  9366. echo "-R Skips self updating feature. No restart."
  9367.  
  9368. # echo "-S Skips automatic logout and X startup when script is run in standalone mode."
  9369. echo "-U Forces $SCRIPT_NAME to update itself, must be root, but can be in x. Exits after."
  9370. echo "-v Prints $SCRIPT_NAME current version information. Exits after."
  9371. echo "-W Skip all wget downloads. Expert Use Only! Only use this to (re)install a driver that has already "
  9372. echo " been downloaded using $SCRIPT_NAME previously. Because using this option can have unknown or unintended"
  9373. echo " consequences, only use it if you are following instructions to do so. $SCRIPT_NAME always saves its "
  9374. echo " driver downloads by default in all cases, so using -W will not change that behavior , but it may stop"
  9375. echo " other key downloads, like patches. The standard use for this is to download the driver file in X,"
  9376. echo " then exit, and install it out of X"
  9377. echo "-x Reverts to default libXvMC.so.1 for system instead of nVidia package (nVidia only)"
  9378. echo "-X Use to skip auto X start/stop. Do not use this unless you have a good reason to not "
  9379. echo " want X start/stop tests to run. Gives start X option on completion if not in X. Expert use only."
  9380. echo "-Y Clean script download and backup files. Shows a list of cleanup actions to carry out, including script uninstaller."
  9381. echo " Can be run in X, as root."
  9382. echo "-z Backup and recreate xorg.conf using the command: X -configure (requires X/Xorg command)"
  9383. echo " Only use if you know what you are doing! This creates a simple, basic xorg.conf file."
  9384. # echo "-Z Skips connection test. Use this if $SCRIPT_NAME gives you connection failed error but"
  9385. # echo " you are sure your connection is fine."
  9386. echo $PLINE
  9387. echo "Advanced Options :: Only for Specialized Cases"
  9388. echo "-! 32 Remove/Purge all drivers; remove all grub modeline blacklists; restore system to default"
  9389. echo " without redoing xorg.conf; moves xorg.conf to backup. Only use this on new Xorgs that do not"
  9390. echo " require xorg.conf file to operate. Using this command restores system to default."
  9391. echo "-! 33 Skip Grub file tests. Important: Only use with nVidia/ATI if radeon/nouveau have been blacklisted."
  9392. echo "-! 40 Create modules for all your kernels (nVidia only). Will loop through and test"
  9393. echo " each if can be made, then create the modules, excluding your running kernel."
  9394. echo " You must have already installed an nVidia driver with $SCRIPT_NAME to use -! 40"
  9395. echo " Note: if your installed driver is NOT the default $SCRIPT_NAME offers, you have to"
  9396. echo " use either the -o <driver number> OR the -B option (if you are using current beta driver)"
  9397. echo " as well as the -! 40 option. EG: to install beta to all kernels: $SCRIPT_NAME -B -! 40"
  9398. echo " -! 40 must be the LAST option in your list of options or errors will occur!"
  9399. echo "--debugger Create debugger data file in $HOME/$SCRIPT_NAME-data - the file is a gz file that holds"
  9400. echo " whatever might be helpful to debugging $SCRIPT_NAME issues, like xorg.conf, lspci, inxi"
  9401. echo " output if present, etc. Upload file to: ftp.techpatterns.com/incoming OR use a service"
  9402. echo " like dropbox.com then give me the url to the uploaded file. If $SCRIPT_NAME has an internet"
  9403. echo " connection and python > 2.5, will also automatically upload the data to server for you."
  9404. if [ "$1" == 'full' ];then
  9405. echo $PLINE
  9406. echo "Developer and Testing Options (Advanced):"
  9407. echo "-! 1 - Sets flag B_TESTING_1='true' - sets testing function data active."
  9408. echo "-! 2 - Sets flag B_TESTING_2='true' - triggers exit after run package download/extract."
  9409. echo "-! 3 - Sets flag B_SKIP_FUNCTION='true' to turn off functions for script testing."
  9410. echo "-! 4 - Sets flags B_TESTING_1='true' and B_TESTING_2='true'."
  9411. echo "-! 5 - Sets flags B_TESTING_1, B_TESTING_2, and B_SKIP_FUNCTION ='true'."
  9412. echo "-! 6 - Sets flag B_TESTING_3='true' - overrides initial driver xorg/kernel support tests."
  9413. echo "-! 7 - Sets flag B_TESTING_4='true' - overrides patch controls."
  9414. echo "-! 8 - Sets flag B_TESTING_5='true' - activates beta/advanced development features for debugging."
  9415. echo "-! 9 - Sets flag B_TESTING_6='true' - triggers experimental new distro support methods."
  9416. echo "-! 10 - Triggers an update from the primary dev download server."
  9417. echo "-! 11 - Triggers an update from svn branch one - if present, of course."
  9418. echo "-! 12 - Triggers an update from svn branch two - if present, of course."
  9419. echo "-! <http://......> - Triggers an update from whatever server you list."
  9420. echo "-! 20 - Uses patch from svn branch one server (must be in branch/one/patches)."
  9421. echo "-! 21 - Uses patch from svn branch two server (must be in branch/two/patches)."
  9422. echo "-! 30 - Backup, download, replace, xorg.conf with basic Debian xorg.conf version (legacy, don't use)."
  9423. echo " Use X -configure instead to redo your xorg, or -z option in $SCRIPT_NAME."
  9424. echo "-! 31 - Backup, download, replace, xorg.conf with basic xorg.conf version (legacy, don't use)."
  9425.  
  9426. echo " Use X -configure instead to redo your xorg, or -z option in $SCRIPT_NAME."
  9427. echo "-p Print currently supported drivers, <default>:<latest>:<legacy1>:<legacy2>"
  9428. echo " then exit the script without doing the driver download/install."
  9429. echo "-! 121 - When used with -p, will use the live driver list from smxi.org"
  9430. echo " instead of the drivers taken from the local user $SCRIPT_NAME values."
  9431. fi
  9432. echo
  9433. if [ "$1" == 'err' ];then
  9434. exit 1
  9435. else
  9436. exit 0
  9437. fi
  9438. }
  9439.  
  9440. # args: $1 - "$@"
  9441. get_options()
  9442. {
  9443. local opt=''
  9444.  
  9445. case $1 in
  9446. --debugger)
  9447. if tty > /dev/null ;then
  9448. debugger_data_collector
  9449. else
  9450. echo "You cannot use the $SCRIPT_NAME debugger option in an IRC client!"
  9451. exit 1
  9452. fi
  9453. ;;
  9454. --help|-h)
  9455. if tty > /dev/null ;then
  9456. show_options
  9457. else
  9458. echo "You cannot use the $SCRIPT_NAME help option in an IRC client!"
  9459. exit 1
  9460. fi
  9461. ;;
  9462. --version|-v)
  9463. # if showing in irc, kill the colors
  9464. if ! tty > /dev/null ;then
  9465. SCRIPT_COLORS=0
  9466. set_script_colors
  9467. fi
  9468. print_information
  9469. exit 0
  9470. ;;
  9471. esac
  9472.  
  9473. while getopts AbBcCdDeEfFGHj:kK:L:mnN:o:pP:QrRsStUWXxYzZ!: opt
  9474. do
  9475. case $opt in
  9476. A) B_AUTORUN='true'
  9477. START_OPTIONS=$START_OPTIONS' -A'
  9478. START_OPTIONS_PRINT="$START_OPTIONS_PRINT -A - Autorun is selected\n"
  9479. ;;
  9480. b) B_TRIPLE_BUFFER='true'
  9481. START_OPTIONS=$START_OPTIONS' -b'
  9482. START_OPTIONS_PRINT="$START_OPTIONS_PRINT -b - TripleBuffer is on (nVidia only)\n"
  9483. ;;
  9484. B) B_USE_BETA='true'
  9485. START_OPTIONS=$START_OPTIONS' -B'
  9486. START_OPTIONS_PRINT="$START_OPTIONS_PRINT -B - Use Beta Driver (Only if available)\n"
  9487. ;;
  9488. c) B_COMPOSITE='true'
  9489. START_OPTIONS=$START_OPTIONS' -c'
  9490. START_OPTIONS_PRINT="$START_OPTIONS_PRINT -c - Force composite flag on. Does not work with legacy nVidia driver\n Composite is default ON for newer nVidia cards (no -c required).\n Switch composite OFF with: -q\n"
  9491. ;;
  9492. C) B_SKIP_CONFIG='true'
  9493. START_OPTIONS=$START_OPTIONS' -C'
  9494. START_OPTIONS_PRINT="$START_OPTIONS_PRINT -C - Xorg.conf will not be modified by this script.\n"
  9495. ;;
  9496. d) B_USE_DISTRO_DRIVER='true'
  9497. B_FGLRX_DIRECT=''
  9498. START_OPTIONS=$START_OPTIONS' -d'
  9499. START_OPTIONS_PRINT="$START_OPTIONS_PRINT -d - Install distro packaged driver.\n"
  9500. ;;
  9501. D) B_FGLRX_DEB_BUILDER='true'
  9502. B_FGLRX_DIRECT=''
  9503. START_OPTIONS=$START_OPTIONS' -D'
  9504. START_OPTIONS_PRINT="$START_OPTIONS_PRINT -D - Using FGLRX Distro package builder install. Not reliable, but try if you want.\n Builds/Installs packages for distro from downloaded fglrx run file.\n"
  9505. ;;
  9506. # e) B_EXPERIMENTAL='true'
  9507. # START_OPTIONS=$START_OPTIONS' -e'
  9508. # ;;
  9509. # E) B_EXTRA_EXPERIMENTAL='true'
  9510. # START_OPTIONS=$START_OPTIONS' -E'
  9511. # ;;
  9512. f) B_FORCE_OPTION='true'
  9513. START_OPTIONS=$START_OPTIONS' -f'
  9514. START_OPTIONS_PRINT="$START_OPTIONS_PRINT -f - You are using the forced override option. This will bypass kernel module\n check/build and force reinstall of your driver (nVidia only).\n"
  9515. ;;
  9516. F) B_FGLRX_DEB_BUILDER='true'
  9517. B_FGLRX_DIRECT=''
  9518. START_OPTIONS=$START_OPTIONS' -F'
  9519. START_OPTIONS_PRINT="$START_OPTIONS_PRINT -F - Using FGLRX package builder install. Not reliable, but try if you want.\n -F is deprecated, please use -D instead in the future.\n"
  9520. ;;
  9521. G) B_GUI_MODE='true'
  9522. B_SKIP_X_TEST='true'
  9523. START_OPTIONS=$START_OPTIONS' -G'
  9524. START_OPTIONS_PRINT="$START_OPTIONS_PRINT -G - Gui mode. Run in X. For nVidia, passes --no-x-check flag to nvidia installer\n . Not reliable, but try if you want.\n"
  9525. ;;
  9526. j) if [ -n "$( grep -sE '^[0-4]$' <<< $OPTARG )" ];then
  9527. SCRIPT_COLORS=$OPTARG
  9528. START_OPTIONS=$START_OPTIONS" -j $OPTARG"
  9529. # no reason to reset the colors if they are default
  9530. if [ "$SCRIPT_COLORS" != 1 ];then
  9531. START_OPTIONS=$START_OPTIONS" -j $SCRIPT_COLORS"
  9532. set_script_colors
  9533. fi
  9534. else
  9535. error_handler 228 $OPTARG
  9536. fi
  9537. ;;
  9538. k) B_KERNEL_MODULE_ONLY='true'
  9539. START_OPTIONS_PRINT="$START_OPTIONS_PRINT -k - Building nvidia kernel module using previously installed driver\n Permits building a module for an alternate kernel while in X.\n"
  9540. START_OPTIONS=$START_OPTIONS" -k "
  9541. ;;
  9542. K) INSTALL_TO_KERNEL="$OPTARG"
  9543. START_OPTIONS_PRINT="$START_OPTIONS_PRINT -K - You are installing a graphic driver onto the kernel: ${C}$INSTALL_TO_KERNEL${S}\n"
  9544. test_install_kernel_version
  9545. START_OPTIONS=$START_OPTIONS" -K $OPTARG"
  9546. ;;
  9547. L) if [ -n "$( grep -sE '^[dfnv]$' <<< $OPTARG )" ];then
  9548. show_extra_data "$OPTARG"
  9549. exit 0
  9550. else
  9551. error_handler 228 $OPTARG
  9552. fi
  9553. ;;
  9554. m) B_USE_DISTRO_MODULE_MA='true'
  9555. B_USE_DISTRO_DRIVER='true'
  9556. B_FGLRX_DIRECT=''
  9557. START_OPTIONS=$START_OPTIONS' -m'
  9558. START_OPTIONS_PRINT="$START_OPTIONS_PRINT -m - Install distro packaged driver using kernel source + m-a.\n"
  9559. ;;
  9560. n) B_NATIVE_DRIVER='true'
  9561. START_OPTIONS=$START_OPTIONS' -n'
  9562. START_OPTIONS_PRINT="$START_OPTIONS_PRINT -n - Auto install of native xorg intel, nvidia, 3dfx, or ati drivers.\n"
  9563. ;;
  9564. N)
  9565. if [ -n $( grep -sE '('$NATIVE_OVERRIDE_SUPPORTED')' <<< $NATIVE_OVERRIDE ) ];then
  9566. NATIVE_OVERRIDE="$OPTARG"
  9567. B_NATIVE_DRIVER='true'
  9568. START_OPTIONS_PRINT="$START_OPTIONS_PRINT -N - Native driver custom install. You have requested to install the xorg driver: $NATIVE_OVERRIDE\n"
  9569. START_OPTIONS=$START_OPTIONS" -N $OPTARG"
  9570. else
  9571. error_handler 237 $NATIVE_OVERRIDE
  9572. fi
  9573. ;;
  9574. o) DRIVER_OVERRIDE="$OPTARG"
  9575. START_OPTIONS_PRINT="$START_OPTIONS_PRINT -o - Driver override. Forces install of this driver: $DRIVER_OVERRIDE (nVidia|ATI fglrx only)\n"
  9576. START_OPTIONS=$START_OPTIONS" -o $OPTARG"
  9577. ;;
  9578. p) B_PRINT_VER='true'
  9579. START_OPTIONS=$START_OPTIONS' -p'
  9580. ;;
  9581. P) if [ -n $( grep -sE '^(apt-get|aptitude)$' <<< $OPTARG ) ];then
  9582. PACKAGE_MANAGER=$OPTARG
  9583. APT_TYPE=$OPTARG
  9584. START_OPTIONS=$START_OPTIONS" -P $OPTARG"
  9585. else
  9586. error_handler 228 $OPTARG
  9587. fi
  9588. ;;
  9589. q) B_FORCE_NO_COMPOSITE='true'
  9590. B_COMPOSITE='false'
  9591. START_OPTIONS=$START_OPTIONS' -q'
  9592. START_OPTIONS_PRINT="$START_OPTIONS_PRINT -q - Turn off default ON composite flag (nVidia only).\n"
  9593. ;;
  9594. Q) B_SKIP_X_QUESTION='true'
  9595. START_OPTIONS=$START_OPTIONS' -Q'
  9596. START_OPTIONS_PRINT="$START_OPTIONS_PRINT -Q - X will start automatically when the driver install is finished.\n"
  9597. ;;
  9598. r) B_REMOVE_MODELINES='true'
  9599. START_OPTIONS=$START_OPTIONS' -r'
  9600. START_OPTIONS_PRINT="$START_OPTIONS_PRINT -r - Remove modelines in xorg.conf (ATI only).\n"
  9601. ;;
  9602. R) B_SKIP_RESTART='true'
  9603. ;;
  9604. # deprecated but leaving to not break existing methods
  9605. s) B_USE_DISTRO_DRIVER='true'
  9606. B_FGLRX_DIRECT=''
  9607. START_OPTIONS=$START_OPTIONS' -s'
  9608. START_OPTIONS_PRINT="$START_OPTIONS_PRINT -s - Install distro packaged driver. Deprecated. Please use -d instead\n"
  9609. ;;
  9610. S) B_SKIP_AUTOSTART='true'
  9611. START_OPTIONS=$START_OPTIONS' -S'
  9612. START_OPTIONS_PRINT="$START_OPTIONS_PRINT -S - Deprecated, not used. Skip autostart of X/kde.\n"
  9613. ;;
  9614. t) B_TWINVIEW='true'
  9615. START_OPTIONS=$START_OPTIONS' -t'
  9616. START_OPTIONS_PRINT="$START_OPTIONS_PRINT -t - twinview on: this is deprecated. Always sets for twinview (nVidia only)\n"
  9617. ;;
  9618. U) B_FORCE_UPDATE='true'
  9619. ;;
  9620. W) B_SKIP_WGET='true'
  9621. START_OPTIONS=$START_OPTIONS' -W'
  9622. START_OPTIONS_PRINT="$START_OPTIONS_PRINT -W - Skip wget downloads. Only use if you are having problems connecting\n but you have the current driver downloaded already. Not recommended!\n"
  9623. ;;
  9624. x) B_NO_XVMC='true' # because two flags are required to use nvidia xvmc, this is fine
  9625. START_OPTIONS=$START_OPTIONS' -x'
  9626. START_OPTIONS_PRINT="$START_OPTIONS_PRINT -x - Skip nVidia xvmc setup. (nVidia only)\n"
  9627. ;;
  9628. X) B_SKIP_X_TEST='true'
  9629. START_OPTIONS=$START_OPTIONS' -X'
  9630. START_OPTIONS_PRINT="$START_OPTIONS_PRINT -X - Skip the test for X/KDE. Only use if you know what you are doing!\n"
  9631. ;;
  9632. Y) clean_script_data
  9633. ;;
  9634. z) if [ -z "$DISPLAY" ];then
  9635. B_MOVE_X_CONF='true'
  9636. START_OPTIONS=$START_OPTIONS' -z'
  9637. START_OPTIONS_PRINT="$START_OPTIONS_PRINT -z - Backup and recreate xorg.conf using the command: X -configure\nOnly use if you know what you are doing!\n"
  9638. else
  9639. error_handler 250
  9640. fi
  9641. ;;
  9642. Z) B_SKIP_CONNECT='true'
  9643. START_OPTIONS=$START_OPTIONS' -ZW'
  9644. START_OPTIONS_PRINT="$START_OPTIONS_PRINT -Z - Deprecated, use -R to skip script update; use -W to skip all downloads.\n"
  9645. ;;
  9646. H) show_options 'full'
  9647. ;;
  9648. ## debuggers and testing options
  9649. !) # test for various supported methods
  9650. bSkipOutput=''
  9651. case $OPTARG in
  9652. 1) B_TESTING_1='true'
  9653. ;;
  9654. 2) B_TESTING_2='true'
  9655. ;;
  9656. 3) B_SKIP_FUNCTION='true'
  9657. ;;
  9658. 4) B_TESTING_1='true'
  9659. B_TESTING_2='true'
  9660. ;;
  9661. 5) B_TESTING_1='true'
  9662. B_TESTING_2='true'
  9663. B_SKIP_FUNCTION='true'
  9664. ;;
  9665. 6) B_TESTING_3='true'
  9666. ;;
  9667. 7) B_TESTING_4='true'
  9668. ;;
  9669. 8) B_TESTING_5='true'
  9670. ;;
  9671. 9) B_TESTING_6='true'
  9672. ;;
  9673. 10)
  9674. cd $SCRIPT_HOME
  9675. check_root
  9676. check_set_distro
  9677. check_update_script "$SCRIPT_NAME" "$SCRIPT_DOWNLOAD_DEV" 'dev server'
  9678. ;;
  9679. 11)
  9680. cd $SCRIPT_HOME
  9681. check_root
  9682. check_set_distro
  9683. check_update_script "$SCRIPT_NAME" "$SCRIPT_DOWNLOAD_BRANCH_1" 'svn: branch one server'
  9684. ;;
  9685. 12)
  9686. cd $SCRIPT_HOME
  9687. check_root
  9688. check_set_distro
  9689. check_update_script "$SCRIPT_NAME" "$SCRIPT_DOWNLOAD_BRANCH_2" 'svn: branch two server'
  9690. ;;
  9691. http*)
  9692. cd $SCRIPT_HOME
  9693. check_root
  9694. check_set_distro
  9695. check_update_script "$SCRIPT_NAME" "$OPTARG" 'alt server'
  9696. ;;
  9697. 20)
  9698. PATCH_DOWNLOAD="$SCRIPT_DOWNLOAD_BRANCH_1"
  9699. ;;
  9700. 21)
  9701. PATCH_DOWNLOAD="$SCRIPT_DOWNLOAD_BRANCH_2"
  9702. ;;
  9703. # let these run in X
  9704. 30)
  9705. cd $SCRIPT_HOME
  9706. check_root
  9707. check_set_distro
  9708. check_update_script "dm-1-xorg-conf" "$SCRIPT_DOWNLOAD_DATA" 'main server'
  9709. exit 0
  9710. ;;
  9711. 31)
  9712. cd $SCRIPT_HOME
  9713. check_root
  9714. check_set_distro
  9715. check_update_script "sm-1-xorg-conf" "$SCRIPT_DOWNLOAD_DATA" 'main server'
  9716. exit 0
  9717. ;;
  9718. 32)
  9719. B_RESTORE_DEFAULTS='true'
  9720. B_NATIVE_DRIVER='true'
  9721. B_MOVE_X_CONF='true'
  9722. ;;
  9723. 33)
  9724. B_SKIP_GRUB_TEST='true'
  9725. ;;
  9726. 40)
  9727. B_BUILD_KERNEL_MODULES='true'
  9728. ;;
  9729. 120)
  9730. B_SM_INSTALL='true'
  9731. S=${CALLER_DEF} # change standard text color to caller standard text
  9732. bSkipOutput='true'
  9733. ;;
  9734. 121)
  9735. B_GET_LIVE_DRIVERS='true'
  9736. ;;
  9737. 122)
  9738. B_LAUNCH_FROM_X='true'
  9739. ;;
  9740. *)
  9741. error_handler 178 "$OPTARG"
  9742. ;;
  9743. esac
  9744. START_OPTIONS="$START_OPTIONS -! $OPTARG"
  9745. if [ "$bSkipOutput" != 'true' ];then
  9746. START_OPTIONS_PRINT="$START_OPTIONS_PRINT -! $OPTARG - You are using an advanced Testing option. Only use this if you know what you are doing!\n"
  9747. fi
  9748. ;;
  9749. *) show_options err
  9750. ;;
  9751. esac
  9752. done
  9753. if [ "$B_FORCE_OPTION" == 'true' -a "$B_KERNEL_MODULE_ONLY" == 'true' ];then
  9754. error_handler 166 "-k and -f"
  9755. fi
  9756. #in case -n is used too - note: this will never be true, have to fix this one
  9757. if [ "$B_NATIVE_DRIVER" == "true" -a -n "$INSTALL_TO_KERNEL" ];then
  9758. echo "${W}WARNING: -n will uninstall binary drivers to all the kernels, not just $KERNEL_FULL${N}"
  9759. fi
  9760.  
  9761. }
  9762.  
  9763. ########################################################################
  9764. #### MAIN: EXECUTE
  9765. ########################################################################
  9766.  
  9767. # this must be set before anything else runs in script, -j will reset to no colors
  9768. set_script_colors $COLOR_DEFAULT
  9769. # set all options
  9770. get_options "$@"
  9771. # this exits when it's done if triggered
  9772. if [ "$B_BUILD_KERNEL_MODULES" == 'true' ];then
  9773. check_set_distro ## need to know what it is for some tests
  9774. install_modules_to_all_kernels
  9775. fi
  9776. # Get kernel string stuff, no need to rerun this after it's been set in options
  9777. if [ -z "$INSTALL_TO_KERNEL" ];then
  9778. kernel_string_info
  9779. fi
  9780.  
  9781. ## if this exits with error, no lib files will be downloaded
  9782. if [ "$B_SKIP_FUNCTION" != 'true' ];then
  9783. basic_startup_tests
  9784. fi
  9785.  
  9786. ## update everything, restart if not run from smxi
  9787. if [ "$B_ALLOW_AUTO_UPDATE" == 'true' -a "$B_SKIP_RESTART" != 'true' -a "$B_SM_INSTALL" != 'true' -a "$B_SKIP_FUNCTION" != 'true' -a "$B_SKIP_WGET" != 'true' -a "$B_PRINT_VER" != 'true' ];then
  9788. check_update_script $SCRIPT_NAME "$SCRIPT_DOWNLOAD" 'default server'
  9789. fi
  9790.  
  9791. set_test_data # this will set other test data for debugging
  9792.  
  9793. if [ "$B_PRINT_VER" != 'true' ];then
  9794. # test for multiple video cards and select only one
  9795. if [ "$CARD_COUNT" -gt 1 -a "$B_RESTORE_DEFAULTS" != 'true' ];then
  9796. # handle no xorg.conf with new X situation, only create xorg.conf
  9797. # if > 2 cards prior to testing for supported cards
  9798. if [ "$B_SKIP_FUNCTION" != 'true' ];then
  9799. create_x_conf
  9800. fi
  9801. select_card
  9802. fi
  9803. print_information
  9804. fi
  9805.  
  9806. if [ "$B_GET_LIVE_DRIVERS" == 'true' -a "$B_PRINT_VER" == 'true' ];then
  9807. reset_using_live_driver_data
  9808. fi
  9809.  
  9810. ## this is separate so card can get set first for native installer
  9811. set_card
  9812.  
  9813. if [ "$B_NATIVE_DRIVER" != 'true' ];then
  9814. detect_card_version
  9815. fi
  9816.  
  9817. # this needs to go before logging starts so we know what the package manager is
  9818. if [ "$B_PRINT_VER" != 'true' -a -z "$PACKAGE_MANAGER" -a "$B_SM_INSTALL" != 'true' -a "$B_AUTORUN" != 'true' ];then
  9819. check_apt_aptitude
  9820. fi
  9821.  
  9822. ## This has to run after card version detection to log that data
  9823. ## don't log the first start if restart/print output happens
  9824. if [ "$B_PRINT_VER" != 'true' ];then
  9825. create_log
  9826. fi
  9827. # need to handle new xorg no xorg.conf systems
  9828. # no need to create this if the card isn't supported, so this comes
  9829. # after print info and log start unless > 1 card detected
  9830. if [ "$B_PRINT_VER" != 'true' -a "$B_SKIP_FUNCTION" != 'true' ];then
  9831. if [ "$B_MOVE_X_CONF" == 'true' ];then
  9832. move_x_conf
  9833. fi
  9834. if [ "$B_RESTORE_DEFAULTS" != 'true' ];then
  9835. create_x_conf
  9836. fi
  9837. fi
  9838.  
  9839. # we'll need to force an initial update on fresh apt type installs for header
  9840. # checks and other package checks.
  9841. if [ "$B_SKIP_FUNCTION" != 'true' -a "$B_PRINT_VER" != 'true' -a "$B_SM_INSTALL" != 'true' ];then
  9842. check_package_manager_updated
  9843. fi
  9844. # this exits when done
  9845. if [ "$B_NATIVE_DRIVER" == 'true' ];then
  9846. install_native_driver
  9847. fi
  9848. ## ready to set the data for version/system info
  9849. if [ "$B_USE_DISTRO_DRIVER" != 'true' ];then
  9850. check_supported_driver # make sure user entered data is correct
  9851. set_cpu_data
  9852. fi
  9853. # needs to be out to give print version, if print out driver data, exits after.
  9854. set_driver_install_version
  9855.  
  9856. if [ "$B_NATIVE_DRIVER" != 'true' ];then
  9857. # make sure user has kernel headers, to avoid running unneeded clean up or prep
  9858. check_kernel_headers
  9859. if [ "$B_CHECK_IA32" == 'true' ];then
  9860. check_ia32_libs 'full'
  9861. fi
  9862. fi
  9863.  
  9864. if [ "$B_USE_DISTRO_DRIVER" != 'true' ];then
  9865. create_data_storage
  9866. check_run_package_tools
  9867. set_download_info # also triggers the download / extract function
  9868. # need to make sure this doesn't run for module build component
  9869. if [ "$B_SKIP_INSTALL" != 'true' ];then
  9870. if [ "$B_KERNEL_MODULE_ONLY" == 'true' ];then
  9871. # this will run by itself because it's just some tests and a module rebuild
  9872. # when it's done it will simply exit, no reboot or desktop start is required.
  9873. build_kernel_module_only 'direct'
  9874. else
  9875. # this is going to run either the fglrx or nvidia patch library file function
  9876. # must be after set_driver_install_version for output of data to smxi
  9877. # note this must occur before binary driver install
  9878. set_install_directory
  9879. check_patch_driver
  9880. fi
  9881. if [ "$B_TESTING_2" == 'true' ];then
  9882. exit 0 # this is just to test up to download/extract point
  9883. fi
  9884. fi
  9885. fi
  9886. # need to make sure this doesn't run for module build component
  9887. if [ "$B_SKIP_INSTALL" != 'true' ];then
  9888. x_start_stop_master stop
  9889.  
  9890. if [ "$B_SKIP_FUNCTION" != 'true' -a "$B_PRINT_VER" != 'true' -a "$B_NATIVE_DRIVER" != 'true' ];then
  9891. check_driver_install_tools
  9892. fi
  9893. prep_install
  9894. # for testing/debugging and alt driver/card download testing,
  9895. # I don't want to remove this stuff from system
  9896. if [ "$B_SKIP_FUNCTION" != 'true' ];then
  9897. preinstall_cleanup
  9898. fi
  9899.  
  9900. ## both have same function name, so no detection is required, we did it already
  9901. if [ "$B_USE_DISTRO_DRIVER" != 'true' ];then
  9902. run_driver_installer
  9903. post_installer_steps
  9904. if [ "$B_FGLRX_DEB_BUILDER" == 'true' ];then
  9905. install_fglrx_debs
  9906. fi
  9907. else
  9908. update_to_nonfree_sources
  9909. install_distro_drivers
  9910. fi
  9911. if [ "$B_SKIP_CONFIG" != 'true' ];then
  9912. update_xorg
  9913. fi
  9914. final_install_steps
  9915.  
  9916. x_start_stop_master start
  9917. fi
  9918.  
  9919. ###**EOF**###
Advertisement
Add Comment
Please, Sign In to add comment