119 lines
3.6 KiB
Bash
Executable File
119 lines
3.6 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
. ./scripts/colors.sh
|
|
. ./scripts/funcs.sh
|
|
. ./scripts/config.sh
|
|
. ./scripts/kernel.sh
|
|
. ./scripts/uboot.sh
|
|
. ./scripts/initramfs.sh
|
|
|
|
#--- sdroot ---
|
|
sdroot() {
|
|
print_info "** Generating sdroot"
|
|
rm -rv $sdroot
|
|
if [ ! -d $sdroot ]; then
|
|
mkdir -pv $sdroot
|
|
fi
|
|
print_info "** Creating dirs"
|
|
mkdir -pv $sdroot/boot/{dtbs,extlinux}
|
|
check $? "Creating dirs"
|
|
print_info "** Copy extlinux.conf"
|
|
cp -v $root/extlinux/extlinux.conf $sdroot/boot/extlinux
|
|
check $? "Copy extlinux.conf"
|
|
[ "$ARCH" = "arm64" ] && sed -i "s/zImage/Image/g" $sdroot/boot/extlinux/extlinux.conf
|
|
kernel_with_rootfs
|
|
uboot
|
|
print_info "** Creating rootfs.ext4"
|
|
cd $out
|
|
rawsdrootsize=$(du -s $sdroot)
|
|
echo $rawsdrootsize
|
|
sdrootsize=(${rawsdrootsize// / })
|
|
echo $sdrootsize
|
|
echo $(($sdrootsize+2))
|
|
dd if=/dev/zero of=rootfs.ext4 bs=1K count=$(($sdrootsize+$sdrootsize))
|
|
check $? "Write zero rootfs.ext4"
|
|
mkfs.ext4 rootfs.ext4
|
|
check $? "Creating ext4 filesystem"
|
|
rawuuid=$(echo $(blkid rootfs.ext4 | echo $(awk '{print $2}')))
|
|
echo $rawuuid
|
|
uuidIN=(${rawuuid//=/ })
|
|
uuid=${uuidIN[1]}
|
|
echo $uuid
|
|
cp -v $root/genimage/genimage.cfg .
|
|
check $? "Copy genimage.cfg"
|
|
sed -i "s/FILEUUID/$uuid/g" genimage.cfg
|
|
mkdir -v rootmnt
|
|
sudo mount -v rootfs.ext4 rootmnt
|
|
sudo cp -rv $sdroot/* rootmnt/
|
|
sudo umount -v rootfs.ext4
|
|
rm -rv rootmnt
|
|
mkdir input
|
|
mv -v ./{rootfs.ext4,u-boot-sunxi-with-spl.bin} input
|
|
genimage --config genimage.cfg
|
|
check $? "Generating sdcard.img"
|
|
}
|
|
#--------------
|
|
|
|
sdroot_usable() {
|
|
print_info "** Generating sdroot usable"
|
|
rm -rv $sdroot
|
|
if [ ! -d $sdroot ]; then
|
|
mkdir -pv $sdroot
|
|
fi
|
|
print_info "** Creating dirs"
|
|
mkdir -pv $sdroot/boot/{dtbs,extlinux}
|
|
check $? "Creating dirs"
|
|
print_info "** Copy extlinux.conf"
|
|
cp -v $root/extlinux/extlinux_usable.conf $sdroot/boot/extlinux/extlinux.conf
|
|
check $? "Copy extlinux.conf"
|
|
# kernel_with_rootfs
|
|
# cp -rv $build/rootfs/* $sdroot/
|
|
cd $rootfspath
|
|
tar -czvf /tmp/rootfs.tar.gz.tmp .
|
|
cd $sdroot
|
|
tar -xf /tmp/rootfs.tar.gz.tmp
|
|
|
|
initramfs
|
|
cp -v $build/initramfs.img $sdroot/boot
|
|
KIMAGE=zImage
|
|
[ "$ARCH" = "arm64" ] && KIMAGE=Image
|
|
cp -v $build/kernel/linux-6.13.3/arch/$ARCH/boot/$KIMAGE $sdroot/boot
|
|
uboot
|
|
print_info "** Creating rootfs.ext4"
|
|
cd $out
|
|
rawsdrootsize=$(du -s $sdroot)
|
|
echo $rawsdrootsize
|
|
sdrootsize=(${rawsdrootsize// / })
|
|
echo $sdrootsize
|
|
echo $(($sdrootsize+2))
|
|
dd if=/dev/zero of=rootfs.ext4 bs=1K count=$(($sdrootsize+$sdrootsize))
|
|
check $? "Write zero rootfs.ext4"
|
|
mkfs.ext4 rootfs.ext4
|
|
check $? "Creating ext4 filesystem"
|
|
rawuuid=$(echo $(blkid rootfs.ext4 | echo $(awk '{print $2}')))
|
|
echo $rawuuid
|
|
uuidIN=(${rawuuid//=/ })
|
|
uuid=${uuidIN[1]}
|
|
echo $uuid
|
|
cp -v $root/genimage/genimage.cfg .
|
|
check $? "Copy genimage.cfg"
|
|
sed -i "s/FILEUUID/$uuid/g" genimage.cfg
|
|
sed -i "s/ROOTUUID/$uuid/g" $sdroot/boot/extlinux/extlinux.conf
|
|
[ "$ARCH" = "arm64" ] && sed -i "s/zImage/Image/g" $sdroot/boot/extlinux/extlinux.conf
|
|
sed -i "s/sdcard.img/sdcard_usable.img/g" genimage.cfg
|
|
mkdir -v rootmnt
|
|
sudo mount -v rootfs.ext4 rootmnt
|
|
cd $sdroot
|
|
sudo tar -czf /tmp/sdroot.tar.gz.tmp .
|
|
cd $root/out/rootmnt
|
|
sudo tar -xf /tmp/sdroot.tar.gz.tmp
|
|
cd $out
|
|
# sudo cp -rv $sdroot/* rootmnt/
|
|
sudo umount -v rootfs.ext4
|
|
rm -rv rootmnt
|
|
mkdir input
|
|
mv -v ./{rootfs.ext4,u-boot-sunxi-with-spl.bin} input
|
|
genimage --config genimage.cfg
|
|
check $? "Generating sdcard_usable.img"
|
|
}
|