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