support loading configuration from file

add configuration file template: config-template.conf

usage:

source env/setenv.sh config config-template.conf
make

known issue:

Variables in configuration file must be set correctly otherwise error occurs.

Signed-off-by: Nick Xie <nick@khadas.com>
This commit is contained in:
Nick Xie
2020-06-20 18:50:18 +08:00
parent b5c6854005
commit 740c33a2ed
3 changed files with 66 additions and 9 deletions

View File

@ -34,10 +34,20 @@ $ cd fenix
* Setup build environment
Setup environment manually.
```bash
$ source env/setenv.sh
```
Or you can load environment configuration from file.
```bash
$ source env/setenv.sh config config-template.conf
```
You need to edit `config-template.conf` file to correct variables.
* Build image
```bash

21
config-template.conf Normal file
View File

@ -0,0 +1,21 @@
#####################################
# Configuration File Template #
#####################################
#KHADAS_BOARD - Supported Khadas Board, check 'config/boards/*.conf'
#LINUX - Supported Linux version, check array 'SUPPORTED_LINUX' in 'config/boards/*KHADAS_BOARD*.conf'
#UBOOT - Supported U-boot version, check array 'SUPPORTED_UBOOT' in 'config/boards/*KHADAS_BOARD*.conf'
#DISTRIBUTION - Supported Distribution, check array 'DISTRIBUTION_ARRAY' in 'env/setenv.sh'
#DISTRIB_RELEASE - Supported Distribution Release, check array '*DISTRIBUTION*_RELEASE_ARRAY' in 'env/setenv.sh'
#DISTRIB_TYPE - Supported Distribution Type, check array '*DISTRIBUTION*_TYPE_ARRAY' in 'env/setenv.sh'
#DISTRIB_ARCH - Supported Distribution Architecture, check array 'DISTRIB_ARCH_ARRAY' in 'env/setenv.sh'
#INSTALL_TYPE - Supported Installation Type, check array 'INSTALL_TYPE_ARRAY' in 'env/setenv.sh'
KHADAS_BOARD=VIM1
LINUX=mainline
UBOOT=mainline
DISTRIBUTION=Ubuntu
DISTRIB_RELEASE=focal
DISTRIB_TYPE=server
DISTRIB_ARCH=arm64
INSTALL_TYPE=SD-USB

44
env/setenv.sh vendored
View File

@ -34,6 +34,8 @@ VENDOR=
CHIP=
EXPERT=
LOAD_CONFIG_FROM_FILE=
CONFIG_FILE=
###############################################################
if [ "$1" == "expert" ]; then
echo -e -n "\e[33mWarning:\e[0m You choose expert options mode, please make sure you know what you are doing. Switching to Expert mode? [N/y] "
@ -45,6 +47,15 @@ if [ "$1" == "expert" ]; then
echo -e "\e[33mWarning:\e[0m Switching to Normal mode!"
EXPERT=""
fi
elif [ "$1" == "config" ]; then
if [ ! -f "$2" ]; then
echo -e "Configuration file: \e[1;32m$2\e[0m doesn't exist!"
echo -e "\e[0;32mCtrl+C\e[0m to abort."
hangup
fi
echo -e "Loading configuration from file: \e[1;32m$2\e[0m"
LOAD_CONFIG_FROM_FILE="yes"
CONFIG_FILE="$2"
fi
## Hangup
@ -602,15 +613,30 @@ function lunch() {
echo ""
}
function load_config_from_file() {
source $CONFIG_FILE
export KHADAS_BOARD
export LINUX
export UBOOT
export DISTRIBUTION
export DISTRIB_RELEASE
export DISTRIB_TYPE
export DISTRIB_ARCH
export INSTALL_TYPE
}
#####################################################################3
export_version
choose_khadas_board
choose_uboot_version
choose_linux_version
choose_distribution
choose_distribution_release
choose_distribution_type
choose_distribution_architecture
choose_install_type
if [ -z "$LOAD_CONFIG_FROM_FILE" ]; then
choose_khadas_board
choose_uboot_version
choose_linux_version
choose_distribution
choose_distribution_release
choose_distribution_type
choose_distribution_architecture
choose_install_type
else
load_config_from_file
fi
lunch