Oryx/images/installPlatform.sh

114 строки
3.1 KiB
Bash
Исходник Обычный вид История

#!/bin/bash
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT license.
# --------------------------------------------------------------------------------------------
set -ex
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
source $CURRENT_DIR/__common.sh
# https://medium.com/@Drew_Stokes/bash-argument-parsing-54f3b81a6a8f
PARAMS=""
while (( "$#" )); do
case "$1" in
-d|--dir)
targetDir=$2
shift 2
;;
-l|--links)
createLinks=$2
shift 2
;;
--) # end argument parsing
shift
break
;;
-*|--*=) # unsupported flags
echo "Error: Unsupported flag $1" >&2
exit 1
;;
*) # preserve positional arguments
PARAMS="$PARAMS $1"
shift
;;
esac
done
# set positional arguments in their proper place
eval set -- "$PARAMS"
PLATFORM_NAME="$1"
VERSION="$2"
IS_FROM_DYNAMIC_INSTALLATION="${3:-false}"
debianFlavor=$DEBIAN_FLAVOR
fileName="$PLATFORM_NAME-$VERSION.tar.gz"
Pauld/1559705 improve cli to detect viable sdks based on debian flavor (#1484) * save point: splitting up versions to build by ostype * restructured and modified the platforms scripts and updated the shared code generator to account for the new versions * updated constants to include ostype change and newer python version * added support for new file structure to the python dockerfiles and publishing from dev to prod sdks * save point, starting to enrich all storage items with version number, and modifying tests for new logic * clean up platforms shell scripts * finish modifying scripts to add version to the metadata, regardless of OSType * beginning to update cli to support pulling only relevant sdks * added constants that relate to the different debian flavors we may see * save point, added to constants yaml file to start adding support for pulling debian flavor sdks * added debian flavor option to the build command, and starting to update tests to be compatible * renamed the vso focal directories to focal scm, and fixed the sdk storage tests * added a number of comments for the second PR and some tests to cover dotnet and node pulling the correct images * added php and python tests for installing based on the available sdks * updated sdk storage provider and platform installer to have bullseye images use buster sdks, since there are currently no bullseye sdks * self reviewed pr: added comments, fixed some bugs and typos, and updated the pipeline scripts to correctly handle stretch images * added default sdk storage metadata to be used for determining versions available * added legacy versions to stretch version directories, so that the supported md file will contain the best information * updated shared code generator to allow for the legacy versions text files * update platform installation scripts to enrich the sdks with an updated version metadata name and the OS type * some fixes for generating the platform binaries locally, and a fix for generating the maven binaries * added legacy version metadata to storage constants * updated the metadata names so that they exist in constants file and can be used throughout oryx * saved leftover merge conflict file * removed old default and versions to build files * updated php fpm configuration to be in the constants.yaml file so that we support the generate constants script * updated the debian flavor arg in the python template * fix failing githubaction and vso focal tests * saved file and added comment to version comparer * fixed some spacing and added comments and a todo * updated dotnet runtime version metadata to be backwards compatible * use version info from elsewhere in oryx to streamline version comparing * pr feedback, using constants during platform installation and sdk storage provider, and trimming whitespace from version files * pr feedback: use constants for file names and renamed the new sdk versions metadata to be consistent * limit bullseye sdks we push to storage to the ones that we know will be used by bullseye * regenerated constants with updated bullseye versions, and removed extra logic in VersionInfo * include all defaultVersion.txt files in the upload * fixed spacing for vsts pipeline * updated the maven base url to point to a source that contains legacy versions * fixed php version sha * use correct get pip url when version 3.6 and stretch * add bullseye maven job * added support to still build php 7.2 binaries * allow enough time for php to generate and upload all sdks * give php jobs 24 hours to run, as they have not been able to generate all versions in the given time * updated python sdk generation to use the correct stretch buildpack for non-3.10 or greater versions * updated logic so that python version 3.10 and above will have the correct prerequisites built * updated common script to ignore whitespace differently * readded deleted line and ran generate constants * Pauld/1559705 PR2 cleanup and utilize bullseye images (#1497) * initial pass at adding support for bullseye by resolving the PR2 todos * allow build * added test for php default versions * added dotnetcore and python tests for invalid versions * added more tests for correct pulling functionality * support for finding default version with no debain flavor * add working python versions * whitespace * added comments explaining the supported version logic, and fixed a statement to ensure that stretch images check for correct dotnet metadata * add preview 7 * addressed PR comments by deleting un-needed method and adding comment
2022-08-15 20:35:32 +03:00
sdkStorageAccountUrl="$ORYX_SDK_STORAGE_BASE_URL"
sasToken=""
if [ -z "$sdkStorageAccountUrl" ]; then
sdkStorageAccountUrl=$PRIVATE_STAGING_SDK_STORAGE_BASE_URL
fi
if [ "$sdkStorageAccountUrl" == "$PRIVATE_STAGING_SDK_STORAGE_BASE_URL" ]; then
2023-08-23 20:48:10 +03:00
set +x
if [ "$IS_FROM_DYNAMIC_INSTALLATION" = "true" ]; then
# retrieves the token coming from the Dynamic Installation Process.
sasToken=$ORYX_SDK_STORAGE_ACCOUNT_ACCESS_TOKEN
else
# retrieves the token coming from the Dockerfiles.
sasToken="$(cat $ORYX_SDK_STORAGE_ACCOUNT_ACCESS_TOKEN_PATH)"
fi
if [ -z "$sasToken" ]; then
echo "sasToken is empty for $sdkStorageAccountUrl."
echo "sasToken cannot be empty. Please get the valid sasToken."
2023-08-23 20:48:10 +03:00
fi
set -x
echo $sasToken
fi
if [ -z "$debianFlavor" ] || [ "$debianFlavor" == "stretch" ]; then
# Use default sdk file name
fileName="$PLATFORM_NAME-$VERSION.tar.gz"
else
Pauld/1559705 improve cli to detect viable sdks based on debian flavor (#1484) * save point: splitting up versions to build by ostype * restructured and modified the platforms scripts and updated the shared code generator to account for the new versions * updated constants to include ostype change and newer python version * added support for new file structure to the python dockerfiles and publishing from dev to prod sdks * save point, starting to enrich all storage items with version number, and modifying tests for new logic * clean up platforms shell scripts * finish modifying scripts to add version to the metadata, regardless of OSType * beginning to update cli to support pulling only relevant sdks * added constants that relate to the different debian flavors we may see * save point, added to constants yaml file to start adding support for pulling debian flavor sdks * added debian flavor option to the build command, and starting to update tests to be compatible * renamed the vso focal directories to focal scm, and fixed the sdk storage tests * added a number of comments for the second PR and some tests to cover dotnet and node pulling the correct images * added php and python tests for installing based on the available sdks * updated sdk storage provider and platform installer to have bullseye images use buster sdks, since there are currently no bullseye sdks * self reviewed pr: added comments, fixed some bugs and typos, and updated the pipeline scripts to correctly handle stretch images * added default sdk storage metadata to be used for determining versions available * added legacy versions to stretch version directories, so that the supported md file will contain the best information * updated shared code generator to allow for the legacy versions text files * update platform installation scripts to enrich the sdks with an updated version metadata name and the OS type * some fixes for generating the platform binaries locally, and a fix for generating the maven binaries * added legacy version metadata to storage constants * updated the metadata names so that they exist in constants file and can be used throughout oryx * saved leftover merge conflict file * removed old default and versions to build files * updated php fpm configuration to be in the constants.yaml file so that we support the generate constants script * updated the debian flavor arg in the python template * fix failing githubaction and vso focal tests * saved file and added comment to version comparer * fixed some spacing and added comments and a todo * updated dotnet runtime version metadata to be backwards compatible * use version info from elsewhere in oryx to streamline version comparing * pr feedback, using constants during platform installation and sdk storage provider, and trimming whitespace from version files * pr feedback: use constants for file names and renamed the new sdk versions metadata to be consistent * limit bullseye sdks we push to storage to the ones that we know will be used by bullseye * regenerated constants with updated bullseye versions, and removed extra logic in VersionInfo * include all defaultVersion.txt files in the upload * fixed spacing for vsts pipeline * updated the maven base url to point to a source that contains legacy versions * fixed php version sha * use correct get pip url when version 3.6 and stretch * add bullseye maven job * added support to still build php 7.2 binaries * allow enough time for php to generate and upload all sdks * give php jobs 24 hours to run, as they have not been able to generate all versions in the given time * updated python sdk generation to use the correct stretch buildpack for non-3.10 or greater versions * updated logic so that python version 3.10 and above will have the correct prerequisites built * updated common script to ignore whitespace differently * readded deleted line and ran generate constants * Pauld/1559705 PR2 cleanup and utilize bullseye images (#1497) * initial pass at adding support for bullseye by resolving the PR2 todos * allow build * added test for php default versions * added dotnetcore and python tests for invalid versions * added more tests for correct pulling functionality * support for finding default version with no debain flavor * add working python versions * whitespace * added comments explaining the supported version logic, and fixed a statement to ensure that stretch images check for correct dotnet metadata * add preview 7 * addressed PR comments by deleting un-needed method and adding comment
2022-08-15 20:35:32 +03:00
fileName="$PLATFORM_NAME-$debianFlavor-$VERSION.tar.gz"
fi
platformDir="/opt/$PLATFORM_NAME"
if [ -z "$targetDir" ]; then
targetDir="$platformDir/$VERSION"
fi
START_TIME=$SECONDS
set +x
downloadFileAndVerifyChecksum $PLATFORM_NAME $VERSION $fileName $sdkStorageAccountUrl $sasToken
set -x
ELAPSED_TIME=$(($SECONDS - $START_TIME))
echo "Downloaded and verified checksum in $ELAPSED_TIME sec(s)."
echo "Extracting..."
START_TIME=$SECONDS
mkdir -p "$targetDir"
tar -xzf $fileName -C "$targetDir"
rm -f "$fileName"
ELAPSED_TIME=$(($SECONDS - $START_TIME))
echo "Extracted contents in $ELAPSED_TIME sec(s)."
if [ "$PLATFORM_NAME" == "python" ]
then
[ -d "/opt/python/$VERSION" ] && echo /opt/python/$VERSION/lib >> /etc/ld.so.conf.d/python.conf
ldconfig
fi
if [ "$createLinks" != "false" ]; then
# Create a link : major.minor => major.minor.patch
cd "$platformDir"
IFS='.' read -ra VERSION_PARTS <<< "$VERSION"
MAJOR_MINOR="${VERSION_PARTS[0]}.${VERSION_PARTS[1]}"
echo
echo "Created link from $MAJOR_MINOR to $VERSION"
ln -sfn "$VERSION" "$MAJOR_MINOR"
fi