Skip to content

Instantly share code, notes, and snippets.

@Checksum
Last active August 19, 2021 02:39
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Checksum/5c604c8d1180dd060aebf51026215977 to your computer and use it in GitHub Desktop.
Save Checksum/5c604c8d1180dd060aebf51026215977 to your computer and use it in GitHub Desktop.
Cross compiling bitwarden_rs for Raspberry Pi
# 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
@kanazir
Copy link

kanazir commented Oct 28, 2019

Good job!
But, cargo is unable to build the latest bitwarden_rs:

note: /bitwarden/target/armv7-unknown-linux-gnueabihf/release/deps/libring-81d89667557a2c83.rlib(ring-81d89667557a2c83.ring.evcv5lom-cgu.6.rcgu.o): In function `spin::once::Once$LT$T$GT$::call_once::h50809b839fe79dd4':
          ring.evcv5lom-cgu.6:(.text._ZN4spin4once13Once$LT$T$GT$9call_once17h50809b839fe79dd4E+0x70): undefined reference to `getauxval'
          ring.evcv5lom-cgu.6:(.text._ZN4spin4once13Once$LT$T$GT$9call_once17h50809b839fe79dd4E+0x80): undefined reference to `getauxval'
          collect2: error: ld returned 1 exit status

Any idea how to fix this?

@Checksum
Copy link
Author

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.

@pedroCX486
Copy link

pedroCX486 commented Aug 19, 2021

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