update for rootfs_usable
This commit is contained in:
1 parent
156e149ecb
commit
eb538f5ff4
19 files changed
+1536
-25
No files matched your search
@@ -9,16 +9,23 @@
|
||||
. ./scripts/rootfs.sh
|
||||
. ./scripts/uboot.sh
|
||||
. ./scripts/sdroot.sh
|
||||
. ./scripts/dropbear.sh
|
||||
|
||||
case $1 in
|
||||
build)
|
||||
rootfs
|
||||
sdroot
|
||||
# rootfs
|
||||
if [ "$image_usable_enable" = "true" ]; then
|
||||
sdroot_usable
|
||||
fi
|
||||
# sdroot
|
||||
# kernel_with_rootfs
|
||||
# uboot
|
||||
# busybox_rootfs
|
||||
# kernel
|
||||
;;
|
||||
dropbear)
|
||||
dropbear
|
||||
;;
|
||||
download)
|
||||
download_sources
|
||||
;;
|
||||
|
||||
+23
-3
@@ -18,10 +18,30 @@ busybox_rootfs() {
|
||||
cd busybox-1.36.1
|
||||
cp -v $root/busybox/busybox-rootfs-config .config # &>> $fulllogfile
|
||||
printf "$UGREEN** Configuring busybox\n$RESET"
|
||||
make ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE oldconfig # &>> $fulllogfile
|
||||
make ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE- oldconfig # &>> $fulllogfile
|
||||
check $? "Configure busybox all logs in .log"
|
||||
printf "$UGREEN** Building busybox\n$RESET"
|
||||
make ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE $makeflags # &>> $fulllogfile
|
||||
make ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE- $makeflags # &>> $fulllogfile
|
||||
check $? "Build busybox all logs in .log"
|
||||
}
|
||||
#--------------------------------------------------
|
||||
#--------------------------------------------------
|
||||
|
||||
#------------------ Building busybox for initramfs ----------------
|
||||
busybox_initramfs() {
|
||||
printf "$UGREEN** Building busybox for initramfs\n$RESET"
|
||||
rm -r $build/busybox # &>> $fulllogfile
|
||||
mkdir -p $build/busybox
|
||||
cd $build/busybox
|
||||
tar -xjf $root/downloads/busybox-1.36.1.tar.bz2
|
||||
check $? "Extract busybox"
|
||||
cd busybox-1.36.1
|
||||
cp $root/busybox/busybox-initramfs-config .config
|
||||
# export PATH=$PATH:/opt/toolchains/x86_64-buildroot-linux-uclibc-gcc/bin
|
||||
printf "$UGREEN** Configuring busybox\n$RESET"
|
||||
make ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE- oldconfig # &>> $fulllogfile
|
||||
check $? "Configure busybox all logs in .log"
|
||||
printf "$UGREEN** Building busybox\n$RESET"
|
||||
make ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE- $makeflags # &>> $fulllogfile
|
||||
check $? "Build busybox all logs in .log"
|
||||
}
|
||||
#------------------------------------------------------------------
|
||||
+6
-3
@@ -12,13 +12,16 @@ export distro_codename="zero_zero_one" # distro codename
|
||||
export out=$root/out # output directory
|
||||
export build=$root/build # build directory
|
||||
export sourcesfilename=sources.txt # sources file for downloading
|
||||
# initramfsfile=$root/initramfs/initramfs.txt # file to created directories for initramfs
|
||||
# initramfspath=$build/initramfs # initramfs build directory
|
||||
export initramfsfile=$root/initramfs/initramfs.txt # file to created directories for initramfs
|
||||
export initramfspath=$build/initramfs # initramfs build directory
|
||||
export rootfsfile=$root/rootfs/rootfs.txt # file to created directories for rootfs
|
||||
export rootfspath=$build/rootfs # rootfs build directory
|
||||
export fulllogfile=$root/.log/fulllog.log # file for full build logs
|
||||
export makeflags=-j$(nproc) # makeflags
|
||||
export CROSS_COMPILE=arm-buildroot-linux-uclibcgnueabihf-
|
||||
export CROSS_COMPILE=arm-buildroot-linux-uclibcgnueabihf
|
||||
export ARCH=arm
|
||||
export sdroot=$out/sdroot
|
||||
export ZLIB_ENABLE="true"
|
||||
export DROPBEAR_ENABLE="true"
|
||||
export image_usable_enable="true"
|
||||
#--------------------------------------
|
||||
@@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
|
||||
. ./scripts/colors.sh
|
||||
. ./scripts/funcs.sh
|
||||
. ./scripts/config.sh
|
||||
. ./scripts/zlib.sh
|
||||
|
||||
dropbear() {
|
||||
if [ ! -d $build/zlib ]; then
|
||||
zlib
|
||||
fi
|
||||
printf "$GREEN** Building and installing dropbear\n$RESET"
|
||||
mkdir $build/dropbear
|
||||
cd $build/dropbear
|
||||
tar -xvf $root/downloads/DROPBEAR_2024.86.tar.gz
|
||||
check $? "Extract dropbear"
|
||||
cd dropbear-DROPBEAR_2024.86
|
||||
./configure \
|
||||
--prefix=/usr \
|
||||
--host=$CROSS_COMPILE \
|
||||
--with-zlib=$build/rootfs
|
||||
# CC=${CROSS_COMPILE}gcc ./configure --prefix=/usr --shared
|
||||
check $? "Configure dropbear"
|
||||
make $makeflags
|
||||
check $? "Build dropbear"
|
||||
make DESTDIR=$rootfspath install
|
||||
check $? "Installing to rootfs dropbear"
|
||||
rm -rv $rootfspath/usr/include $rootfspath/usr/share/man $rootfspath/usr/lib/{pkgconfig,libz.a}
|
||||
${CROSS_COMPILE}-strip $rootfspath/usr/bin/*
|
||||
mkdir -pv $build/rootfs/etc/dropbear
|
||||
# check $? "Installing to rootfs zlib"
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
#!/bin/sh
|
||||
|
||||
. ./scripts/colors.sh
|
||||
. ./scripts/funcs.sh
|
||||
. ./scripts/config.sh
|
||||
. ./scripts/busybox.sh
|
||||
|
||||
#------------------ Building initramfs.img ------------------------
|
||||
initramfs() {
|
||||
printf "$UGREEN** Building initramfs\n$RESET"
|
||||
|
||||
#--------- Creating directories and files -------------------
|
||||
rm -r $initramfspath # &>> $fulllogfile >> $(tty)
|
||||
mkdir -p $initramfspath
|
||||
cd $initramfspath
|
||||
mkdir -p $(cat $initramfsfile)
|
||||
cp $root/initramfs/init.in $initramfspath/init
|
||||
chmod 755 $initramfspath/init
|
||||
#------------------------------------------------------------
|
||||
|
||||
#------------ Building initramfs busybox and copy to initramfs directory --------------------
|
||||
busybox_initramfs
|
||||
cp $build/busybox/busybox-1.36.1/busybox $initramfspath/bin
|
||||
cd $initramfspath/bin
|
||||
for i in $(cat $root/busybox/busybox_initramfs_list); do ln -s busybox $i; done
|
||||
cd ..
|
||||
#--------------------------------------------------------------------------------------------
|
||||
|
||||
#--------------------- Creating initramfs.img image ------------
|
||||
find . | cpio -H newc -o | gzip > ../initramfs.img
|
||||
check $? "Build initramfs.img image"
|
||||
cd $root
|
||||
#---------------------------------------------------------------
|
||||
|
||||
} # initramfs
|
||||
#------------------------------------------------------------------
|
||||
+6
-6
@@ -15,12 +15,12 @@ kernel() {
|
||||
check $? "Extract Linux Kernel"
|
||||
cd linux-6.1.91
|
||||
printf "$UGREEN** Configuring Linux Kernel\n$RESET"
|
||||
make ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE mrproper # &>> $fulllogfile
|
||||
make ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE- mrproper # &>> $fulllogfile
|
||||
cp -v $root/kernel/config-6.1.91 .config # &>> $fulllogfile
|
||||
make ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE oldconfig # &>> $fulllogfile
|
||||
make ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE- oldconfig # &>> $fulllogfile
|
||||
check $? "Configure Linux Kernel"
|
||||
printf "$UGREEN** Building Linux Kernel\n$RESET"
|
||||
make ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE $makeflags # &>> $fulllogfile
|
||||
make ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE- $makeflags # &>> $fulllogfile
|
||||
check $? "Build Linux Kernel"
|
||||
ls -lh arch/$ARCH/boot/zImage
|
||||
} # kernel
|
||||
@@ -30,10 +30,10 @@ kernel() {
|
||||
kernel_modules() {
|
||||
printf "$UGREEN** Building Linux Kernel modules\n$RESET"
|
||||
cd $build/kernel/linux-6.1.91
|
||||
make ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE modules # &>> fulllogfile
|
||||
make ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE- modules # &>> fulllogfile
|
||||
check $? "Build Linux Kernel modules"
|
||||
printf "$UGREEN** Installing Linux Kernel modules into rootfs path\n$RESET"
|
||||
make ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE INSTALL_MOD_PATH=$rootfspath modules_install # &>> $fulllogfile
|
||||
make ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE- INSTALL_MOD_PATH=$rootfspath modules_install # &>> $fulllogfile
|
||||
rm -v $rootfspath/usr/lib/modules/6.1.91/{source,build}
|
||||
check $? "Install Linux Kernel modules"
|
||||
} # kernel_modules
|
||||
@@ -46,7 +46,7 @@ kernel_with_rootfs() {
|
||||
mkdir -pv $out
|
||||
fi
|
||||
cd $build/kernel/linux-6.1.91
|
||||
make ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE CONFIG_INITRAMFS_SOURCE=$rootfspath $makeflags # &>> fulllogfile
|
||||
make ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE- CONFIG_INITRAMFS_SOURCE=$rootfspath $makeflags # &>> fulllogfile
|
||||
check $? "Build Linux Kernel with rootfs"
|
||||
printf "$UGREEN** Installing Linux Kernel into images path\n$RESET"
|
||||
# make ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE INSTALL_MOD_PATH=$rootfspath modules_install # &>> $fulllogfile
|
||||
|
||||
+8
-1
@@ -7,6 +7,7 @@
|
||||
. ./scripts/uclibc.sh
|
||||
. ./scripts/kernel.sh
|
||||
. ./scripts/zlib.sh
|
||||
. ./scripts/dropbear.sh
|
||||
|
||||
#----------- Building rootfs ----------------------
|
||||
rootfs() {
|
||||
@@ -19,6 +20,7 @@ rootfs() {
|
||||
ln -sv usr/lib lib32 # &>> $fulllogfile
|
||||
ln -sv usr/bin bin # &>> $fulllogfile
|
||||
ln -sv usr/bin sbin # &>> $fulllogfile
|
||||
ln -sv var/run run
|
||||
cd usr
|
||||
ln -sv bin sbin # &>> $fulllogfile
|
||||
ln -sv lib lib32 # &>> $fulllogfile
|
||||
@@ -36,7 +38,12 @@ rootfs() {
|
||||
uclibc
|
||||
kernel
|
||||
kernel_modules
|
||||
zlib
|
||||
if [ "$ZLIB_ENABLE" = "true" ]; then
|
||||
zlib
|
||||
fi
|
||||
if [ "$DROPBEAR_ENABLE" = "true" ]; then
|
||||
dropbear
|
||||
fi
|
||||
|
||||
chmod 640 $rootfspath/etc/shadow $rootfspath/etc/inittab
|
||||
chmod 755 $rootfspath/etc/init.d/* $rootfspath/usr/share/udhcpc/default.script $rootfspath/init
|
||||
|
||||
@@ -5,10 +5,12 @@
|
||||
. ./scripts/config.sh
|
||||
. ./scripts/kernel.sh
|
||||
. ./scripts/uboot.sh
|
||||
. ./scripts/initramfs.sh
|
||||
|
||||
#--- sdroot ---
|
||||
sdroot() {
|
||||
printf "$GREEN** Generating sdroot\n$RESET"
|
||||
rm -rv $sdroot
|
||||
if [ ! -d $sdroot ]; then
|
||||
mkdir -pv $sdroot
|
||||
fi
|
||||
@@ -50,3 +52,53 @@ sdroot() {
|
||||
check $? "Generating sdcard.img"
|
||||
}
|
||||
#--------------
|
||||
|
||||
sdroot_usable() {
|
||||
printf "$GREEN** Generating sdroot usable\n$RESET"
|
||||
rm -rv $sdroot
|
||||
if [ ! -d $sdroot ]; then
|
||||
mkdir -pv $sdroot
|
||||
fi
|
||||
printf "$GREEN** Creating dirs\n$RESET"
|
||||
mkdir -pv $sdroot/boot/{dtbs,extlinux}
|
||||
check $? "Creating dirs"
|
||||
printf "$GREEN** Copy extlinux.conf\n$RESET"
|
||||
cp -v $root/extlinux/extlinux_usable.conf $sdroot/boot/extlinux/extlinux.conf
|
||||
check $? "Copy extlinux.conf"
|
||||
# kernel_with_rootfs
|
||||
cp -rv $build/rootfs/* $sdroot/
|
||||
initramfs
|
||||
cp -v $build/initramfs.img $sdroot/boot
|
||||
cp -v $build/kernel/linux-6.1.91/arch/$ARCH/boot/zImage $sdroot/boot
|
||||
uboot
|
||||
printf "$GREEN** Creating rootfs.ext4\n$RESET"
|
||||
cd $out
|
||||
rawsdrootsize=$(du -sh $sdroot)
|
||||
echo $rawsdrootsize
|
||||
sdrootsize=(${rawsdrootsize//M/ })
|
||||
echo $sdrootsize
|
||||
echo $(($sdrootsize+2))
|
||||
dd if=/dev/zero of=rootfs.ext4 bs=1M count=$(($sdrootsize+3))
|
||||
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
|
||||
sed -i "s/sdcard.img/sdcard_usable.img/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_usable.img"
|
||||
}
|
||||
+2
-2
@@ -13,9 +13,9 @@ uboot() {
|
||||
check $? "Extract uboot"
|
||||
cd u-boot-2024.10
|
||||
# cp -rv $root/uclibc/config-1.0.50 .config
|
||||
make ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE orangepi_pc_defconfig
|
||||
make ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE- orangepi_pc_defconfig
|
||||
check $? "Configure uboot"
|
||||
make ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE $makeflags # &>> $fulllogfile
|
||||
make ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE- $makeflags # &>> $fulllogfile
|
||||
check $? "Build uboot"
|
||||
cp -v u-boot-sunxi-with-spl.bin $out
|
||||
cp -v arch/arm/dts/sun8i-h3-orangepi-pc.dtb $sdroot/boot/dtbs
|
||||
|
||||
+4
-4
@@ -13,17 +13,17 @@ uclibc() {
|
||||
check $? "Extract uclibc"
|
||||
cd uClibc-ng-1.0.50
|
||||
cp -rv $root/uclibc/config-1.0.50 .config
|
||||
make ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE oldconfig
|
||||
make ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE- oldconfig
|
||||
check $? "Configure uclibc"
|
||||
make ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE $makeflags # &>> $fulllogfile
|
||||
make ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE- $makeflags # &>> $fulllogfile
|
||||
check $? "Build uclibc"
|
||||
make ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE DESTDIR=$rootfspath install # &>> $fulllogfile
|
||||
make ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE- DESTDIR=$rootfspath install # &>> $fulllogfile
|
||||
check $? "Install uclibc to rootfs"
|
||||
cd $rootfspath
|
||||
find -name \*.a -delete # &>> $fulllogfile
|
||||
find -name \*.o -delete
|
||||
rm -v $rootfspath/usr/lib/libc.so
|
||||
${CROSS_COMPILE}strip --strip-unneeded $rootfspath/usr/lib/* $rootfspath/usr/bin/* # &>> $fulllogfile
|
||||
${CROSS_COMPILE}-strip --strip-unneeded $rootfspath/usr/lib/* $rootfspath/usr/bin/* # &>> $fulllogfile
|
||||
rm -rv $rootfspath/usr/include
|
||||
cd $root
|
||||
check $? "Build and install uclibc"
|
||||
|
||||
+2
-2
@@ -11,12 +11,12 @@ zlib() {
|
||||
tar -xvf $root/downloads/zlib-1.3.1.tar.gz
|
||||
check $? "Extract zlib"
|
||||
cd zlib-1.3.1
|
||||
CC=${CROSS_COMPILE}gcc ./configure --prefix=/usr --shared
|
||||
CC=${CROSS_COMPILE}-gcc ./configure --prefix=/usr --shared
|
||||
check $? "Configure zlib"
|
||||
make $makeflags
|
||||
check $? "Build zlib"
|
||||
make DESTDIR=$rootfspath install
|
||||
rm -rv $rootfspath/usr/include $rootfspath/usr/share/man $rootfspath/usr/lib/{pkgconfig,libz.a}
|
||||
${CROSS_COMPILE}strip $rootfspath/usr/lib/libz.so.1.3.1
|
||||
${CROSS_COMPILE}-strip $rootfspath/usr/lib/libz.so.1.3.1
|
||||
check $? "Installing to rootfs zlib"
|
||||
}
|
||||
Reference in new issue
Block a user