tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

deps.sh (3125B)


      1 #!/usr/bin/env bash
      2 # Copyright (c) the JPEG XL Project Authors. All rights reserved.
      3 #
      4 # Use of this source code is governed by a BSD-style
      5 # license that can be found in the LICENSE file.
      6 
      7 # This file downloads the dependencies needed to build JPEG XL into third_party.
      8 # These dependencies are normally pulled by git.
      9 
     10 set -eu
     11 
     12 SELF=$(realpath "$0")
     13 MYDIR=$(dirname "${SELF}")
     14 
     15 # Git revisions we use for the given submodules. Update these whenever you
     16 # update a git submodule.
     17 TESTDATA="873045a9c42ed60721756e26e2a6b32e17415205"
     18 THIRD_PARTY_BROTLI="36533a866ed1ca4b75cf049f4521e4ec5fe24727"
     19 THIRD_PARTY_GOOGLETEST="58d77fa8070e8cec2dc1ed015d66b454c8d78850"
     20 THIRD_PARTY_HIGHWAY="457c891775a7397bdb0376bb1031e6e027af1c48"
     21 THIRD_PARTY_SKCMS="42030a771244ba67f86b1c1c76a6493f873c5f91"
     22 THIRD_PARTY_SJPEG="e5ab13008bb214deb66d5f3e17ca2f8dbff150bf"
     23 THIRD_PARTY_ZLIB="51b7f2abdade71cd9bb0e7a373ef2610ec6f9daf" # v1.3.1
     24 THIRD_PARTY_LIBPNG="f135775ad4e5d4408d2e12ffcc71bb36e6b48551" # v1.6.40
     25 THIRD_PARTY_LIBJPEG_TURBO="8ecba3647edb6dd940463fedf38ca33a8e2a73d1" # 2.1.5.1
     26 
     27 # Download the target revision from GitHub.
     28 download_github() {
     29  local path="$1"
     30  local project="$2"
     31 
     32  local varname=`echo "$path" | tr '[:lower:]' '[:upper:]'`
     33  varname="${varname//[\/-]/_}"
     34  local sha
     35  eval "sha=\${${varname}}"
     36 
     37  local down_dir="${MYDIR}/downloads"
     38  local local_fn="${down_dir}/${sha}.tar.gz"
     39  if [[ -e "${local_fn}" && -d "${MYDIR}/${path}" ]]; then
     40    echo "${path} already up to date." >&2
     41    return 0
     42  fi
     43 
     44  local url
     45  local strip_components=0
     46  if [[ "${project:0:4}" == "http" ]]; then
     47    # "project" is a googlesource.com base url.
     48    url="${project}${sha}.tar.gz"
     49  else
     50    # GitHub files have a top-level directory
     51    strip_components=1
     52    url="https://github.com/${project}/tarball/${sha}"
     53  fi
     54 
     55  echo "Downloading ${path} version ${sha}..." >&2
     56  mkdir -p "${down_dir}"
     57  curl -L --show-error -o "${local_fn}.tmp" "${url}"
     58  mkdir -p "${MYDIR}/${path}"
     59  tar -zxf "${local_fn}.tmp" -C "${MYDIR}/${path}" \
     60    --strip-components="${strip_components}"
     61  mv "${local_fn}.tmp" "${local_fn}"
     62 }
     63 
     64 is_git_repository() {
     65    local dir="$1"
     66    local toplevel=$(git rev-parse --show-toplevel)
     67 
     68    [[ "${dir}" == "${toplevel}" ]]
     69 }
     70 
     71 
     72 main() {
     73  if is_git_repository "${MYDIR}"; then
     74    cat >&2 <<EOF
     75 Current directory is a git repository, downloading dependencies via git:
     76 
     77  git submodule update --init --recursive
     78 
     79 EOF
     80    git -C "${MYDIR}" submodule update --init --recursive --depth 1 --recommend-shallow
     81    return 0
     82  fi
     83 
     84  # Sources downloaded from a tarball.
     85  download_github testdata libjxl/testdata
     86  download_github third_party/brotli google/brotli
     87  download_github third_party/googletest google/googletest
     88  download_github third_party/highway google/highway
     89  download_github third_party/sjpeg webmproject/sjpeg
     90  download_github third_party/skcms \
     91    "https://skia.googlesource.com/skcms/+archive/"
     92  download_github third_party/zlib madler/zlib
     93  download_github third_party/libpng glennrp/libpng
     94  download_github third_party/libjpeg-turbo libjpeg-turbo/libjpeg-turbo
     95  echo "Done."
     96 }
     97 
     98 main "$@"