# Rockpro64: uses extroot not u-boot
# 	buildroot/configs/rockpro64_defconfig  # variables set for scripts
# 	buildroot/board/pine64/rockpro64/readme.txt
# 	buildroot/board/pine64/rockpro64/post-build.sh
# 	buildroot/board/pine64/rockpro64/extlinux.conf # boot menu
# 	buildroot/support/scripts/

# The image is created by:
# 	buildroot/support/scripts/genimage.sh
# 	buildroot/board/pine64/rockpro64/genimage.cfg
# eg: genimage.sh -c board/pine64/rockpro64/genimage.cfg

# bananapi m2-zero: uses u-boot
# configs/bananapi_m2_zero_defconfig
# board/bananapi/bananapi-m2-zero/readme.txt
# board/bananapi/bananapi-m2-zero/genimage.cfg
# board/bananapi/bananapi-m2-zero/boot.cmd
 


workdir=/var/tmp/buildroot
mkdir -p $workdir
release=snapshot
release=latest

# 3 month release cycle; 02, 05, 08, 11
year=$(date +%Y)
month=$(date +%m) 
if [[ $release == lastest ]];then
	if [[ 2 >= $month < 5 ]]; then
		month=2;
	elif [[ 5 >= $month < 8 ]]; then
		month=5;
	elif [[ 8 >= $month < 11 ]]; then
		month=8;
	else
		month=11;
	fi
fi


branch=2021.02.x
branch=2021.05.x
branch=2021.08.x
branch=2021.11.x
branch=master
branch=next

git_url=https://git.buildroot.net/buildroot\
git_url=https://git.busybox.net/buildroot\
git clone $git_url --depth=1 --brnach=${branch} /var/tmp/buildroot

if [[ release == latest ]];then
	wget -c https://buildroot.org/downloads/buildroot-${year}.${month}.tar.xz
	wget -c  https://buildroot.org/downloads/buildroot-${year}.${month}.tar.xz.sign
elif [[ release == snapshot ]]; then
	wget -c https://buildroot.org/downloads/buildroot-snapshot.tar.bz2
	wget -c https://buildroot.org/downloads/buildroot-snapshot.tar.bz2.sign
else
	echo "Pass either 'latest' or 'snapshot' as arguments."
fi

#    build-essential sed make binutils gcc g++ bash patch gzip bzip2 perl tar cpio unzip rsync file bc git scp ncurses5  # menuconfig qt5  # xconfig glib2, gtk2, glade2 # gconfig libglib2.0-0 libgtk2.0-0 libglade2-0

make rockpro64_defconfig
make
