Last active
August 19, 2021 02:39
-
-
Save Checksum/5c604c8d1180dd060aebf51026215977 to your computer and use it in GitHub Desktop.
Cross compiling bitwarden_rs for Raspberry Pi
This file contains hidden or 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
# Requires git and docker | |
# clone bitwarden_rs | |
git clone https://github.com/dani-garcia/bitwarden_rs | |
cd bitwarden_rs | |
# Use rust docker container to build everything | |
docker run --rm -it -v `pwd`:/bitwarden rust bash | |
# Download pi tools and openssl | |
cd /root | |
git clone https://github.com/raspberrypi/tools.git --depth=1 pitools | |
git clone https://github.com/openssl/openssl | |
# Export required paths | |
export CROSSCOMP_DIR=/root/pitools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin | |
export INSTALL_DIR=/root | |
export PATH=$PATH:$CROSSCOMP_DIR | |
# Build openssl | |
cd /root/openssl | |
git checkout OpenSSL_1_0_2t | |
./Configure linux-generic32 shared \ | |
--prefix=$INSTALL_DIR --openssldir=$INSTALL_DIR/openssl \ | |
--cross-compile-prefix=$CROSSCOMP_DIR/arm-linux-gnueabihf- | |
make depend | |
make | |
make install | |
# Build bitwarden | |
cd /bitwarden | |
mkdir -p .cargo | |
cat <<EOF > .cargo/config | |
[target.armv7-unknown-linux-gnueabihf] | |
linker = "arm-linux-gnueabihf-gcc" | |
EOF | |
rustup target add armv7-unknown-linux-gnueabihf | |
export ARMV7_UNKNOWN_LINUX_GNUEABIHF_OPENSSL_LIB_DIR=/root/lib | |
export ARMV7_UNKNOWN_LINUX_GNUEABIHF_OPENSSL_INCLUDE_DIR=/root/include | |
export PKG_CONFIG_ALLOW_CROSS=1 | |
cargo build --features sqlite --release --target=armv7-unknown-linux-gnueabihf | |
# Copy required files pi | |
scp target/armv7-unknown-linux-gnueabihf/release/bitwarden_rs pi@pi:/home/pi | |
scp -r /root/lib /root/bin /root/include pi@pi:/home/pi | |
sudo mv /root/lib /root/bin /root/include /usr | |
sudo mv bitwarden_rs /usr/bin | |
# Download web valut | |
sudo mkdir /usr/local/bitwarden_vault | |
wget https://github.com/dani-garcia/bw_web_builds/releases/download/v2.12.0/bw_web_v2.12.0.tar.gz | |
sudo tar -xvf bw_web_v2.12.0.tar.gz -C /usr/local/bitwarden_vault | |
# Start bitwarden | |
WEB_VAULT_FOLDER=/usr/local/bitwarden_vault DATA_FOLDER=/usr/local/bitwarden_vault/data bitwarden_rs |
You maybe better off using the official docker image and extracting the binary - https://github.com/dani-garcia/bitwarden_rs/blob/master/docker/armv7/sqlite/Dockerfile. I found that after I spent a lot of time on this.
Does following this (but changing the docker parts) work with Vagrant just to cross-compile? I'm still setting up my env, and would rather use Vagrant than Docker.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Good job!
But, cargo is unable to build the latest bitwarden_rs:
Any idea how to fix this?