windows-setup.sh (5264B)
1 #!/bin/bash 2 # This Source Code Form is subject to the terms of the Mozilla Public 3 # License, v. 2.0. If a copy of the MPL was not distributed with this 4 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 5 6 set -vex 7 8 . ./taskcluster/docker/updatebot/updatebot-version.sh # Get UPDATEBOT_REVISION 9 10 HOME=$(python3 -c "import os;print(os.path.expanduser('~'))") 11 export HOME 12 GECKO_PATH="$PWD" 13 UPDATEBOT_PATH="$MOZ_FETCHES_DIR/updatebot" 14 15 # MOZ_FETCHES_DIR is in Z:/ format. When we update the PATH we need to use 16 # /z/ format. Fortunately, we can translate them like so: 17 cd "$MOZ_FETCHES_DIR" 18 MOZ_FETCHES_PATH="$PWD" 19 20 ######################################################### 21 # Install dependencies 22 23 # Move depot_tools 24 cd "$MOZ_FETCHES_DIR" 25 mv depot_tools.git depot_tools 26 27 28 # Generating a new version of the preloaded depot_tools download can be done by: 29 # 1) Running the task, uncommenting the variable assignment below, uncommenting the 30 # _GENERATE_DEPOT_TOOLS_BINARIES_ section in taskcluster/kinds/updatebot/kind.yml, 31 # and ensuring that an angle update will actually take place (so it downloads the depot_tools) 32 # 2) Downloading and sanity-checking the depot_tools-preloaded-binaries-GIT_HASH-DATE.zip artifact 33 # 3) Adding it to tooltool 34 # 4) Updating the updatebot manifest 35 # Note that even for the same git revision the downloaded tools can change, so they are tagged 36 # with both the git hash and the date it was generated 37 38 # export GENERATE_DEPOT_TOOLS_BINARIES=1 39 40 if test -n "$GENERATE_DEPOT_TOOLS_BINARIES"; then 41 cp -r depot_tools depot_tools-from-git 42 fi 43 44 # Git is at /c/Program Files/Git/cmd/git.exe 45 # It's in PATH for this script (confusingly) but not in PATH so we need to add it 46 export PATH="/c/Program Files/Git/cmd:$PATH" 47 48 # php & arcanist 49 if [ -n "$TOOLTOOL_MANIFEST" ]; then 50 . "$GECKO_PATH/taskcluster/scripts/misc/tooltool-download.sh" 51 fi 52 53 cp "$MOZ_FETCHES_DIR/vcruntime140.dll" "$MOZ_FETCHES_DIR/php-win" 54 cp "$GECKO_PATH/taskcluster/docker/updatebot/windows-php.ini" "$MOZ_FETCHES_DIR/php-win/php.ini" 55 56 cd "$MOZ_FETCHES_DIR/arcanist" 57 patch -p1 < "$GECKO_PATH/taskcluster/docker/updatebot/arcanist_windows_stream.patch" 58 patch -p1 < "$GECKO_PATH/taskcluster/docker/updatebot/arcanist_patch_size.patch" 59 cd "$MOZ_FETCHES_DIR" 60 61 export PATH="$MOZ_FETCHES_PATH/php-win:$PATH" 62 export PATH="$MOZ_FETCHES_PATH/arcanist/bin:$PATH" 63 64 # get Updatebot 65 cd "$MOZ_FETCHES_DIR" 66 git clone https://github.com/mozilla-services/updatebot.git 67 cd updatebot 68 git checkout "$UPDATEBOT_REVISION" 69 70 # base python needs 71 python3 -m pip install --no-warn-script-location --user -U pip 72 python3 -m pip install --no-warn-script-location --user poetry wheel requests setuptools 73 74 # updatebot dependencies 75 cd "$UPDATEBOT_PATH" 76 python3 -m poetry install 77 78 # taskcluster secrets and writing out localconfig 79 cd "$GECKO_PATH" 80 python3 ./taskcluster/docker/updatebot/run.py "$GECKO_PATH" "$UPDATEBOT_PATH" "$MOZ_FETCHES_PATH" 81 82 # mercurial configuration 83 cp "$GECKO_PATH/taskcluster/docker/updatebot/hgrc" "$HOME/.hgrc" 84 # Windows is not happy with $HOME in the hgrc so we need to do a hack to replace it 85 # with the actual value 86 ( echo "cat <<EOF" ; cat "$HOME/.hgrc" ) | sh > tmp 87 mv tmp "$HOME/.hgrc" 88 89 # ssh known hosts 90 cp "$GECKO_PATH/taskcluster/docker/push-to-try/known_hosts" "$HOME/ssh_known_hosts" 91 92 ######################################################### 93 # Run it 94 export PYTHONIOENCODING=utf8 95 export PYTHONUNBUFFERED=1 96 97 cd "$UPDATEBOT_PATH" 98 python3 -m poetry run python3 ./automation.py 99 100 ######################################################### 101 if test -n "$GENERATE_DEPOT_TOOLS_BINARIES"; then 102 # Artifacts 103 104 cd "$MOZ_FETCHES_PATH" 105 mv depot_tools depot_tools-from-tc 106 107 # Clean out unneeded files 108 # Need to use cmd because for some reason rm from bash throws 'Access Denied' 109 cmd '/c for /d /r %i in (*__pycache__) do rmdir /s /q %i' 110 rm -rf depot_tools-from-git/.git || true 111 112 # Delete the files that are already in git 113 find depot_tools-from-git -mindepth 1 -maxdepth 1 | sed s/depot_tools-from-git/depot_tools-from-tc/ | while read -r d; do rm -rf "$d"; done 114 115 # Make the artifact 116 rm -rf depot_tools-preloaded-binaries #remove it if it existed (i.e. we probably have one from tooltool already) 117 mv depot_tools-from-tc depot_tools-preloaded-binaries 118 119 # zip can't add symbolic links, and exits with an error code. || true avoids a script crash 120 zip -r depot_tools-preloaded-binaries.zip depot_tools-preloaded-binaries/ || true 121 122 # Convoluted way to get the git hash, because we don't have a .git directory 123 # Adding extra print statements just in case we need to debug it 124 GIT_HASH=$(grep depot_tools -A 1 "$GECKO_PATH/taskcluster/kinds/fetch/updatebot.yml" | tee /dev/tty | grep revision | tee /dev/tty | awk -F': *' '{print $2}' | tee /dev/tty) 125 DATE=$(date -I) 126 mv depot_tools-preloaded-binaries.zip "depot_tools-preloaded-binaries-$GIT_HASH-$DATE.zip" 127 128 # Put the artifact into the directory we will look for it 129 mkdir -p "$GECKO_PATH/obj-build/depot_tools" || true 130 mv "depot_tools-preloaded-binaries-$GIT_HASH-$DATE.zip" "$GECKO_PATH/obj-build/depot_tools" 131 fi 132 133 ######################################################### 134 echo "Killing SQL Proxy" 135 taskkill -f -im cloud_sql_proxy.exe || true