2022-03-15 14:06:02 +08:00
#!/bin/bash
2022-03-28 13:36:51 +08:00
2022-04-05 19:45:39 +08:00
#
2022-04-13 20:51:56 +08:00
# envsetup.sh for buildroot YuzukiSBC
2022-04-05 19:45:39 +08:00
# Copyright (C) 2022 YuzukiTsuru <gloomyghost@gloomyghost.com>. All rights reserved.
#
2022-04-13 20:51:56 +08:00
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
2022-04-05 19:45:39 +08:00
2022-04-13 22:10:21 +08:00
# Logo
2022-04-13 22:35:16 +08:00
LOCAL_COMMIT_ID = $( git rev-parse --short HEAD)
2022-04-13 22:10:21 +08:00
echo " _____ _____ ___ __ __ _ _ _____ _____ _____ "
echo "| __ | __ |_ | | | |_ _ ___ _ _| |_|_| __| __ | |"
echo "| __ -| -| _| |_ _| | |- _| | | '_| |__ | __ -| --|"
echo "|_____|__|__|___| |_| |___|___|___|_,_|_|_____|_____|_____|"
2022-04-13 22:35:16 +08:00
echo -e " Commit: $LOCAL_COMMIT_ID \n "
2022-04-13 22:10:21 +08:00
2022-04-05 15:45:14 +08:00
# WSL SUpport
2022-04-05 19:50:04 +08:00
if [ $( uname -r | grep -c "WSL1" ) -eq 1 ] ;
2022-03-28 13:36:51 +08:00
then
2022-04-05 15:45:14 +08:00
# Not support WSL 1
2022-04-05 19:45:39 +08:00
echo "#### Buildroot-YuzukiSBC Not Support WSL 1 ####"
2022-04-05 15:45:14 +08:00
exit 1
2022-04-05 19:50:04 +08:00
elif [ $( uname -r | grep -c "WSL2" ) -eq 1 ] ;
2022-03-28 13:36:51 +08:00
then
echo "Buildroot-YuzukiSBC Now running on WSL2, setting PATH..."
export PATH = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib"
fi
2022-06-21 22:34:39 +08:00
UpdateInfo( ) {
echo "************************************************************"
echo "* Update done! You may need to run sync_update after lunch.*"
echo "************************************************************"
}
2022-04-13 20:51:56 +08:00
FetchUpdate( ) {
git fetch origin master:tmp
if [ $( git diff tmp | grep -c "-" ) -gt 1 ] ;
then
read -r -p "Update found, Update to Remote? [y/N] " input
case $input in
[ yY] [ eE] [ sS] | [ yY] )
echo "Now try to merge upstream..."
git merge tmp
2022-06-21 22:34:39 +08:00
UpdateInfo
2022-04-13 20:51:56 +08:00
; ;
[ nN] [ oO] | [ nN] )
echo "Cancel update..."
; ;
*)
echo "Invalid input..."
; ;
esac
2022-04-13 21:04:14 +08:00
else
echo "Local code all up to date! commit id:"
git rev-parse HEAD
2022-04-13 20:51:56 +08:00
fi
# delete the commit
git branch -d tmp
}
# Fetch latest commit.
read -r -p "Check for repository updates? [y/N] " input
case $input in
[ yY] [ eE] [ sS] | [ yY] )
echo "Fetching remote repo data..."
FetchUpdate
; ;
[ nN] [ oO] | [ nN] )
echo "Cancel update check..."
; ;
*)
echo "Cancel update check..."
; ;
esac
2022-04-05 19:45:39 +08:00
# configure C compiler
export compiler = $( which gcc)
# get version code
MAJOR = $( echo __GNUC__ | $compiler -E -xc - | tail -n 1)
MINOR = $( echo __GNUC_MINOR__ | $compiler -E -xc - | tail -n 1)
PATCHLEVEL = $( echo __GNUC_PATCHLEVEL__ | $compiler -E -xc - | tail -n 1)
2022-04-05 19:50:04 +08:00
if [ $MAJOR -lt 7 ] ;
2022-04-05 19:45:39 +08:00
then
echo "#### Buildroot-YuzukiSBC Not Support GCC Version less than 7 ####"
2022-04-05 19:50:04 +08:00
elif [ $MAJOR -gt 12 ] ;
then
echo "#### Buildroot-YuzukiSBC Not Support GCC Version more than 12 ####"
else
echo " Your Host GCC Version is $MAJOR . $MINOR . $PATCHLEVEL "
2022-04-05 19:45:39 +08:00
fi
# Add alias
2022-03-28 13:36:51 +08:00
# Alias
2022-04-12 22:51:31 +08:00
alias lunch = "cd buildroot && echo -e \"You're building on Linux\n\nLunch menu... \npick a combo by 'make xxx_defconfig':\nScaning combo...\" && make list-defconfigs"
2022-07-09 09:53:19 +08:00
alias lunchs = "cd buildroot"
2022-04-01 00:21:31 +08:00
alias rebuild_kernel = "touch ./output/images/a.dtb && rm ./output/images/*.dtb && make linux-rebuild -j8 && make"
2022-03-21 14:31:59 +08:00
alias rebuild_uboot = "make uboot-rebuild -j8 && make"
alias wsl_path = "export PATH=\"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib\""
2022-03-21 15:46:00 +08:00
alias sync_kernel = "rm -rf output/build/linux* && rm -rf output/build/.linux* && make"
2022-04-13 22:04:31 +08:00
alias sync_uboot = "rm -rf output/build/uboot* && make"
2022-06-21 22:34:39 +08:00
alias sync_update = "rm -rf output/build/linux* && rm -rf output/build/.linux* && rm -rf output/build/uboot* && rm -rf dl/uboot* && rm -rf dl/linux*"
2022-03-21 14:31:59 +08:00
2022-04-05 15:45:51 +08:00
alias mm = "make"
alias m = "make"
alias mkernel = "rebuild_kernel"
2022-04-07 11:00:42 +08:00
alias rkernel = "rebuild_kernel"
2022-04-05 15:45:51 +08:00
2022-04-24 11:26:28 +08:00
alias sm = "make savedefconfig"
2022-04-23 16:07:27 +08:00
alias skernel = "make linux-update-defconfig"
alias suboot = "make uboot-update-defconfig"
2022-04-23 15:19:28 +08:00
2022-05-07 16:05:44 +08:00
alias muboot = "rebuild_uboot"
alias ruboot = "rebuild_uboot"
2022-04-07 15:35:46 +08:00
2022-04-13 22:35:16 +08:00
LOCAL_COMMIT_ID = $( git rev-parse --short HEAD)
echo -e "\n"
echo "******************************************"
echo "* Setup env done! Please run lunch next. *"
echo "******************************************"