From 72fc13f80b9c244317d89414f6a63402d12cea40 Mon Sep 17 00:00:00 2001 From: Thomas Meckel <14177833+tmeckel@users.noreply.github.com> Date: Mon, 2 Dec 2019 22:32:28 +0100 Subject: [PATCH] Add support for different Debian versions (#8) --- README.md | 9 ++++++++- build.sh | 18 ++++++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2275633..e4b1d5f 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,14 @@ Then: ``` git clone https://github.com/greizgh/bitwarden_rs-debian.git cd bitwarden_rs-debian -./build.sh 1.10.0 +./build.sh -r 1.10.0 +``` + +The `build.sh` script will build bitwarden_rs for the same Debian version which targets bitwarden_rs. +To compile for a different Debian version, specify the release name (e.g. Stretch, Buster) using the `-o` option. + +``` +./build.sh -o stretch ``` ## Post installation diff --git a/build.sh b/build.sh index e52f4f3..5984434 100755 --- a/build.sh +++ b/build.sh @@ -5,7 +5,19 @@ set -e DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" SRC="$DIR/git" DST="$DIR/dist" -if [ -z "$1" ]; then REF="1.13.0"; else REF="$1"; fi + +while getopts ":r:o:" opt; do + case $opt in + r) REF="$OPTARG" + ;; + o) OS_VERSION_NAME="$OPTARG" + ;; + \?) echo "Invalid option -$OPTARG" >&2 + ;; + esac +done +if [ -z "$REF" ]; then REF="1.13.0"; fi +if [ -z "$OS_VERSION_NAME" ]; then OS_VERSION_NAME='buster'; fi # Clone bitwarden_rs if [ ! -d "$SRC" ]; then @@ -32,9 +44,11 @@ mkdir -p "$DST" # Prepare Dockerfile patch -i "$DIR/Dockerfile.patch" "$SRC/docker/amd64/sqlite/Dockerfile" -o "$DIR/Dockerfile" || exit +sed -E "s/(FROM[[:space:]]*rust:)[^[:space:]]+(.+)/\1${OS_VERSION_NAME}\2/g" -i "$DIR/Dockerfile" +sed -E "s/(FROM[[:space:]]*debian:)[^-]+(-.+)/\1${OS_VERSION_NAME}\2/g" -i "$DIR/Dockerfile" docker build -t bitwarden-deb "$DIR" CID=$(docker run -d bitwarden-deb) -docker cp "$CID":/bitwarden_package/bitwarden-rs.deb "$DST/bitwarden_rs-$REF.deb" +docker cp "$CID":/bitwarden_package/bitwarden-rs.deb "$DST/bitwarden_rs-${OS_VERSION_NAME}-${REF}.deb" docker rm "$CID"