Debian Codegraph @

gopls/internal/licenses/gen-licenses.sh

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/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=$(mktempscip-shell system . . mktemp.)
11 cd $(dirnamescip-shell system . . dirname. $0)
12
13 catscip-shell system . . 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=$(goscip-shell system . . go. list -deps -f '{{with .Module}}{{.Path}}{{end}}' golang.org/x/tools/gopls | sortscip-shell system . . sort. -u | grepscip-shell system . . 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=$(goscip-shell system . . go. list -m -f {{.Dir}} $mod)
30 license=$(lsscip-shell system . . ls. -1 $dir | grepscip-shell system . . grep. -E -i '^(LICENSE|LICENSE.md|COPYING)?$')
31 echoscip-shell system . . echo. "-- $mod $license --" >> $tempfile
32 echoscip-shell system . . echo. >> $tempfile
33 sedscip-shell system . . sed. 's/^-- / &/' $dir/$license >> $tempfile
34 echoscip-shell system . . echo. >> $tempfile
35 done
36
37 echoscip-shell system . . echo. "\`" >> $tempfile
38 mvscip-shell system . . mv. $tempfile $output