博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Buildroot 打包文件系统流程跟踪
阅读量:6036 次
发布时间:2019-06-20

本文共 12332 字,大约阅读时间需要 41 分钟。

/********************************************************************************* *                  Buildroot 打包文件系统流程跟踪 * 说明: *     之前在使用Buildroot过程中,发现其自身生成的rootfs.tar.bz2文件系统可以正常运行 * 但自己使用命令打包的文件系统就有问题,于是跟一下其脚本运行的输出信息,原来使用到 * 了fakeroot来模拟root权限。 * *                                              2017-10-11 深圳 南山平山村 曾剑锋 ********************************************************************************/一、输出信息分析:    [7m>>>   Finalizing target directory[27m    rm -f /home/zengjf/zengjfos/buildroot-2017.02.3/output/target/usr/share/glib-2.0/schemas/*.xml /home/zengjf/zengjfos/buildroot-2017.02.3/output/target/usr/share/glib-2.0/schemas/*.dtd    /home/zengjf/zengjfos/buildroot-2017.02.3/output/host/usr/bin/glib-compile-schemas /home/zengjf/zengjfos/buildroot-2017.02.3/output/host/usr/arm-buildroot-linux-gnueabi/sysroot/usr/share/glib-2.0/schemas --targetdir=/home/zengjf/zengjfos/buildroot-2017.02.3/output/target/usr/share/glib-2.0/schemas    No schema files found: doing nothing.    PYTHONPATH="/home/zengjf/zengjfos/buildroot-2017.02.3/output/target/usr/lib/python3.5/sysconfigdata/:/home/zengjf/zengjfos/buildroot-2017.02.3/output/target/usr/lib/python3.5/site-packages/" /home/zengjf/zengjfos/buildroot-2017.02.3/output/host/usr/bin/python3.5 support/scripts/pycompile.py /home/zengjf/zengjfos/buildroot-2017.02.3/output/target/usr/lib/python3.5    find /home/zengjf/zengjfos/buildroot-2017.02.3/output/target/usr/lib/python3.5 -name '*.py' -print0 | xargs -0 --no-run-if-empty rm -f    find /home/zengjf/zengjfos/buildroot-2017.02.3/output/target/usr/lib/python3.5 -name '*.opt-1.pyc' -print0 -o -name '*.opt-2.pyc' -print0 | xargs -0 --no-run-if-empty rm -f    # 创建etc目录    mkdir -p /home/zengjf/zengjfos/buildroot-2017.02.3/output/target/etc    # 创建hostname目录    echo "AplexOS" > /home/zengjf/zengjfos/buildroot-2017.02.3/output/target/etc/hostname    # 使用sed对文件进行操作    /bin/sed -i -e '$a \127.0.1.1\tAplexOS' -e '/^127.0.1.1/d' /home/zengjf/zengjfos/buildroot-2017.02.3/output/target/etc/hosts    mkdir -p /home/zengjf/zengjfos/buildroot-2017.02.3/output/target/etc    # 登录前欢迎语句    echo "Welcome to AplexOS" > /home/zengjf/zengjfos/buildroot-2017.02.3/output/target/etc/issue    # 创建network目录    mkdir -p /home/zengjf/zengjfos/buildroot-2017.02.3/output/target/etc/network/    # 设置loopback设备,这也就是为什么interfaces如果这里不进行修改,每次都会被修改的原因    ( echo "# interface file auto-generated by buildroot"; echo ; echo "auto lo"; echo "iface lo inet loopback"; ) > /home/zengjf/zengjfos/buildroot-2017.02.3/output/target/etc/network/interfaces    # 设置eth0设备    ( echo ; echo "auto eth0"; echo "iface eth0 inet static"; echo "     address 192.168.1.202"; echo "     netmask 255.255.255.0"; echo "     broadcast 0.0.0.0"; echo "     gateway 192.168.1.1"; ) >> /home/zengjf/zengjfos/buildroot-2017.02.3/output/target/etc/network/interfaces    /usr/bin/install -m 0755 -D package/skeleton//nfs_check /home/zengjf/zengjfos/buildroot-2017.02.3/output/target/etc/network/nfs_check    # 生成root账户及密码    /bin/sed -i -e s,^root:[^:]*:,root:"`/home/zengjf/zengjfos/buildroot-2017.02.3/output/host/usr/bin/mkpasswd -m "md5" "aplex"`":, /home/zengjf/zengjfos/buildroot-2017.02.3/output/target/etc/shadow    # debug port    /bin/sed -i -e '/# GENERIC_SERIAL$/s~^.*#~console::respawn:/sbin/getty -L  console 0 vt100 #~' /home/zengjf/zengjfos/buildroot-2017.02.3/output/target/etc/inittab    # 修改inittab文件    /bin/sed -i -e '/^#.*-o remount,rw \/$/s~^#\+~~' /home/zengjf/zengjfos/buildroot-2017.02.3/output/target/etc/inittab    rm -f /home/zengjf/zengjfos/buildroot-2017.02.3/output/build/locales.nopurge    for i in C en_US locale-archive; do echo $i >> /home/zengjf/zengjfos/buildroot-2017.02.3/output/build/locales.nopurge; done    for dir in /home/zengjf/zengjfos/buildroot-2017.02.3/output/target/usr/share/locale; do for langdir in $dir/*; do if [ -e "${langdir}" ]; then grep -qx "${langdir##*/}" /home/zengjf/zengjfos/buildroot-2017.02.3/output/build/locales.nopurge || rm -rf $langdir; fi done; done    if [ -d /home/zengjf/zengjfos/buildroot-2017.02.3/output/target/usr/share/X11/locale ]; then for lang in C en_US; do if [ -f /home/zengjf/zengjfos/buildroot-2017.02.3/output/target/usr/share/X11/locale/$lang/XLC_LOCALE ]; then echo "$lang/XLC_LOCALE: $lang"; fi done > /home/zengjf/zengjfos/buildroot-2017.02.3/output/target/usr/share/X11/locale/locale.dir; fi    rm -rf /home/zengjf/zengjfos/buildroot-2017.02.3/output/target/usr/include /home/zengjf/zengjfos/buildroot-2017.02.3/output/target/usr/share/aclocal \        /home/zengjf/zengjfos/buildroot-2017.02.3/output/target/usr/lib/pkgconfig /home/zengjf/zengjfos/buildroot-2017.02.3/output/target/usr/share/pkgconfig \        /home/zengjf/zengjfos/buildroot-2017.02.3/output/target/usr/lib/cmake /home/zengjf/zengjfos/buildroot-2017.02.3/output/target/usr/share/cmake    find /home/zengjf/zengjfos/buildroot-2017.02.3/output/target/usr/{lib,share}/ -name '*.cmake' -print0 | xargs -0 rm -f    find /home/zengjf/zengjfos/buildroot-2017.02.3/output/target/lib/ /home/zengjf/zengjfos/buildroot-2017.02.3/output/target/usr/lib/ /home/zengjf/zengjfos/buildroot-2017.02.3/output/target/usr/libexec/ \        \( -name '*.a' -o -name '*.la' \) -print0 | xargs -0 rm -f    rm -rf /home/zengjf/zengjfos/buildroot-2017.02.3/output/target/usr/share/gdb    rm -rf /home/zengjf/zengjfos/buildroot-2017.02.3/output/target/usr/share/bash-completion    rm -rf /home/zengjf/zengjfos/buildroot-2017.02.3/output/target/usr/share/zsh    rm -rf /home/zengjf/zengjfos/buildroot-2017.02.3/output/target/usr/man /home/zengjf/zengjfos/buildroot-2017.02.3/output/target/usr/share/man    rm -rf /home/zengjf/zengjfos/buildroot-2017.02.3/output/target/usr/info /home/zengjf/zengjfos/buildroot-2017.02.3/output/target/usr/share/info    rm -rf /home/zengjf/zengjfos/buildroot-2017.02.3/output/target/usr/doc /home/zengjf/zengjfos/buildroot-2017.02.3/output/target/usr/share/doc    rm -rf /home/zengjf/zengjfos/buildroot-2017.02.3/output/target/usr/share/gtk-doc    rmdir /home/zengjf/zengjfos/buildroot-2017.02.3/output/target/usr/share 2>/dev/null || true    find /home/zengjf/zengjfos/buildroot-2017.02.3/output/target -type f \( -perm /111 -o -name '*.so*' \) -not \( -name 'libpthread*.so*' -o -name 'ld-*.so*' -o -name '*.ko' \) -print0 | xargs -0 /home/zengjf/zengjfos/buildroot-2017.02.3/output/host/usr/bin/arm-buildroot-linux-gnueabi-strip --remove-section=.comment --remove-section=.note 2>/dev/null || true    find /home/zengjf/zengjfos/buildroot-2017.02.3/output/target/lib/ -type f -name 'libpthread*.so*' | \        xargs -r /home/zengjf/zengjfos/buildroot-2017.02.3/output/host/usr/bin/arm-buildroot-linux-gnueabi-strip --remove-section=.comment --remove-section=.note --strip-debug    find /home/zengjf/zengjfos/buildroot-2017.02.3/output/target/lib/ -type f -name 'ld-*.so*' | \        xargs -r /home/zengjf/zengjfos/buildroot-2017.02.3/output/host/usr/bin/arm-buildroot-linux-gnueabi-strip --remove-section=.comment --remove-section=.note --strip-debug    # 检查一些库的存在    test -f /home/zengjf/zengjfos/buildroot-2017.02.3/output/target/etc/ld.so.conf && \        { echo "ERROR: we shouldn't have a /etc/ld.so.conf file"; exit 1; } || true    test -d /home/zengjf/zengjfos/buildroot-2017.02.3/output/target/etc/ld.so.conf.d && \        { echo "ERROR: we shouldn't have a /etc/ld.so.conf.d directory"; exit 1; } || true    mkdir -p /home/zengjf/zengjfos/buildroot-2017.02.3/output/target/etc    ( \        echo "NAME=Buildroot"; \        echo "VERSION=2017.02.3"; \        echo "ID=buildroot"; \        echo "VERSION_ID=2017.02.3"; \        echo "PRETTY_NAME=\"Buildroot 2017.02.3\"" \    ) >  /home/zengjf/zengjfos/buildroot-2017.02.3/output/target/etc/os-release    [7m>>>   Generating root filesystem image rootfs.tar[27m    rm -f /home/zengjf/zengjfos/buildroot-2017.02.3/output/build/_fakeroot.fs    rm -f /home/zengjf/zengjfos/buildroot-2017.02.3/output/target/THIS_IS_NOT_YOUR_ROOT_FILESYSTEM    rm -f /home/zengjf/zengjfos/buildroot-2017.02.3/output/build/_users_table.txt    echo '#!/bin/sh' > /home/zengjf/zengjfos/buildroot-2017.02.3/output/build/_fakeroot.fs    echo "set -e" >> /home/zengjf/zengjfos/buildroot-2017.02.3/output/build/_fakeroot.fs    echo "chown -h -R 0:0 /home/zengjf/zengjfos/buildroot-2017.02.3/output/target" >> /home/zengjf/zengjfos/buildroot-2017.02.3/output/build/_fakeroot.fs    printf '       sshd -1 sshd -1 * - - - SSH drop priv user\n     ftp -1 ftp -1 * /home/ftp - - Anonymous FTP User\n\n' >> /home/zengjf/zengjfos/buildroot-2017.02.3/output/build/_users_table.txt    PATH="/home/zengjf/zengjfos/buildroot-2017.02.3/output/host/bin:/home/zengjf/zengjfos/buildroot-2017.02.3/output/host/sbin:/home/zengjf/zengjfos/buildroot-2017.02.3/output/host/usr/bin:/home/zengjf/zengjfos/buildroot-2017.02.3/output/host/usr/sbin:/home/bin:/home/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/zengjf/zengjfos/buildroot-2016.08/output/host/opt/ext-toolchain/bin::/home/zengjf/zengjfos/AplexOS/git-repo:/home/linux/pycharm-community-2017.1.3/bin" /home/zengjf/zengjfos/buildroot-2017.02.3/support/scripts/mkusers /home/zengjf/zengjfos/buildroot-2017.02.3/output/build/_users_table.txt /home/zengjf/zengjfos/buildroot-2017.02.3/output/target >> /home/zengjf/zengjfos/buildroot-2017.02.3/output/build/_fakeroot.fs    cat system/device_table.txt > /home/zengjf/zengjfos/buildroot-2017.02.3/output/build/_device_table.txt    printf '       /bin/busybox                     f 4755 0  0 - - - - -\n /dev/console c 622 0 0 5 1 - - -\n\n' >> /home/zengjf/zengjfos/buildroot-2017.02.3/output/build/_device_table.txt    echo "/home/zengjf/zengjfos/buildroot-2017.02.3/output/host/usr/bin/makedevs -d /home/zengjf/zengjfos/buildroot-2017.02.3/output/build/_device_table.txt /home/zengjf/zengjfos/buildroot-2017.02.3/output/target" >> /home/zengjf/zengjfos/buildroot-2017.02.3/output/build/_fakeroot.fs    # 这里很重要,因为这里可以将target中的内容打包进入rootfs.tar中去    printf '       (cd /home/zengjf/zengjfos/buildroot-2017.02.3/output/target; find -print0 | LC_ALL=C sort -z | tar  -cf /home/zengjf/zengjfos/buildroot-2017.02.3/output/images/rootfs.tar --null --no-recursion -T - --numeric-owner)\n' >> /home/zengjf/zengjfos/buildroot-2017.02.3/output/build/_fakeroot.fs    # 给_fakeroot.fs加执行权限    chmod a+x /home/zengjf/zengjfos/buildroot-2017.02.3/output/build/_fakeroot.fs    # 用fakeroot执行_fakeroot.fs    PATH="/home/zengjf/zengjfos/buildroot-2017.02.3/output/host/bin:/home/zengjf/zengjfos/buildroot-2017.02.3/output/host/sbin:/home/zengjf/zengjfos/buildroot-2017.02.3/output/host/usr/bin:/home/zengjf/zengjfos/buildroot-2017.02.3/output/host/usr/sbin:/home/bin:/home/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/zengjf/zengjfos/buildroot-2016.08/output/host/opt/ext-toolchain/bin::/home/zengjf/zengjfos/AplexOS/git-repo:/home/linux/pycharm-community-2017.1.3/bin" /home/zengjf/zengjfos/buildroot-2017.02.3/output/host/usr/bin/fakeroot -- /home/zengjf/zengjfos/buildroot-2017.02.3/output/build/_fakeroot.fs    rootdir=/home/zengjf/zengjfos/buildroot-2017.02.3/output/target    table='/home/zengjf/zengjfos/buildroot-2017.02.3/output/build/_device_table.txt'    # 相当于拷贝,同时可以设定权限    /usr/bin/install -m 0644 support/misc/target-dir-warning.txt /home/zengjf/zengjfos/buildroot-2017.02.3/output/target/THIS_IS_NOT_YOUR_ROOT_FILESYSTEM    # 使用bzip2进行压缩    PATH="/home/zengjf/zengjfos/buildroot-2017.02.3/output/host/bin:/home/zengjf/zengjfos/buildroot-2017.02.3/output/host/sbin:/home/zengjf/zengjfos/buildroot-2017.02.3/output/host/usr/bin:/home/zengjf/zengjfos/buildroot-2017.02.3/output/host/usr/sbin:/home/bin:/home/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/zengjf/zengjfos/buildroot-2016.08/output/host/opt/ext-toolchain/bin::/home/zengjf/zengjfos/AplexOS/git-repo:/home/linux/pycharm-community-2017.1.3/bin" bzip2 -9 -c /home/zengjf/zengjfos/buildroot-2017.02.3/output/images/rootfs.tar > /home/zengjf/zengjfos/buildroot-2017.02.3/output/images/rootfs.tar.bz2二、fakeroot使用:    1. 参考命令:fakeroot -- /home/zengjf/zengjfos/buildroot-2017.02.3/output/build/_fakeroot.fs    2. cd 
&& fakeroot -- tar jcvf rootfs.tar.bz2 *

 

转载于:https://www.cnblogs.com/zengjfgit/p/7651302.html

你可能感兴趣的文章
Android dumpsys命令的使用
查看>>
Linux Kernel系列一:开篇和Kernel启动概要
查看>>
BZOJ 2756: [SCOI2012]奇怪的游戏 网络流/二分
查看>>
master + worker模式的node多核解决框架——node-cluster
查看>>
Android如何实现超级棒的沉浸式体验
查看>>
使用node打造自己的命令行工具方法教程
查看>>
Express代理中间件问题与解决方案
查看>>
||和&&返回什么?
查看>>
linux在文件中查找指定字符串,然后根据查找结果来做进一步的处理
查看>>
在Oracle中删除所有强制性外键约束
查看>>
dhcp
查看>>
【R】R语言使用命令行参数 - [编程技巧(Program Skill)]
查看>>
经典算法题每日演练——第二题 五家共井
查看>>
存储过程中拼接的变量和点的问题
查看>>
ASP.NET那点不为人知的事(一)
查看>>
HTML 表格
查看>>
VMware 虚拟化编程(7) — VixDiskLib 虚拟磁盘库详解之三
查看>>
php 未实例化类调用方法的问题
查看>>
我对读计算机软件专业硕士的几点看法
查看>>
用JS写CSS
查看>>