Import bumblebee_3.2.1-25+rpi1.debian.tar.xz
authorPeter Michael Green <plugwash@raspbian.org>
Sat, 22 Aug 2020 19:42:31 +0000 (20:42 +0100)
committerPeter Michael Green <plugwash@raspbian.org>
Sat, 22 Aug 2020 19:42:31 +0000 (20:42 +0100)
[dgit import tarball bumblebee 3.2.1-25+rpi1 bumblebee_3.2.1-25+rpi1.debian.tar.xz]

39 files changed:
README.Debian [new file with mode: 0644]
bug-control [new file with mode: 0644]
bug-script [new file with mode: 0644]
bumblebee-nvidia.lintian-overrides [new file with mode: 0644]
bumblebee-nvidia.postinst.Debian [new file with mode: 0644]
bumblebee-nvidia.postinst.Ubuntu [new file with mode: 0644]
bumblebee-nvidia.postrm.Ubuntu [new file with mode: 0644]
bumblebee.bash-completion [new file with mode: 0644]
bumblebee.bumblebeed.init [new file with mode: 0644]
bumblebee.dirs [new file with mode: 0644]
bumblebee.docs [new file with mode: 0644]
bumblebee.install [new file with mode: 0644]
bumblebee.maintscript [new file with mode: 0644]
bumblebee.manpages [new file with mode: 0644]
bumblebee.postinst [new file with mode: 0644]
bumblebee.postrm [new file with mode: 0644]
bumblebee.triggers [new file with mode: 0644]
changelog [new file with mode: 0644]
control [new file with mode: 0644]
copyright [new file with mode: 0644]
not-installed [new file with mode: 0644]
patches/amd-apu.patch [new file with mode: 0644]
patches/fix-device-detection.patch [new file with mode: 0644]
patches/fix-typos.patch [new file with mode: 0644]
patches/gcc-10.patch [new file with mode: 0644]
patches/ignore-error-on-X-shutdown.patch [new file with mode: 0644]
patches/ignore-failure-to-set-DRM-interface.patch [new file with mode: 0644]
patches/ignore-systemd-logind-noise.patch [new file with mode: 0644]
patches/libkmod.patch [new file with mode: 0644]
patches/man-section.patch [new file with mode: 0644]
patches/modprobe-r-instead-of-rmmod.patch [new file with mode: 0644]
patches/no-bbswitch.patch [new file with mode: 0644]
patches/primus-vk.patch [new file with mode: 0644]
patches/series [new file with mode: 0644]
patches/xorg-binary-config.patch [new file with mode: 0644]
rules [new file with mode: 0755]
source/format [new file with mode: 0644]
upstream/metadata [new file with mode: 0644]
watch [new file with mode: 0644]

