goreleaser / godownloader

[DEPRECATED] Download Go binaries as fast and easily as possible.
MIT License
445 stars 54 forks source link

Fails with gometalinter #52

Closed autarch closed 6 years ago

autarch commented 6 years ago
$> godownloader -repo https://github.com/alecthomas/gometalinter > foo.sh
2018/03/09 16:23:01 Reading https://raw.githubusercontent.com/https://github.com/alecthomas/gometalinter/master/goreleaser.yml
2018/03/09 16:23:01 Issue reading https://raw.githubusercontent.com/https://github.com/alecthomas/gometalinter/master/goreleaser.yml returned: 404 Not Found
2018/03/09 16:23:01 Reading https://raw.githubusercontent.com/https://github.com/alecthomas/gometalinter/master/.goreleaser.yml
2018/03/09 16:23:01  info loading environment variables
2018/03/09 16:23:01  info snapshoting              
2018/03/09 16:23:01  info releasing to GitHub      
2018/03/09 16:23:01  info creating archives        
2018/03/09 16:23:01  info building binaries        
2018/03/09 16:23:01  info creating Linux packages with fpm
2018/03/09 16:23:01  info creating Linux packages with nfpm
2018/03/09 16:23:01  info creating Linux packages with snapcraft
2018/03/09 16:23:01  info calculating checksums    
2018/03/09 16:23:01  info signing artifacts        
2018/03/09 16:23:01  info creating Docker images   
2018/03/09 16:23:01  info releasing to Artifactory 
2018/03/09 16:23:01  info creating homebrew formula
2018/03/09 16:23:01  info creating Scoop Manifest  
$> sh ./foo.sh 
alecthomas/gometalinter info checking GitHub for latest tag
alecthomas/gometalinter info found version: 2.0.5 for v2.0.5/linux/amd64
install: cannot stat '/tmp/tmp.zqpty6BYN2/gometalinter': No such file or directory

The problem is that that after untarring the downloaded tarball in $TMPDIR, it assumes that $TMPDIR contains the binaries. But in this case $TMPDIR contains this:

ls -l /tmp/tmp.zqpty6BYN2/
total 39324
-rw-rw-r-- 1 autarch autarch      312 Mar  9 16:23 gometalinter-2.0.5-checksums.txt
drwxrwxr-x 2 autarch autarch     4096 Mar  9 16:23 gometalinter-2.0.5-linux-amd64
-rw-rw-r-- 1 autarch autarch 40258507 Mar  9 16:23 gometalinter-2.0.5-linux-amd64.tar.gz
autarch commented 6 years ago

I should note that the actual binaries end up in $TMPDIR/gometalinter-2.0.5-linux-amd64.

client9 commented 6 years ago

@autarch Oh thanks for the report. I use gometalinter a lot and didn't know they used goreleaser.

I'll check it out.

n

client9 commented 6 years ago

Issue is with the wrap_in_directory directive which is 'new' and godownloader doesn't understand it (it's probably not actually new, but new to me)

on it @autarch

archive:
  format: tar.gz
  wrap_in_directory: true
  format_overrides:
    - goos: windows
      format: zip
  name_template: '{{ .Binary }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
  files:
    - COPYING
    - README*
client9 commented 6 years ago

