build.sh 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/bin/sh
  2. # https://golang.org/doc/install/source#environment
  3. #
  4. cd "$(dirname "${0}")" || exit 1
  5. # $ uname -s -m
  6. # Darwin x86_64
  7. # Linux x86_64
  8. # Linux armv6l
  9. say="say"
  10. parm="" # "-u"
  11. {
  12. "${say}" "go get"
  13. go get ${parm} github.com/gorilla/sessions \
  14. github.com/jteeuwen/go-bindata/... \
  15. golang.org/x/crypto/bcrypt \
  16. golang.org/x/net/html \
  17. golang.org/x/net/html/atom \
  18. golang.org/x/text/language \
  19. golang.org/x/text/search \
  20. gopkg.in/yaml.v2 \
  21. \
  22. github.com/stretchr/testify \
  23. github.com/yhat/scrape \
  24. golang.org/x/tools/blog/atom
  25. }
  26. "$(go env GOPATH)/bin/go-bindata" -ignore="\\.DS_Store" -ignore=".+\\.woff" -prefix static static/... tpl/...
  27. VERSION="$(grep -F 'version = ' version.go | cut -d \" -f 2)"
  28. LDFLAGS="-s -w -X main.GitSHA1=$(git rev-parse --short HEAD)"
  29. rm "shaarligo"-*-*".cgi"* 2>/dev/null
  30. "${say}" "test"
  31. umask 0022
  32. go fmt && go vet && go test --short || { exit $?; }
  33. "${say}" "ok"
  34. tar -czf testdata.tar.gz testdata/*.html testdata/*.atom testdata/*.gob
  35. "${say}" "build localhost"
  36. go build -ldflags "${LDFLAGS}" -o "shaarligo.cgi" || { echo "Aua" 1>&2 && exit 1; }
  37. cp "shaarligo.cgi" ~/"public_html/b/shaarligo.cgi"
  38. "${say}" "ok"
  39. # open "http://localhost/~$(whoami)/b/shaarligo.cgi"
  40. "${say}" bench
  41. go test -bench=.
  42. "${say}" ok
  43. "${say}" "linux build"
  44. # http://dave.cheney.net/2015/08/22/cross-compilation-with-go-1-5
  45. env GOOS=linux GOARCH=amd64 go build -ldflags="${LDFLAGS}" -o "shaarligo-Linux-x86_64.cgi" || { echo "Aua" 1>&2 && exit 1; }
  46. env GOOS=linux GOARCH=arm GOARM=6 go build -ldflags="${LDFLAGS}" -o "shaarligo-Linux-armv6l.cgi" || { echo "Aua" 1>&2 && exit 1; }
  47. # env GOOS=linux GOARCH=386 GO386=387 go build -o "shaarligo-linux-386-${VERSION}" # https://github.com/golang/go/issues/11631
  48. # env GOOS=darwin GOARCH=amd64 go build -o "shaarligo-darwin-amd64-${VERSION}"
  49. "${say}" "simply"
  50. gzip --force --best "shaarligo-"*-*".cgi" \
  51. && rsync -vp --bwlimit=1234 "shaarligo-"*-*".cgi.gz" "simply:/var/www/lighttpd/l.mro.name/public_html/" \
  52. && ssh simply "sh -c 'cd /var/www/lighttpd/l.mro.name/public_html/ && gunzip < shaarligo-$(uname -s)-$(uname -m).cgi.gz > shaarligo.cgi && ls -l shaarligo*cgi*'" \
  53. && ssh simply "sh -c 'cd /var/www/lighttpd/b.r-2.eu/public_html/u/ && cp /var/www/lighttpd/l.mro.name/public_html/shaarligo?cgi* . && ls -l shaarligo*cgi*'" \
  54. && ssh simply "sh -c 'cd /var/www/lighttpd/b.mro.name/public_html/u/ && cp /var/www/lighttpd/l.mro.name/public_html/shaarligo?cgi* . && ls -l shaarligo*cgi*'"
  55. "${say}" "ok"
  56. "${say}" "vario"
  57. # scp "ServerInfo.cgi" vario:~/mro.name/webroot/b/"info.cgi"
  58. ssh vario "sh -c 'cd ~/mro.name/webroot/b/ && curl -L http://purl.mro.name/shaarligo-$(uname -s)-$(uname -m).cgi.gz | tee shaarligo.cgi.gz | gunzip > shaarligo.cgi && chmod a+x shaarligo.cgi && ls -l shaarligo?cgi*'"
  59. "${say}" "ok"