pentoo-livecd: major enhancements to binary-driver-handler, still missing fglrx support check

This commit is contained in:
Zero_Chaos 2014-09-13 18:53:43 +00:00
parent 96c34fe351
commit ba3f2f8fc4
5 changed files with 144 additions and 63 deletions

View file

@ -1,4 +1,4 @@
AUX binary-driver-handler.initd-2014.3-r4 5635 SHA256 ad18d6d3526f8a159c569fa6b4b581e79f4cbcdaf4e5c459d3bd52d705329b00 SHA512 c75cadb6a3672f283f29c58fff211cf8c2df52dd089148c449da2d7f22759742ba12211eeee8ae23090117c07ba4a420bba6bfe0e051cc185dc1b35bddbf8ce6 WHIRLPOOL dd76e16f531cf3acb5a84c350864e3f15a4eb40708a32274ff11ac710742e7847c5112b3848eed7539b502e12ec9a7fa582c262780a59f79e5340d09a07bf497
AUX flushchanges-2014.3-r2 1512 SHA256 81e9fe4d127a0cc1edfab5f342a4a565b7e68930cbeecbb210b91a8f5db1d772 SHA512 3b079d8c8436e14a159caa750afc422cdd062dba7659d8a8904f6a91eeda7f1d069fd2cfbc48e5e68477221237149f5d37e9ff8440adfae33dccae50fb4f0dc8 WHIRLPOOL 34c00f44948541dfc858fcf0b83f27ddd328690fcb90f78718a6cf4152d8574ab5cd5b4f025e7ce45e559b75eed2987ed37aa62da379f31ffd365b260c448911
AUX makemo-2014.3-r4 2139 SHA256 2036a26bebc9ff0023e483ea00c4718c3861e3cbd76c57a09115ff67c57a2e07 SHA512 e0a67370231b33fe47f44ed2b3819e75b8762a51c157cd2bb88c5d0dbe88ef8d12b34386b9c8e3efe78de52ee463fefd31d703d6bbfbbd2d57e65a6322e61cbf WHIRLPOOL a3ee660576d1d9a2152149e0e62a57620f0167da067ad81e33ff237ce2c4e61efd4f8d43906a112d248cd99a30acca2082a716faf0bac21807107d52ff89c855
EBUILD pentoo-livecd-2014.3-r3.ebuild 936 SHA256 a51c06f5456a96ef528010796a849231633fc5383770a25cc1e9356138b8e70c SHA512 219b3ce99d42d4a56980e656800410e3bf6c56d3f05412dbb40000f06ffe397f962b32a9a48ef10a5957031a020ed883fd3d6017d8bf3baba77ae2f63c6ebfd7 WHIRLPOOL 180b483933c7720221776efaf480ae7c6751f7b858bc15a72f25ba80f809ae8fa5cbb786df1573bf3aff3257b0790ab5af909c5bbacda7d7ff6337515cc8012c
AUX binary-driver-handler.initd-2014.3-r5 7875 SHA256 4611d47211f7ff5de4dc1f90e3b8e46e1e086473b8f336007ebb1d374a89f3b7 SHA512 6caa2824c85a4efbeadd407eac35a9f4b230095da9992eca9ab029475166bf081e7113e441f3d69089efcf92fa9b8528c9110f2681184653b4d49bdc3078bebd WHIRLPOOL 85ed5978936bf6feecbfa41c5d88c00b8d478a1bcf7b082eabea52c31de4844b140c758e71f16688ea874e0d859b616a0363d927f1b5054e962a9d55ccde4360
AUX flushchanges-2014.3-r5 1874 SHA256 0a229f43ccd2c158cb872c8f1f6efd5f177d199ad77a807657cfb83e95a19d62 SHA512 72816d6f157bfcd92138f47cc54d114ea2572e85d383f3b423c5ab77a6535e1ac3c259ace3258d3a9c49c332677be6408bc96610914a4abff8f62780c6fec7ed WHIRLPOOL 1bf74ccdf9c203e943ad5a8fd98a1c56fe1ede1ba9b44171e700fd2a40fa08973bfeff315d79a8efa0ca1d6af7e88cc94022e8bebf9fd06cf3ab95d9d1178a96
AUX makemo-2014.3-r5 2140 SHA256 44814912e990baa7c6f4c62ac027e01d3e31777ea9350452a1063f6efb6c4270 SHA512 808859dcb33143171275b5cae965efbadb7bf15d28e53981a38e472cba714e866ea71dc8e7fbce364197c0ed6e5f59e0c365d42fa59759da96de42d3ef05b1c8 WHIRLPOOL 8d3041667a3546d96bc7145f77772b4ba35c625745aa010e37c257a397c5d993c4f65ed60014d9073b5d1ee8f4aefc8f7ed639c09379ca01c5729adcc37d4a87
EBUILD pentoo-livecd-2014.3-r5.ebuild 936 SHA256 a51c06f5456a96ef528010796a849231633fc5383770a25cc1e9356138b8e70c SHA512 219b3ce99d42d4a56980e656800410e3bf6c56d3f05412dbb40000f06ffe397f962b32a9a48ef10a5957031a020ed883fd3d6017d8bf3baba77ae2f63c6ebfd7 WHIRLPOOL 180b483933c7720221776efaf480ae7c6751f7b858bc15a72f25ba80f809ae8fa5cbb786df1573bf3aff3257b0790ab5af909c5bbacda7d7ff6337515cc8012c

