我想编写一个执行以下命令的脚本:
${CROSS_COMPILE}gcc -static myinit.c -o myinit
cd initramfs
fakeroot # this is pure magic (it allows us to pretend to be root)
mkdir -p dev
mknod dev/console c 5 1
chown root init
find . | cpio -H newc -o > ../initramfs.cpio # <-- this is the actual initramfs
exit # leave the fakeroot shell
cd ..
截至目前,我必须每天手动做200次。所以我想它可以转换成一个自动化过程的scipt。在这个论坛中,我试过的其他答案是:
更新代码
#!/bin/bash
LD_PRELOAD="/usr/lib64/libfakeroot/libfakeroot-tcp.so" printenv "LD_PRELOAD" libfakeroot-tcp.so
printenv "LD_PRELOAD"
printenv "LD_PRELOAD"
arm-xilinx-linux-gnueabi-gcc -static echotest.c -o init
cp init initramfs
cd initramfs
fakeroot
mkdir -p dev
mknod dev/console c 5 1
chown root init
find . | cpio -H newc -o > ../initramfs.cpio
exit
cd ..
我在test.sh中保存了这个,并使这个文件可执行。这是我得到的输出:
更新了输出
/usr/lib64/libfakeroot/libfakeroot-tcp.so
libfakeroot-tcp.so
ERROR: ld.so: object 'libfakeroot-tcp.so' from LD_PRELOAD cannot be preloaded: ignored.
ERROR: ld.so: object 'libfakeroot-tcp.so' from LD_PRELOAD cannot be preloaded: ignored.
ERROR: ld.so: object 'libfakeroot-tcp.so' from LD_PRELOAD cannot be preloaded: ignored.
ERROR: ld.so: object 'libfakeroot-tcp.so' from LD_PRELOAD cannot be preloaded: ignored.
ERROR: ld.so: object 'libfakeroot-tcp.so' from LD_PRELOAD cannot be preloaded: ignored.
fakeroot: FAKEROOTKEY set to 39730
fakeroot: nested operation not yet supported
1289 blocks
我收到了预期的文件initramfs.cpio,但为什么会出现这些错误?
答案 0 :(得分:2)
当你说
时LD_PRELOAD="/usr/lib64/libfakeroot/libfakeroot-tcp.so" printenv "LD_PRELOAD" libfakeroot-tcp.so
在printenv命令的持续时间内设置LD_PRELOAD变量仅。尝试:
export LD_PRELOAD="/usr/lib64/libfakeroot/libfakeroot-tcp.so"
arm-xilinx-linux-gnueabi-gcc -static echotest.c -o init
...