1#! /usr/bin/env nix-shell
2#! nix-shell -p python3 dotnet-sdk_3 -i bash
3
4# Run this script to generate deps.nix
5# ./create_deps.sh /path/to/microsoft/python/language/server/source/checkout
6
7SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
8
9if [ -d "$1" ]; then
10 CHECKOUT_PATH="$1"
11else
12 echo "First argument must be a directory, the path to the Microsoft Python Language Server source checkout"
13 exit 1
14fi
15
16# Generate lockfiles in source checkout
17cd $CHECKOUT_PATH/src
18dotnet nuget locals all --clear
19dotnet restore -v normal --no-cache PLS.sln --use-lock-file -r linux-x64
20
21# Use the lockfiles to make a file with two columns: name and version number
22# for all possible package dependencies
23cd $SCRIPTDIR
24echo "" > all_versions.txt
25for lockfile in $(find "$CHECKOUT_PATH" -name packages.lock.json); do
26 echo "Processing lockfile $lockfile"
27 python ./process_lockfile.py "$lockfile" >> all_versions.txt
28done
29# Add extra manually added packages
30cat ./manual_deps.txt >> all_versions.txt
31cat all_versions.txt | sed '/^$/d' | sort | uniq > tmp
32mv tmp all_versions.txt
33
34# Retrieve sha256 hashes for each dependency and format fetchNuGet calls into deps.nix
35./format-deps.sh all_versions.txt > deps.nix
36rm all_versions.txt