Debian Codegraph @

gopls/internal/licenses/gen-licenses.sh

raw symbols SCIP
1 #!/bin/bash -eu
2
3 # Copyright 2020 The Go Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style
5 # license that can be found in the LICENSE file.
6
7 set -o pipefail
8
9 output=$1
10 tempfile=$(mktemp)
11 cd $(dirname $0)
12
13 cat > $tempfile <<END
14 // Copyright 2020 The Go Authors. All rights reserved.
15 // Use of this source code is governed by a BSD-style
16 // license that can be found in the LICENSE file.
17
18 //go:generate ./gen-licenses.sh licenses.go
19 package licenses
20
21 const Text = \`
22 END
23
24 # List all the modules gopls depends on, except other golang.org modules, which
25 # are known to have the same license.
26 mods=$(go list -deps -f '{{with .Module}}{{.Path}}{{end}}' golang.org/x/tools/gopls | sort -u | grep -v golang.org)
27 for mod in $mods; do
28 # Find the license file, either LICENSE, COPYING, or LICENSE.md and add it to the result.
29 dir=$(go list -m -f {{.Dir}} $mod)
30 license=$(ls -1 $dir | grep -E -i '^(LICENSE|LICENSE.md|COPYING)?$')
31 echo "-- $mod $license --" >> $tempfile
32 echo >> $tempfile
33 sed 's/^-- / &/' $dir/$license >> $tempfile
34 echo >> $tempfile
35 done
36
37 echo "\`" >> $tempfile
38 mv $tempfile $output