• [X3m]Ubuntu 根文件系统制作


    使用ubuntu20.04

    1. sudo apt-get install wget ca-certificates device-tree-compiler pv bc lzop zip binfmt-support \
    2. build-essential ccache debootstrap ntpdate gawk gcc-arm-linux-gnueabihf qemu-user-static \
    3. u-boot-tools uuid-dev zlib1g-dev unzip libusb-1.0-0-dev fakeroot parted pkg-config \
    4. libncurses5-dev whiptail debian-keyring debian-archive-keyring f2fs-tools libfile-fcntllock-perl \
    5. rsync libssl-dev nfs-kernel-server btrfs-progs ncurses-term p7zip-full kmod dosfstools \
    6. libc6-dev-armhf-cross imagemagick curl patchutils liblz4-tool libpython2.7-dev linux-base swig acl \
    7. python3-dev python3-distutils libfdt-dev locales ncurses-base pixz dialog systemd-container udev \
    8. lib32stdc++6 libc6-i386 lib32ncurses5 lib32tinfo5 bison libbison-dev flex libfl-dev cryptsetup gpg \
    9. gnupg1 gpgv1 gpgv2 cpio aria2 pigz dirmngr python3-distutils distcc git dos2unix apt-cacher-ng

    重点工具介绍

    debootstrap

    debootstrap是debian/ubuntu下的一个工具,用来构建一套基本的系统(根文件系统)。生成的目录符合Linux文件系统标准(FHS),即包含了 /boot、 /etc、 /bin、 /usr 等等目录,但它比发行版本的Linux体积小很多,当然功能也没那么强大,因此只能说是“基本的系统”。在我们的xj3平台上可以按照需求定制自己的ubuntu系统。

    ubuntu系统(PC)下安装debootstrap

    sudo apt-get install debootstrap
    

    使用方式

    # 可加参数指定源
    sudo debootstrap --arch [平台] [发行版本代号] [目录] [源]

    chroot

    chroot,即 change root directory (更改 root 目录)。在 linux 系统中,系统默认的目录结构都是以 /,即是以根 (root) 开始的。而在使用 chroot 之后,系统的目录结构将以指定的位置作为 / 位置。

    mkfs.ext4

    mkfs.ext4命令可以磁盘分区创建ext4文件系统,可以实现ext4文件系统格式化。该命令是mke2fs命令的符号链接,使用方法和mke2fs命令一样。

    parted

    parted命令是由GNU组织开发的一款功能强大的磁盘分区和分区大小调整工具,与fdisk不同,它支持调整分区的大小。作为一种设计用于Linux的工具,它没有构建成处理与fdisk关联的多种分区类型,但是,它可以处理最常见的分区格式,包括:ext2、ext3、fat16、fat32、NTFS、ReiserFS、JFS、XFS、UFS、HFS以及Linux交换分区。

    制作XJ3-Ubuntu rootfs脚本代码

    从 Ubuntu根文件系统制作 下载脚本代码

    ubuntu_20.04_rootfs - 文件 - Nextcloud (horizon.ai)

    执行以下命令生成ubuntu根文件系统:

    mkdir ubuntu_rootfs
    cd ubuntu_rootfs
    # 复制 make_ubuntu_rootfs.sh 到前面目录
    chmod +x make_ubuntu_rootfs.sh
    sudo ./make_ubuntu_rootfs.sh
    1. 编译成功的输出结果:
    2. ubuntu_src/ # 编译输出目录
    3. ├── focal-xj3-arm64 # 编译成功后生成的根文件系统,会有比较多的系统临时文件
    4. ├── focal-xj3-arm64.tar.xz0 # 以下几个压缩文件是剔除 dev、 proc、 sys等系统临时文件的根文件系统
    5. ├── focal-xj3-arm64.tar.xz1
    6. ├── focal-xj3-arm64.tar.xz2
    7. ├── focal-xj3-arm64.tar.xz3
    8. └── focal-xj3-arm64.tar.xz.info # 当前系统安装了哪些 apt 包
    9. system/ # 解压 focal-xj3-arm64.tar.xz[0-9] 的测试目录
    10. ├── app
    11. ├── bin -> usr/bin
    12. ├── boot
    13. ├── dev
    14. ├── etc
    15. ├── home
    16. ├── lib -> usr/lib
    17. ├── media
    18. ├── mnt
    19. ├── opt
    20. ├── proc
    21. ├── root
    22. ├── run
    23. ├── sbin -> usr/sbin
    24. ├── srv
    25. ├── sys
    26. ├── tmp
    27. ├── userdata
    28. ├── usr
    29. └── var
    30. 21 directories, 5 files

    ubuntu_src 目录下的 focal-xj3-arm64.tar.xz[0-9] 这些压缩包文件用于替换 BSP 源码 system/rootfs_ubuntu 目录下的ubuntu根文件系统源码。

    脚本代码解析

    debootstrap拉取定制的ubuntu根文件系统

    debootstrap这个命令执行步骤可以分为两步:

    怎么”定制“呢,debootstrap有很多参数,可以按需配置debootstrap

    1. debootstrap --variant=minbase \
    2. --include=${DEBOOTSTRAP_LIST// /,} \
    3. --arch=${ARCH} \
    4. --components=${DEBOOTSTRAP_COMPONENTS} \
    5. --foreign ${RELEASE} \
    6. $dst_dir \
    7. $apt_mirror

    上述代码中

    –variant:选择最小的minbase

    –include:在生成rootfs的时候要添加的组件,上面的步骤阅读说明里有组件名单

    –arch:指定制作的文件系统是什么架构的,在这里选择arm64

    –components:选择”main,universe”

    –foreign:在与主机架构不相同时需要指定此参数,仅做初始化的解包,${RELEASE} 代表发行版本 XJ3-ubuntu可选的有bionic和focal,分别代表18.04的版本和20.04的版本

    $dst_dir:这个是要存放文件系统的文件夹

    $apt_mirror:代表镜像的源地址,我们选择国内的源http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ 一般使用本地缓存代理来做加速

    执行上述命令之后在$dst_dir里就生成了定制的rootfs,进入$dst_dir可以看到bin lib usr等等目录

    拷贝/usr/bin/qemu-aarch64-static 到$dst_dir/usr/bin

    拷贝/usr/share/keyrings/*-archive-keyring.gpg 到$dst_dir/usr/share/keyrings/

    chroot执行debootstrap的第二阶段

    执行

    chroot ${dst_dir} /bin/bash -c "/debootstrap/debootstrap --second-stage"

    上面的指令代表的意思就是改变根文件系统到${dst_dir}中执行/debootstrap/debootstrap --second-stage这个命令,-c 代表执行完前面的命令之后返回当前的shell

    挂载根文件系统的dev sysfs proc 等目录

    1. mount -t proc chproc "${dst_dir}"/proc
    2. mount -t sysfs chsys "${dst_dir}"/sys
    3. mount -t devtmpfs chdev "${dst_dir}"/dev || mount --bind /dev "${dst_dir}"/dev
    4. mount -t devpts chpts "${dst_dir}"/dev/pts

    设置apt的软件源 修改根文件系统中的etc/apt/sources.list

    1. deb http://${UBUNTU_MIRROR} $release main restricted universe multiverse
    2. #deb-src http://${UBUNTU_MIRROR} $release main restricted universe multiverse
    3. deb http://${UBUNTU_MIRROR} ${release}-security main restricted universe multiverse
    4. #deb-src http://${UBUNTU_MIRROR} ${release}-security main restricted universe multiverse
    5. deb http://${UBUNTU_MIRROR} ${release}-updates main restricted universe multiverse
    6. #deb-src http://${UBUNTU_MIRROR} ${release}-updates main restricted universe multiverse
    7. deb http://${UBUNTU_MIRROR} ${release}-backports main restricted universe multiverse
    8. #deb-src http://${UBUNTU_MIRROR} ${release}-backports main restricted universe multiverse

    用apt安装包

    1. log_out "Updating base packages" "${dst_dir}" "info"
    2. eval 'LC_ALL=C LANG=C chroot ${dst_dir} /bin/bash -c "apt-get -q -y $apt_extra update"'
    3. [[ $? -ne 0 ]] && exit -1
    4. log_out "Upgrading base packages" "${dst_dir}" "info"
    5. eval 'LC_ALL=C LANG=C chroot ${dst_dir} /bin/bash -c "apt-get -q -y $apt_extra upgrade"'
    6. [[ $? -ne 0 ]] && exit -1
    7. log_out "Installing base packages" "${dst_dir}" "info"
    8. eval 'LC_ALL=C LANG=C chroot ${dst_dir} /bin/bash -c "DEBIAN_FRONTEND=noninteractive apt-get -y -q $apt_extra --no-install-recommends install $ADD_PACKAGE_LIST"'
    9. [[ $? -ne 0 ]] && exit -1
    10. chroot ${dst_dir} /bin/bash -c "dpkg --get-selections" | grep -v deinstall | awk '{print $1}' | cut -f1 -d':' > ${tar_file}.info
    11. log_out "Configure hostname" "$HOST" "info"

    从上述代码中可以看的出来就是chroot到生成的根文件系统中去然后执行了apt update,apt upgrade和apt install $ADD_PACKAGE_LIST三个命令,主要就是用apt工具更新软件,下载必要的软件。

    为了加快apt的速度,添加了代理

    local apt_extra="-o Acquire::http::Proxy=\"http://localhost:3142\""

    修改hostname

    echo "$HOST" > ${dst_dir}/etc/hostname

    编辑/etc/hostname内容为xj3ubuntu

    为了下面能安装python库,需要修改dns

    1. #首先删掉链接文件
    2. rm ${dst_dir}/etc/resolv.conf
    3. #重新生成新的文件
    4. echo "nameserver $NAMESERVER" > ${dst_dir}/etc/resolv.conf

    安装python库

    chroot ${dst_dir} /bin/bash -c "pip install $PYTHON_PACKAGE_LIST"

    目前只预装了下面的俩python库

    PYTHON_PACKAGE_LIST="numpy opencv-python "

    配置udev

    1. #解决自动加载驱动的bug
    2. sed -i 's/ENV{MODALIAS}/# ENV{MODALIAS}/' "${dst_dir}"/lib/udev/rules.d/80-drivers.rules
    3. #解决加载camera 驱动panic的问题
    4. sed -i 's/IMPORT{program}/# IMPORT{program}/' "${dst_dir}"/lib/udev/rules.d/60-persistent-v4l.rules
    5. #解决 ubuntu20.04 usb storage和sdcard的udev自动mount的问题
    6. mkdir "${dst_dir}"/etc/systemd/system/systemd-udevd.service.d
    7. cat <<-EOF >> "${dst_dir}"/etc/systemd/system/systemd-udevd.service.d/00-hobot-private.conf
    8. [Service]
    9. PrivateMounts=no
    10. EOF

    解决 ubuntu20.04 usb storage和sdcard的udev自动mount失败的问题

    配置ssh

    1. log_out "Configure ssh" ""${dst_dir}"/etc/ssh/sshd_config" "info"
    2. # permit root login via SSH for the first boot
    3. sed -i 's/#\?PermitRootLogin .*/PermitRootLogin yes/' "${dst_dir}"/etc/ssh/sshd_config
    4. # enable PubkeyAuthentication
    5. sed -i 's/#\?PubkeyAuthentication .*/PubkeyAuthentication yes/' "${dst_dir}"/etc/ssh/sshd_config

    解决了root用户不能通过ssh 登录的问题

    配置console

    1. # # console fix due to Debian bug
    2. sed -e 's/CHARMAP=".*"/CHARMAP="'$CONSOLE_CHAR'"/g' -i "${dst_dir}"/etc/default/console-setup

    配置/etc/hosts文件

    1. cat <<-EOF >> "${dst_dir}"/etc/hosts
    2. 127.0.0.1 localhost
    3. 127.0.0.1 $HOST
    4. EOF

    配置网络

    1. cat <<-EOF >> "${dst_dir}"/etc/network/interfaces
    2. auto ${ethdev}
    3. iface ${ethdev} inet static
    4. address ${address}
    5. netmask ${netmask}
    6. #network ${network}
    7. #broadcast ${broadcast}
    8. gateway ${gateway}
    9. EOF

    目前是按照下面的配置

    1. ethdev="eth0"
    2. address="192.168.1.10"
    3. netmask="255.255.255.0"
    4. gateway="192.168.1.1"

    配置串口

    1. cp "${dst_dir}"/lib/systemd/system/serial-getty@.service "${dst_dir}/lib/systemd/system/serial-getty@ttyS0.service"
    2. sed -i "s/--keep-baud 115200/--keep-baud 921600,115200/" "${dst_dir}/lib/systemd/system/serial-getty@ttyS0.service"
    3. log_out "Enabling serial console" "ttyS0" "info"
    4. chroot "${dst_dir}" /bin/bash -c "systemctl daemon-reload"
    5. chroot "${dst_dir}" /bin/bash -c "systemctl --no-reload enable serial-getty@ttyS0.service"

    这里配置的是/dev/ttyS1

    配置rootfs的用户和密码,目前用户: root和xj3

    1. chroot "${dst_dir}" /bin/bash -c "(echo $ROOTPWD;echo $ROOTPWD;) | passwd root"
    2. chroot "${dst_dir}" /bin/bash -c "adduser --quiet --disabled-password --shell /bin/bash --home /home/${XJ3_USERNAME} --gecos ${XJ3_USERNAME} ${XJ3_USERNAME}"
    3. chroot "${dst_dir}" /bin/bash -c "(echo ${XJ3_PWD};echo ${XJ3_PWD};) | passwd ${XJ3_USERNAME}"

    配置network manager

    1. sed "s/managed=\(.*\)/managed=true/g" -i "${dst_dir}"/etc/NetworkManager/NetworkManager.conf
    2. # most likely we don't need to wait for nm to get online
    3. chroot "${dst_dir}" /bin/bash -c "systemctl disable NetworkManager-wait-online.service"
    4. # Just regular DNS and maintain /etc/resolv.conf as a file
    5. sed "/dns/d" -i "${dst_dir}"/etc/NetworkManager/NetworkManager.conf
    6. sed "s/\[main\]/\[main\]\ndns=default\nrc-manager=file/g" -i "${dst_dir}"/etc/NetworkManager/NetworkManager.conf
    7. if [[ -n $NM_IGNORE_DEVICES ]]; then
    8. mkdir -p "${dst_dir}"/etc/NetworkManager/conf.d/
    9. cat <<-EOF > "${dst_dir}"/etc/NetworkManager/conf.d/10-ignore-interfaces.conf
    10. [keyfile]
    11. unmanaged-devices=$NM_IGNORE_DEVICES
    12. EOF
    13. fi

    最后就是卸载之前挂载的dev,proc,sys节点

    1. umount -l --recursive "${dst_dir}"/dev >/dev/null 2>&1
    2. umount -l "${dst_dir}"/proc >/dev/null 2>&1
    3. umount -l "${dst_dir}"/sys >/dev/null 2>&1

    打包rootfs

    tar -Jcf - -C $src_dir/ --exclude='./dev/*' --exclude='./proc/*' --exclude='./run/*' --exclude='./tmp/*' --exclude='./sys/*' .  | split -b 99m -d -a 1 - ${tar_file}

    打包的时候不要打包sys proc dev tmp run目录,等解压的时候在创建

    make_ubuntu_rootfs.sh如下:
    1. #!/bin/bash
    2. set -e
    3. LOCAL_DIR=$(realpath $(cd $(dirname $0); pwd))
    4. # RELEASE=bionic
    5. RELEASE="focal"
    6. ARCH=arm64
    7. DEBOOTSTRAP_COMPONENTS="main,universe"
    8. # apt_mirror="http://ports.ubuntu.com/"
    9. UBUNTU_MIRROR="mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/"
    10. # apt_mirror="http://${UBUNTU_MIRROR}"
    11. # To use a local proxy to cache apt packages, you need to install apt-cacher-ng
    12. apt_mirror="http://localhost:3142/${UBUNTU_MIRROR}"
    13. CONSOLE_CHAR="UTF-8"
    14. DEST_LANG="en_US.UTF-8"
    15. SUN_USERNAME="sunrise"
    16. ROOTPWD="root"
    17. SUN_PWD="sunrise"
    18. HOST="ubuntu"
    19. #network
    20. ethdev="eth0"
    21. address="192.168.1.10"
    22. netmask="255.255.255.0"
    23. gateway="192.168.1.1"
    24. NAMESERVER="114.114.114.114"
    25. COMMON_PACKAGE_LIST=" "
    26. PYTHON_PACKAGE_LIST="numpy opencv-python pySerial i2cdev spidev matplotlib pillow \
    27. websocket websockets lark-parser netifaces google protobuf==3.20.1 "
    28. #DEBOOTSTRAP_LIST="systemd sudo locales apt-utils openssh-server ssh dbus init module-init-tools \
    29. DEBOOTSTRAP_LIST="systemd sudo vim locales apt-utils openssh-server ssh dbus init \
    30. strace kmod init udev bash-completion netbase network-manager \
    31. ifupdown ethtool net-tools iputils-ping "
    32. BASE_PACKAGE_LIST="file openssh-server ssh bsdmainutils whiptail device-tree-compiler \
    33. bzip2 htop rsyslog parted python3 python3-pip console-setup fake-hwclock \
    34. ncurses-term gcc g++ toilet sysfsutils rsyslog tzdata u-boot-tools \
    35. libcjson1 libcjson-dev db-util diffutils e2fsprogs libc6 xterm \
    36. libcrypt1 libcrypto++6 libdevmapper1.02.1 libedit2 libgcc-s1-arm64-cross libgcrypt20 libgpg-error0 \
    37. libion0 libjsoncpp1 libkcapi1 libmenu-cache3 libnss-db libpcap0.8 libpcre3 \
    38. libstdc++-10-dev libvorbis0a libzmq5 lvm2 makedev mtd-utils ncurses-term ncurses-base nettle-bin \
    39. nfs-common openssl perl-base perl tftpd-hpa tftp-hpa tzdata watchdog \
    40. wpasupplicant alsa-utils base-files cryptsetup diffutils dosfstools \
    41. dropbear e2fsprogs ethtool exfat-utils ffmpeg i2c-tools iperf3 \
    42. libaio1 libasound2 libattr1 libavcodec58 libavdevice58 libavfilter7 libavformat58 libavutil56 \
    43. libblkid1 libc6 libc6-dev libcap2 libcom-err2 libcrypt-dev libdbus-1-3 libexpat1 libext2fs2 libflac8 \
    44. libgcc1 libgdbm-compat4 libgdbm-dev libgdbm6 libgmp10 libgnutls30 libidn2-0 libjson-c4 libkmod2 \
    45. liblzo2-2 libmount1 libncurses5 libncursesw5 libnl-3-200 libnl-genl-3-200 libogg0 libpopt0 \
    46. libpostproc55 libreadline8 libsamplerate0 libsndfile1 libss2 libssl1.1 libstdc++6 libswresample3 \
    47. libswscale5 libtinfo5 libtirpc3 libudev1 libunistring2 libusb-1.0-0 libuuid1 libwrap0 libx11-6 \
    48. libxau6 libxcb1 libxdmcp6 libxext6 libxv1 libz-dev libz1 lrzsz lvm2 mtd-utils net-tools \
    49. netbase openssh-sftp-server openssl rpcbind screen sysstat tcpdump libgl1-mesa-glx \
    50. thin-provisioning-tools trace-cmd tzdata usbutils watchdog libturbojpeg libturbojpeg0-dev \
    51. base-passwd libasound2-dev libavcodec-dev libavformat-dev libavutil-dev libcrypto++-dev \
    52. libjsoncpp-dev libssl-dev libswresample-dev libzmq3-dev perl sed \
    53. symlinks libunwind8 libperl-dev devmem2 ifmetric v4l-utils python3-dev \
    54. build-essential libbullet-dev libasio-dev libtinyxml2-dev iotop htop iw wireless-tools \
    55. bluetooth bluez blueman sqlite3 libsqlite3-dev libeigen3-dev liblog4cxx-dev libcurl4-openssl-dev \
    56. libboost-dev libboost-date-time-dev libboost-thread-dev "
    57. SERVER_PACKAGE_LIST="file openssh-server ssh bsdmainutils whiptail device-tree-compiler \
    58. bzip2 htop rsyslog make cmake parted python3 python3-pip console-setup fake-hwclock \
    59. ncurses-term gcc g++ toilet sysfsutils rsyslog tzdata u-boot-tools \
    60. libcjson1 libcjson-dev db-util diffutils e2fsprogs iptables libc6 xterm \
    61. libcrypt1 libcrypto++6 libdevmapper1.02.1 libedit2 libgcc-s1-arm64-cross libgcrypt20 libgpg-error0 \
    62. libion0 libjsoncpp1 libkcapi1 libmenu-cache3 libnss-db libpcap0.8 libpcre3 \
    63. libstdc++-10-dev libvorbis0a libzmq5 lvm2 makedev mtd-utils ncurses-term ncurses-base nettle-bin \
    64. nfs-common openssl perl-base perl tftpd-hpa tftp-hpa tzdata watchdog \
    65. wpasupplicant alsa-utils base-files cryptsetup diffutils dosfstools \
    66. dropbear e2fsprogs ethtool exfat-utils ffmpeg file gdb gdbserver i2c-tools iperf3 iptables \
    67. libaio1 libasound2 libattr1 libavcodec58 libavdevice58 libavfilter7 libavformat58 libavutil56 \
    68. libblkid1 libc6 libc6-dev libcap2 libcom-err2 libcrypt-dev libdbus-1-3 libexpat1 libext2fs2 libflac8 \
    69. libgcc1 libgdbm-compat4 libgdbm-dev libgdbm6 libgmp10 libgnutls30 libidn2-0 libjson-c4 libkmod2 \
    70. liblzo2-2 libmount1 libncurses5 libncursesw5 libnl-3-200 libnl-genl-3-200 libogg0 libpopt0 \
    71. libpostproc55 libreadline8 libsamplerate0 libsndfile1 libss2 libssl1.1 libstdc++6 libswresample3 \
    72. libswscale5 libtinfo5 libtirpc3 libudev1 libunistring2 libusb-1.0-0 libuuid1 libwrap0 libx11-6 \
    73. libxau6 libxcb1 libxdmcp6 libxext6 libxv1 libz-dev libz1 lrzsz lvm2 mtd-utils net-tools \
    74. netbase openssh-sftp-server openssl rpcbind screen sysstat tcpdump libgl1-mesa-glx \
    75. thin-provisioning-tools trace-cmd tzdata usbutils watchdog libturbojpeg libturbojpeg0-dev \
    76. base-passwd libasound2-dev libavcodec-dev libavformat-dev libavutil-dev libcrypto++-dev \
    77. libjsoncpp-dev libssl-dev libswresample-dev libzmq3-dev perl sed \
    78. symlinks libunwind8 libperl-dev devmem2 tree unzip ifmetric v4l-utils python3-dev \
    79. wget curl gnupg2 lsb-release lshw lsof memstat aptitude apt-show-versions \
    80. build-essential libbullet-dev libasio-dev libtinyxml2-dev iotop htop iw wireless-tools \
    81. bluetooth bluez blueman sqlite3 libsqlite3-dev libeigen3-dev liblog4cxx-dev libcurl4-openssl-dev \
    82. libboost-dev libboost-date-time-dev libboost-thread-dev \
    83. python3-wstool ninja-build stow \
    84. libgoogle-glog-dev libgflags-dev libatlas-base-dev libeigen3-dev libsuitesparse-dev \
    85. lua5.2 liblua5.2-dev libluabind-dev libprotobuf-dev protobuf-compiler libcairo2-dev \
    86. hostapd isc-dhcp-server x11vnc "
    87. DESKTOP_PACKAGE_LIST="xubuntu-desktop xserver-xorg-video-fbdev policykit-1-gnome notification-daemon \
    88. tightvncserver network-manager-gnome gnome-terminal tightvncserver firefox firefox-locale-zh-hans \
    89. gedit \
    90. fonts-beng \
    91. fonts-beng-extra fonts-deva fonts-deva-extra fonts-freefont-ttf fonts-gargi fonts-gubbi fonts-gujr fonts-gujr-extra fonts-guru fonts-guru-extra \
    92. fonts-indic fonts-kacst fonts-kacst-one fonts-kalapi fonts-khmeros-core fonts-knda fonts-lao fonts-liberation fonts-lklug-sinhala \
    93. fonts-lohit-beng-assamese fonts-lohit-beng-bengali fonts-lohit-deva fonts-lohit-gujr fonts-lohit-guru fonts-lohit-knda fonts-lohit-mlym \
    94. fonts-lohit-orya fonts-lohit-taml fonts-lohit-taml-classical fonts-lohit-telu fonts-mlym fonts-nakula fonts-navilu fonts-noto-cjk \
    95. fonts-noto-core fonts-noto-hinted fonts-noto-ui-core fonts-orya fonts-orya-extra fonts-pagul fonts-sahadeva fonts-samyak-deva fonts-samyak-gujr \
    96. fonts-samyak-mlym fonts-samyak-taml fonts-sarai fonts-sil-abyssinica fonts-sil-padauk fonts-smc fonts-smc-anjalioldlipi fonts-smc-chilanka \
    97. fonts-smc-dyuthi fonts-smc-gayathri fonts-smc-karumbi fonts-smc-keraleeyam fonts-smc-manjari fonts-smc-meera fonts-smc-rachana \
    98. fonts-smc-raghumalayalamsans fonts-smc-suruma fonts-smc-uroob fonts-symbola fonts-taml fonts-telu fonts-telu-extra fonts-thai-tlwg \
    99. fonts-tibetan-machine fonts-tlwg-garuda fonts-tlwg-garuda-ttf fonts-tlwg-kinnari fonts-tlwg-kinnari-ttf fonts-tlwg-laksaman \
    100. fonts-tlwg-laksaman-ttf fonts-tlwg-loma fonts-tlwg-loma-ttf fonts-tlwg-mono fonts-tlwg-mono-ttf fonts-tlwg-norasi fonts-tlwg-norasi-ttf \
    101. fonts-tlwg-purisa fonts-tlwg-purisa-ttf fonts-tlwg-sawasdee fonts-tlwg-sawasdee-ttf fonts-tlwg-typewriter fonts-tlwg-typewriter-ttf \
    102. fonts-tlwg-typist fonts-tlwg-typist-ttf fonts-tlwg-typo fonts-tlwg-typo-ttf fonts-tlwg-umpush fonts-tlwg-umpush-ttf fonts-tlwg-waree \
    103. fonts-tlwg-waree-ttf fonts-ubuntu fonts-yrsa-rasa \
    104. smplayer pavucontrol pulseaudio "
    105. # The default version is Ubuntu Server
    106. ADD_PACKAGE_LIST="${SERVER_PACKAGE_LIST} "
    107. ubuntufs_src="${LOCAL_DIR}/ubuntu_src"
    108. ubuntufs_dst="${LOCAL_DIR}/system"
    109. # Ubuntu Desktop
    110. if [[ $1 == *"d"* ]] ; then
    111. desktop="true"
    112. ADD_PACKAGE_LIST="$ADD_PACKAGE_LIST $DESKTOP_PACKAGE_LIST "
    113. ubuntufs_src="${LOCAL_DIR}/ubuntu_src_desktop"
    114. fi
    115. # Ubuntu Base
    116. if [[ $1 == *"b"* ]] ; then
    117. ADD_PACKAGE_LIST="${BASE_PACKAGE_LIST} "
    118. ubuntufs_src="${LOCAL_DIR}/ubuntu_src_base"
    119. fi
    120. root_path=${ubuntufs_src}/${RELEASE}-xj3-${ARCH}
    121. tar_file=${root_path}.tar.xz
    122. # Release specific packages
    123. case $RELEASE in
    124. bionic)
    125. # Dependent debootstarp packages
    126. DEBOOTSTRAP_COMPONENTS="main,universe"
    127. DEBOOTSTRAP_LIST+=" module-init-tools"
    128. ADD_PACKAGE_LIST+=" android-tools-adbd"
    129. ;;
    130. focal)
    131. # Dependent debootstarp packages
    132. DEBOOTSTRAP_COMPONENTS="main,universe"
    133. DEBOOTSTRAP_LIST+=""
    134. ADD_PACKAGE_LIST+=""
    135. ;;
    136. esac
    137. log_out()
    138. {
    139. # log function parameters to install.log
    140. local tmp=""
    141. [[ -n $2 ]] && tmp="[\e[0;33m $2 \x1B[0m]"
    142. case $3 in
    143. err)
    144. echo -e "[\e[0;31m error \x1B[0m] $1 $tmp"
    145. ;;
    146. wrn)
    147. echo -e "[\e[0;35m warn \x1B[0m] $1 $tmp"
    148. ;;
    149. ext)
    150. echo -e "[\e[0;32m o.k. \x1B[0m] \e[1;32m$1\x1B[0m $tmp"
    151. ;;
    152. info)
    153. echo -e "[\e[0;32m o.k. \x1B[0m] $1 $tmp"
    154. ;;
    155. *)
    156. echo -e "[\e[0;32m .... \x1B[0m] $1 $tmp"
    157. ;;
    158. esac
    159. }
    160. # mount_chroot
    161. #
    162. # helper to reduce code duplication
    163. #
    164. mount_chroot()
    165. {
    166. local target=$1
    167. log_out "Mounting" "$target" "info"
    168. mount -t proc chproc "${target}"/proc
    169. mount -t sysfs chsys "${target}"/sys
    170. mount -t devtmpfs chdev "${target}"/dev || mount --bind /dev "${target}"/dev
    171. mount -t devpts chpts "${target}"/dev/pts
    172. }
    173. # unmount_on_exit
    174. #
    175. # helper to reduce code duplication
    176. #
    177. unmount_on_exit()
    178. {
    179. local target=$1
    180. trap - INT TERM EXIT
    181. umount_chroot "${target}/"
    182. rm -rf ${target}
    183. }
    184. # umount_chroot
    185. #
    186. # helper to reduce code duplication
    187. #
    188. umount_chroot()
    189. {
    190. local target=$1
    191. log_out "Unmounting" "$target" "info"
    192. while grep -Eq "${target}.*(dev|proc|sys)" /proc/mounts
    193. do
    194. umount -l --recursive "${target}"/dev >/dev/null 2>&1
    195. umount -l "${target}"/proc >/dev/null 2>&1
    196. umount -l "${target}"/sys >/dev/null 2>&1
    197. sleep 5
    198. done
    199. }
    200. create_base_sources_list()
    201. {
    202. local release=$1
    203. local basedir=$2
    204. [[ -z $basedir ]] && log_out "No basedir passed to create_base_sources_list" " " "err"
    205. # cp /etc/apt/sources.list "${basedir}"/etc/apt/sources.list
    206. cat <<-EOF > "${basedir}"/etc/apt/sources.list
    207. # See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
    208. # newer versions of the distribution.
    209. deb http://${UBUNTU_MIRROR} $release main restricted universe multiverse
    210. #deb-src http://${UBUNTU_MIRROR} $release main restricted universe multiverse
    211. EOF
    212. }
    213. create_sources_list()
    214. {
    215. local release=$1
    216. local basedir=$2
    217. [[ -z $basedir ]] && log_out "No basedir passed to create_sources_list" " " "err"
    218. # cp /etc/apt/sources.list "${basedir}"/etc/apt/sources.list
    219. cat <<-EOF > "${basedir}"/etc/apt/sources.list
    220. # See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
    221. # newer versions of the distribution.
    222. deb http://${UBUNTU_MIRROR} $release main restricted universe multiverse
    223. #deb-src http://${UBUNTU_MIRROR} $release main restricted universe multiverse
    224. deb http://${UBUNTU_MIRROR} ${release}-security main restricted universe multiverse
    225. #deb-src http://${UBUNTU_MIRROR} ${release}-security main restricted universe multiverse
    226. deb http://${UBUNTU_MIRROR} ${release}-updates main restricted universe multiverse
    227. #deb-src http://${UBUNTU_MIRROR} ${release}-updates main restricted universe multiverse
    228. deb http://${UBUNTU_MIRROR} ${release}-backports main restricted universe multiverse
    229. #deb-src http://${UBUNTU_MIRROR} ${release}-backports main restricted universe multiverse
    230. EOF
    231. }
    232. end_debootstrap()
    233. {
    234. local target=$1
    235. # remove service start blockers
    236. rm -f "${target}"/sbin/initctl "${target}"/sbin/start-stop-daemon
    237. chroot "${target}" /bin/bash -c "dpkg-divert --quiet --local --rename --remove /sbin/initctl"
    238. chroot "${target}" /bin/bash -c "dpkg-divert --quiet --local --rename --remove /sbin/start-stop-daemon"
    239. rm -f "${target}"/usr/sbin/policy-rc.d
    240. }
    241. extract_base_root() {
    242. local tar_file=$1
    243. local dest_dir=$2
    244. rm -rf $dest_dir
    245. mkdir -p $dest_dir
    246. if [ ! -f "${tar_file}0" ];then
    247. log_out "File is not exist!" "${tar_file}0" "err"
    248. exit -1
    249. fi
    250. if [ ! -d $dest_dir ];then
    251. log_out "Dir is not exist!" "${dest_dir}" "err"
    252. exit -1
    253. fi
    254. log_out "Start extract" "$tar_file to $dest_dir" "info"
    255. cat ${tar_file}[0-9] | tar -Jxf - -C $dest_dir --exclude='./dev/*' --exclude='./proc/*' --exclude='./run/*' --exclude='./tmp/*' --exclude='./sys/*'
    256. mkdir -p ${dest_dir}/{dev,proc,tmp,run,proc,sys,userdata,app}
    257. }
    258. compress_base_root() {
    259. local tar_file=$1
    260. local src_dir=$2
    261. if [ ! -d $src_dir ];then
    262. log_out "Dir is not exist!" "${src_dir}" "err"
    263. exit -1
    264. fi
    265. log_out "Start compress" "${tar_file} from ${src_dir}" "info"
    266. tar -Jcf - -C $src_dir/ --exclude='./dev/*' --exclude='./proc/*' --exclude='./run/*' --exclude='./tmp/*' --exclude='./sys/*' --exclude='./usr/lib/aarch64-linux-gnu/dri/*' . | split -b 99m -d -a 1 - ${tar_file}
    267. # rm -rf $src_dir
    268. }
    269. check_ret(){
    270. ret=$1
    271. if [ ${ret} -ne 0 ];then
    272. log_out "return value:" "${ret}" "err"
    273. exit -1
    274. fi
    275. }
    276. make_base_root() {
    277. local dst_dir=$1
    278. rm -rf $dst_dir
    279. mkdir -p $dst_dir
    280. trap "unmount_on_exit ${dst_dir}" INT TERM EXIT
    281. log_out "Installing base system : " "Stage 2/1" "info"
    282. debootstrap --variant=minbase \
    283. --include=${DEBOOTSTRAP_LIST// /,} \
    284. --arch=${ARCH} \
    285. --components=${DEBOOTSTRAP_COMPONENTS} \
    286. --foreign ${RELEASE} \
    287. $dst_dir \
    288. $apt_mirror
    289. if [[ $? -ne 0 ]] || [[ ! -f $dst_dir/debootstrap/debootstrap ]];then
    290. log_out "Debootstrap base system first stage failed" "err"
    291. exit -1
    292. fi
    293. if [ ! -f /usr/bin/qemu-aarch64-static ];then
    294. log_out "File is not exist!" "Please install qemu-user-static with apt first" "err"
    295. exit -1
    296. else
    297. log_out "Copy qemu-aarch64-static to" "$dst_dir/usr/bin" "info"
    298. cp /usr/bin/qemu-aarch64-static $dst_dir/usr/bin
    299. fi
    300. mkdir -p $dst_dir/usr/share/keyrings/
    301. log_out "Copy .gpg files to" "$dst_dir/usr/share/keyrings/" "info"
    302. cp -a /usr/share/keyrings/*-archive-keyring.gpg $dst_dir/usr/share/keyrings/
    303. log_out "Installing base system : " "Stage 2/2" "info"
    304. chroot ${dst_dir} /bin/bash -c "/debootstrap/debootstrap --second-stage"
    305. if [[ $? -ne 0 ]] || [[ ! -f $dst_dir/bin/bash ]];then
    306. log_out "Debootstrap base system second stage failed" "err"
    307. exit -1
    308. fi
    309. mount_chroot ${dst_dir}
    310. printf '#!/bin/sh\nexit 101' > $dst_dir/usr/sbin/policy-rc.d
    311. chroot $dst_dir /bin/bash -c "dpkg-divert --quiet --local --rename --add /sbin/initctl"
    312. chroot $dst_dir /bin/bash -c "dpkg-divert --quiet --local --rename --add /sbin/start-stop-daemon"
    313. printf '#!/bin/sh\necho "Warning: Fake start-stop-daemon called, doing nothing"' > $dst_dir/sbin/start-stop-daemon
    314. printf '#!/bin/sh\necho "Warning: Fake initctl called, doing nothing"' > $dst_dir/sbin/initctl
    315. chmod 755 $dst_dir/usr/sbin/policy-rc.d
    316. chmod 755 $dst_dir/sbin/initctl
    317. chmod 755 $dst_dir/sbin/start-stop-daemon
    318. log_out "Configuring locales" "$DEST_LANG" "info"
    319. if [ -f ${dst_dir}/etc/locale.gen ];then
    320. sed -i "s/^# $DEST_LANG/$DEST_LANG/" $dst_dir/etc/locale.gen
    321. fi
    322. eval 'LC_ALL=C LANG=C chroot $dst_dir /bin/bash -c "locale-gen $DEST_LANG"'
    323. eval 'LC_ALL=C LANG=C chroot $dst_dir /bin/bash -c "update-locale LANG=$DEST_LANG LANGUAGE=$DEST_LANG LC_MESSAGES=$DEST_LANG"'
    324. if [[ -f ${dst_dir}/etc/default/console-setup ]]; then
    325. sed -e 's/CHARMAP=.*/CHARMAP="UTF-8"/' -e 's/FONTSIZE=.*/FONTSIZE="8x16"/' \
    326. -e 's/CODESET=.*/CODESET="guess"/' -i ${dst_dir}/etc/default/console-setup
    327. eval 'LC_ALL=C LANG=C chroot ${dst_dir} /bin/bash -c "setupcon --save"'
    328. fi
    329. # this should fix resolvconf installation failure in some cases
    330. chroot ${dst_dir} /bin/bash -c 'echo "resolvconf resolvconf/linkify-resolvconf boolean false" | debconf-set-selections'
    331. local apt_extra="-o Acquire::http::Proxy=\"http://localhost:3142\""
    332. # base for gcc 9.3
    333. create_base_sources_list ${RELEASE} ${dst_dir}
    334. log_out "Updating base packages" "${dst_dir}" "info"
    335. eval 'LC_ALL=C LANG=C chroot ${dst_dir} /bin/bash -c "apt-get -q -y $apt_extra update"'
    336. [[ $? -ne 0 ]] && exit -1
    337. log_out "Upgrading base packages" "${dst_dir}" "info"
    338. eval 'LC_ALL=C LANG=C chroot ${dst_dir} /bin/bash -c "apt-get -q -y $apt_extra upgrade"'
    339. [[ $? -ne 0 ]] && exit -1
    340. log_out "Installing base packages" "${dst_dir}" "info"
    341. eval 'LC_ALL=C LANG=C chroot ${dst_dir} /bin/bash -c "DEBIAN_FRONTEND=noninteractive apt-get -y -q $apt_extra --no-install-recommends install $ADD_PACKAGE_LIST"'
    342. [[ $? -ne 0 ]] && exit -1
    343. chroot ${dst_dir} /bin/bash -c "dpkg --get-selections" | grep -v deinstall | awk '{print $1}' | cut -f1 -d':' > ${tar_file}.info
    344. # Fixed GCC version: 9.3.0
    345. chroot ${dst_dir} /bin/bash -c "apt-mark hold cpp-9 g++-9 gcc-9-base gcc-9 libasan5 libgcc-9-dev libstdc++-9-dev"
    346. # upgrade packages
    347. create_sources_list ${RELEASE} ${dst_dir}
    348. log_out "Updating focal-updates and focal-security packages" "${dst_dir}" "info"
    349. eval 'LC_ALL=C LANG=C chroot ${dst_dir} /bin/bash -c "apt-get -q -y $apt_extra update"'
    350. [[ $? -ne 0 ]] && exit -1
    351. log_out "Upgrading base packages" "${dst_dir}" "info"
    352. eval 'LC_ALL=C LANG=C chroot ${dst_dir} /bin/bash -c "apt-get -q -y $apt_extra upgrade"'
    353. [[ $? -ne 0 ]] && exit -1
    354. log_out "Installing base packages" "${dst_dir}" "info"
    355. eval 'LC_ALL=C LANG=C chroot ${dst_dir} /bin/bash -c "DEBIAN_FRONTEND=noninteractive apt-get -y -q $apt_extra --no-install-recommends install $ADD_PACKAGE_LIST"'
    356. [[ $? -ne 0 ]] && exit -1
    357. chroot ${dst_dir} /bin/bash -c "dpkg --get-selections" | grep -v deinstall | awk '{print $1}' | cut -f1 -d':' > ${tar_file}.info
    358. log_out "Configure hostname" "$HOST" "info"
    359. echo "$HOST" > ${dst_dir}/etc/hostname
    360. log_out "Configure resolv" ""${dst_dir}"/etc/resolv.conf" "info"
    361. rm ${dst_dir}/etc/resolv.conf
    362. echo "nameserver $NAMESERVER" > ${dst_dir}/etc/resolv.conf
    363. chroot ${dst_dir} /bin/bash -c "pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple"
    364. chroot ${dst_dir} /bin/bash -c "pip3 config set install.trusted-host https://pypi.tuna.tsinghua.edu.cn"
    365. chroot ${dst_dir} /bin/bash -c "pip3 install $PYTHON_PACKAGE_LIST"
    366. chroot ${dst_dir} /bin/bash -c "apt clean"
    367. log_out "Configure udev" ""${dst_dir}"/lib/udev/rules.d/" "info"
    368. # fixed camera sensor bug and fixed auto load audio ko bug
    369. # sed -i 's/ENV{MODALIAS}/# ENV{MODALIAS}/' "${dst_dir}"/lib/udev/rules.d/80-drivers.rules
    370. sed -i 's/IMPORT{program}/# IMPORT{program}/' "${dst_dir}"/lib/udev/rules.d/60-persistent-v4l.rules
    371. log_out "Configure udev" "${dst_dir}/lib/systemd/system/udev.service" "info"
    372. mkdir "${dst_dir}"/etc/systemd/system/systemd-udevd.service.d
    373. cat <<-EOF >> "${dst_dir}"/etc/systemd/system/systemd-udevd.service.d/00-hobot-private.conf
    374. [Service]
    375. PrivateMounts=no
    376. EOF
    377. log_out "Configure ssh" ""${dst_dir}"/etc/ssh/sshd_config" "info"
    378. # permit root login via SSH for the first boot
    379. sed -i 's/#\?PermitRootLogin .*/PermitRootLogin yes/' "${dst_dir}"/etc/ssh/sshd_config
    380. # enable PubkeyAuthentication
    381. sed -i 's/#\?PubkeyAuthentication .*/PubkeyAuthentication yes/' "${dst_dir}"/etc/ssh/sshd_config
    382. # # console fix due to Debian bug
    383. sed -e 's/CHARMAP=".*"/CHARMAP="'$CONSOLE_CHAR'"/g' -i "${dst_dir}"/etc/default/console-setup
    384. # add the /dev/urandom path to the rng config file
    385. echo "HRNGDEVICE=/dev/urandom" >> "${dst_dir}"/etc/default/rng-tools
    386. cat <<-EOF >> "${dst_dir}"/etc/hosts
    387. 127.0.0.1 localhost
    388. 127.0.0.1 $HOST
    389. EOF
    390. log_out "Setup net IP =" "${address}" "info"
    391. cat <<-EOF >> "${dst_dir}"/etc/network/interfaces
    392. auto ${ethdev}
    393. iface ${ethdev} inet static
    394. address ${address}
    395. netmask ${netmask}
    396. #network ${network}
    397. #broadcast ${broadcast}
    398. gateway ${gateway}
    399. metric 700
    400. EOF
    401. cp "${dst_dir}"/lib/systemd/system/serial-getty@.service "${dst_dir}/lib/systemd/system/serial-getty@ttyS0.service"
    402. sed -i "s/--keep-baud 115200/--keep-baud 921600,115200/" "${dst_dir}/lib/systemd/system/serial-getty@ttyS0.service"
    403. log_out "Enabling serial console" "ttyS0" "info"
    404. chroot "${dst_dir}" /bin/bash -c "systemctl daemon-reload"
    405. chroot "${dst_dir}" /bin/bash -c "systemctl --no-reload enable serial-getty@ttyS0.service"
    406. chroot "${dst_dir}" /bin/bash -c "(echo $ROOTPWD;echo $ROOTPWD;) | passwd root"
    407. chroot "${dst_dir}" /bin/bash -c "adduser --quiet --disabled-password --shell /bin/bash --ingroup sudo --home /home/${SUN_USERNAME} --gecos ${SUN_USERNAME} ${SUN_USERNAME}"
    408. chroot "${dst_dir}" /bin/bash -c "(echo ${SUN_PWD};echo ${SUN_PWD};) | passwd ${SUN_USERNAME}"
    409. chroot "${dst_dir}" /bin/bash -c "addgroup --quiet ${SUN_USERNAME}"
    410. # configure network manager
    411. sed "s/managed=\(.*\)/managed=true/g" -i "${dst_dir}"/etc/NetworkManager/NetworkManager.conf
    412. # most likely we don't need to wait for nm to get online
    413. chroot "${dst_dir}" /bin/bash -c "systemctl disable NetworkManager-wait-online.service"
    414. chroot "${dst_dir}" /bin/bash -c "systemctl disable hostapd.service"
    415. # Just regular DNS and maintain /etc/resolv.conf as a file
    416. sed "/dns/d" -i "${dst_dir}"/etc/NetworkManager/NetworkManager.conf
    417. sed "s/\[main\]/\[main\]\ndns=default\nrc-manager=file/g" -i "${dst_dir}"/etc/NetworkManager/NetworkManager.conf
    418. if [[ -n $NM_IGNORE_DEVICES ]]; then
    419. mkdir -p "${dst_dir}"/etc/NetworkManager/conf.d/
    420. cat <<-EOF > "${dst_dir}"/etc/NetworkManager/conf.d/10-ignore-interfaces.conf
    421. [keyfile]
    422. unmanaged-devices=$NM_IGNORE_DEVICES
    423. EOF
    424. fi
    425. chroot ${dst_dir} /bin/bash -c "chmod a=rx,u+ws /usr/bin/sudo"
    426. #/etc/apt/source.list
    427. chroot ${dst_dir} /bin/bash -c "apt clean"
    428. chroot ${dst_dir} /bin/bash -c "rm -f /var/lib/apt/lists/mirrors*"
    429. chroot ${dst_dir} /bin/bash -c "rm -rf /home/hobot"
    430. log_out "Configure tzdata" "${dst_dir}/etc/timezone" "info"
    431. echo "`cat /etc/timezone`" > "${dst_dir}"/etc/timezone
    432. chroot "${dst_dir}" /bin/bash -c "dpkg-reconfigure -f noninteractive tzdata >/dev/null 2>&1"
    433. # initial date for fake-
    434. log_out "Configure fake-hwclock" "date :`date '+%Y-%m-%d %H:%M:%S'`" "info"
    435. date '+%Y-%m-%d %H:%M:%S' > "${dst_dir}"/etc/fake-hwclock.data
    436. umount_chroot ${dst_dir}
    437. end_debootstrap ${dst_dir}
    438. chmod 777 ${dst_dir}/home/ -R
    439. # enable few bash aliases enabled in Ubuntu by default to make it even
    440. sed "s/#alias ll='ls -l'/alias ll='ls -l'/" -i "${dst_dir}"/etc/skel/.bashrc
    441. sed "s/#alias la='ls -A'/alias la='ls -A'/" -i "${dst_dir}"/etc/skel/.bashrc
    442. sed "s/#alias l='ls -CF'/alias l='ls -CF'/" -i "${dst_dir}"/etc/skel/.bashrc
    443. echo "/usr/bin/resize > /dev/null" >> "${dst_dir}"/etc/skel/.bashrc
    444. # root user is already there. Copy bashrc there as well
    445. cp "${dst_dir}"/etc/skel/.bashrc "${dst_dir}"/root
    446. if [ x$"desktop" == x"true" ];then
    447. log_out "Recreating Synaptic search index" "Please wait" "info"
    448. chroot ${dst_dir} /bin/bash -c "/usr/sbin/update-apt-xapian-index -u"
    449. # fix for gksu in Xenial
    450. touch ${dst_dir}/home/${SUN_USERNAME}/.Xauthority
    451. chroot "${dst_dir}" /bin/bash -c "chown ${SUN_USERNAME}:${SUN_USERNAME} /home/${SUN_USERNAME}/.Xauthority"
    452. # set up profile sync daemon on desktop systems
    453. chroot "${dst_dir}" /bin/bash -c "which psd >/dev/null 2>&1"
    454. if [ $? -eq 0 ]; then
    455. echo -e "${SUN_USERNAME} ALL=(ALL) NOPASSWD: /usr/bin/psd-overlay-helper" >> ${dst_dir}/etc/sudoers
    456. touch ${dst_dir}/home/${SUN_USERNAME}/.activate_psd
    457. chroot "${dst_dir}" /bin/bash -c "chown $SUN_USERNAME:$SUN_USERNAME /home/${SUN_USERNAME}/.activate_psd"
    458. fi
    459. fi
    460. #store size of dst_dir to ${tar_file}.info
    461. local dusize=`du -sh ${dst_dir} 2> /dev/null |awk '{print $1}'`
    462. echo "DIR_DU_SIZE ${dusize%%M}" >> ${tar_file}.info
    463. trap - INT TERM EXIT
    464. }
    465. log_out "Build ubuntu base" "root_path=$root_path tar_file=$tar_file" "info"
    466. log_out "Start build" "ubuntu base :${RELEASE}-xj3-${ARCH}" "info"
    467. mkdir -p ${ubuntufs_dst}
    468. if [ ! -f "${tar_file}0" ];then
    469. make_base_root "${root_path}"
    470. sync
    471. # Compression takes longer
    472. compress_base_root "${tar_file}" "${root_path}" s
    473. extract_base_root "${tar_file}" "${ubuntufs_dst}"
    474. sync
    475. else
    476. extract_base_root "${tar_file}" "${ubuntufs_dst}"
    477. sync
    478. fi
    479. log_out "End build ubuntu base" "${ubuntufs_dst}" "info"
    480. exit 0

  • 相关阅读:
    反编译过程中会面临哪些挑战和难题
    系分 - 操作系统 - 嵌入式
    队列OJ--循环队列
    2021 第四届 浙江省大学生网络与信息安全竞赛技能赛 决赛 Writeup,5题
    Qt 集成OSG
    [每日两题系列]刷算法题咯~~
    vue在方法里如何使用过滤器(在methods函数里使用filters)
    JDBC(Java Database Connectivity)
    Tarjan基础用法
    JavaParse入门
  • 原文地址:https://blog.csdn.net/ldinvicible/article/details/132967059