質問

I have an embedded system where I cannot install anything and the only tool I could potentially use to fetch something is wget. It turns out you cannot do the same things with wget that you can with curl. I cannot cross-compile for this system either, so I need to resort to Python or shell scripts. There pure-Python implementation of git called Dulwich actually has some C code that I'd need to cross-compile... So I even resorted looking into that, FYI.

What I need is get code from github repository, and the obvious solution to that is using tarballs they provide. I usually copy the link to download zip button from the repository page and use an authorization token instead of username and password. It works pretty simply with curl like so:

curl -L https://<token>@github.com/<org|user>/<repo>/archive/master.tar.gz | tar xz

Turns out wget is somewhat more awkward and whatever I tried just does work.

役に立ちましたか?

解決

After beating my head on various combination of wget flags involving either:

  • --post-data; or
  • --user= with and without --pasword= as well as vice versa; or
  • --header="Authorization: token <token>"

I looked back at the documentation and found that there are alternative endpoints in releases API. Looks like firstly I just cannot use the Authorization header with the server that hosts tarballs and secondly curl (or github front-end, based on the agent string) seem to be doing a different thing with <token>@github.com vs wget's --user=<token>, and it's not the most pleasant thing to figure out.

So what works is this:

wget \
  --header='Authorization: token <token>' \
  https://api.github.com/repos/<org|user>/<repo>/tarball/<ref>
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top