Revisions
-
anacrolix revised this gist
Jan 17, 2019 . 1 changed file with 6 additions and 5 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,7 @@ #!/bin/bash set -eu export IPFS_GATEWAY="${IPFS_GATEWAY:-http://127.0.0.1:8080}" CACHE_DIR="$(go env GOPATH)/pkg/mod/cache" @@ -21,10 +23,10 @@ case "$1" in temp="$(mktemp -d "$CACHE_DIR/.tmpXXXXXXXXX")" trap 'rm -rf "$temp"' 0 go mod download -json > "$temp/info.json" jq -r '"VERSION=\(.Version | @sh) INFO=\(.Info | @sh) GOMOD=\(.GoMod | @sh) ZIP=\(.Zip | @sh) modpath=\(.Path | @sh)"' < "$temp/info.json" \ | while read line; do eval "$line" echo bundling $modpath/$VERSION base="$(dirname "${temp}/bundle/$(basepath "$INFO")")" mkdir -p "$base" @@ -33,13 +35,12 @@ case "$1" in done go mod graph | while read _ dep; do IFS="@" read name ver<<<"$dep" name="$(cleanpath "$name")" base="$temp/bundle/$name/@v/" mkdir -p "$base" ln -t "$base" "$CACHE_DIR/download/$name/@v/$ver".{info,mod} 2> /dev/null && echo adding info for $name/$ver || true done du -hs "$temp/bundle" HASH="$(ipfs add -Qr "$temp/bundle")" echo "/ipfs/$HASH" > deps.ipfs ;; -
anacrolix revised this gist
Jan 17, 2019 . 1 changed file with 5 additions and 1 deletion.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,8 +8,10 @@ basepath() { echo "${1##${CACHE_DIR}/download/}" } sed=`type gsed 2>&1 > /dev/null && echo gsed || echo sed` cleanpath() { echo "$1" | "$sed" 's/[A-Z]/!\L&/g' } case "$1" in @@ -31,7 +33,9 @@ case "$1" in done go mod graph | while read _ dep; do IFS="@" read name ver<<<"$dep" echo "$name" name="$(cleanpath "$name")" echo "$name" base="$temp/bundle/$name/@v/" mkdir -p "$base" ln -f -t "$base" "$CACHE_DIR/download/$name/@v/$ver".{info,mod} -
Stebalien created this gist
Jan 16, 2019 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,49 @@ #!/bin/bash export IPFS_GATEWAY="${IPFS_GATEWAY:-http://127.0.0.1:8080}" CACHE_DIR="$(go env GOPATH)/pkg/mod/cache" basepath() { echo "${1##${CACHE_DIR}/download/}" } cleanpath() { echo "$1" | sed 's/[A-Z]/!\L&/g' } case "$1" in ipfs-lock) export GO111MODULE=on temp="$(mktemp -d "$CACHE_DIR/.tmpXXXXXXXXX")" trap 'rm -rf "$temp"' 0 go mod download -json > "$temp/info.json" jq -r '"VERSION=\(.Version | @sh) INFO=\(.Info | @sh) GOMOD=\(.GoMod | @sh) ZIP=\(.Zip | @sh)"' < "$temp/info.json" \ | while read line; do eval "$line" echo $INFO base="$(dirname "${temp}/bundle/$(basepath "$INFO")")" mkdir -p "$base" ln -t "$base" "$INFO" "$GOMOD" "$ZIP" echo "$VERSION" >> "$base/list" done go mod graph | while read _ dep; do IFS="@" read name ver<<<"$dep" name="$(cleanpath "$name")" base="$temp/bundle/$name/@v/" mkdir -p "$base" ln -f -t "$base" "$CACHE_DIR/download/$name/@v/$ver".{info,mod} done HASH="$(ipfs add -Qr "$temp/bundle")" echo "/ipfs/$HASH" > deps.ipfs ;; *) if [[ -e "deps.ipfs" ]]; then path="$(< deps.ipfs)" export GOPROXY="${IPFS_GATEWAY}$path" export GO111MODULE=on fi exec go "${@}" esac