1 Star 0 Fork 0

unicornx/ilovelinux

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
build_initrd.sh 2.05 KB
一键复制 编辑 原始数据 按行查看 历史
unicornx 提交于 2024-08-30 16:00 . build initrd support -k
#!/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
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/unicornx/ilovelinux.git
[email protected]:unicornx/ilovelinux.git
unicornx
ilovelinux
ilovelinux
master

搜索帮助