diff --git a/contrib/dependency_setup.sh b/contrib/dependency_setup.sh index 4f9320e19..3f3cd8e3c 100644 --- a/contrib/dependency_setup.sh +++ b/contrib/dependency_setup.sh @@ -56,6 +56,11 @@ setup_emerge() { $1 $emerge_deps || return 1 } +setup_pkg() { + pkg_deps="git bash jq gcc findutils cantarell-fonts devel/pkgconf gmake devel/automake pulseaudio-module-sndio" + $1 install -y $pkg_deps || return 1 +} + case "$(uname -s)" in Linux) if command -v apt >/dev/null; then @@ -118,7 +123,46 @@ Linux) echo "Error: Could not recognize your package manager." >&2 exit 1 ;; +*BSD*) + if command -v pkg; then + echo "Setting up for pkg/BSD" >&2 + setup_pkg "$SUDO $(command -v pkg)" || exit 1 + echo "Dependencies installed!" >&2 + cat <<'ENDOFCAT' >&2 +======================= +Few more things needed: +Install rust from https://www.rust-lang.org/tools/install +Execute: rustup target add wasm32-unknown-unknown +And apply few patches ... +cd .. +git clone --recurse-submodules -j8 https://github.com/stainless-steel/mpg123-sys +cd ./mpg123-sys +sed -e's/$(RM)/rm -f/g' -i.bak source/Makefile.in +patch -p0 build.rs <<'EOF' +43a44 +> .arg(&format!("--with-audio=sndio")) +EOF + +cargo build # to see if it works fine + +cd ../darkfi + +patch -p0 Cargo.toml <<'EOF' +329a330 +> mpg123-sys = { path = "../mpg123-sys" } +EOF + +gmake test # no errors expected +gmake +ls -al darkfid ircd dnetview faucetd vanityaddr # list of built executables +ENDOFCAT + exit 0 + fi + + echo "Error: Could not recognize your package manager." >&2 + exit 1 + ;; Darwin) echo "Setting up for OSX" >&2 setup_mac || exit 1 diff --git a/contrib/docker/Dockerfile.alpineARMviaEmulation b/contrib/docker/Dockerfile.alpineARMviaEmulation new file mode 100644 index 000000000..9c5cbd9d8 --- /dev/null +++ b/contrib/docker/Dockerfile.alpineARMviaEmulation @@ -0,0 +1,56 @@ +# Beware, uses emulation, with AMD 24 threads: Building 7788.3s +# Use: docker build . --platform=linux/arm64 --pull -t darkfi:alpine_arm64 -f ./contrib/docker/Dockerfile.alpineARMviaEmulation +# optionally with: --build-arg OS_VER=3.17 --build-arg RUST_VER=nightly + +ARG RUST_VER=1.67 +ARG OS_VER=3.17 +ARG REPOSITORY=arm64v8/alpine + +FROM --platform=$TARGETPLATFORM ${REPOSITORY}:${OS_VER} as rust_builder + +ARG RUST_VER +ARG OS_VER +ARG TARGETPLATFORM +ARG BUILDPLATFORM +RUN echo "I am running on $BUILDPLATFORM, building for $TARGETPLATFORM with Rust $RUST_VER" + +RUN apk update + +RUN apk add cmake jq wget clang curl gcc make llvm-dev \ + openssl-dev expat-dev freetype-dev libudev-zero-dev \ + libgudev-dev pkgconf clang-dev fontconfig-dev bash \ + ttf-opensans musl-dev + +RUN curl https://sh.rustup.rs -sSf | bash -s -- -y --default-toolchain "${RUST_VER}" + +ENV PATH="/root/.cargo/bin:${PATH}" + +RUN rustup target add wasm32-unknown-unknown + +RUN cargo search whatever # creates .cargo cache + +# 2. stage +FROM --platform=$TARGETPLATFORM rust_builder as builder + +WORKDIR /opt/darkfi + +COPY . ./ + +ARG RUSTFLAGS="-C target-feature=-crt-static" + +RUN make clean + +RUN rm -rf ./target/ + +RUN bash -c 'make -j test && make -j' + +# 3. stage +FROM --platform=$TARGETPLATFORM ${REPOSITORY}:${OS_VER} + +RUN apk add --no-cache openssl ttf-opensans libgcc mpg123-libs + +WORKDIR /opt/darkfi + +COPY --from=builder /opt/darkfi/drk /opt/darkfi/darkfid \ + /opt/darkfi/ircd /opt/darkfi/dnetview /opt/darkfi/faucetd \ + /opt/darkfi/zkas /opt/darkfi/vanityaddr ./