FreeBSD 3D桌面实现手记:AIGLX与Beryl配置详解
最近几晚空闲时,一直在研究如何在FreeBSD上搭建3D桌面。翻阅了两篇写得很细致的参考文档,现将内容整合梳理出来。目前我尚未实际动手操作,因为还有几个关键问题没有完全想通。
先聊聊核心疑问
第一个问题:要实现XGL/GLX,xorg版本最低需要多少?是否必须xorg 7以上,还是xorg 6.9就能满足?
第二个问题:显卡支持情况如何?手头这块Intel 865G集成显卡,能否顺利跑起来?
下面这篇教程写得非常详细,不过有几个地方值得推敲,特别是第8步,看得有些困惑。有懂行的朋友欢迎指点。如果感兴趣,完全可以按照步骤尝试一下。
AIGLX for FreeBSD (FreeBSD Release 6.2 + AIGLX + Beryl) 完整流程
1. 系统安装
建议选择最小化安装,配置好网络和键盘即可,其余组件后续逐步补充。
2. bash
从ports安装bash,并设置为默认shell,之后新建用户也可直接指定bash。
root@cnbsd/# cd /usr/ports/shells/bash
root@cnbsd/usr/ports/shells/bash# make install clean
root@cnbsd/usr/ports/shells/bash# ln -s /usr/local/bin/bash /bin/bash
root@cnbsd/usr/ports/shells/bash# chsh -s /usr/local/bin/bash
root@cnbsd/usr/ports/shells/bash# reboot
系统安装完成后,别忘了安装linux_base、perl包,并修改fstab挂载/proc目录。环境变量可根据个人喜好调整。
3. axel
下载加速工具,使用后确实快了不少。
root@cnbsd/# cd /usr/ports/ftp/axel
root@cnbsd/usr/ports/ftp/axel# make install clean
root@cnbsd/etc# make.conf
加入以下内容:
FETCH_CMD = axel -a
MASTER_SITE_OVERRIDE= / ftp://ftp.freebsd.org.cn/pub/FreeBSD/ports/distfiles/ \
4. fcitx
输入法自然不能少。
wanglong@unixsir/usr/ports/chinese/fcitx$ make install clean
5. git
版本管理工具,后续拉取代码需要用。
root@cnbsd/etc# cd /usr/ports/devel/git
root@cnbsd/usr/ports/devel/git# make install clean
6. pkg_deinstall
root@cnbsd/usr/ports/sysutils/portupgrade# cd /usr/ports/sysutils/portupgrade
root@cnbsd/usr/ports/devel/git# cd /usr/ports/sysutils/portupgrade
root@cnbsd/usr/ports/sysutils/portupgrade# make install clean
7. pkgdb
root@cnbsd/usr/ports/sysutils/portupgrade# cd /usr/ports/sysutils/pkg_trackinst
root@cnbsd/usr/ports/sysutils/pkg_trackinst# make install clean
8. checkout the code
这一步是关键,也是最令人困惑的部分。
root@cnbsd/usr/ports/sysutils/pkg_trackinst# cd /usr
root@cnbsd/usr# mv ports ports.20070128
root@cnbsd/usr# git clone git://git.geekfire.com/git/ports.git
root@cnbsd/usr# cd ports
root@cnbsd/usr# pkg_info -Ex xorg- | grep -v linux | xargs -n1 pkg_create -b
root@cnbsd/usr# pkg_deinstall -fP xorg-\* libdrm-\* dri-\* libGL-\* libGLU-\* libglut-\* nvidia-driver-\*
root@cnbsd/usr# cd /usr/ports/x11/xorg
root@cnbsd/usr/ports/x11/xorg# make all install clean
root@cnbsd/usr/ports/x11/xorg# cd /usr
root@cnbsd/usr# pkgdb -F
root@cnbsd/usr# reboot
重启后配置xorg:
root@cnbsd/# Xorg -configure
root@cnbsd/# cp /root/xorg.conf.new /etc/X11/xorg.conf
在/etc/X11/xorg.conf中加入以下内容:
Section "ServerFlags"
Option "AIGLX" "on"
EndSection
Section "DRI"
Mode 0666
EndSection
Section "Extensions"
Option "Composite" "true"
EndSection
然后将#Option "Dac6Bit" # []改为Option "DRI" "True"。
9. 确认3D功能是否打开
在安装xfce4之前,先检查3D功能。通过/var/log/Xorg.0.log确认——Linux下可以轻松找到glxinfo,但FreeBSD的ports里似乎没有提供。
root@cnbsd/# Xorg -config /etc/X11/xorg.conf
root@cnbsd/# grep rendering /var/log/Xorg.0.log
(II) I810(0): direct rendering: Enabled
看到"Enabled"就可以稍微放心了。如果是"Disabled",多半是mesa或dri的问题,dri和mesa关系紧密,具体情况还需根据日志判断。
root@cnbsd/# cd /home
root@cnbsd/home# git clone git://anongit.freedesktop.org/git/mesa/mesa
root@cnbsd/home# chown -R surferwl:surferwl mesal
root@cnbsd/home# su - surferwl
surferwl@cnbsd~$
习惯使用surferwl这个用户,添加步骤这里省略。
编辑.profile加入:
export PKG_CONFIG_PATH=/usr/local/libdata/pkgconfigPKG_CONFIG_PATH
然后编译mesa:
root@cnbsd/# cd /home/mesa
root@cnbsd/home/mesa# gmake freebsd-dri-x86
root@cnbsd/home/mesa# gmake install
root@cnbsd/home/mesa# ln -s /usr/X11R6/lib/modules/dri /usr/X11R6/lib/dri
在/home/surferwl/.profile中加入:
export LIBGL_DRIVERS_PATH="/home/mesa/lib"
export LD_PRELOAD="/home/mesa/lib/libGL.so.1"
重启后再调试3D功能。关于drm,官方解释如下:"The DRM is shipped with the kernel, so you shouldn't need to build it. If you choose to, simply run 'make && make install' from the drm/bsd-core directory."
3D搞定之后再安装其他组件。
10. xfce4
root@cnbsd/usr/ports/x11-wm/xfce4# make install clean
11. beryl
root@cnbsd/usr/ports/x11-wm/beryl# make install clean
12. .xinitrc
surferwl@cnbsd~$ echo "exec fcitx -nb &" > .xinitrc
surferwl@cnbsd~$ echo "exec beryl-manager &" >> .xinitrc
surferwl@cnbsd~$ echo "exec /usr/local/bin/startxfce4" >> .xinitrc
接下来执行startx,或者配置gdm,然后就可以转动你的屏幕了。放张照片上去,360度随心所欲地旋转观看,就看你的发挥了!
最后补充几点:上述步骤掺杂了不少个人习惯,比如切换目录、使用bash shell等细节,明白大致思路照着操作即可。字体方面我习惯用simsun或文泉,这里没有写出。另外尚未仔细检查,可能有错字,但大体的思路就是这样。实际使用过程中没有发现问题,与不使用AIGLX功能时一样稳定,只是画面更加“动态”了。
