@ -1,11 +1,11 @@
#!/bin/bash
#simplebuild_plugin tcupdate (s3.TUP) 0.8.0
#simplebuild_plugin tcupdate (s3.TUP) 0.8.1
tcupdate(){
clear && _check_bin;
pversion="0.8.0 ";
pversion="0.8.1 ";
pname="s3.TUP";
pdesc="Plugin $pname v$pversion";
configname="$configdir/plugin_update_toolchain.config";
@ -28,8 +28,11 @@ tcupdate(){
#create config
if [ ! -f "$configname" ];then
echo -e "$g_l""CLEANUP -> Creating new config file. Please wait...""$y_l""$re_";
_create_config;
echo -e "config file='$configname'\nYou can extend them to fit your needs.\n";
if ! _create_config;then
exit;
else
echo -e "config file='$configname'\nYou can change/extend them to fit your needs.\n";
fi;
_paktc_timer 5;
fi;
@ -57,7 +60,7 @@ tcupdate(){
fi;
[ $COUNT -eq 0 ] && MENU_OPTIONS+=("" "no toolchains found" "no toolchains found") && counter;
fi;
out=$("$gui" "$st_" "$bt_" "$title_ - \Z4 $pdesc\Zn" "--colors" "--item-help" "--help-tags" "--default-item" "$3" "--ok-label" "Update" "--cancel-label" "Create" "--help-button" "--help-label" "Exit" "--extra-button" "--extra-label" "Copy" "--title" "-[ Toolchain Menu ]-" \
out=$("$gui" "$st_" "$bt_" "$title_ - \Z0 $pdesc\Zn" "--colors" "--item-help" "--help-tags" "--default-item" "$3" "--ok-label" "Update" "--cancel-label" "Create" "--help-button" "--help-label" "Exit" "--extra-button" "--extra-label" "Copy" "--title" "-[ Toolchain Menu ]-" \
--menu "\nSelect one of the installed tool chains that you want to update:\n " \
"${COUNT+10}" 0 0 "${MENU_OPTIONS[@]}");
ret="$?"
@ -142,7 +145,7 @@ tcupdate(){
done;
[ $COUNT -eq 0 ] && MENU_OPTIONS+=("" "no libraries found" "no libraries found") && counter;
opts=$("$gui" "--item-help" "--help-tags" "$st_" "$bt_" "$title_ - \Z4 $pdesc\Zn" "--colors" "--default-item" "$3" "--ok-label" "Start" "--help-button" "--help-label" "Info" "--cancel-label" "$([ "$tc_menu" == "1" ] && echo "Back" || echo "Exit")" "--title" "-[ Library Update Menu - \Z2$tc\Zn ]-" "$cl_"\
opts=$("$gui" "--item-help" "--help-tags" "$st_" "$bt_" "$title_ - \Z0 $pdesc\Zn" "--colors" "--default-item" "$3" "--ok-label" "Start" "--help-button" "--help-label" "Info" "--cancel-label" "$([ "$tc_menu" == "1" ] && echo "Back" || echo "Exit")" "--title" "-[ Library Update Menu - \Z2$tc\Zn ]-" "$cl_"\
"\nSelect all libraries to update in toolchain's SYSROOT folder:\n$prefixdir\n\n library version NEW CURRENT" \
"${COUNT+12}" 70 0 "${MENU_OPTIONS[@]}");
@ -159,7 +162,7 @@ tcupdate(){
bcd=$(cat "$configname" | grep ""$libkey"_tasks");
txt=$(echo -e "Toolchain: $tcdir/$tc\nCompiler: $compilername\nSysroot: $sr\nPrefix: $prefixdir\n$sp\n\nLibrary configuration:\n$txt\n\nBuild command:\n$(_replace_tokens "$(_tidy_tasks "$bcd" "$libkey")")");
tempfile=$(mktemp) && echo -e "$txt" > "$tempfile";
"$gui" "$st_" "$nc_" "$bt_" "$title_ - \Z4 $pdesc\Zn" "--colors" "--textbox" "$tempfile" 30 80;
"$gui" "$st_" "$nc_" "$bt_" "$title_ - \Z0 $pdesc\Zn" "--colors" "--textbox" "$tempfile" 30 80;
rm "$tempfile" 2>/dev/null;
tcupdate $tc $tc_menu $libkey;
fi;
@ -223,7 +226,7 @@ _create_tc(){
fi;
[ $COUNT -eq 0 ] && MENU_OPTIONS+=("" "no templates found" "no templates found") && counter;
opts=$("$gui" "$st_" "$bt_" "$title_ - \Z4 $pdesc\Zn" "--colors" "--item-help" "--help-tags" "--default-item" "$3" "--ok-label" "Start" "--cancel-label" "Setup" "--help-button" "--help-label" "$([ $tc_menu ] && echo "Back" || echo "Exit")" "--title" "-[ Cross Toolchain Template Menu ]-" "$cl_"\
opts=$("$gui" "$st_" "$bt_" "$title_ - \Z0 $pdesc\Zn" "--colors" "--item-help" "--help-tags" "--default-item" "$3" "--ok-label" "Start" "--cancel-label" "Setup" "--help-button" "--help-label" "$([ $tc_menu ] && echo "Back" || echo "Exit")" "--title" "-[ Cross Toolchain Template Menu ]-" "$cl_"\
"\nSelect on of the templates to create the cross toolchain you want:\n\n\Z1NOTE: If you create a cross toolchain from a template with a red colored description, an existing one with the same name will be replaced without asking!\Zn" \
"${COUNT+11}" 0 0 "${MENU_OPTIONS[@]}");
ret="$?"
@ -264,7 +267,7 @@ _create_tc(){
target=$(sed -n -e '/target = / s/.*\= *//p' "$ctsrcdir/build.log");
#compress toolchain
_compress "$dldir/Toolchain-$tpl.tar.xz" "$tcdir/$tpl" | "$gui" "$st_" "$bt_" "$title_ - \Z4 $pdesc\Zn" "--colors" "--title" " -[ Compress cross toolchain $tpl... ]- " "$pb_" "$_lines" "$_cols";
_compress "$dldir/Toolchain-$tpl.tar.xz" "$tcdir/$tpl" | "$gui" "$st_" "$bt_" "$title_ - \Z0 $pdesc\Zn" "--colors" "--title" " -[ Compress cross toolchain $tpl... ]- " "$pb_" "$_lines" "$_cols";
#create toolchain.cfg
desc=$(sed -n -e '/#toolchain template/ s/.*\: *//p' "$cttpldir/$tpl");
@ -278,7 +281,7 @@ _create_tc(){
fi;
done;
else
echo -e "$r_l""CHECK -> crosstool-NG is not setup correctly. Please run 'Setup' from menu!\n""$re_";
echo -e "$r_l""\n CHECK -> crosstool-NG is not setup correctly. Please run 'Setup' from menu!\n""$re_";
_paktc_timer 10;
fi;
_create_tc;;
@ -310,7 +313,7 @@ _create_tc(){
cd "$ctsrcdir";
cmd="${CTNG_SETUP_tasks[@]}";
sudo -u "$CTNG_USER" -H -- sh -c "$(_replace_tokens "$cmd")" 2>&1;
) | tee "$logfile" | "$gui" "$st_" "$bt_" "$title_ - \Z4 $pdesc\Zn" "--colors" "--title" " -[ Setup crosstool-NG... ]- " "$pb_" "$_lines" "$_cols";
) | tee "$logfile" | "$gui" "$st_" "$bt_" "$title_ - \Z0 $pdesc\Zn" "--colors" "--title" " -[ Setup crosstool-NG... ]- " "$pb_" "$_lines" "$_cols";
_paktc_timer 10;
_create_tc;;
2) #Exit
@ -332,7 +335,7 @@ _copy(){
#create toolchain.cfg
source "$tccfgdir/$1" && target="${_compiler%?}" && desc="$_description";
_create_toolchaincfg "$tcdir/$1" "$newtc" "$target" "$desc" "$xzfile";
) | "$gui" "$st_" "$bt_" "$title_ - \Z4 $pdesc\Zn" "--colors" "--title" " -[ Copy $1 to $newtc ... ]- " "$pb_" "$_lines" "$_cols";
) | "$gui" "$st_" "$bt_" "$title_ - \Z0 $pdesc\Zn" "--colors" "--title" " -[ Copy $1 to $newtc ... ]- " "$pb_" "$_lines" "$_cols";
[ -f "$newtccfgfile" ] && echo "$newtc";
};
_build(){
@ -352,7 +355,7 @@ _build(){
sleep 2;
cd "$libsrcdir";
( eval "${tasks[@]}" ) 2>&1 | tee -a "$lf"
) | "$gui" "$st_" "$bt_" "$title_ - \Z4 $pdesc\Zn" "--colors" "--title" " -[ Build $desc... ]- " "$pb_" "$_lines" "$_cols";sleep 2;
) | "$gui" "$st_" "$bt_" "$title_ - \Z0 $pdesc\Zn" "--colors" "--title" " -[ Build $desc... ]- " "$pb_" "$_lines" "$_cols";sleep 2;
#build error message
error_on_build=$(grep -cw1 Error "$lf");
@ -367,7 +370,7 @@ _dl(){
[ -d "$dldir/#tmp" ] && rm --recursive --force "$dldir/#tmp"
mkdir --parents "$dldir/#tmp";
cd "$dldir/#tmp";
wget --content-disposition "$1" 2>&1 | stdbuf -o0 awk '/[.] +[0-9][0-9]?[0-9]?%/ { print substr($0,63,3) }' | "$gui" "$st_" "$bt_" "$title_ - \Z4 $pdesc\Zn" "--colors" "--title" " -[ download $2 ]- " --gauge " $txt_loading $txt_wait" 6 74;
wget --content-disposition "$1" 2>&1 | stdbuf -o0 awk '/[.] +[0-9][0-9]?[0-9]?%/ { print substr($0,63,3) }' | "$gui" "$st_" "$bt_" "$title_ - \Z0 $pdesc\Zn" "--colors" "--title" " -[ download $2 ]- " --gauge " $txt_loading $txt_wait" 6 74;
if [ $? -eq 0 ];then
fname="$(ls -t | head -n1)"; md5file="$fname.md5";
md5sum "$fname" > "$md5file";
@ -418,7 +421,7 @@ _extract(){
cd "$edir";
BEFORE=(.*/ */);
command "${c[@]}" "$i" |"$gui" "$st_" "$bt_" "$title_ - \Z4 $pdesc\Zn" "--colors" "--title" " -[ $txt_extracting $i ]- " "$pb_" 20 74;
command "${c[@]}" "$i" |"$gui" "$st_" "$bt_" "$title_ - \Z0 $pdesc\Zn" "--colors" "--title" " -[ $txt_extracting $i ]- " "$pb_" 20 74;
((e = e || $?));
AFTER=(.*/ */);
@ -477,6 +480,7 @@ else
fi;
done
fi;
echo -e "\033[2K\r"; #remove characters from console
};
_check_bin(){
@ -492,7 +496,7 @@ _check_bin(){
failed=1;
fi;
done;
[ "$failed" == 1 ] && echo -e "$r_l""\nCHECK -> You need to install the following tools to use this plugin properly:\n"$y_l"apt install$packages\n""$re_" && _paktc_timer 10 && echo -e "\n TODO" ;
[ "$failed" == 1 ] && echo -e "$r_l""\nCHECK -> You need to install the following tools to use this plugin properly:\n"$y_l"apt install$packages\n""$re_" && _paktc_timer 10;
return $failed;
};
_check_config(){
@ -502,7 +506,7 @@ _check_config(){
if [ $nok -eq 1 ]; then
clear;
echo -e "$r_l""CHECK -> Your config file seems to be outdated. Please restart s3 as follows to recreate an updated config file:\n"$y_l"./s3 tcupdate -r\n""$re_";
echo -e "$r_l""\n CHECK -> Your config file seems to be outdated. Please restart s3 as follows to recreate an updated config file:\n"$y_l"./s3 tcupdate -r\n""$re_";
_paktc_timer 10;
return $nok;
fi;
@ -527,6 +531,12 @@ _check_github_api_limits(){
fi;
};
_create_config(){
#check existing jq
if [ ! $(which jq) ];then
echo -e "$r_l""\nCHECK -> Without the tool 'jq' automatic config file generation is not possible. Please install it first:\n"$y_l"apt install jq\n""$re_" && _paktc_timer 10;
return 1;
fi;
lib_comments=( "#Enable/Disable (1|0)" \
"#Displayname" \
"#Versionnumber" \
@ -573,7 +583,7 @@ _create_config(){
ctng_build_tasks_comment="#build command";
ctng_setup_tasks=( "(\"git clone --progress \"\$CTNG_REPO_URL\" \"@CTNGSOURCE@\";\")" "(\"./bootstrap;\")" "(\"./configure --enable-local;\")" "(\"make;\")" "(\"touch \"@CTNGSOURCE@/.config\";\")" );
ctng_setup_tasks_comment="#setup command";
echo '#CROSS toolchain build settings' >"$configname";
echo 'CTNG_USER="ctng"; #low privileged user that run ct-ng (will be created automatically, if not exists)' >>"$configname";
echo 'CTNG_REPO_URL="https://github.com/crosstool-ng/crosstool-ng"; #Repository to load ct-ng from' >>"$configname";
@ -622,6 +632,8 @@ _create_config(){
done;
((i++))
done;
return 0;
};
_create_toolchaincfg(){
cd "$1/bin";