Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2016
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 79.58 KB | None | 0 0
  1. #!/bin/sh
  2. #
  3. #Policy layer information:
  4. # Completion date: August 2006
  5. #
  6. # Copyright (c) 2008-2009, 2010, 2011, 2012 Advanced Micro Devices, Inc.
  7. #
  8. #Purpose: this script is called after .run archive is extracted, "--argument" is passed to this script
  9. # it handles "install," "listpkg," and "buildpkg <package name>"
  10. #Parameters:
  11. # Input:
  12. # $1 - driver version
  13. # $2 - operation to perform (--install, --listpkg, --buildpkg, --buildandinstallpkg)
  14. # $3 - <package name> if the operation is --buildpkg or --buildandinstallpkg
  15. # If the appropriate ati-packager.sh file has been updated to version 2 or higher
  16. # $3 can be --dryrun to simulate the operation
  17. # $4 - If the ati-packager.sh associated with <package name> has been updated to version 2
  18. # or higher $4 can be --dryrun
  19. # Return:
  20. # status - 1 if error occurs, 0 if not
  21. # External variables:
  22. # all variables listed in ExportVars; these are set by default_policy.sh
  23. # and possibly also by packages/*/ati-packager.sh if the current distro
  24. # matches (as defined by --iscurrentdistro) one of the distros in the
  25. # packages folder
  26.  
  27. checksh()
  28. {
  29. . ./check.sh $@
  30. }
  31.  
  32. Setup_with_CD_and_CDV_set()
  33. {
  34. WRITE_DEFAULT_POLICY="0"
  35. WriteNewInstPath
  36. . $TMP_INST_PATH_OVERRIDE
  37. ExportVars
  38. }
  39.  
  40.  
  41. CreateInstallLog()
  42. {
  43.  
  44. # Clean up the log directory and create the log file
  45.  
  46. # make sure we're not doing "rm -rf /"; that would be bad
  47. if [ "${ATI_UNINST}" = "/" ]
  48. then
  49. echo "Error: UNINST_PATH is / in create_log.sh; aborting" 1>&2
  50. echo "rm operation to prevent unwanted data loss" 1>&2
  51.  
  52. exit 1
  53. fi
  54.  
  55. # if ${UNINST_PATH} directory doesn't exist, create it
  56. if [ ! -d ${ATI_UNINST} ]
  57. then
  58. mkdir -p ${ATI_UNINST}
  59. fi
  60.  
  61. # if ${LOG_FILE} already exists, remove it
  62. if [ -e ${ATI_LOG}/fglrx-install.log ]
  63. then
  64. rm -f ${ATI_LOG}/fglrx-install.log
  65. fi
  66.  
  67. # create ${LOG_FILE}
  68. touch ${ATI_LOG}/fglrx-install.log
  69. }
  70.  
  71. #Installs the distribution specific packages if user accepts to install the package.
  72. InstallDistPackage()
  73. {
  74. pkg_list=`execIdentify 2>/dev/null`
  75.  
  76. checkDistroResult ${pkg_list}
  77. if [ $? -eq 0 ]
  78. then
  79. # Get distro/package values
  80. distro=`echo ${pkg_list} | cut -d"/" -f1`
  81. package=`echo ${pkg_list} | cut -d"/" -f2`
  82. if [ "${distro}" -a -d packages/${distro} ]
  83. then
  84. echo "Installing package for: ${distro}/${package}"
  85. packager=packages/${distro}/ati-packager.sh
  86. #if the distro is ubuntu take backup of the genearted packages as if th epackage installation is successfull, deletes the generated package
  87. if [ "${distro}" = "Ubuntu" ]; then
  88. InstallerRootDir="`pwd`" # Absolute path of the <installer root> directory
  89. AbsInstallerParentDir="`cd "${InstallerRootDir}"/.. 2>/dev/null && pwd`" # Absolute path to the installer parent directory
  90. DRV_RELEASE=`./ati-packager-helper.sh --version`
  91. PADDED_DRV_RELEASE=`printf '%5.3f' "$DRV_RELEASE" 2>/dev/null`
  92.  
  93. pacakge1="fglrx_${PADDED_DRV_RELEASE}-0ubuntu${REVISION}_${ARCH}.deb"
  94. echo "$pacakge1"
  95. pacakge2="fglrx-amdcccle_${PADDED_DRV_RELEASE}-0ubuntu${REVISION}_${ARCH}.deb"
  96. echo "$pacakge2"
  97. pacakge3="fglrx-dev_${PADDED_DRV_RELEASE}-0ubuntu${REVISION}_${ARCH}.deb"
  98. echo "$pacakge3"
  99. pacakge4="fglrx-core_${PADDED_DRV_RELEASE}-0ubuntu${REVISION}_${ARCH}.deb"
  100. echo "$pacakge4"
  101.  
  102. if [ -f "${AbsInstallerParentDir}/$pacakge1" ]; then
  103. cp -av pacakge1 pacakge1.bak 2>/dev/null
  104. fi
  105. if [ -f "${AbsInstallerParentDir}/$pacakge2" ]; then
  106. cp -av pacakge2 pacakge2.bak 2>/dev/null
  107. fi
  108. if [ -f "${AbsInstallerParentDir}/$pacakge3" ]; then
  109. cp -av pacakge3 pacakge3.bak 2>/dev/null
  110. fi
  111. if [ -f "${AbsInstallerParentDir}/$pacakge4" ]; then
  112. cp -av pacakge4 pacakge4.bak 2>/dev/null
  113. fi
  114. fi
  115.  
  116. #Install the generated package
  117. execInstallPkg ${packager} ${package}
  118. #if the ubuntu package installation is successfull, move the backup files to original
  119. if [ "${distro}" = "Ubuntu" ]; then
  120. mv pacakge1.bak pacakge1 2>/dev/null
  121. echo "$pacakge1"
  122. mv pacakge2.bak pacakge2 2>/dev/null
  123. echo "$pacakge2"
  124. mv pacakge3.bak pacakge3 2>/dev/null
  125. echo "$pacakge3"
  126. mv pacakge4.bak pacakge4 2>/dev/null
  127. echo "$pacakge4"
  128. fi
  129. fi
  130. fi
  131. }
  132.  
  133. RunLoki()
  134. {
  135. LOKI_USE=$1
  136. loki_installer_ncurses=0
  137.  
  138. if [ -z "${LC_CTYPE}" -a -z "${LANG}" ]; then
  139. LANG=".UTF-8"
  140. export LANG
  141. fi
  142.  
  143. if [ "${_ARCH}" = "x86_64" ]; then
  144. ARCH_DIR=x86_64
  145. else
  146. ARCH_DIR=x86
  147. fi
  148.  
  149.  
  150. if [ "${DISPLAY}" != "" ]
  151. then
  152. if [ "$LOKI_USE" = "installation" ]; then
  153. cp setup.data/install_gtk.xml setup.data/install.xml
  154. fi
  155.  
  156. LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:setup.data/bin/${ARCH_DIR}/glibc-2.1 ./setup.data/bin/${ARCH_DIR}/glibc-2.1/setup.gtk 2>/dev/null
  157. status=$?
  158.  
  159. if [ $status -ne 0 -a $status -ne 1 -a $status -ne 3 ]; then
  160. # Workaround: try text-based setup if graphical mode failed,
  161. # exclude that end user aborts the graphical setup manually,
  162. # return value for this is "3" for 64-bit OS, "1" for 32-bit OS
  163. loki_installer_ncurses=1
  164. else
  165.  
  166. #check if an error occurred
  167. if [ $status -ne 0 -a -f "${ATI_LOG}/fglrx-install.log" ]; then
  168.  
  169. error_line=`cat "${ATI_LOG}/fglrx-install.log" | grep "^\[Error\]"`
  170. if [ -n "$error_line" ]; then
  171. #error occurred
  172. status=1
  173. else
  174. #user cancelled, reset error code
  175. status=0
  176. fi
  177. else
  178. #ask reboot if installing from X and reboot required
  179. #check if reboot required
  180. if [ -f "${ATI_LOG}/fglrx-install.log" ]; then
  181. reboot_line=`cat "${ATI_LOG}/fglrx-install.log" | grep "^\[Reboot\]"`
  182. update_line=`cat "${ATI_LOG}/fglrx-install.log" | grep "update initramfs not required"`
  183. ZENITY_BIN=`which zenity 2> /dev/null`
  184. if [ -n "$reboot_line" -o "$update_line" ]; then
  185. if [ `id -u` -eq 0 -a -n "${ZENITY_BIN}" -a -x "${ZENITY_BIN}" ]; then
  186. ${ZENITY_BIN} --question --text "Actions taken by AMD Proprietary Driver requires a reboot. Would you like to reboot now? Other users may be logged on."
  187. ans=$?
  188.  
  189. # cases for user to select
  190. case $ans in
  191. 0)
  192. #set the reboot flag
  193. reboot=1
  194. ;;
  195. esac
  196. fi
  197. else
  198. #ask to install the generated distribution specific packge if the package is generated successfully
  199. package_line=`cat "${ATI_LOG}/fglrx-install.log" | grep "successfully generated" | cut -f2 -d" " | rev | cut -d/ -f1 | rev`
  200. if [ -n "$package_line" ]; then
  201. packageinstall=0
  202. if [ `id -u` -eq 0 -a -n "${ZENITY_BIN}" -a -x "${ZENITY_BIN}" ]; then
  203. ${ZENITY_BIN} --question --text "Do you want to install the generated package? Click Yes to install the package."
  204. ans=$?
  205.  
  206. # cases for user to select
  207. case $ans in
  208. 0)
  209. #set the install package flag
  210. packageinstall=1
  211. ;;
  212. esac
  213. fi
  214.  
  215. if [ ${packageinstall} -eq 1 ]
  216. then
  217. InstallDistPackage
  218. fi
  219.  
  220. fi
  221. fi
  222. fi
  223. fi
  224. fi
  225. else
  226. # DISPLAY not set, try ncurses instead
  227. loki_installer_ncurses=1
  228. fi
  229.  
  230. if [ ${loki_installer_ncurses} -eq 1 ]
  231. then
  232. if [ "$LOKI_USE" = "installation" ]; then
  233. cp setup.data/install_txt.xml setup.data/install.xml
  234. fi
  235.  
  236. ./setup.data/bin/${ARCH_DIR}/setup 2>/dev/null
  237. status=$?
  238.  
  239. # note for console installer if Loki is being used for installation
  240. if [ $status -eq 0 -a "$LOKI_USE" = "installation" ]; then
  241. echo "For further configuration of the driver, please run aticonfig from a terminal window or AMD CCC:LE from the Desktop Manager Menu."
  242.  
  243. #check if reboot required
  244. if [ -f "${ATI_LOG}/fglrx-install.log" ]; then
  245. reboot_line=`cat "${ATI_LOG}/fglrx-install.log" | grep "^\[Reboot\]"`
  246. if [ -n "$reboot_line" ]; then
  247. echo "System must be rebooted to avoid system instability and potential data loss."
  248. else
  249. #ask to install the generated distribution specific packge if the package is generated successfully
  250. package_line=`cat "${ATI_LOG}/fglrx-install.log" | grep "successfully generated" | cut -f2 -d" " | rev | cut -d/ -f1 | rev`
  251. if [ -n "$package_line" ]; then
  252. while true;do
  253. read -p "Do you want us to install the package generated?[Yes/No]" yn
  254. case $yn in
  255. [Yy]* ) InstallDistPackage; break;;
  256. [Nn]* ) exit ;;
  257. * ) echo "Please enter yes or no." ;;
  258. esac
  259. done
  260. fi
  261. fi
  262. fi
  263. fi
  264. echo "See ${ATI_LOG}/fglrx-install.log for installation details."
  265. fi
  266.  
  267. return $status
  268. }
  269.  
  270. ExportVars()
  271. {
  272. export X_VERSION
  273. export _ARCH
  274. export X_LAYOUT
  275. export ATI_XLIB_32
  276. export ATI_XLIB_64
  277. export ATI_3D_DRV_32
  278. export ATI_3D_DRV_64
  279. export ATI_XLIB
  280. export ATI_X_BIN
  281. export ATI_SBIN
  282. export ATI_KERN_MOD
  283. export ATI_2D_DRV
  284. export ATI_X_MODULE
  285. export ATI_DRM_LIB
  286. export ATI_CP_LNK
  287. export ATI_CP_KDE3_LNK
  288. export ATI_GL_INCLUDE
  289. export ATI_ATIGL_INCLUDE
  290. export ATI_CP_KDE_LNK
  291. export ATI_DOC
  292. export ATI_CP_DOC
  293. export ATI_CP_GNOME_LNK
  294. export ATI_ICON
  295. export ATI_MAN
  296. export ATI_SRC
  297. export ATI_X11_INCLUDE
  298. export ATI_CP_BIN
  299. export ATI_CP_I18N
  300. export ATI_LOG
  301. export ATI_CONFIG
  302. export OPENCL_CONFIG
  303. export OPENCL_LIB_32
  304. export OPENCL_LIB_64
  305. export OPENCL_BIN
  306. export ATI_SECURITY_CFG
  307. export ATI_UNINST
  308. export ATI_PX_SUPPORT
  309. export ATI_XLIB_EXT_32
  310. export ATI_XLIB_EXT_64
  311.  
  312. }
  313.  
  314. CleanTmpInstPath()
  315. {
  316. rm -f $TMP_INST_PATH_DEFAULT
  317. rm -f $TMP_INST_PATH_OVERRIDE
  318. }
  319.  
  320. WriteNewInstPath()
  321. {
  322. if [ "$WRITE_DEFAULT_POLICY" = "1" ]
  323. then
  324. FINAL_FILENAME="inst_path_default"
  325. OUT_FILE=$TMP_INST_PATH_DEFAULT
  326. POLICY_SCRIPT="./default_policy.sh"
  327. DISTRO_IN_INST_PATH="Default policy"
  328. else
  329. FINAL_FILENAME="inst_path_override"
  330. OUT_FILE=$TMP_INST_PATH_OVERRIDE
  331. POLICY_SCRIPT="packages/${CURRENT_DISTRO}/ati-packager.sh"
  332. DISTRO_IN_INST_PATH="Distribution: ${CURRENT_DISTRO}"
  333. fi
  334.  
  335. POLICY_FIRST_LINE=`${POLICY_SCRIPT} --printpolicy \
  336. "${CURRENT_DISTRO_VERSION}" | head -n 1`
  337.  
  338. if [ "--printpolicy: unsupported option passed by ati-installer.sh" = "$POLICY_FIRST_LINE" ]
  339. then
  340. echo
  341. echo "Error: ${POLICY_SCRIPT} supports --iscurrentdistro but not"
  342. echo "--printpolicy; the script must support either both or none of"
  343. echo "these options; check if your distribution has an update for"
  344. echo "these drivers"
  345. echo
  346.  
  347. CleanTmpInstPath
  348.  
  349. exit 1
  350. elif [ "`echo $POLICY_FIRST_LINE | grep "error:" `" != "" ]
  351. then
  352.  
  353. echo
  354. echo "$POLICY_FIRST_LINE (${CURRENT_DISTRO_VERSION})"
  355. echo "Installation will not proceed."
  356. echo
  357.  
  358. CleanTmpInstPath
  359. exit 1
  360. fi
  361.  
  362. TIMESTAMP=`date`
  363.  
  364. cat - > $OUT_FILE << INST_PATH_HEADER_END
  365. # /etc/ati/${FINAL_FILENAME}
  366. #
  367. # Created ${TIMESTAMP} with the following configuration:
  368. #
  369. # Driver version: ${DRV_RELEASE}
  370. # ${DISTRO_IN_INST_PATH}
  371. # Policy version: ${CURRENT_DISTRO_VERSION}
  372.  
  373. INST_PATH_HEADER_END
  374.  
  375. ${POLICY_SCRIPT} --printpolicy ${CURRENT_DISTRO_VERSION} >> $OUT_FILE
  376. }
  377.  
  378. GetDefaultPolicyVersion()
  379. {
  380. GET_DEFAULT_POLICY=1
  381. MULTIPLE_MATCHES=0
  382.  
  383. GetDistroPolicy
  384.  
  385. RETURN_CODE=$?
  386.  
  387. if [ 0 -eq $RETURN_CODE ]
  388. then
  389. return 0
  390. elif [ 64 -eq $RETURN_CODE ]
  391. then
  392. # 64 means distro supports --printversion but the current
  393. # distro does not match
  394.  
  395. echo
  396. echo "Error: The default policy script is unable to provide a policy"
  397. echo "for the current configuration; the default policy must be"
  398. echo "updated to support the current configuration before installation"
  399. echo "can continue"
  400. echo
  401.  
  402. CleanTmpInstPath
  403.  
  404. exit 1
  405. elif [ 65 -eq $RETURN_CODE ]
  406. then
  407. # 65 means distro does not support --printversion
  408.  
  409. echo
  410. echo "Error: The default policy script does not support --printversion;"
  411. echo "the default policy script must support --printversion for the"
  412. echo "installation to continue"
  413. echo
  414.  
  415. CleanTmpInstPath
  416.  
  417. exit 1
  418. else
  419. echo
  420. echo "Unexpected error code returned by GetDistroPolicy for default"
  421. echo "policy query; error code returned was $RETURN_CODE"
  422. echo
  423.  
  424. CleanTmpInstPath
  425.  
  426. exit 1
  427. fi
  428. }
  429.  
  430. #GetVersionForPolicy() ${1}=distro name
  431. #This function takes a distribution name and calls --identify on that distro's ati-packager.sh
  432. #it takes the results and echo's a response as expected by the rest of the policy interpretation code
  433. GetVersionForPolicy()
  434. {
  435. distro=${1}
  436. output=`packages/${distro}/ati-packager.sh --identify | tail -n 1`
  437. if [ "${output}" = "--identify: unsupported option passed by ati-installer.sh" ]
  438. then
  439. echo ${output}
  440. else
  441. for package in `packages/$distro/ati-packager.sh --get-supported`
  442. do
  443. packages/$distro/ati-packager.sh --identify ${package}
  444. retval=$?
  445. if [ ${retval} -eq 0 ]
  446. then
  447. echo "distro query result: yes, version: ${package}"
  448. return 0
  449. fi
  450. done
  451. echo "distro query result: no"
  452. fi
  453. }
  454.  
  455. #GetDistroPolicy()
  456. #Decides whether to use a custom policy or the default
  457. GetDistroPolicy()
  458. {
  459. if [ -z "$GET_DEFAULT_POLICY" -o "1" != "$GET_DEFAULT_POLICY" ]
  460. then
  461. if [ "`grep '\-\-printpolicy' ./packages/$distro/ati-packager.sh`" != "" ]
  462. then
  463. SCRIPT_NAME="packages/$distro/ati-packager.sh"
  464. PARAM_NAME="--identify"
  465. output=`GetVersionForPolicy $distro`
  466. else
  467. output="--identify: unsupported option passed by ati-installer.sh"
  468. fi
  469. else
  470. SCRIPT_NAME="./default_policy.sh"
  471. PARAM_NAME="--printversion"
  472. output=`./default_policy.sh --printversion`
  473. fi
  474.  
  475. header=`echo $output | cut -d\ -f1-3`
  476. result=`echo $output | cut -d\ -f4`
  477.  
  478. # the current distro is $distro, according to $distro/ati-packager.sh
  479. if [ "distro query result:" = "$header" -a "yes," = "$result" ]
  480. then
  481. # $version is the X in "distro query result: yes, version: X"
  482. version=`echo $output | cut -d\ -f6-`
  483. if [ -z "$version" ]
  484. then
  485. echo
  486. echo "Error in packages/$distro/ati-packager.sh: empty version"
  487. echo "string found; positive match for distribution must be"
  488. echo "printed in the following form:"
  489. echo
  490. echo "distro query result: yes, version: X"
  491. echo
  492. echo "where X is a string with no spaces"
  493. echo
  494.  
  495. CleanTmpInstPath
  496.  
  497. exit 1
  498. fi
  499.  
  500. if [ 0 -eq $MULTIPLE_MATCHES ]
  501. then
  502. if [ -z $CURRENT_DISTRO ]
  503. then
  504. CURRENT_DISTRO_VERSION=$version
  505.  
  506. if [ -z "$GET_DEFAULT_POLICY" -o "1" != "$GET_DEFAULT_POLICY" ]
  507. then
  508. CURRENT_DISTRO=$distro
  509. NO_OVERRIDE_POLICY=0
  510. else
  511. CURRENT_DISTRO=""
  512. NO_OVERRIDE_POLICY=1
  513. fi
  514.  
  515. return 0
  516. else
  517. MULTIPLE_MATCHES=1
  518.  
  519. # backup existing setup.glade file
  520. mv setup.data/setup.glade setup.data/setup.glade.bak
  521. mv setup.data/pre-setup.glade setup.data/setup.glade
  522.  
  523. # make source and destination directories for installation
  524. mkdir tmp
  525. MM_SRC=`mktemp -d tmp/mm_src.XXXXXX`
  526. MM_DST=`mktemp -d -t mm_dst.XXXXXX`
  527.  
  528. # output the second last distro/version found to a file
  529. cat - > ${MM_SRC}/${CURRENT_DISTRO} << FILE_END
  530. CURRENT_DISTRO=${CURRENT_DISTRO}
  531. CURRENT_DISTRO_VERSION=${CURRENT_DISTRO_VERSION}
  532. FILE_END
  533.  
  534. # output the last distro/version found to a file
  535. cat - > ${MM_SRC}/${distro} << FILE_END
  536. CURRENT_DISTRO=${distro}
  537. CURRENT_DISTRO_VERSION=${version}
  538. FILE_END
  539.  
  540. # print header for Loki's XML file
  541. cat - > setup.data/setup.xml << SETUP_XML_END
  542. <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  543. <install
  544. desc="Distribution selection"
  545. version="${DRV_RELEASE}"
  546. splash="atilogo.xpm"
  547. path="${MM_DST}"
  548. nopromptoverwrite="yes"
  549. nouninstall="yes"
  550. superuser="yes">
  551.  
  552. <exclusive>
  553. <option>
  554. ${CURRENT_DISTRO}, version: ${CURRENT_DISTRO_VERSION}
  555. <files path=".">${MM_SRC}/${CURRENT_DISTRO}</files>
  556. </option>
  557. <option>
  558. ${distro}, version: ${version}
  559. <files path=".">${MM_SRC}/${distro}</files>
  560. </option>
  561. SETUP_XML_END
  562.  
  563. # 66 means that multiple matches have been found
  564. return 66
  565. fi
  566. else
  567. # output the last distro/version found to a file
  568. cat - > ${MM_SRC}/${distro} << FILE_END
  569. CURRENT_DISTRO=${distro}
  570. CURRENT_DISTRO_VERSION=${version}
  571. FILE_END
  572.  
  573. # add the corresponding option to Loki setup
  574. cat - >> setup.data/setup.xml << SETUP_XML_END
  575. <option>
  576. ${distro}, version: ${version}
  577. <files path=".">${MM_SRC}/${distro}</files>
  578. </option>
  579. SETUP_XML_END
  580.  
  581. # 66 means that multiple matches have been found
  582. return 66
  583. fi
  584. elif [ "distro query result:" = "$header" -a "no" = "$result" ]
  585. then
  586. # 64 means distro supports --identify but the current distro
  587. # does not match
  588.  
  589. # the return value is discarded when GetDistroPolicy is called by
  590. # DetectDistro, but it is used when GetDistroPolicy is called after
  591. # a user defines CURRENT_DISTRO themselves to determine whether their
  592. # selection is valid
  593.  
  594. return 64
  595. elif [ "--identify: unsupported option passed by ati-installer.sh" = "$output" ]
  596. then
  597. # 65 means distro does not support --identify
  598.  
  599. # the return value is discarded when GetDistroPolicy is called by
  600. # DetectDistro, but it is used when GetDistroPolicy is called after
  601. # a user defines CURRENT_DISTRO themselves to determine whether their
  602. # selection is valid
  603.  
  604. return 65
  605. else
  606. echo
  607. echo "Error in $SCRIPT_NAME: unexpected output"
  608. echo "received from script on $PARAM_NAME call; output must"
  609. echo "be of the following form:"
  610. echo
  611. echo "distro query result: no OR"
  612. echo "distro query result: yes, version: X OR"
  613. echo "$PARAM_NAME: unsupported option passed by ati-installer.sh"
  614. echo
  615.  
  616. CleanTmpInstPath
  617.  
  618. exit 1
  619. fi
  620. }
  621.  
  622. # NOTE: if DetectDistro is used, its return value MUST be checked; if it is 64,
  623. # the handling will be much different than if it is 0
  624. DetectDistro()
  625. {
  626. GET_DEFAULT_POLICY=0
  627. NO_OVERRIDE_POLICY=1
  628. CURRENT_DISTRO=""
  629. MULTIPLE_MATCHES=0
  630.  
  631. for dir in `find packages -mindepth 1 -maxdepth 1 -type d -print`
  632. do
  633. distro=`basename $dir`
  634.  
  635. GetDistroPolicy
  636. done
  637.  
  638. if [ 1 -eq $MULTIPLE_MATCHES ]
  639. then
  640. # print Loki XML footer (the rest of the file has been printed)
  641. cat - >> setup.data/setup.xml << SETUP_XML_END
  642. </exclusive>
  643.  
  644. </install>
  645. SETUP_XML_END
  646.  
  647. # run Loki to get the user's distribution selection
  648. RunLoki
  649.  
  650. # there is now one file in MM_DST, the file that contains the
  651. # CURRENT_DISTRO and CURRENT_DISTRO_VERSION that the user selected;
  652. # we find it...
  653. SELECTION_FILE=`ls -1 ${MM_DST} | head -n 1`
  654.  
  655. # ...and source it, but only if SELECTION_FILE is non-empty
  656. if [ -n "${SELECTION_FILE}" ]
  657. then
  658. . ${MM_DST}/${SELECTION_FILE}
  659. fi
  660.  
  661. # remove Loki's XML file
  662. rm -f setup.data/setup.xml
  663.  
  664. # remove the temporary source and destination folders
  665. rm -rf ${MM_SRC}
  666. rm -rf ${MM_DST}
  667. rmdir tmp
  668.  
  669. # move the glade files back to their original locations
  670. mv setup.data/setup.glade setup.data/pre-setup.glade
  671. mv setup.data/setup.glade.bak setup.data/setup.glade
  672.  
  673. # cleanup inst_path_override (will be re-created later)
  674. echo -n > ${TMP_INST_PATH_OVERRIDE}
  675.  
  676. # if SELECTION_FILE is empty, user probably cancelled the Loki installer
  677. # so we will silently exit
  678. if [ -z "${SELECTION_FILE}" ]
  679. then
  680. CleanTmpInstPath
  681. exit 0
  682. fi
  683.  
  684. # return 64 to indicate that multiple matches were found
  685. return 64
  686. fi
  687.  
  688. # we can make the following assertions at this point:
  689. # - if no matches were found, CURRENT_DISTRO="", NO_OVERRIDE_POLICY=1, and
  690. # CURRENT_DISTRO_VERSION=Y for some non-null version Y
  691. # - if one match X was found with non-null version Y, CURRENT_DISTRO=X,
  692. # NO_OVERRIDE_POLICY=0, and CURRENT_DISTRO_VERSION=Y
  693. # - if more than one match was found, the script has already quit
  694. # - if any matches were found with null version, the script has already quit
  695. }
  696.  
  697.  
  698.  
  699. printHelp()
  700. {
  701. #Commented arguments in this list are availible to distro package maintainers to implement but are not exposed to end users
  702. echo "This script supports the following arguments:"
  703. echo "--help : print help messages"
  704. echo "--listpkg : print out a list of generatable packages"
  705. echo "--buildpkg [package] [--dryrun] : if generatable, the package will be created"
  706. echo "--buildpkg package --NoXServer : if generatable, the package will be created without XServer"
  707. #echo "--installpkg <package> [--force] : if already generated, the package will be installed"
  708. echo "--buildandinstallpkg [package] [--dryrun] [--force] : if generatable, the package will be creadted and installed"
  709. #echo "--getAPIVersion <distro> : returns the API version number of given distro"
  710. echo "--install : install the driver"
  711. }
  712.  
  713. #execIdentify
  714. #cycles through all supported versions of all distros and returns a list of which think they are running currently
  715. execIdentify()
  716. {
  717. pkg_list=""
  718. for distro in `ls packages`
  719. do
  720. packager=packages/${distro}/ati-packager.sh
  721. if [ -e ${packager} ]
  722. then
  723. execGetAPIVersion ${packager}
  724. if [ $? -gt 1 ]
  725. then
  726. for package in `./${packager} --get-supported`
  727. do
  728. ./${packager} --identify ${package}
  729. if [ $? -eq 0 ]
  730. then
  731. pkg_list="${pkg_list} ${distro}/${package}"
  732. fi
  733. done
  734. fi
  735. fi
  736. done
  737.  
  738. echo ${pkg_list}
  739. return 0
  740. }
  741.  
  742. #checkDistroResult() ${1}=pkg_list
  743. #takes a list of possible packages returns if there is exactly 1 package in the list or else ERROR
  744. checkDistroResult()
  745. {
  746. found=`echo ${1} | wc -w`
  747. if [ ${found} -eq 0 ]
  748. then
  749. echo "Error: Packaging scripts failed to identify current distro/version. Please provide a distro/version from --listpkg as a parameter"
  750. return ${ATI_INSTALLER_ERR_FIND_DIST}
  751. elif [ ${found} -eq 1 ]
  752. then
  753. return 0
  754. else
  755. echo "Error: Unable to identify currently running distribution. Please provide one of the following as a parameter: ${1}"
  756. return ${ATI_INSTALLER_ERR_FIND_MULTI}
  757. fi
  758. }
  759. #execGetAPIVersion ${1}=packages/<distro>/ati-packager.sh
  760. #returns the API version of ${1}
  761. execGetAPIVersion()
  762. {
  763. if [ -e ${1} ]
  764. then
  765. if [ "`grep getAPIVersion ./${1}`" != "" ]
  766. then
  767. ./${1} --getAPIVersion
  768. return $?
  769. else
  770. return 1
  771. fi
  772. else
  773. return 1
  774. fi
  775. }
  776.  
  777.  
  778. #execGetMaintainer ${1}=packages/<distro>/ati-packager.sh
  779. #returns the maintainer of ${1}
  780. execGetMaintainer()
  781. {
  782. if [ -e ${1} ]; then
  783.  
  784. if [ -n "`grep '\-\-get\-maintainer' ${1}`" ]; then
  785.  
  786. newMaintainer=`./${packager} --get-maintainer 2> /dev/null`
  787. if [ $? -eq 0 -a -n "${newMaintainer}" ]; then
  788. echo ${newMaintainer}
  789. return 0
  790. fi
  791. fi
  792.  
  793. fi
  794.  
  795. return 1
  796. }
  797.  
  798.  
  799. #execVerifyVersion ${1}=packages/<distro>/ati-packager.sh ${2}=distro version
  800. #verifies that ${1} is an existing file
  801. #checks if the supplied ${2} is in the list of supported Distro version by file ${1}
  802. execVerifyVersion()
  803. {
  804. if [ -e ${1} ]
  805. then
  806. for version in `./${1} --get-supported`
  807. do
  808. if [ "${2}" = ${version} ]
  809. then
  810. return 0
  811. fi
  812. done
  813. echo "Error: Distro Version entered incorrectly or not supported, use --listpkg to identify valid distro versions"
  814. return ${ATI_INSTALLER_ERR_VERS}
  815. else
  816. return ${ATI_INSTALLER_ERR_FILE}
  817. fi
  818. }
  819.  
  820. #execBuildPrep ${1}=packages/<distro>/ati-packager.sh ${2}=distro version ${3}="--dryrun" or ""
  821. #uses the supplied ati-packager.sh to check requirements for building the package are met.
  822. #verifies ${1} and ${2}; ${3} is verified by calling function
  823. execBuildPrep()
  824. {
  825. if [ -e ${1} ]
  826. then
  827. execVerifyVersion ${1} ${2}
  828. if [ $? -eq 0 ]
  829. then
  830. ./${1} --buildprep ${2} ${3}
  831. return $?
  832. else
  833. return ${ATI_INSTALLER_ERR_VERS}
  834. fi
  835. else
  836. echo "Error: Cannot prep the build of the package - ${1} is missing"
  837. return ${ATI_INSTALLER_ERR_FILE}
  838. fi
  839.  
  840. }
  841. #execBuildPkg ${1}=packages/<distro>/ati-packager.sh ${2}=distro version
  842. #goes to packages/distro/ati-packager.sh to generate the requested package
  843. #verifies both parameters
  844. execBuildPkg()
  845. {
  846.  
  847. if [ -e ${1} ]
  848. then
  849. execVerifyVersion ${1} ${2}
  850. if [ $? -eq 0 ]
  851. then
  852. ./${1} --buildpkg ${2}
  853. return $?
  854. else
  855. return ${ATI_INSTALLER_ERR_VERS}
  856. fi
  857. else
  858. echo "Error: Cannot build the package - ${1} is missing"
  859. return ${ATI_INSTALLER_ERR_FILE}
  860. fi
  861. }
  862.  
  863. #execInstallPrep ${1}=packages/<distro>/ati-packager.sh ${2}=distro version ${3}="--dryrun" or ""
  864. #uses the supplied ati-packager.sh to requirements for driver operation are met.
  865. #verifies ${1} and ${2}; ${3} is verified by execBuildAndInstall
  866. execInstallPrep()
  867. {
  868. if [ -e ${1} ]
  869. then
  870. execVerifyVersion ${1} ${2}
  871. if [ $? -eq 0 ]
  872. then
  873. ./${1} --installprep ${2} ${3}
  874. return $?
  875. else
  876. return ${ATI_INSTALLER_ERR_VERS}
  877. fi
  878. else
  879. echo "Error: Cannot prep the installation of the package - ${1} is missing"
  880. return ${ATI_INSTALLER_ERR_FILE}
  881. fi
  882. }
  883.  
  884. #execInstallPkg ${1}=packages/<distro>/ati-packager.sh ${2}=distro version
  885. #uses the supplied ati-packager.sh to install the available package
  886. #verifies both ${1} and ${2}
  887. execInstallPkg()
  888. {
  889. if [ -e ${1} ]
  890. then
  891. execVerifyVersion ${1} ${2}
  892. if [ $? -eq 0 ]
  893. then
  894. ./${1} --installpkg ${2}
  895. return $?
  896. else
  897. return ${ATI_INSTALLER_ERR_VERS}
  898. fi
  899. else
  900. echo "Error: Cannot install the package - ${1} is missing"
  901. return ${ATI_INSTALLER_ERR_FILE}
  902. fi
  903. }
  904.  
  905. #execBuildAndInstall ${1}=packages/<distro>/ati-packager.sh ${2}=distro version ${3}=--dryrun
  906. #If buildandinstall option --dryrun is provided it is error checked here.
  907. execBuildAndInstall()
  908. {
  909. if [ "${3}" = "" ] || [ "${3}" = "--dryrun" ]
  910. then
  911. execBuildPrep ${1} ${2} ${3}
  912. buildPrepResult=$?
  913. if [ ${buildPrepResult} -ne 0 ]
  914. then
  915. return ${buildPrepResult}
  916. fi
  917.  
  918. if [ "${3}" = "" ]
  919. then
  920. execBuildPkg ${1} ${2}
  921. buildPkgResult=$?
  922. if [ ${buildPkgResult} -ne 0 ]
  923. then
  924. return ${buildPkgResult}
  925. fi
  926. fi
  927.  
  928. execInstallPrep ${1} ${2} ${3}
  929. instPrepResult=$?
  930. if [ ${instPrepResult} -ne 0 ]
  931. then
  932. return ${instPrepResult}
  933. fi
  934.  
  935. if [ "${3}" = "" ]
  936. then
  937. execInstallPkg ${1} ${2}
  938. instPkgResult=$?
  939. if [ ${instPkgResult} -ne 0 ]
  940. then
  941. return ${instPkgResult}
  942. fi
  943. fi
  944.  
  945. return 0
  946. else
  947. echo "Error: Unrecognized build option parameter ${3}"
  948. printHelp
  949. return ${ATI_INSTALLER_ERR_BUILDOP}
  950. fi
  951. }
  952.  
  953. # Script execution starts here
  954.  
  955. alias echo=/bin/echo
  956.  
  957. # ensure the working directory is where the script resides
  958. scriptdir=`dirname "$0"`
  959. curdir=`pwd`
  960. if [ -n "$scriptdir" -a "$scriptdir" != "$curdir" ]; then
  961. cd "$scriptdir"
  962. fi
  963.  
  964. echo -e "====================================================================="
  965. echo -e "\033[31m AMD Proprietary Driver Installer/Packager \033[0m"
  966. echo -e "====================================================================="
  967.  
  968. #Detect headless configuration
  969. GetHeadLessConfig() {
  970.  
  971. devid=`lspci -vmnn -d 1002:* | awk 'BEGIN { FS="\n";RS=""} {if(($2 ~ /VGA/) || ($2 ~ /Display/) && $3 ~ /AMD/) print $4}' | sed 's/.*\[\([^]]*\)\].*/\1/g' | sort | uniq`
  972. isDevFound=""
  973. retval=0
  974. for did in $devid
  975. do
  976. isdevidfound=`cat headlessDID.config | egrep -i "^$did" | cut -f2 -d':'`
  977. if [ -n "$isdevidfound" ]
  978. then
  979. isDevFound=`lspci -vmnn -d 1002:$did | awk 'BEGIN { FS="\n";RS=""} {if(($2 ~ /VGA/) || ($2 ~ /Display/) && $3 ~ /AMD/) print $6}' | sed 's/.*\[\([^]]*\)\].*/\1/g' | sort | uniq`
  980. for sdid in $isDevFound
  981. do
  982. if [ -n "$isDevFound" ] && [ "`echo "$isdevidfound" | egrep -i "^$sdid$"`" ]
  983. then
  984. retval=1
  985. break
  986. fi
  987. done
  988. fi
  989. done
  990. #echo "$retval"
  991. return "$retval"
  992. }
  993.  
  994. # Create installer symlinks
  995.  
  996. # Custom package directory
  997. if [ -z ${ATI_CUSTOM_PKG_DIR} ]; then
  998. ATI_CUSTOM_PKG_DIR=/etc/ati/custom-package
  999. fi
  1000. if [ -d ${ATI_CUSTOM_PKG_DIR} ]; then
  1001. if [ -x "${ATI_CUSTOM_PKG_DIR}/ati-packager.sh" ]; then
  1002.  
  1003. # this used to be "ln -s ${ATI_CUSTOM_PKG_DIR} packages/custom-package";
  1004. # it has been changed because symlinks don't behave precisely the same
  1005. # way as regular directories, which means that copying an arbitrary
  1006. # packages/X folder to ${ATI_CUSTOMER_PKG_DIR} and running the
  1007. # installer using the symlink method might not work; for example,
  1008. # "ls -l packages/custom-package/.." should be equivalent to
  1009. # "ls -l packages", but if the above symlink method is used, it is
  1010. # actually equivalent to "ls -l ${ATI_CUSTOM_PKG_DIR}/.."
  1011.  
  1012. mkdir packages/custom-package
  1013. cp -rp ${ATI_CUSTOM_PKG_DIR}/* packages/custom-package
  1014. else
  1015. echo "Warning: ${ATI_CUSTOM_PKG_DIR}/ati-packager.sh is missing or not a script."
  1016. fi
  1017. fi
  1018.  
  1019. declare tester_var=7 2>/dev/null #testing if declare is available
  1020.  
  1021. if [ $? -eq 0 ]
  1022. then
  1023. #set error code variables
  1024. declare -r -i ATI_INSTALLER_ERR_PREP=1 #Error: Could not complete prep for build
  1025. declare -r -i ATI_INSTALLER_ERR_FILE=2 #Error: Cannot build the package - ${<path>/ati-packager.sh} is missing
  1026. declare -r -i ATI_INSTALLER_ERR_DIST=3 #Error: The distribution ${distro} is not supported
  1027. declare -r -i ATI_INSTALLER_ERR_FIND_DIST=4 #Error: Packaging scripts failed to identify current distro/version. Please provide a distro/version from --listpkg as a parameter
  1028. declare -r -i ATI_INSTALLER_ERR_FIND_MULTI=5 #Error: Unable to identify currently running kernel. Please provide one of the following as a parameter: ${pkg_list}
  1029. declare -r -i ATI_INSTALLER_ERR_VERS=6 #Error: Distro Version entered incorrectly or not supported, use --listpkg to identify valid distro versions
  1030. declare -r -i ATI_INSTALLER_ERR_BUILDOP=7 #Error: Unrecognized build option parameter
  1031. declare -r -i ATI_INSTALLER_ERR_API=8 #Error: Build Option ${1} not supported currently by packager
  1032. declare -r -i ATI_INSTALLER_ERR_PREV_INSTALL=9 #Error: Previous installation detected and must be uninstalled first
  1033. declare -r -i ATI_INSTALLER_ERR_SUPERUSER=10 #Error: User is missing superuser privileges
  1034.  
  1035. else
  1036. ATI_INSTALLER_ERR_PREP=1 #declare unavailable so cant produce static error variables.
  1037. ATI_INSTALLER_ERR_FILE=2
  1038. ATI_INSTALLER_ERR_DIST=3
  1039. ATI_INSTALLER_ERR_FIND_DIST=4
  1040. ATI_INSTALLER_ERR_FIND_MULTI=5
  1041. ATI_INSTALLER_ERR_VERS=6
  1042. ATI_INSTALLER_ERR_BUILDOP=7
  1043. ATI_INSTALLER_ERR_API=8
  1044. ATI_INSTALLER_ERR_PREV_INSTALL=9
  1045. ATI_INSTALLER_ERR_SUPERUSER=10
  1046. fi
  1047. export ATI_INSTALLER_ERR_PREP
  1048. export ATI_INSTALLER_ERR_FILE
  1049. export ATI_INSTALLER_ERR_DIST
  1050. export ATI_INSTALLER_ERR_FIND_DIST
  1051. export ATI_INSTALLER_ERR_FIND_MULTI
  1052. export ATI_INSTALLER_ERR_VERS
  1053. export ATI_INSTALLER_ERR_BUILDOP
  1054. export ATI_INSTALLER_ERR_API
  1055. export ATI_INSTALLER_ERR_PREV_INSTALL
  1056. export ATI_INSTALLER_ERR_SUPERUSER
  1057.  
  1058. DRV_RELEASE=$1
  1059. ACTION=$2
  1060.  
  1061. # Process input command
  1062. reboot=0
  1063. status=0
  1064. case "${ACTION}" in
  1065.  
  1066. --install)
  1067. SIGNATURE=$3
  1068. if [ "`echo $@ | grep '\-\-force'`" != "" ]; then
  1069. FORCE_ATI_UNINSTALL=y
  1070. export FORCE_ATI_UNINSTALL
  1071. fi
  1072.  
  1073. if [ ! -z "${X_VERSION}" ]
  1074. then
  1075. export X_VERSION
  1076. USER_SPECIFIED_X_VERSION=1
  1077. SAVED_X_VERSION=${X_VERSION}
  1078. fi
  1079.  
  1080. if [ -z "$KERNEL_PATH" ]; then
  1081. kernel_release=`uname -r`
  1082. kernel_release_major=${kernel_release%%.*}
  1083. kernel_release_rest=${kernel_release#*.}
  1084. kernel_release_minor=${kernel_release_rest%%-*}
  1085. kernel_release_minor=${kernel_release_minor%%.*}
  1086.  
  1087. if [ "$kernel_release_major" -lt 2 -o \
  1088. \( "$kernel_release_major" -eq 2 -a "$kernel_release_minor" -lt 6 \) ];
  1089. then
  1090. echo "Your kernel version $kernel_release is not supported by this driver release."
  1091. echo "Only 2.6.0 and newer kernels are supported."
  1092. echo "If you want to install for a different kernel than the one currently running,"
  1093. echo "please use the KERNEL_PATH environment variable to override, e.g.:"
  1094. echo "export KERNEL_PATH=/lib/modules/2.6.22/build"
  1095.  
  1096. CleanTmpInstPath
  1097. exit 1
  1098. fi
  1099. fi
  1100.  
  1101. TMP_INST_PATH_DEFAULT=`mktemp -t inst_path_default.XXXXXX`
  1102. TMP_INST_PATH_OVERRIDE=`mktemp -t inst_path_override.XXXXXX`
  1103. export TMP_INST_PATH_DEFAULT
  1104. export TMP_INST_PATH_OVERRIDE
  1105.  
  1106.  
  1107. if [ -n "${INST_PATH_DEFAULT_FILE}" -o -n "${INST_PATH_OVERRIDE_FILE}" ]
  1108. then
  1109. if ! [ -n "${INST_PATH_DEFAULT_FILE}" -a \
  1110. -n "${INST_PATH_OVERRIDE_FILE}" ]
  1111. then
  1112. echo
  1113. echo "When the variable INST_PATH_DEFAULT_FILE or"
  1114. echo "INST_PATH_OVERRIDE_FILE is set, both variables must be set;"
  1115. echo "since only one of these was set, installation cannot continue"
  1116. echo
  1117.  
  1118. CleanTmpInstPath
  1119.  
  1120. exit 1
  1121. fi
  1122.  
  1123. cp -p ${INST_PATH_DEFAULT_FILE} ${TMP_INST_PATH_DEFAULT}
  1124. RETVAL_DEFAULT=$?
  1125. cp -p ${INST_PATH_OVERRIDE_FILE} ${TMP_INST_PATH_OVERRIDE}
  1126. RETVAL_OVERRIDE=$?
  1127.  
  1128. if [ ${RETVAL_DEFAULT} -ne 0 -o ${RETVAL_OVERRIDE} -ne 0 ]
  1129. then
  1130. echo
  1131. echo "Copying INST_PATH_DEFAULT_FILE or INST_PATH_OVERRIDE_FILE"
  1132. echo "was unsuccessful; check the permissions on the files to"
  1133. echo "ensure root can read them and then restart the installer"
  1134. echo
  1135.  
  1136. CleanTmpInstPath
  1137.  
  1138. exit 1
  1139. fi
  1140.  
  1141. . $TMP_INST_PATH_DEFAULT
  1142. . $TMP_INST_PATH_OVERRIDE
  1143. ExportVars
  1144.  
  1145. echo "NOTE: Using INST_PATH_DEFAULT_FILE and INST_PATH_OVERRIDE_FILE"
  1146.  
  1147. # file overrides not set so we determine which distribution we're running on
  1148. elif [ "$USE_DEFAULT_POLICY" = "1" ]
  1149. then
  1150. if [ ! -z "$CURRENT_DISTRO" ]
  1151. then
  1152. echo
  1153. echo "Error: You can't use the default policy and use a specific"
  1154. echo "distribution's policy at the same time; unset CURRENT_DISTRO"
  1155. echo "or USE_DEFAULT_POLICY and run the installer again"
  1156. echo
  1157.  
  1158. CleanTmpInstPath
  1159.  
  1160. exit 1
  1161. fi
  1162.  
  1163. # print warning message about not using override to inst_path_override
  1164. TIMESTAMP=`date`
  1165. cat - > $TMP_INST_PATH_OVERRIDE << INST_PATH_HEADER_END
  1166. # /etc/ati/inst_path_override
  1167. #
  1168. # Created ${TIMESTAMP} with the following configuration:
  1169. #
  1170. # Driver version: ${DRV_RELEASE}
  1171. # No override policy used because USE_DEFAULT_POLICY was set to 1
  1172.  
  1173. INST_PATH_HEADER_END
  1174.  
  1175. # if the user has not set CURRENT_DISTRO_VERSION, then we set it; if
  1176. # the user has set CURRENT_DISTRO_VERSION, then presumably they know
  1177. # what they're doing (since they also set USE_DEFAULT_POLICY if they
  1178. # reach this point in the code) so no validation is done; validation
  1179. # can wait until WriteNewInstPath below, which preforms validation
  1180.  
  1181. if [ -z $CURRENT_DISTRO_VERSION ]
  1182. then
  1183. # get version of default policy to use
  1184. GetDefaultPolicyVersion
  1185.  
  1186. # assert: CURRENT_DISTRO_VERSION is set; the above exits on error
  1187. fi
  1188.  
  1189. # print default policy to file; source policy
  1190. WRITE_DEFAULT_POLICY="1"
  1191. WriteNewInstPath
  1192. . $TMP_INST_PATH_DEFAULT
  1193. ExportVars
  1194.  
  1195. elif [ -z $CURRENT_DISTRO ]
  1196. then
  1197. # get version of default policy to use
  1198. GetDefaultPolicyVersion
  1199.  
  1200. # assert: CURRENT_DISTRO_VERSION is now set; the above exits on error
  1201.  
  1202. # print default policy to file; source policy
  1203. WRITE_DEFAULT_POLICY="1"
  1204. WriteNewInstPath
  1205. . $TMP_INST_PATH_DEFAULT
  1206. ExportVars
  1207.  
  1208. #create log here
  1209. if [ `id -u` -eq 0 ]; then
  1210. CreateInstallLog
  1211. fi
  1212.  
  1213. # run the pre-requisite script for LOKI UI support[checks only language support]
  1214. sh ./sw_preq_check.sh 2>/dev/null
  1215. exitstatus=$?
  1216. if [ $exitstatus != 0 ]; then
  1217. exit 0
  1218. fi
  1219.  
  1220. # detect the current distro and set CURRENT_DISTRO accordingly
  1221. DetectDistro
  1222.  
  1223. DD_RETVAL=$?
  1224.  
  1225. if [ "${DD_RETVAL}" = "64" ]
  1226. then
  1227. # multiple matches found, process as if CURRENT_DISTRO and
  1228. # CURRENT_DISTRO_VERSION were set
  1229. Setup_with_CD_and_CDV_set
  1230.  
  1231. # add warning to inst_path_override
  1232. cat - >> $TMP_INST_PATH_OVERRIDE << INST_PATH_END
  1233.  
  1234. # Warning: multiple matches found by detection scripts; distro is user-selected
  1235.  
  1236. INST_PATH_END
  1237. else
  1238. # no multiple matches found, continue as usual
  1239. if [ "$NO_OVERRIDE_POLICY" = "1" ]
  1240. then
  1241. # print warning message about not using override
  1242. cat - > $TMP_INST_PATH_OVERRIDE << INST_PATH_HEADER_END
  1243. # /etc/ati/inst_path_override
  1244. #
  1245. # Created ${TIMESTAMP} with the following configuration:
  1246. #
  1247. # Driver version: ${DRV_RELEASE}
  1248. # No override policy used because no distributions matched the current distro
  1249.  
  1250. INST_PATH_HEADER_END
  1251. else
  1252. WRITE_DEFAULT_POLICY="0"
  1253. WriteNewInstPath
  1254. . $TMP_INST_PATH_OVERRIDE
  1255. ExportVars
  1256. fi
  1257. fi
  1258. else # USE_DEFAULT_POLICY != 1 and user specified CURRENT_DISTRO
  1259. # setup default policy
  1260.  
  1261. # save existing CURRENT_VERSION and CURRENT_DISTRO_VERSION values
  1262. SAVED_CURRENT_DISTRO=${CURRENT_DISTRO}
  1263. SAVED_CURRENT_DISTRO_VERSION=${CURRENT_DISTRO_VERSION}
  1264.  
  1265. # unset variables so that user-defined variables are not used
  1266. CURRENT_DISTRO=
  1267. CURRENT_DISTRO_VERSION=
  1268.  
  1269. # get version of default policy to use
  1270. GetDefaultPolicyVersion
  1271.  
  1272. # assert: CURRENT_DISTRO_VERSION is now set; the above exits on error
  1273.  
  1274. # print default policy to file; source policy
  1275. WRITE_DEFAULT_POLICY="1"
  1276. WriteNewInstPath
  1277. . $TMP_INST_PATH_DEFAULT
  1278. ExportVars
  1279.  
  1280. # restore CURRENT_VERSION and CURRENT_DISTRO_VERSION values
  1281. CURRENT_DISTRO=${SAVED_CURRENT_DISTRO}
  1282. CURRENT_DISTRO_VERSION=${SAVED_CURRENT_DISTRO_VERSION}
  1283.  
  1284.  
  1285. if [ ! -d packages/$CURRENT_DISTRO ]
  1286. then
  1287. echo
  1288. echo "Error: The distribution specified in the CURRENT_DISTRO"
  1289. echo "environment variable does not match any of the distributions"
  1290. echo "recognized by this installer. The recognized distributions"
  1291. echo "are the following:"
  1292. echo
  1293.  
  1294. for dir in `find packages -mindepth 1 -maxdepth 1 -type d -print`
  1295. do
  1296. distro=`basename $dir`
  1297. echo " $distro"
  1298. done
  1299.  
  1300. echo
  1301.  
  1302. CleanTmpInstPath
  1303.  
  1304. exit 1
  1305. elif [ -z $CURRENT_DISTRO_VERSION ]
  1306. then
  1307. # user specified CURRENT_DISTRO, but not CURRENT_DISTRO_VERSION so
  1308. # we'll try to get a CURRENT_DISTRO_VERSION from the CURRENT_DISTRO
  1309. # that they specified
  1310.  
  1311. distro=$CURRENT_DISTRO
  1312.  
  1313. GET_DEFAULT_POLICY="0"
  1314. NO_OVERRIDE_POLICY=1
  1315. CURRENT_DISTRO=""
  1316. MULTIPLE_MATCHES=0
  1317.  
  1318. GetDistroPolicy
  1319.  
  1320. RETURN_CODE=$?
  1321.  
  1322. # restore old CURRENT_DISTRO value
  1323. CURRENT_DISTRO=${distro}
  1324.  
  1325. if [ 0 -eq $RETURN_CODE ]
  1326. then
  1327. # no error; do nothing and fall through to the rest of the
  1328. # installation
  1329.  
  1330. true # do nothing, successfully
  1331. elif [ 64 -eq $RETURN_CODE ]
  1332. then
  1333. # 64 means distro supports --iscurrentdistro but the current
  1334. # distro does not match
  1335.  
  1336. echo
  1337. echo "Error: The distribution specified in CURRENT_DISTRO"
  1338. echo "${distro} is not the current distribution according"
  1339. echo "to packages/$distro/ati-packager.sh --identify"
  1340. echo
  1341.  
  1342. CleanTmpInstPath
  1343.  
  1344. exit 1
  1345. elif [ 65 -eq $RETURN_CODE ]
  1346. then
  1347. # 65 means distro does not provide a policy
  1348.  
  1349. echo
  1350. echo "Error: The distribution specified in CURRENT_DISTRO"
  1351. echo "${distro} does not provide a policy to use for"
  1352. echo "installation; try running the installer again with"
  1353. echo "CURRENT_DISTRO unset"
  1354. echo
  1355.  
  1356. CleanTmpInstPath
  1357.  
  1358. exit 1
  1359. else
  1360. echo
  1361. echo "Unexpected error code returned by GetDistroPolicy;"
  1362. echo "error code returned was $RETURN_CODE"
  1363. echo
  1364.  
  1365. CleanTmpInstPath
  1366.  
  1367. exit 1
  1368. fi
  1369.  
  1370. WRITE_DEFAULT_POLICY="0"
  1371. WriteNewInstPath
  1372. . $TMP_INST_PATH_OVERRIDE
  1373. ExportVars
  1374.  
  1375. # add note to inst_path_override
  1376. cat - >> $TMP_INST_PATH_OVERRIDE << INST_PATH_END
  1377.  
  1378. # Note: user specified CURRENT_DISTRO on the command line so the installer used
  1379. # its value instead of detecting it; CURRENT_DISTRO_VERSION was detected
  1380.  
  1381. INST_PATH_END
  1382.  
  1383. else
  1384. # user specified both CURRENT_DISTRO and CURRENT_DISTRO_VERSION;
  1385. # we will assume the user knows what they're doing and not bother
  1386. # validating whether the CURRENT_DISTRO_VERSION actually matches
  1387. # one that would be returned by --iscurrentdistro; if it doesn't,
  1388. # it will be caught later on anyway
  1389.  
  1390. # note: one could specify a CURRENT_DISTRO_VERSION that is never
  1391. # returned by --iscurrentdistro but is handled by --getpolicy to
  1392. # provide hidden functionality
  1393.  
  1394. Setup_with_CD_and_CDV_set
  1395.  
  1396. # add note to inst_path_override
  1397. cat - >> $TMP_INST_PATH_OVERRIDE << INST_PATH_END
  1398.  
  1399. # Note: user specified both CURRENT_DISTRO and CURRENT_DISTRO_VERSION on the
  1400. # command line so the installer used both values instead of detecting them
  1401.  
  1402. INST_PATH_END
  1403. fi
  1404. fi
  1405.  
  1406. # The uninstall script "fglrx-uninstall.sh" will be saved to ${SETUP_INSTALLPATH}${ATI_UNINST}
  1407. # by copy_uninstall_file.sh during the install process
  1408.  
  1409.  
  1410. if [ "$USER_SPECIFIED_X_VERSION" = "1" ]; then
  1411. X_VERSION=${SAVED_X_VERSION}
  1412.  
  1413. # get check.sh to print human-readable X_VERSION/_ARCH, with hint that
  1414. # X_VERSION has was overridden so it prints it as such
  1415. checksh --nodetect --override
  1416.  
  1417. cat - >> $TMP_INST_PATH_OVERRIDE << INST_PATH_FOOTER_END
  1418. # user overrode X_VERSION to the following:
  1419. X_VERSION=${X_VERSION}
  1420.  
  1421. INST_PATH_FOOTER_END
  1422.  
  1423. else
  1424. # get check.sh to print human-readable X_VERSION/_ARCH given policy
  1425. checksh --nodetect
  1426. fi
  1427.  
  1428.  
  1429. if [ -z "${X_VERSION}" ]
  1430. then
  1431. echo
  1432. echo "X_VERSION variable was not set by the default policy or by"
  1433. echo "the override policy; perhaps the version of X being used is not"
  1434. echo "a well-known one; the X_VERSION variable must be set in the"
  1435. echo "override policy if you wish to continue; see README.distro for"
  1436. echo "details"
  1437. echo
  1438.  
  1439. CleanTmpInstPath
  1440.  
  1441. exit 1
  1442. else
  1443. case "${_ARCH}" in
  1444. i?86 | x86_64)
  1445. if [ ${_ARCH} = "x86_64" ]; then
  1446. ArchDir=x86_64
  1447. XLibDir=lib64
  1448. else
  1449. ArchDir=x86
  1450. XLibDir=lib
  1451. fi
  1452.  
  1453. # Verify the directory for the detected X is included with the installer
  1454. if [ -d ${X_VERSION} -o -L ${X_VERSION} ]; then
  1455.  
  1456. TmpDrvFilesDir=install
  1457. rm -rf ${TmpDrvFilesDir}
  1458. mkdir -p ${TmpDrvFilesDir}
  1459.  
  1460. ### Begin creating directories for the files to go in ###
  1461. ATI_VAR_LIST="${ATI_XLIB_32} ${ATI_XLIB_64} ${ATI_3D_DRV_32} ${ATI_3D_DRV_64} ${ATI_X_BIN} ${ATI_SBIN} ${ATI_KERN_MOD} ${ATI_2D_DRV} ${ATI_X_MODULE} ${ATI_DRM_LIB} ${ATI_CP_KDE3_LNK} ${ATI_GL_INCLUDE} ${ATI_ATIGL_INCLUDE} ${ATI_CP_LNK} ${ATI_CP_KDE_LNK} ${ATI_DOC} ${ATI_CP_DOC} ${ATI_CP_GNOME_LNK} ${ATI_ICON} ${ATI_MAN} ${ATI_SRC} ${ATI_X11_INCLUDE} ${ATI_CP_BIN} ${ATI_CP_I18N} ${ATI_LIB} ${ATI_SECURITY_CFG} ${ATI_XLIB_EXT_32} ${ATI_XLIB_EXT_64} ${ATI_PX_SUPPORT} ${OPENCL_CONFIG} ${OPENCL_LIB_32} ${OPENCL_LIB_64} ${OPENCL_BIN}"
  1462.  
  1463. #the vars that are to be used for dirs out of the installer dir
  1464.  
  1465. for ATI_VAR in ${ATI_VAR_LIST}; do
  1466. mkdir -p ${TmpDrvFilesDir}/${ATI_VAR}
  1467. done
  1468.  
  1469. #installing to libglx a subdirectory
  1470. mkdir -p ${TmpDrvFilesDir}/${ATI_XLIB_32}/fglrx
  1471. mkdir -p ${TmpDrvFilesDir}/${ATI_XLIB_64}/fglrx
  1472.  
  1473. #directory exceptions go here
  1474. mkdir -p ${TmpDrvFilesDir}/${ATI_KERN_MOD}/build_mod
  1475.  
  1476. # we also copy files to /etc/ati (although not in variable list)
  1477. mkdir -p ${TmpDrvFilesDir}/etc/ati
  1478.  
  1479. ### Done creating directories ###
  1480. GetHeadLessConfig
  1481. is_headless=$?
  1482.  
  1483. if [ "$is_headless" = "1" ]
  1484. then
  1485. NoAMDXorg=y
  1486. export NoAMDXorg
  1487. #echo "exporting value $NoAMDXorg"
  1488. fi
  1489. #NoAMDXorg suppory flag-Dell Server Issue
  1490. #Take back up of original libGL*
  1491. if [ "$NoAMDXorg" = "y" ] && ! [ "`cat /etc/*-release | grep "Ubuntu"`" ]; then
  1492. #echo "taking backup of libGL libraries..."
  1493. mkdir /usr/lib/NoAMDXorgBak 2>> /dev/null
  1494. mkdir /usr/lib64/NoAMDXorgBak 2>> /dev/null
  1495. cp /usr/lib/libGL.so.1.2.0 /usr/lib/NoAMDXorgBak 2>> /dev/null
  1496. cp /usr/lib64/libGL.so.1.2.0 /usr/lib64/NoAMDXorgBak 2>> /dev/null
  1497. fi
  1498.  
  1499. ### Begin copying files to specified paths in config ###
  1500.  
  1501. # arch
  1502. if [ ${ArchDir} = "x86_64" ]; then
  1503.  
  1504. cp -R arch/${ArchDir}/usr/X11R6/lib64/libfglrx*.* \
  1505. ${TmpDrvFilesDir}/${ATI_XLIB_64}
  1506. cp -R arch/${ArchDir}/usr/X11R6/lib64/fglrx/fglrx-libGL*.* \
  1507. ${TmpDrvFilesDir}/${ATI_XLIB_64}/fglrx
  1508. cp -R arch/${ArchDir}/usr/X11R6/lib64/libatiadl*.* \
  1509. ${TmpDrvFilesDir}/${ATI_XLIB_64}
  1510. cp -R arch/${ArchDir}/usr/lib64/libatiuki*.* \
  1511. ${TmpDrvFilesDir}/${ATI_XLIB_64}
  1512. cp -R arch/${ArchDir}/usr/lib64/libatical*.* \
  1513. ${TmpDrvFilesDir}/${ATI_XLIB_64}
  1514. cp -R arch/${ArchDir}/usr/X11R6/lib64/libAMDXvBA*.* \
  1515. ${TmpDrvFilesDir}/${ATI_XLIB_64}
  1516. cp -R arch/${ArchDir}/usr/X11R6/lib64/libXvBAW*.* \
  1517. ${TmpDrvFilesDir}/${ATI_XLIB_64}
  1518. cp -R arch/${ArchDir}/usr/X11R6/lib64/modules/dri/*.* \
  1519. ${TmpDrvFilesDir}/${ATI_3D_DRV_64}
  1520. cp -R arch/${ArchDir}/usr/lib64/fglrx/switchlib* \
  1521. ${TmpDrvFilesDir}/${ATI_PX_SUPPORT}
  1522.  
  1523. cp -R arch/${ArchDir}/usr/share/ati/lib64/libQt*.* \
  1524. ${TmpDrvFilesDir}/${ATI_LIB}
  1525.  
  1526. ## OpenCL sdk files
  1527. cp -R arch/${ArchDir}/usr/lib64/libamdocl*.* \
  1528. ${TmpDrvFilesDir}/${OPENCL_LIB_64}
  1529. cp -R arch/${ArchDir}/usr/lib64/libOpenCL*.* \
  1530. ${TmpDrvFilesDir}/${OPENCL_LIB_64}
  1531. cp -R arch/${ArchDir}/etc/OpenCL/vendors/* \
  1532. ${TmpDrvFilesDir}/${OPENCL_CONFIG}
  1533.  
  1534. ### Copy 32-bit libraries even if using a 64-bit system
  1535.  
  1536. cp -R arch/x86/usr/X11R6/lib/libfglrx*.* \
  1537. ${TmpDrvFilesDir}/${ATI_XLIB_32}
  1538. cp -R arch/x86/usr/X11R6/lib/fglrx/fglrx-libGL*.* \
  1539. ${TmpDrvFilesDir}/${ATI_XLIB_32}/fglrx
  1540. cp -R arch/x86/usr/X11R6/lib/libatiadl*.* \
  1541. ${TmpDrvFilesDir}/${ATI_XLIB_32}
  1542. cp -R arch/x86/usr/lib/libatiuki*.* \
  1543. ${TmpDrvFilesDir}/${ATI_XLIB_32}
  1544. cp -R arch/x86/usr/lib/libatical*.* \
  1545. ${TmpDrvFilesDir}/${ATI_XLIB_32}
  1546. cp -R arch/x86/usr/X11R6/lib/libAMDXvBA*.* \
  1547. ${TmpDrvFilesDir}/${ATI_XLIB_32}
  1548. cp -R arch/x86/usr/X11R6/lib/libXvBAW*.* \
  1549. ${TmpDrvFilesDir}/${ATI_XLIB_32}
  1550. cp -R arch/x86/usr/X11R6/lib/modules/dri/*.* \
  1551. ${TmpDrvFilesDir}/${ATI_3D_DRV_32}
  1552. cp -R arch/x86/usr/lib/libamdocl*.* \
  1553. ${TmpDrvFilesDir}/${OPENCL_LIB_32}
  1554. cp -R arch/x86/usr/lib/libOpenCL*.* \
  1555. ${TmpDrvFilesDir}/${OPENCL_LIB_32}
  1556. cp -R arch/x86/etc/OpenCL/vendors/* \
  1557. ${TmpDrvFilesDir}/${OPENCL_CONFIG}
  1558.  
  1559. else
  1560.  
  1561. cp -R arch/${ArchDir}/usr/X11R6/lib/libfglrx*.* \
  1562. ${TmpDrvFilesDir}/${ATI_XLIB_32}
  1563. cp -R arch/${ArchDir}/usr/X11R6/lib/fglrx/fglrx-libGL*.* \
  1564. ${TmpDrvFilesDir}/${ATI_XLIB_32}/fglrx
  1565. cp -R arch/${ArchDir}/usr/X11R6/lib/libatiadl*.* \
  1566. ${TmpDrvFilesDir}/${ATI_XLIB_32}
  1567. cp -R arch/${ArchDir}/usr/lib/libatiuki*.* \
  1568. ${TmpDrvFilesDir}/${ATI_XLIB_32}
  1569. cp -R arch/${ArchDir}/usr/lib/libatical*.* \
  1570. ${TmpDrvFilesDir}/${ATI_XLIB_32}
  1571. cp -R arch/${ArchDir}/usr/X11R6/lib/libAMDXvBA*.* \
  1572. ${TmpDrvFilesDir}/${ATI_XLIB_32}
  1573. cp -R arch/${ArchDir}/usr/X11R6/lib/libXvBAW*.* \
  1574. ${TmpDrvFilesDir}/${ATI_XLIB_32}
  1575. cp -R arch/${ArchDir}/usr/X11R6/lib/modules/dri/*.* \
  1576. ${TmpDrvFilesDir}/${ATI_3D_DRV_32}
  1577. cp -R arch/${ArchDir}/usr/lib/fglrx/switchlib* \
  1578. ${TmpDrvFilesDir}/${ATI_PX_SUPPORT}
  1579.  
  1580. cp -R arch/${ArchDir}/usr/share/ati/lib/libQt*.* \
  1581. ${TmpDrvFilesDir}/${ATI_LIB}
  1582.  
  1583. ## OpenCL sdk files
  1584. cp -R arch/${ArchDir}/usr/lib/libamdocl*.* \
  1585. ${TmpDrvFilesDir}/${OPENCL_LIB_32}
  1586. cp -R arch/${ArchDir}/usr/lib/libOpenCL*.* \
  1587. ${TmpDrvFilesDir}/${OPENCL_LIB_32}
  1588. cp -R arch/${ArchDir}/etc/OpenCL/vendors/* \
  1589. ${TmpDrvFilesDir}/${OPENCL_CONFIG}
  1590. fi
  1591. cp -R arch/${ArchDir}/usr/bin/clinfo \
  1592. ${TmpDrvFilesDir}/${OPENCL_BIN}
  1593. cp -R arch/${ArchDir}/usr/X11R6/bin/* \
  1594. ${TmpDrvFilesDir}/${ATI_X_BIN}
  1595. if [ -n "$NoAMDXorg" ]; then
  1596. rm -rf ${TmpDrvFilesDir}/${ATI_X_BIN}/amdcccle
  1597. fi
  1598. cp -R common/usr/sbin/* \
  1599. ${TmpDrvFilesDir}/${ATI_SBIN}
  1600. cp -R arch/${ArchDir}/usr/sbin/* \
  1601. ${TmpDrvFilesDir}/${ATI_SBIN}
  1602. cp -R arch/${ArchDir}/lib/modules/fglrx/build_mod/*.* \
  1603. ${TmpDrvFilesDir}/${ATI_KERN_MOD}/build_mod
  1604.  
  1605. # x version
  1606. if [ ${ArchDir} = "x86_64" ]; then
  1607. mkdir ${TmpDrvFilesDir}/${ATI_XLIB_EXT_64}/fglrx
  1608. cp -R ${X_VERSION}/usr/X11R6/${XLibDir}/modules/extensions/fglrx/*.* \
  1609. ${TmpDrvFilesDir}/${ATI_XLIB_EXT_64}/fglrx/
  1610. else
  1611. mkdir ${TmpDrvFilesDir}/${ATI_XLIB_EXT_32}/fglrx
  1612. cp -R ${X_VERSION}/usr/X11R6/${XLibDir}/modules/extensions/fglrx/*.* \
  1613. ${TmpDrvFilesDir}/${ATI_XLIB_EXT_32}/fglrx/
  1614. fi
  1615. cp -R ${X_VERSION}/usr/X11R6/${XLibDir}/modules/drivers/*.* \
  1616. ${TmpDrvFilesDir}/${ATI_2D_DRV}
  1617. cp -R ${X_VERSION}/usr/X11R6/${XLibDir}/modules/glesx* \
  1618. ${TmpDrvFilesDir}/${ATI_X_MODULE}
  1619. cp -R ${X_VERSION}/usr/X11R6/${XLibDir}/modules/amdxmm* \
  1620. ${TmpDrvFilesDir}/${ATI_X_MODULE}
  1621. cp -R ${X_VERSION}/usr/X11R6/${XLibDir}/modules/linux/*.* \
  1622. ${TmpDrvFilesDir}/${ATI_DRM_LIB}
  1623.  
  1624. # common
  1625. cp -R common/etc/ati/* \
  1626. ${TmpDrvFilesDir}/etc/ati
  1627. cp -R common/lib/modules/fglrx/* \
  1628. ${TmpDrvFilesDir}/${ATI_KERN_MOD}
  1629. cp -p common/etc/security/console.apps/amdcccle-su \
  1630. ${TmpDrvFilesDir}/${ATI_SECURITY_CFG}
  1631.  
  1632. # common/usr
  1633. cp -R common/usr/include/GL/*.* \
  1634. ${TmpDrvFilesDir}/${ATI_GL_INCLUDE}
  1635. cp -R common/usr/include/ATI/GL/*.* \
  1636. ${TmpDrvFilesDir}/${ATI_ATIGL_INCLUDE}
  1637. if [ -z "$NoAMDXorg" ]; then
  1638. cp -R common/usr/share/applications/*.desktop \
  1639. ${TmpDrvFilesDir}/${ATI_CP_LNK}
  1640. fi
  1641. cp -R common/usr/share/ati/amdcccle/*.qm \
  1642. ${TmpDrvFilesDir}/${ATI_CP_I18N}
  1643. cp -R common/usr/share/doc/fglrx/* \
  1644. ${TmpDrvFilesDir}/${ATI_DOC}
  1645. if [ -z "$NoAMDXorg" ]; then
  1646. cp -R common/usr/share/icons/*.* \
  1647. ${TmpDrvFilesDir}/${ATI_ICON}
  1648. fi
  1649. cp -R common/usr/share/man/* \
  1650. ${TmpDrvFilesDir}/${ATI_MAN}
  1651. cp -R common/usr/src/ati/*.* \
  1652. ${TmpDrvFilesDir}/${ATI_SRC}
  1653. cp -R common/usr/X11R6/bin/* \
  1654. ${TmpDrvFilesDir}/${ATI_CP_BIN}
  1655. cp -R common/usr/share/doc/amdcccle/* \
  1656. ${TmpDrvFilesDir}/${ATI_CP_DOC}
  1657.  
  1658. ### Done copying ###
  1659.  
  1660.  
  1661. ### blacklisting - required for disabling radeon on systems with KMS ###
  1662. mkdir -p ${TmpDrvFilesDir}/etc/modprobe.d
  1663. blacklistfile="${TmpDrvFilesDir}/etc/modprobe.d/blacklist-fglrx.conf"
  1664. echo "# Advanced Micro Devices, Inc."> ${blacklistfile}
  1665. echo "# radeon conflicts with AMD Linux Graphics Driver" >> ${blacklistfile}
  1666. echo "blacklist radeon" >> ${blacklistfile}
  1667. echo "blacklist amdgpu" >> ${blacklistfile}
  1668.  
  1669. ### amdconfig to symlink to aticonfig ###
  1670. ln -s ${ATI_X_BIN}/aticonfig ${TmpDrvFilesDir}/${ATI_X_BIN}/amdconfig
  1671.  
  1672. #amdcccle security file only for Ubuntu
  1673. if [ "`cat /etc/*-release | grep "Ubuntu" `" ]; then
  1674. mkdir -p ${TmpDrvFilesDir}/usr/share/polkit-1/actions
  1675. cp -R com.ubuntu.amdcccle.pkexec.policy \
  1676. ${TmpDrvFilesDir}/usr/share/polkit-1/actions
  1677. fi
  1678.  
  1679. # for Xorg 7, the .so files are put in ${ATI_3D_DRV_32} (and
  1680. # possibly also ${ATI_3D_DRV_64}); however, some of the code
  1681. # looks for the files in the hard-coded paths
  1682. # /usr/X11R6/lib/modules/dri and /usr/X11R6/lib64/modules/dri
  1683. # so we are creating symlinks so the code can still find those
  1684. # .so files
  1685. if [ "$X_LAYOUT" = "modular" ]
  1686. then
  1687. mkdir -p ${TmpDrvFilesDir}/usr/X11R6/lib/modules/dri
  1688. ln -s ${ATI_3D_DRV_32}/fglrx_dri.so ${TmpDrvFilesDir}/usr/X11R6/lib/modules/dri/fglrx_dri.so
  1689.  
  1690. if [ ! -z ${ATI_3D_DRV_64} ]
  1691. then
  1692. mkdir -p ${TmpDrvFilesDir}/usr/X11R6/lib64/modules/dri
  1693. ln -s ${ATI_3D_DRV_64}/fglrx_dri.so ${TmpDrvFilesDir}/usr/X11R6/lib64/modules/dri/fglrx_dri.so
  1694. fi
  1695. fi
  1696.  
  1697. # replace strings in setup.glade (XML file)
  1698. SETUP_GLADE="./setup.data/setup.glade"
  1699. ATI_LOG_EXP=$( echo ${ATI_LOG} | sed -e 's/\//\\\//g' )
  1700.  
  1701. rm -f ${SETUP_GLADE}_new
  1702. sed s/\${ATI_LOG}/${ATI_LOG_EXP}/g ${SETUP_GLADE} >> ${SETUP_GLADE}_new
  1703. rm -f ${SETUP_GLADE}
  1704. mv -f ${SETUP_GLADE}_new ${SETUP_GLADE}
  1705.  
  1706. # Generate xml scripts for Loki Setup
  1707. ./lokixml.sh ${X_VERSION} ${DRV_RELEASE} ${TmpDrvFilesDir} 2>/dev/null
  1708.  
  1709. # Run the installer
  1710. RunLoki installation
  1711. status=$?
  1712.  
  1713. # Remove the temporary directory
  1714.  
  1715. # make sure we're not doing "rm -rf /"; that would be bad
  1716. if [ "${TmpDrvFilesDir}" = "/" ]
  1717. then
  1718. echo "Error: TmpDrvFilesDir is / in ati-installer.sh;" 1>&2
  1719. echo "aborting rm operation to prevent data loss" 1>&2
  1720.  
  1721. exit 1
  1722. fi
  1723.  
  1724. rm -rf ${TmpDrvFilesDir}
  1725. else
  1726. echo ""
  1727. echo "Detected version of X does not have a matching '${X_VERSION}' directory"
  1728. echo "You may override the detected version using the following syntax:"
  1729. echo " X_VERSION=<xdir> ./amd-driver-installer-<ver>-<arch>.run [--install]"
  1730. echo ""
  1731. echo "The following values may be used for <xdir>:"
  1732.  
  1733. for xdir in `ls -d x*`; do
  1734. echo -e " ${xdir}\t`./map_xname.sh ${xdir}`"
  1735. done
  1736.  
  1737. status=1
  1738. fi
  1739. ;;
  1740. *)
  1741. echo "Architecture '${_ARCH}' is not supported"
  1742. status=1
  1743. ;;
  1744. esac
  1745. fi
  1746.  
  1747. CleanTmpInstPath
  1748.  
  1749. ;;
  1750. --listpkg)
  1751. #iterate through all ati-packager.sh under packages/distro/ to return all package types
  1752. #categorize by distro, show its maintainer, and its status
  1753. echo -e "List of generatable packages:\n"
  1754. for distro in `ls packages`
  1755. do
  1756. #for several entries for maintainer, use "; " as a delimeter, for example "1st; 2nd"
  1757. case "${distro}" in
  1758. ATI)
  1759. maintainer="ATI"
  1760. verified_status=1
  1761. ;;
  1762. Debian)
  1763. maintainer="Aric Cyr <aric.cyr@gmail.com>;Mario Limonciello <superm1@gmail.com>"
  1764. verified_status=0
  1765. ;;
  1766. Fedora)
  1767. maintainer="Niko Mirthes <nmirthes@gmail.com>;Michael Larabel <michael@phoronix.com>"
  1768. verified_status=0
  1769. ;;
  1770. Gentoo)
  1771. maintainer="UNKNOWN"
  1772. verified_status=0
  1773. ;;
  1774. Mandriva)
  1775. maintainer="Anssi Hannula <anssi@mandriva.org>"
  1776. verified_status=0
  1777. ;;
  1778. RedHat)
  1779. maintainer="ATI"
  1780. verified_status=1
  1781. ;;
  1782. RedFlag)
  1783. maintainer="Bowen Zhu <bwzhu@redflag-linux.com>"
  1784. verified_status=0
  1785. ;;
  1786. Slackware)
  1787. maintainer="Emanuele Tomasi <tomasi@cli.di.unipi.it>;Federico Rota <federico.rota01@gmail.com>"
  1788. verified_status=0
  1789. ;;
  1790. SuSE)
  1791. maintainer="Sebastian Siebert <freespacer@gmx.de>"
  1792. verified_status=0
  1793. ;;
  1794. Ubuntu)
  1795. maintainer="Mario Limonciello <superm1@gmail.com>;Aric Cyr <aric.cyr@gmail.com>;Alberto Milone <alberto.milone@canonical.com>"
  1796. verified_status=0
  1797. ;;
  1798. custom-package)
  1799. maintainer="Your Self <your@email>"
  1800. verified_status=0
  1801. ;;
  1802. *)
  1803. maintainer="UNKNOWN"
  1804. verified_status=0
  1805. ;;
  1806. esac
  1807.  
  1808. if [ -d packages/${distro} ]
  1809. then
  1810. packager=packages/${distro}/ati-packager.sh
  1811. if [ -e ${packager} ]
  1812. then
  1813.  
  1814. pkg_list=""
  1815. for package in `./${packager} --get-supported`
  1816. do
  1817. pkg_list="${pkg_list}\t${distro}/${package}\n"
  1818. done
  1819.  
  1820. newMaintainer=`execGetMaintainer ${packager}`
  1821.  
  1822. if [ $? -eq 0 -a -n "${newMaintainer}" ]; then
  1823. maintainer=${newMaintainer}
  1824. fi
  1825.  
  1826. if [ ${pkg_list} ]
  1827. then
  1828. echo -e "Package Maintainer(s): ${maintainer}" | sed "s/;/\n /g"
  1829.  
  1830. if [ ${verified_status} -eq 1 ]; then
  1831. echo "Status: Verified"
  1832. else
  1833. echo "Status: *UNVERIFIED*"
  1834. fi
  1835. echo -e "${distro} Packages:"
  1836.  
  1837. echo -e "${pkg_list}"
  1838. fi
  1839. fi
  1840. fi
  1841. done
  1842. echo -e "For example, to build a Debian Etch package, run the following:"
  1843. echo -e "% ./amd-driver-installer-<version>-<architecture>.run --buildpkg Debian/etch\n"
  1844. ;;
  1845. --buildpkg)
  1846.  
  1847. case "$#" in
  1848.  
  1849. 2) #means --buildpkg was called without package_info or --dryrun
  1850. pkg_list=`execIdentify 2>/dev/null`
  1851.  
  1852. checkDistroResult ${pkg_list}
  1853. if [ $? -eq 0 ]
  1854. then
  1855. # Get distro/package values
  1856. distro=`echo ${pkg_list} | cut -d"/" -f1`
  1857. package=`echo ${pkg_list} | cut -d"/" -f2`
  1858. if [ "${distro}" -a -d packages/${distro} ]
  1859. then
  1860. echo "Generating package: ${distro}/${package}"
  1861. packager=packages/${distro}/ati-packager.sh
  1862. execBuildPrep ${packager} ${package}
  1863. prepResult=$?
  1864. if [ ${prepResult} -ne 0 ]
  1865. then
  1866. status=1
  1867. break #set error to ${prepResult}
  1868. fi
  1869. execBuildPkg ${packager} ${package}
  1870. buildResult=$?
  1871. if [ ${buildResult} -ne 0 ]
  1872. then
  1873. status=1
  1874. break #set error to ${buildResult}
  1875. fi
  1876. else
  1877. echo "Error: The distribution ${distro} is not supported"
  1878. status=1
  1879. break #error was ATI_INSTALLER_ERR_DIST
  1880. fi
  1881. else #else in an error condition and msg was relayed by checkDistroResult()
  1882. status=1
  1883. break
  1884. fi
  1885. ;;
  1886. 3)
  1887. if [ "${3}" = "--dryrun" ]
  1888. then
  1889. pkg_list=`execIdentify`
  1890.  
  1891. checkDistroResult ${pkg_list}
  1892. if [ $? -eq 0 ]
  1893. then
  1894. distro=`echo ${pkg_list} | cut -d"/" -f1`
  1895. package=`echo ${pkg_list} | cut -d"/" -f2`
  1896. if [ "${distro}" -a -d packages/${distro} ]
  1897. then
  1898. packager=packages/${distro}/ati-packager.sh
  1899. echo "Simulating Generation of package: ${distro}/${package}"
  1900. execBuildPrep ${packager} ${package} ${3}
  1901. prepResult=$?
  1902. if [ ${prepResult} -ne 0 ]
  1903. then
  1904. status=1
  1905. break #set error to ${prepResult}
  1906. fi
  1907. else
  1908. echo "Error: The distribution ${distro} is not supported"
  1909. status=1
  1910. break #error was ATI_INSTALLER_ERR_DIST
  1911. fi
  1912. else #else in an error condition and msg was relayed by checkDistroResult()
  1913. status=1
  1914. break
  1915. fi
  1916. else
  1917. package_info=$3
  1918.  
  1919. # Get distro/package values
  1920. distro=`echo ${package_info} | cut -d"/" -f1`
  1921. package=`echo ${package_info} | cut -d"/" -f2`
  1922. if [ "${distro}" -a -d packages/${distro} ]
  1923. then
  1924. echo "Generating package: ${distro}/${package}"
  1925. packager=packages/${distro}/ati-packager.sh
  1926. execGetAPIVersion ${packager}
  1927. if [ $? -gt 1 ]
  1928. then
  1929. execBuildPrep ${packager} ${package}
  1930. prepResult=$?
  1931. if [ ${prepResult} -ne 0 ]
  1932. then
  1933. status=1
  1934. break #set error to ${prepResult}
  1935. fi
  1936. fi
  1937. execBuildPkg ${packager} ${package}
  1938. buildResult=$?
  1939. if [ ${buildResult} -ne 0 ]
  1940. then
  1941. status=1
  1942. break #set error to ${buildResult}
  1943. fi
  1944. else
  1945. echo "Error: The distribution ${distro} is not supported"
  1946. status=1
  1947. break #error was ATI_INSTALLER_ERR_DIST
  1948. fi
  1949. fi
  1950. ;;
  1951. 4)
  1952. if [ "${4}" = "--dryrun" ]
  1953. then
  1954. package_info=$3
  1955.  
  1956. # Get distro/package values
  1957. distro=`echo ${package_info} | cut -d"/" -f1`
  1958. package=`echo ${package_info} | cut -d"/" -f2`
  1959. if [ "${distro}" -a -d packages/${distro} ]
  1960. then
  1961. packager=packages/${distro}/ati-packager.sh
  1962. execGetAPIVersion ${packager}
  1963. if [ $? -gt 1 ]
  1964. then
  1965. echo "Simulating Generation of package: ${distro}/${package}"
  1966. execBuildPrep ${packager} ${package} ${4}
  1967. prepResult=$?
  1968. if [ ${prepResult} -ne 0 ]
  1969. then
  1970. status=1
  1971. break #set error to ${prepResult}
  1972. fi
  1973. else
  1974. echo "Error: Build Option ${4}, not supported currently by packager"
  1975. status=1
  1976. break #error was ATI_INSTALLER_ERR_API
  1977. fi
  1978. else
  1979. echo "Error: The distribution ${distro} is not supported"
  1980. status=1
  1981. break #error was ATI_INSTALLER_ERR_DIST
  1982. fi
  1983. elif [ "${4}" = "--NoXServer" ]
  1984. then
  1985. package_info=$3
  1986.  
  1987. # Get distro/package values
  1988. distro=`echo ${package_info} | cut -d"/" -f1`
  1989. package=`echo ${package_info} | cut -d"/" -f2`
  1990. if [ "${distro}" -a -d packages/${distro} ]
  1991. then
  1992. echo "Generating package: ${distro}/${package}"
  1993. #ToDo:we can remove these if-else section, as we are maintaining 2 scripts on RHEL.
  1994. #we can club it to one going forward like Ubuntu and SuSE.
  1995. if [ "$distro" = "RedHat" ]; then
  1996. packager=packages/${distro}/ati-packager-NoX.sh
  1997. ./${packager} --buildpkg ${package}
  1998. else
  1999. packager=packages/${distro}/ati-packager.sh
  2000. ./${packager} --buildpkg ${package} $4
  2001. fi
  2002.  
  2003. # Need to uncomment these soon
  2004. # execGetAPIVersion ${packager}
  2005. # if [ $? -gt 1 ]
  2006. # then
  2007. # execBuildPrep ${packager} ${package}
  2008. # prepResult=$?
  2009. # if [ ${prepResult} -ne 0 ]
  2010. # then
  2011. # status=1
  2012. # break #set error to ${prepResult}
  2013. # fi
  2014. # fi
  2015. # execBuildPkg ${packager} ${package}
  2016. # ./${packager} --buildpkg ${package}
  2017. buildResult=$?
  2018. if [ ${buildResult} -ne 0 ]
  2019. then
  2020. status=1
  2021. break #set error to ${buildResult}
  2022. fi
  2023. else
  2024. echo "Error: The distribution ${distro} is not supported"
  2025. status=1
  2026. break #error was ATI_INSTALLER_ERR_DIST
  2027. fi
  2028. else
  2029. echo "Error: Unrecognized build option parameter ${4}"
  2030. printHelp
  2031. status=1
  2032. break #error was ATI_INSTALLER_ERR_BUILDOP
  2033. fi
  2034. ;;
  2035. *)
  2036. echo "Error: Unrecognized build option parameters"
  2037. printHelp
  2038. status=1
  2039. break #error was ATI_INSTALLER_ERR_BUILDOP
  2040. ;;
  2041. esac
  2042. ;;
  2043. --buildandinstallpkg)
  2044.  
  2045. numArgs="$#"
  2046. args=$@
  2047. if [ "`echo $args | grep '\-\-force'`" != "" ]; then
  2048. FORCE_ATI_UNINSTALL=y
  2049. export FORCE_ATI_UNINSTALL
  2050. #remove force command from args
  2051. args=`echo $args | sed "s/'--force'//g"`
  2052. numArgs=$(($numArgs-1))
  2053. fi
  2054.  
  2055. case ${numArgs} in
  2056.  
  2057. 2) #means --buildandinstallpkg was called without package_info or --dryrun
  2058. pkg_list=`execIdentify 2>/dev/null`
  2059.  
  2060. checkDistroResult ${pkg_list}
  2061. if [ $? -eq 0 ]
  2062. then
  2063. # Get distro/package values
  2064. distro=`echo ${pkg_list} | cut -d"/" -f1`
  2065. package=`echo ${pkg_list} | cut -d"/" -f2`
  2066. if [ "${distro}" -a -d packages/${distro} ]
  2067. then
  2068. echo "Generating and Installing package: ${distro}/${package}"
  2069. packager=packages/${distro}/ati-packager.sh
  2070. execBuildAndInstall ${packager} ${package}
  2071. BandIResult=$?
  2072. if [ ${BandIResult} -ne 0 ]
  2073. then
  2074. status=1
  2075. break #set error to ${BandIResult}
  2076. fi
  2077. else
  2078. echo "Error: The distribution ${1} is not supported"
  2079. status=1
  2080. break #error was ATI_INSTALLER_ERR_DIST
  2081. fi
  2082. else #else in an error condition and msg was relayed by checkDistroResult()
  2083. status=1
  2084. break
  2085. fi
  2086. ;;
  2087. 3)
  2088. if [ "`echo $args | grep '\-\-dryrun'`" != "" ]
  2089. then
  2090. pkg_list=`execIdentify`
  2091.  
  2092. checkDistroResult ${pkg_list}
  2093. if [ $? -eq 0 ]
  2094. then
  2095. distro=`echo ${pkg_list} | cut -d"/" -f1`
  2096. package=`echo ${pkg_list} | cut -d"/" -f2`
  2097. if [ "${distro}" -a -d packages/${distro} ]
  2098. then
  2099. packager=packages/${distro}/ati-packager.sh
  2100. echo "Simulating Generation and Installation of package: ${distro}/${package}"
  2101. execBuildAndInstall ${packager} ${package} --dryrun
  2102. BandIResult=$?
  2103. if [ ${BandIResult} -ne 0 ]
  2104. then
  2105. status=1
  2106. break #set error to ${BandIResult}
  2107. fi
  2108. else
  2109. echo "Error: The distribution ${1} is not supported"
  2110. status=1
  2111. break #error was ATI_INSTALLER_ERR_DIST
  2112. fi
  2113. else #else in an error condition and msg was relayed by checkDistroResult()
  2114. status=1
  2115. break
  2116. fi
  2117. else
  2118. package_info=$3
  2119.  
  2120. # Get distro/package values
  2121. distro=`echo ${package_info} | cut -d"/" -f1`
  2122. package=`echo ${package_info} | cut -d"/" -f2`
  2123. if [ "${distro}" -a -d packages/${distro} ]
  2124. then
  2125. packager=packages/${distro}/ati-packager.sh
  2126. execGetAPIVersion ${packager}
  2127. if [ $? -gt 1 ]
  2128. then
  2129. echo "Generating and Installing package: ${distro}/${package}"
  2130. execBuildAndInstall ${packager} ${package}
  2131. BandIResult=$?
  2132. if [ ${BandIResult} -ne 0 ]
  2133. then
  2134. status=1
  2135. break #set error to ${BandIResult}
  2136. fi
  2137. else
  2138. echo "Error: Build Option ${ACTION} not supported currently by packager"
  2139. status=1
  2140. break #error was ATI_INSTALLER_ERR_API
  2141. fi
  2142. else
  2143. echo "Error: The distribution ${distro} is not supported"
  2144. status=1
  2145. break #error was ATI_INSTALLER_ERR_DIST
  2146. fi
  2147. fi
  2148. ;;
  2149. 4)
  2150. if [ "`echo $args | grep '\-\-dryrun'`" != "" ]
  2151. then
  2152. package_info=$3
  2153.  
  2154. # Get distro/package values
  2155. distro=`echo ${package_info} | cut -d"/" -f1`
  2156. package=`echo ${package_info} | cut -d"/" -f2`
  2157. if [ "${distro}" -a -d packages/${distro} ]
  2158. then
  2159. packager=packages/${distro}/ati-packager.sh
  2160. execGetAPIVersion ${packager}
  2161. if [ $? -gt 1 ]
  2162. then
  2163. echo "Simulating Generation and Installation of package: ${distro}/${package}"
  2164. execBuildAndInstall ${packager} ${package} --dryrun
  2165. BandIResult=$?
  2166. if [ ${BandIResult} -ne 0 ]
  2167. then
  2168. status=1
  2169. break #set error to ${BandIResult}
  2170. fi
  2171. else
  2172. echo "Error: Build Option ${ACTION} not supported currently by packager"
  2173. status=1
  2174. break #error was ATI_INSTALLER_ERR_API
  2175. fi
  2176. else
  2177. echo "Error: The distribution ${distro} is not supported"
  2178. status=1
  2179. break #error was ATI_INSTALLER_ERR_DIST
  2180. fi
  2181. else
  2182. echo "Error: Unrecognized build option parameter"
  2183. printHelp
  2184. status=1
  2185. break #error was ATI_INSTALLER_ERR_BUILDOP
  2186. fi
  2187. ;;
  2188. *)
  2189. echo "Error: Unrecognized build option parameter"
  2190. printHelp
  2191. status=1
  2192. break #error was ATI_INSTALLER_ERR_BUILDOP
  2193. ;;
  2194. esac
  2195. ;;
  2196. --installpkg)
  2197.  
  2198. if [ "`echo $@ | grep '\-\-force'`" != "" ]; then
  2199. FORCE_ATI_UNINSTALL=y
  2200. export FORCE_ATI_UNINSTALL
  2201. fi
  2202.  
  2203. package_info=$3
  2204.  
  2205. # Get distro/package values
  2206. distro=`echo ${package_info} | cut -d"/" -f1`
  2207. package=`echo ${package_info} | cut -d"/" -f2`
  2208. if [ "${distro}" -a -d packages/${distro} ]
  2209. then
  2210. packager=packages/${distro}/ati-packager.sh
  2211. execGetAPIVersion ${packager}
  2212. if [ $? -gt 1 ]
  2213. then
  2214.  
  2215. execInstallPrep ${packager} ${package}
  2216. prepResult=$?
  2217. if [ ${prepResult} -ne 0 ]
  2218. then
  2219. status=1
  2220. break #set error to ${prepResult}
  2221. fi
  2222. execInstallPkg ${packager} ${package}
  2223. installResult=$?
  2224. if [ ${installResult} -ne 0 ]
  2225. then
  2226. status=1
  2227. break #set error to ${installResult}
  2228. fi
  2229. else
  2230. echo "Action ${2} not supported by current API of ${3}"
  2231. status=1
  2232. break
  2233. fi
  2234. else
  2235. echo "Error: The distribution ${distro} is not supported"
  2236. status=1
  2237. break #error was ATI_INSTALLER_ERR_DIST
  2238. fi
  2239. ;;
  2240. --getAPIVersion)
  2241. if [ "${3}" -a -d packages/${3} ]
  2242. then
  2243. packager=packages/${3}/ati-packager.sh
  2244. execGetAPIVersion ${packager}
  2245. echo "Installer API version for distribution ${3} is $?"
  2246. else
  2247. echo "Error: The distribution ${3} is not supported"
  2248. status=1
  2249. break #error was ATI_INSTALLER_ERR_DIST
  2250. fi
  2251. ;;
  2252. --help)
  2253. printHelp
  2254. ;;
  2255. *)
  2256. echo "Unrecognized parameter '${ACTION}' to ati-installer.sh"
  2257. printHelp
  2258. status=1
  2259. ;;
  2260. esac
  2261.  
  2262. #write status to file to be read by .run
  2263. echo ${status} > ATI_STATUS
  2264.  
  2265. #check if user agreed to reboot
  2266. if [ $reboot -eq 1 ]; then
  2267. SHUTDOWN_BIN=`which shutdown 2> /dev/null`
  2268. if [ $? -ne 0 ]; then
  2269. SHUTDOWN_BIN="/sbin/shutdown"
  2270. fi
  2271. ${SHUTDOWN_BIN} -r now "System rebooting" &
  2272. fi
  2273.  
  2274. exit ${status}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement