从github下载tarball无curl

从github下载tarball无curl

本文介绍了从github下载tarball无curl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个嵌入式系统,其中我不能安装任何东西,唯一可以使用的工具来获取一些东西是wget。原来你不能做同样的事情与wget,你可以用curl。我不能交叉编译这个系统,所以我需要诉诸Python或shell脚本。有一个纯Python的Git实现,称为Dulwich,实际上有一些C代码,我需要交叉编译...所以我甚至诉诸于调查,FYI。

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.

我需要的是从github存储库获取代码,明显的解决方案是使用它们提供的tarball。我通常从存储库页面复制链接以下载zip按钮,并使用授权令牌,而不是用户名和密码。它的工作原理很简单,卷曲如下:

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

结果是wget比较尴尬,

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

推荐答案

在各种组合的wget标志上跳过我的头后,包括:

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


  • - post-data ;或

  • - user = 含有和不含 - pasword = 反之亦然;或

  • - header =授权:令牌< token>

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

我回顾了文档,发现在。看起来像我只是不能使用授权头与托管tarball的服务器,其次curl(或github前端,基于代理字符串)似乎在做一个与< token> @ github.com 与wget的 - user =< 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.

这是什么工作原理:

wget \
  --header='Authorization: token <token>' \
  https://api.github.com/repos/<org|user>/<repo>/tarball/<ref>

这篇关于从github下载tarball无curl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 09:33