diff --git a/.dockerignore b/.dockerignore new file mode 120000 index 0000000..3e4e48b --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +.gitignore \ No newline at end of file diff --git a/.gitignore b/.gitignore index a7ca880..0004792 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /workspace +/out diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..10f9349 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +FROM buildpack-deps:bullseye + +# Install Dependencies +RUN \ + apt-get update && \ + apt-get install -y \ + build-essential \ + g++-aarch64-linux-gnu \ + flex \ + texinfo \ + help2man \ + gawk \ + libtool-bin \ + bison && \ + rm -rf /var/lib/apt/lists/* + +# Copy Files +COPY . /data + +# Prepare +RUN /data/scripts/prepare.sh +CMD ["/data/scripts/build.sh"] \ No newline at end of file diff --git a/build.sh b/build.sh deleted file mode 100755 index dbb5110..0000000 --- a/build.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -set -e -cd "$(dirname "$0")" - -# Build -cd workspace/build -for type in */; do - cd "${type}" - ../../crosstool-ng/bin/ct-ng build - cd ../ -done \ No newline at end of file diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..a36c13a --- /dev/null +++ b/run.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +set -e +cd "$(dirname "$0")" + +# Build Image +TAG='arm-toolchain-build' +docker buildx build --tag "${TAG}" . + +# Run +rm -rf out +mkdir out +docker run \ + --rm \ + -u "$(id -u):$(id -g)" \ + -v "$(pwd)/out:/data/out" \ + "${TAG}" + +# Clean Up +docker image rm "${TAG}" \ No newline at end of file diff --git a/scripts/build.sh b/scripts/build.sh new file mode 100755 index 0000000..0cb0ca4 --- /dev/null +++ b/scripts/build.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +set -e +cd "$(dirname "$0")/../" + +# Store Output +OUT="$(pwd)/out" +mkdir -p "${OUT}" + +# Build +cd workspace/build +for type in *; do + cd "${type}" + ../../crosstool-ng/ct-ng build + # Compress + tar -cJf "${out}/arm-toolchain-${type}.tar.xz" out + cd ../ +done \ No newline at end of file diff --git a/prepare.sh b/scripts/prepare.sh similarity index 80% rename from prepare.sh rename to scripts/prepare.sh index 78f74be..25f8be6 100755 --- a/prepare.sh +++ b/scripts/prepare.sh @@ -1,7 +1,7 @@ #!/bin/sh set -e -cd "$(dirname "$0")" +cd "$(dirname "$0")/../" # Check if [ "$(uname -m)" != 'x86_64' ]; then @@ -10,8 +10,8 @@ if [ "$(uname -m)" != 'x86_64' ]; then fi # Versions -CT_NAME="crosstool-ng" -CT_VERSION="1.27.0" +CT_NAME='crosstool-ng' +CT_VERSION='1.27.0' CT="${CT_NAME}-${CT_VERSION}" # Source Files @@ -28,19 +28,16 @@ WORKSPACE="$(pwd)" # Build crosstools-ng dir "${CT_NAME}" -PREFIX="$(pwd)" -dir src wget "https://github.com/${CT_NAME}/${CT_NAME}/releases/download/${CT}/${CT}.tar.xz" tar -xJf "${CT}.tar.xz" --strip-components=1 ./configure \ - "--prefix=${PREFIX}" \ + --enable-local \ --enable-silent-rules \ --quiet make -j$(nproc) -make install > /dev/null # Add Patch -cd "${PREFIX}/share/crosstool-ng/packages/binutils" +cd packages/binutils patch() { for version in */; do cp "${SRC}/$1" "${version}" @@ -49,8 +46,8 @@ patch() { patch 9999-change-page-size.patch # Configure Toolchain -export PATH="${PREFIX}/bin:${PATH}" cd "${WORKSPACE}" +export PATH="$(pwd)/${CT_NAME}:${PATH}" dir build prepare() { dir "$1" @@ -58,6 +55,7 @@ prepare() { printf "$2" >> defconfig ct-ng defconfig ct-ng show-config + chmod -R o+rw . cd ../ } prepare x86_64 ''