diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-05-02 10:40:49 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-05-06 11:44:31 +0300 |
commit | a62176db357c3b66b02f01a4271ecda5bb2db35c (patch) | |
tree | 46a7793189f2c48ae4d6fa3472e6019a2688dc74 /_support | |
parent | 44b15190d40cfe6aeb27e8751dd646ac44db379d (diff) |
tools: Move `noticegen` into top-level `tools/` directory
Move the `noticegen` tool into the top-level `tools/` directory so that
all of our custom build tools are in one place. This also makes its
sources discoverable for our formatter.
Diffstat (limited to '_support')
-rw-r--r-- | _support/noticegen/notice.template | 60 | ||||
-rw-r--r-- | _support/noticegen/noticegen.go | 87 |
2 files changed, 0 insertions, 147 deletions
diff --git a/_support/noticegen/notice.template b/_support/noticegen/notice.template deleted file mode 100644 index 28484c208..000000000 --- a/_support/noticegen/notice.template +++ /dev/null @@ -1,60 +0,0 @@ -The following components are included in Gitaly: - -LICENSE - go -Copyright (c) 2009 The Go Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -PATENTS - go -Additional IP Rights Grant (Patents) - -"This implementation" means the copyrightable works distributed by -Google as part of the Go project. - -Google hereby grants to You a perpetual, worldwide, non-exclusive, -no-charge, royalty-free, irrevocable (except as stated in this section) -patent license to make, have made, use, offer to sell, sell, import, -transfer and otherwise run, modify and propagate the contents of this -implementation of Go, where such license applies only to those patent -claims, both currently owned or controlled by Google and acquired in -the future, licensable by Google that are necessarily infringed by this -implementation of Go. This grant does not include claims that would be -infringed only as a consequence of further modification of this -implementation. If you or your agent or exclusive licensee institute or -order or agree to the institution of patent litigation against any -entity (including a cross-claim or counterclaim in a lawsuit) alleging -that this implementation of Go or any code incorporated within this -implementation of Go constitutes direct or contributory patent -infringement, or inducement of patent infringement, then any patent -rights granted to you under this License for this implementation of Go -shall terminate as of the date such litigation is filed. - -{{ range . }} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -{{ .Filename }} - {{ .Path }} -{{ .Text }} -{{- end }} diff --git a/_support/noticegen/noticegen.go b/_support/noticegen/noticegen.go deleted file mode 100644 index 0d54f221a..000000000 --- a/_support/noticegen/noticegen.go +++ /dev/null @@ -1,87 +0,0 @@ -package main - -import ( - "encoding/json" - "flag" - "log" - "os" - "os/exec" - "path/filepath" - "text/template" -) - -var ( - sourcePath = flag.String("source", "", "directory path containing license files") - tmplPath = flag.String("template", "", "file path to notice template") -) - -type license struct { - Filename string - Path string - Text string -} - -func main() { - flag.Parse() - - if *sourcePath == "" || *tmplPath == "" { - log.Fatal("must provide flags 'source' and 'template'") - } - - tmpl, err := template.ParseFiles(*tmplPath) - if err != nil { - log.Fatal(err) - } - - var licenses []license - - data, err := exec.Command("go", "mod", "edit", "-json").Output() - if err != nil { - log.Fatal(err) - } - var modInfo = struct { - Module struct { - Path string - } - }{} - if err := json.Unmarshal(data, &modInfo); err != nil { - log.Fatal(err) - } - - if err := filepath.Walk(*sourcePath, func(path string, info os.FileInfo, err error) error { - if err != nil { - return err - } - if info.IsDir() { - return nil - } - - p, err := filepath.Rel(*sourcePath, filepath.Dir(path)) - if err != nil { - log.Fatal(err) - } - - if p == modInfo.Module.Path { - return nil - } - - t, err := os.ReadFile(path) - if err != nil { - log.Fatal(err) - } - - licenses = append(licenses, license{ - Filename: filepath.Base(path), - Path: p, - Text: string(t), - }) - - return nil - }); err != nil { - log.Fatal(err) - } - - if err := tmpl.Execute(os.Stdout, licenses); err != nil { - log.Fatal(err) - } -} |