Skip to content

Instantly share code, notes, and snippets.

@drinkcat
Last active August 29, 2015 14:03
Show Gist options
  • Save drinkcat/4376b28383c324fd42ab to your computer and use it in GitHub Desktop.
Save drinkcat/4376b28383c324fd42ab to your computer and use it in GitHub Desktop.
Downgrade Mesa to version 8 for >precise on kernel 3.4 (improved)
#!/bin/sh -e
# Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Add this target by using -T /path/to/x11-downgrade at install/update time
#
# This target is easily removed by running
# rm /etc/apt/sources.list.d/precise.list
# rm /etc/apt/preferences.d/precise-mesa-pin
# apt-get update
# apt-get dist-upgrade
REQUIRES='x11'
DESCRIPTION='Downgrade mesa drivers'
. "${TARGETSDIR:="$PWD"}/common"
### Append to prepare.sh:
# Make sure dependencies are correct (we use -f later: we want to make sure
# we only use it to fix our own problems)
apt-get -y dist-upgrade
# Add precise package sources
# Detect mirror: Find the first source that provides the "main" component
mirror="`awk '/^deb .* main( .*)?$/ { print $2; exit }' \
/etc/apt/sources.list /etc/apt/sources.list.d/*.list 2>/dev/null`"
if [ -z "$mirror" ]; then
error 1 "Cannot detect mirror."
fi
cat > /etc/apt/sources.list.d/precise.list <<END
deb $mirror precise main
deb $mirror precise-updates main
deb $mirror precise-security main
END
cat > /etc/apt/preferences.d/precise-mesa-pin <<END
# Do not install any packages from precise by default
Package: *
Pin: release n=precise
Pin-Priority: -10
# Install mesa packages and their dependencies from precise
Package: libegl1-mesa:* libegl1-mesa-drivers:* libgl1-mesa-dri:* libgl1-mesa-glx:* libglapi-mesa:* libgles2-mesa:* libdrm-nouveau1a:* libllvm3.0:* libudev0:*
Pin: release n=precise
Pin-Priority: 1100
END
# Create a dummy libwayland-egl1 package, to satisfy dependencies
# (the libraries are actually provided by libegl1-mesa-drivers in precise)
install --minimal --asdeps equivs
DEBTMP="`mktemp -d crouton.XXXXXX --tmpdir=/tmp`"
addtrap "rm -rf --one-file-system '$DEBTMP'"
( cd "$DEBTMP"; equivs-build - ) <<END
Section: misc
Priority: optional
Standards-Version: 3.9.2
Package: libwayland-egl1-dummy
Version: 8.0.4
Depends: libegl1-mesa-drivers
Provides: libwayland-egl1
Description: Dummy package providing libwayland-egl1
END
# Fetch new package sources
apt-get update
# Forcibly replace libwayland-egl1-mesa by libwayland-egl1-dummy
dpkg -r --force-depends libwayland-egl1-mesa
if [ "$ARCH" = 'amd64' ]; then
dpkg -r --force-depends libwayland-egl1-mesa:i386
fi
dpkg -i --force-depends "$DEBTMP"/libwayland-egl1-dummy_*_all.deb
# Downgrade packages, -f is needed as dependencies are broken
apt-get -y --force-yes dist-upgrade -f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment