diff options
3 files changed, 98 insertions, 0 deletions
diff --git a/recipes-devtools/go-dirhash-native/go-dirhash-native.bb b/recipes-devtools/go-dirhash-native/go-dirhash-native.bb new file mode 100644 index 00000000..64eab48c --- /dev/null +++ b/recipes-devtools/go-dirhash-native/go-dirhash-native.bb | |||
| @@ -0,0 +1,48 @@ | |||
| 1 | SUMMARY = "Go dirhash helper for offline Go module checksum generation" | ||
| 2 | HOMEPAGE = "https://go.googlesource.com/mod" | ||
| 3 | |||
| 4 | LICENSE = "BSD-3-Clause" | ||
| 5 | LIC_FILES_CHKSUM = "file://LICENSE;md5=7998cb338f82d15c0eff93b7004d272a" | ||
| 6 | |||
| 7 | SRC_URI = "git://go.googlesource.com/mod;protocol=https;nobranch=1;rev=f8a9fe217cff893cb67f4acad96a0021c13ee6e7;destsuffix=git/mod \ | ||
| 8 | file://dirhash-helper.go \ | ||
| 9 | file://LICENSE" | ||
| 10 | |||
| 11 | S = "${UNPACKDIR}/git/mod" | ||
| 12 | |||
| 13 | PV = "1.0" | ||
| 14 | |||
| 15 | DEPENDS = "go-native" | ||
| 16 | |||
| 17 | inherit go native | ||
| 18 | |||
| 19 | do_compile() { | ||
| 20 | dirhash_gopath="${WORKDIR}/dirhash-gopath" | ||
| 21 | dirhash_gocache="${WORKDIR}/dirhash-gocache" | ||
| 22 | dirhash_gomodcache="${WORKDIR}/dirhash-gomodcache" | ||
| 23 | |||
| 24 | install -d "${dirhash_gopath}/src/dirhash-helper" | ||
| 25 | install -d "${dirhash_gopath}/src/golang.org/x" | ||
| 26 | |||
| 27 | cp "${UNPACKDIR}/dirhash-helper.go" "${dirhash_gopath}/src/dirhash-helper/main.go" | ||
| 28 | cp -a "${S}" "${dirhash_gopath}/src/golang.org/x/mod" | ||
| 29 | |||
| 30 | bbnote "Building dirhash helper" | ||
| 31 | ( | ||
| 32 | cd "${dirhash_gopath}/src/dirhash-helper" && \ | ||
| 33 | GOPATH="${dirhash_gopath}" \ | ||
| 34 | GOCACHE="${dirhash_gocache}" \ | ||
| 35 | GOMODCACHE="${dirhash_gomodcache}" \ | ||
| 36 | GO111MODULE="off" \ | ||
| 37 | ${GO} build -o dirhash . | ||
| 38 | ) | ||
| 39 | } | ||
| 40 | |||
| 41 | do_install() { | ||
| 42 | install -d "${D}${bindir}" | ||
| 43 | dirhash_gopath="${WORKDIR}/dirhash-gopath" | ||
| 44 | install -m 0755 "${dirhash_gopath}/src/dirhash-helper/dirhash" "${D}${bindir}/dirhash" | ||
| 45 | |||
| 46 | install -d "${D}${datadir}/licenses/${PN}" | ||
| 47 | install -m 0644 "${UNPACKDIR}/LICENSE" "${D}${datadir}/licenses/${PN}/LICENSE" | ||
| 48 | } | ||
diff --git a/recipes-devtools/go-dirhash-native/go-dirhash/LICENSE b/recipes-devtools/go-dirhash-native/go-dirhash/LICENSE new file mode 100644 index 00000000..9feb7621 --- /dev/null +++ b/recipes-devtools/go-dirhash-native/go-dirhash/LICENSE | |||
| @@ -0,0 +1,26 @@ | |||
| 1 | Copyright (c) 2009 The Go Authors. All rights reserved. | ||
| 2 | |||
| 3 | Redistribution and use in source and binary forms, with or without | ||
| 4 | modification, are permitted provided that the following conditions are met: | ||
| 5 | |||
| 6 | * Redistributions of source code must retain the above copyright | ||
| 7 | notice, this list of conditions and the following disclaimer. | ||
| 8 | * Redistributions in binary form must reproduce the above copyright | ||
| 9 | notice, this list of conditions and the following disclaimer in | ||
| 10 | the documentation and/or other materials provided with the | ||
| 11 | distribution. | ||
| 12 | * Neither the name of Google Inc. nor the names of its | ||
| 13 | contributors may be used to endorse or promote products derived | ||
| 14 | from this software without specific prior written permission. | ||
| 15 | |||
| 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| 17 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
| 18 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
| 19 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
| 20 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 21 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
| 22 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
| 23 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
| 24 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
| 26 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
diff --git a/recipes-devtools/go-dirhash-native/go-dirhash/dirhash-helper.go b/recipes-devtools/go-dirhash-native/go-dirhash/dirhash-helper.go new file mode 100644 index 00000000..d2aec41c --- /dev/null +++ b/recipes-devtools/go-dirhash-native/go-dirhash/dirhash-helper.go | |||
| @@ -0,0 +1,24 @@ | |||
| 1 | package main | ||
| 2 | |||
| 3 | import ( | ||
| 4 | "fmt" | ||
| 5 | "os" | ||
| 6 | |||
| 7 | "golang.org/x/mod/sumdb/dirhash" | ||
| 8 | ) | ||
| 9 | |||
| 10 | func main() { | ||
| 11 | if len(os.Args) != 2 { | ||
| 12 | fmt.Fprintf(os.Stderr, "Usage: %s <zip-file>\n", os.Args[0]) | ||
| 13 | os.Exit(1) | ||
| 14 | } | ||
| 15 | |||
| 16 | zipPath := os.Args[1] | ||
| 17 | hash, err := dirhash.HashZip(zipPath, dirhash.DefaultHash) | ||
| 18 | if err != nil { | ||
| 19 | fmt.Fprintf(os.Stderr, "Error: %v\n", err) | ||
| 20 | os.Exit(1) | ||
| 21 | } | ||
| 22 | |||
| 23 | fmt.Println(hash) | ||
| 24 | } | ||
