Skip to content

Instantly share code, notes, and snippets.

@infinity0
Created January 12, 2018 00:04
Show Gist options
  • Save infinity0/004c27287106d4f578c34cafdcebb5a2 to your computer and use it in GitHub Desktop.
Save infinity0/004c27287106d4f578c34cafdcebb5a2 to your computer and use it in GitHub Desktop.
#!/bin/sh
set -e
export KERNEL=$(uname -r)
export TARGET=/lib/modules/$KERNEL/kernel/drivers/gpu/drm/nouveau/nouveau.ko
case $KERNEL in 4.1[0123].*|4.[123456789].*|3.*|2.*) echo >&2 "requires kernel >= 4.14, have $KERNEL"; exit 1;; esac
( test -d nouveau || git clone "https://github.com/skeggsb/nouveau" )
( cd nouveau && git checkout devel-clk && git reset --hard && git clean -fqdx && \
git diff 1e53ec42 -- drm/nouveau/ > k.patch )
( test -d linux || git clone -o torvalds "https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git" )
( cd linux && git checkout -B nv-reclock v4.15-rc2 && git reset --hard && git clean -fqdx && \
cd drivers/gpu && patch -r- -l -p1 -N < ../../../nouveau/k.patch && case $KERNEL in 4.14.*) sed -i -e 's/drm_encoder_find(dev, NULL, id)/drm_encoder_find(dev, id)/g' drm/nouveau/nouveau_connector.c;; esac && \
sed -ne 's,^\(---\|+++\) [ab]/,,p' ../../../nouveau/k.patch | xargs -rn1 git add && git commit -m "Import skeggsb/devel-clk" && EDITOR=cat git merge torvalds/master && \
cd drm/nouveau && make -j$(nproc) -C /lib/modules/$KERNEL/build/ M=$PWD && cp nouveau.ko nouveau.ko.dist && strip --strip-debug nouveau.ko.dist )
( set -x && test -f $TARGET.old || sudo cp $TARGET $TARGET.old && sudo cp linux/drivers/gpu/drm/nouveau/nouveau.ko.dist $TARGET )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment