无法在Mac终端下载开源项目的源代码

发布于 2024-07-16 23:16:58 字数 1552 浏览 7 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

生生漫 2024-07-23 23:16:58

MacPorts 是一个基于源代码的包管理器。 这意味着每次您通过 MacPorts 安装软件包时,它都会下载源代码,可能会修补它,配置它,构建它,将其安装到临时位置(以便它可以跟踪端口需要哪些文件),并对其进行存档,然后将该存档安装到 MacPorts 根目录中,通常是 /opt/local

如果您想在构建之前查看或编辑源代码,则可以执行下载和安装它所需的部分步骤。 port extract 将下载并提取端口的源代码,而无需实际构建或安装它。 然后,您可以使用 port dir 找到提取的源代码:

$ sudo port -v extract zlib
Password:
--->  Fetching zlib
--->  Verifying checksum(s) for zlib
--->  Checksumming zlib-1.2.3.tar.bz2
--->  Extracting zlib
--->  Extracting zlib-1.2.3.tar.bz2
$ ls $(port dir zlib)
Portfile    files       work
$ ls $(port dir zlib)/work
zlib-1.2.3
$ ls $(port dir zlib)/work/zlib-1.2.3
ChangeLog   as400       examples    inftrees.h  uncompr.c
FAQ     compress.c  gzio.c      make_vms.com    win32
INDEX       configure   infback.c   minigzip.c  zconf.h
Makefile    contrib     inffast.c   msdos       zconf.in.h
Makefile.in crc32.c     inffast.h   old     zlib.3
README      crc32.h     inffixed.h  projects    zlib.h
adler32.c   deflate.c   inflate.c   qnx     zutil.c
algorithm.txt   deflate.h   inflate.h   trees.c     zutil.h
amiga       example.c   inftrees.c  trees.h

请参阅 MacPorts 指南 有关开发端口以及 man port 的更多信息。

MacPorts is a source-based package manager. That means that each time you install a package via MacPorts, it downloads the source, potentially patches it, configures it, builds it, installs it to a temporary location (so it can track which files the port needs), makes an archive of it, then installs that archive into the MacPorts root, which is usually /opt/local.

If you want to look at or edit the source before building it, you can execute a subset of the steps necessary to download and install it. port extract <name> will download and extract the source for the port, without actually building or installing it. You can then find the extracted source with port dir <portname>:

$ sudo port -v extract zlib
Password:
--->  Fetching zlib
--->  Verifying checksum(s) for zlib
--->  Checksumming zlib-1.2.3.tar.bz2
--->  Extracting zlib
--->  Extracting zlib-1.2.3.tar.bz2
$ ls $(port dir zlib)
Portfile    files       work
$ ls $(port dir zlib)/work
zlib-1.2.3
$ ls $(port dir zlib)/work/zlib-1.2.3
ChangeLog   as400       examples    inftrees.h  uncompr.c
FAQ     compress.c  gzio.c      make_vms.com    win32
INDEX       configure   infback.c   minigzip.c  zconf.h
Makefile    contrib     inffast.c   msdos       zconf.in.h
Makefile.in crc32.c     inffast.h   old     zlib.3
README      crc32.h     inffixed.h  projects    zlib.h
adler32.c   deflate.c   inflate.c   qnx     zutil.c
algorithm.txt   deflate.h   inflate.h   trees.c     zutil.h
amiga       example.c   inftrees.c  trees.h

See the MacPorts guide for more information on developing ports, and also man port.

倦话 2024-07-23 23:16:58

大多数开源项目提供源代码的压缩存档或可读的版本控制存储库。 例如,wget 的源代码可在 http://ftp.gnu.org/gnu/wget/。 您需要做的就是决定要下载哪个版本,然后在终端窗口中输入类似的命令,

ftp http://ftp.gnu.org/gnu/wget/wget-1.10.2.tar.gz

然后可以使用类似的命令解压源代码

tar xvzf wget-1.10.2.tar.gz

如果代码位于版本控制存储库中,那么该项目还将列出命令您需要下载代码。 例如, cvs2svn 为您提供命令

svn co --username=guest http://cvs2svn.tigris.org/svn/cvs2svn/trunk cvs2svn-trunk

可能有特定于 Mac 的方法,但我所描述的内容很美妙它适用于任何类 Unix 环境。

Most open source projects provide a compressed archive of their source code, or a readable version control repository. For instance, the source code for wget is available at http://ftp.gnu.org/gnu/wget/. All you need to do is decide which version you want to download and enter in the terminal window a command like

ftp http://ftp.gnu.org/gnu/wget/wget-1.10.2.tar.gz

You can then unpack the source code with a command like

tar xvzf wget-1.10.2.tar.gz

If the code is in a version control repository, then the project will also list the command you'll need to download the code. For instance, cvs2svn gives you the command

svn co --username=guest http://cvs2svn.tigris.org/svn/cvs2svn/trunk cvs2svn-trunk

There may be Mac-specific methods, but the beauty of what I described is that it works for any Unix-like environment.

断肠人 2024-07-23 23:16:58

apt-get是一个自动下载和安装软件包及其依赖项的程序; 它仅适用于某些基于 Linux 的平台,例如 Debian 和 Ubuntu。 Mac OS X 有两个类似的实用程序:FinkMacPorts. 两者的用途与 apt-get 相同。 我个人更喜欢MacPorts,因为我认为它有更好的用户界面,但这两个软件的工作原理或多或少是相同的。

apt-get is a program for automatically downloading and installing software packages and their dependencies; it is only available on some Linux-based platforms like Debian and Ubuntu. Mac OS X has two similar utilities: Fink and MacPorts. Both serve the same purpose as apt-get. I personally prefer MacPorts because I think it has a nicer UI, but both pieces of software work more or less the same.

会傲 2024-07-23 23:16:58

AFAIK,MacPorts 没有与 apt-get 源代码类似的功能。

但是,源 URL 位于 Portfiles 中。 键入来查看端口的端口文件

cat `port file port_name`

您可以通过在终端中

cat `port file wget`

,例如:或者您可以只安装端口并在 /opt/local/var/macports/distfiles 中查找源代码。

您甚至可以使用安装命令来下载(而不是构建或安装)端口。

AFAIK, MacPorts doesn't have a similar function to apt-get's source.

However, the source URL is in the Portfiles. You can view the portfile for a port by typing

cat `port file port_name`

in the terminal, for example:

cat `port file wget`

Or you can just install the port and find the source in /opt/local/var/macports/distfiles.

You might even be able to use the install command to just download (and not build or install) the port.

删除→记忆 2024-07-23 23:16:58

如果您想要开源项目的 apt 接口,请查看 Fink,这是一个适用于 Mac OS X 的 dpkg 系统,各种开源包。

If you want an apt interface onto open source projects, look at Fink, a dpkg system for Mac OS X with various open source packages.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文