Skip to content

Commit

Permalink
fix: try simplifying access to vars
Browse files Browse the repository at this point in the history
  • Loading branch information
gschrisstadler committed Apr 17, 2024
1 parent a30071a commit 01d8973
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
10 changes: 5 additions & 5 deletions web-build/snowflake-odbc/download-package
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

set -e

if [ "${GOARCH}" = "amd64" ]; then
if [ "$GOARCH" = "amd64" ]; then
ARCH="x86_64";
BUILD="";
elif [ "${GOARCH}" = "arm64" ]; then
elif [ "$GOARCH" = "arm64" ]; then
ARCH="aarch64";
BUILD="aarch64";
else
Expand All @@ -17,12 +17,12 @@ fi
PACKAGE_URL="https://sfc-repo.snowflakecomputing.com/odbc/linux$BUILD/3.3.0/snowflake-odbc-3.3.0.$ARCH.deb"
PACKAGE_NAME="./web-build/snowflake-odbc/snowflake.deb"

rm -f "${PACKAGE_NAME}"
rm -f "$PACKAGE_NAME"

if command -v wget &> /dev/null; then
wget -O "${PACKAGE_NAME}" "${PACKAGE_URL}"
wget -O "$PACKAGE_NAME" "$PACKAGE_URL"
elif command -v curl &> /dev/null; then
curl "${PACKAGE_URL}" -o "${PACKAGE_NAME}"
curl "$PACKAGE_URL" -o "$PACKAGE_NAME"
else
echo "None of the required downloaders (wget, curl) are available."
exit 1
Expand Down
23 changes: 11 additions & 12 deletions web-build/snowflake-odbc/modify-dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ if [ ! -e "./web-build/snowflake-odbc/${PACKAGE_NAME}" ]; then
exit 1;
fi

if [ "${GOARCH}" = "amd64" ]; then
if [ "$GOARCH" = "amd64" ]; then
ARCH="x86_64";
elif [ "${GOARCH}" = "arm64" ]; then
elif [ "$GOARCH" = "arm64" ]; then
ARCH="aarch64";
else
echo "This package does not work on this machines";
Expand All @@ -23,7 +23,7 @@ fi

add_directives() {
local FILE_PATH="$1"
cat <<EOF >> "${FILE_PATH}"
cat <<EOF >> "$FILE_PATH"
# BEGIN Snowflake ODBC Install
RUN (apt-get -qq update || true) && DEBIAN_FRONTEND=noninteractive apt-get -qq install -y -o Dpkg::Options::="--force-confold" --no-install-recommends --no-install-suggests php${DDEV_PHP_VERSION}-odbc libodbc1 unixodbc
RUN ln -s "/usr/lib/${ARCH}-linux-gnu/libodbccr.so.2" "/etc/libodbccr.so"
Expand All @@ -39,25 +39,24 @@ remove_directives() {
between_markers=false

while IFS= read -r LINE; do
if [[ "${LINE}" == "# BEGIN Snowflake ODBC Install" ]]; then
if [[ $LINE == "# BEGIN Snowflake ODBC Install" ]]; then
between_markers=true
continue
fi

if [[ "${LINE}" == "# END Snowflake ODBC Install" ]]; then
if [[ $LINE == "# END Snowflake ODBC Install" ]]; then
between_markers=false
continue
fi

if [ "${between_markers}" == false ]; then
echo "${LINE}" >> "${TMP_FILE}"
if [ "$between_markers" == false ]; then
echo "$LINE" >> "$TMP_FILE"
fi

done < "${FILE_PATH}"
done < "$FILE_PATH"
}

FILE_PATH="./web-build/Dockerfile"
if [ -e "${FILE_PATH}" ]; then
remove_directives "${FILE_PATH}"
if [ -e "$FILE_PATH" ]; then
remove_directives "$FILE_PATH"
fi
add_directives "${FILE_PATH}"
add_directives "$FILE_PATH"

0 comments on commit 01d8973

Please sign in to comment.