From 4a82672a1f7b0e08c2e8bd7d69b3856268698b4d Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 5 Aug 2022 14:38:45 -0500 Subject: [PATCH] added artifactory as well as new libraries for download Signed-off-by: Matt Bruce --- VDSSample.xcodeproj/project.pbxproj | 164 ++++++++++++++++++ .../xcschemes/xcschememanagement.plist | 10 ++ .../AppIcon.appiconset/Contents.json | 5 + .../Artifactory/Artifactory.sh | 81 +++++++++ .../Artifactory/ArtifactoryItems.txt | 5 + .../Artifactory/DownloadArtifactoryItems.sh | 79 +++++++++ dependency.txt | 2 + update.sh | 44 +++++ 8 files changed, 390 insertions(+) create mode 100755 VDSSample/Supporting Files/Artifactory/Artifactory.sh create mode 100644 VDSSample/Supporting Files/Artifactory/ArtifactoryItems.txt create mode 100644 VDSSample/Supporting Files/Artifactory/DownloadArtifactoryItems.sh create mode 100644 dependency.txt create mode 100755 update.sh diff --git a/VDSSample.xcodeproj/project.pbxproj b/VDSSample.xcodeproj/project.pbxproj index 57d539f..29a67ec 100644 --- a/VDSSample.xcodeproj/project.pbxproj +++ b/VDSSample.xcodeproj/project.pbxproj @@ -6,6 +6,31 @@ objectVersion = 55; objects = { +/* Begin PBXAggregateTarget section */ + EAF7F0BE289DA16000B287F5 /* UpdateDependency */ = { + isa = PBXAggregateTarget; + buildConfigurationList = EAF7F0BF289DA16000B287F5 /* Build configuration list for PBXAggregateTarget "UpdateDependency" */; + buildPhases = ( + EAF7F0C2289DA16900B287F5 /* ShellScript */, + ); + dependencies = ( + ); + name = UpdateDependency; + productName = UpdateDependencies; + }; + EAF7F0CE289DA44300B287F5 /* Artifactory */ = { + isa = PBXAggregateTarget; + buildConfigurationList = EAF7F0CF289DA44300B287F5 /* Build configuration list for PBXAggregateTarget "Artifactory" */; + buildPhases = ( + EAF7F0D2289DA44700B287F5 /* ShellScript */, + ); + dependencies = ( + ); + name = Artifactory; + productName = Artifactory; + }; +/* End PBXAggregateTarget section */ + /* Begin PBXBuildFile section */ EA3C3B9D289966EF000CA526 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3C3B9C289966EF000CA526 /* AppDelegate.swift */; }; EA3C3B9F289966EF000CA526 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3C3B9E289966EF000CA526 /* SceneDelegate.swift */; }; @@ -26,6 +51,13 @@ EAF7F07C2899698800B287F5 /* Components.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = EAF7F07A2899698800B287F5 /* Components.storyboard */; }; EAF7F07D2899698800B287F5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = EAF7F07B2899698800B287F5 /* Assets.xcassets */; }; EAF7F09C2899B92400B287F5 /* CheckboxViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF7F09B2899B92400B287F5 /* CheckboxViewController.swift */; }; + EAF7F0CA289DA24F00B287F5 /* ArtifactoryItems.txt in Resources */ = {isa = PBXBuildFile; fileRef = EAF7F0C5289DA24F00B287F5 /* ArtifactoryItems.txt */; }; + EAF7F0CC289DA24F00B287F5 /* DownloadArtifactoryItems.sh in Resources */ = {isa = PBXBuildFile; fileRef = EAF7F0C8289DA24F00B287F5 /* DownloadArtifactoryItems.sh */; }; + EAF7F0CD289DA24F00B287F5 /* Artifactory.sh in Resources */ = {isa = PBXBuildFile; fileRef = EAF7F0C9289DA24F00B287F5 /* Artifactory.sh */; }; + EAF7F0D5289DA4A900B287F5 /* VDSLayoutTokens.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = EAF7F0D3289DA4A900B287F5 /* VDSLayoutTokens.xcframework */; }; + EAF7F0D6289DA4A900B287F5 /* VDSLayoutTokens.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = EAF7F0D3289DA4A900B287F5 /* VDSLayoutTokens.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + EAF7F0D7289DA4A900B287F5 /* VDSAccessibilityTokens.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = EAF7F0D4289DA4A900B287F5 /* VDSAccessibilityTokens.xcframework */; }; + EAF7F0D8289DA4A900B287F5 /* VDSAccessibilityTokens.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = EAF7F0D4289DA4A900B287F5 /* VDSAccessibilityTokens.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -37,7 +69,9 @@ files = ( EA3C3BC1289968A0000CA526 /* VDSFormControlsTokens.xcframework in Embed Frameworks */, EA3C3BBF289968A0000CA526 /* VDSTypographyTokens.xcframework in Embed Frameworks */, + EAF7F0D8289DA4A900B287F5 /* VDSAccessibilityTokens.xcframework in Embed Frameworks */, EA3C3BC5289968B1000CA526 /* VDS.framework in Embed Frameworks */, + EAF7F0D6289DA4A900B287F5 /* VDSLayoutTokens.xcframework in Embed Frameworks */, EA3C3BBD289968A0000CA526 /* VDSColorTokens.xcframework in Embed Frameworks */, ); name = "Embed Frameworks"; @@ -63,6 +97,11 @@ EAF7F07A2899698800B287F5 /* Components.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Components.storyboard; sourceTree = ""; }; EAF7F07B2899698800B287F5 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; EAF7F09B2899B92400B287F5 /* CheckboxViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckboxViewController.swift; sourceTree = ""; }; + EAF7F0C5289DA24F00B287F5 /* ArtifactoryItems.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ArtifactoryItems.txt; sourceTree = ""; }; + EAF7F0C8289DA24F00B287F5 /* DownloadArtifactoryItems.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = DownloadArtifactoryItems.sh; sourceTree = ""; }; + EAF7F0C9289DA24F00B287F5 /* Artifactory.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = Artifactory.sh; sourceTree = ""; }; + EAF7F0D3289DA4A900B287F5 /* VDSLayoutTokens.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDSLayoutTokens.xcframework; path = ../SharedFrameworks/VDSLayoutTokens.xcframework; sourceTree = ""; }; + EAF7F0D4289DA4A900B287F5 /* VDSAccessibilityTokens.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDSAccessibilityTokens.xcframework; path = ../SharedFrameworks/VDSAccessibilityTokens.xcframework; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -72,7 +111,9 @@ files = ( EA3C3BC0289968A0000CA526 /* VDSFormControlsTokens.xcframework in Frameworks */, EA3C3BBE289968A0000CA526 /* VDSTypographyTokens.xcframework in Frameworks */, + EAF7F0D7289DA4A900B287F5 /* VDSAccessibilityTokens.xcframework in Frameworks */, EA3C3BC4289968B1000CA526 /* VDS.framework in Frameworks */, + EAF7F0D5289DA4A900B287F5 /* VDSLayoutTokens.xcframework in Frameworks */, EA3C3BBC289968A0000CA526 /* VDSColorTokens.xcframework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -100,6 +141,7 @@ EA3C3B9B289966EF000CA526 /* VDSSample */ = { isa = PBXGroup; children = ( + EAF7F0C3289DA24F00B287F5 /* Supporting Files */, EAF7F0792899698800B287F5 /* Resources */, EAF7F07E28996A0700B287F5 /* Protocols */, EAF7F07F28996A1900B287F5 /* ViewControllers */, @@ -113,6 +155,8 @@ EA3C3BB8289968A0000CA526 /* Frameworks */ = { isa = PBXGroup; children = ( + EAF7F0D4289DA4A900B287F5 /* VDSAccessibilityTokens.xcframework */, + EAF7F0D3289DA4A900B287F5 /* VDSLayoutTokens.xcframework */, EA3C3BC3289968B1000CA526 /* VDS.framework */, EA3C3BB9289968A0000CA526 /* VDSColorTokens.xcframework */, EA3C3BBB289968A0000CA526 /* VDSFormControlsTokens.xcframework */, @@ -151,6 +195,24 @@ path = ViewControllers; sourceTree = ""; }; + EAF7F0C3289DA24F00B287F5 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + EAF7F0C4289DA24F00B287F5 /* Artifactory */, + ); + path = "Supporting Files"; + sourceTree = ""; + }; + EAF7F0C4289DA24F00B287F5 /* Artifactory */ = { + isa = PBXGroup; + children = ( + EAF7F0C5289DA24F00B287F5 /* ArtifactoryItems.txt */, + EAF7F0C8289DA24F00B287F5 /* DownloadArtifactoryItems.sh */, + EAF7F0C9289DA24F00B287F5 /* Artifactory.sh */, + ); + path = Artifactory; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -185,6 +247,12 @@ EA3C3B98289966EF000CA526 = { CreatedOnToolsVersion = 13.4.1; }; + EAF7F0BE289DA16000B287F5 = { + CreatedOnToolsVersion = 13.4.1; + }; + EAF7F0CE289DA44300B287F5 = { + CreatedOnToolsVersion = 13.4.1; + }; }; }; buildConfigurationList = EA3C3B94289966EF000CA526 /* Build configuration list for PBXProject "VDSSample" */; @@ -201,6 +269,8 @@ projectRoot = ""; targets = ( EA3C3B98289966EF000CA526 /* VDSSample */, + EAF7F0BE289DA16000B287F5 /* UpdateDependency */, + EAF7F0CE289DA44300B287F5 /* Artifactory */, ); }; /* End PBXProject section */ @@ -214,11 +284,51 @@ EAF7F07C2899698800B287F5 /* Components.storyboard in Resources */, EAF7F07D2899698800B287F5 /* Assets.xcassets in Resources */, EA3C3BA4289966EF000CA526 /* Main.storyboard in Resources */, + EAF7F0CC289DA24F00B287F5 /* DownloadArtifactoryItems.sh in Resources */, + EAF7F0CA289DA24F00B287F5 /* ArtifactoryItems.txt in Resources */, + EAF7F0CD289DA24F00B287F5 /* Artifactory.sh in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXResourcesBuildPhase section */ +/* Begin PBXShellScriptBuildPhase section */ + EAF7F0C2289DA16900B287F5 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "#!/bin/bash\n\ncd ../\nsh update.sh\n"; + }; + EAF7F0D2289DA44700B287F5 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "cd \"${PROJECT_DIR}/VDSSample/Supporting Files/Artifactory\"\nsh DownloadArtifactoryItems.sh\n"; + }; +/* End PBXShellScriptBuildPhase section */ + /* Begin PBXSourcesBuildPhase section */ EA3C3B95289966EF000CA526 /* Sources */ = { isa = PBXSourcesBuildPhase; @@ -428,6 +538,42 @@ }; name = Release; }; + EAF7F0C0289DA16000B287F5 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = FCMA4QKS77; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + EAF7F0C1289DA16000B287F5 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = FCMA4QKS77; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; + EAF7F0D0289DA44300B287F5 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = FCMA4QKS77; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + EAF7F0D1289DA44300B287F5 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = FCMA4QKS77; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -449,6 +595,24 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + EAF7F0BF289DA16000B287F5 /* Build configuration list for PBXAggregateTarget "UpdateDependency" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + EAF7F0C0289DA16000B287F5 /* Debug */, + EAF7F0C1289DA16000B287F5 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + EAF7F0CF289DA44300B287F5 /* Build configuration list for PBXAggregateTarget "Artifactory" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + EAF7F0D0289DA44300B287F5 /* Debug */, + EAF7F0D1289DA44300B287F5 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; /* End XCConfigurationList section */ }; rootObject = EA3C3B91289966EF000CA526 /* Project object */; diff --git a/VDSSample.xcodeproj/xcuserdata/mattbruce.xcuserdatad/xcschemes/xcschememanagement.plist b/VDSSample.xcodeproj/xcuserdata/mattbruce.xcuserdatad/xcschemes/xcschememanagement.plist index fef7a06..fad134e 100644 --- a/VDSSample.xcodeproj/xcuserdata/mattbruce.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/VDSSample.xcodeproj/xcuserdata/mattbruce.xcuserdatad/xcschemes/xcschememanagement.plist @@ -4,6 +4,16 @@ SchemeUserState + Artifactory.xcscheme_^#shared#^_ + + orderHint + 8 + + UpdateDependencies.xcscheme_^#shared#^_ + + orderHint + 6 + VDSSample.xcscheme_^#shared#^_ orderHint diff --git a/VDSSample/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json b/VDSSample/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json index 5a3257a..9221b9b 100644 --- a/VDSSample/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json +++ b/VDSSample/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -70,6 +70,11 @@ "scale" : "2x", "size" : "40x40" }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "76x76" + }, { "idiom" : "ipad", "scale" : "2x", diff --git a/VDSSample/Supporting Files/Artifactory/Artifactory.sh b/VDSSample/Supporting Files/Artifactory/Artifactory.sh new file mode 100755 index 0000000..6ad5af6 --- /dev/null +++ b/VDSSample/Supporting Files/Artifactory/Artifactory.sh @@ -0,0 +1,81 @@ +#!/bin/bash + +#First arg should be the local path, second arg should be the remote path. +VERSION="2.0" +#Update onces stable +#APITOKEN=AKCp5cbwXBA2Rarq6WagmFFxQxcxsARGxSq5g1H8NaGm7837KTgwdWPqsp7FdgRa13B7AcpGN +#URL=https://oneartifactorycloud.verizon.com/artifactory + +APITOKEN=AKCp5ZmHP8B1dkLtdSh23bMcWHtrWzoB3SfhoCNpEC5e3dKNhiKsn8TPMZQafXzm2qkeXFXE6 +URL=https://oneartifactoryprod.verizon.com/artifactory + +LOCALPATH="${1}" +REMOTEPATH="${2}" +LOGFILE=$3 +LOCALDIR=$(dirname "${LOCALPATH}") +LOCALBASE=$(basename "${LOCALPATH}") +NEWFILEPATH="${LOCALDIR}"/$(basename "${REMOTEPATH}") +VERSIONFILE=./Checksums/"${LOCALBASE}".txt + +if [ -z $LOGFILE ]; then +LOGFILE="/tmp/${LOCALBASE}.txt" +fi + +#first argument is error message. +exit_with_error () { +echo "Error: $1" >> "${LOGFILE}" +if [ -f "${NEWFILEPATH}" ]; then +rm -rf "${NEWFILEPATH}" 2>>"${LOGFILE}" +fi +exit 1 +} + +echo "----------------------------------------------------------" >> $LOGFILE +echo "Logs for ${LOCALBASE}" >> $LOGFILE + +echo -e "Local Target: ${LOCALPATH}" >> $LOGFILE +echo -e "Remote Source: ${REMOTEPATH}" >> $LOGFILE + +if [ -z "$LOCALPATH" ]; then +exit_with_error "Missing local path argument" +fi + +if [ -z "$REMOTEPATH" ]; then +exit_with_error "Missing filename path argument" +fi + +#get local and remote checksums for comparison +echo -e "Getting checksums..." >> $LOGFILE +echo -e "URL: ${URL}/api/storage/${REMOTEPATH}" >> $LOGFILE +JSON=$(curl --header "X-JFrog-Art-Api: ${APITOKEN}" -X GET "${URL}/api/storage/${REMOTEPATH}" 2>>"${LOGFILE}") +CHECKSUM=$(echo "$JSON" | python3 -c 'import sys, json; print(json.load(sys.stdin)["checksums"]["sha1"])') 2>>"${LOGFILE}" +if [[ -z "$CHECKSUM" ]]; then +exit_with_error "No Checksum found in json: ${JSON}" +fi +echo "Remote checksum ${CHECKSUM}" >> "${LOGFILE}" +OLDCHECKSUM=$(cat "${VERSIONFILE}" 2>/dev/null) +echo "Local checksum ${OLDCHECKSUM}" >> "${LOGFILE}" + +#get new framework if no original framework, no local checksum, or remote checksum is different from local. +if [ ! -e "${LOCALPATH}" ] || [ -z "$OLDCHECKSUM" ] || [ "$CHECKSUM" != "$OLDCHECKSUM" ]; then +echo "Downloading..." >> "${LOGFILE}" +echo -e "URL: ${URL}/${REMOTEPATH}" >> $LOGFILE +curl --header "X-JFrog-Art-Api: ${APITOKEN}" -f -X GET "$URL/$REMOTEPATH" --output "${NEWFILEPATH}" 2>>"${LOGFILE}" +if [ $? -eq 0 ] && [ -e "${NEWFILEPATH}" ]; then +echo "Finished Downloading, begin unzip" >> "${LOGFILE}" +unzip -q -o "${NEWFILEPATH}" -d "${LOCALDIR}" 2>>"${LOGFILE}" +if [ $? -eq 0 ]; then +echo "Finished unzipping, remove zip" >> "${LOGFILE}" +rm -rf "${NEWFILEPATH}" 2>>"${LOGFILE}" +echo "Writing new checksum to file" >> "${LOGFILE}" +echo "${CHECKSUM}" > "${VERSIONFILE}" 2>>"${LOGFILE}" +echo "Successfully downloaded and unzipped archive." >> "${LOGFILE}" +else +exit_with_error "Error unzipping" +fi +else +exit_with_error "Failed to download" +fi +else +echo "Successful, No New Version" >> "${LOGFILE}" +fi diff --git a/VDSSample/Supporting Files/Artifactory/ArtifactoryItems.txt b/VDSSample/Supporting Files/Artifactory/ArtifactoryItems.txt new file mode 100644 index 0000000..7529a94 --- /dev/null +++ b/VDSSample/Supporting Files/Artifactory/ArtifactoryItems.txt @@ -0,0 +1,5 @@ +${PROJECT_DIR}/../SharedFrameworks/VDSAccessibilityTokens.xcframework GVJV_VDS_Maven/@vds-tokens/ios/VDSAccessibilityTokens.1.0.7.xcframework.zip +${PROJECT_DIR}/../SharedFrameworks/VDSColorTokens.xcframework GVJV_VDS_Maven/%40vds-tokens/ios/VDSColorTokens.1.0.6.xcframework.zip +${PROJECT_DIR}/../SharedFrameworks/VDSLayoutTokens.xcframework GVJV_VDS_Maven/@vds-tokens/ios/VDSLayoutTokens.1.0.6.xcframework.zip +${PROJECT_DIR}/../SharedFrameworks/VDSFormControlsTokens.xcframework GVJV_VDS_Maven/@vds-tokens/ios/VDSFormControlsTokens.1.0.7.xcframework.zip +${PROJECT_DIR}/../SharedFrameworks/VDSTypographyTokens.xcframework GVJV_VDS_Maven/@vds-tokens/ios/VDSTypographyTokens.2.0.0.xcframework.zip diff --git a/VDSSample/Supporting Files/Artifactory/DownloadArtifactoryItems.sh b/VDSSample/Supporting Files/Artifactory/DownloadArtifactoryItems.sh new file mode 100644 index 0000000..7ab8500 --- /dev/null +++ b/VDSSample/Supporting Files/Artifactory/DownloadArtifactoryItems.sh @@ -0,0 +1,79 @@ +#!/bin/sh + +# DownloadArtifactoryItems.sh +# myverizon +# +# Created by Kyle on 3/2/20. +# Copyright © 2020 Verizon Wireless Inc. All rights reserved. + +ARTIFACTORYITEMS=./ArtifactoryItems.txt +ARTIFACTORY=Artifactory.sh + +update_artifactory_item () { + #echo "Run Artifactory for ${1} from ${2}" + ./${ARTIFACTORY} "${1}" "${2}" +} + +#Loop through items needed to download and download them. +PIDARRAY=() +LOGFILEARRAY=() +while read -r LOCALFILE REMOTEFILE; do + + #for if the directory has a parameter, such as PROJECT_DIR + FILE=$(eval echo ${LOCALFILE}) + LOGFILE="/tmp/$(basename ${FILE}).txt" + rm $LOGFILE 2> /dev/null + touch $LOGFILE + + #download them in parallel and store the PIDS. + update_artifactory_item "${FILE}" $REMOTEFILE $LOGFILE & + PIDARRAY+=($!) + LASTPID=${PIDARRAY[${#PIDARRAY[@]}-1]} + LOGFILEARRAY+=($LOGFILE) + echo "Process ${LASTPID} spawned for ${REMOTEFILE##*/}" + +done < "${ARTIFACTORYITEMS}" + +#wait for all processes to finish and fail if one of them fails. +INDEX=-1 +TOTAL=${#PIDARRAY[@]} +for i in "${PIDARRAY[@]}"; do + + INDEX=$((INDEX + 1)) + LOGFILE=${LOGFILEARRAY[$((INDEX))]} + + echo "\n\n$((INDEX + 1)) / ${TOTAL} (PID: ${i}) " + + # tail the subprocess log + tail -n +1 -f $LOGFILE & + READ_PID=$! + + # wait for subprocess to finish + sleep 0.05 # Allow tail -n +1 to print + wait $i + + # catch any subprocess non-zero status + status=$? + if [[ $status -gt 0 ]]; then + FAILED_PID_STATUS=$status + FAILED_PID=$i + fi + + # kill the running tail, consume the kill output + kill $READ_PID + wait $READ_PID > /dev/null 2>&1 + + # Need proper way to terminate children. + #if [[ -n $FAILED_PID ]] && [[ -n $FAIL_EARLY ]]; then + # echo "\n\nProcess ${FAILED_PID} failed with exit code ${FAILED_PID_STATUS}" + # echo $( ps -o pgid $FAILED_PID | grep [0-9] | tr -d ' ' ) + # kill -9 $(printf '%s ' "${PIDARRAY[@]}") + # exit $FAILED_PID_STATUS + #fi + +done + +if [[ -n $FAILED_PID_STATUS ]]; then + echo "\n\nProcess ${FAILED_PID} failed with exit code ${FAILED_PID_STATUS}" + exit $FAILED_PID_STATUS +fi diff --git a/dependency.txt b/dependency.txt new file mode 100644 index 0000000..7d40cd3 --- /dev/null +++ b/dependency.txt @@ -0,0 +1,2 @@ +vds https://gitlab.verizon.com/BPHV_MIPS/vds_ios.git develop +vds_sample https://gitlab.verizon.com/BPHV_MIPS/vds_ios_sample develop \ No newline at end of file diff --git a/update.sh b/update.sh new file mode 100755 index 0000000..8a9d748 --- /dev/null +++ b/update.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +exitCode=0 +exitCode=$(mktemp) && echo 0 >$exitCode + +handleRepo() { + read repo url branchName + if [ ! -d "$repo" ] || [ ! "$(ls -A $repo)" ] ; then + #clone if the local working copy does not exist (or empty) + printf "\n===== repo:$repo ----> cloning "$repo" at "$url" for branch: "$branchName"\n" + git clone $url -b $branchName + else + #get current branch + cd $repo + currentBranch=$(git symbolic-ref HEAD | sed -e 's/refs\/heads\///g') + printf "\n===== repo:$repo ----> current branch = '$currentBranch'\n" + + if [[ $currentBranch == $branchName ]]; then + printf "\n===== repo:$repo ----> pulling branch: $branchName \n" + git pull + else + git fetch -a + #checkout the brach if the folder is already downloaded + printf "\n===== repo:$repo ----> checkout "$repo" at branch: "$branchName"\n" + git checkout $branchName + if [[ $? == 0 ]]; then + git pull + else + echo "error: branch $branchName does not exist, exit code = 1" + echo 1 >$exitCode + exit 1 + fi + fi + cd .. + fi + printf "\n===== repo:$repo ----> git operation finished" +} + +file="dependency.txt" +grep -vE '^(\s*$|#)' $file | (while read -r line +do echo $line | handleRepo & done +wait +echo "exitCode => $(cat $exitCode)" +exit $(cat $exitCode))