build.sh 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #!/bin/sh
  2. # https://golang.org/doc/install/source#environment
  3. #
  4. cd "$(dirname "${0}")"
  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. go get ${parm} github.com/jteeuwen/go-bindata/... &
  15. go get ${parm} golang.org/x/crypto/bcrypt &
  16. go get ${parm} golang.org/x/net/html &
  17. go get ${parm} golang.org/x/net/html/atom &
  18. go get ${parm} golang.org/x/text/language &
  19. go get ${parm} golang.org/x/text/search &
  20. go get ${parm} gopkg.in/yaml.v2 &
  21. # for testing only:
  22. go get ${parm} github.com/stretchr/testify &
  23. go get ${parm} github.com/yhat/scrape &
  24. go get ${parm} golang.org/x/tools/blog/atom &
  25. wait
  26. }
  27. "$(go env GOPATH)/bin/go-bindata" -ignore=\\.DS_Store -prefix static static/...
  28. PROG_NAME="ShaarliGo"
  29. VERSION=`fgrep 'version = ' version.go | cut -d '"' -f 2`
  30. rm "${PROG_NAME}"-*-"${VERSION}" 2>/dev/null
  31. "${say}" "test"
  32. umask 0022
  33. go fmt && go vet && go test --short || { exit $?; }
  34. "${say}" "ok"
  35. tar -czf testdata.tar.gz testdata/*.html testdata/*.atom testdata/*.gob
  36. "${say}" "build localhost"
  37. go build -ldflags "-s -w -X main.GitSHA1=$(git rev-parse --short HEAD)" -o ~/public_html/b/shaarligo.cgi || { echo "Aua" 1>&2 && exit 1; }
  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="-s -w -X main.GitSHA1=$(git rev-parse --short HEAD)" -o "${PROG_NAME}-linux-amd64-${VERSION}" || { echo "Aua" 1>&2 && exit 1; }
  46. env GOOS=linux GOARCH=arm GOARM=6 go build -ldflags="-s -w -X main.GitSHA1=$(git rev-parse --short HEAD)" -o "${PROG_NAME}-linux-arm-${VERSION}" || { echo "Aua" 1>&2 && exit 1; }
  47. # env GOOS=linux GOARCH=386 GO386=387 go build -o "${PROG_NAME}-linux-386-${VERSION}" # https://github.com/golang/go/issues/11631
  48. # env GOOS=darwin GOARCH=amd64 go build -o "${PROG_NAME}-darwin-amd64-${VERSION}"
  49. "${say}" "simply"
  50. # scp "ServerInfo.cgi" simply:/var/www/lighttpd/h4u.r-2.eu/public_html/"info.cgi"
  51. gzip --force --best "${PROG_NAME}"-*-"${VERSION}" \
  52. && chmod a-x "${PROG_NAME}"-*-"${VERSION}.gz" \
  53. && rsync -vp --bwlimit=1234 "${PROG_NAME}"-*-"${VERSION}.gz" "simply:/tmp/" \
  54. && ssh simply "sh -c 'cd /var/www/lighttpd/l.mro.name/public_html/ && cp "/tmp/${PROG_NAME}-linux-amd64-${VERSION}.gz" shaarligo_cgi.gz && gunzip < shaarligo_cgi.gz > shaarligo.cgi && chmod a+x shaarligo.cgi && ls -l shaarligo?cgi*'" \
  55. && 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* .'"
  56. 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*'"
  57. "${say}" "ok"
  58. "${say}" "vario"
  59. # scp "ServerInfo.cgi" vario:~/mro.name/webroot/b/"info.cgi"
  60. ssh vario "sh -c 'cd ~/mro.name/webroot/b/ && curl -L http://purl.mro.name/shaarligo_cgi.gz | tee shaarligo_cgi.gz | gunzip > shaarligo.cgi && chmod a+x shaarligo.cgi && ls -l shaarligo?cgi*'"
  61. "${say}" "ok"