updated on Wed Jan 11 20:01:35 UTC 2012
[aur-mirror.git] / bumblebee-git / bumblebee.install
blob4be36781e611b956d870a47534f8924ce2ff6c90
1 _replace_busid() {
2     NVIDIABUSID=$(lspci -d 10de: -n | grep '030[02]:' | cut -d' ' -f1 | tr . :)
4     case $(wc -l <<<"$NVIDIABUSID") in
5       0)
6         echo "The BusID of the nVidia card can't be determined."
7         echo "You must set that manually in $1"
8         ;;
9       1)
10         NVIDIABUSID="PCI:$NVIDIABUSID"
11         #echo "Detected Bus ID: $NVIDIABUSID"
12         ;;
13       *)
14         # You'll never know.
15         echo "Multiple graphics cards are not supported by Bumblebee yet. The"
16         echo "following PCI Bus IDs have been detected:"
17         echo "$NVIDIABUSID"
18         echo "If this information is wrong, please report it to:"
19         echo "https://github.com/Bumblebee-Project/Bumblebee/issues"
20         # empty the ID so we can detect this as error
21         NVIDIABUSID=
22         ;;
23     esac
25     re_busid='^( *BusID +")[^"]*'
27     sed -E -i "$1" -e "s,${re_busid},\1${NVIDIABUSID},"
30 _backup() {
31     cp "$1" "$1.pacsave"
32     #echo "File $1 backed up as $1.pacsave"
35 _restore() {
36     local sumSave
37     local sumNew
38     if [ -f "$1.pacsave" ]; then
39         sumNew=$(openssl dgst -md5 "$1")
40         sumSave=$(openssl dgst -md5 "$1.pacsave")
41         if [ "x${sumSave##* }" = "x${sumNew##* }" ]; then
42             rm "$1.pacsave"
43         else
44             mv "$1" "$1.pacnew"
45             mv "$1.pacsave" "$1"
46             echo "New $1 saved as $1.pacnew"
47         fi
48     fi
51 pre_upgrade() {
52     rc.d stop bumblebeed
53     # Backup old config files if they exist
54     if [ -f /etc/bumblebee/xorg.conf.nvidia ]; then
55         _backup /etc/bumblebee/xorg.conf.nvidia
56     fi
57     if [ -f /etc/bumblebee/xorg.conf.nouveau ]; then
58         _backup /etc/bumblebee/xorg.conf.nouveau
59     fi
62 post_upgrade() {
63     if [ -f /etc/bumblebee/xorg.conf.nvidia ]; then
64         _replace_busid /etc/bumblebee/xorg.conf.nvidia
65         _restore /etc/bumblebee/xorg.conf.nvidia
66     fi
67     if [ -f /etc/bumblebee/xorg.conf.nouveau ]; then
68         _replace_busid /etc/bumblebee/xorg.conf.nouveau
69         _restore /etc/bumblebee/xorg.conf.nouveau
70     fi
71     groupadd bumblebee && echo "Bumblebee group created"
72     echo "Update complete."
73     #rc.d start bumblebee
76 pre_remove() {
77     rc.d stop bumblebeed
78     # Backup old config files if they exist
79     if [ -f /etc/bumblebee/xorg.conf.nvidia ]; then
80         _backup /etc/bumblebee/xorg.conf.nvidia
81     fi
82     if [ -f /etc/bumblebee/xorg.conf.nouveau ]; then
83         _backup /etc/bumblebee/xorg.conf.nouveau
84     fi
87 post_remove() {
88     #groupdel bumblebee && echo "Bumblebee group deleted"
89     echo "Uninstallation complete."
90     echo "You may delete the group 'bumblebee' now."
93 post_install() {
94     if [ -f /etc/bumblebee/xorg.conf.nvidia ]; then
95         _replace_busid /etc/bumblebee/xorg.conf.nvidia
96     fi
97     if [ -f /etc/bumblebee/xorg.conf.nouveau ]; then
98         _replace_busid /etc/bumblebee/xorg.conf.nouveau
99     fi
100     groupadd bumblebee && echo "Bumblebee group created"
101     echo
102     echo "Installation complete..."
103     echo "Visit ArchWiki page on Bumblebee for documentation on how to finish setup,"
104     echo "configure and run applications with Bumblebee:"
105     echo "http://wiki.archlinux.org/index.php/Bumblebee"
106     echo