diff --git a/lib/build-all-ng.sh b/lib/build-all-ng.sh index 4947212fd2..a3447c6fbd 100644 --- a/lib/build-all-ng.sh +++ b/lib/build-all-ng.sh @@ -325,11 +325,9 @@ function build_all() fi if [[ "$store_hash" != idential ]]; then - ((n+=1)) - if [[ $1 != "dryrun" ]] && [[ $n -ge $START ]]; then - - while : + ((n+=1)) + while : do if [[ $(find /run/armbian/*.pid 2>/dev/null | wc -l) -le ${MULTITHREAD} || ${MULTITHREAD} -eq 0 ]]; then break @@ -340,13 +338,17 @@ function build_all() display_alert "Building ${n}." if [[ "$KERNEL_ONLY" == "no" && "${MULTITHREAD}" -gt 0 ]]; then build_main & + sleep $((RANDOM % 5)) + elif [[ "${MULTITHREAD}" -gt 0 ]]; then + build_main & + sleep $((RANDOM % 5)) else build_main fi # create BSP for all boards elif [[ "${BSP_BUILD}" == yes ]]; then - + ((n+=1)) for BOARD in "${unique_boards[@]}" do # shellcheck source=/dev/null @@ -368,8 +370,11 @@ function build_all() display_alert "BSP for ${BOARD} ${BRANCH} ${RELEASE}." if [[ "$IGNORE_HASH" == yes && "$KERNEL_ONLY" != "yes" && "${MULTITHREAD}" -gt 0 ]]; then build_main & - sleep 0.5 - else + sleep 0.02 + elif [[ "${MULTITHREAD}" -gt 0 ]]; then + build_main & + sleep $((RANDOM % 5)) + else build_main fi # unset non board related stuff @@ -380,6 +385,7 @@ function build_all() display_alert "Done building all BSP images" exit else + ((n+=1)) # In dryrun it only prints out what will be build printf "%s\t%-32s\t%-8s\t%-14s\t%-6s\t%-6s\t%-6s\n" "${n}." \ "$BOARD (${BOARDFAMILY})" "${BRANCH}" "${RELEASE}" "${BUILD_DESKTOP}" "${BUILD_MINIMAL}" @@ -454,4 +460,4 @@ fi buildall_end=$(date +%s) buildall_runtime=$(((buildall_end - buildall_start) / 60)) display_alert "Runtime in total" "${buildall_runtime} min" "info" -echo "${n}" > "${SRC}"/.tmp/n +export n=${n} diff --git a/lib/compilation.sh b/lib/compilation.sh index ffefbdbe66..2c3534c1d8 100644 --- a/lib/compilation.sh +++ b/lib/compilation.sh @@ -80,6 +80,8 @@ compile_atf() [[ $(type -t atf_custom_postprocess) == function ]] && atf_custom_postprocess atftempdir=$(mktemp -d) + chmod 700 ${atftempdir} + trap "rm -rf \"${atftempdir}\" ; exit 0" 0 1 2 3 15 # copy files to temp directory for f in $target_files; do @@ -144,6 +146,8 @@ compile_uboot() # create directory structure for the .deb package uboottempdir=$(mktemp -d) + chmod 700 ${uboottempdir} + trap "rm -rf \"${uboottempdir}\" ; exit 0" 0 1 2 3 15 local uboot_name=${CHOSEN_UBOOT}_${REVISION}_${ARCH} rm -rf $uboottempdir/$uboot_name mkdir -p $uboottempdir/$uboot_name/usr/lib/{u-boot,$uboot_name} $uboottempdir/$uboot_name/DEBIAN @@ -275,7 +279,7 @@ compile_uboot() [[ ! -f $uboottempdir/${uboot_name}.deb ]] && exit_with_error "Building u-boot package failed" - rsync -rq "$uboottempdir/${uboot_name}.deb" "${DEB_STORAGE}/" + rsync --remove-source-files -rq "$uboottempdir/${uboot_name}.deb" "${DEB_STORAGE}/" } compile_kernel() @@ -319,8 +323,8 @@ compile_kernel() # create linux-source package - with already patched sources local sources_pkg_dir=$(mktemp -d)/${CHOSEN_KSRC}_${REVISION}_all - rm -rf "${sources_pkg_dir}" - mkdir -p "${sources_pkg_dir}"/usr/src/ "${sources_pkg_dir}/usr/share/doc/linux-source-${version}-${LINUXFAMILY}" "${sources_pkg_dir}"/DEBIAN + trap "rm -rf \"${sources_pkg_dir}\" ; exit 0" 0 1 2 3 15 + mkdir -p "${sources_pkg_dir}"/usr/src/ "${sources_pkg_dir}"/usr/share/doc/linux-source-${version}-${LINUXFAMILY} "${sources_pkg_dir}"/DEBIAN if [[ $BUILD_KSRC != no ]]; then display_alert "Compressing sources for the linux-source package" @@ -329,7 +333,6 @@ compile_kernel() | pixz -4 > "${sources_pkg_dir}/usr/src/linux-source-${version}-${LINUXFAMILY}.tar.xz" cp COPYING "${sources_pkg_dir}/usr/share/doc/linux-source-${version}-${LINUXFAMILY}/LICENSE" fi - display_alert "Compiling $BRANCH kernel" "$version" "info" local toolchain @@ -447,14 +450,15 @@ compile_kernel() if [[ $BUILD_KSRC != no ]]; then fakeroot dpkg-deb -z0 -b "${sources_pkg_dir}" "${sources_pkg_dir}.deb" - rsync -rq "${sources_pkg_dir}.deb" "${DEB_STORAGE}/" + rsync --remove-source-files -rq "${sources_pkg_dir}.deb" "${DEB_STORAGE}/" fi rm -rf "${sources_pkg_dir}" cd .. || exit # remove firmare image packages here - easier than patching ~40 packaging scripts at once rm -f linux-firmware-image-*.deb - rsync -rq ./*.deb "${DEB_STORAGE}/" || exit_with_error "Failed moving kernel DEBs" + + rsync --remove-source-files -rq ./*.deb "${DEB_STORAGE}/" || exit_with_error "Failed moving kernel DEBs" # store git hash to the file echo "${hash}" > "${SRC}/cache/hash"$([[ ${BETA} == yes ]] && echo "-beta")"/linux-image-${BRANCH}-${LINUXFAMILY}.githash" @@ -479,7 +483,8 @@ compile_firmware() fi firmwaretempdir=$(mktemp -d) - + chmod 700 ${firmwaretempdir} + trap "rm -rf \"${firmwaretempdir}\" ; exit 0" 0 1 2 3 15 local plugin_dir="armbian-firmware${FULL}" mkdir -p "${firmwaretempdir}/${plugin_dir}/lib/firmware" @@ -529,7 +534,8 @@ compile_armbian-config() { local tmpdir=$(mktemp -d)/armbian-config_${REVISION}_all - + chmod 700 ${tmpdir} + trap "rm -rf \"${tmpdir}\" ; exit 0" 0 1 2 3 15 display_alert "Building deb" "armbian-config" "info" fetch_from_repo "https://github.com/armbian/config" "armbian-config" "branch:master" diff --git a/lib/debootstrap.sh b/lib/debootstrap.sh index f2ec880829..1cf9c34c7b 100644 --- a/lib/debootstrap.sh +++ b/lib/debootstrap.sh @@ -418,8 +418,12 @@ prepare_partitions() # stage: create blank image display_alert "Creating blank image for rootfs" "$sdsize MiB" "info" - # truncate --size=${sdsize}M ${SDCARD}.raw # sometimes results in fs corruption, revert to previous know to work solution - dd if=/dev/zero bs=1M status=none count=$sdsize | pv -p -b -r -s $(( $sdsize * 1024 * 1024 )) -N "[ .... ] dd" | dd status=none of=${SDCARD}.raw + if [[ $FAST_CREATE_IMAGE == yes ]]; then + truncate --size=${sdsize}M ${SDCARD}.raw # sometimes results in fs corruption, revert to previous know to work solution + sync + else + dd if=/dev/zero bs=1M status=none count=$sdsize | pv -p -b -r -s $(( $sdsize * 1024 * 1024 )) -N "[ .... ] dd" | dd status=none of=${SDCARD}.raw + fi # stage: calculate boot partition size local bootstart=$(($OFFSET * 2048)) diff --git a/lib/makeboarddeb.sh b/lib/makeboarddeb.sh index ac1c13a742..3f3874c446 100644 --- a/lib/makeboarddeb.sh +++ b/lib/makeboarddeb.sh @@ -17,8 +17,10 @@ create_board_package() { display_alert "Creating board support package" "$BOARD $BRANCH" "info" - local destination=$(mktemp -d)/${RELEASE}/${CHOSEN_ROOTFS}_${REVISION}_${ARCH} - rm -rf "${destination}" + bsptempdir=$(mktemp -d) + chmod 700 ${bsptempdir} + trap "rm -rf \"${bsptempdir}\" ; exit 0" 0 1 2 3 15 + local destination=${bsptempdir}/${RELEASE}/${CHOSEN_ROOTFS}_${REVISION}_${ARCH} mkdir -p "${destination}"/DEBIAN cd $destination @@ -307,7 +309,7 @@ fi display_alert "Building package" "$CHOSEN_ROOTFS" "info" fakeroot dpkg-deb -b "${destination}" "${destination}.deb" >> "${DEST}"/debug/install.log 2>&1 mkdir -p "${DEB_STORAGE}/${RELEASE}/" - rsync -rq --delete-after "${destination}.deb" "${DEB_STORAGE}/${RELEASE}/" + rsync --remove-source-files -rq "${destination}.deb" "${DEB_STORAGE}/${RELEASE}/" # cleanup - rm -rf "${destination}" + rm -rf ${bsptempdir} }