some enchantments for build scripts (#1364)

* downloader aria2 replace curl

aria2 is a fast downloader and it can do much more than curl
 - skip download when target file exists
 - restart an interrupted download session
 - multithreading

* remove duplicate download item

* change btrfs compression to zstd and no force compression

* mkfs.btrfs options '--data single --metadata single --label btrfs'

disable dup(duplication) on microsd card

* [fstab] change mountopts[btrfs] compression method to zstd

lzo is no fater than zstd because the low 4k write performance on my
Samsung EVO+ 32GB microsd card.
meanwhile the best io size is above 32k based on benchmark

* replace dd with truncate, create a sparse disk image

* create btrfs subvolume by default

subvolume @ as rootfs, mount at /
subvolume @home as /home, mount at /home

* fix extraargs in armbianEnv.txt

* remove tmpfs mount on /tmp

A zram block device will mount on /tmp by
/usr/lib/armbian/armbian-zram-config.

And instead, mount /media as tmpfs.

* [rsync] add '--inplace' option, optimize for btrfs

* [general.sh] change ntp server to pool.ntp.org

* [general] new option to setup btrfs compression method

for support old and boring 3.x kernels

* [general] set btrfs space cache based kervel version

kernel version above 4.5 select 'v2' as default

* [btrfs] BTRFS_COMPRESSION accept compression ratio

BTRFS_COMPRESSION=zlib
BTRFS_COMPRESSION=zstd:5
BTRFS_COMPRESSION=zstd:12 are acceptable

* [btrfs] set btrfs compression to lzo when input is illegal

* [general] new option DOWNLOAD_MIRROR to select download mirror

current DOWNLOAD_MIRROR=china is used
the mirror is provided by tsinghua university

* [general] replace USE_MAINLINE_GOOGLE_MIRROR with MAINLINE_MIRROR

MAINLINE_MIRROR=google, use google provided mirror
MAINLINE_MIRROR=tuna, use tsinghua provided mirror
leave it empty, use official git.kernel.org

* fix btrfs default compression

* display $fscreateopt

* display_alert BTRFS_COMPRESSION

* try fix BTRFS_COMPRESSION variable not working

* debug fetch_from_repo

* configuration.sh debug BTRFS_COMPRESION

* update logic

* debug checking btrfs compression

* fix variable check,fix local variable usage

* [general] replace USE_MAINLINE_GOOGLE_MIRROR with MAINLINE_MIRROR

MAINLINE_MIRROR=google, use google provided mirror
MAINLINE_MIRROR=tuna, use tsinghua provided mirror
leave it empty, use official git.kernel.org

* [general] new option DOWNLOAD_MIRROR to select download mirror

current DOWNLOAD_MIRROR=china is used
the mirror is provided by tsinghua university

* Revert "try fix BTRFS_COMPRESSION variable not working"

This reverts commit 9814cfb054.

* Revert "debug fetch_from_repo"

This reverts commit ba571f0d89.

* add default compression method for mountopts

* remove useless var

* remove debug

* remove debug

* [general] set btrfs space cache based on kernel version

kernel version above 4.5 select 'v2' as default,
below 4.5 select 'v1' as default

* [general] reintroduce USE_MAINLINE_GOOGLE_MIRROR

* [general] case replaces 'if xx ;elif xxx;fi'

* [general] fix always downloading linux-firmware.git

clone to new dir 'linux-firmware-git' instead the old '$plugin_dir/lib/firmware'
,and then copy files as hardlinks.

* [general] create soft link instead of moving directory

* [btrfs] change rootfs subvolume name to @$RELEASE

now, the rootfs subvolume looks like @stretch,@bionic
it is possible to use different distribution in the same btrfs
partition.
This commit is contained in:
mei
2019-05-15 00:37:00 +08:00
committed by Igor Pečovnik
parent cde51f556a
commit 7f1c5b19cd
4 changed files with 90 additions and 25 deletions

View File

@@ -545,6 +545,8 @@ prepare_host()
curl patchutils python liblz4-tool libpython2.7-dev linux-base swig libpython-dev aptly acl \
locales ncurses-base pixz dialog systemd-container udev lib32stdc++6 libc6-i386 lib32ncurses5 lib32tinfo5 \
bison libbison-dev flex libfl-dev cryptsetup gpgv1 gnupg1 cpio"
which aria2c >/dev/null || hostdeps="$hostdeps aria2"
local codename=$(lsb_release -sc)
display_alert "Build host OS release" "${codename:-(unknown)}" "info"
@@ -624,7 +626,7 @@ prepare_host()
# sync clock
if [[ $SYNC_CLOCK != no ]]; then
display_alert "Syncing clock" "host" "info"
ntpdate -s ${NTP_SERVER:- time.ijs.si}
ntpdate -s ${NTP_SERVER:- pool.ntp.org}
fi
if [[ $(dpkg-query -W -f='${db:Status-Abbrev}\n' 'zlib1g:i386' 2>/dev/null) != *ii* ]]; then
@@ -658,6 +660,9 @@ prepare_host()
# Use backup server by default to balance the load
ARMBIANSERVER=dl.armbian.com
if [[ $DOWNLOAD_MIRROR == 'china' ]]; then
ARMBIANSERVER='mirrors.tuna.tsinghua.edu.cn/armbian-releases'
fi
local toolchains=(
"https://${ARMBIANSERVER}/_toolchains/gcc-linaro-aarch64-none-elf-4.8-2013.11_linux.tar.xz"
@@ -671,7 +676,6 @@ prepare_host()
"https://${ARMBIANSERVER}/_toolchains/gcc-linaro-5.5.0-2017.10-x86_64_arm-linux-gnueabihf.tar.xz"
"https://${ARMBIANSERVER}/_toolchains/gcc-linaro-6.4.1-2017.11-x86_64_arm-linux-gnueabihf.tar.xz"
"https://${ARMBIANSERVER}/_toolchains/gcc-linaro-6.4.1-2017.11-x86_64_aarch64-linux-gnu.tar.xz"
"https://${ARMBIANSERVER}/_toolchains/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu.tar.xz"
"https://${ARMBIANSERVER}/_toolchains/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf.tar.xz"
"https://${ARMBIANSERVER}/_toolchains/gcc-linaro-7.4.1-2019.02-x86_64_arm-eabi.tar.xz"
"https://${ARMBIANSERVER}/_toolchains/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabi.tar.xz"
@@ -718,6 +722,16 @@ prepare_host()
fi
}
# downloader() <url> <outputfilename>
downloader()
{
[ $# -ne 2 ] && exit_with_error "downloader args count" "$#"
args='--file-allocation=falloc --auto-file-renaming=false --continue=true --allow-overwrite=false'
display_alert "downloader args 1" "$1" "info"
display_alert "downloader args 2" "$2" "info"
aria2c $args "$1" -o "$2"
}
# download_toolchain <url>
#
download_toolchain()
@@ -733,8 +747,8 @@ download_toolchain()
cd $SRC/cache/toolchains/
display_alert "Downloading" "$dirname"
curl -Lf --progress-bar $url -o $filename
curl -Lf --progress-bar ${url}.asc -o ${filename}.asc
downloader $url $filename
downloader ${url}.asc ${filename}.asc
local verified=false
@@ -783,7 +797,7 @@ download_etcher_cli()
cd $SRC/cache/utility/
display_alert "Downloading" "$dirname"
curl -Lf --progress-bar $url -o $filename
downloader $url $filename
local verified=false
local b=$(sha256sum $filename)