3 kernver
=${KERNVER:-$(uname -r)}
4 arch
=${ARCH:-$(uname -m)}
6 LOG
="/var/log/catalyst-install.log"
9 # file_patch="${kernver:0:6}.patch"
10 # if [[ -f "${file_patch}" ]]; then
11 # patch -Np6 -i ${file_patch} || return 1
19 date '+%Y-%m-%d %H:%M:%S'
20 echo "Building fglrx module for ${kernver} kernel ..."
22 if [ ! -d "/lib/modules/${kernver}/build" ]; then
23 echo "Kernel header files are absent: directory /lib/modules/${kernver}/build doesn't exist! Game over"
26 workdir
=$
(mktemp
-du /tmp
/catalyst.XXXXXX
)
28 cp "/usr/share/ati/build_mod" "${workdir}" -R
30 patch -Np7 -i makefile_compat.
patch ||
return 1
32 # if [[ ${kernver:0:6} < "2.6.39" ]] && [[ `cat /lib/modules/${kernver}/build/.config | grep -c CONFIG_BKL=y` = 0 ]]; then
33 # patch -Np6 -i no_bkl.patch || return 1
36 # if [[ ${kernver:0:6} == "2.6.39" ]] || [[ ${kernver:0:6} > "2.6.39" ]]; then
37 # patch -Np6 -i no_bkl.patch || return 1
38 # patch -Np6 -i 2.6.39_bkl.patch || return 1
43 ## include ati_make.sh and use _ati_check function from it
47 ## Compile module using _ati_check variables
48 make -C /lib
/modules
/${kernver}/build SUBDIRS
="`pwd`" ARCH
=${arch} \
49 MODFLAGS
="-DMODULE -DATI -DFGL -DPAGE_ATTR_FIX=$PAGE_ATTR_FIX -DCOMPAT_ALLOC_USER_SPACE=$COMPAT_ALLOC_USER_SPACE $def_smp $def_modversions" \
50 PAGE_ATTR_FIX
=$PAGE_ATTR_FIX COMPAT_ALLOC_USER_SPACE
=$COMPAT_ALLOC_USER_SPACE modules ||
return 1
53 ## here we are checking kernel's extramodules dir
54 for r
in /lib
/modules
/*; do
56 if [[ ${s:0:3} = "ext" ]]; then
57 if [[ `cat ${r}/version | grep -c ${kernver}` != 0 ]]; then
60 elif [[ ${s} = ${kernver} ]] && [[ ! -e ${r}/extramodules
]]; then
61 destidir
=${kernver}/video
65 install -m755 -d "/lib/modules/${destidir}/" ||
return 1
66 install -m644 fglrx.ko
"/lib/modules/${destidir}/" ||
return 1
75 for p
in /lib
/modules
/*; do
76 if [ ${p:13:3} != "ext" ] && [ -d $p/build
] && [ -d $p/kernel
]; then
77 /usr
/bin
/catalyst_build_module
${p##*/lib/modules/}
83 for p
in /lib
/modules
/*; do
84 if [[ ${p:13:3} != "ext" ]]; then
85 if [ ! -d $p/kernel
]; then #check if /lib/modules/p/kernel directory does NOT exist
86 if [[ -e $p/video
/fglrx.ko
]] ||
[[ -e $p/extramodules
/fglrx.ko
]]; then
87 echo "+ removing fglrx module from $p"
88 rm "$p/video/fglrx.ko" &>/dev
/null
89 rm "$p/extramodules/fglrx.ko" &>/dev
/null
90 rmdir -p "$p/video/" --ignore-fail-on-non-empty &>/dev
/null
92 if [ -d $p ]; then #check if /lib/modules/p exist
93 if [ -z "$(ls $p)" ]; then #check if /lib/modules/p is empty
94 echo "+ removing empty directory: $p"
96 else echo "- $p looks like unused, maybe remove it manualy?"
104 remove_all_modules
(){
105 for p
in /lib
/modules
/*; do
106 if [[ ${p:13:3} != "ext" ]]; then
107 if [[ -e $p/video
/fglrx.ko
]] ||
[[ -e $p/extramodules
/fglrx.ko
]]; then
108 echo "+ removing fglrx module from $p"
109 rm "$p/video/fglrx.ko" &>/dev
/null
110 rm "$p/extramodules/fglrx.ko" &>/dev
/null
111 rmdir -p "$p/video/" --ignore-fail-on-non-empty &>/dev
/null
112 depmod $
(basename $p)
114 if [ -d $p ]; then #check if /lib/modules/p exist
115 if [ -z "$(ls $p)" ]; then #check if /lib/modules/p is empty
116 echo "+ removing empty directory: $p"
118 elif [ ! -d $p/kernel
]; then
119 echo "- $p looks like unused, maybe remove it manualy?"
127 # add hook fglrx to mkiniticpio
128 hooks
=$
(grep ^HOOKS
/etc
/mkinitcpio.conf |
grep fglrx
)
129 if [ "$hooks" = "" ]; then
131 sed 's/^HOOKS="\([^"]*\)"/HOOKS="\1 fglrx"/' -i /etc
/mkinitcpio.conf
133 #add kernel26-headers to SyncFirst array of pacman.conf
134 heads
=$
(grep ^SyncFirst
/etc
/pacman.conf |
grep kernel26-headers
)
135 if [ "$heads" = "" ]; then
137 sed '/^SyncFirst/s|$| kernel26-headers|' -i /etc
/pacman.conf
139 echo "----------------------------------------------------------------"
140 echo "Answer 'Yes' whenever pacman ask you about updating"
141 echo "'kernel26-headers' in first place"
142 echo "----------------------------------------------------------------"
145 auto_recompile_off
(){
147 sed '/^HOOKS/s/ *fglrx//' -i /etc
/mkinitcpio.conf
149 sed '/^SyncFirst/s/ *kernel26-headers//' -i /etc
/pacman.conf
150 echo "Auto re-compilation is Disabled."
155 echo "usage: $0 {version|all|remove|remove_all|auto|autooff}"
156 echo "- with no specified kernel version it will use the current kernel version to build module"
157 echo "- all will try to build fglrx modules for all working system's kernels"
158 echo "- remove is removing unused fglrx modules and all empty /lib/modules/* directories"
159 echo "- remove_all is removing all fglrx modules and all empty /lib/modules/* directories"
160 echo "- auto will turn ON 'auto re-compilation of fglrx module with every kernel update'"
161 echo "- autooff will turn off auto re-compilation of fglrx module"
179 test "$1" != "" && kernver
="$1"
180 echo "Building fglrx module for ${kernver} kernel ..."
181 install_module
>> $LOG 2>&1 && echo "Ok." ||
echo "Failed!!! Check out log: $LOG"