View file

@ -1,3 +1,4 @@
#!/bin/bash
#!/sbin/runscript
#seriously, fuck you AMD and Nvidia. Write a sane license that permits redistribution, we just want your shitty hardware to work
@ -21,6 +22,60 @@ start() {
sed -i "/${1}/d" "${BLACKLIST_FILE}"
}
switch_to_nvidia() {
#remove oss
if $(lsmod | grep -iq nouveau) ; then
modprobe -r nouveau || eerror "Unable to unload nouveau driver."
fi
if [ ! -f /lib/modules/$(uname -r)/video/nvidia.ko ]; then
einfo "Building evil binary nvidia driver..."
eval ${run_merge} --nodeps nvidia-drivers
fi
modprobe nvidia || NVIDIA_FAILURE=yes
if [ "${NVIDIA_FAILURE}" = "yes" ]; then
eerror "Nvidia drivers failed to load, something went wrong. Please try open source drivers."
eend 1
else
einfo "Enabling evil binary nvidia driver..."
#blacklist the open drivers
#check for nvidia in the blacklist and remove it
unblacklist nvidia
#check for nouveau in the blacklist and add it
blacklist nouveau
fi
#check for intel gpu
if $(lspci -d8086: | grep -q VGA); then
ewarn "nvidia and intel are both detected, using intel for video"
eend 0
elif [ "${NVIDIA_FAILURE}" != "yes" ]; then
/opt/bin/nvidia-xconfig
#eselect opengl set nvidia
[ "$(eselect opengl show)" != "xorg-x11" ] && eselect opengl set xorg-x11
eselect opencl set nvidia
einfo "Enabled evil NVIDIA binary GPU driver"
eend 0
fi
}
switch_to_nouveau() {
modprobe nouveau || NOUVEAU_FAILURE=yes
if [ "${NOUVEAU_FAILURE}" = "yes" ]; then
eerror "Nouveau drivers failed to load, something went wrong. Please try the binary nvidia driver."
eend 1
else ! $(lspci -d8086: | grep -q VGA); then
einfo "Enabling open source nouveau driver..."
#blacklist the binary drivers
#check for nouveau in the blacklist and remove it
unblacklist nouveau
#check for nvidia in the blacklist and add it
blacklist nvidia
eend 0
fi
}
handle_nvidia() {
einfo "Detected: nvidia gpu, please stand by..."
if [ "${NOBINDRIVERS}" = 1 ]; then
@ -32,51 +87,56 @@ start() {
if $(lspci -d8086: | grep -q VGA); then
ewarn "Intel GPU detected, if you wish to use nouveau please disable optimus or manually setup bumblebee."
einfo "Using Intel GPU."
eend 0
else
modprobe nouveau || NOUVEAU_FAILURE=yes
fi
if [ "${NOUVEAU_FAILURE}" = "yes" ]; then
eerror "Nouveau drivers failed to load, something went wrong. Please try the binary nvidia driver."
elif ! $(lspci -d8086: | grep -q VGA); then
einfo "Enabling open source nouveau driver..."
#blacklist the binary drivers
#check for nouveau in the blacklist and remove it
unblacklist nouveau
#check for nvidia in the blacklist and add it
blacklist nvidia
switch_to_nouveau
fi
else
#remove oss
if $(lsmod | grep -iq nouveau) ; then
modprobe -r nouveau || eerror "Unable to unload nouveau driver."
fi
#first we detect if the nvidia binary driver can actually support the hardware
NV_TARBALL="$(FETCHCOMMAND="false" RESUMECOMMAND="false" emerge --color=n -f nvidia-drivers --nodeps 2> /dev/zero | \
grep "SHA256 SHA512 WHIRLPOOL size ;-) ..." | awk '{print $2}')"
if [ ! -f /lib/modules/$(uname -r)/video/nvidia.ko ]; then
einfo "Building evil binary nvidia driver..."
eval ${run_merge} --nodeps nvidia-drivers
fi
if [ -n "${NV_TARBALL}" ]; then
cd $(mktemp -d -t nvidia-detectXXXX)
#stolen from unpacker.eclass
exe="tail -n +$(grep -a ^skip= "$(portageq envvar DISTDIR)/${NV_TARBALL}" | cut -d= -f2) '$(portageq envvar DISTDIR)/${NV_TARBALL}'"
eval ${exe} | pixz -d | tar --no-same-owner -xf - --wildcards --no-anchored 'README.txt'
if [ -f README.txt ]; then
#stolen from debian's nvidia-detect rules file
sed -e '0,/A. Supported\|APPENDIX A: SUPPORTED/d' \
-e '0,/Appendix A. Supported\|APPENDIX A: SUPPORTED/d' \
-e '0,/^Below\|APPENDIX B/{/ 0x/s/.* 0x\([0-9a-fA-F]\{4\}\).*/10de\1/p};d' \
README.txt \
| tr a-f A-F | sort -u > list.txt
if [ -f list.txt ]; then
#stolen from nvidia-detect code
NVIDIA_VGA=$(sudo lspci -mmn -d 10de: | awk '{ gsub("\"",""); print $3 $4 }')
for pciid in ${NVIDIA_VGA^^}
do
if $(grep -q ${pciid} list.txt) ; then
switch_to_nvidia
else
eerror "NVIDIA binary driver requested but doesn't support this hardware, trying nouveau"
switch_to_nouveau
fi
done
else
eerror "Failed to extract or sort PCIIDs from NVIDIA README.txt, please report this."
eend 1
fi
else
eerror "Failed to unpack README from NVIDIA drivers, please report this."
eend 1
fi
modprobe nvidia || NVIDIA_FAILURE=yes
if [ "${NVIDIA_FAILURE}" = "yes" ]; then
eerror "Nvidia drivers failed to load, something went wrong. Please try open source drivers."
else
einfo "Enabling evil binary nvidia driver..."
#blacklist the open drivers
#check for nvidia in the blacklist and remove it
unblacklist nvidia
#check for nouveau in the blacklist and add it
blacklist nouveau
fi
#check for intel gpu
#lspci | grep -iq "VGA.*Intel"
if $(lspci -d8086: | grep -q VGA); then
ewarn "nvidia and intel are both detected, using intel for video"
elif [ "${NVIDIA_FAILURE}" != "yes" ]; then
/opt/bin/nvidia-xconfig
#eselect opengl set nvidia
eselect opencl set nvidia
einfo "Enabled evil NVIDIA binary GPU driver"
eerror "Missing nvidia-drivers distfile, please download it first or run \"/etc/init.d/binary-driver-handler aufs-module\""
eerror "before making the livecd to create an aufs-module which contains the needed distfiles."
eend
fi
fi
}
@ -91,6 +151,7 @@ start() {
modprobe radeon || RADEON_FAILURE=yes
if [ "${RADEON_FAILURE}" = "yes" ]; then
eerror "Radeon drivers failed to load, something went wrong. Please try the binary drivers."
eend 1
else
einfo "Enabling open source radeon driver..."
#blacklist the binary driver
@ -98,6 +159,7 @@ start() {
unblacklist radeon
#check for fglrx in the blacklist and add it
blacklist fglrx
eend 0
fi
else
#remove oss
@ -112,6 +174,7 @@ start() {
modprobe fglrx || FGLRX_FAILURE=yes
if [ "${FGLRX_FAILURE}" = "yes" ]; then
eerror "FGLRX drivers failed to load, something went wrong. Please try open source drivers."
eend 1
else
einfo "Enabling evil binary ati driver..."
#blacklist the open drivers
@ -122,8 +185,10 @@ start() {
/opt/bin/aticonfig --initial
#eselect opengl set ati
[ "$(eselect opengl show)" != "xorg-x11" ] && eselect opengl set xorg-x11
eselect opencl set amd
einfo "Successfully switched to AMD binary GPU driver"
eend 0
fi
fi
}
@ -157,13 +222,16 @@ start() {
#lspci | grep -iq "VGA.*Radeon"
elif $(lspci -d1002: | grep -q VGA); then
handle_amd
else
[ "$(eselect opengl show)" != "xorg-x11" ] && eselect opengl set xorg-x11
eend 0
fi
[ "$(eselect opengl show)" != "xorg-x11" ] && eselect opengl set xorg-x11
eend 0
}
aufs_module() {
ebegin "Making aufs module with needed distfiles for binary drivers"
#temp dir
T="/dev/shm"
#target dir
@ -175,4 +243,6 @@ aufs_module() {
cp "${T}"/distfiles/{*[Ll]inux*,xvba*} "${T}"/distfiles/rootfs/usr/portage/distfiles
chown portage.portage -R "${T}"/distfiles/rootfs/usr/portage
mksquashfs "${T}"/distfiles/rootfs/ "${DEST}"/zdistfiles-`date "+%Y%m%d"`.lzm -comp xz -b 1048576 -Xdict-size 1048576 -no-recovery -noappend
eend 0
}

View file

@ -5,14 +5,18 @@
DST="/mnt/cdrom/modules"
CHANGESDIR="/.unions/memory/aufs-rw-branch/default/"
[ -e /lib/gentoo/functions.sh ] && . /lib/gentoo/functions.sh
#gentoo-functions uses "consoletype" which returns non-zero exit codes on success
#the cleanest way to handle this is to never "set -e" before sourcing gentoo-functions
source /lib/gentoo/functions.sh
set -e
usage ()
{
echo
echo " Usage : flushchanges [dest]"
echo " Where [dest] is the modules storage directory"
echo " defaulting to /mnt/cdrom/modules"
echo " defaulting to ${DST}"
echo
}
@ -59,16 +63,24 @@ else
fi
fi
done
if [ -f "${DST}/z_changes-${index}.lzm" ]
then
ewarn "The changesfile will be cleared a next reboot"
if [ -e /usr/sbin/doclean.sh ]
then
cp -a /usr/sbin/doclean.sh /.unions/memory/.doclean.sh
else
eerror "Unable to find /usr/sbin/doclean.sh"
eerror "Your changesfile will not be cleared at reboot"
exit $?
fi
fi
## I don't really get the point of this, and the doclean.sh code is terrible, so I am removing it for now
# if [ -f "${DST}/z_changes-${index}.lzm" ]
# then
# ewarn "The changesfile will be cleared a next reboot"
# if [ -e /usr/sbin/doclean.sh ]
# then
# cp -a /usr/sbin/doclean.sh /.unions/memory/.doclean.sh
# else
# eerror "Unable to find /usr/sbin/doclean.sh"
# eerror "Your changesfile will not be cleared at reboot"
# exit $?
# fi
# fi
fi
## doclean.sh
#good_msg "Cleaning the permanent changes"
#rm -rf $CHANGES/*
#good_msg "Cleaning complete"

View file

@ -1,12 +1,11 @@
#!/bin/bash
set -e
#work around a bug in gentoo-functions that craps when it thinks CONSOLETYPE=serial
#this happens when we pipe yes into makemo for binary-driver handler
CONSOLETYPE=vt
#gentoo-functions uses "consoletype" which returns non-zero exit codes on success
#the cleanest way to handle this is to never "set -e" before sourcing gentoo-functions
source /lib/gentoo/functions.sh
set -e
if [[ -z "$@" ]] ; then
eerror "Please specify a package to build." && exit 1
fi