Skip to content

Commit

Permalink
feat(toolchain): add musl-obstack
Browse files Browse the repository at this point in the history
  • Loading branch information
adonis0147 committed Oct 29, 2024
1 parent 168525a commit 2421928
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 5 deletions.
2 changes: 1 addition & 1 deletion toolchain/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM ubuntu:22.04 AS builder

RUN apt update && apt upgrade --yes
RUN DEBIAN_FRONTEND=noninteractive apt install --yes \
build-essential texinfo bison git curl rsync gawk python-is-python3 help2man file
build-essential texinfo bison git curl rsync gawk python-is-python3 help2man file autoconf libtool pkg-config

RUN mkdir -p /opt/patchelf
RUN curl -L "https://github.com/NixOS/patchelf/releases/download/0.16.1/patchelf-0.16.1-$(uname -m).tar.gz" \
Expand Down
39 changes: 36 additions & 3 deletions toolchain/generate_toolchan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ declare -r GCC_MD5SUM='2268420ba02dc01821960e274711bde0'
declare -r LIBXCRYPT_PACKAGE_URL='https://github.com/besser82/libxcrypt/releases/download/v4.4.36/libxcrypt-4.4.36.tar.xz'
declare -r LIBXCRYPT_MD5SUM='b84cd4104e08c975063ec6c4d0372446'

declare -r MUSL_OBSTACK_URL='https://github.com/void-linux/musl-obstack/archive/refs/tags/v1.2.3.tar.gz'
declare -r MUSL_OBSTACK_MD5SUM='e4f1d16aa3187e8d071f656dd2b10a9e'
declare -r MUSL_OBSTACK_NAME='musl-obstack-1.2.3.tar.gz'

function log() {
local level="${1}"
local message="${2}"
Expand Down Expand Up @@ -79,8 +83,7 @@ function show_environment() {
function download() {
local url="${1}"
local md5sum="${2}"
local package
package="$(basename "${url}")"
local package="${3:-$(basename "${url}")}"

mkdir -p "${PACKAGES_PATH}"
pushd "${PACKAGES_PATH}" >/dev/null
Expand All @@ -100,15 +103,25 @@ function download_all() {
download "${GLIBC_PACKAGE_URL}" "${GLIBC_MD5SUM}"
download "${GCC_PACKAGE_URL}" "${GCC_MD5SUM}"
download "${LIBXCRYPT_PACKAGE_URL}" "${LIBXCRYPT_MD5SUM}"
download "${MUSL_OBSTACK_URL}" "${MUSL_OBSTACK_MD5SUM}" "${MUSL_OBSTACK_NAME}"
}

function extract_packages() {
local package

pushd "${PACKAGES_PATH}" >/dev/null

find . -mindepth 1 -maxdepth 1 -type d -exec rm -rf {} \;

for package in *.tar.xz; do
log_info "Extract ${package} ..."
tar -xf "${package}"
tar -Jxf "${package}"
log_info "Extract ${package} successfully!"
done

for package in *.tar.gz; do
log_info "Extract ${package} ..."
tar -zxf "${package}"
log_info "Extract ${package} successfully!"
done

Expand Down Expand Up @@ -353,6 +366,25 @@ function build_libxcrypt() {
popd >/dev/null
}

function build_musl_obstack() {
local package="${MUSL_OBSTACK_NAME}"
pushd "${package/.tar.gz/}" >/dev/null

./bootstrap.sh

rm -rf build
mkdir build
cd build

../configure --prefix="${PREFIX}"
make -j "$(nproc)"
make install

rm -rf "${PREFIX}/lib/pkgconfig"

popd >/dev/null
}

function build_final_toolchain() {
build_binutils_final
build_gcc_final
Expand All @@ -365,6 +397,7 @@ function build_all() {
build_cross_toolchain
build_final_toolchain
build_libxcrypt
build_musl_obstack

popd >/dev/null
}
Expand Down
2 changes: 1 addition & 1 deletion toolchain/setup_toolchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function extract_toolchain() {
local temp_dir

if [[ -d "${prefix}/${TOOLCHAIN_DIRNAME}" ]]; then
log_error "Failed to extract the toolchain due to the target directory already exists."
log_error "Failed to extract the toolchain due to the target directory \033[34;1m${prefix}/${TOOLCHAIN_DIRNAME}\033[0m already exists."
fi

if ! temp_dir="$(mktemp -d)"; then
Expand Down

0 comments on commit 2421928

Please sign in to comment.