wxyz/profiles/base/build.sh

98 lines
3.6 KiB
Bash
Raw Normal View History

2022-11-30 16:59:05 +00:00
#!/bin/bash
# wxyz main profile build script
2022-12-01 14:58:56 +00:00
# Copyright (C) 2022 The wxyz Team & contributors
2022-11-30 16:59:05 +00:00
#
# This file is part of wxyz GNU/Linux.
#
# wxyz GNU/Linux is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option)
# any later version.
#
# wxyz GNU/Linux is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# wxyz GNU/Linux. If not, see <https://www.gnu.org/licenses/>.
version="0.1"
#success_message="OK! ;-)"
success_message="\e[34m[ \e[32mOK\e[34m ]\e[0m"
error_message="\e[34m[ \e[31m!!\e[34m ]\e[0m"
die() {
printf "\n\e[31m-------------------------------------------------------------------------------\e[0m\n\n"
printf "die(): %b\n" "$1"
printf "Please contact the profile/build script maintainer.\n"
printf "\n\e[31m-------------------------------------------------------------------------------\e[0m\n\n"
exit 1;
}
#TODO: Add required packages, such as Linux
package_names=( "binutils" "busybox" "e2fsprogs" "eudev" "linux" "glibc")
package_versions=( "2.39" "1.33.2" "1.46.5" "3.2.11" "6.0.10" "2.36")
2022-11-30 16:59:05 +00:00
package_sources=(\
"https://ftp.gnu.org/gnu/binutils/binutils-2.39.tar.xz" \
"https://www.busybox.net/downloads/busybox-1.33.2.tar.bz2" \
"https://mirrors.edge.kernel.org/pub/linux/kernel/people/tytso/e2fsprogs/v1.46.5/e2fsprogs-1.46.5.tar.xz" \
"https://github.com/eudev-project/eudev/releases/download/v3.2.11/eudev-3.2.11.tar.gz" \
"https://mirrors.edge.kernel.org/pub/linux/kernel/v6.x/linux-6.0.10.tar.gz" \
"https://ftp.gnu.org/gnu/glibc/glibc-2.36.tar.gz" \
2022-11-30 16:59:05 +00:00
)
printf "wxyz main profile build script v%s\n\n" "$version"
printf "Checking if package_names, package_versions, and package_sources are the same length... "
if [ ${#package_names[@]} == ${#package_versions[@]} ] && [ ${#package_versions[@]} == ${#package_sources[@]} ]; then
printf "%b\n" "$success_message"
else
printf "%b\n" "$error_message"
die "package_* does not match"
fi
printf "\nThese packages will be installed to the profile by this script:\n"
for (( i=0; i<${#package_names[@]}; i++ )); do
printf "%s " "${package_names[$i]}"
printf "v%s -" "${package_versions[$i]}"
printf " Source: %s \n" "${package_sources[$i]}"
done
printf "\n"
printf "Creating tmp directory... "
if [[ -d tmp ]]; then
printf "Already exists. %b\n" "$success_message"
else
if eval mkdir tmp; then
printf "%b\n" "$success_message"
else
printf "%b\n" "$error_message"
die "cannot create tmp directory; is the disk read only?"
fi
fi
for (( i=0; i<${#package_names[@]}; i++ )); do
printf "Downloading %s " "${package_names[$i]}"
printf "v%s... " "${package_versions[$i]}"
# "-C -" will prevent curl from downloading files that have already been downloaded
if eval curl -C - -s --output-dir "tmp" -LO "${package_sources[$i]}"; then
2022-11-30 16:59:05 +00:00
printf "%b\n" "$success_message"
else
printf "%b\n" "$error_message"
die "downloading package failed"
fi
2022-12-02 14:04:56 +00:00
printf "Extracting %s " "${package_names[$i]}"
printf "v%s... " "${package_versions[$i]}"
# shellcheck disable=SC2001 disable=SC2086
tarball_location="$(echo ${package_sources[$i]} | sed 's@.*/@@')"
if eval tar -C tmp -xf "tmp/$tarball_location"; then
printf "%b\n" "$success_message"
else
printf "%b\n" "$error_message"
die "extracting package failed"
fi
2022-11-30 16:59:05 +00:00
done
printf "\n"
# TODO: Build packages and install them onto the filesystem