gometalinter is an especially great example since it also bundles in all the linters with separate build stanza (see #28)

also, I went to school at U of MN @autarch

client9 commented 6 years ago

should be fixed... let us know

$ ./samples/godownloader-gometalinter.sh 
alecthomas/gometalinter info checking GitHub for latest tag
alecthomas/gometalinter info found version: 2.0.5 for v2.0.5/darwin/amd64
alecthomas/gometalinter info installed as ./bin/gometalinter
alecthomas/gometalinter info installed as ./bin/gocyclo
alecthomas/gometalinter info installed as ./bin/nakedret
alecthomas/gometalinter info installed as ./bin/misspell
alecthomas/gometalinter info installed as ./bin/govet
alecthomas/gometalinter info installed as ./bin/gas
alecthomas/gometalinter info installed as ./bin/golint
alecthomas/gometalinter info installed as ./bin/ineffassign
alecthomas/gometalinter info installed as ./bin/goconst
alecthomas/gometalinter info installed as ./bin/errcheck
alecthomas/gometalinter info installed as ./bin/maligned
alecthomas/gometalinter info installed as ./bin/unconvert
alecthomas/gometalinter info installed as ./bin/dupl
alecthomas/gometalinter info installed as ./bin/structcheck
alecthomas/gometalinter info installed as ./bin/varcheck
alecthomas/gometalinter info installed as ./bin/safesql
alecthomas/gometalinter info installed as ./bin/deadcode
alecthomas/gometalinter info installed as ./bin/lll
alecthomas/gometalinter info installed as ./bin/goimports
alecthomas/gometalinter info installed as ./bin/gotype
alecthomas/gometalinter info installed as ./bin/gosimple
alecthomas/gometalinter info installed as ./bin/megacheck
alecthomas/gometalinter info installed as ./bin/staticcheck
alecthomas/gometalinter info installed as ./bin/unused
alecthomas/gometalinter info installed as ./bin/interfacer
alecthomas/gometalinter info installed as ./bin/unparam
autarch commented 6 years ago

also, I went to school at U of MN

@client9 - me too, that's why I live here in Mpls.

autarch commented 6 years ago

This still doesn't seem to be working ...

$> install-gometalinter.sh -d
alecthomas/gometalinter info checking GitHub for latest tag
alecthomas/gometalinter debug http_download https://github.com/alecthomas/gometalinter/releases/latest
alecthomas/gometalinter info found version: 2.0.5 for v2.0.5/linux/amd64
alecthomas/gometalinter debug http_download https://github.com/alecthomas/gometalinter/releases/download/v2.0.5/gometalinter-2.0.5-linux-amd64.tar.gz

$> ls -l /tmp/tmp.R0XI3hXWjR/
total 0

So now it's failing to download the tarball because the directory into which it tries to download does not exist, but that's not what it should do anyway. It should download into the newly created tmpdir, then untar it, then install from the dir created by the tarball. Here's an edited execute that works for me:

execute() {
  TMPDIR=$(mktmpdir)
  TARBALLDIR="${TMPDIR}/${NAME}"
  http_download "${TMPDIR}/${TARBALL}" "${TARBALL_URL}"
  http_download "${TMPDIR}/${CHECKSUM}" "${CHECKSUM_URL}"
  hash_sha256_verify "${TMPDIR}/${TARBALL}" "${TMPDIR}/${CHECKSUM}"

  (cd "${TMPDIR}" && untar "${TARBALL}")
  install -d "${BINDIR}"
  for binexe in "gometalinter" "gocyclo" "nakedret" "misspell" "govet" "gas" "golint" "ineffassign" "goconst" "errcheck" "maligned" "unconvert" "dupl" "structcheck" "varcheck" "safesql" "deadcode" "lll" "goimports" "gotype" "gosimple" "megacheck" "staticcheck" "unused" "interfacer" "unparam" ; do
    if [ "$OS" = "windows" ]; then
      binexe="${binexe}.exe"
    fi
    install "${TARBALLDIR}/${binexe}" "${BINDIR}/"
    log_info "installed ${BINDIR}/${binexe}"
  done
}
client9 commented 6 years ago

Oh I think this might be due to a slight out of date version of godownloader (sorry no versions on this yet.. that's coming very soon).

can you re-install or re-build (make sure you do a 'make install' not just 'make build')

and/or use

https://raw.githubusercontent.com/goreleaser/godownloader/master/samples/godownloader-gometalinter.sh

thanks!

n

autarch commented 6 years ago

I installed the latest godownloader with go get -u. The shell file you link has the exact problem I describe. It untars the tarball inside a directory named after the tarball, creating yet another subdirectory with that same name, which it then ignores.

client9 commented 6 years ago

ok thanks for your patience @autarch

Looks like the problem was with my tmpdir which all sorts of half-downloaded gometalinter files masking the problem

Should be fixed now, and now RM the tarball dir before the un-tarring to prevent this type of thing from happening again.

autarch commented 6 years ago

Yes, this now appears to be fixed.