From e718c60a22efd88f5db1c7aec886912b7446fb48 Mon Sep 17 00:00:00 2001 From: david Date: Mon, 20 May 2024 08:57:25 +0200 Subject: [PATCH 1/5] Adding aarch64 support for install script --- install | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/install b/install index 355a0a5..4260ee4 100755 --- a/install +++ b/install @@ -12,10 +12,16 @@ function fail() { # platform IDs LIN=linux -LIN_URL=https://git.phoenix.ipv64.de/attachments/f701fbff-c58b-4aac-91e3-47efda1fc760 MAC=macos -MAC_URL=https://git.phoenix.ipv64.de/attachments/b09c6469-406a-4dd1-b5e8-1294a3aabf0f WIN=windows +# Urls +LIN_X64_URL=https://git.phoenix.ipv64.de/public/warp/releases/download/1.0.0/linux-x64.warp-packer +LIN_AARCH64_URL=https://git.phoenix.ipv64.de/public/warp/releases/download/1.0.0/linux-aarch64.warp-packer +MAC_URL=https://git.phoenix.ipv64.de/public/warp/releases/download/1.0.0/macos-x64.warp-packer + +# platform architecture +X64=x64 +AARCH64=aarch64 # returns this platform ID function get_this_platform() { @@ -30,18 +36,39 @@ function get_this_platform() { esac } +# returns this platform architecture +function get_this_architecture() { + local this_machine="$(uname -m)" + case $this_machine in + x86_64) echo $X64 ;; + aarch64) echo $AARCH64 ;; + *) + fail_with "Unsupported machine $this_machine" + ;; + esac +} + # actually sets this platform THIS_PLATFORM=$(get_this_platform) +# actually sets this architecture +THIS_ARCHITECTURE=$(get_this_architecture) + # fetches latest release download link for the platform function get_warp_link() { local this_platform=$1 + local this_architecture=$2 if [ "$this_platform" = "$LIN" ]; then - echo "$LIN_URL" - else - echo "$MAC_URL" - fi + echo "$LIN_URL" + if [ "$this_architecture" = "$X64" ]; then + echo "$LIN_X64_URL" + else + echo "$LIN_AARCH64_URL" + fi + else + echo "$MAC_URL" + fi } # downloads and installs single binary @@ -90,7 +117,7 @@ function get_missing_deps() { WARP4J_LINK="https://git.phoenix.ipv64.de/public/warp4j/raw/branch/master/warp4j" echo "Getting information about warp-packer releases..." -WARP_LINK=$(get_warp_link $THIS_PLATFORM) +WARP_LINK=$(get_warp_link $THIS_PLATFORM $THIS_ARCHITECTURE) MISSING_DEPS=$(get_missing_deps) -- 2.45.2 From c00e1598425eb60dae9c9fec5fb1ef3ba9105fa1 Mon Sep 17 00:00:00 2001 From: david Date: Mon, 20 May 2024 09:26:10 +0200 Subject: [PATCH 2/5] Fixing install script --- install | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/install b/install index 4260ee4..8821855 100755 --- a/install +++ b/install @@ -77,7 +77,7 @@ function install() { local link=$2 local temp_location="/tmp/$name" echo "Downloading $name..." - curl -fsSL -o "$temp_location" "$link" + curl -fsSL -o $temp_location $link if [[ $? != 0 ]]; then echo "Error: Failed to download $name" >&2 fail @@ -92,6 +92,7 @@ function install() { echo "Error: Failed to install $name" >&2 fail fi + rm $temp_location } # returns missing dependencies -- 2.45.2 From 14e7aaf81218c3cb3853f24f1f0b098438c7bab8 Mon Sep 17 00:00:00 2001 From: david Date: Mon, 20 May 2024 09:32:59 +0200 Subject: [PATCH 3/5] Using install script in Dockerfile --- Dockerfile | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index 26cd7c8..7547d0b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,15 +5,5 @@ RUN apt-get update && apt-get install -y \ unzip \ zip \ && rm -rf /var/lib/apt/lists/* -RUN curl -fsSL -o /tmp/warp-packer \ - https://git.phoenix.ipv64.de/public/warp/releases/download/1.0.0/linux-aarch64.warp-packer \ - && install -D \ - --mode=755 \ - --owner=root \ - --group=root \ - /tmp/warp-packer \ - /usr/local/bin \ - && rm /tmp/warp-packer -WORKDIR /workdir -COPY warp4j /usr/local/bin/ +RUN ./install ENTRYPOINT [ "/usr/local/bin/warp4j" ] -- 2.45.2 From 966a3b753e696ada8b433d5572c6725b149b1062 Mon Sep 17 00:00:00 2001 From: david Date: Mon, 20 May 2024 09:37:00 +0200 Subject: [PATCH 4/5] Fixing Dockerfile Changing temp the url for Dockerfile Removing bash specific commands in install script Using su instead of sudo, fixing Dokcerfile --- Dockerfile | 2 +- install | 70 ++++++++++++++++++++++++++++++------------------------ 2 files changed, 40 insertions(+), 32 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7547d0b..98ad649 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,5 +5,5 @@ RUN apt-get update && apt-get install -y \ unzip \ zip \ && rm -rf /var/lib/apt/lists/* -RUN ./install +RUN curl -s https://git.phoenix.ipv64.de/public/warp4j/raw/branch/feature/update_install_script/install | /bin/sh -s ENTRYPOINT [ "/usr/local/bin/warp4j" ] diff --git a/install b/install index 8821855..a7b9569 100755 --- a/install +++ b/install @@ -6,7 +6,7 @@ LOCATION=/usr/local/bin # exit top level program from subshell trap "exit 1" TERM export TOP_PID=$$ -function fail() { +fail() { kill -s TERM $TOP_PID } @@ -24,7 +24,7 @@ X64=x64 AARCH64=aarch64 # returns this platform ID -function get_this_platform() { +get_this_platform() { local this_platform="$(uname -s)" case $this_platform in Linux*) echo $LIN ;; @@ -37,7 +37,7 @@ function get_this_platform() { } # returns this platform architecture -function get_this_architecture() { +get_this_architecture() { local this_machine="$(uname -m)" case $this_machine in x86_64) echo $X64 ;; @@ -55,7 +55,7 @@ THIS_PLATFORM=$(get_this_platform) THIS_ARCHITECTURE=$(get_this_architecture) # fetches latest release download link for the platform -function get_warp_link() { +get_warp_link() { local this_platform=$1 local this_architecture=$2 @@ -72,23 +72,23 @@ function get_warp_link() { } # downloads and installs single binary -function install() { +install() { local name=$1 local link=$2 local temp_location="/tmp/$name" echo "Downloading $name..." curl -fsSL -o $temp_location $link - if [[ $? != 0 ]]; then + if [ $? != 0 ]; then echo "Error: Failed to download $name" >&2 fail fi echo "Creating $LOCATION/$name..." - sudo install -D \ + su -c "install -D \ --mode=755 \ --owner=root \ --group=root \ - "$temp_location" "$LOCATION" - if [[ $? != 0 ]]; then + '$temp_location' '$LOCATION'" + if [ $? != 0 ]; then echo "Error: Failed to install $name" >&2 fail fi @@ -96,23 +96,34 @@ function install() { } # returns missing dependencies -function get_missing_deps() { - local deps=( - "awk" \ - "curl" \ - "file" \ - "grep" \ - "sed" \ - "sort" \ - "tar" \ - "unzip" \ - "zip" \ - ) - for d in ${deps[@]}; do - if ! command -v $d &> /dev/null ; then - echo -n "$d " - fi - done +get_missing_deps() { + if ! command -v awk > /dev/null 2<&1; then + echo -n "awk " + fi + if ! command -v curl > /dev/null 2<&1; then + echo -n "curl " + fi + if ! command -v file > /dev/null 2<&1; then + echo -n "file " + fi + if ! command -v grep > /dev/null 2<&1; then + echo -n "grep " + fi + if ! command -v sed > /dev/null 2<&1; then + echo -n "sed " + fi + if ! command -v sort > /dev/null 2<&1; then + echo -n "sort " + fi + if ! command -v tar > /dev/null 2<&1; then + echo -n "tar " + fi + if ! command -v unzip > /dev/null 2<&1; then + echo -n "unzip " + fi + if ! command -v zip > /dev/null 2<&1; then + echo -n "zip" + fi } WARP4J_LINK="https://git.phoenix.ipv64.de/public/warp4j/raw/branch/master/warp4j" @@ -125,14 +136,11 @@ MISSING_DEPS=$(get_missing_deps) install "warp-packer" "$WARP_LINK" && \ install "warp4j" "$WARP4J_LINK" -if [[ -z $MISSING_DEPS ]]; then +if [ -z "$MISSING_DEPS" ]; then echo "Successfully installed" else echo "Main tools successfully installed" echo "Please install following with your package manager:" - for d in ${MISSING_DEPS[@]}; do - echo -n "$d " - done - echo + echo $MISSING_DEPS exit 1 fi -- 2.45.2 From 1e633691ff379b1b042cb98eb3846d3872b2e59e Mon Sep 17 00:00:00 2001 From: david Date: Mon, 20 May 2024 15:43:18 +0200 Subject: [PATCH 5/5] Changing temporary the warp4j link --- install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install b/install index a7b9569..8a7695b 100755 --- a/install +++ b/install @@ -126,7 +126,7 @@ get_missing_deps() { fi } -WARP4J_LINK="https://git.phoenix.ipv64.de/public/warp4j/raw/branch/master/warp4j" +WARP4J_LINK="https://git.phoenix.ipv64.de/public/warp4j/raw/branch/develop/warp4j" echo "Getting information about warp-packer releases..." WARP_LINK=$(get_warp_link $THIS_PLATFORM $THIS_ARCHITECTURE) -- 2.45.2