Compare commits
No commits in common. "7a96634b5a60b6b42adb9f0097c0db2a2cc09380" and "f5357cc6e035f447d3bc288ac69a4d98c5c5946b" have entirely different histories.
7a96634b5a
...
f5357cc6e0
@ -1,25 +0,0 @@
|
||||
FROM docker.io/library/rust:${RUST_VERSION}-slim
|
||||
LABEL maintainer 'Jacob Kiers <code@kie.rs>'
|
||||
ENV ZIG_VERSION=${ZIG_VERSION}
|
||||
|
||||
# Install zig, binstall and zigbuild
|
||||
COPY zig/install-dependencies.sh /tmp/install-dependencies.sh
|
||||
RUN chmod +x /tmp/install-dependencies.sh && /tmp/install-dependencies.sh && rm /tmp/install-dependencies.sh
|
||||
|
||||
# Install macOS SDKs
|
||||
RUN curl -L "https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX10.9.sdk.tar.xz" | tar -J -x -C /opt
|
||||
RUN curl -L "https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX11.3.sdk.tar.xz" | tar -J -x -C /opt
|
||||
ENV SDKROOT=/opt/MacOSX11.3.sdk
|
||||
|
||||
# Install Rust targets
|
||||
RUN rustup target add \
|
||||
x86_64-unknown-linux-gnu \
|
||||
x86_64-unknown-linux-musl \
|
||||
aarch64-unknown-linux-gnu \
|
||||
aarch64-unknown-linux-musl \
|
||||
arm-unknown-linux-gnueabihf \
|
||||
arm-unknown-linux-musleabihf \
|
||||
x86_64-apple-darwin \
|
||||
aarch64-apple-darwin \
|
||||
x86_64-pc-windows-gnu
|
||||
|
2
LICENSE
2
LICENSE
@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2022-2024 Jacob Kiers
|
||||
Copyright (c) <year> <copyright holders>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
|
13
README.md
13
README.md
@ -9,17 +9,14 @@ By default, it uses the latest [Rust][2] and [`cross`][3] versions.
|
||||
## Usage
|
||||
|
||||
```
|
||||
USAGE: ./build.sh <slim|full|zig> [rust version] [cross version] [zig version]
|
||||
USAGE: ./build.sh <slim|full> [rust version] [cross version]
|
||||
|
||||
Arguments:
|
||||
<slim|full> Slim build (without targets) or Full build (with targets)
|
||||
<slim|full> Slim build (without targets) or Full build (with targets)
|
||||
[rust version] Version of rust (https://github.com/rust-lang/rust)
|
||||
[cross version] Version of cross (https://github.com/cross-rs/cross)
|
||||
|
||||
[rust version] Version of rust (https://github.com/rust-lang/rust)
|
||||
[cross version] Version of cross (https://github.com/cross-rs/cross)
|
||||
[zig version] Version of zig (https://ziglang.org/download)
|
||||
Use 'master' for master version of zig
|
||||
|
||||
All versions default to the latest release.
|
||||
Both versions default to the latest version.
|
||||
```
|
||||
|
||||
[1]: https://code.kiers.eu/newsletter-to-web/newsletter-to-web
|
||||
|
48
build.sh
Normal file → Executable file
48
build.sh
Normal file → Executable file
@ -2,17 +2,14 @@
|
||||
|
||||
print_usage()
|
||||
{
|
||||
echo "USAGE: $0 <slim|full|zig> [rust version] [cross version] [zig version]"
|
||||
echo "USAGE: $0 <slim|full> [rust version] [cross version]"
|
||||
echo
|
||||
echo "Arguments:"
|
||||
echo -e "\t<slim|full>\tSlim build (without targets) or Full build (with targets)"
|
||||
echo
|
||||
echo -e "\t[rust version]\tVersion of rust (https://github.com/rust-lang/rust)"
|
||||
echo -e "\t[cross version]\tVersion of cross (https://github.com/cross-rs/cross)"
|
||||
echo -e "\t[zig version]\tVersion of zig (https://ziglang.org/download)"
|
||||
echo -e "\t\t\tUse 'master' for master version of zig"
|
||||
echo
|
||||
echo "All versions default to the latest release."
|
||||
echo "Both versions default to the latest version."
|
||||
}
|
||||
|
||||
get_latest_release() {
|
||||
@ -21,18 +18,6 @@ get_latest_release() {
|
||||
sed -E 's/.*"v?([^"]+)".*/\1/' # Pluck JSON value
|
||||
}
|
||||
|
||||
get_version() {
|
||||
case $2 in
|
||||
latest | "")
|
||||
echo $(get_latest_release $1)
|
||||
;;
|
||||
*)
|
||||
echo $2
|
||||
;;
|
||||
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
if command -v podman &> /dev/null
|
||||
then
|
||||
@ -57,7 +42,7 @@ if [ $# -lt 1 ]; then
|
||||
fi
|
||||
|
||||
case ${1} in
|
||||
full | slim | zig)
|
||||
full | slim)
|
||||
;;
|
||||
|
||||
*)
|
||||
@ -71,7 +56,7 @@ esac
|
||||
set -e -o pipefail
|
||||
|
||||
if [ -z "$2" ]; then
|
||||
RUST_VERSION=$(get_version 'rust-lang/rust' $2)
|
||||
RUST_VERSION=$(get_latest_release 'rust-lang/rust')
|
||||
else
|
||||
RUST_VERSION=$2
|
||||
fi
|
||||
@ -82,25 +67,12 @@ else
|
||||
CROSS_VERSION=$3
|
||||
fi
|
||||
|
||||
ZIG_VERSION=$(get_latest_release 'ziglang/zig')
|
||||
echo "Creating a ${1} build with Rust ${RUST_VERSION} and cross ${CROSS_VERSION}"
|
||||
|
||||
export RUST_VERSION
|
||||
export CROSS_VERSION
|
||||
export ZIG_VERSION
|
||||
|
||||
echo "Creating a ${1} build with the following versions:"
|
||||
echo -e "\tRust:\t${RUST_VERSION}"
|
||||
echo -e "\tcross:\t${CROSS_VERSION}"
|
||||
echo -e "\tzig:\t${ZIG_VERSION}"
|
||||
|
||||
case $1 in
|
||||
full | slim)
|
||||
IMAGE="img.kie.rs/jjkiers/rust-crossbuild:rust${RUST_VERSION}-cross${CROSS_VERSION}-${1}"
|
||||
;;
|
||||
zig)
|
||||
IMAGE="img.kie.rs/jjkiers/rust-crossbuild:rust${RUST_VERSION}-zig${ZIG_VERSION}-${1}"
|
||||
;;
|
||||
esac
|
||||
IMAGE="img.kie.rs/jjkiers/rust-dind-cross:rust${RUST_VERSION}-cross${CROSS_VERSION}-${1}"
|
||||
|
||||
envsubst < Dockerfile-${1} | ${BUILDER} build -f - \
|
||||
-t ${IMAGE} \
|
||||
@ -108,12 +80,6 @@ envsubst < Dockerfile-${1} | ${BUILDER} build -f - \
|
||||
|
||||
echo "Built image ${IMAGE}"
|
||||
|
||||
exit 0
|
||||
|
||||
${BUILDER} push ${IMAGE}
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Pushing failed: ${BUILDER} push ${IMAGE}"
|
||||
else
|
||||
echo "Pushed image ${IMAGE}"
|
||||
fi
|
||||
echo "Pushed image ${IMAGE}"
|
||||
|
@ -1,51 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -xo pipefail
|
||||
|
||||
apt-get update && apt-get install -y jq curl xz-utils
|
||||
|
||||
TMP_DIR=$(mktemp -d)
|
||||
|
||||
pushd ${TMP_DIR}
|
||||
|
||||
# Install minisign
|
||||
curl -Ls https://github.com/jedisct1/minisign/releases/download/0.11/minisign-0.11-linux.tar.gz -o - | tar --strip-components 2 -C /usr/local/bin/ -vxzf - minisign-linux/x86_64/minisign
|
||||
|
||||
# Installing zig, checking its validity
|
||||
mkdir -p /usr/local/bin
|
||||
curl -Ls https://ziglang.org/download/index.json -o zig-versions.json
|
||||
|
||||
ZIG_SHASUM=".\"${ZIG_VERSION}\".\"x86_64-linux\".shasum"
|
||||
ZIG_TARBALL_URL=".\"${ZIG_VERSION}\".\"x86_64-linux\".tarball"
|
||||
|
||||
echo "$(jq -r ${ZIG_SHASUM} zig-versions.json) zig.tar.xz" > zig.tar.xz.shasum
|
||||
curl -Ls "$(jq -r ${ZIG_TARBALL_URL} zig-versions.json)" -o zig.tar.xz
|
||||
curl -Ls "$(jq -r ${ZIG_TARBALL_URL} zig-versions.json).minisig" -o zig.tar.xz.minisig
|
||||
sha256sum -c zig.tar.xz.shasum
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error in SHA256 hash!"
|
||||
exit 1
|
||||
else
|
||||
echo "SHA256 hash OK"
|
||||
fi
|
||||
|
||||
minisign -P 'RWSGOq2NVecA2UPNdBUZykf1CCb147pkmdtYxgb3Ti+JO/wCYvhbAb/U' -Vm zig.tar.xz
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error in signature!"
|
||||
exit 1
|
||||
else
|
||||
echo "Signature OK"
|
||||
fi
|
||||
|
||||
tar -C /usr/local/bin --strip-components 1 -xf zig.tar.xz
|
||||
|
||||
# Installing binstall and zigbuild
|
||||
curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
|
||||
cargo binstall -y cargo-zigbuild
|
||||
|
||||
popd
|
||||
rm -rf ${TMP_DIR}
|
||||
|
||||
apt-get clean
|
||||
rm -rf /var/lib/apt/lists/*
|
Loading…
Reference in New Issue
Block a user