diff --git a/README.Debian b/README.Debian
new file mode 100644 (file)
index 0000000..32bd53b
--- /dev/null
@@ -0,0 +1,96 @@
+bumblebee for Debian/Ubuntu
+---------------------------
+
+Post-installation instructions:
+-------------------------------
+
+You must add your user to the bumblebee group in order to use optirun or
+primusrun, i.e.
+
+ $ sudo adduser $USER bumblebee
+
+where $USER corresponds to your username. Don't forget to log out and log back
+in for this to take effect.
+
+If you have sudo configured for your current user, i.e. your user is a member
+of the sudo group, this step is not needed (the bumblebee package postinst
+script takes care of adding sudo users to the bumblebee group automatically).
+To clarify, sudo is not needed to use bumblebee; it simply makes adding your
+user to the bumblebee group unnecessary.
+
+This step is unnecessary for Ubuntu users since sudo comes pre-configured and
+ready to be used by default (for user accounts created during install).
+
+To test whether bumblebee has been configured correctly, try running the
+glxgears demo (you must first install mesa-utils):
+
+ $ optirun glxgears -info
+
+
+Primus vs. VirtualGL:
+---------------------
+
+Bumblebee in Debian and Ubuntu defaults to using the primus backend, because
+virtualgl has not yet been packaged for Debian/Ubuntu proper. For Ubuntu users,
+it is however easy to switch to using virtualgl by using upstream's PPAs.
+Follow the instructions at:
+https://launchpad.net/~bumblebee/+archive/stable
+
+
+Common issues:
+--------------
+
+- If optirun returns the following error:
+[ERROR]Cannot access secondary GPU - error: Could not load GPU driver
+
+You must edit /etc/bumblebee/bumblebee.conf using your preferred editor as
+root, and change "KernelDriver=nvidia" to "KernelDriver=nvidia-current",
+then restart the bumblebee daemon, i.e.
+
+ $ sudo service bumblebeed restart 
+
+(Refer to https://bugs.debian.org/717687 for a brief explanation.)
+
+- If optirun returns the following error:
+[ERROR]Cannot access secondary GPU - error: [XORG] (EE) No devices detected
+
+You may have to set the BusID manually, in /etc/bumblebee/xorg.conf.nvidia.
+To get the BusID, run lspci | egrep 'VGA|3D' in a terminal. Refer to the
+comments in that file for further instructions.
+
+- If optirun returns the following error:
+[ERROR]Cannot access secondary GPU - error: [XORG] (EE) /dev/dri/card0:
+failed to set DRM interface version 1.4: Permission denied
+
+You have to append the following section to /etc/bumblebee/xorg.conf.nvidia:
+
+Section "Screen"
+    Identifier "Default Screen"
+    Device "DiscreteNvidia"
+EndSection
+
+Also refer to https://bugs.debian.org/756522 for a brief explanation.
+
+- If optirun errors out and dmesg reports that the GPU has "fallen off the bus"
+or "nvidia_frontend_open: minor 0, module->open() failed, error -5" on Linux
+>= 3.10 and < 3.19, either stick with an older kernel version (<= 3.9) or
+upgrade to > 3.19, or add rcutree.rcu_idle_gp_delay=1 to your grub command line
+(in /etc/default/grub, then run update-grub and reboot) as a workaround.
+
+This is a known problem upstream and suspected to be an issue with the
+proprietary nvidia driver. Refer to Bumblebee github issue #455 and #615,
+https://github.com/Bumblebee-Project/Bumblebee/issues/455 and
+https://github.com/Bumblebee-Project/Bumblebee/issues/615.
+
+A more up-to-date list of common issues can be found on the Debian/Ubuntu wiki
+pages relating to bumblebee, i.e.:
+
+https://wiki.debian.org/Bumblebee
+https://wiki.ubuntu.com/Bumblebee
+
+A more comprehensive list is available upstream:
+
+https://github.com/Bumblebee-Project/Bumblebee/wiki/Troubleshooting
+
+
+ -- Vincent Cheng <vcheng@debian.org>  Sat, 25 Oct 2014 10:13:42 -0700
diff --git a/bug-control b/bug-control
new file mode 100644 (file)
index 0000000..fd9a17c
--- /dev/null
@@ -0,0 +1 @@
+package-status: nvidia-driver-any nvidia-driver-libs-any xserver-xorg-video-nvidia-any primus-libs
diff --git a/bug-script b/bug-script
new file mode 100644 (file)
index 0000000..a1442f5
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+export LC_ALL=C
+
+exec >&3
+
+echo "OpenGL and NVIDIA library files installed:"
+ls -l  /etc/alternatives/glx* \
+       /etc/alternatives/nvidia* \
+       2>/dev/null
+echo
+
+echo "/etc/modprobe.d:"
+ls -la /etc/modprobe.d/
+echo
+grep -ri nvidia /etc/modprobe.d/
+grep -ri nouveau /etc/modprobe.d/
+echo
+
+exit 0
diff --git a/bumblebee-nvidia.lintian-overrides b/bumblebee-nvidia.lintian-overrides
new file mode 100644 (file)
index 0000000..d01c112
--- /dev/null
@@ -0,0 +1,2 @@
+bumblebee-nvidia: postinst-has-useless-call-to-ldconfig
+bumblebee-nvidia: postrm-has-useless-call-to-ldconfig
diff --git a/bumblebee-nvidia.postinst.Debian b/bumblebee-nvidia.postinst.Debian
new file mode 100644 (file)
index 0000000..433f1ba
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/sh
+set -e
+
+case "$1" in
+  configure)
+    if dpkg --compare-versions "$2" lt-nl "3.2.1-21~" ; then
+        update-alternatives --force --auto glx 2>/dev/null || true
+        dpkg-trigger register-glx-alternative-nvidia
+    fi
+
+    # this has a chance of crashing the machine with mainline kernels...
+    grep -q '^nouveau ' /proc/modules && rmmod nouveau || true
+    ;;
+esac
+
+#DEBHELPER#
diff --git a/bumblebee-nvidia.postinst.Ubuntu b/bumblebee-nvidia.postinst.Ubuntu
new file mode 100644 (file)
index 0000000..f1279b5
--- /dev/null
@@ -0,0 +1,36 @@
+#!/bin/sh
+set -e
+
+xconffile=/etc/bumblebee/xorg.conf.nvidia
+
+case "$1" in
+  configure)
+      # Repair GL on the intel display
+      for arch in x86_64-linux-gnu i386-linux-gnu; do
+        update-alternatives --force --set \
+          ${arch}_gl_conf /usr/lib/$arch/mesa/ld.so.conf 2>/dev/null || true
+      done
+
+      # assume first device to be discrete in nvidia/nvidia
+      busid=$(lspci -d10de: -nn | grep '\[030[02]\]' | cut -d' ' -f1 | tr . : | head -1)
+
+      if [ -z "$busid" ]; then
+        echo "No Nvidia card found. If you really have an Optimus system,"
+        echo "try selecting the Optimus setup in BIOS and run:"
+        echo "sudo dpkg-reconfigure bumblebee-nvidia"
+      else
+        echo "Selecting $busid as discrete nvidia card. If this is incorrect,"
+        echo "edit the BusID line in $xconffile"
+        sed -i $xconffile -r -e "s/^([\t ]*)#([\t ]*BusID[\t ]*)\"[^\"]*\"$/\\1 \\2\"PCI\:$busid\"/"
+      fi
+
+    ldconfig
+    # this has a chance of crashing the machine with mainline kernels...
+    grep -q '^nouveau ' /proc/modules && rmmod nouveau || true
+    if [ -e "/etc/init/bumblebeed.conf" ]; then
+        invoke-rc.d bumblebeed restart || true
+    fi
+    ;;
+esac
+
+#DEBHELPER#
diff --git a/bumblebee-nvidia.postrm.Ubuntu b/bumblebee-nvidia.postrm.Ubuntu
new file mode 100644 (file)
index 0000000..2a88c43
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/sh
+set -e
+
+case "$1" in
+  remove|abort-install)
+      # Restore the alternatives in case bumblebee is installed on a
+      # non-Optimus system that requires the nvidia driver
+      for arch in x86_64-linux-gnu i386-linux-gnu; do
+        update-alternatives --force --auto ${arch}_gl_conf 2>/dev/null || true
+      done
+
+    ldconfig
+    ;;
+esac
+
+#DEBHELPER#
diff --git a/bumblebee.bash-completion b/bumblebee.bash-completion
new file mode 100644 (file)
index 0000000..ec3d503
--- /dev/null
@@ -0,0 +1 @@
+etc/bash_completion.d/bumblebee
diff --git a/bumblebee.bumblebeed.init b/bumblebee.bumblebeed.init
new file mode 100644 (file)
index 0000000..a29ca39
--- /dev/null
@@ -0,0 +1,156 @@
+#!/bin/sh
+### BEGIN INIT INFO
+# Provides:          bumblebeed
+# Required-Start:    $local_fs $remote_fs $syslog
+# Required-Stop:     $local_fs $remote_fs $syslog
+# Should-Start:      kdm gdm lightdm nvidia-kernel
+# Should-Stop:       kdm gdm lightdm nvidia-kernel
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: Bumblebee supporting NVIDIA Optimus cards
+# Description:       Daemon responsible for handling power management for
+#                    NVIDIA Optimus cards and handling optirun requests which
+#                    allows the discrete card to be used
+### END INIT INFO
+
+# Author: Aron Xu <aron@debian.org>
+
+# PATH should only include /usr/* if it runs after the mountnfs.sh script
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
+DESC=bumblebeed             # Introduce a short description here
+NAME=bumblebeed             # Introduce the short server's name here
+DAEMON=/usr/sbin/bumblebeed # Introduce the server's location here
+DAEMON_ARGS="--daemon"             # Arguments to run the daemon with
+PIDFILE=/var/run/$NAME.pid
+SCRIPTNAME=/etc/init.d/$NAME
+
+# Exit if the package is not installed
+[ -x $DAEMON ] || exit 0
+
+# Read configuration variable file if it is present
+[ -r /etc/default/$NAME ] && . /etc/default/$NAME
+
+# Load the VERBOSE setting and other rcS variables
+. /lib/init/vars.sh
+
+# Define LSB log_* functions.
+# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
+. /lib/lsb/init-functions
+
+#
+# Function that starts the daemon/service
+#
+do_start()
+{
+       # Return
+       #   0 if daemon has been started
+       #   1 if daemon was already running
+       #   2 if daemon could not be started
+       start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
+               || return 1
+       start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
+               $DAEMON_ARGS \
+               || return 2
+       # Add code here, if necessary, that waits for the process to be ready
+       # to handle requests from services started subsequently which depend
+       # on this one.  As a last resort, sleep for some time.
+}
+
+#
+# Function that stops the daemon/service
+#
+do_stop()
+{
+       # Return
+       #   0 if daemon has been stopped
+       #   1 if daemon was already stopped
+       #   2 if daemon could not be stopped
+       #   other if a failure occurred
+       start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
+       RETVAL="$?"
+       [ "$RETVAL" = 2 ] && return 2
+       # Wait for children to finish too if this is a daemon that forks
+       # and if the daemon is only ever run from this initscript.
+       # If the above conditions are not satisfied then add some other code
+       # that waits for the process to drop all resources that could be
+       # needed by services started subsequently.  A last resort is to
+       # sleep for some time.
+       start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
+       [ "$?" = 2 ] && return 2
+       # Many daemons don't delete their pidfiles when they exit.
+       rm -f $PIDFILE
+       return "$RETVAL"
+}
+
+#
+# Function that sends a SIGHUP to the daemon/service
+#
+do_reload() {
+       #
+       # If the daemon can reload its configuration without
+       # restarting (for example, when it is sent a SIGHUP),
+       # then implement that here.
+       #
+       start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
+       return 0
+}
+
+case "$1" in
+  start)
+    [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC " "$NAME"
+    do_start
+    case "$?" in
+               0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
+               2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+       esac
+  ;;
+  stop)
+       [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
+       do_stop
+       case "$?" in
+               0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
+               2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+       esac
+       ;;
+  status)
+       status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
+       ;;
+  #reload|force-reload)
+       #
+       # If do_reload() is not implemented then leave this commented out
+       # and leave 'force-reload' as an alias for 'restart'.
+       #
+       #log_daemon_msg "Reloading $DESC" "$NAME"
+       #do_reload
+       #log_end_msg $?
+       #;;
+  restart|force-reload)
+       #
+       # If the "reload" option is implemented then remove the
+       # 'force-reload' alias
+       #
+       log_daemon_msg "Restarting $DESC" "$NAME"
+       do_stop
+       case "$?" in
+         0|1)
+               do_start
+               case "$?" in
+                       0) log_end_msg 0 ;;
+                       1) log_end_msg 1 ;; # Old process is still running
+                       *) log_end_msg 1 ;; # Failed to start
+               esac
+               ;;
+         *)
+               # Failed to stop
+               log_end_msg 1
+               ;;
+       esac
+       ;;
+  *)
+       #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
+       echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
+       exit 3
+       ;;
+esac
+
+:
diff --git a/bumblebee.dirs b/bumblebee.dirs
new file mode 100644 (file)
index 0000000..126f580
--- /dev/null
@@ -0,0 +1,2 @@
+/etc/bumblebee/xorg.conf.d
+/etc/modprobe.d
diff --git a/bumblebee.docs b/bumblebee.docs
new file mode 100644 (file)
index 0000000..ea89266
--- /dev/null
@@ -0,0 +1,2 @@
+usr/share/doc/bumblebee/README.markdown
+usr/share/doc/bumblebee/RELEASE_NOTES_3_2_1
diff --git a/bumblebee.install b/bumblebee.install
new file mode 100644 (file)
index 0000000..9264e0b
--- /dev/null
@@ -0,0 +1,10 @@
+etc/bumblebee/bumblebee.conf
+etc/bumblebee/xorg.conf.nvidia
+etc/bumblebee/xorg.conf.nouveau
+lib/udev/rules.d/99-bumblebee-nvidia-dev.rules
+usr/bin/optirun
+usr/bin/bumblebee-bugreport
+usr/sbin/bumblebeed
+etc/bumblebee/*                       usr/share/bumblebee/default-conf/
+debian/bumblebee.conf                 usr/share/bumblebee/modprobe.d/
+scripts/systemd/bumblebeed.service    lib/systemd/system/
diff --git a/bumblebee.maintscript b/bumblebee.maintscript
new file mode 100644 (file)
index 0000000..c4e4f5d
--- /dev/null
@@ -0,0 +1,4 @@
+rm_conffile /etc/modprobe.d/bumblebee.conf 3.2.1-6~
+rm_conffile /etc/bash_completion.d/bumblebee 3.2.1-8~
+rm_conffile /etc/init/bumblebeed.conf 3.2.1-18~
+rm_conffile /etc/bumblebee/xorg.conf.d/10-dummy.conf 3.2.1-23~
diff --git a/bumblebee.manpages b/bumblebee.manpages
new file mode 100644 (file)
index 0000000..0e70b1f
--- /dev/null
@@ -0,0 +1,2 @@
+usr/share/man/man1/optirun.1
+usr/share/man/man8/bumblebeed.8
diff --git a/bumblebee.postinst b/bumblebee.postinst
new file mode 100644 (file)
index 0000000..262f0b5
--- /dev/null
@@ -0,0 +1,79 @@
+#!/bin/sh
+# postinst script for bumblebee
+#
+# see: dh_installdeb(1)
+
+set -e
+
+xconffile=/etc/bumblebee/xorg.conf.nouveau
+
+# group that allows users to use Bumblebee
+BB_GROUP=bumblebee
+
+# add members of these groups automatically to group "bumblebee" for new
+# installations
+USE_GROUPS='adm sudo admin'
+
+case "$1" in
+  configure)
+    # only add a group and members if the configured group does match the
+    # default group and if the group is missing
+    if grep -qx ServerGroup=$BB_GROUP /etc/bumblebee/bumblebee.conf &&
+        ! getent group $BB_GROUP > /dev/null; then
+        groupadd --system $BB_GROUP
+        users=$(getent -s files group $USE_GROUPS | cut -d: -f4 | tr , '\n' | sort -u)
+        echo "Adding members from group(s) '$USE_GROUPS' to '$BB_GROUP':"
+        echo $users
+        for user in $users; do
+            gpasswd -a $user $BB_GROUP
+        done
+    fi
+
+
+    # Raring specific issue
+    # Also, do not rely solely on dpkg-vendor (see LP: #1061769)
+    if (which dpkg-vendor >/dev/null && dpkg-vendor --derives-from Ubuntu) || \
+      [ -e /etc/dpkg/origins/ubuntu ]; then
+        # assume first device to be discrete in nvidia/nvidia
+        busid=$(lspci -d10de: -nn | grep '\[030[02]\]' | cut -d' ' -f1 | tr . : | head -1)
+        if [ -z "$busid" ]; then
+            echo "No Nvidia card found. If you really have an Optimus system,"
+            echo "try selecting the Optimus setup in BIOS and run:"
+            echo "sudo dpkg-reconfigure bumblebee"
+        else
+            echo "Selecting $busid as discrete nvidia card. If this is incorrect,"
+            echo "edit the BusID line in $xconffile ."
+            sed -i $xconffile -r -e "s/^([\t ]*)#([\t ]*BusID[\t ]*)\"[^\"]*\"$/\\1 \\2\"PCI\:$busid\"/"
+        fi
+        
+        # Only for 3.2.1, remove busid.conf if still present.
+        if [ -e /etc/bumblebee/xorg.conf.d/busid.conf ]; then
+            echo "Deleting old /etc/bumblebee/xorg.conf.d/busid.conf"
+            rm /etc/bumblebee/xorg.conf.d/busid.conf
+        fi
+    fi
+
+    # Do not treat /etc/modprobe.d/bumblebee-nvidia.conf as a conffile
+    # LP: #1242785, https://github.com/Bumblebee-Project/Bumblebee/issues/525
+    cp -f /usr/share/bumblebee/modprobe.d/bumblebee.conf /etc/modprobe.d/bumblebee.conf
+
+    ;;
+  triggered)
+    case "$2" in
+      restart-bumblebeed)
+        # Trigger a restart of the bumblebee service, only if it's already running
+
+        if [ -d /run/systemd/system ]; then
+          if deb-systemd-invoke is-active bumblebeed.service > /dev/null 2>&1; then
+              deb-systemd-invoke restart bumblebeed.service || exit $?
+          fi
+        elif [ -x "/etc/init.d/bumblebeed" ]; then
+          if invoke-rc.d bumblebeed status > /dev/null 2>&1; then
+              invoke-rc.d bumblebeed restart || exit $?
+          fi
+        fi
+        ;;
+    esac
+esac
+
+#DEBHELPER#
diff --git a/bumblebee.postrm b/bumblebee.postrm
new file mode 100644 (file)
index 0000000..b014aaa
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/sh
+# postrm script for bumblebee
+#
+# see: dh_installdeb(1)
+
+set -e
+
+case "$1" in
+  purge)
+    groupdel bumblebee || true
+    # keep this as old versions did not mark these files as conffiles
+    for file in bumblebee.conf xorg.conf.nvidia xorg.conf.nouveau; do
+        rm -f /etc/bumblebee/$file
+    done
+
+    ;;
+  remove)
+    # Do not treat /etc/modprobe.d/bumblebee-nvidia.conf as a conffile
+    # LP: #1242785, https://github.com/Bumblebee-Project/Bumblebee/issues/525
+    rm -f /etc/modprobe.d/bumblebee.conf
+
+    ;;
+esac
+
+#DEBHELPER#
diff --git a/bumblebee.triggers b/bumblebee.triggers
new file mode 100644 (file)
index 0000000..d7fea6c
--- /dev/null
@@ -0,0 +1,2 @@
+activate-noawait update-initramfs
+interest-noawait restart-bumblebeed
diff --git a/changelog b/changelog
new file mode 100644 (file)
index 0000000..81c22a3
--- /dev/null
+++ b/changelog
@@ -0,0 +1,310 @@
+bumblebee (3.2.1-25+rpi1) bullseye-staging; urgency=medium
+
+  * Disable bumblebee-nvidia package.
+
+ -- Peter Michael Green <plugwash@raspbian.org>  Sat, 22 Aug 2020 19:42:31 +0000
+
+bumblebee (3.2.1-25) unstable; urgency=medium
+
+  * bumblebee-nvidia: Add Tesla 450 driver as alternative dependency.
+
+ -- Andreas Beckmann <anbe@debian.org>  Fri, 24 Jul 2020 14:23:13 +0200
+
+bumblebee (3.2.1-24) unstable; urgency=medium
+
+  * bumblebee-nvidia: Add arch restrictions to dependencies.
+  * bumblebee-nvidia: Build for armhf, arm64 and ppc64el, too.
+    (Closes: #963681)
+  * bumblebee: Depend on pciutils for lspci usage in postinst on Ubuntu.
+    (Closes: #964377)
+
+ -- Andreas Beckmann <anbe@debian.org>  Tue, 07 Jul 2020 17:35:19 +0200
+
+bumblebee (3.2.1-23) unstable; urgency=medium
+
+  [ Andreas Beckmann ]
+  * Do not recommend unavailable virtualgl on Debian.  (Closes: #881337)
+  * Fix FTBFS with gcc-10.  (Closes: #957058)
+  * Switch to debhelper-compat (= 13).
+  * Use dh_bash-completion.
+  * Simplify rules and use bumblebee.install etc. for installation.
+  * Remove obsolete conffile /etc/bumblebee/xorg.conf.d/10-dummy.conf.
+  * bumblebee-nvidia: Recommend nvidia-primus-vk-wrapper.
+  * optirun: Export ENABLE_PRIMUS_LAYER=1 when using primus backend to let
+    primus-vk (if available) handle Vulkan applications.  (Closes: #892646)
+
+  [ Debian Janitor ]
+  * Set upstream metadata fields: Bug-Database, Bug-Submit, Repository,
+    Repository-Browse.
+
+ -- Andreas Beckmann <anbe@debian.org>  Thu, 11 Jun 2020 20:55:55 +0200
+
+bumblebee (3.2.1-22) unstable; urgency=medium
+
+  * Ship empty /etc/modprobe.d directory.
+  * Generate vendor-specific modprobe.d/bumblebee.conf.
+  * Collect more information with reportbug.
+
+ -- Andreas Beckmann <anbe@debian.org>  Wed, 18 Mar 2020 23:37:06 +0100
+
+bumblebee (3.2.1-21) unstable; urgency=medium
+
+  [ Andreas Beckmann ]
+  * Recommend primus-libs instead of primus.
+  * Downgrade bbswitch dependency to Recommends.
+  * Add only local users to the bumblebee group.  (Closes: #928119)
+  * Generate vendor-specific driver dependency lists for bumblebee-nvidia.
+  * Add alternative dependency on Tesla driver.  (Closes: #946556)
+  * Move bumblebeed manpage to section 8.
+  * Fall back to /usr/lib/<triplet>/libGL.so.1 as the "nvidia" libGL.so.1 for
+    glvnd-enabled nvidia drivers that no longer provide a proprietary
+    libGL.so.1 replacement.  (Closes: #947661)
+  * Stop manipulating the glx alternative (Debian).
+  * Add Ubuntu's dependencies for 418, 430, 435, and 440 driver series.
+  * Bump Standards-Version to 4.5.0, no changes needed.
+  * Add myself to Uploaders.
+
+  [ Debian Janitor ]
+  * Set upstream metadata fields: Repository.
+
+ -- Andreas Beckmann <anbe@debian.org>  Tue, 10 Mar 2020 13:58:32 +0100
+
+bumblebee (3.2.1-20) unstable; urgency=medium
+
+  [ Andreas Beckmann ]
+  * Drop versioned constraints that are satisfied in wheezy.
+  * Switch to debhelper-compat (= 12).
+
+  [ Luca Boccassi ]
+  * Enable all hardening build flags.
+  * bumblebee-nvidia: add Ubuntu's dependencies for 390 and 410 series.
+
+ -- Luca Boccassi <bluca@debian.org>  Wed, 06 Feb 2019 11:57:48 +0000
+
+bumblebee (3.2.1-19) unstable; urgency=medium
+
+  * Use wildcard to install bash completion file.
+  * Backport patch to support AMD APU setups.
+  * Backport patch to support nvidia drivers without bbswitch.
+  * Bump Standards-Version to 4.3.0, no changes.
+  * Set debhelper compat to 11.
+
+ -- Luca Boccassi <bluca@debian.org>  Mon, 31 Dec 2018 18:12:20 +0000
+
+bumblebee (3.2.1-18) unstable; urgency=medium
+
+  [ Andreas Beckmann ]
+  * Add support for the 390xx legacy driver package available in Debian.
+    (Closes: #916448)
+  * The dbgsym migration was done in stretch.
+  * Switch Vcs-* URLs to salsa.debian.org.
+  * Set Rules-Requires-Root: no.
+
+  [ Luca Boccassi ]
+  * Bump Standards-Version to 4.2.1.
+  * Remove obsolete conffile /etc/init/bumblebeed.conf. Thanks Ansgar!
+    (Closes: #914979)
+
+ -- Luca Boccassi <bluca@debian.org>  Fri, 14 Dec 2018 16:02:16 +0000
+
+bumblebee (3.2.1-17) unstable; urgency=medium
+
+  * Switch the triggers to -noawait to fix Lintian warning and to make
+    things easier for apt/dpkg. Both restarting bumblebeed and re-building
+    the initramfs can be deferred.
+  * B-D on debhelper (>= 9.20160709) instead of dh-systemd to fix L:E.
+  * Switch Uploaders field to bluca@debian.org email address.
+  * Switch from priority extra to optional to fix L:W and comply with
+    Policy 4.0.1.
+  * Do not ship Upstart file anymore, fixes L:W.
+  * Add 387 series to dependencies for Ubuntu.
+  * Bump Standards-Version to 4.1.2.
+
+ -- Luca Boccassi <bluca@debian.org>  Fri, 08 Dec 2017 23:07:05 +0000
+
+bumblebee (3.2.1-16) unstable; urgency=medium
+
+  * Ubuntu: fix typo in modprobe, really support 378
+
+ -- Luca Boccassi <luca.boccassi@gmail.com>  Sun, 02 Jul 2017 10:36:52 +0100
+
+bumblebee (3.2.1-15) unstable; urgency=medium
+
+  * Use https in debian/copyright
+  * Bump Standards-Version to 4.0.0
+  * Ubuntu: add support for 375, 378, 381 and 384
+
+ -- Luca Boccassi <luca.boccassi@gmail.com>  Sat, 01 Jul 2017 19:43:52 +0100
+
+bumblebee (3.2.1-14) unstable; urgency=medium
+
+  * Add dependency to lsb-base (>= 3.0-6) to fix Lintian Error
+  * Add blacklist and dependency for nvidia-367*
+
+ -- Luca Boccassi <luca.boccassi@gmail.com>  Tue, 24 Jan 2017 14:20:27 +0000
+
+bumblebee (3.2.1-13) unstable; urgency=medium
+
+  * Backport libkmod.patch from upstream develop branch and add build-dep
+    on libkmod-dev. Definitively fixes all issues with multiple kernel
+    modules loading/unloading.
+  * Remove Ubuntu modprobe hack from debian/rules
+  * Add restart-bumblebeed dpkg-trigger, to be used by update-glx when
+    changing the provider of libglx.so and the nvidia kernel module.
+
+ -- Luca Boccassi <luca.boccassi@gmail.com>  Sat, 11 Jun 2016 12:49:56 +0100
+
+bumblebee (3.2.1-12) unstable; urgency=medium
+
+  [ Luca Boccassi ]
+  * Set nvidia lib directory to /usr/lib/nvidia/nvidia to solve
+    incompatibility between Bumblebee and concurrent installations of
+    current plus legacyYYYxx Nvidia driver series on the same system.
+  * Add ignore-systemd-logind-noise.patch and
+    ignore-failure-to-set-DRM-interface.patch to ignore red herrings.
+    (Closes: #822665)
+  * Set Ubuntu default kernel driver to nvidia, which is provided as a
+    modprobe alias by the nvidia-XYZ packages.
+
+  [ Vincent Cheng ]
+  * Use dh_strip --dbgsym-migration to cleanly migrate from old-style dbg
+    packages to autogenerated dbgsym packages.
+
+ -- Luca Boccassi <luca.boccassi@gmail.com>  Wed, 18 May 2016 00:17:59 +0100
+
+bumblebee (3.2.1-11) unstable; urgency=medium
+
+  [ Andreas Beckmann ]
+  * Team upload.
+  * Drop -dbg package in favor of autogenerated -dbgsym packages.
+  * Update Vcs-* URLs.
+  * Update Standards version to 3.9.8, no changes required.
+  * Drop obsolete Debian NVIDIA package alternatives.
+  * Add support for the 304xx/340xx legacy driver packages available in
+    Debian.  (Closes: #802479, #717687)
+  * Use vendor-specific maintainer scripts.
+  * Add Luca Boccassi to Uploaders.
+
+  [ Luca Boccassi ]
+  * Mention kernel cmdline workaround for nvidia module load issues on
+    some hardware, and related upstream tickets, in README.Debian.
+    (Closes: #822330)
+  * Run dh --with autoreconf to regenerate configure, Makefile, etc.
+  * Add xorg-binary-config.patch to allow changing the Xorg binary in
+    bumblebee.conf.
+  * Add dependency on xserver-xorg-core >= 1.18 and set default binary
+    to /usr/lib/xorg/Xorg in order to support xserver-xorg-legacy.
+    (Closes: #815888)
+  * Add 358, 361, 364 in alternate dep and blacklist.
+  * Install modprobe blacklist in /usr/share/bumblebee/modprobe.d/ to avoid
+    clash with the daemon config file.
+  * Delete /etc/modprobe.d/bumblebee.conf already when bumblebee is removed,
+    to not keep the blacklists active until it is purged.  (LP: #1242785)
+
+ -- Andreas Beckmann <anbe@debian.org>  Sat, 07 May 2016 23:42:16 +0200
+
+bumblebee (3.2.1-10) unstable; urgency=medium
+
+  * Team upload.
+  * Blacklist the nvidia legacy kernel modules available in Debian.
+  * Use the new /usr/lib/nvidia/bumblebee glx alternative.
+    (Closes: #802310, #802245)
+  * Add Depends: glx-alternative-nvidia (>= 0.6.92) (only for Debian).
+  * Trigger the glx-alternative-nvidia package after updating the alternative.
+  * fix-typos.patch: New, fix some typos noticed by Lintian.
+
+ -- Andreas Beckmann <anbe@debian.org>  Wed, 21 Oct 2015 02:14:27 +0200
+
+bumblebee (3.2.1-9) unstable; urgency=medium
+
+  [ Luca Boccassi ]
+  * Add modprobe remove in bumblebee.conf on Ubuntu to fix timeout when
+    unloading nvidia-uvm.
+
+  [ Vincent Cheng ]
+  * Add nvidia-355 in alternate dep and blacklist.
+
+ -- Vincent Cheng <vcheng@debian.org>  Fri, 14 Aug 2015 23:58:12 -0700
+
+bumblebee (3.2.1-8) unstable; urgency=medium
+
+  [ Luca Boccassi ]
+  * Cherry-pick patch for modprobe -r instead of rmmod (Closes: #793389)
+  * Add nvidia-346, 349, and 352 in alternate dep and blacklist.
+    (LP: #1511560)
+
+  [ Vincent Cheng ]
+  * Move bumblebee bash-completion file from obsolete /etc/bash_completion.d/
+    to /usr/share/bash-completion/completions/.
+
+ -- Vincent Cheng <vcheng@debian.org>  Sat, 25 Jul 2015 19:28:48 -0700
+
+bumblebee (3.2.1-7) unstable; urgency=medium
+
+  * Move conffile handling introduced in 3.2.1-6 from bumblebee-nvidia
+    to bumblebee.
+
+ -- Vincent Cheng <vcheng@debian.org>  Sat, 25 Oct 2014 17:04:28 -0700
+
+bumblebee (3.2.1-6) unstable; urgency=medium
+
+  * Build with CONF_DRIVER_MODULE_NVIDIA=nvidia-current instead of nvidia.
+  * Stop treating /etc/modprobe.d/bumblebee.conf as a conffile and remove it
+    when removing bumblebee, not just when purging it. (LP: #1242785)
+    - Pre-Depends on dpkg >= 1.15.7.2 for dpkg-maintscript-helper rm_conffile.
+  * Add patches: fix-device-detection.patch, ignore-error-on-X-shutdown.patch,
+    cherry-picked from upstream git. (LP: #1230008)
+  * Allow more nvidia flavours to satisfy bumblebee-nvidia's dependencies
+    (relevant only for Ubuntu).
+  * Update debian/README.Debian.
+  * Update email address.
+  * Update Standards version to 3.9.6, no changes required.
+
+ -- Vincent Cheng <vcheng@debian.org>  Sat, 25 Oct 2014 10:13:42 -0700
+
+bumblebee (3.2.1-5) unstable; urgency=medium
+
+  * Allow more nvidia flavours to satisfy bumblebee-nvidia's dependencies
+    (relevant only for Ubuntu). (LP: #1261180)
+  * Update Standards version to 3.9.5, no changes required.
+
+ -- Vincent Cheng <Vincentc1208@gmail.com>  Mon, 06 Jan 2014 01:24:33 -0800
+
+bumblebee (3.2.1-4) unstable; urgency=low
+
+  * Use dh-systemd (for systemd-specific additions to maintscripts).
+    (Closes: #715270)
+  * Add bumblebee group as system group (gid in between 100-999) instead
+    of a regular group in postinst. (Closes: #718772)
+
+ -- Vincent Cheng <Vincentc1208@gmail.com>  Tue, 20 Aug 2013 02:35:34 -0700
+
+bumblebee (3.2.1-3) unstable; urgency=low
+
+  * Append /usr/lib/primus to CONF_PRIMUS_LD_PATH in d/rules to ease
+    pre-multiarch backports. (Closes: #712665)
+  * Have bumblebee depend on bbswitch-dkms | bbswitch-source, and
+    bumblebee-nvidia depend on all possible m-a built nvidia modules.
+  * Add support for nvidia-325 packaged in Ubuntu (not relevant for Debian).
+
+ -- Vincent Cheng <Vincentc1208@gmail.com>  Thu, 11 Jul 2013 01:18:07 -0700
+
+bumblebee (3.2.1-2) unstable; urgency=low
+
+  * Allow more nvidia flavours to satisfy bumblebee-nvidia's dependencies
+    (relevant for Ubuntu).
+
+ -- Vincent Cheng <Vincentc1208@gmail.com>  Wed, 29 May 2013 01:45:35 -0700
+
+bumblebee (3.2.1-1) unstable; urgency=low
+
+  [ Aron Xu ]
+  * Initial release (Closes: #659440).
+  * Thanks to Peter Lekensteyn and Bruno Pagani, most stuff taken from the
+    packaging for Ubuntu PPA.
+
+  [ Vincent Cheng ]
+  * Thanks to Igor Urazov for lots of the Debian-specific portions of the
+    packaging.
+
+ -- Vincent Cheng <Vincentc1208@gmail.com>  Fri, 03 May 2013 03:04:38 -0700
diff --git a/control b/control
new file mode 100644 (file)
index 0000000..65f5fca
--- /dev/null
+++ b/control
@@ -0,0 +1,65 @@
+Source: bumblebee
+Section: utils
+Priority: optional
+Maintainer: Debian NVIDIA Maintainers <pkg-nvidia-devel@lists.alioth.debian.org>
+Uploaders:
+ Aron Xu <aron@debian.org>,
+ Vincent Cheng <vcheng@debian.org>,
+ Yunqiang Su <wzssyqa@gmail.com>,
+ Luca Boccassi <bluca@debian.org>,
+ Andreas Beckmann <anbe@debian.org>,
+Build-Depends:
+ debhelper-compat (= 13),
+ help2man,
+ libbsd-dev,
+ libglib2.0-dev,
+ libx11-dev,
+ pkg-config,
+ libkmod-dev,
+ bash-completion,
+Rules-Requires-Root: no
+Standards-Version: 4.5.0
+Homepage: https://launchpad.net/~bumblebee
+Vcs-Browser: https://salsa.debian.org/nvidia-team/bumblebee
+Vcs-Git: https://salsa.debian.org/nvidia-team/bumblebee.git
+
+Package: bumblebee
+Architecture: linux-any
+Pre-Depends:
+ ${misc:Pre-Depends},
+Depends:
+ lsb-base,
+ xserver-xorg-core (>= 2:1.18),
+ ${bumblebee:Depends},
+ ${misc:Depends},
+ ${shlibs:Depends},
+Recommends:
+ bbswitch-dkms | bbswitch-source,
+ ${bumblebee:backend},
+Suggests:
+ bumblebee-nvidia (= ${binary:Version}),
+Description: NVIDIA Optimus support for Linux
+ Bumblebee is an effort to make NVIDIA Optimus enabled laptops work in
+ GNU/Linux systems. These laptops are built in such a way that the NVIDIA
+ graphics card can be used on demand so that battery life is improved and
+ temperature is kept low.
+ .
+ It disables the discrete graphics card if no client is detected, and starts
+ an X server making use of NVIDIA card if requested then let software GL
+ implementations (such as VirtualGL) copy frames to the visible display that
+ runs on the integrated graphics. The ability to use discrete graphics
+ depends on the driver: open source nouveau and proprietary nvidia.
+
+Package: bumblebee-nvidia
+Architecture: none
+Section: contrib/utils
+Depends:
+ bumblebee (= ${binary:Version}),
+ ${misc:Depends},
+ ${nvidia:Depends},
+Recommends:
+ nvidia-primus-vk-wrapper,
+Description: NVIDIA Optimus support using the proprietary NVIDIA driver
+ This metapackage ensures that the proprietary NVIDIA driver is installed in a
+ way such that 3D acceleration does not break. It does so by configuring the
+ OpenGL library path to use the Mesa graphics library.
diff --git a/copyright b/copyright
new file mode 100644 (file)
index 0000000..2dbc3df
--- /dev/null
+++ b/copyright
@@ -0,0 +1,34 @@
+Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+Upstream-Name: bumblebee
+Source: https://github.com/Bumblebee-Project/Bumblebee
+
+Files: *
+Copyright: 2011-2013 Bumblebee Project <bumblebee@lists.launchpad.net>
+License: GPL-3.0+
+
+Files: debian/*
+Copyright: 2011-2013 Peter Lekensteyn <lekensteyn@gmail.com>
+           2011-2013 Bruno Pagani <bruno.n.pagani@gmail.com>
+           2012 Igor Urazov <z0rc3r@gmail.com>
+           2013 Aron Xu <aron@debian.org>
+           2013-2015 Vincent Cheng <vcheng@debian.org>
+           2015-2019 Luca Boccassi <bluca@debian.org>
+           Â© 2015-2020 Andreas Beckmann <anbe@debian.org>
+License: GPL-3.0+
+
+License: GPL-3.0+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+ .
+ This package is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ GNU General Public License for more details.
+ .
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ .
+ On Debian systems, the complete text of the GNU General
+ Public License version 3 can be found in "/usr/share/common-licenses/GPL-3".
diff --git a/not-installed b/not-installed
new file mode 100644 (file)
index 0000000..641d90a
--- /dev/null
@@ -0,0 +1,2 @@
+#960640: dh_bash-completion does not log installed files
+etc/bash_completion.d/bumblebee
diff --git a/patches/amd-apu.patch b/patches/amd-apu.patch
new file mode 100644 (file)
index 0000000..9fda6e6
--- /dev/null
@@ -0,0 +1,35 @@
+Description: Support for AMD APU+NVIDIA setup
+Origin: upstream, https://github.com/Bumblebee-Project/Bumblebee/pull/1009
+--- a/src/bumblebeed.c
++++ b/src/bumblebeed.c
+@@ -464,12 +464,19 @@ int main(int argc, char* argv[]) {
+   /* First look for an intel card */
+   struct pci_bus_id *pci_id_igd = pci_find_gfx_by_vendor(PCI_VENDOR_ID_INTEL, 0);
++
++  /* Then look for an amd card */
++  if (!pci_id_igd) {
++    bb_log(LOG_INFO, "No Intel video card found, testing for system with an AMD APU.\n");
++    pci_id_igd = pci_find_gfx_by_vendor(PCI_VENDOR_ID_AMD, 0);
++  }
++
+   if (!pci_id_igd) {
+     /* This is no Optimus configuration. But maybe it's a
+        dual-nvidia configuration. Let us test that.
+     */
+     pci_id_igd = pci_find_gfx_by_vendor(PCI_VENDOR_ID_NVIDIA, 1);
+-    bb_log(LOG_INFO, "No Intel video card found, testing for dual-nvidia system.\n");
++    bb_log(LOG_INFO, "No Intel/AMD video card found, testing for dual-nvidia system.\n");
+     if (!pci_id_igd) {
+       /* Ok, this is not a double gpu setup supported (there is at most
+--- a/src/pci.h
++++ b/src/pci.h
+@@ -21,6 +21,7 @@
+ #pragma once
+ #include <sys/types.h> /* necessary for int32_t */
++#define PCI_VENDOR_ID_AMD     0x1002
+ #define PCI_VENDOR_ID_NVIDIA  0x10de
+ #define PCI_VENDOR_ID_INTEL   0x8086
+ #define PCI_CLASS_DISPLAY_VGA 0x0300
diff --git a/patches/fix-device-detection.patch b/patches/fix-device-detection.patch
new file mode 100644 (file)
index 0000000..791ad63
--- /dev/null
@@ -0,0 +1,15 @@
+Description: Fix detection of devices on bus numbers larger than 9
+Origin: upstream, https://github.com/Bumblebee-Project/Bumblebee/commit/2073f8537412aa47755eb6f3f22a114403e5285b
+Bug: https://github.com/Bumblebee-Project/Bumblebee/issues/573
+
+--- a/src/bbsecondary.c
++++ b/src/bbsecondary.c
+@@ -138,7 +138,7 @@
+   if (!bb_is_running(bb_status.x_pid)) {
+     char pci_id[12];
+     static char *x_conf_file;
+-    snprintf(pci_id, 12, "PCI:%02x:%02x:%o", pci_bus_id_discrete->bus,
++    snprintf(pci_id, 12, "PCI:%02d:%02d:%o", pci_bus_id_discrete->bus,
+             pci_bus_id_discrete->slot, pci_bus_id_discrete->func);
+     if (!x_conf_file) {
+       x_conf_file = xorg_path_w_driver(bb_config.x_conf_file, bb_config.driver);
diff --git a/patches/fix-typos.patch b/patches/fix-typos.patch
new file mode 100644 (file)
index 0000000..4da4823
--- /dev/null
@@ -0,0 +1,72 @@
+Author: Andreas Beckmann <anbe@debian.org>
+Description: fix some typos found by Lintian
+
+--- a/src/bbconfig.c
++++ b/src/bbconfig.c
+@@ -201,11 +201,11 @@ void print_usage(int exit_val) {
+   }
+   /* common options */
+   fputs("\
+-  -q, --quiet, --silent   supresses all logging messages\n\
++  -q, --quiet, --silent   suppresses all logging messages\n\
+   -v, --verbose           increase the verbosity level of log messages. It\n\
+                             can be specified up to two times (or five if\n\
+                             --quiet is used)\n\
+-      --debug             show all logging messsages by setting the verbosity\n\
++      --debug             show all logging messages by setting the verbosity\n\
+                             level to the maximum\n\
+   -C, --config FILE       retrieve settings for Bumblebee from FILE\n", out);
+   if (is_optirun) {
+--- a/src/module.c
++++ b/src/module.c
+@@ -64,7 +64,7 @@ int module_is_loaded(char *driver) {
+  *
+  * @param module_name The filename of the module to be loaded
+  * @param driver The name of the driver to be loaded
+- * @return 1 if the driver is succesfully loaded, 0 otherwise
++ * @return 1 if the driver is successfully loaded, 0 otherwise
+  */
+ int module_load(char *module_name, char *driver) {
+   if (module_is_loaded(driver) == 0) {
+@@ -89,7 +89,7 @@ int module_load(char *module_name, char
+  * giving up
+  *
+  * @param driver The name of the driver (not a filename)
+- * @return 1 if the driver is succesfully unloaded, 0 otherwise
++ * @return 1 if the driver is successfully unloaded, 0 otherwise
+  */
+ int module_unload(char *driver) {
+   if (module_is_loaded(driver) == 1) {
+--- a/src/optirun.c
++++ b/src/optirun.c
+@@ -62,7 +62,7 @@ static void handle_signal(int sig) {
+ /**
+  * Prints the status of the Bumblebee server if available
+- * @return EXIT_SUCCESS if the status is succesfully retrieved,
++ * @return EXIT_SUCCESS if the status is successfully retrieved,
+  * EXIT_FAILURE otherwise
+  */
+ static int report_daemon_status(void) {
+--- a/src/switch/sw_bbswitch.c
++++ b/src/switch/sw_bbswitch.c
+@@ -98,7 +98,7 @@ int bbswitch_is_available(struct switch_
+    * recognized by bbswitch. Assuming that vga_switcheroo was not told to OFF
+    * the device */
+   if (module_load("bbswitch", "bbswitch")) {
+-    bb_log(LOG_DEBUG, "succesfully loaded bbswitch\n");
++    bb_log(LOG_DEBUG, "successfully loaded bbswitch\n");
+     /* hurrah, bbswitch could be loaded which means that the module is
+      * available and that the card is supported */
+     return 1;
+--- a/src/bbrun.c
++++ b/src/bbrun.c
+@@ -170,7 +170,7 @@ int bb_run_fork(char **argv, int detache
+         exitcode = 128 + WTERMSIG(status);
+       }
+     } else {
+-      bb_log(LOG_ERR, "waitpid(%i) faild with %s\n", pid, strerror(errno));
++      bb_log(LOG_ERR, "waitpid(%i) failed with %s\n", pid, strerror(errno));
+     }
+     pidlist_remove(pid);
+   } else {
diff --git a/patches/gcc-10.patch b/patches/gcc-10.patch
new file mode 100644 (file)
index 0000000..7d02226
--- /dev/null
@@ -0,0 +1,66 @@
+Author: Andreas Beckmann <anbe@debian.org>
+Description: fix FTBFS with gcc-10
+ gcc-10 defaults to -fno-common
+ see https://gcc.gnu.org/gcc-10/porting_to.html
+Bug-Debian: https://bugs.debian.org/957058
+
+--- a/src/bbconfig.h
++++ b/src/bbconfig.h
+@@ -103,7 +103,7 @@ enum bb_pm_method {
+     PM_VGASWITCHEROO,
+     PM_METHODS_COUNT /* not a method but a marker for the end */
+ };
+-const char *bb_pm_method_string[PM_METHODS_COUNT];
++extern const char *bb_pm_method_string[PM_METHODS_COUNT];
+ /* String buffer size */
+ #define BUFFER_SIZE 1024
+--- a/src/switch/switching.h
++++ b/src/switch/switching.h
+@@ -60,10 +60,10 @@ void switcheroo_off(void);
+ /* number of switchers as defined in switching.c */
+ #define SWITCHERS_COUNT 2
+-struct switching_method switching_methods[SWITCHERS_COUNT];
++extern struct switching_method switching_methods[SWITCHERS_COUNT];
+ /* A switching method that can be used or NULL if none */
+-struct switching_method *switcher;
++extern struct switching_method *switcher;
+ struct switching_method *switcher_detect(const char *name, struct switch_info);
+ enum switch_state switch_status(void);
+--- a/src/bbsecondary.h
++++ b/src/bbsecondary.h
+@@ -21,7 +21,7 @@
+ #pragma once
+ /* PCI Bus ID of the discrete video card */
+-struct pci_bus_id *pci_bus_id_discrete;
++extern struct pci_bus_id *pci_bus_id_discrete;
+ /// Start the X server by fork-exec, turn card on if needed.
+ bool start_secondary(bool);
+--- a/src/switch/switching.c
++++ b/src/switch/switching.c
+@@ -31,6 +31,8 @@ struct switching_method switching_method
+           switcheroo_on, switcheroo_off}
+ };
++struct switching_method *switcher = NULL;
++
+ /**
+  * Enumerates through available switching methods and try a method
+  * 
+--- a/src/bbsecondary.c
++++ b/src/bbsecondary.c
+@@ -37,6 +37,9 @@
+ #include "pci.h"
+ #include "module.h"
++/* PCI Bus ID of the discrete video card */
++struct pci_bus_id *pci_bus_id_discrete;
++
+ /**
+  * Substitutes DRIVER in the passed path
+  * @param x_conf_file A path to be processed
diff --git a/patches/ignore-error-on-X-shutdown.patch b/patches/ignore-error-on-X-shutdown.patch
new file mode 100644 (file)
index 0000000..323a333
--- /dev/null
@@ -0,0 +1,15 @@
+Description: Ignore error on X shutdown
+Origin: upstream, https://github.com/Bumblebee-Project/Bumblebee/commit/25387e92822fb1a56fa43f1f9f636b987018d068
+
+--- a/src/bblogger.c
++++ b/src/bblogger.c
+@@ -144,7 +144,8 @@
+   /* Error lines are errors. */
+   if (strncmp(string, "(EE)", 4) == 0){
+     if (strstr(string, "Failed to load module \"kbd\"") ||
+-            strstr(string, "No input driver matching")) {
++            strstr(string, "No input driver matching") ||
++            strstr(string, "Server terminated successfully")) {
+       /* non-fatal errors */
+       prio = LOG_DEBUG;
+     } else {
diff --git a/patches/ignore-failure-to-set-DRM-interface.patch b/patches/ignore-failure-to-set-DRM-interface.patch
new file mode 100644 (file)
index 0000000..fbf9a77
--- /dev/null
@@ -0,0 +1,22 @@
+From: Luca Boccassi <luca.boccassi@gmail.com>
+Date: Sat, 14 May 2016 21:44:00 +0100
+Subject: Ignore failure to set DRM interface
+
+This always fail due to problems in libdrm, but does not affect
+Bumblebee's functionality. See GH-652 for more details.
+---
+ src/bblogger.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/src/bblogger.c b/src/bblogger.c
+index c882275..ba3787e 100644
+--- a/src/bblogger.c
++++ b/src/bblogger.c
+@@ -146,6 +146,7 @@ static void parse_xorg_output(char * string){
+     if (strstr(string, "Failed to load module \"kbd\"") ||
+             strstr(string, "No input driver matching") ||
+             strstr(string, "systemd-logind: failed to get session:") ||
++            strstr(string, "failed to set DRM interface version 1.4:") ||
+             strstr(string, "Server terminated successfully")) {
+       /* non-fatal errors */
+       prio = LOG_DEBUG;
diff --git a/patches/ignore-systemd-logind-noise.patch b/patches/ignore-systemd-logind-noise.patch
new file mode 100644 (file)
index 0000000..cbe48b4
--- /dev/null
@@ -0,0 +1,33 @@
+From: Peter Wu <peter@lekensteyn.nl>
+Date: Thu, 30 Oct 2014 10:22:07 +0100
+Subject: Ignore systemd-logind noise
+
+This "error" appears when not run under logind. As it is not fatal,
+ignore it. (It also appears on my KDE desktop using KDM.)
+
+Error message reported in bugs GH-600, GH-582.
+---
+ src/bblogger.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/src/bblogger.c b/src/bblogger.c
+index aaadba9..c882275 100644
+--- a/src/bblogger.c
++++ b/src/bblogger.c
+@@ -145,6 +145,7 @@ static void parse_xorg_output(char * string){
+   if (strncmp(string, "(EE)", 4) == 0){
+     if (strstr(string, "Failed to load module \"kbd\"") ||
+             strstr(string, "No input driver matching") ||
++            strstr(string, "systemd-logind: failed to get session:") ||
+             strstr(string, "Server terminated successfully")) {
+       /* non-fatal errors */
+       prio = LOG_DEBUG;
+@@ -201,7 +202,7 @@ static void parse_xorg_output(char * string){
+       }
+     }
+   }
+-  
++
+   /* do the actual logging */
+   bb_log(prio, "[XORG] %s\n", string);
+ }
diff --git a/patches/libkmod.patch b/patches/libkmod.patch
new file mode 100644 (file)
index 0000000..f29068f
--- /dev/null
@@ -0,0 +1,434 @@
+From: =?utf-8?q?Ond=C5=99ej_Jano=C5=A1=C3=ADk?= <j.ondra14@gmail.com>
+Date: Thu, 5 May 2016 18:48:43 +0200
+Subject: module: use libkmod2 instead of modprobe
+
+---
+ Makefile.am      |   8 +--
+ README.markdown  |   1 +
+ configure.ac     |   1 +
+ src/bbconfig.c   |  12 ++--
+ src/bbconfig.h   |   2 +
+ src/bblogger.c   |   4 +-
+ src/bumblebeed.c |  12 ++++
+ src/module.c     | 185 +++++++++++++++++++++++++++++++++++++------------------
+ src/optirun.c    |   1 -
+ 9 files changed, 152 insertions(+), 74 deletions(-)
+
+diff --git a/Makefile.am b/Makefile.am
+index 0f38a54..25e32d5 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -10,7 +10,7 @@ AM_CPPFLAGS = ${regular_CPPFLAGS} \
+               -DCONF_XORG='"$(bumblebeedconfdir)/xorg.conf.DRIVER"' \
+               -DCONF_XORG_DIR='"$(bumblebeedconfdir)/xorg.conf.d"'
+ AM_CFLAGS = ${regular_CFLAGS} \
+-              ${x11_CFLAGS} ${libbsd_CFLAGS} ${glib_CFLAGS} \
++              ${x11_CFLAGS} ${libbsd_CFLAGS} ${glib_CFLAGS} ${kmod_CFLAGS} \
+               -Wextra -funsigned-char -DGITVERSION='"${GITVERSION}"'
+ noinst_SCRIPTS = scripts/systemd/bumblebeed.service \
+@@ -49,13 +49,13 @@ sbin_PROGRAMS = bin/bumblebeed
+ bin_PROGRAMS = bin/optirun
+ bin_optirun_SOURCES = src/module.c src/bbconfig.c src/bblogger.c src/bbrun.c \
+-      src/bbsocket.c src/driver.c src/optirun.c src/bbsocketclient.c
+-bin_optirun_LDADD = ${glib_LIBS} -lrt
++      src/bbsocket.c src/optirun.c src/bbsocketclient.c
++bin_optirun_LDADD = ${glib_LIBS} ${kmod_LIBS} -lrt
+ bin_bumblebeed_SOURCES = src/pci.c src/bbconfig.c src/bblogger.c src/bbrun.c \
+       src/bbsocket.c src/module.c src/bbsecondary.c src/switch/switching.c \
+       src/switch/sw_bbswitch.c src/switch/sw_switcheroo.c \
+       src/driver.c src/bumblebeed.c
+-bin_bumblebeed_LDADD = ${x11_LIBS} ${libbsd_LIBS} ${glib_LIBS} -lrt
++bin_bumblebeed_LDADD = ${x11_LIBS} ${libbsd_LIBS} ${glib_LIBS} ${kmod_LIBS} -lrt
+ dist_doc_DATA = $(relnotes) README.markdown
+ bumblebeedconf_DATA = conf/bumblebee.conf conf/xorg.conf.nouveau conf/xorg.conf.nvidia
+diff --git a/README.markdown b/README.markdown
+index b534a6c..5c2baa5 100644
+--- a/README.markdown
++++ b/README.markdown
+@@ -19,6 +19,7 @@ The following packages are dependencies for the build process:
+ - pkg-config
+ - glib-2.0 and development headers
+ - libx11 and development headers
++- libkmod2 and development headers
+ - libbsd and development headers (if pidfile support is enabled, default yes)
+ - help2man (optional, it is needed for building manual pages)
+diff --git a/configure.ac b/configure.ac
+index 4e22314..d5194b8 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -132,6 +132,7 @@ AC_SUBST([regular_CFLAGS])
+ # Checks for header files.
+ PKG_CHECK_MODULES([x11], [x11])
+ PKG_CHECK_MODULES([glib], [glib-2.0])
++PKG_CHECK_MODULES([kmod], [libkmod])
+ AS_IF([test "x$with_pidfile" != xno], [
+               PKG_CHECK_MODULES([libbsd], [libbsd >= 0.2.0])
+               PKG_CHECK_EXISTS([libbsd = 0.2.0], [AC_DEFINE(HAVE_LIBBSD_020)])
+diff --git a/src/bbconfig.c b/src/bbconfig.c
+index 4f5ac7a..62a3306 100644
+--- a/src/bbconfig.c
++++ b/src/bbconfig.c
+@@ -251,12 +251,6 @@ Bumblebee homepage: <http://Bumblebee-Project.org/>\n", out);
+  */
+ static int bbconfig_parse_common(int opt, char *value) {
+   switch (opt) {
+-    case 'q'://quiet mode
+-      bb_status.verbosity = VERB_NONE;
+-      break;
+-    case OPT_DEBUG://debug mode
+-      bb_status.verbosity = VERB_ALL;
+-      break;
+     case 'd'://X display number
+       set_string_value(&bb_config.x_display, value);
+       break;
+@@ -307,6 +301,12 @@ void bbconfig_parse_opts(int argc, char *argv[], int conf_round) {
+             bb_status.verbosity++;
+           }
+           break;
++        case 'q'://quiet mode
++          bb_status.verbosity = VERB_NONE;
++          break;
++        case OPT_DEBUG://debug mode
++          bb_status.verbosity = VERB_ALL;
++          break;
+         case 's': /* Unix socket to use for communication */
+           set_string_value(&bb_config.socket_path, optarg);
+           break;
+diff --git a/src/bbconfig.h b/src/bbconfig.h
+index 656286b..a19f5d3 100644
+--- a/src/bbconfig.h
++++ b/src/bbconfig.h
+@@ -26,6 +26,7 @@
+ #include <unistd.h> //for pid_t
+ #include <limits.h> //for CHAR_MAX
+ #include <glib.h>
++#include <libkmod.h>
+ /* Daemon states */
+ #define BB_DAEMON 1
+@@ -118,6 +119,7 @@ struct bb_status_struct {
+     int x_pipe[2];//pipes for reading/writing output from X's stdout/stderr
+     gboolean use_syslog;
+     char *program_name;
++    struct kmod_ctx *kmod_ctx;
+ };
+ /* Structure containing the configuration. */
+diff --git a/src/bblogger.c b/src/bblogger.c
+index ba3787e..7c13c93 100644
+--- a/src/bblogger.c
++++ b/src/bblogger.c
+@@ -228,7 +228,7 @@ void check_xorg_pipe(void){
+         /* line / buffer is full, process the remaining buffer the next round */
+         repeat = 1;
+       }
+-    }else{
++    } else {
+       if (r == 0 || (errno != EAGAIN && r == -1)){
+         /* the pipe is closed/invalid. Clean up. */
+         if (bb_status.x_pipe[0] != -1){close(bb_status.x_pipe[0]); bb_status.x_pipe[0] = -1;}
+@@ -257,5 +257,5 @@ void check_xorg_pipe(void){
+         memmove(x_output_buffer, next_part, x_buffer_pos);
+       }
+     }
+-  }while(repeat);
++  }while (repeat);
+ }/* check_xorg_pipe */
+diff --git a/src/bumblebeed.c b/src/bumblebeed.c
+index a911da9..6e0ade5 100644
+--- a/src/bumblebeed.c
++++ b/src/bumblebeed.c
+@@ -34,6 +34,7 @@
+ #include <string.h>
+ #include <errno.h>
+ #include <getopt.h>
++#include <libkmod.h>
+ #ifdef WITH_PIDFILE
+ #ifdef HAVE_LIBBSD_020
+ #include <libutil.h>
+@@ -488,6 +489,14 @@ int main(int argc, char* argv[]) {
+   free(pci_id_igd);
++  // kmod context have to be available for driver detection
++  bb_status.kmod_ctx = kmod_new(NULL, NULL);
++  if (bb_status.kmod_ctx == NULL) {
++    bb_log(LOG_ERR, "kmod_new() failed!\n");
++    bb_closelog();
++    exit(EXIT_FAILURE);
++  }
++
+   GKeyFile *bbcfg = bbconfig_parse_conf();
+   bbconfig_parse_opts(argc, argv, PARSE_STAGE_DRIVER);
+   driver_detect();
+@@ -500,6 +509,7 @@ int main(int argc, char* argv[]) {
+   /* dump the config after detecting the driver */
+   config_dump();
++
+   if (config_validate() != 0) {
+     return (EXIT_FAILURE);
+   }
+@@ -572,5 +582,7 @@ int main(int argc, char* argv[]) {
+   //close X pipe, if any parts of it are open still
+   if (bb_status.x_pipe[0] != -1){close(bb_status.x_pipe[0]); bb_status.x_pipe[0] = -1;}
+   if (bb_status.x_pipe[1] != -1){close(bb_status.x_pipe[1]); bb_status.x_pipe[1] = -1;}
++  //cleanup kmod context
++  kmod_unref(bb_status.kmod_ctx);
+   return (EXIT_SUCCESS);
+ }
+diff --git a/src/module.c b/src/module.c
+index bb32e15..ef3e84c 100644
+--- a/src/module.c
++++ b/src/module.c
+@@ -24,91 +24,152 @@
+ #include <ctype.h>
+ #include <stdlib.h>
+ #include <unistd.h>
++#include <libkmod.h>
++#include <errno.h>
+ #include "module.h"
+ #include "bblogger.h"
+ #include "bbrun.h"
++#include "bbconfig.h"
++
++int module_unload_recursive(struct kmod_module *mod);
+ /**
+- * Checks in /proc/modules whether a kernel module is loaded
++ * Checks whether a kernel module is loaded
+  *
+  * @param driver The name of the driver (not a filename)
+  * @return 1 if the module is loaded, 0 otherwise
+  */
+ int module_is_loaded(char *driver) {
+-  // use the same buffer length as lsmod
+-  char buffer[4096];
+-  FILE * bbs = fopen("/proc/modules", "r");
+-  int ret = 0;
+-  /* assume mod_len <= sizeof(buffer) */
+-  int mod_len = strlen(driver);
++  int err, state;
++  struct kmod_module *mod;
+-  if (bbs == 0) {//error opening, return -1
+-    bb_log(LOG_DEBUG, "Couldn't open /proc/modules");
+-    return -1;
++  err = kmod_module_new_from_name(bb_status.kmod_ctx, driver, &mod);
++  if (err < 0) {
++    bb_log(LOG_DEBUG, "kmod_module_new_from_name(%s) failed (err: %d).\n",
++      driver, err);
++    return 0;
+   }
+-  while (fgets(buffer, sizeof(buffer), bbs)) {
+-    /* match "module" with "module " and not "module-blah" */
+-    if (!strncmp(buffer, driver, mod_len) && isspace(buffer[mod_len])) {
+-      /* module is found */
+-      ret = 1;
+-      break;
+-    }
+-  }
+-  fclose(bbs);
+-  return ret;
++
++  state = kmod_module_get_initstate(mod);
++  kmod_module_unref(mod);
++
++  return state == KMOD_MODULE_LIVE;
+ }
+ /**
+- * Attempts to load a module. If the module has not been loaded after ten
+- * seconds, give up
++ * Attempts to load a module.
+  *
+  * @param module_name The filename of the module to be loaded
+  * @param driver The name of the driver to be loaded
+  * @return 1 if the driver is successfully loaded, 0 otherwise
+  */
+ int module_load(char *module_name, char *driver) {
++  int err = 0;
++  int flags = KMOD_PROBE_IGNORE_LOADED;
++  struct kmod_list *l, *list = NULL;
++
+   if (module_is_loaded(driver) == 0) {
+     /* the module has not loaded yet, try to load it */
+-    bb_log(LOG_INFO, "Loading driver %s (module %s)\n", driver, module_name);
+-    char *mod_argv[] = {
+-      "modprobe",
+-      module_name,
+-      NULL
+-    };
+-    bb_run_fork_wait(mod_argv, 10);
+-    if (module_is_loaded(driver) == 0) {
+-      bb_log(LOG_ERR, "Module %s could not be loaded (timeout?)\n", module_name);
++
++    bb_log(LOG_INFO, "Loading driver '%s' (module '%s')\n", driver, module_name);
++    err = kmod_module_new_from_lookup(bb_status.kmod_ctx, module_name, &list);
++
++    if (err < 0) {
++      bb_log(LOG_DEBUG, "kmod_module_new_from_lookup(%s) failed (err: %d).\n",
++        module_name, err);
++      return 0;
++    }
++
++    if (list == NULL) {
++      bb_log(LOG_ERR, "Module '%s' not found.\n", module_name);
+       return 0;
+     }
++
++    kmod_list_foreach(l, list) {
++      struct kmod_module *mod = kmod_module_get_module(l);
++
++      bb_log(LOG_DEBUG, "Loading module '%s'.\n", kmod_module_get_name(mod));
++      err = kmod_module_probe_insert_module(mod, flags, NULL, NULL, NULL, 0);
++
++      if (err < 0) {
++        bb_log(LOG_DEBUG, "kmod_module_probe_insert_module(%s) failed (err: %d).\n",
++          kmod_module_get_name(mod), err);
++      }
++
++      kmod_module_unref(mod);
++
++      if (err < 0) {
++        break;
++      }
++    }
++
++    kmod_module_unref_list(list);
++  }
++
++  return err >= 0;
++}
++
++/**
++ * Unloads module and modules that are depending on this module.
++ *
++ * @param mod Reference to libkmod module
++ * @return 1 if the module is successfully unloaded, 0 otherwise
++ */
++int module_unload_recursive(struct kmod_module *mod) {
++  int err = 0, flags = 0, refcnt;
++  struct kmod_list *holders;
++
++  holders = kmod_module_get_holders(mod);
++  if (holders != NULL) {
++    struct kmod_list *itr;
++
++    kmod_list_foreach(itr, holders) {
++      struct kmod_module *hm = kmod_module_get_module(itr);
++      err = module_unload_recursive(hm);
++      kmod_module_unref(hm);
++
++      if (err < 0) {
++        break;
++      }
++    }
++    kmod_module_unref_list(holders);
+   }
+-  return 1;
++
++  refcnt = kmod_module_get_refcnt(mod);
++  if (refcnt == 0) {
++    bb_log(LOG_INFO, "Unloading module %s\n", kmod_module_get_name(mod));
++    err = kmod_module_remove_module(mod, flags);
++  } else {
++    bb_log(LOG_ERR, "Failed to unload module '%s' (ref count: %d).\n",
++      kmod_module_get_name(mod), refcnt);
++    err = 1;
++  }
++
++  return err == 0;
+ }
+ /**
+- * Attempts to unload a module if loaded, for ten seconds before
+- * giving up
++ * Attempts to unload a module if loaded.
+  *
+  * @param driver The name of the driver (not a filename)
+  * @return 1 if the driver is successfully unloaded, 0 otherwise
+  */
+ int module_unload(char *driver) {
++  int err;
++  struct kmod_module *mod;
+   if (module_is_loaded(driver) == 1) {
+-    int retries = 30;
+-    bb_log(LOG_INFO, "Unloading %s driver\n", driver);
+-    char *mod_argv[] = {
+-      "modprobe",
+-      "-r",
+-      driver,
+-      NULL
+-    };
+-    bb_run_fork_wait(mod_argv, 10);
+-    while (retries-- > 0 && module_is_loaded(driver) == 1) {
+-      usleep(100000);
+-    }
+-    if (module_is_loaded(driver) == 1) {
+-      bb_log(LOG_ERR, "Unloading %s driver timed out.\n", driver);
++    err = kmod_module_new_from_name(bb_status.kmod_ctx, driver, &mod);
++
++    if (err < 0) {
++      bb_log(LOG_DEBUG, "kmod_module_new_from_name(%s) failed (err: %d).\n",
++        driver, err);
+       return 0;
+     }
++
++    err = module_unload_recursive(mod);
++    kmod_module_unref(mod);
++
++    return err;
+   }
+   return 1;
+ }
+@@ -120,18 +181,20 @@ int module_unload(char *driver) {
+  * @return 1 if the module is available for loading, 0 otherwise
+  */
+ int module_is_available(char *module_name) {
+-  /* HACK to support call from optirun */
+-  char *modprobe_bin = "/sbin/modprobe";
+-  if (access(modprobe_bin, X_OK)) {
+-    /* if /sbin/modprobe is not found, pray that PATH contains it */
+-    modprobe_bin = "modprobe";
++  int err, available;
++  struct kmod_list *list = NULL;
++
++  err = kmod_module_new_from_lookup(bb_status.kmod_ctx, module_name, &list);
++
++  if (err < 0) {
++    bb_log(LOG_DEBUG, "kmod_module_new_from_lookup(%s) failed (err: %d).\n",
++      module_name, err);
++    return 0;
+   }
+-  char *mod_argv[] = {
+-    modprobe_bin,
+-    "--dry-run",
+-    "--quiet",
+-    module_name,
+-    NULL
+-  };
+-  return bb_run_fork(mod_argv, 1) == EXIT_SUCCESS;
++
++  available = list != NULL;
++
++  kmod_module_unref_list(list);
++
++  return available;
+ }
+diff --git a/src/optirun.c b/src/optirun.c
+index bcc6c13..f05f05c 100644
+--- a/src/optirun.c
++++ b/src/optirun.c
+@@ -37,7 +37,6 @@
+ #include "bbsocketclient.h"
+ #include "bblogger.h"
+ #include "bbrun.h"
+-#include "driver.h"
+ /**
diff --git a/patches/man-section.patch b/patches/man-section.patch
new file mode 100644 (file)
index 0000000..b82b7d3
--- /dev/null
@@ -0,0 +1,26 @@
+Description: fix man section
+Author: Andreas Beckmann <anbe@debian.org>
+
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -113,7 +113,7 @@ scripts/upstart/bumblebeed.conf: $(srcdi
+       $(do_subst) < $< > $@
+ if HAVE_HELP2MAN
+-man_MANS = bumblebeed.1 optirun.1
++man_MANS = bumblebeed.8 optirun.1
+ CLEANFILES += $(man_MANS)
+ optirun.1: bin/optirun $(bin_optirun_SOURCES)
+@@ -121,9 +121,10 @@ optirun.1: bin/optirun $(bin_optirun_SOU
+               --name='run programs on the discrete video card' \
+               bin/optirun
+-bumblebeed.1: bin/bumblebeed $(bin_bumblebeed_SOURCES)
++bumblebeed.8: bin/bumblebeed $(bin_bumblebeed_SOURCES)
+       $(HELP2MAN) --output=$@ --no-info \
+               --name='bumblebee daemon' \
++              --section=8 \
+               bin/bumblebeed
+ else
+       @echo "Warning: help2man not available, no man page is created."
diff --git a/patches/modprobe-r-instead-of-rmmod.patch b/patches/modprobe-r-instead-of-rmmod.patch
new file mode 100644 (file)
index 0000000..97c62c3
--- /dev/null
@@ -0,0 +1,21 @@
+Description: switch from "rmmod" to "modprobe -r"
+ With the introduction of nvidia-uvm module, unloading nvidia module will fail
+ unless nvidia-uvm is unloaded.  GH-565 suggests using "remove" or "softdep"
+ modprobe.d clauses to teach modprobe to handle that for us; "rmmod" does not
+ have that functionality, so switch to "modprobe -r".
+Origin: upstream, https://github.com/Bumblebee-Project/Bumblebee/commit/1ada79fe5916961fc4e4917f8c63bb184908d986
+Bug: https://github.com/Bumblebee-Project/Bumblebee/issues/565
+Bug-Debian: https://bugs.debian.org/793389
+
+--- a/src/module.c
++++ b/src/module.c
+@@ -96,7 +96,8 @@ int module_unload(char *driver) {
+     int retries = 30;
+     bb_log(LOG_INFO, "Unloading %s driver\n", driver);
+     char *mod_argv[] = {
+-      "rmmod",
++      "modprobe",
++      "-r",
+       driver,
+       NULL
+     };
diff --git a/patches/no-bbswitch.patch b/patches/no-bbswitch.patch
new file mode 100644 (file)
index 0000000..65f43f4
--- /dev/null
@@ -0,0 +1,82 @@
+Description: Add option to always unload the driver on exit
+Origin: upstream, https://github.com/Bumblebee-Project/Bumblebee/pull/983
+--- a/src/bbconfig.c
++++ b/src/bbconfig.c
+@@ -462,6 +462,10 @@ void bbconfig_parse_conf_driver(GKeyFile
+       g_free(module_name);
+     }
+   }
++  key = "AlwaysUnloadKernelDriver";
++  if (g_key_file_has_key(bbcfg, section, key, NULL)) {
++    bb_config.force_driver_unload = g_key_file_get_boolean(bbcfg, section, key, NULL);
++  }
+   key = "LibraryPath";
+   if (g_key_file_has_key(bbcfg, section, key, NULL)) {
+     free_and_set_value(&bb_config.ld_path, g_key_file_get_string(bbcfg, section, key, NULL));
+--- a/src/bbconfig.h
++++ b/src/bbconfig.h
+@@ -145,6 +145,7 @@ struct bb_config_struct {
+     char * module_name; /* Kernel module to be loaded for the driver.
+                                     * If empty, driver will be used. This is
+                                     * for Ubuntu which uses nvidia-current */
++    int force_driver_unload; /* Force driver unload, even without active PM method */
+     int card_shutdown_state;
+ #ifdef WITH_PIDFILE
+     char *pid_file; /* pid file for storing the daemons PID */
+--- a/src/bbsecondary.c
++++ b/src/bbsecondary.c
+@@ -223,24 +223,31 @@ bool start_secondary(bool need_secondary
+ static void switch_and_unload(void)
+ {
+   char driver[BUFFER_SIZE];
++  int unload_driver = 0;
+-  if (bb_config.pm_method == PM_DISABLED && bb_status.runmode != BB_RUN_EXIT) {
++  if (bb_config.pm_method == PM_DISABLED && !bb_config.force_driver_unload && bb_status.runmode != BB_RUN_EXIT) {
+     /* do not disable the card if PM is disabled unless exiting */
+     return;
+   }
+   //if card is on and can be switched, switch it off
++  if (switcher && switcher->need_driver_unloaded) {
++    /* do not unload the drivers nor disable the card if the card is not on */
++    if (switcher->status() != SWITCH_ON) {
++      return;
++    }
++    unload_driver = 1;
++  }
++
++  if (unload_driver || bb_config.force_driver_unload) {
++    /* unload the driver loaded by the graphica card */
++    if (pci_get_driver(driver, pci_bus_id_discrete, sizeof driver)) {
++      module_unload(driver);
++    }
++  }
++
+   if (switcher) {
+     if (switcher->need_driver_unloaded) {
+-      /* do not unload the drivers nor disable the card if the card is not on */
+-      if (switcher->status() != SWITCH_ON) {
+-        return;
+-      }
+-      /* unload the driver loaded by the graphica card */
+-      if (pci_get_driver(driver, pci_bus_id_discrete, sizeof driver)) {
+-        module_unload(driver);
+-      }
+-
+       //only turn card off if no drivers are loaded
+       if (pci_get_driver(NULL, pci_bus_id_discrete, 0)) {
+         bb_log(LOG_DEBUG, "Drivers are still loaded, unable to disable card\n");
+--- a/conf/bumblebee.conf.in
++++ b/conf/bumblebee.conf.in
+@@ -62,6 +62,10 @@ LibraryPath=@CONF_LDPATH_NVIDIA@
+ # default Xorg modules path
+ XorgModulePath=@CONF_MODPATH_NVIDIA@
+ XorgConfFile=@BBCONFDIR@/xorg.conf.nvidia
++# If set to true, will always unload the kernel module(s) even with
++# PMMethod=none - useful for newer Optimus models on which the kernel power
++# management works out of the box to power the card on/off without bbswitch.
++AlwaysUnloadKernelDriver=false
+ ## Section with nouveau driver specific options, only parsed if Driver=nouveau
+ [driver-nouveau]
diff --git a/patches/primus-vk.patch b/patches/primus-vk.patch
new file mode 100644 (file)
index 0000000..f2df3f7
--- /dev/null
@@ -0,0 +1,15 @@
+Author: Andreas Beckmann <anbe@debian.org>
+Description: optirun: set ENABLE_PRIMUS_LAYER=1 to enable primus-vk handling
+
+--- a/src/optirun.c
++++ b/src/optirun.c
+@@ -256,6 +256,9 @@ static int run_primus(int argc, char **a
+   /* assume OSS drivers for primary display (Mesa for Intel) */
+   setenv("PRIMUS_libGLd", libgl_mesa, 0);
++  /* vulkan applications are handled via primus-vk */
++  setenv("ENABLE_PRIMUS_LAYER", "1", 0);
++
+   int exitcode = bb_run_fork(run_args, 0);
+   free(run_args);
+   return exitcode;
diff --git a/patches/series b/patches/series
new file mode 100644 (file)
index 0000000..8f72a48
--- /dev/null
@@ -0,0 +1,13 @@
+fix-device-detection.patch
+ignore-error-on-X-shutdown.patch
+modprobe-r-instead-of-rmmod.patch
+fix-typos.patch
+xorg-binary-config.patch
+ignore-systemd-logind-noise.patch
+ignore-failure-to-set-DRM-interface.patch
+libkmod.patch
+amd-apu.patch
+no-bbswitch.patch
+man-section.patch
+gcc-10.patch
+primus-vk.patch
diff --git a/patches/xorg-binary-config.patch b/patches/xorg-binary-config.patch
new file mode 100644 (file)
index 0000000..e4c751d
--- /dev/null
@@ -0,0 +1,135 @@
+From: Rogier 'DocWilco' Mulhuijzen <github@bsdchicks.com>
+Date: Sat, 27 Feb 2016 12:43:41 -0800
+Subject: Add config option to set Xorg binary to run
+
+Also add Xorg commandline binary to debug output
+---
+ Makefile.am            | 1 +
+ conf/bumblebee.conf.in | 2 ++
+ configure.ac           | 6 ++++++
+ src/bbconfig.c         | 6 ++++++
+ src/bbconfig.h         | 1 +
+ src/bbsecondary.c      | 8 +++++++-
+ src/bbsecondary.h      | 8 --------
+ 7 files changed, 23 insertions(+), 9 deletions(-)
+
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -70,6 +70,7 @@
+ do_subst = sed -e 's|[@]GITVERSION[@]|$(GITVERSION)|g' \
+       -e 's|[@]CONF_XDISP[@]|$(CONF_XDISP)|g' \
++      -e 's|[@]CONF_XORG_BINARY[@]|$(CONF_XORG_BINARY)|g' \
+       -e 's|[@]CONF_SOCKPATH[@]|$(CONF_SOCKPATH)|g' \
+       -e 's|[@]CONF_GID[@]|$(CONF_GID)|g' \
+       -e 's|[@]CONF_PM_METHOD[@]|$(CONF_PM_METHOD)|g' \
+--- a/conf/bumblebee.conf.in
++++ b/conf/bumblebee.conf.in
+@@ -22,6 +22,8 @@
+ Driver=@CONF_DRIVER@
+ # Directory with a dummy config file to pass as a -configdir to secondary X
+ XorgConfDir=@XCONFDDIR@
++# Xorg binary to run
++XorgBinary=@CONF_XORG_BINARY@
+ ## Client options. Will take effect on the next optirun executed.
+ [optirun]
+--- a/configure.ac
++++ b/configure.ac
+@@ -32,6 +32,16 @@
+ AC_DEFINE_SUBST(CONF_VGLCOMPRESS, "proxy", [vglclient transport method])
+ AC_DEFINE_SUBST(CONF_TURNOFFATEXIT, "false", [state of card when shutting off daemon])
++# OpenSUSE: /usr/bin/X -> /var/lib/X11/X -> /usr/bin/Xorg
++# Fedora, Arch Linux: /usr/bin/X -> /usr/bin/Xorg
++# Ubuntu: /usr/bin/X is a custom binary doing authorization and then executes
++#         /etc/X11/X -> /usr/bin/Xorg
++AC_DEFINE_CONF(CONF_XORG_BINARY, [Xorg binary to run], [
++if test "x" = "x$CONF_XORG_BINARY"; then
++      CONF_XORG_BINARY=Xorg
++fi
++])
++
+ AC_DEFINE_CONF(CONF_BRIDGE, [optirun display/render bridge, valid values are auto (default), primus and virtualgl], [
+ case $CONF_BRIDGE in
+ auto|primus|virtualgl) ;;
+--- a/src/bbconfig.c
++++ b/src/bbconfig.c
+@@ -425,6 +425,10 @@
+   if (g_key_file_has_key(bbcfg, section, key, NULL)) {
+     free_and_set_value(&bb_config.x_conf_dir, g_key_file_get_string(bbcfg, section, key, NULL));
+   }
++  key = "XorgBinary";
++  if (g_key_file_has_key(bbcfg, section, key, NULL)) {
++    free_and_set_value(&bb_config.xorg_binary, g_key_file_get_string(bbcfg, section, key, NULL));
++  }
+   return bbcfg;
+ }
+@@ -517,6 +521,7 @@
+   set_string_value(&bb_config.gid_name, CONF_GID);
+   set_string_value(&bb_config.x_conf_file, CONF_XORG);
+   set_string_value(&bb_config.x_conf_dir, CONF_XORG_DIR);
++  set_string_value(&bb_config.xorg_binary, CONF_XORG_BINARY);
+   set_string_value(&bb_config.optirun_bridge, CONF_BRIDGE);
+   set_string_value(&bb_config.primus_ld_path, CONF_PRIMUS_LD_PATH);
+   set_string_value(&bb_config.vgl_compress, CONF_VGLCOMPRESS);
+@@ -550,6 +555,7 @@
+ #endif
+     bb_log(LOG_DEBUG, " xorg.conf file: %s\n", bb_config.x_conf_file);
+     bb_log(LOG_DEBUG, " xorg.conf.d dir: %s\n", bb_config.x_conf_dir);
++    bb_log(LOG_DEBUG, " Xorg binary: %s\n", bb_config.xorg_binary);
+     bb_log(LOG_DEBUG, " ModulePath: %s\n", bb_config.mod_path);
+     bb_log(LOG_DEBUG, " GID name: %s\n", bb_config.gid_name);
+     bb_log(LOG_DEBUG, " Power method: %s\n",
+--- a/src/bbconfig.h
++++ b/src/bbconfig.h
+@@ -122,6 +122,7 @@
+ /* Structure containing the configuration. */
+ struct bb_config_struct {
++    char * xorg_binary; /// Xorg binary to run.
+     char * x_display; /// X display number to use.
+     char * x_conf_file; /// Path to the X configuration file.
+     char * x_conf_dir; /// Path to the dummy X configuration directory.
+--- a/src/bbsecondary.c
++++ b/src/bbsecondary.c
+@@ -146,7 +146,7 @@
+     bb_log(LOG_INFO, "Starting X server on display %s.\n", bb_config.x_display);
+     char *x_argv[] = {
+-      XORG_BINARY,
++      bb_config.xorg_binary,
+       bb_config.x_display,
+       "-config", x_conf_file,
+       "-configdir", bb_config.x_conf_dir,
+@@ -158,6 +158,12 @@
+       "-modulepath", bb_config.mod_path, // keep last
+       NULL
+     };
++    char **argvp;
++    bb_log(LOG_DEBUG, "X server command line:");
++    for (argvp = x_argv; argvp && *argvp; argvp++) {
++          bb_log(LOG_DEBUG, " %s", *argvp);
++    }
++    bb_log(LOG_DEBUG, "\n");
+     enum {n_x_args = sizeof(x_argv) / sizeof(x_argv[0])};
+     if (!*bb_config.mod_path) {
+       x_argv[n_x_args - 3] = 0; //remove -modulepath if not set
+--- a/src/bbsecondary.h
++++ b/src/bbsecondary.h
+@@ -20,14 +20,6 @@
+  */
+ #pragma once
+-/**
+- * OpenSUSE: /usr/bin/X -> /var/lib/X11/X -> /usr/bin/Xorg
+- * Fedora, Arch Linux: /usr/bin/X -> /usr/bin/Xorg
+- * Ubuntu: /usr/bin/X is a custom binary doing authorization and then executes
+- *         /etc/X11/X -> /usr/bin/Xorg
+- */
+-#define XORG_BINARY "Xorg"
+-
+ /* PCI Bus ID of the discrete video card */
+ struct pci_bus_id *pci_bus_id_discrete;
diff --git a/rules b/rules
new file mode 100755 (executable)
index 0000000..3eb63a1
--- /dev/null
+++ b/rules
@@ -0,0 +1,118 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+get_variant             = $(word 1,$(subst _, ,$1))
+get_constraint          = $(1:$(call get_variant,$1)%=%)
+
+nv_variant_Debian      += tesla-450_[amd64_arm64_ppc64el]
+nv_variant_Debian      += tesla-440_[amd64_ppc64el]
+nv_variant_Debian      += tesla-418_[amd64_ppc64el]
+nv_variant_Debian      += legacy-390xx_[amd64_i386_armhf]
+nv_variant_Debian      += legacy-340xx_[amd64_i386_armhf]
+
+nv_driver_Debian       += nvidia-driver_[!i386_!armhf_!ppc64el]
+nv_driver_Debian       += $(foreach v,$(nv_variant_Debian),nvidia-$(call get_variant,$v)-driver$(call get_constraint,$v))
+nv_driver_Debian       += nvidia-driver-any
+nv_driver_Debian       += nvidia-kernel-dkms_[!i386_!armhf_!ppc64el]
+nv_driver_Debian       += $(foreach v,$(nv_variant_Debian),nvidia-$(call get_variant,$v)-kernel-dkms$(call get_constraint,$v))
+
+nv_module_Debian       += nvidia
+nv_module_Debian       += nvidia-current
+nv_module_Debian       += $(foreach v,$(nv_variant_Debian),nvidia-$(call get_variant,$v))
+
+nv_version_Ubuntu      += 450_[amd64]
+nv_version_Ubuntu      += 450-server_[amd64]
+nv_version_Ubuntu      += 440_[amd64]
+nv_version_Ubuntu      += 440-server_[amd64]
+nv_version_Ubuntu      += 435_[amd64]
+nv_version_Ubuntu      += 430_[amd64]
+nv_version_Ubuntu      += 418_[amd64]
+nv_version_Ubuntu      += 418-server_[amd64]
+nv_version_Ubuntu      += 410_[amd64]
+nv_version_Ubuntu      += 390_[amd64_i386] #_armhf
+nv_version_old_Ubuntu  += 387 384 381 378 375 367 364 361 358 355 352 349 346 343 340 337 334 331 325 319 313 310 304
+
+nv_driver_Ubuntu       += nvidia_[amd64_i386]
+nv_driver_Ubuntu       += nvidia-current_[amd64_i386]
+nv_driver_Ubuntu       += nvidia-current-updates_[amd64_i386]
+nv_driver_Ubuntu       += nvidia-driver-binary_[amd64_i386]
+nv_driver_Ubuntu       += $(foreach v,$(nv_version_Ubuntu),nvidia-driver-$(call get_variant,$v)$(call get_constraint,$v))
+nv_driver_Ubuntu       += $(foreach version,$(nv_version_old_Ubuntu),nvidia-$(version)_[amd64_i386] nvidia-$(version)-updates_[amd64_i386] nvidia-experimental-$(version)_[amd64_i386])
+
+nv_module_Ubuntu       += $(filter-out nvidia-driver-binary,$(foreach v,$(nv_driver_Ubuntu),$(call get_variant,$v)))
+
+
+VENDOR := $(shell dpkg-vendor --derives-from Ubuntu && echo Ubuntu || echo Debian)
+
+bb_depends_Debian       =
+bb_depends_Ubuntu       = pciutils
+
+bbnv_depends_Debian     = glx-alternative-nvidia (>= 0.6.92)
+bbnv_depends_Ubuntu     =
+
+bb_backend_Debian       = primus-libs
+bb_backend_Ubuntu       = virtualgl | primus-libs
+
+MAINTSCRIPTS_GENERATED          = $(MAINTSCRIPTS_GENERATED.$(VENDOR))
+MAINTSCRIPTS_GENERATED         += debian/bumblebee.conf
+MAINTSCRIPTS_GENERATED.Debian  += debian/bumblebee-nvidia.postinst
+MAINTSCRIPTS_GENERATED.Ubuntu  += debian/bumblebee-nvidia.postinst
+MAINTSCRIPTS_GENERATED.Ubuntu  += debian/bumblebee-nvidia.postrm
+
+DPKG_EXPORT_BUILDFLAGS = 1
+export DEB_BUILD_MAINT_OPTIONS = hardening=+all
+include /usr/share/dpkg/default.mk
+
+%:
+       dh $@ --with bash_completion
+
+override_dh_auto_configure: $(MAINTSCRIPTS_GENERATED)
+ifeq ($(VENDOR),Ubuntu)
+       dh_auto_configure -- \
+               CONF_DRIVER_MODULE_NVIDIA=nvidia \
+               CONF_LDPATH_NVIDIA=/usr/lib/nvidia-current:/usr/lib32/nvidia-current:/usr/lib/x86_64-linux-gnu:/usr/lib/i386-linux-gnu \
+               CONF_MODPATH_NVIDIA=/usr/lib/nvidia-current/xorg,/usr/lib/xorg/modules \
+               CONF_PRIMUS_LD_PATH=/usr/lib/x86_64-linux-gnu/primus:/usr/lib/i386-linux-gnu/primus \
+               CONF_XORG_BINARY=/usr/lib/xorg/Xorg
+else
+       dh_auto_configure -- \
+               CONF_DRIVER_MODULE_NVIDIA=nvidia \
+               CONF_LDPATH_NVIDIA=/usr/lib/x86_64-linux-gnu/nvidia:/usr/lib/i386-linux-gnu/nvidia:/usr/lib/x86_64-linux-gnu:/usr/lib/i386-linux-gnu \
+               CONF_MODPATH_NVIDIA=/usr/lib/nvidia,/usr/lib/xorg/modules \
+               CONF_PRIMUS_LD_PATH=/usr/lib/x86_64-linux-gnu/primus:/usr/lib/i386-linux-gnu/primus \
+               CONF_XORG_BINARY=/usr/lib/xorg/Xorg
+endif
+
+execute_after_dh_clean:
+       $(RM) $(MAINTSCRIPTS_GENERATED)
+
+override_dh_installinit:
+       dh_installinit --name=bumblebeed
+
+override_dh_bugfiles:
+       dh_bugfiles -A
+
+override_dh_gencontrol:
+       dh_gencontrol -- \
+               -V'bumblebee:Depends=$(bb_depends_$(VENDOR))' \
+               -V'nvidia:Depends=$(bbnv_depends_$(VENDOR)), $(subst _, ,$(foreach d,$(nv_driver_$(VENDOR)),$(d) |))' \
+               -V'bumblebee:backend=$(bb_backend_$(VENDOR))'
+
+debian/%: debian/%.$(VENDOR)
+       cp -a $< $@
+
+debian/bumblebee.conf: debian/rules
+       $(RM) $@
+       echo '# This file is installed by bumblebee, do NOT edit!' >> $@
+       echo '# to be used by kmod / module-init-tools, and installed in /etc/modprobe.d/' >> $@
+       echo '# or equivalent' >> $@
+       echo '' >> $@
+       echo '# do not automatically load nouveau as it may prevent nvidia from loading' >> $@
+       echo 'blacklist nouveau' >> $@
+       echo '' >> $@
+       echo '# do not automatically load nvidia as it'"'"'s unloaded anyway when bumblebeed' >> $@
+       echo '# starts and may fail bumblebeed to disable the card in a race condition.' >> $@
+       for module in $(nv_module_$(VENDOR)) ; do echo "blacklist $$module" >> $@ ; done
diff --git a/source/format b/source/format
new file mode 100644 (file)
index 0000000..163aaf8
--- /dev/null
@@ -0,0 +1 @@
+3.0 (quilt)
diff --git a/upstream/metadata b/upstream/metadata
new file mode 100644 (file)
index 0000000..a18eacd
--- /dev/null
@@ -0,0 +1,4 @@
+Bug-Database: https://github.com/Bumblebee-Project/Bumblebee/issues
+Bug-Submit: https://github.com/Bumblebee-Project/Bumblebee/issues/new
+Repository: https://github.com/Bumblebee-Project/Bumblebee.git
+Repository-Browse: https://github.com/Bumblebee-Project/Bumblebee
diff --git a/watch b/watch
new file mode 100644 (file)
index 0000000..721a8b6
--- /dev/null
+++ b/watch
@@ -0,0 +1,2 @@
+version=3
+https://github.com/Bumblebee-Project/Bumblebee/tags .*/v?(\d.*)\.(?:tgz|tbz2|tar\.(?:gz|bz2|xz))