代码拉取完成,页面将自动刷新
#!/bin/bash
# Usage
# ./build_initrd.sh [-k]
# -k: keep rootfs in ram and not swtich to block device
source ./envsetup
WS_BB=$WS/test-busybox
#set -v
OUT=$WS_BB/output
export OUT
echo "======> OUT=$OUT"
export CROSS_COMPILE=riscv64-buildroot-linux-gnu-
#export CROSS_COMPILE=riscv64-unknown-linux-gnu-
echo "======> CROSS_COMPILE=$CROSS_COMPILE"
PATH_BB=$WS_BB/busyboxsource
# $ git remote -v
# busybox git://git.busybox.net/busybox (fetch)
# busybox git://git.busybox.net/busybox (push)
# origin [email protected]:mirrors/busyboxsource.git (fetch)
# origin [email protected]:mirrors/busyboxsource.git (push)
PATH_ROOTFS=$WS_BB/rootfs
PATH_INITRD_IMAGE=$WS_BB/initrd.img
if [ "$1" = "-k" ]; then
O_KEEPINRAM=y
fi
echo "======> Start building ......"
pushd $PATH_BB
echo "======> Cleanup for FULLY building ......"
rm -rf $OUT
mkdir $OUT
echo "======> \"Settings\" -> \"Build Options\" -> eanble \"Build static binary (no shared libs)\""
read -p "Would you continue? [Y/N]:" choice
case $choice in
Y | y)
make O=$OUT menuconfig
;;
*)
popd
exit
;;
esac
make -j$(nproc) O=$OUT
make O=$OUT install
popd
echo "======> Building busybox is done."
echo "======> Starting to make initramfs image ......"
if [ -d $PATH_ROOTFS ]; then
rm -rf $PATH_ROOTFS
fi
if [ -f $PATH_INITRD_IMAGE ];then
rm -f $PATH_INITRD_IMAGE
fi
mkdir $PATH_ROOTFS
pushd $PATH_ROOTFS
cp -r $OUT/_install/* .
mkdir mnt proc sys dev etc etc/init.d
if [ "$O_KEEPINRAM" = "y" ]; then
ln -s /bin/busybox init
touch etc/init.d/rcS
chmod +x etc/init.d/rcS
cat >> etc/init.d/rcS << EOF
#!/bin/sh
mount -t proc none /proc
mount -t sysfs none /sys
sleep 1
echo "sleep done!"
/sbin/mdev -s
EOF
else
touch init
chmod +x init
cat >> init << EOF
#!/bin/sh
mount -t proc none /proc
mount -t sysfs none /sys
sleep 1
echo "sleep done!"
/sbin/mdev -s
sleep 1
echo "slepp 2 done!"
/bin/mount /dev/mmcblk1p2 /mnt
echo "mount sdcard done!"
exec switch_root /mnt /usr/sbin/init
EOF
fi
find . | cpio --create --format='newc' > $PATH_INITRD_IMAGE
echo "======> Initramfs image is done."
popd
#rm -rf $PATH_ROOTFS
#rm -rf $OUT
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。