Debian Codegraph @

download_vendor

raw symbols SCIP
1 #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash
2 # Simple script to download the artifacts from the GitLab CI runner
3 # - Prerequisites: `curl` `unzip`
4 # - Optionally: set `MZNARCH` variable to select
5 # - Run as `./download_vendor` or `bash download_vendor`
6 # - Rerun to update vendor packages (remove `./vendor` directory to force redownload)
7
8 set -e # abort if any command fails
9
10 BRANCH="master" # branch of the vendor repository
11
12 if [scip-shell system . . `[`. -z ${MZNARCH+x} ]; then
13 if [[ "$OSTYPE" == "linux-gnu"* ]]; then
14 MZNARCH="linux"
15 elif [[ "$OSTYPE" == "darwin"* ]]; then
16 MZNARCH="osx"
17 elif [[ "$OSTYPE" == "cygwin" ]]; then
18 MZNARCH="win64"
19 elif [[ "$OSTYPE" == "msys" ]]; then
20 MZNARCH="win64"
21 elif [[ "$OSTYPE" == "win32" ]]; then
22 MZNARCH="win64"
23 else
24 echoscip-shell system . . echo. "Unable to determine operating system"
25 exit 1
26 fi
27 fi
28
29 JOB="vendor:${MZNARCH}"
30
31 # -- Download JSON file with newest dependencies version
32 curlscip-shell system . . curl. --silent -o "_newversion.json" --location "https://gitlab.com/api/v4/projects/minizinc%2Fminizinc-vendor/pipelines?ref=${BRANCH}&per_page=1&page=1"
33 echoscip-shell system . . echo. $JOB >> _newversion.json
34 # --- Compare with current downloaded version (if exists)
35 if [scip-shell system . . `[`. ! -f "vendor/version.json" ] || ! cmpscip-shell system . . cmp. --silent "vendor/version.json" "_newversion.json"; then
36 echoscip-shell system . . echo. -n "Updating depencencies..."
37 # --- Remove old version of the dependencies
38 rmscip-shell system . . rm. -rf vendor/
39 # --- Download new version of dependencies
40 curlscip-shell system . . curl. --silent -o "artifact.zip" --location "https://gitlab.com/api/v4/projects/minizinc%2Fminizinc-vendor/jobs/artifacts/${BRANCH}/download?job=${JOB}"
41 # --- Extract new version of dependencies
42 unzip -q "artifact.zip"
43 # --- Update version of dependencies
44 mvscip-shell system . . mv. "_newversion.json" "vendor/version.json"
45 rmscip-shell system . . rm. "artifact.zip"
46 echoscip-shell system . . echo. " COMPLETE"
47 else
48 # --- Nothing to do
49 # --- Clear temporary file
50 rmscip-shell system . . rm. "_newversion.json"
51 echoscip-shell system . . echo. "Dependencies already up-to-date"
52 fi