init: allow modifyiing bblayer.conf files

required for possible new layers and migration
This commit is contained in:
2022-09-06 20:11:48 +02:00
parent 60951020ac
commit b3bf207181

102
init.sh
View File

@@ -6,7 +6,8 @@ BASEPATH=`pwd`
TIMESTAMP=`date '+%Y%m%d_%H%M%S'` TIMESTAMP=`date '+%Y%m%d_%H%M%S'`
# only current version # only current version
IMAGE_VERSION=`git -C $BASEPATH rev-parse --abbrev-ref HEAD` # IMAGE_VERSION=`git -C $BASEPATH rev-parse --abbrev-ref HEAD`
IMAGE_VERSION="3.2"
FILES_DIR="$BASEPATH/files" FILES_DIR="$BASEPATH/files"
@@ -288,15 +289,6 @@ fi
if test ! -f $BASEPATH/local.conf.common.inc; then if test ! -f $BASEPATH/local.conf.common.inc; then
echo -e "\033[37;1mCONFIG:\033[0m\tcreate $BASEPATH/local.conf.common.inc as include file for layer configuration ..." echo -e "\033[37;1mCONFIG:\033[0m\tcreate $BASEPATH/local.conf.common.inc as include file for layer configuration ..."
do_exec "cp -v $BASEPATH/local.conf.common.inc.sample $BASEPATH/local.conf.common.inc" do_exec "cp -v $BASEPATH/local.conf.common.inc.sample $BASEPATH/local.conf.common.inc"
else
echo -e "\033[37;1mNOTE:\tLocal configuration not considered\033[0m"
echo -e "\t##########################################################################################"
echo -e "\t# $BASEPATH/local.conf.common.inc already exists. #"
echo -e "\t# Nothing was changed on this file for your configuration. #"
echo -e "\t# Possible changes at sample configuration will be ignored. #"
echo -e "\t# You should check local configuration and modify your configuration if required. #"
echo -e "\t# \033[37;1m$BASEPATH/local.conf.common.inc\033[0m #"
echo -e "\t##########################################################################################"
fi fi
# get matching machine type from machine build id # get matching machine type from machine build id
@@ -325,6 +317,21 @@ function get_real_machine_id() {
echo $RMI_RES echo $RMI_RES
} }
# function to create file enrties into a file, already existing entry will be ignored
function set_file_entry () {
FILE_NAME=$1
FILE_SEARCH_ENTRY=$2
FILE_NEW_ENTRY=$3
if test ! -f $FILE_NAME; then
echo $FILE_NEW_ENTRY > $FILE_NAME
else
HAS_ENTRY=`grep -c -w $FILE_SEARCH_ENTRY $FILE_NAME`
if [ "$HAS_ENTRY" == "0" ] ; then
echo $FILE_NEW_ENTRY >> $FILE_NAME
fi
fi
}
# function to create configuration for box types # function to create configuration for box types
function create_local_config () { function create_local_config () {
CLC_ARG1=$1 CLC_ARG1=$1
@@ -352,51 +359,49 @@ function create_local_config () {
# move config files into conf directory # move config files into conf directory
if test -f $BASEPATH/local.conf.common.inc; then if test -f $BASEPATH/local.conf.common.inc; then
LOCAL_CONFIG_FILE_PATH=$MACHINE_BUILD_DIR/conf/local.conf LOCAL_CONFIG_FILE_PATH=$MACHINE_BUILD_DIR/conf/local.conf
if test ! -f $LOCAL_CONFIG_FILE_PATH.$BACKUP_SUFFIX || test ! -f $LOCAL_CONFIG_FILE_PATH; then
echo -e "\tcreate configuration for $CLC_ARG1 ... " echo -e "\tcreate configuration for $CLC_ARG1 ... "
if test -f $LOCAL_CONFIG_FILE_PATH; then if test -f $LOCAL_CONFIG_FILE_PATH; then
do_exec "mv -v $LOCAL_CONFIG_FILE_PATH $LOCAL_CONFIG_FILE_PATH.$BACKUP_SUFFIX" do_exec "mv -v $LOCAL_CONFIG_FILE_PATH $LOCAL_CONFIG_FILE_PATH.$TIMESTAMP.$BACKUP_SUFFIX"
fi fi
set_file_entry $LOCAL_CONFIG_FILE_PATH "generated" "# auto generated entries by init script"
# add line 1, include for local.conf.common.inc # add line 1, include for local.conf.common.inc
echo "include $BASEPATH/local.conf.common.inc" > $LOCAL_CONFIG_FILE_PATH set_file_entry $LOCAL_CONFIG_FILE_PATH "$BASEPATH/local.conf.common.inc" "include $BASEPATH/local.conf.common.inc"
# add line 2 # add line 2, machine type
M_TYPE='MACHINE = "'`get_real_machine_type $CLC_ARG1`'"' M_TYPE='MACHINE = "'`get_real_machine_type $CLC_ARG1`'"'
echo $M_TYPE >> $LOCAL_CONFIG_FILE_PATH set_file_entry $LOCAL_CONFIG_FILE_PATH "MACHINE" "$M_TYPE"
# add line 3 # add line 3, machine build
M_ID='MACHINEBUILD = "'`get_real_machine_id $CLC_ARG1`'"' M_ID='MACHINEBUILD = "'`get_real_machine_id $CLC_ARG1`'"'
echo $M_ID >> $LOCAL_CONFIG_FILE_PATH set_file_entry $LOCAL_CONFIG_FILE_PATH "MACHINEBUILD" "$M_ID"
fi
else else
echo -e "\033[31;1mERROR:\033[0m:\ttemplate $BASEPATH/local.conf.common.inc not found..." echo -e "\033[31;1mERROR:\033[0m:\ttemplate $BASEPATH/local.conf.common.inc not found..."
exit 1 exit 1
fi fi
if test ! -f $MACHINE_BUILD_DIR/conf/bblayers.conf.$BACKUP_SUFFIX; then
echo -e "\tcreate bblayer configuration for $CLC_ARG1..." echo -e "\tcreate bblayer configuration for $CLC_ARG1..."
do_exec "cp -v $MACHINE_BUILD_DIR/conf/bblayers.conf $MACHINE_BUILD_DIR/conf/bblayers.conf.$TIMESTAMP.$BACKUP_SUFFIX" BBLAYER_CONF_FILE="$MACHINE_BUILD_DIR/conf/bblayers.conf"
# craete backup for bblayer.conf
do_exec "cp -v $BBLAYER_CONF_FILE $BBLAYER_CONF_FILE.$TIMESTAMP.$BACKUP_SUFFIX"
META_MACHINE_LAYER=meta-`get_metaname $CLC_ARG1` META_MACHINE_LAYER=meta-`get_metaname $CLC_ARG1`
echo 'BBLAYERS += " \
'$BUILD_ROOT_DIR'/'$TUXBOX_LAYER_NAME' \ # add layer entries into bblayer.conf
'$BUILD_ROOT_DIR'/'$META_MACHINE_LAYER' \ set_file_entry $BBLAYER_CONF_FILE "generated" '# auto generated entries by init script'
'$BUILD_ROOT_DIR'/'$OE_LAYER_NAME/meta-oe' \ LAYER_LIST=" $TUXBOX_LAYER_NAME $META_MACHINE_LAYER $OE_LAYER_NAME/meta-oe $OE_LAYER_NAME/meta-networking $PYTHON2_LAYER_NAME $QT5_LAYER_NAME "
'$BUILD_ROOT_DIR'/'$OE_LAYER_NAME/meta-networking' \ for LL in $LAYER_LIST ; do
"' >> $MACHINE_BUILD_DIR/conf/bblayers.conf set_file_entry $BBLAYER_CONF_FILE $LL 'BBLAYERS += " '$BUILD_ROOT_DIR'/'$LL' "'
if test -d $BUILD_ROOT_DIR/$META_MACHINE_LAYER/recipes-kodi; then done
echo 'BBLAYERS += " \
'$BUILD_ROOT_DIR'/'$PYTHON2_LAYER_NAME' \
"' >> $MACHINE_BUILD_DIR/conf/bblayers.conf
fi
if test -d $BUILD_ROOT_DIR/$META_MACHINE_LAYER/recipes-qt; then
echo 'BBLAYERS += " \
'$BUILD_ROOT_DIR'/'$QT5_LAYER_NAME' \
"' >> $MACHINE_BUILD_DIR/conf/bblayers.conf
fi
fi
fi fi
} }
# function create local dist directory to prepare for web access # function create local dist directory to prepare for web access
function create_dist_tree () { function create_dist_tree () {
@@ -427,17 +432,28 @@ else
create_local_config $MACHINE; create_local_config $MACHINE;
fi fi
echo -e "\033[37;1mNOTE:\tLocal configuration not considered\033[0m"
echo -e "\t##########################################################################################"
echo -e "\t# $BASEPATH/local.conf.common.inc already exists."
echo -e "\t# Nothing was changed on this file for your configuration."
echo -e "\t# Possible changes at sample configuration will be ignored."
echo -e "\t# You should check local configuration and modify your configuration if required."
echo -e "\t# \033[37;1m$BASEPATH/local.conf.common.inc"
echo -e "\t# local.conf, bblayer.conf\033[0m files could be modifyed, "
echo -e "\t# Please check this files if required!"
echo -e "\t##########################################################################################"
create_dist_tree; create_dist_tree;
# check and create distribution directory inside html directory for online update # check and create distribution directory inside html directory for online update
if test ! -L /var/www/html/dist; then if test ! -L /var/www/html/dist; then
echo -e "\033[37;1mNOTE:\t Online update usage.\033[0m" echo -e "\033[37;1mNOTE:\tOnline update.\033[0m"
echo -e "\t##########################################################################################" echo -e "\t##########################################################################################"
echo -e "\t# /var/www/html/dist doesn't exists. #" echo -e "\t# /var/www/html/dist doesn't exists."
echo -e "\t# If you want to use online update, please configure your webserver and use dist content #" echo -e "\t# If you want to use online update, please configure your webserver and use dist content"
echo -e "\t# Super user permissions are required to create symlink... #" echo -e "\t# Super user permissions are required to create symlink..."
echo -e "\t# An easy way is to create a symlink to dist directory: #" echo -e "\t# An easy way is to create a symlink to dist directory:"
echo -e "\t# \033[37;1msudo ln -s $BASEPATH/dist /var/www/html/dist\033[0m #" echo -e "\t# \033[37;1msudo ln -s $BASEPATH/dist /var/www/html/dist\033[0m"
echo -e "\t##########################################################################################" echo -e "\t##########################################################################################"
fi fi