From 0ea96d011c4ae1f8f85ef78c9adba0490403fe38 Mon Sep 17 00:00:00 2001 From: TolaMironcenko Date: Fri, 23 Aug 2024 17:29:26 +0700 Subject: [PATCH] update build_image.sh script added rootfs_archive and unified busybox building --- build_image.sh => scripts/build_image.sh | 100 +++++++++++---------- scripts/busybox.sh | 59 ++++++++++++ colors.sh => scripts/colors.sh | 0 funcs.sh => scripts/funcs.sh | 2 +- install_deps.sh => scripts/install_deps.sh | 0 5 files changed, 112 insertions(+), 49 deletions(-) rename build_image.sh => scripts/build_image.sh (83%) create mode 100644 scripts/busybox.sh rename colors.sh => scripts/colors.sh (100%) rename funcs.sh => scripts/funcs.sh (93%) rename install_deps.sh => scripts/install_deps.sh (100%) diff --git a/build_image.sh b/scripts/build_image.sh similarity index 83% rename from build_image.sh rename to scripts/build_image.sh index c9008a2..16823f1 100755 --- a/build_image.sh +++ b/scripts/build_image.sh @@ -17,10 +17,10 @@ version=0.0.1 # script version # TolaMironcenko is licensed under MIT #--- import rolors --- -. ./colors.sh +. ./scripts/colors.sh #--------------------- #--- import funcs ---- -. ./funcs.sh +. ./scripts/funcs.sh #--------------------- #------------ config ------------------ @@ -41,6 +41,10 @@ fulllogfile=$root/.log/fulllog.log # file for full build logs makeflags=-j16 # makeflags #-------------------------------------- +#----- import busybox build funcs --- +. ./scripts/busybox.sh +#------------------------------------ + #-------- check root ------------------ if [ $(id -u) -ne 0 ]; then printf "$URED** You are not root\n$RESET" @@ -132,54 +136,54 @@ glibc() { #----------------------------------------------------------- # #------------------ 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 CROSS_COMPILE=x86_64-buildroot-linux-uclibc- oldconfig &> $fulllogfile - check $? "Configure busybox all logs in .log" - printf "$UGREEN** Building busybox\n$RESET" - make CROSS_COMPILE=x86_64-buildroot-linux-uclibc- $makeflags &> $fulllogfile - check $? "Build busybox all logs in .log" -} -# #------------------------------------------------------------------ +# 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 CROSS_COMPILE=x86_64-buildroot-linux-uclibc- oldconfig &> $fulllogfile +# check $? "Configure busybox all logs in .log" +# printf "$UGREEN** Building busybox\n$RESET" +# make CROSS_COMPILE=x86_64-buildroot-linux-uclibc- $makeflags &> $fulllogfile +# check $? "Build busybox all logs in .log" +# } +# # #------------------------------------------------------------------ -# #----------- Building busybox for rootfs ---------- -busybox_rootfs() { - printf "$UGREEN** Building busybox for rootfs\n$RESET" - rm -rv $build/busybox &>> $fulllogfile - mkdir -v $build/busybox &>> $fulllogfile - cd $build/busybox - tar -xvjf $root/downloads/busybox-1.36.1.tar.bz2 &>> $fulllogfile - cd busybox-1.36.1 - cp -v $root/busybox/busybox-rootfs-config .config &>> $fulllogfile - printf "$UGREEN** Configuring busybox\n$RESET" - make oldconfig &>> $fulllogfile - check $? "Configure busybox all logs in .log" - printf "$UGREEN** Building busybox\n$RESET" - make $makeflags &>> $fulllogfile - check $? "Build busybox all logs in .log" -} -#-------------------------------------------------- +# # #----------- Building busybox for rootfs ---------- +# busybox_rootfs() { +# printf "$UGREEN** Building busybox for rootfs\n$RESET" +# rm -rv $build/busybox &>> $fulllogfile +# mkdir -v $build/busybox &>> $fulllogfile +# cd $build/busybox +# tar -xvjf $root/downloads/busybox-1.36.1.tar.bz2 &>> $fulllogfile +# cd busybox-1.36.1 +# cp -v $root/busybox/busybox-rootfs-config .config &>> $fulllogfile +# printf "$UGREEN** Configuring busybox\n$RESET" +# make oldconfig &>> $fulllogfile +# check $? "Configure busybox all logs in .log" +# printf "$UGREEN** Building busybox\n$RESET" +# make $makeflags &>> $fulllogfile +# check $? "Build busybox all logs in .log" +# } +# #-------------------------------------------------- -#------------------ Building busybox ------------------------------ -busybox() { - case "$1" in - initramfs) - busybox_initramfs - ;; - rootfs) - busybox_rootfs - ;; - esac -} +# #------------------ Building busybox ------------------------------ +# busybox() { +# case "$1" in +# initramfs) +# busybox_initramfs +# ;; +# rootfs) +# busybox_rootfs +# ;; +# esac +# } #------------------------------------------------------------------ #------------------ Building initramfs.img ------------------------ diff --git a/scripts/busybox.sh b/scripts/busybox.sh new file mode 100644 index 0000000..64113e4 --- /dev/null +++ b/scripts/busybox.sh @@ -0,0 +1,59 @@ +#!/bin/sh + +#--- import rolors --- +. ./scripts/colors.sh +#--------------------- +#--- import funcs ---- +. ./scripts/funcs.sh +#--------------------- + +#------------------ 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 CROSS_COMPILE=x86_64-buildroot-linux-uclibc- oldconfig &>> $fulllogfile + check $? "Configure busybox all logs in .log" + printf "$UGREEN** Building busybox\n$RESET" + make CROSS_COMPILE=x86_64-buildroot-linux-uclibc- $makeflags &>> $fulllogfile + check $? "Build busybox all logs in .log" +} +#------------------------------------------------------------------ + +#----------- Building busybox for rootfs ---------- +busybox_rootfs() { + printf "$UGREEN** Building busybox for rootfs\n$RESET" + rm -rv $build/busybox &>> $fulllogfile + mkdir -v $build/busybox &>> $fulllogfile + cd $build/busybox + tar -xvjf $root/downloads/busybox-1.36.1.tar.bz2 &>> $fulllogfile + cd busybox-1.36.1 + cp -v $root/busybox/busybox-rootfs-config .config &>> $fulllogfile + printf "$UGREEN** Configuring busybox\n$RESET" + make oldconfig &>> $fulllogfile + check $? "Configure busybox all logs in .log" + printf "$UGREEN** Building busybox\n$RESET" + make $makeflags &>> $fulllogfile + check $? "Build busybox all logs in .log" +} +#-------------------------------------------------- + +#------------------ Building busybox ------------------------------ +busybox() { + case "$1" in + initramfs) + busybox_initramfs + ;; + rootfs) + busybox_rootfs + ;; + esac +} +#------------------------------------------------------------------ diff --git a/colors.sh b/scripts/colors.sh similarity index 100% rename from colors.sh rename to scripts/colors.sh diff --git a/funcs.sh b/scripts/funcs.sh similarity index 93% rename from funcs.sh rename to scripts/funcs.sh index 1832a75..30890a7 100644 --- a/funcs.sh +++ b/scripts/funcs.sh @@ -1,7 +1,7 @@ #!/bin/sh #--- Import colors --- -. ./colors.sh +. ./scripts/colors.sh #--------------------- #------- Check errors func ----------------- diff --git a/install_deps.sh b/scripts/install_deps.sh similarity index 100% rename from install_deps.sh rename to scripts/install_deps.sh