mirror of
https://github.com/superconvert/smart-os.git
synced 2024-11-24 11:00:35 +08:00
update some script
This commit is contained in:
parent
e9c9c533bf
commit
b4153d2f65
@ -10,11 +10,10 @@ fi
|
|||||||
|
|
||||||
#-----------------------------------------------
|
#-----------------------------------------------
|
||||||
#
|
#
|
||||||
# 导入公共变量 ( xfce4 需要 5.4.0 的内核 )
|
# 导入公共变量 ( xfce4 需要 5.4.0 的内核, glibc 必须为 2.27 否则 xfce4 相关的编译有问题 )
|
||||||
#
|
#
|
||||||
#-----------------------------------------------
|
#-----------------------------------------------
|
||||||
. ./common.sh
|
. ./common.sh
|
||||||
|
|
||||||
#LINUX_SRC_URL=https://kernel.org/pub/linux/kernel/v4.x/linux-4.14.9.tar.xz
|
#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/v5.x/linux-5.8.6.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://ftp.gnu.org/gnu/glibc/glibc-2.32.tar.bz2
|
||||||
@ -31,8 +30,6 @@ GCC_SRC_URL=https://mirrors.ustc.edu.cn/gnu/gcc/gcc-7.5.0/gcc-7.5.0.tar.xz
|
|||||||
#BINUTILS_SRC_URL=https://ftp.gnu.org/gnu/binutils/binutils-2.36.tar.xz
|
#BINUTILS_SRC_URL=https://ftp.gnu.org/gnu/binutils/binutils-2.36.tar.xz
|
||||||
BINUTILS_SRC_URL=https://mirrors.ustc.edu.cn/gnu/binutils/binutils-2.36.tar.xz
|
BINUTILS_SRC_URL=https://mirrors.ustc.edu.cn/gnu/binutils/binutils-2.36.tar.xz
|
||||||
|
|
||||||
export CFLAGS="-Os -s -fno-stack-protector -fomit-frame-pointer -U_FORTIFY_SOURCE"
|
|
||||||
|
|
||||||
#----------------------------------------------
|
#----------------------------------------------
|
||||||
#
|
#
|
||||||
# 下载源码
|
# 下载源码
|
||||||
@ -59,7 +56,6 @@ cd ..
|
|||||||
#
|
#
|
||||||
#---------------------------------------------
|
#---------------------------------------------
|
||||||
mkdir -pv ${build_dir}
|
mkdir -pv ${build_dir}
|
||||||
|
|
||||||
LINUX_SRC_DIR=$(unzip_src ".tar.xz" ${LINUX_SRC_NAME}); echo "unzip ${LINUX_SRC_NAME} source code"
|
LINUX_SRC_DIR=$(unzip_src ".tar.xz" ${LINUX_SRC_NAME}); echo "unzip ${LINUX_SRC_NAME} source code"
|
||||||
GLIBC_SRC_DIR=$(unzip_src ".tar.xz" ${GLIBC_SRC_NAME}); echo "unzip ${GLIBC_SRC_NAME} source code"
|
GLIBC_SRC_DIR=$(unzip_src ".tar.xz" ${GLIBC_SRC_NAME}); echo "unzip ${GLIBC_SRC_NAME} source code"
|
||||||
BUSYBOX_SRC_DIR=$(unzip_src ".tar.bz2" ${BUSYBOX_SRC_NAME}); echo "unzip ${BUSYBOX_SRC_NAME} source code"
|
BUSYBOX_SRC_DIR=$(unzip_src ".tar.bz2" ${BUSYBOX_SRC_NAME}); echo "unzip ${BUSYBOX_SRC_NAME} source code"
|
||||||
@ -90,6 +86,8 @@ fi
|
|||||||
# 编译源码
|
# 编译源码
|
||||||
#
|
#
|
||||||
#---------------------------------------------
|
#---------------------------------------------
|
||||||
|
export CFLAGS="-Os -s -fno-stack-protector -fomit-frame-pointer -U_FORTIFY_SOURCE"
|
||||||
|
|
||||||
cd ${build_dir}
|
cd ${build_dir}
|
||||||
|
|
||||||
# 编译内核, 最终所有模块都装到目录 /lib/modules/5.8.6
|
# 编译内核, 最终所有模块都装到目录 /lib/modules/5.8.6
|
||||||
@ -287,7 +285,8 @@ if [ ! -d "linux_install" ]; then
|
|||||||
make modules -j8
|
make modules -j8
|
||||||
#cd linux-5.8.6 && 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
|
make INSTALL_HDR_PATH=${linux_install} headers_install -j8
|
||||||
make modules_install INSTALL_MOD_PATH=${linux_install} -j8 && cp arch/x86_64/boot/bzImage ${linux_install} && cd ..
|
make modules_install INSTALL_MOD_PATH=${linux_install} -j8 && cp arch/x86_64/boot/bzImage ${linux_install} || exit
|
||||||
|
cd ..
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 编译glibc
|
# 编译glibc
|
||||||
@ -301,7 +300,7 @@ if [ ! -d "glibc_install" ]; then
|
|||||||
--disable-werror \
|
--disable-werror \
|
||||||
--disable-werror \
|
--disable-werror \
|
||||||
CFLAGS="$CFLAGS"
|
CFLAGS="$CFLAGS"
|
||||||
make -j8 && make install -j8 DESTDIR=${glibc_install}
|
make -j8 && make install -j8 DESTDIR=${glibc_install} || exit
|
||||||
cd .. && cd ..
|
cd .. && cd ..
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -317,21 +316,21 @@ if [ ! -d "busybox_install" ]; then
|
|||||||
sed -i "s|.*CONFIG_EXTRA_CFLAGS.*|CONFIG_EXTRA_CFLAGS=\"-I${linux_install}/include -I${glibc_install}/include -L${glibc_install}/usr/lib64 $CFLAGS\"|" .config
|
sed -i "s|.*CONFIG_EXTRA_CFLAGS.*|CONFIG_EXTRA_CFLAGS=\"-I${linux_install}/include -I${glibc_install}/include -L${glibc_install}/usr/lib64 $CFLAGS\"|" .config
|
||||||
# 环境变量 PATH 的设定,因为 busybox 的 init 会覆盖用户设置的 PATH,只能源码进行编译
|
# 环境变量 PATH 的设定,因为 busybox 的 init 会覆盖用户设置的 PATH,只能源码进行编译
|
||||||
sed -i "s|#define BB_ADDITIONAL_PATH \"\"|#define BB_ADDITIONAL_PATH \":/usr/local/sbin:/usr/local/bin\"|" include/libbb.h
|
sed -i "s|#define BB_ADDITIONAL_PATH \"\"|#define BB_ADDITIONAL_PATH \":/usr/local/sbin:/usr/local/bin\"|" include/libbb.h
|
||||||
make busybox -j8 && make CONFIG_PREFIX=${busybox_install} install
|
make busybox -j8 && make CONFIG_PREFIX=${busybox_install} install || exit
|
||||||
cd ..
|
cd ..
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 编译 lshw ( 调试方便 )
|
# 编译 lshw ( 调试方便 )
|
||||||
if [ ! -d "lshw_install" ]; then
|
if [ ! -d "lshw_install" ]; then
|
||||||
mkdir -pv lshw_install && cd ${LSHW_SRC_DIR}
|
mkdir -pv lshw_install && cd ${LSHW_SRC_DIR}
|
||||||
CFLAGS="-L${glibc_install}/lib64 $CFLAGS" make -j8 && make install -j8 DESTDIR=${lshw_install} PREFIX=/usr
|
CFLAGS="-L${glibc_install}/lib64 $CFLAGS" make -j8 && make install -j8 DESTDIR=${lshw_install} PREFIX=/usr || exit
|
||||||
cd ..
|
cd ..
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 编译 pciutils ( busybox 的 lspci 太简单 )
|
# 编译 pciutils ( busybox 的 lspci 太简单 )
|
||||||
if [ ! -d "pciutils_install" ]; then
|
if [ ! -d "pciutils_install" ]; then
|
||||||
mkdir -pv pciutils_install && cd ${PCIUTILS_SRC_DIR}
|
mkdir -pv pciutils_install && cd ${PCIUTILS_SRC_DIR}
|
||||||
CFLAGS="-L${glibc_install}/lib64 $CFLAGS" make -j8 && make install -j8 DESTDIR=${pciutils_install} PREFIX=/usr
|
CFLAGS="-L${glibc_install}/lib64 $CFLAGS" make -j8 && make install -j8 DESTDIR=${pciutils_install} PREFIX=/usr || exit
|
||||||
cd ..
|
cd ..
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -339,8 +338,7 @@ fi
|
|||||||
if [ ! -d "lsof_install" ]; then
|
if [ ! -d "lsof_install" ]; then
|
||||||
mkdir -pv lsof_install && cd ${LSOF_SRC_DIR}
|
mkdir -pv lsof_install && cd ${LSOF_SRC_DIR}
|
||||||
./Configure linux -n
|
./Configure linux -n
|
||||||
CFLAGS="-L${glibc_install}/lib64 $CFLAGS" make -j8
|
CFLAGS="-L${glibc_install}/lib64 $CFLAGS" make -j8 && mkdir -pv ${lsof_install}/usr/bin && cp ./lsof ${lsof_install}/usr/bin || exit
|
||||||
mkdir -pv ${lsof_install}/usr/bin && cp ./lsof ${lsof_install}/usr/bin
|
|
||||||
cd ..
|
cd ..
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -348,7 +346,7 @@ fi
|
|||||||
if [ ! -d "strace_install" ]; then
|
if [ ! -d "strace_install" ]; then
|
||||||
mkdir -pv strace_install && cd ${STRACE_SRC_DIR}
|
mkdir -pv strace_install && cd ${STRACE_SRC_DIR}
|
||||||
./configure --prefix=/usr --enable-mpers=no
|
./configure --prefix=/usr --enable-mpers=no
|
||||||
CFLAGS="-L${glibc_install}/lib64 $CFLAGS" make -j8 && make install -j8 DESTDIR=${strace_install} PREFIX=/usr
|
CFLAGS="-L${glibc_install}/lib64 $CFLAGS" make -j8 && make install -j8 DESTDIR=${strace_install} PREFIX=/usr || exit
|
||||||
cd ..
|
cd ..
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -356,11 +354,11 @@ fi
|
|||||||
if [ ! -d "openssl_install" ]; then
|
if [ ! -d "openssl_install" ]; then
|
||||||
mkdir -pv openssl_install && cd ${OPENSSL_SRC_DIR}
|
mkdir -pv openssl_install && cd ${OPENSSL_SRC_DIR}
|
||||||
./config --prefix=/usr shared
|
./config --prefix=/usr shared
|
||||||
CFLAGS="-L${glibc_install}/lib64 $CFLAGS" make -j8 && make install -j8 DESTDIR=${openssl_install} PREFIX=/usr
|
CFLAGS="-L${glibc_install}/lib64 $CFLAGS" make -j8 && make install -j8 DESTDIR=${openssl_install} PREFIX=/usr || exit
|
||||||
cd ..
|
cd ..
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 编译 openssh
|
# 编译 openssh ( 需要 openssl )
|
||||||
if [ ! -d "openssh_install" ]; then
|
if [ ! -d "openssh_install" ]; then
|
||||||
mkdir -pv openssh_install && cd ${OPENSSH_SRC_DIR}
|
mkdir -pv openssh_install && cd ${OPENSSH_SRC_DIR}
|
||||||
./configure --prefix=/usr --sysconfdir=/etc/ssh --with-ssl-dir=${openssl_install}/usr/ --without-openssl-header-check
|
./configure --prefix=/usr --sysconfdir=/etc/ssh --with-ssl-dir=${openssl_install}/usr/ --without-openssl-header-check
|
||||||
@ -403,7 +401,7 @@ fi
|
|||||||
if [ ! -d "binutils_install" ]; then
|
if [ ! -d "binutils_install" ]; then
|
||||||
mkdir -pv binutils_install && cd ${BINUTILS_SRC_DIR} && make distclean
|
mkdir -pv binutils_install && cd ${BINUTILS_SRC_DIR} && make distclean
|
||||||
./configure --prefix=/usr
|
./configure --prefix=/usr
|
||||||
CFLAGS="-L${glibc_install}/lib64 $CFLAGS" make -j8 && make install -j8 DESTDIR=${binutils_install}
|
CFLAGS="-L${glibc_install}/lib64 $CFLAGS" make -j8 && make install -j8 DESTDIR=${binutils_install} || exit
|
||||||
cd ..
|
cd ..
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
#----------------------------------------------
|
||||||
|
#
|
||||||
# 导入公共环境
|
# 导入公共环境
|
||||||
|
#
|
||||||
|
#----------------------------------------------
|
||||||
. ./common.sh
|
. ./common.sh
|
||||||
|
|
||||||
#----------------------------------------------
|
#----------------------------------------------
|
||||||
@ -31,7 +35,7 @@ losetup -o 1048576 ${loop_dev} disk.img
|
|||||||
# 对磁盘进行格式化
|
# 对磁盘进行格式化
|
||||||
mkfs.ext3 ${loop_dev}
|
mkfs.ext3 ${loop_dev}
|
||||||
|
|
||||||
# 如果制作的 disk.img 转换为 qemu-img convert disk.img -f raw -O vmdk out.vmdk, vmware 的磁盘类型一定设置为 SATA ,否则,启动失败
|
# 如果制作的 disk.img
|
||||||
diskfs="diskfs"
|
diskfs="diskfs"
|
||||||
# 挂载磁盘到本地目录
|
# 挂载磁盘到本地目录
|
||||||
mkdir -pv ${diskfs}
|
mkdir -pv ${diskfs}
|
||||||
@ -57,6 +61,7 @@ mkdir -pv rootfs/sbin
|
|||||||
mkdir -pv rootfs/proc
|
mkdir -pv rootfs/proc
|
||||||
mkdir -pv rootfs/root
|
mkdir -pv rootfs/root
|
||||||
mkdir -pv rootfs/lib64
|
mkdir -pv rootfs/lib64
|
||||||
|
mkdir -pv rootfs/var/run
|
||||||
mkdir -pv rootfs/lib/modules
|
mkdir -pv rootfs/lib/modules
|
||||||
|
|
||||||
# 拷贝内核镜像
|
# 拷贝内核镜像
|
||||||
@ -69,6 +74,7 @@ rm -rf rootfs/var/db
|
|||||||
rm -rf rootfs/share
|
rm -rf rootfs/share
|
||||||
rm -rf rootfs/usr/share
|
rm -rf rootfs/usr/share
|
||||||
find rootfs/ -name "*.a" -exec rm -rf {} \;
|
find rootfs/ -name "*.a" -exec rm -rf {} \;
|
||||||
|
|
||||||
# 编译的镜像带有 gcc 编译器
|
# 编译的镜像带有 gcc 编译器
|
||||||
if [ "${with_gcc}" = false ]; then
|
if [ "${with_gcc}" = false ]; then
|
||||||
rm -rf rootfs/usr/include
|
rm -rf rootfs/usr/include
|
||||||
@ -103,18 +109,23 @@ make_init() {
|
|||||||
|
|
||||||
cat<<"EOF">init
|
cat<<"EOF">init
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# 必须首先挂载,否则 mdev 不能正常工作
|
# 必须首先挂载,否则 mdev 不能正常工作
|
||||||
mount -t sysfs sysfs /sys
|
mount -t sysfs sysfs /sys
|
||||||
mount -t proc proc /proc
|
mount -t proc proc /proc
|
||||||
mount -t devtmpfs udev /dev
|
mount -t devtmpfs udev /dev
|
||||||
mount -t tmpfs tmpfs /tmp -o mode=1777
|
mount -t tmpfs tmpfs /tmp -o mode=1777
|
||||||
|
|
||||||
# 必须挂载一下,否则下面的 mount 不上
|
# 必须挂载一下,否则下面的 mount 不上
|
||||||
mdev -s
|
mdev -s
|
||||||
mount -t ext3 /dev/sda1 /mnt
|
mount -t ext3 /dev/sda1 /mnt
|
||||||
|
|
||||||
# 关闭内核烦人的输出信息
|
# 关闭内核烦人的输出信息
|
||||||
echo 0 > /proc/sys/kernel/printk
|
echo 0 > /proc/sys/kernel/printk
|
||||||
|
|
||||||
# 热插拔处理都交给 mdev
|
# 热插拔处理都交给 mdev
|
||||||
# echo /sbin/mdev > /proc/sys/kernel/hotplug
|
# echo /sbin/mdev > /proc/sys/kernel/hotplug
|
||||||
|
|
||||||
echo -e "\n\e[0;32mBoot took $(cut -d' ' -f1 /proc/uptime) seconds\e[0m"
|
echo -e "\n\e[0;32mBoot took $(cut -d' ' -f1 /proc/uptime) seconds\e[0m"
|
||||||
mkdir -p /dev/pts
|
mkdir -p /dev/pts
|
||||||
mount -t devpts devpts /dev/pts
|
mount -t devpts devpts /dev/pts
|
||||||
@ -123,10 +134,11 @@ mount --move /dev /mnt/dev
|
|||||||
mount --move /sys /mnt/sys
|
mount --move /sys /mnt/sys
|
||||||
mount --move /proc /mnt/proc
|
mount --move /proc /mnt/proc
|
||||||
mount --move /tmp /mnt/tmp
|
mount --move /tmp /mnt/tmp
|
||||||
# 切换到真正的磁盘系统上 rootfs ---> diskfs
|
|
||||||
# 因为 busybox 的 init 会重置环境变量,因此需要加动这里
|
# 因为 busybox 的 init 会重置环境变量 PATH 等,因此需要放到这里加载
|
||||||
export LD_LIBRARY_PATH="/lib:/lib64:/usr/lib:/usr/lib64:/usr/local/lib:/usr/local/lib64:/usr/lib/x86_64-linux-gnu"
|
export LD_LIBRARY_PATH="/lib:/lib64:/usr/lib:/usr/lib64:/usr/local/lib:/usr/local/lib64:/usr/lib/x86_64-linux-gnu"
|
||||||
# 切换到真正的文件系统
|
|
||||||
|
# 切换到真正的磁盘系统上 rootfs ---> diskfs, 切换到真正的文件系统
|
||||||
exec switch_root /mnt /sbin/init
|
exec switch_root /mnt /sbin/init
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
@ -144,23 +156,22 @@ make_init
|
|||||||
# mknod -m 600 dev/console c 5 1
|
# mknod -m 600 dev/console c 5 1
|
||||||
# mknod -m 644 dev/null c 1 3
|
# mknod -m 644 dev/null c 1 3
|
||||||
# mknod -m 640 dev/sda1 b 8 1
|
# mknod -m 640 dev/sda1 b 8 1
|
||||||
# xfce 需要显卡设备
|
|
||||||
# mknod -m 664 dev/dri/card0 c 226 0
|
|
||||||
|
|
||||||
# 指定了利用 /etc/init.d/rcS 启动
|
# 指定了利用 /etc/init.d/rcS 启动
|
||||||
cat<<"EOF">etc/inittab
|
cat<<"EOF">etc/inittab
|
||||||
|
|
||||||
# 启动 syslogd
|
# 启动 syslogd ( 日志系统 )
|
||||||
::sysinit:/bin/echo "starting syslogd ... ..."
|
::sysinit:/bin/echo "starting syslogd ... ..."
|
||||||
::sysinit:/sbin/syslogd
|
::sysinit:/sbin/syslogd
|
||||||
::sysinit:/sbin/klogd
|
::sysinit:/sbin/klogd
|
||||||
|
|
||||||
# 启动 udevd 服务,保证鼠标设备能正常监视,否则键盘不能使用
|
# 启动 udevd 服务,保证鼠标设备能正常监视,否则桌面系统下键盘不能使用
|
||||||
::sysinit:/bin/echo "starting udevd ... ..."
|
::sysinit:/bin/echo "starting udevd ... ..."
|
||||||
::sysinit:/usr/sbin/udevd --daemon
|
::sysinit:/usr/sbin/udevd --daemon
|
||||||
::sysinit:/usr/sbin/udevadm trigger
|
::sysinit:/usr/sbin/udevadm trigger
|
||||||
::sysinit:/usr/sbin/udevadm settle
|
::sysinit:/usr/sbin/udevadm settle
|
||||||
|
|
||||||
|
# 基本启动信息都放到这个脚本里
|
||||||
::sysinit:echo "sysinit ++++++++++++++++++++++++++++++++++++++"
|
::sysinit:echo "sysinit ++++++++++++++++++++++++++++++++++++++"
|
||||||
::sysinit:/etc/init.d/rcS
|
::sysinit:/etc/init.d/rcS
|
||||||
::sysinit:echo "sysinit ++++++++++++++++++++++++++++++++++++++"
|
::sysinit:echo "sysinit ++++++++++++++++++++++++++++++++++++++"
|
||||||
@ -173,6 +184,7 @@ cat<<"EOF">etc/inittab
|
|||||||
# this yourself...
|
# this yourself...
|
||||||
#
|
#
|
||||||
# Start an "askfirst" shell on the console (whatever that may be) -f root 自动登录
|
# Start an "askfirst" shell on the console (whatever that may be) -f root 自动登录
|
||||||
|
|
||||||
# 一定要加 tty1 ,否则登录时,会提示 : root login on 'UNKNOWN'
|
# 一定要加 tty1 ,否则登录时,会提示 : root login on 'UNKNOWN'
|
||||||
tty1::respawn:-/bin/login -f root
|
tty1::respawn:-/bin/login -f root
|
||||||
# Start an "askfirst" shell on /dev/tty2-4
|
# Start an "askfirst" shell on /dev/tty2-4
|
||||||
@ -200,6 +212,7 @@ tty5::respawn:/sbin/getty 38400 tty6
|
|||||||
::shutdown:/sbin/swapoff -a
|
::shutdown:/sbin/swapoff -a
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
# 制作 initrd 文件系统
|
||||||
find . | cpio -R root:root -H newc -o | gzip -9 > ../${diskfs}/boot/initrd
|
find . | cpio -R root:root -H newc -o | gzip -9 > ../${diskfs}/boot/initrd
|
||||||
echo "${GREEN}+++ build initrd ok +++${NC}"
|
echo "${GREEN}+++ build initrd ok +++${NC}"
|
||||||
cd ..
|
cd ..
|
||||||
@ -270,21 +283,25 @@ if [ "${with_xfce}" = true ]; then
|
|||||||
if [ -f "${xfce_install}/usr/local/lib/libffi.so.8" ]; then
|
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
|
cp ${xfce_install}/usr/local/lib/libffi.so.8 ${xfce_install}/usr/local/lib/libffi.so.6
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# dbus 用户添加
|
# dbus 用户添加
|
||||||
echo "video:x:44:" >> ${diskfs}/etc/group
|
echo "video:x:44:" >> ${diskfs}/etc/group
|
||||||
echo "messagebus:x:107:" >> ${diskfs}/etc/group
|
echo "messagebus:x:107:" >> ${diskfs}/etc/group
|
||||||
echo "messagebus:x:103:107::/nonexistent:/usr/sbin/nologin" >> ${diskfs}/etc/passwd
|
echo "messagebus:x:103:107::/nonexistent:/usr/sbin/nologin" >> ${diskfs}/etc/passwd
|
||||||
# dbus 启动需要这个,否则 upowerd 就不能正常工作
|
# dbus 启动需要这个,否则 upowerd 就不能正常工作
|
||||||
cp ${xfce_install}/usr/share/dbus-1/* ${xfce_install}/usr/local/share/dbus-1/ -r
|
cp ${xfce_install}/usr/share/dbus-1/* ${xfce_install}/usr/local/share/dbus-1/ -r
|
||||||
|
|
||||||
# dbus 启动脚本
|
# dbus 启动脚本
|
||||||
# dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
|
# dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
|
||||||
# dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
|
# dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
|
||||||
# dbus-daemon --config-file=/usr/share/defaults/at-spi2/accessibility.conf --nofork --print-address 3
|
# dbus-daemon --config-file=/usr/share/defaults/at-spi2/accessibility.conf --nofork --print-address 3
|
||||||
# 常用的 dbus 命令
|
# 常用的 dbus 命令
|
||||||
# 列出所有的dbus服务 :
|
# 列出所有的dbus服务 :
|
||||||
# dbus-send --system --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.ListActivatableNames
|
# dbus-send --system --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.ListActivatableNames
|
||||||
# UPower 的dbus服务 :
|
# UPower 的dbus服务 :
|
||||||
# dbus-send --print-reply --system --dest=org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower.EnumerateDevices
|
# dbus-send --print-reply --system --dest=org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower.EnumerateDevices
|
||||||
|
|
||||||
|
# 产生 xfce 启动脚本,进入系统后,手工执行这个就能拉起桌面
|
||||||
echo "if [ -f "/swapfile" ]; then" > ${diskfs}/xfce.sh
|
echo "if [ -f "/swapfile" ]; then" > ${diskfs}/xfce.sh
|
||||||
echo " dd if=/dev/zero of=/swapfile bs=1M count=2048" >> ${diskfs}/xfce.sh
|
echo " dd if=/dev/zero of=/swapfile bs=1M count=2048" >> ${diskfs}/xfce.sh
|
||||||
echo " mkswap /swapfile" >> ${diskfs}/xfce.sh
|
echo " mkswap /swapfile" >> ${diskfs}/xfce.sh
|
||||||
@ -295,22 +312,18 @@ if [ "${with_xfce}" = true ]; then
|
|||||||
echo "dbus-daemon --system --nopidfile --systemd-activation" >> ${diskfs}/xfce.sh
|
echo "dbus-daemon --system --nopidfile --systemd-activation" >> ${diskfs}/xfce.sh
|
||||||
echo "xinit /xinitrc -- /usr/local/bin/Xorg :10" >> ${diskfs}/xfce.sh
|
echo "xinit /xinitrc -- /usr/local/bin/Xorg :10" >> ${diskfs}/xfce.sh
|
||||||
chmod +x ${diskfs}/xfce.sh ${diskfs}/xinitrc
|
chmod +x ${diskfs}/xfce.sh ${diskfs}/xinitrc
|
||||||
|
|
||||||
# 添加 machine-id
|
# 添加 machine-id
|
||||||
mkdir -p ${diskfs}/usr/local/var/lib/dbus
|
mkdir -p ${diskfs}/usr/local/var/lib/dbus
|
||||||
echo "2add25d2f5994832ba171755bc21f9fe" > ${diskfs}/etc/machine-id
|
echo "2add25d2f5994832ba171755bc21f9fe" > ${diskfs}/etc/machine-id
|
||||||
echo "2add25d2f5994832ba171755bc21f9fe" > ${diskfs}/usr/local/var/lib/dbus/machine-id
|
echo "2add25d2f5994832ba171755bc21f9fe" > ${diskfs}/usr/local/var/lib/dbus/machine-id
|
||||||
|
|
||||||
# 这些本来需要编译完成,目前暂且拷贝
|
# 这些本来需要编译完成,目前暂且拷贝
|
||||||
cp /usr/lib/x86_64-linux-gnu/libLLVM-10.so.1 build/xfce_install/usr/lib/x86_64-linux-gnu/
|
cp /usr/lib/x86_64-linux-gnu/libLLVM-10.so.1 build/xfce_install/usr/lib/x86_64-linux-gnu/
|
||||||
# cp /usr/lib/x86_64-linux-gnu/libffi.so.6 build/xfce_install/usr/lib/x86_64-linux-gnu/
|
|
||||||
# 拷贝 xfce4 到镜像目录
|
# 拷贝 xfce4 到镜像目录
|
||||||
cp ${xfce_install}/* ${diskfs} -r -n
|
cp ${xfce_install}/* ${diskfs} -r -n
|
||||||
# xfce 需要系统内执行下面两句,保证键盘数据存在 Xorg :10 才能执行成功
|
|
||||||
# 1. 键盘数据
|
|
||||||
# rm /usr/local/share/X11/xkb -rf
|
|
||||||
# ln -s /usr/share/X11/xkb /usr/local/share/X11
|
|
||||||
# 2. 需要改动 libpcre.so.1 ---> libpcre.so.3
|
|
||||||
# 3. xfce4-session 需要 libuuid.so
|
|
||||||
|
|
||||||
|
# 删除冗余文件,防止后续编译很多警告
|
||||||
# 依赖版本 libpcre.so.3
|
# 依赖版本 libpcre.so.3
|
||||||
if [ -f "${xfce_install}/usr/local/lib/libpcre.so.1" ]; then
|
if [ -f "${xfce_install}/usr/local/lib/libpcre.so.1" ]; then
|
||||||
rm ${xfce_install}/usr/local/lib/libpcre.so.3 -rf
|
rm ${xfce_install}/usr/local/lib/libpcre.so.3 -rf
|
||||||
@ -350,6 +363,7 @@ nameserver 8.8.8.8
|
|||||||
nameserver 114.114.114.114
|
nameserver 114.114.114.114
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
# 生成 /etc/fstab 挂载文件
|
||||||
cat -> ${diskfs}/etc/fstab << EOF
|
cat -> ${diskfs}/etc/fstab << EOF
|
||||||
# <file system> <dir> <type> <options> <dump> <pass>
|
# <file system> <dir> <type> <options> <dump> <pass>
|
||||||
proc /proc proc defaults 0 0
|
proc /proc proc defaults 0 0
|
||||||
@ -370,6 +384,8 @@ title=$(cat<<EOF
|
|||||||
\e[0m
|
\e[0m
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# 生成 /etc/init.d/rcS 脚本
|
||||||
mkdir -pv ${diskfs}/etc/init.d
|
mkdir -pv ${diskfs}/etc/init.d
|
||||||
cat - > ${diskfs}/etc/init.d/rcS << EOF
|
cat - > ${diskfs}/etc/init.d/rcS << EOF
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
@ -379,10 +395,11 @@ echo -e "\n“${title}”\n"
|
|||||||
cd /lib/modules && insmod hello_world.ko
|
cd /lib/modules && insmod hello_world.ko
|
||||||
|
|
||||||
# dns 测试 busybox 必须动态编译 动态编译 glibc 已经集成 dns 功能
|
# dns 测试 busybox 必须动态编译 动态编译 glibc 已经集成 dns 功能
|
||||||
# qemu
|
# qemu 网卡设置(调试方便)
|
||||||
# ifconfig eth0 192.168.100.6 && ifconfig eth0 up
|
# ifconfig eth0 192.168.100.6 && ifconfig eth0 up
|
||||||
# route add default gw 192.168.100.1
|
# route add default gw 192.168.100.1
|
||||||
# vmware
|
|
||||||
|
# vmware 网卡设置 ( 调试方便 )
|
||||||
ifconfig eth0 192.168.222.195 && ifconfig eth0 up
|
ifconfig eth0 192.168.222.195 && ifconfig eth0 up
|
||||||
route add default gw 192.168.222.2
|
route add default gw 192.168.222.2
|
||||||
|
|
||||||
@ -441,7 +458,7 @@ losetup -d ${loop_dev}
|
|||||||
|
|
||||||
#---------------------------------------------------------------
|
#---------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# 转换为 vmware 格式
|
# 转换为 vmware 格式, 虚拟机的磁盘类型一定设置为 SATA ,否则启动失败
|
||||||
#
|
#
|
||||||
#---------------------------------------------------------------
|
#---------------------------------------------------------------
|
||||||
qemu-img convert disk.img -f raw -O vmdk disk.vmdk
|
qemu-img convert disk.img -f raw -O vmdk disk.vmdk
|
||||||
|
@ -31,4 +31,5 @@ export PS1 HOSTNAME
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
# 重新生成 inittab 文件
|
# 重新生成 inittab 文件
|
||||||
sed -i "/::sysinit:\/etc\/init.d\/rcS/a\::sysinit:\/bin\/hostname -F \/etc\/hostname" ${diskfs}/etc/inittab
|
sed -i "1i\::sysinit:\/bin\/hostname -F \/etc\/hostname" ${diskfs}/etc/inittab
|
||||||
|
sed -i "1i\# 加载主机名称" ${diskfs}/etc/inittab
|
||||||
|
21
mk_strip.sh
21
mk_strip.sh
@ -3,6 +3,7 @@
|
|||||||
# 导入公共环境
|
# 导入公共环境
|
||||||
. ./common.sh
|
. ./common.sh
|
||||||
|
|
||||||
|
# 对指定的目录进行 strip
|
||||||
strip_dir() {
|
strip_dir() {
|
||||||
for file in `ls $1`
|
for file in `ls $1`
|
||||||
do
|
do
|
||||||
@ -32,7 +33,25 @@ strip_dir ${glibc_install}
|
|||||||
|
|
||||||
# strip busybox
|
# strip busybox
|
||||||
rm -rf ${busybox_install}/linuxrc
|
rm -rf ${busybox_install}/linuxrc
|
||||||
strip ${busybox_install}/bin/busybox
|
strip_dir ${busybox_install}/bin/busybox
|
||||||
|
|
||||||
|
# strip lshw
|
||||||
|
strip_dir ${lshw_install}
|
||||||
|
|
||||||
|
# strip pciutils_install
|
||||||
|
strip_dir ${pciutils_install}
|
||||||
|
|
||||||
|
# strip lsof
|
||||||
|
strip_dir ${lsof_install}
|
||||||
|
|
||||||
|
# strip strace
|
||||||
|
strip_dir ${strace_install}
|
||||||
|
|
||||||
|
# strip openssl
|
||||||
|
strip_dir ${openssl_install}
|
||||||
|
|
||||||
|
# strip openssh
|
||||||
|
strip_dir ${openssh_install}
|
||||||
|
|
||||||
# strip gcc
|
# strip gcc
|
||||||
#rm -rf work/libgcc_install/usr/share
|
#rm -rf work/libgcc_install/usr/share
|
||||||
|
@ -806,7 +806,7 @@ llvm_build() {
|
|||||||
meson_build pango ${PANGO_SRC_DIR}
|
meson_build pango ${PANGO_SRC_DIR}
|
||||||
# 编译基础库 ( 这些都是系统库,新系统需要集成 )
|
# 编译基础库 ( 这些都是系统库,新系统需要集成 )
|
||||||
if [ "${with_xfce}" = true ] && [ "$1" = "img" ]; then
|
if [ "${with_xfce}" = true ] && [ "$1" = "img" ]; then
|
||||||
# 编译 llvm ( swrast 依赖此库 )
|
# 编译 llvm ( swrast 依赖此库,可以加大 swap 分区,编译时对内存要求极高 )
|
||||||
# llvm_build llvm ${LLVM_SRC_DIR}
|
# llvm_build llvm ${LLVM_SRC_DIR}
|
||||||
# 编译 expat
|
# 编译 expat
|
||||||
common_build expat ${EXPAT_SRC_DIR}
|
common_build expat ${EXPAT_SRC_DIR}
|
||||||
|
Loading…
Reference in New Issue
Block a user