forked from dlecan/rust-crosscompiler-arm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create an image based off of debian:stretch
Add a Dockerfile that builds a similar image to rust-crosscompiler-arm:stable, but that uses debian:stretch as the base image instead of debian:jessie. This solves an issue where cross-compiling with openssl-sys links to the correct library that is provided with each release. Fixes dlecan#15
- Loading branch information
1 parent
d2f34b1
commit a7a2f69
Showing
8 changed files
with
143 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
FROM debian:stretch | ||
MAINTAINER Damien Lecan <[email protected]> | ||
|
||
#ENV USER root | ||
ENV CHANNEL stable | ||
|
||
ENV CC_DIR /opt/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin | ||
ENV REAL_CC $CC_DIR/arm-linux-gnueabihf-gcc | ||
ENV CC arm-linux-gnueabihf-gcc-with-link-search | ||
ENV CXX arm-linux-gnueabihf-g++-with-link-search | ||
ENV PATH $CC_DIR:$PATH:/root/.cargo/bin | ||
ENV ROOT_FS / | ||
ENV OBJCOPY $CC_DIR/arm-linux-gnueabihf-objcopy | ||
ENV PKG_CONFIG_ALLOW_CROSS 1 | ||
|
||
COPY include/config /tmp/.cargo/ | ||
COPY include/arm-linux-gnueabihf-gcc-with-link-search /usr/local/sbin/ | ||
COPY include/arm-linux-gnueabihf-g++-with-link-search /usr/local/sbin/ | ||
COPY include/fixQualifiedLibraryPaths.sh /usr/local/sbin/ | ||
COPY include/cargo /usr/local/sbin/ | ||
|
||
RUN mv /tmp/.cargo $HOME && \ | ||
dpkg --add-architecture armhf && \ | ||
apt-get update && \ | ||
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ | ||
build-essential \ | ||
ca-certificates \ | ||
file \ | ||
pkg-config \ | ||
curl \ | ||
crossbuild-essential-armhf \ | ||
libssl1.0-dev \ | ||
libssl1.0-dev:armhf && \ | ||
curl https://sh.rustup.rs -sSf | sh /dev/stdin -y && \ | ||
PATH=$PATH:$HOME/.cargo/bin && \ | ||
rustup target add arm-unknown-linux-gnueabihf && \ | ||
curl -sSL https://github.com/raspberrypi/tools/archive/master.tar.gz \ | ||
| tar -zxC /opt tools-master/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64 --strip=2 && \ | ||
fixQualifiedLibraryPaths.sh $ROOT_FS $REAL_CC && \ | ||
DEBIAN_FRONTEND=noninteractive apt-get remove --purge -y curl && \ | ||
DEBIAN_FRONTEND=noninteractive apt-get autoremove -y && \ | ||
rm -rf \ | ||
/var/lib/apt/lists/* \ | ||
/tmp/* \ | ||
/var/tmp/* && \ | ||
mkdir -p /source | ||
|
||
VOLUME ["/root/.cargo/git", "/root/.cargo/registry"] | ||
|
||
VOLUME ["/source"] | ||
WORKDIR /source | ||
|
||
CMD ["cargo", "build", "--release"] |
11 changes: 11 additions & 0 deletions
11
arm-stretch/include/arm-linux-gnueabihf-g++-with-link-search
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
# /!\ Same config for gcc | ||
|
||
arm-linux-gnueabihf-g++ \ | ||
-isystem/usr/include/arm-linux-gnueabihf \ | ||
-isystem/usr/include \ | ||
-L/usr/lib/arm-linux-gnueabihf \ | ||
-L/usr/lib \ | ||
$@ | ||
|
11 changes: 11 additions & 0 deletions
11
arm-stretch/include/arm-linux-gnueabihf-gcc-with-link-search
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
# /!\ Same config for g++ | ||
|
||
arm-linux-gnueabihf-gcc \ | ||
-isystem/usr/include/arm-linux-gnueabihf \ | ||
-isystem/usr/include \ | ||
-L/usr/lib/arm-linux-gnueabihf \ | ||
-L/usr/lib \ | ||
$@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
/root/.cargo/bin/cargo $@ --target=arm-unknown-linux-gnueabihf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[target.arm-unknown-linux-gnueabihf] | ||
linker = "arm-linux-gnueabihf-gcc-with-link-search" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/bin/bash | ||
#This script is ugly, feel free to fix it | ||
|
||
if [ "$#" -ne 2 ]; then | ||
echo "usage ./cmd target-rootfs target-toolchain" | ||
exit -1 | ||
fi | ||
|
||
#passed args | ||
ROOTFS=$1 | ||
TOOLCHAIN=$2 | ||
|
||
if [ -x $TOOLCHAIN ]; then | ||
echo "Passed valid toolchain" | ||
MACHINE=$($TOOLCHAIN -dumpmachine) | ||
DEB_MULTI_ARCH_MADNESS=$ROOTFS/usr/lib/$MACHINE | ||
fi | ||
|
||
CURRENTDIR=$PWD | ||
|
||
function adjustSymLinks | ||
{ | ||
echo "Adjusting the symlinks in $1 to be relative" | ||
cd $1 | ||
find . -maxdepth 1 -type l | while read i; | ||
do qualifies=$(file $i | sed -e "s/.*\`\(.*\)'/\1/g" | grep ^/lib) | ||
if [ -n "$qualifies" ]; then | ||
newPath=$(file $i | sed -e "s/.*\`\(.*\)'/\1/g" | sed -e "s,\`,,g" | sed -e "s,',,g" | sed -e "s,^/lib,$2/lib,g"); | ||
echo $i | ||
echo $newPath; | ||
#sudo rm $i; | ||
rm $i; | ||
#sudo ln -s $newPath $i; | ||
ln -s $newPath $i; | ||
fi | ||
done | ||
} | ||
|
||
adjustSymLinks $ROOTFS/usr/lib "../.." | ||
|
||
if [ -n "$DEB_MULTI_ARCH_MADNESS" -a -d "$DEB_MULTI_ARCH_MADNESS" ]; then | ||
echo "Debian multiarch dir exists, adjusting" | ||
adjustSymLinks $DEB_MULTI_ARCH_MADNESS "../../.." | ||
fi | ||
|
||
cd $CURRENTDIR |