Advertisement
Guest User

AMDGPU 16.40 FIX BUG NO ./amdgpu-pro-install

a guest
Aug 31st, 2017
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.29 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # Copyright 2016 Advanced Micro Devices, Inc.
  4. #
  5. # Permission is hereby granted, free of charge, to any person obtaining a
  6. # copy of this software and associated documentation files (the "Software"),
  7. # to deal in the Software without restriction, including without limitation
  8. # the rights to use, copy, modify, merge, publish, distribute, sublicense,
  9. # and/or sell copies of the Software, and to permit persons to whom the
  10. # Software is furnished to do so, subject to the following conditions:
  11. #
  12. # The above copyright notice and this permission notice shall be included in
  13. # all copies or substantial portions of the Software.
  14. #
  15. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  18. # THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  19. # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  20. # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  21. # OTHER DEALINGS IN THE SOFTWARE.
  22.  
  23. set -e
  24.  
  25. REPOSITORY="/var/opt/amdgpu-pro-local"
  26.  
  27. usage() {
  28. cat <<END_USAGE
  29. Usage: $PROG [options...]
  30.  
  31. Options:
  32. -h|--help display this help message
  33. --px PX platform support
  34.  
  35. Unless the -h|--help option is given, 'apt-get' options may be present.
  36.  
  37. END_USAGE
  38. }
  39.  
  40. function stderr() {
  41. cat - 1>&2
  42. }
  43.  
  44. function os_release() {
  45. [[ -r /etc/os-release ]] && . /etc/os-release
  46.  
  47. case "$ID" in
  48. ubuntu)
  49. PACKAGES="amdgpu-pro amdgpu-pro-lib32 amdgpu-pro-dkms"
  50. ;;
  51. steamos)
  52. PACKAGES="amdgpu-pro-driver amdgpu-pro-lib32 "`
  53. `"glx-alternative-amdgpu-pro amdgpu-pro-dkms"
  54. ;;
  55. *)
  56. echo "Unsupported OS" | stderr
  57. exit 1
  58. ;;
  59. esac
  60. }
  61.  
  62. function source_list() {
  63. local dir etc sourceparts
  64. eval $(apt-config shell dir Dir)
  65. eval $(apt-config shell etc Dir::Etc)
  66. eval $(apt-config shell sourceparts Dir::Etc::sourceparts)
  67. echo ${dir}/${etc}/${sourceparts}/amdgpu-pro.list
  68. }
  69.  
  70. function amdgpu_pro_install() {
  71. local src=$(cd ${0%/*} && pwd -P)
  72. local index=$src/Packages
  73.  
  74. amdgpu_pro_uninstall $@
  75.  
  76. if [[ -r $index ]]; then
  77. $SUDO mkdir -p $REPOSITORY && $SUDO cp -af $src/* $_
  78. $SUDO ln -s $_/$PROG $SBIN/${PROG%-*}-uninstall
  79.  
  80. echo "deb [ trusted=yes ] file:$REPOSITORY/ ./" | \
  81. $SUDO tee $(source_list)
  82. $SUDO apt-get update ||:
  83. $SUDO apt-get $@ install $PACKAGES
  84. fi
  85. }
  86.  
  87. function amdgpu_pro_uninstall() {
  88. local p
  89. local installed=()
  90.  
  91. [[ -r "$(source_list)" ]] || return 0
  92.  
  93. for p in $(cat $REPOSITORY/Packages | awk '{
  94. if ($1 == "Package:")
  95. p = $2;
  96. else if ($1 == "Architecture:")
  97. print p ":" $2
  98. }')
  99. do
  100. if dpkg -s $p >/dev/null 2>&1; then
  101. installed+=($p)
  102. fi
  103. done
  104.  
  105. if [[ ${#installed[@]} -ne 0 ]]; then
  106. $SUDO apt-get $@ remove --purge ${installed[@]}
  107. fi
  108.  
  109. $SUDO rm -rf $SBIN/${PROG%-*}-uninstall $(source_list) $REPOSITORY
  110. $SUDO apt-get update ||:
  111. }
  112.  
  113. PROG=${0##*/}
  114. SUDO=$([[ $(id -u) -ne 0 ]] && echo "sudo" ||:)
  115. SBIN="/usr/bin"
  116. os_release
  117.  
  118. while (($#))
  119. do
  120. case "$1" in
  121. -h|--help)
  122. usage
  123. exit 0
  124. ;;
  125. --px)
  126. PACKAGES="$PACKAGES xserver-xorg-video-modesetting-amdgpu-pro"
  127. shift
  128. ;;
  129. *)
  130. ARGS+="$1 "
  131. shift
  132. ;;
  133. esac
  134. done
  135.  
  136. set -- $ARGS
  137. amdgpu_pro_${0##*-} $@
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement