diff --git a/01_build_src.sh b/01_build_src.sh index 4efd394..0afbaef 100755 --- a/01_build_src.sh +++ b/01_build_src.sh @@ -1,22 +1,22 @@ #!/bin/sh if [ -f "/usr/bin/apt" ]; then - apt -y install gcc g++ make gawk bison libelf-dev bridge-utils + apt -y install gcc g++ make gawk flex bison libelf-dev libssl-dev bridge-utils fi if [ -f "/usr/bin/yum" ]; then - yum -y install gcc gcc-c++ make gawk bison elfutils-libelf bridge-utils + yum -y install gcc gcc-c++ make gawk flex bison elfutils-libelf libssl-dev bridge-utils fi #----------------------------------------------- # -# 导入公共变量 +# 导入公共变量 ( xfce4 需要 5.4.0 的内核 ) # #----------------------------------------------- . ./common.sh #LINUX_SRC_URL=https://kernel.org/pub/linux/kernel/v4.x/linux-4.14.9.tar.xz -LINUX_SRC_URL=https://mirror.bjtu.edu.cn/kernel/linux/kernel/v4.x/linux-4.14.9.tar.xz +LINUX_SRC_URL=https://mirror.bjtu.edu.cn/kernel/linux/kernel/v5.x/linux-5.8.6.tar.xz #GLIBC_SRC_URL=https://ftp.gnu.org/gnu/glibc/glibc-2.32.tar.bz2 GLIBC_SRC_URL=https://mirrors.ustc.edu.cn/gnu/glibc/glibc-2.27.tar.xz BUSYBOX_SRC_URL=https://busybox.net/downloads/busybox-1.34.1.tar.bz2 @@ -108,14 +108,41 @@ fi #--------------------------------------------- cd ${build_dir} -# 编译内核, 最终所有模块都装到目录 /lib/modules/4.14.9 +# 编译内核, 最终所有模块都装到目录 /lib/modules/5.8.6 if [ ! -d "linux_install" ]; then mkdir -pv linux_install && cd ${LINUX_SRC_DIR} && make mrproper && make x86_64_defconfig # Enable the VESA framebuffer for graphics support. sed -i "s/.*CONFIG_FB_VESA.*/CONFIG_FB_VESA=y/" .config + # xfce4 需要 drm 支持,内核版本尽量大于等于 18.04 的,所以选取了 5.8.6 的内核 + sed -i "/CONFIG_ARCH_HAS_PTE_SPECIAL=y/a\CONFIG_MAPPING_DIRTY_HELPERS=y" .config + sed -i "/# CONFIG_DRM_DP_CEC is not set/a\CONFIG_DRM_TTM=m" .config + sed -i "/CONFIG_DRM_TTM=m/a\CONFIG_DRM_TTM_DMA_PAGE_POOL=y" .config + sed -i "/CONFIG_DRM_TTM_DMA_PAGE_POOL=y/a\CONFIG_DRM_VRAM_HELPER=m" .config + sed -i "/CONFIG_DRM_VRAM_HELPER=m/a\CONFIG_DRM_TTM_HELPER=m" .config + sed -i "/CONFIG_DRM_TTM_HELPER=m/a\CONFIG_DRM_GEM_SHMEM_HELPER=y" .config + sed -i "/# CONFIG_FIRMWARE_EDID is not set/a\CONFIG_FB_BOOT_VESA_SUPPORT=y" .config + sed -i "/CONFIG_FB_DEFERRED_IO=y/a\CONFIG_FB_BACKLIGHT=m" .config + sed -i "/CONFIG_HDMI=y/i\CONFIG_VGASTATE=m" .config + sed -i "s/# CONFIG_FB_BACKLIGHT is not set/CONFIG_FB_BACKLIGHT=y/" .config + sed -i "s/# CONFIG_FB_CIRRUS is not set/CONFIG_FB_CIRRUS=m/" .config + sed -i "s/# CONFIG_FB_VGA16 is not set/CONFIG_FB_VGA16=m/" .config + sed -i "s/# CONFIG_FB_UVESA is not set/CONFIG_FB_UVESA=m/" .config + sed -i "s/# CONFIG_FB_OPENCORES is not set/CONFIG_FB_OPENCORES=m/" .config + sed -i "s/# CONFIG_FB_NVIDIA is not set/CONFIG_FB_NVIDIA=m/" .config + sed -i "/CONFIG_FB_NVIDIA=m/a\# CONFIG_FB_NVIDIA_I2C is not set" .config + sed -i "/# CONFIG_FB_NVIDIA_I2C is not set/a\# CONFIG_FB_NVIDIA_DEBUG is not set" .config + sed -i "/# CONFIG_FB_NVIDIA_DEBUG is not set/a\CONFIG_FB_NVIDIA_BACKLIGHT=y" .config + sed -i "s/# CONFIG_FB_IBM_GXT4500 is not set/CONFIG_FB_IBM_GXT4500=m/" .config + sed -i "s/# CONFIG_FB_SIMPLE is not set/CONFIG_FB_SIMPLE=y/" .config + sed -i "s/# CONFIG_VGASTATE is not set/CONFIG_VGASTATE=m/" .config + sed -i "s/# CONFIG_DRM_VMWGFX is not set/CONFIG_DRM_VMWGFX=m\nCONFIG_DRM_VMWGFX_FBCON=y/" .config + sed -i "s/# CONFIG_DRM_CIRRUS_QEMU is not set/CONFIG_DRM_CIRRUS_QEMU=m/" .config + sed -i "s/# CONFIG_DRM_QXL is not set/CONFIG_DRM_QXL=m/" .config + sed -i "s/# CONFIG_DRM_BOCHS is not set/CONFIG_DRM_BOCHS=m/" .config + sed -i "s/# CONFIG_DRM_HISI_HIBMC is not set/CONFIG_DRM_HISI_HIBMC=m/" .config # 网络需要 TUN/TAP 驱动 [ Device Drivers ] ---> [ Network device support ] ---> [ Universal TUN/TAP device driver support ] make bzImage -j8 - #cd linux-4.14.9 && make x86_64_defconfig && make bzImage -j8 && make modules && make modules_install && cd .. + #cd linux-5.8.6 && make x86_64_defconfig && make bzImage -j8 && make modules && make modules_install && cd .. make INSTALL_HDR_PATH=${linux_install} headers_install -j8 && cp arch/x86_64/boot/bzImage ${linux_install} && cd .. fi diff --git a/02_build_img.sh b/02_build_img.sh index eb3fbe5..adb8bd2 100755 --- a/02_build_img.sh +++ b/02_build_img.sh @@ -187,7 +187,7 @@ if [ "${with_xfce}" = true ]; then # 构建 Xorg 的键盘数据 rm ${xfce_install}/usr/local/share/X11/xkb -rf ln -s /usr/share/X11/xkb ${xfce_install}/usr/local/share/X11 - # 依赖版本 3 + # 依赖版本 libpcre.so.3 if [ -f "${xfce_install}/usr/local/lib/libpcre.so.1" ]; then mv ${xfce_install}/usr/local/lib/libpcre.so.1 ${xfce_install}/usr/local/lib/libpcre.so.3 fi @@ -199,6 +199,10 @@ if [ "${with_xfce}" = true ]; then if [ -f "${xfce_install}/usr/lib/libtinfo.so.6" ]; then mv ${xfce_install}/usr/lib/libtinfo.so.6 ${xfce_install}/usr/lib/libtinfo.so.5 fi + # 依赖版本 libffi.so.6 + if [ -f "${xfce_install}/usr/local/lib/libffi.so.8" ]; then + cp ${xfce_install}/usr/local/lib/libffi.so.8 ${xfce_install}/usr/local/lib/libffi.so.6 + fi # dbus 用户添加 echo "video:x:44:" >> ${diskfs}/etc/group echo "messagebus:x:107:" >> ${diskfs}/etc/group @@ -230,7 +234,7 @@ fi # 我们测试驱动, 制作的镜像启动后,我们进入此目录 insmod hello_world.ko 即可 ./mk_drv.sh $(pwd)/${diskfs}/lib/modules # 编译网卡驱动 ( 目前版本内核已集成 e1000 ) -# cd ${build_dir}/linux-4.14.9 && make M=drivers/net/ethernet/intel/e1000/ && cd ../.. +# cd ${build_dir}/linux-5.8.6 && make M=drivers/net/ethernet/intel/e1000/ && cd ../.. # 生成 grub.cfg 文件, 增加 console=ttyS0 就会让 qemu 输出日志到 qemu.log cat - > ${diskfs}/boot/grub/grub.cfg << EOF diff --git a/03_run_qemu.sh b/03_run_qemu.sh index 64ef377..55cc7c6 100755 --- a/03_run_qemu.sh +++ b/03_run_qemu.sh @@ -91,6 +91,9 @@ else sdb_img="-hdb extra.img" fi +# 指定内存 +memory="-m 4G" + # 主磁盘 disk="-drive format=raw,file=disk.img" @@ -101,11 +104,11 @@ logfile="-serial file:./qemu.log" # 网络参数 network="-netdev tap,id=nd0,ifname=tap0,script=no,downscript=no -device e1000,netdev=nd0" -# 显卡参数 -display="-vga std" +# 显卡参数 需要编译 xf86-video-vmware, see mk_xfce.sh +display="-vga vmware" # 启动镜像 网络对应 run_nat.sh 里面的配置 ( -enable-kvm : vmware 里面 CPU 设置需要支持虚拟化 Intel VT-x/EPT 或 AMD-V/RVI ) -qemu-system-x86_64 -enable-kvm ${disk} ${sdb_img} ${network} ${logfile} ${display} - +# 命令 qemu-system-x86_64 -device help 可以查看支持哪些设备 +qemu-system-x86_64 -enable-kvm ${display} ${memory} ${disk} ${sdb_img} ${network} ${logfile} # stop nat stop_nat diff --git a/mk_drv.sh b/mk_drv.sh index 9334d1c..05646bc 100755 --- a/mk_drv.sh +++ b/mk_drv.sh @@ -27,9 +27,9 @@ EOF cat<Makefile obj-m += hello_world.o all: - make -C ../build/linux-4.14.9 M=`pwd` modules + make -C ../build/linux-5.8.6 M=`pwd` modules clean: - make -C ../build/linux-4.14.9 M=`pwd` clean + make -C ../build/linux-5.8.6 M=`pwd` clean EOF echo $1 diff --git a/mk_xfce.sh b/mk_xfce.sh index 5feae15..bb234f3 100755 --- a/mk_xfce.sh +++ b/mk_xfce.sh @@ -142,6 +142,7 @@ FONTUTIL_SRC_URL=https://www.x.org/releases/individual/font/font-util-1.3.3.tar. FONTMISC_SRC_URL=https://www.x.org/releases/individual/font/font-misc-misc-1.1.2.tar.bz2 XF86INPUT_SRC_URL=https://www.x.org/releases/individual/driver/xf86-input-libinput-1.2.1.tar.xz XF86VIDEOVESA_SRC_URL=https://www.x.org/releases/individual/driver/xf86-video-vesa-2.5.0.tar.bz2 +XF86VIDEOVMWARE_SRC_URL=https://www.x.org/releases/individual/driver/xf86-video-vmware-13.3.0.tar.bz2 XKBDATA_SRC_URL=https://www.x.org/releases/individual/data/xkbdata-1.0.1.tar.bz2 XKBDCFG_SRC_URL=https://www.x.org/releases/individual/data/xkeyboard-config/xkeyboard-config-2.36.tar.xz @@ -258,6 +259,7 @@ LIBWACOM_SRC_NAME=$(download_src ${LIBWACOM_SRC_URL}) LIBINPUT_SRC_NAME=$(download_src ${LIBINPUT_SRC_URL}) XF86INPUT_SRC_NAME=$(download_src ${XF86INPUT_SRC_URL}) XF86VIDEOVESA_SRC_NAME=$(download_src ${XF86VIDEOVESA_SRC_URL}) +XF86VIDEOVMWARE_SRC_NAME=$(download_src ${XF86VIDEOVMWARE_SRC_URL}) DEJAVUFONTS1_SRC_NAME=$(download_src ${DEJAVUFONTS1_SRC_URL}) DEJAVUFONTS2_SRC_NAME=$(download_src ${DEJAVUFONTS2_SRC_URL}) GNOMEICONTHEME_SRC_NAME=$(download_src ${GNOMEICONTHEME_SRC_URL}) @@ -382,6 +384,7 @@ LIBEVDEV_SRC_DIR=$(unzip_src ".tar.xz" ${LIBEVDEV_SRC_NAME}); echo "unzip ${LIBE LIBINPUT_SRC_DIR=$(unzip_src ".tar.xz" ${LIBINPUT_SRC_NAME}); echo "unzip ${LIBINPUT_SRC_NAME} source code" XF86INPUT_SRC_DIR=$(unzip_src ".tar.xz" ${XF86INPUT_SRC_NAME}); echo "unzip ${XF86INPUT_SRC_NAME} source code" XF86VIDEOVESA_SRC_DIR=$(unzip_src ".tar.bz2" ${XF86VIDEOVESA_SRC_NAME}); echo "unzip ${XF86VIDEOVESA_SRC_NAME} source code" +XF86VIDEOVMWARE_SRC_DIR=$(unzip_src ".tar.bz2" ${XF86VIDEOVMWARE_SRC_NAME}); echo "unzip ${XF86VIDEOVMWARE_SRC_NAME} source code" DEJAVUFONTS1_SRC_DIR=$(unzip_src ".tar.bz2" ${DEJAVUFONTS1_SRC_NAME}); echo "unzip ${DEJAVUFONTS1_SRC_NAME} source code" DEJAVUFONTS2_SRC_DIR=$(unzip_src ".tar.bz2" ${DEJAVUFONTS2_SRC_NAME}); echo "unzip ${DEJAVUFONTS2_SRC_NAME} source code" GNOMEICONTHEME_SRC_DIR=$(unzip_src ".tar.xz" ${GNOMEICONTHEME_SRC_NAME}); echo "unzip ${GNOMEICONTHEME_SRC_NAME} source code" @@ -846,6 +849,8 @@ llvm_build() { common_build xf86input ${XF86INPUT_SRC_DIR} # xf86videovesa ( vesa是一个支持大部分显卡的通用驱动,不提供任何 2D 和 3D 加速功能 也可以 apt install libgl1-mesa-dri ) common_build xf86videovesa ${XF86VIDEOVESA_SRC_DIR} + # xf86videovmware ( qemu 要模拟 vmware 的显卡,需要编译此工程 -vga vmware ) + common_build xf86videovmware ${XF86VIDEOVMWARE_SRC_DIR} # gsetting-desktop-schemas meson_build gsetting-desktop-schemas ${GSETDESKTOPSCHEMAS_SRC_DIR}