我想編寫一個腳本,將執行以下命令:無法正確設置環境變量LD_PRELOAD在bash腳本
${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。 follwoing在這個論壇是我嘗試過其他的答案是這樣的:
更新的代碼
#!/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,但爲什麼這些錯誤?
您的圖書館setuid?嘗試使用'chmod g + s libfakeroot-tcp.so' setgid –
@MarkSetchell感謝您的評論。但是你認爲這個錯誤是否會影響輸出文件initramfs.cpio – user2799508
@MarkSetchell [root @ xilinx /]#chmod g + s /usr/lib64/libfakeroot/libfakeroot-tcp.so,但即使如此也會出現相同的錯誤。 – user2799508