summaryrefslogtreecommitdiffstats
path: root/os-plugins/plugins/xserver/files/suse-gfx-install.sh
blob: 9a55f0b0d232262416622a486660df92a3186697 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#!/bin/sh

#
# Currently 11.0 is supported!
#
# Working on 10.2 with pgk-installer
#

# not right any more - removed from script
# is there any busybox in this environment
#BUSYBOX="/mnt/opt/openslx//busybox/busybox"

BASE=/opt/openslx/plugin-repo/xserver
cd ${BASE} 

if [ -L /boot/vmlinuz ]; then 
    KSUFFIX=$(ls -l /boot/vmlinuz | grep -P -o -e "-[a-z]*$" )
	KVERS=$(ls -l /boot/vmlinuz | awk -F "->" '{print $2}'| grep -P -o "2.6.*")
else 
    KSUFFIX=$(ls /boot/vmlinuz-* | head -n1 | grep -P -o -e "-[a-z]*$" )
	KVERS=$(ls /boot/vmlinuz-* | head -n1 | awk -F "->" '{print $2}' | grep -P -o "2.6.*" )

fi

if [ -z "${KSUFFIX}" ]; then
    echo "Could not determine proper local kernel suffix!"
    echo "This is needed to install kernel modules for graphics drivers!"
    exit 1
#else
#	echo -e "Kernel-Suffix: ${KSUFFIX}"
#	echo -e "Kernel-version:${KVERS}"
fi


buildfglrx() {
	# build ATI kernel module
    cd ${BASE}/ati/usr/src/kernel-modules/fglrx
	rm -rf fglrx.ko >/dev/null 2>&1
    make KVER=${1} >/dev/null 2>&1
	if [ "$?" -eq "0" ]; then
	    cp fglrx.ko ../../../../modules
	else
		echo -e "Kernel module for kernel ${1} could not be built!"
	fi
    cd - >/dev/null 2>&1

}


##########################################################################
# NVidia section
##########################################################################
if [ "$1" = "nvidia" ]; then
  if [ -e nvidia/usr/lib/libGL.so.1 ]; then
    exit
  fi

  ############################################################
  ##                 SUSE 11.0 Section                      ##
  ############################################################

  # distro info should be passed by calling scripts as known within the
  # plugin environment, see e.g. rev2561
  if [ "11.0" = "`cat /etc/SuSE-release | tail -n1 | cut -d' ' -f3`" ]; then
    echo "  * Downloading nvidia rpm packages... this could take some time..."
    # add repository for nvidia drivers
    zypper --no-gpg-checks addrepo http://download.nvidia.com/opensuse/11.0/ NVIDIA > /dev/null 2>&1
    # get URLs by virtually installing nvidia-OpenGL driver
    zypper --no-gpg-checks -n -vv install -D x11-video-nvidiaG01 > logfile 2>&1 

    # zypper refresh is requested if something is not found
    if [ "1" -le "$(cat logfile | grep -o "zypper refresh"| wc -l)" ]; then 
        zypper refresh >/dev/null 2>&1 
    fi

    # take unique urls from logfile
    URLS=$(cat logfile |  grep -P -o "http://.*?rpm " | sort -u | xargs)
    for RPM in $URLS; do
      RNAME=$(echo ${RPM} | sed -e 's,^.*/\(.*\)$,\1,g')
      if [ ! -e ${RNAME} ]; then
        wget ${RPM} > /dev/null 2>&1
      fi
      # We use rpm2cpio from suse to extract
      rpm2cpio ${RNAME} | cpio -id > /dev/null 2>&1
    done
    mv ./usr/X11R6/lib/* ./usr/lib/
    mv ./usr ..
    find lib/ -name "*.ko" -exec mv {} ../modules \;

  fi

  cd .. 
fi



############################################################################
# ATI section
############################################################################
if [ "$1" = "ati" ]; then
  if [ -e ati/usr/lib/libGL.so.1.2 ]; then
    exit
  fi

  mkdir -p ati/modules ati/temp

  if [ "10.2" = "`cat /etc/SuSE-release | tail -n1 | awk '{print $3}'`" ]; then
    ### SUSE 10.2 section ###
    echo "* Extracting ATI package (expected in xserver::pkgpath) ... this could take some time..."

    PKG=`find packages/ -name ati-driver*\.run | tail -n1`
    PKG_VERSION=`head ${PKG} | grep -P -o "[0-9]\.[0-9]{3}"`
    
    chmod +x ${PKG}

    ${PKG} --extract ati/temp >/dev/null 2>&1

    cd ati/temp/
    RPM=`./ati-installer.sh ${PKG_VERSION} --buildpkg SuSE/SUSE102-IA32 2>&1 | grep Package | awk '{print $2}' | tail -n1`

    cd ..
    rpm2cpio ${RPM} 2>/dev/null | cpio -i --make-directories >/dev/null 2>&1 


    mv ./usr/X11R6/lib/* ./usr/lib/

    # cleanup
    rm -rf ${RPM}
    cd ..
    rm -rf ${PKG}

	buildfglrx ${KVERS}

  fi

  if [ "11.0" = "`cat /etc/SuSE-release | tail -n1 | awk '{print $3}'`" ]; then
    ### SUSE 11.0 Section ###

    echo "* Downloading ati rpm packages... this could take some time..."
	cd ati/temp

     # add repository for nvidia drivers
    zypper --no-gpg-checks addrepo http://www2.ati.com/suse/11.0/ ATI > /dev/null 2>&1 
    # get URLs by virtually installing fglrx-OpenGL driver
    zypper --no-gpg-checks -n -vv install -D ati-fglrxG01-kmp${KSUFFIX} \
    x11-video-fglrxG01 > logfile 2>&1

    # zypper refresh is requested if something is not found
    if [ "1" -le "$(cat logfile | grep -o "zypper refresh" | wc -l)" ]; then
        zypper refresh >/dev/null 2>&1
    fi

    # take unique urls from logfile
    URLS=$(cat logfile |  grep -P -o "http://.*?rpm " | grep fglrx | sort -u | xargs)
    for RPM in $URLS; do
      RNAME=$(echo ${RPM} | sed -e 's,^.*/\(.*\)$,\1,g')
      if [ ! -e ${RNAME} ]; then
        wget ${RPM} > /dev/null 2>&1 
      fi
      # We use rpm2cpio from suse to extract -> propably new rpm version
      rpm2cpio ${RNAME} | cpio -id > /dev/null 2>&1
    done

    mv ./usr/X11R6/lib/* ./usr/lib/
    mv ./usr ..
    mv ./etc ..

    find lib/ -name "*.ko" -exec mv {} ../modules \;

  fi
  cd ..

  rm -rf temp/
fi