mirror of
https://github.com/tuxbox-neutrino/buildenv.git
synced 2025-08-26 15:02:58 +02:00
fix(fetch_meta): skip checkout when branch_hash is empty
Added a condition to only execute the git checkout command if a valid branch_hash is provided. This prevents the "empty string is not a valid pathspec" error when branch_hash is empty.
This commit is contained in:
@@ -2,12 +2,13 @@
|
|||||||
|
|
||||||
## Function to replace the echo command
|
## Function to replace the echo command
|
||||||
function my_echo() {
|
function my_echo() {
|
||||||
local no_term_output="$1"
|
local no_term_output="$1"
|
||||||
# Clean up text
|
# Clean up text
|
||||||
if [ "$no_term_output" == "true" ]; then
|
if [ "$no_term_output" == "true" ]; then
|
||||||
shift
|
shift
|
||||||
fi
|
fi
|
||||||
local cleaned_output=$(echo -e "${@}" | sed -r "s/\x1B\[[0-9;]*[a-zA-Z]//g")
|
local cleaned_output
|
||||||
|
cleaned_output=$(echo -e "${@}" | sed -r "s/\x1B\[[0-9;]*[a-zA-Z]//g")
|
||||||
# Write to log
|
# Write to log
|
||||||
echo "[ $(date '+%Y-%m-%d %H:%M:%S') ] - ${cleaned_output}" >> "$LOGFILE"
|
echo "[ $(date '+%Y-%m-%d %H:%M:%S') ] - ${cleaned_output}" >> "$LOGFILE"
|
||||||
# Show on terminal
|
# Show on terminal
|
||||||
@@ -16,18 +17,16 @@ function my_echo() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# function for checking of valid machine(s)
|
## Function to check if a machine is valid
|
||||||
function is_valid_machine ()
|
# Returns 0 if valid, 1 if not.
|
||||||
{
|
function is_valid_machine() {
|
||||||
local ISM=$1
|
local machine_to_check="$1"
|
||||||
for M in $MACHINES ; do
|
for m in $MACHINES; do
|
||||||
if [ "$ISM" == "$M" ] || [ "$MACHINE" == "all" ]; then
|
if [[ "$machine_to_check" == "$m" || "$MACHINE" == "all" ]]; then
|
||||||
echo true
|
return 0 # valid
|
||||||
return 1
|
fi
|
||||||
fi
|
done
|
||||||
done
|
return 1 # not valid
|
||||||
echo false
|
|
||||||
return 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function do_exec() {
|
function do_exec() {
|
||||||
@@ -39,14 +38,7 @@ function do_exec() {
|
|||||||
|
|
||||||
my_echo true "[EXEC] $cmd"
|
my_echo true "[EXEC] $cmd"
|
||||||
|
|
||||||
# TODO: Evaluate alternatives to 'eval' for executing complex commands
|
# Execute the command
|
||||||
# Using 'eval' here allows for dynamic execution of commands that may include
|
|
||||||
# special characters, variable expansions, or other complexities that are
|
|
||||||
# difficult to handle with direct execution methods. However, 'eval' comes with
|
|
||||||
# significant security implications, especially when dealing with untrusted input.
|
|
||||||
# It executes the given string as a bash command, which can lead to code injection
|
|
||||||
# vulnerabilities if not carefully managed. This usage is a temporary solution to
|
|
||||||
# achieve desired functionality and should be revisited to explore safer alternatives.
|
|
||||||
if [[ "$show_output" == "show_output" ]]; then
|
if [[ "$show_output" == "show_output" ]]; then
|
||||||
eval $cmd 2>> "$TMP_LOGFILE"
|
eval $cmd 2>> "$TMP_LOGFILE"
|
||||||
else
|
else
|
||||||
@@ -57,7 +49,7 @@ function do_exec() {
|
|||||||
|
|
||||||
if [[ -f "$TMP_LOGFILE" ]]; then
|
if [[ -f "$TMP_LOGFILE" ]]; then
|
||||||
log_text=$(cat "$TMP_LOGFILE")
|
log_text=$(cat "$TMP_LOGFILE")
|
||||||
>> "$LOGFILE" # Clear TMP_LOGFILE after reading
|
: > "$TMP_LOGFILE" # Clear TMP_LOGFILE after reading
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $cmd_exit_status -ne 0 ]]; then
|
if [[ $cmd_exit_status -ne 0 ]]; then
|
||||||
@@ -76,26 +68,26 @@ function do_exec() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_metaname () {
|
function get_metaname() {
|
||||||
local TMP_NAME=$1
|
local TMP_NAME="$1"
|
||||||
|
|
||||||
if [ "$TMP_NAME" == "hd51" ] || [ "$TMP_NAME" == "bre2ze4k" ] || [ "$TMP_NAME" == "mutant51" ] || [ "$TMP_NAME" == "ax51" ]; then
|
if [ "$TMP_NAME" == "hd51" ] || [ "$TMP_NAME" == "bre2ze4k" ] || [ "$TMP_NAME" == "mutant51" ] || [ "$TMP_NAME" == "ax51" ]; then
|
||||||
META_NAME="gfutures"
|
META_NAME="gfutures"
|
||||||
elif [ "$TMP_NAME" == "h7" ] || [ "$TMP_NAME" == "zgemmah7" ]; then
|
elif [ "$TMP_NAME" == "h7" ] || [ "$TMP_NAME" == "zgemmah7" ]; then
|
||||||
META_NAME="airdigital"
|
META_NAME="airdigital"
|
||||||
elif [ "$TMP_NAME" == "hd60" ] || [ "$TMP_NAME" == "hd61" ] || [ "$TMP_NAME" == "ax60" ] || [ "$TMP_NAME" == "ax61" ]; then
|
elif [ "$TMP_NAME" == "hd60" ] || [ "$TMP_NAME" == "hd61" ] || [ "$TMP_NAME" == "ax60" ] || [ "$TMP_NAME" == "ax61" ]; then
|
||||||
META_NAME="hisilicon"
|
META_NAME="hisilicon"
|
||||||
elif [ "$TMP_NAME" == "osmio4k" ] || [ "$TMP_NAME" == "osmio4kplus" ]; then
|
elif [ "$TMP_NAME" == "osmio4k" ] || [ "$TMP_NAME" == "osmio4kplus" ]; then
|
||||||
META_NAME="edision"
|
META_NAME="edision"
|
||||||
elif [ "$TMP_NAME" == "e4hdultra" ]; then
|
elif [ "$TMP_NAME" == "e4hdultra" ]; then
|
||||||
META_NAME="ceryon"
|
META_NAME="ceryon"
|
||||||
else
|
else
|
||||||
META_NAME=$TMP_NAME
|
META_NAME="$TMP_NAME"
|
||||||
fi
|
fi
|
||||||
echo "$META_NAME"
|
echo "$META_NAME"
|
||||||
}
|
}
|
||||||
|
|
||||||
# clone or update required branch for required meta-<layer>
|
## Clone or update required branch for a meta-layer
|
||||||
function fetch_meta() {
|
function fetch_meta() {
|
||||||
local layer_name="$1"
|
local layer_name="$1"
|
||||||
local branch_name="$2"
|
local branch_name="$2"
|
||||||
@@ -104,287 +96,253 @@ function fetch_meta() {
|
|||||||
local target_git_path="$5"
|
local target_git_path="$5"
|
||||||
local patch_list="$6"
|
local patch_list="$6"
|
||||||
|
|
||||||
local GIT_SSH_COMMAND=""
|
|
||||||
if [[ "$GIT_SSH_KEYFILE" != "" ]]; then
|
if [[ "$GIT_SSH_KEYFILE" != "" ]]; then
|
||||||
export GIT_SSH_COMMAND="$SSH -i \"$GIT_SSH_KEYFILE\""
|
export GIT_SSH_COMMAND="$SSH -i \"$GIT_SSH_KEYFILE\""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -d "$target_git_path/.git" ]]; then
|
if [[ ! -d "$target_git_path/.git" ]]; then
|
||||||
my_echo -e "Clone branch $branch_name from $layer_git_url into $target_git_path"
|
my_echo -e "Clone branch $branch_name from $layer_git_url into $target_git_path"
|
||||||
if do_exec "git clone -b "$branch_name" "$layer_git_url" "$target_git_path""; then
|
if do_exec "git clone -b \"$branch_name\" \"$layer_git_url\" \"$target_git_path\""; then
|
||||||
do_exec "git -C "$target_git_path" checkout "$branch_hash" -b "$IMAGE_VERSION""
|
# Only perform checkout if branch_hash is not empty
|
||||||
do_exec "git -C "$target_git_path" pull -r origin "$branch_name""
|
if [ -n "$branch_hash" ]; then
|
||||||
else
|
do_exec "git -C \"$target_git_path\" checkout \"$branch_hash\" -b \"$IMAGE_VERSION\""
|
||||||
my_echo -e "\033[31;1mError cloning $layer_name from $layer_git_url\033[0m"
|
fi
|
||||||
return 1
|
do_exec "git -C \"$target_git_path\" pull -r origin \"$branch_name\""
|
||||||
fi
|
else
|
||||||
## Patching
|
my_echo -e "\033[31;1mError cloning $layer_name from $layer_git_url\033[0m"
|
||||||
if [[ -n "$patch_list" ]]; then
|
return 1
|
||||||
for patch_file in $patch_list; do
|
fi
|
||||||
# First, check if the patch can be applied cleanly
|
## Patching
|
||||||
my_echo -e "Applying patch: $patch_file"
|
if [[ -n "$patch_list" ]]; then
|
||||||
if do_exec "git -C "$target_git_path" apply --check "$FILES_DIR/$patch_file""; then
|
for patch_file in $patch_list; do
|
||||||
# Attempt to apply the patch if 'apply --check' was successful
|
my_echo -e "Applying patch: $patch_file"
|
||||||
if ! do_exec "git -C "$target_git_path" am < "$FILES_DIR/$patch_file""; then
|
if do_exec "git -C \"$target_git_path\" apply --check \"$FILES_DIR/$patch_file\""; then
|
||||||
# Error message if 'git am' fails
|
if ! do_exec "git -C \"$target_git_path\" am < \"$FILES_DIR/$patch_file\""; then
|
||||||
my_echo -e "\033[31;1mFailed to apply patch $patch_file to $layer_name\033[0m"
|
my_echo -e "\033[31;1mFailed to apply patch $patch_file to $layer_name\033[0m"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# Message about skipping if 'apply --check' fails
|
my_echo -e "\033[33;1mSkipping patch $patch_file already applied or cannot be applied cleanly.\033[0m"
|
||||||
my_echo -e "\033[33;1mSkipping patch $patch_file already applied or cannot be applied cleanly.\033[0m"
|
fi
|
||||||
fi
|
done
|
||||||
done
|
fi
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
if [[ $DO_UPDATE == "$true" ]]; then
|
if [[ $DO_UPDATE == "$true" ]]; then
|
||||||
my_echo -e "Update $target_git_path on branch $branch_name"
|
my_echo -e "Update $target_git_path on branch $branch_name"
|
||||||
if [[ $(git -C "$target_git_path" stash list) ]]; then
|
if [[ $(git -C "$target_git_path" stash list) ]]; then
|
||||||
my_echo -e "Stashing changes in $target_git_path"
|
my_echo -e "Stashing changes in $target_git_path"
|
||||||
do_exec "git -C "$target_git_path" stash push --include-untracked"
|
do_exec "git -C \"$target_git_path\" stash push --include-untracked"
|
||||||
local stash_applied=true
|
local stash_applied=true
|
||||||
fi
|
fi
|
||||||
do_exec "git -C "$target_git_path" checkout "$branch_name"" || do_exec "git -C "$target_git_path" checkout -b "$branch_name""
|
do_exec "git -C \"$target_git_path\" checkout \"$branch_name\"" || do_exec "git -C \"$target_git_path\" checkout -b \"$branch_name\""
|
||||||
do_exec "git -C "$target_git_path" pull -r origin "$branch_name""
|
do_exec "git -C \"$target_git_path\" pull -r origin \"$branch_name\""
|
||||||
if [[ "$stash_applied" == true ]]; then
|
if [[ "$stash_applied" == true ]]; then
|
||||||
if do_exec "git -C "$target_git_path" stash pop"; then
|
if do_exec "git -C \"$target_git_path\" stash pop"; then
|
||||||
my_echo -e "Stash applied successfully."
|
my_echo -e "Stash applied successfully."
|
||||||
else
|
else
|
||||||
my_echo -e "\033[33;1mNote: Stash could not be applied. Manual intervention required.\033[0m"
|
my_echo -e "\033[33;1mNote: Stash could not be applied. Manual intervention required.\033[0m"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# clone/update required branch from tuxbox bsp layers
|
## Clone/update required branch from tuxbox bsp layers
|
||||||
function is_required_machine_layer ()
|
# Returns 0 if machine is required, 1 if not.
|
||||||
{
|
function is_required_machine_layer() {
|
||||||
local HIM1=$1
|
local machine_list="$1"
|
||||||
for M in $HIM1 ; do
|
for m in $machine_list; do
|
||||||
if [ "$M" == "$MACHINE" ]; then
|
if [[ "$m" == "$MACHINE" ]]; then
|
||||||
echo true
|
return 0 # required
|
||||||
return 1
|
fi
|
||||||
fi
|
done
|
||||||
done
|
return 1 # not required
|
||||||
echo false
|
|
||||||
return 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# get matching machine type from machine build id
|
## Get matching machine type from machine build id
|
||||||
function get_real_machine_type() {
|
function get_real_machine_type() {
|
||||||
local MACHINE_TYPE=$1
|
local MACHINE_TYPE="$1"
|
||||||
if [ "$MACHINE_TYPE" == "mutant51" ] || [ "$MACHINE_TYPE" == "ax51" ] || [ "$MACHINE_TYPE" == "hd51" ]; then
|
if [ "$MACHINE_TYPE" == "mutant51" ] || [ "$MACHINE_TYPE" == "ax51" ] || [ "$MACHINE_TYPE" == "hd51" ]; then
|
||||||
RMT_RES="hd51"
|
echo "hd51"
|
||||||
elif [ "$MACHINE_TYPE" == "hd60" ] || [ "$MACHINE_TYPE" == "ax60" ]; then
|
elif [ "$MACHINE_TYPE" == "hd60" ] || [ "$MACHINE_TYPE" == "ax60" ]; then
|
||||||
RMT_RES="hd60"
|
echo "hd60"
|
||||||
elif [ "$MACHINE_TYPE" == "hd61" ] || [ "$MACHINE_TYPE" == "ax61" ]; then
|
elif [ "$MACHINE_TYPE" == "hd61" ] || [ "$MACHINE_TYPE" == "ax61" ]; then
|
||||||
RMT_RES="hd61"
|
echo "hd61"
|
||||||
elif [ "$MACHINE_TYPE" == "zgemmah7" ] || [ "$MACHINE_TYPE" == "h7" ]; then
|
elif [ "$MACHINE_TYPE" == "zgemmah7" ] || [ "$MACHINE_TYPE" == "h7" ]; then
|
||||||
RMT_RES="h7"
|
echo "h7"
|
||||||
else
|
else
|
||||||
RMT_RES=$MACHINE_TYPE
|
echo "$MACHINE_TYPE"
|
||||||
fi
|
fi
|
||||||
echo $RMT_RES
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# get matching machine build id from machine type
|
## Get matching machine build id from machine type
|
||||||
function get_real_machine_id() {
|
function get_real_machine_id() {
|
||||||
local MACHINEBUILD=$1
|
local MACHINEBUILD="$1"
|
||||||
if [ "$MACHINEBUILD" == "hd51" ]; then
|
if [ "$MACHINEBUILD" == "hd51" ]; then
|
||||||
RMI_RES="ax51"
|
echo "ax51"
|
||||||
elif [ "$MACHINEBUILD" == "hd60" ]; then
|
elif [ "$MACHINEBUILD" == "hd60" ]; then
|
||||||
RMI_RES="ax60"
|
echo "ax60"
|
||||||
elif [ "$MACHINEBUILD" == "hd61" ]; then
|
elif [ "$MACHINEBUILD" == "hd61" ]; then
|
||||||
RMI_RES="ax61"
|
echo "ax61"
|
||||||
elif [ "$MACHINEBUILD" == "h7" ]; then
|
elif [ "$MACHINEBUILD" == "h7" ]; then
|
||||||
RMI_RES="zgemmah7"
|
echo "zgemmah7"
|
||||||
else
|
else
|
||||||
RMI_RES=$MACHINEBUILD
|
echo "$MACHINEBUILD"
|
||||||
fi
|
fi
|
||||||
echo $RMI_RES
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# function to create file entries into a file, already existing entry will be ignored
|
## Function to add an entry to a file if it doesn't already exist.
|
||||||
function set_file_entry () {
|
## Returns 0 if entry was added, 1 if it already existed.
|
||||||
local FILE_NAME=$1
|
function set_file_entry() {
|
||||||
local FILE_SEARCH_ENTRY=$2
|
local FILE_NAME="$1"
|
||||||
local FILE_NEW_ENTRY=$3
|
local FILE_SEARCH_ENTRY="$2"
|
||||||
if test ! -f $FILE_NAME; then
|
local FILE_NEW_ENTRY="$3"
|
||||||
echo $FILE_NEW_ENTRY > $FILE_NAME
|
if [ ! -f "$FILE_NAME" ]; then
|
||||||
return 1
|
echo "$FILE_NEW_ENTRY" > "$FILE_NAME"
|
||||||
else
|
return 0
|
||||||
OLD_CONTENT=`cat $FILE_NAME`
|
else
|
||||||
HAS_ENTRY=`grep -c -w $FILE_SEARCH_ENTRY $FILE_NAME`
|
if grep -q -w "$FILE_SEARCH_ENTRY" "$FILE_NAME"; then
|
||||||
if [ "$HAS_ENTRY" == "0" ] ; then
|
return 1 # entry exists
|
||||||
echo $FILE_NEW_ENTRY >> $FILE_NAME
|
else
|
||||||
fi
|
echo "$FILE_NEW_ENTRY" >> "$FILE_NAME"
|
||||||
NEW_CONTENT=`cat $FILE_NAME`
|
return 0
|
||||||
if [ "$OLD_CONTENT" == "$NEW_CONTENT" ] ; then
|
fi
|
||||||
return 1
|
fi
|
||||||
fi
|
|
||||||
fi
|
|
||||||
return 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
## Function to create configuration for box types
|
||||||
|
function create_local_config() {
|
||||||
|
local machine="$1"
|
||||||
|
|
||||||
# function to create configuration for box types
|
if [ "$machine" != "all" ]; then
|
||||||
function create_local_config () {
|
MACHINE_BUILD_DIR="$BUILD_ROOT/$machine"
|
||||||
local machine=$1
|
do_exec "mkdir -p \"$BUILD_ROOT\""
|
||||||
|
|
||||||
if [ "$machine" != "all" ]; then
|
BACKUP_CONFIG_DIR="$BACKUP_PATH/$machine/conf"
|
||||||
|
do_exec "mkdir -p \"$BACKUP_CONFIG_DIR\""
|
||||||
|
|
||||||
MACHINE_BUILD_DIR=$BUILD_ROOT/$machine
|
LOCAL_CONFIG_FILE_PATH="$MACHINE_BUILD_DIR/conf/local.conf"
|
||||||
do_exec "mkdir -p $BUILD_ROOT"
|
|
||||||
|
|
||||||
BACKUP_CONFIG_DIR="$BACKUP_PATH/$machine/conf"
|
if [ -d "$BUILD_ROOT_DIR/$machine" ]; then
|
||||||
do_exec "mkdir -p $BACKUP_CONFIG_DIR"
|
if [ ! -L "$BUILD_ROOT_DIR/$machine" ]; then
|
||||||
|
my_echo -e "\033[37;1m\tcreate compatible symlinks directory for $machine environment ...\033[0m"
|
||||||
|
do_exec "mv \"$BUILD_ROOT_DIR/$machine\" \"$BUILD_ROOT\""
|
||||||
|
do_exec "ln -s \"$MACHINE_BUILD_DIR\" \"$BUILD_ROOT_DIR/$machine\""
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
LOCAL_CONFIG_FILE_PATH=$MACHINE_BUILD_DIR/conf/local.conf
|
if [ ! -d "$MACHINE_BUILD_DIR/conf" ]; then
|
||||||
|
my_echo -e "\033[37;1m\tcreating build directory for $machine environment ...\033[0m"
|
||||||
|
do_exec "cd \"$BUILD_ROOT_DIR\""
|
||||||
|
do_exec ". ./oe-init-build-env \"$MACHINE_BUILD_DIR\""
|
||||||
|
if [ -f "$LOCAL_CONFIG_FILE_PATH" ] && [ ! -f "$LOCAL_CONFIG_FILE_PATH.origin" ]; then
|
||||||
|
do_exec "mv \"$LOCAL_CONFIG_FILE_PATH\" \"$LOCAL_CONFIG_FILE_PATH.origin\""
|
||||||
|
fi
|
||||||
|
do_exec "cd \"$BASEPATH\""
|
||||||
|
echo "[Desktop Entry]" > "$BUILD_ROOT/.directory"
|
||||||
|
echo "Icon=folder-green" >> "$BUILD_ROOT/.directory"
|
||||||
|
fi
|
||||||
|
|
||||||
if test -d $BUILD_ROOT_DIR/$machine; then
|
if [ -f "$LOCAL_CONFIG_FILE_INC_PATH" ]; then
|
||||||
if test ! -L $BUILD_ROOT_DIR/$machine; then
|
if [ -f "$LOCAL_CONFIG_FILE_PATH" ]; then
|
||||||
# generate build/config symlinks for compatibility
|
HASHSTAMP=$(MD5SUM "$LOCAL_CONFIG_FILE_PATH")
|
||||||
my_echo -e "\033[37;1m\tcreate compatible symlinks directory for $machine environment ...\033[0m"
|
do_exec "cp \"$LOCAL_CONFIG_FILE_PATH\" \"$BACKUP_CONFIG_DIR/local.conf.$HASHSTAMP.$BACKUP_SUFFIX\""
|
||||||
do_exec "mv $BUILD_ROOT_DIR/$machine $BUILD_ROOT"
|
my_echo "migrate settings within $LOCAL_CONFIG_FILE_INC_PATH..."
|
||||||
do_exec "ln -s $MACHINE_BUILD_DIR $BUILD_ROOT_DIR/$machine"
|
do_exec "sed -i -e 's|http://archiv.tuxbox-neutrino.org|https://n4k.sourceforge.io|g' \"$LOCAL_CONFIG_FILE_INC_PATH\""
|
||||||
fi
|
do_exec "sed -i -e 's|https://archiv.tuxbox-neutrino.org|https://n4k.sourceforge.io|g' \"$LOCAL_CONFIG_FILE_INC_PATH\""
|
||||||
fi
|
do_exec "sed -i -e 's|http://archiv.tuxbox-neutrino.org/sources|https://n4k.sourceforge.io/sources|g' \"$LOCAL_CONFIG_FILE_INC_PATH\""
|
||||||
|
do_exec "sed -i -e 's|https://archiv.tuxbox-neutrino.org/sources|https://n4k.sourceforge.io/sources|g' \"$LOCAL_CONFIG_FILE_INC_PATH\""
|
||||||
|
do_exec "sed -i -e 's|http://sstate.tuxbox-neutrino.org|https://n4k.sourceforge.io|g' \"$LOCAL_CONFIG_FILE_INC_PATH\""
|
||||||
|
do_exec "sed -i -e 's|https://sstate.tuxbox-neutrino.org|https://n4k.sourceforge.io|g' \"$LOCAL_CONFIG_FILE_INC_PATH\""
|
||||||
|
do_exec "sed -i -e 's|archiv.tuxbox-neutrino.org|n4k.sourceforge.io|g' \"$LOCAL_CONFIG_FILE_INC_PATH\""
|
||||||
|
do_exec "sed -i -e 's|sstate.tuxbox-neutrino.org|n4k.sourceforge.io|g' \"$LOCAL_CONFIG_FILE_INC_PATH\""
|
||||||
|
|
||||||
# generate default config
|
my_echo "migrate settings within $LOCAL_CONFIG_FILE_PATH"
|
||||||
if test ! -d $MACHINE_BUILD_DIR/conf; then
|
do_exec "sed -i -e 's|http://archiv.tuxbox-neutrino.org|https://n4k.sourceforge.io|g' \"$LOCAL_CONFIG_FILE_PATH\""
|
||||||
my_echo -e "\033[37;1m\tcreating build directory for $machine environment ...\033[0m"
|
do_exec "sed -i -e 's|https://archiv.tuxbox-neutrino.org|https://n4k.sourceforge.io|g' \"$LOCAL_CONFIG_FILE_PATH\""
|
||||||
do_exec "cd $BUILD_ROOT_DIR"
|
do_exec "sed -i -e 's|http://archiv.tuxbox-neutrino.org/sources|https://n4k.sourceforge.io/sources|g' \"$LOCAL_CONFIG_FILE_PATH\""
|
||||||
do_exec ". ./oe-init-build-env $MACHINE_BUILD_DIR"
|
do_exec "sed -i -e 's|https://archiv.tuxbox-neutrino.org/sources|https://n4k.sourceforge.io/sources|g' \"$LOCAL_CONFIG_FILE_PATH\""
|
||||||
# we need a clean config file
|
do_exec "sed -i -e 's|http://sstate.tuxbox-neutrino.org|https://n4k.sourceforge.io|g' \"$LOCAL_CONFIG_FILE_PATH\""
|
||||||
if test -f $LOCAL_CONFIG_FILE_PATH & test ! -f $LOCAL_CONFIG_FILE_PATH.origin; then
|
do_exec "sed -i -e 's|https://sstate.tuxbox-neutrino.org|https://n4k.sourceforge.io|g' \"$LOCAL_CONFIG_FILE_PATH\""
|
||||||
# so we save the origin local.conf
|
do_exec "sed -i -e 's|archiv.tuxbox-neutrino.org|n4k.sourceforge.io|g' \"$LOCAL_CONFIG_FILE_PATH\""
|
||||||
do_exec "mv $LOCAL_CONFIG_FILE_PATH $LOCAL_CONFIG_FILE_PATH.origin"
|
do_exec "sed -i -e 's|sstate.tuxbox-neutrino.org|n4k.sourceforge.io|g' \"$LOCAL_CONFIG_FILE_PATH\""
|
||||||
fi
|
|
||||||
do_exec "cd $BASEPATH"
|
|
||||||
echo "[Desktop Entry]" > $BUILD_ROOT/.directory
|
|
||||||
echo "Icon=folder-green" >> $BUILD_ROOT/.directory
|
|
||||||
fi
|
|
||||||
|
|
||||||
# modify or upgrade config files inside conf directory
|
search_line="#UPDATE_SERVER_URL = \"http:\/\/@hostname@\""
|
||||||
if test -f $LOCAL_CONFIG_FILE_INC_PATH; then
|
add_line="UPDATE_SERVER_URL = \"http://$HTTP_ADDRESS\""
|
||||||
|
if ! grep -qF -- "$add_line" "$LOCAL_CONFIG_FILE_INC_PATH"; then
|
||||||
|
sed -i -e "/$search_line/a $add_line" "$LOCAL_CONFIG_FILE_INC_PATH"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
if test -f $LOCAL_CONFIG_FILE_PATH; then
|
set_file_entry "$LOCAL_CONFIG_FILE_PATH" "generated" "# auto generated entries by init script"
|
||||||
HASHSTAMP=`MD5SUM $LOCAL_CONFIG_FILE_PATH`
|
|
||||||
do_exec "cp $LOCAL_CONFIG_FILE_PATH $BACKUP_CONFIG_DIR/local.conf.$HASHSTAMP.$BACKUP_SUFFIX"
|
|
||||||
|
|
||||||
# migrate settings after server switch
|
set_file_entry "$LOCAL_CONFIG_FILE_PATH" "$BASEPATH/local.conf.common.inc" "include $BASEPATH/local.conf.common.inc"
|
||||||
my_echo "migrate settings within $LOCAL_CONFIG_FILE_INC_PATH..."
|
|
||||||
do_exec "sed -i -e 's|http://archiv.tuxbox-neutrino.org|https://n4k.sourceforge.io|' $LOCAL_CONFIG_FILE_INC_PATH"
|
|
||||||
do_exec "sed -i -e 's|https://archiv.tuxbox-neutrino.org|https://n4k.sourceforge.io|' $LOCAL_CONFIG_FILE_INC_PATH"
|
|
||||||
|
|
||||||
do_exec "sed -i -e 's|http://archiv.tuxbox-neutrino.org/sources|https://n4k.sourceforge.io/sources|' $LOCAL_CONFIG_FILE_INC_PATH"
|
M_TYPE='MACHINE = "'$(get_real_machine_type "$machine")'"'
|
||||||
do_exec "sed -i -e 's|https://archiv.tuxbox-neutrino.org/sources|https://n4k.sourceforge.io/sources|' $LOCAL_CONFIG_FILE_INC_PATH"
|
if set_file_entry "$LOCAL_CONFIG_FILE_PATH" "MACHINE" "$M_TYPE"; then
|
||||||
|
my_echo -e "\t\033[37;1m$LOCAL_CONFIG_FILE_PATH has been upgraded with entry: $M_TYPE \033[0m"
|
||||||
|
fi
|
||||||
|
|
||||||
do_exec "sed -i -e 's|http://sstate.tuxbox-neutrino.org|https://n4k.sourceforge.io|' $LOCAL_CONFIG_FILE_INC_PATH"
|
M_ID='MACHINEBUILD = "'$(get_real_machine_id "$machine")'"'
|
||||||
do_exec "sed -i -e 's|https://sstate.tuxbox-neutrino.org|https://n4k.sourceforge.io|' $LOCAL_CONFIG_FILE_INC_PATH"
|
if set_file_entry "$LOCAL_CONFIG_FILE_PATH" "MACHINEBUILD" "$M_ID"; then
|
||||||
|
my_echo -e "\t\033[37;1m$LOCAL_CONFIG_FILE_PATH has been upgraded with entry: $M_ID \033[0m"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
my_echo -e "\033[31;1mERROR:\033[0m:\ttemplate $BASEPATH/local.conf.common.inc not found..."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
do_exec "sed -i -e 's|archiv.tuxbox-neutrino.org|n4k.sourceforge.io|' $LOCAL_CONFIG_FILE_INC_PATH"
|
BBLAYER_CONF_FILE="$MACHINE_BUILD_DIR/conf/bblayers.conf"
|
||||||
do_exec "sed -i -e 's|sstate.tuxbox-neutrino.org|n4k.sourceforge.io|' $LOCAL_CONFIG_FILE_INC_PATH"
|
|
||||||
|
|
||||||
my_echo "migrate settings within $LOCAL_CONFIG_FILE_PATH"
|
if [ -f "$BBLAYER_CONF_FILE" ]; then
|
||||||
do_exec "sed -i -e 's|http://archiv.tuxbox-neutrino.org|https://n4k.sourceforge.io|' $LOCAL_CONFIG_FILE_PATH"
|
HASHSTAMP=$(MD5SUM "$BBLAYER_CONF_FILE")
|
||||||
do_exec "sed -i -e 's|https://archiv.tuxbox-neutrino.org|https://n4k.sourceforge.io|' $LOCAL_CONFIG_FILE_PATH"
|
do_exec "cp \"$BBLAYER_CONF_FILE\" \"$BACKUP_CONFIG_DIR/bblayer.conf.$HASHSTAMP.$BACKUP_SUFFIX\""
|
||||||
|
fi
|
||||||
|
|
||||||
do_exec "sed -i -e 's|http://archiv.tuxbox-neutrino.org/sources|https://n4k.sourceforge.io/sources|' $LOCAL_CONFIG_FILE_PATH"
|
META_MACHINE_LAYER="meta-$(get_metaname "$machine")"
|
||||||
do_exec "sed -i -e 's|https://archiv.tuxbox-neutrino.org/sources|https://n4k.sourceforge.io/sources|' $LOCAL_CONFIG_FILE_PATH"
|
|
||||||
|
|
||||||
do_exec "sed -i -e 's|http://sstate.tuxbox-neutrino.org|https://n4k.sourceforge.io|' $LOCAL_CONFIG_FILE_PATH"
|
set_file_entry "$BBLAYER_CONF_FILE" "generated" "# auto generated entries by init script"
|
||||||
do_exec "sed -i -e 's|https://sstate.tuxbox-neutrino.org|https://n4k.sourceforge.io|' $LOCAL_CONFIG_FILE_PATH"
|
|
||||||
|
|
||||||
do_exec "sed -i -e 's|archiv.tuxbox-neutrino.org|n4k.sourceforge.io|' $LOCAL_CONFIG_FILE_PATH"
|
if [[ -z "$PYTHON2_SRCREV" ]]; then
|
||||||
do_exec "sed -i -e 's|sstate.tuxbox-neutrino.org|n4k.sourceforge.io|' $LOCAL_CONFIG_FILE_PATH"
|
PYTHON2_LAYER_NAME=""
|
||||||
|
fi
|
||||||
|
|
||||||
search_line="#UPDATE_SERVER_URL = \"http:\/\/@hostname@\""
|
LAYER_LIST="$TUXBOX_LAYER_NAME $META_MACHINE_LAYER $OE_LAYER_NAME/meta-oe $OE_LAYER_NAME/meta-networking $PYTHON2_LAYER_NAME $QT5_LAYER_NAME"
|
||||||
add_line="UPDATE_SERVER_URL = \"http://$HTTP_ADDRESS\""
|
for LL in $LAYER_LIST; do
|
||||||
if ! grep -qF -- "$add_line" "$LOCAL_CONFIG_FILE_INC_PATH"; then
|
if set_file_entry "$BBLAYER_CONF_FILE" "$LL" "BBLAYERS += \"${BUILD_ROOT_DIR}/${LL}\""; then
|
||||||
# Wenn nicht, füge die neue Zeile nach der spezifischen Zeile ein
|
my_echo -e "\t\033[37;1m$BBLAYER_CONF_FILE has been upgraded with entry: $LL... \033[0m"
|
||||||
sed -i -e "/$search_line/a $add_line" "$LOCAL_CONFIG_FILE_INC_PATH"
|
fi
|
||||||
fi
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# add init note
|
|
||||||
set_file_entry $LOCAL_CONFIG_FILE_PATH "generated" "# auto generated entries by init script"
|
|
||||||
|
|
||||||
# add line 1, include for local.conf.common.inc
|
|
||||||
set_file_entry $LOCAL_CONFIG_FILE_PATH "$BASEPATH/local.conf.common.inc" "include $BASEPATH/local.conf.common.inc"
|
|
||||||
|
|
||||||
# add line 2, machine type
|
|
||||||
M_TYPE='MACHINE = "'`get_real_machine_type $machine`'"'
|
|
||||||
if set_file_entry $LOCAL_CONFIG_FILE_PATH "MACHINE" "$M_TYPE" == 1; then
|
|
||||||
my_echo -e "\t\033[37;1m$LOCAL_CONFIG_FILE_PATH has been upgraded with entry: $M_TYPE \033[0m"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# add line 3, machine build
|
|
||||||
M_ID='MACHINEBUILD = "'`get_real_machine_id $machine`'"'
|
|
||||||
if set_file_entry $LOCAL_CONFIG_FILE_PATH "MACHINEBUILD" "$M_ID" == 1; then
|
|
||||||
my_echo -e "\t\033[37;1m$LOCAL_CONFIG_FILE_PATH has been upgraded with entry: $M_ID \033[0m"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
my_echo -e "\033[31;1mERROR:\033[0m:\ttemplate $BASEPATH/local.conf.common.inc not found..."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
BBLAYER_CONF_FILE="$MACHINE_BUILD_DIR/conf/bblayers.conf"
|
|
||||||
|
|
||||||
# craete backup for bblayer.conf
|
|
||||||
if test -f $BBLAYER_CONF_FILE; then
|
|
||||||
HASHSTAMP=`MD5SUM $BBLAYER_CONF_FILE`
|
|
||||||
do_exec "cp $BBLAYER_CONF_FILE $BACKUP_CONFIG_DIR/bblayer.conf.$HASHSTAMP.$BACKUP_SUFFIX"
|
|
||||||
fi
|
|
||||||
|
|
||||||
META_MACHINE_LAYER=meta-`get_metaname $machine`
|
|
||||||
|
|
||||||
# add layer entries into bblayer.conf
|
|
||||||
set_file_entry $BBLAYER_CONF_FILE "generated" '# auto generated entries by init script'
|
|
||||||
if [[ -z "$PYTHON2_SRCREV" ]]; then
|
|
||||||
PYTHON2_LAYER_NAME=""
|
|
||||||
fi
|
|
||||||
LAYER_LIST=" $TUXBOX_LAYER_NAME $META_MACHINE_LAYER $OE_LAYER_NAME/meta-oe $OE_LAYER_NAME/meta-networking $PYTHON2_LAYER_NAME $QT5_LAYER_NAME "
|
|
||||||
for LL in $LAYER_LIST ; do
|
|
||||||
if set_file_entry $BBLAYER_CONF_FILE $LL 'BBLAYERS += " '$BUILD_ROOT_DIR'/'$LL' "' == 1;then
|
|
||||||
my_echo -e "\t\033[37;1m$BBLAYER_CONF_FILE has been upgraded with entry: $LL... \033[0m"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# function create local dist directory to prepare for web access
|
## Function to create local dist directory to prepare for web access
|
||||||
function create_dist_tree () {
|
function create_dist_tree() {
|
||||||
|
DIST_BASEDIR="$DIST_DIR/$IMAGE_VERSION"
|
||||||
|
if [ ! -d "$DIST_BASEDIR" ]; then
|
||||||
|
my_echo -e "\033[37;1mcreate dist directory:\033[0m $DIST_BASEDIR"
|
||||||
|
do_exec "mkdir -p \"$DIST_BASEDIR\""
|
||||||
|
fi
|
||||||
|
|
||||||
# create dist dir
|
DIST_LIST=$(ls "$BUILD_ROOT")
|
||||||
DIST_BASEDIR="$DIST_DIR/$IMAGE_VERSION"
|
for DL in $DIST_LIST; do
|
||||||
if test ! -d "$DIST_BASEDIR"; then
|
DEPLOY_DIR="$BUILD_ROOT/$DL/tmp/deploy"
|
||||||
my_echo -e "\033[37;1mcreate dist directory:\033[0m $DIST_BASEDIR"
|
do_exec "ln -sf \"$DEPLOY_DIR\" \"$DIST_BASEDIR/$DL\""
|
||||||
do_exec "mkdir -p $DIST_BASEDIR"
|
if [ -L "$DIST_BASEDIR/$DL/deploy" ]; then
|
||||||
fi
|
do_exec "unlink \"$DIST_BASEDIR/$DL/deploy\""
|
||||||
|
fi
|
||||||
# create link sources
|
done
|
||||||
DIST_LIST=`ls $BUILD_ROOT`
|
|
||||||
for DL in $DIST_LIST ; do
|
|
||||||
DEPLOY_DIR="$BUILD_ROOT/$DL/tmp/deploy"
|
|
||||||
do_exec "ln -sf $DEPLOY_DIR $DIST_BASEDIR/$DL"
|
|
||||||
if test -L "$DIST_BASEDIR/$DL/deploy"; then
|
|
||||||
do_exec "unlink $DIST_BASEDIR/$DL/deploy"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function MD5SUM () {
|
function MD5SUM() {
|
||||||
local MD5SUM_FILE=$1
|
local MD5SUM_FILE="$1"
|
||||||
MD5STAMP=`md5sum $MD5SUM_FILE |cut -f 1 -d " "`
|
md5sum "$MD5SUM_FILE" | cut -f 1 -d " "
|
||||||
echo $MD5STAMP
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function for selecting for items included a custom entry
|
## Function for selecting items with a custom entry
|
||||||
function do_select() {
|
function do_select() {
|
||||||
local items="$1"
|
local items="$1"
|
||||||
SELECTION=""
|
SELECTION=""
|
||||||
@@ -427,59 +385,42 @@ function do_select() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Remove the last space
|
|
||||||
SELECTION=$(echo "$SELECTION" | sed 's/ $//')
|
SELECTION=$(echo "$SELECTION" | sed 's/ $//')
|
||||||
|
|
||||||
my_echo "Selected entries: $SELECTION"
|
my_echo "Selected entries: $SELECTION"
|
||||||
# Return the selected machines as a string
|
|
||||||
#"$SELECTION" has global scope
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
## Reset the build. Folders are renamed for safety.
|
||||||
# Reset the build. Nothing is deleted, but rather renamed for safety.
|
|
||||||
# Users can then decide when they want to clean up permanently.
|
|
||||||
function do_reset() {
|
function do_reset() {
|
||||||
# Make selection and save in a variable
|
|
||||||
do_select "$MACHINES"
|
do_select "$MACHINES"
|
||||||
local selected_machines=$SELECTION
|
local selected_machines="$SELECTION"
|
||||||
|
|
||||||
# Check if a selection was made
|
|
||||||
if [ -z "$selected_machines" ]; then
|
if [ -z "$selected_machines" ]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Set the start directory from where the search should begin
|
local start_directory="$BUILD_ROOT_DIR"
|
||||||
local start_directory="$BUILD_ROOT_DIR" # Adjust to base directory
|
local rename_success=0
|
||||||
local rename_success=0 # Tracks if a rename was performed
|
|
||||||
|
|
||||||
# Process the selected machines
|
|
||||||
IFS=' ' read -r -a machines_array <<< "$selected_machines"
|
IFS=' ' read -r -a machines_array <<< "$selected_machines"
|
||||||
for machine in "${machines_array[@]}"; do
|
for machine in "${machines_array[@]}"; do
|
||||||
my_echo "Reset is being carried out for: $machine"
|
my_echo "Reset is being carried out for: $machine"
|
||||||
|
|
||||||
# Save results from find in an array
|
|
||||||
readarray -t found_dirs < <(find "$start_directory" -type f -name "saved_tmpdir")
|
readarray -t found_dirs < <(find "$start_directory" -type f -name "saved_tmpdir")
|
||||||
|
|
||||||
# Check if the array contains elements
|
|
||||||
for dir in "${found_dirs[@]}"; do
|
for dir in "${found_dirs[@]}"; do
|
||||||
# Read the path from the file
|
|
||||||
tmp_dir_path=$(cat "$dir")
|
tmp_dir_path=$(cat "$dir")
|
||||||
# Check if the path exists and matches the machine name
|
|
||||||
if [[ -d "$tmp_dir_path" && "$tmp_dir_path" == *"/$machine/tmp"* ]]; then
|
if [[ -d "$tmp_dir_path" && "$tmp_dir_path" == *"/$machine/tmp"* ]]; then
|
||||||
local timestamp=$(date '+%Y%m%d_%H%M%S')
|
local timestamp
|
||||||
do_exec "mv "$tmp_dir_path" "${tmp_dir_path%/*}/tmp_${timestamp}""
|
timestamp=$(date '+%Y%m%d_%H%M%S')
|
||||||
|
do_exec "mv \"$tmp_dir_path\" \"${tmp_dir_path%/*}/tmp_${timestamp}\""
|
||||||
my_echo "Folder $tmp_dir_path was renamed to ${tmp_dir_path%/*}/tmp_${timestamp}."
|
my_echo "Folder $tmp_dir_path was renamed to ${tmp_dir_path%/*}/tmp_${timestamp}."
|
||||||
rename_success=1
|
rename_success=1
|
||||||
break # Exit the loop after the first successful rename
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
# Check if reset was performed
|
|
||||||
if [ "$rename_success" -eq 0 ]; then
|
if [ "$rename_success" -eq 0 ]; then
|
||||||
my_echo "\033[33mNo reset could be performed.\033[0m"
|
my_echo "\033[33mNo reset could be performed.\033[0m"
|
||||||
else
|
else
|
||||||
my_echo "Reset succeeded."
|
my_echo "Reset succeeded."
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user