DEVenv/Internal/unix_gcc_build.sh
2024-04-30 15:54:40 +10:00

34 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
# Run script and build GCC versions
# ./unix_gcc_build.sh 13.2.0 12.3.0 11.4.0 10.4.0 9.5.0 8.5.0 7.5.0 6.5.0
# Extract and install the build using
# tar --use-compress-program=zstd -xf gcc-mostlyportable-13.2.0.tar.zst -C ~/Dev/Linux/GCC
for gcc_version in "$@"
do
image_name=mostlyportable-gcc-image
container_name=mostlyportable-gcc
tar_file=gcc-mostlyportable-${gcc_version}.tar
archive_file=${tar_file}.zst
if [ ! -e "${archive_file}" ]; then
docker build -t ${image_name} --build-arg GCC_VERSION=${gcc_version} -f unix_gcc_dockerfile . || exit
docker container rm ${container_name} > /dev/null 2>&1
docker create --name ${container_name} ${image_name} || exit
docker cp ${container_name}:/usr/local/docker/mostlyportable-gcc/mostly-built/gcc-mostlyportable-${gcc_version} . || exit
docker container rm ${container_name} || exit
mv --force gcc-mostlyportable-${gcc_version} ${gcc_version} || exit
tar cf ${tar_file} -p ${gcc_version} || exit
zstd --rm ${tar_file} || exit
rm -rf ./${gcc_version} || exit
fi
done
# if [[ $EUID == 0 ]]; then
# chown --recursive ${USER} gcc-mostlyportable-*
# fi