我想在 Ubuntu WSL 实例上安装 libuv,并且特别需要版本 1.45.0 或更高版本。
我的理解(来自本教程文章)是,查找可安装的软件包版本的命令是apt list | grep
:
$ apt list | grep libuv
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
libuv1-dev/jammy,now 1.43.0-1 amd64 [installed]
libuv1/jammy,now 1.43.0-1 amd64 [installed,automatic]
libuvc-dev/jammy 0.0.6-1.1 amd64
libuvc-doc/jammy 0.0.6-1.1 all
libuvc0/jammy 0.0.6-1.1 amd64
...这让我认为只有 1.43.0-1 可供安装apt-get
,并且它已经安装了。
但libuv 的 GitHub 站点表明有更新的版本。
如何在我的 Ubuntu 实例上使用 libuv v1.45.0(或更高版本)apt-get
?
虽然我的迫切需求是特定于 libuv 的,但我实际上想总体了解 Unix/Linux 生态系统的这个方面:驱动程序/包/等之间的关系是什么。似乎是“已发布”(例如根据其 GitHub 页面)与包管理器“可用”的内容,例如apt-get
?如果用户想要一个软件包管理器无法提供的较新版本的软件包,他们应该怎么做?他们应该下载源代码并在本地编译吗?
更新:为什么我需要 1.45.0,即为什么我需要比我的包管理器提供的版本更高级的版本?
我的Linux机器是一个开发环境,我需要在其中编译到主机(即我们可以忽略这个问题的上下文的交叉编译)。我需要编译的应用程序(不是我编写的)依赖于uv_timespec64_t
,这显然是在 libuv v1.45.0 中引入的(根据git merge/diff)。
因此,这就是这个问题的前提:我需要编译(到主机)一个应用程序,该应用程序依赖于比我的 Linux 发行版的包管理器提供的更新版本的 libuv 中的功能。
更新:这个问题有一个相关的后续问题:为什么不同的 Linux 发行版有不同的包格式(和包管理器)?
树干和树木
在 @TechLoom 回答您有关 的问题的同时
libuv
,请允许我回答您有关 Linux 生态系统的问题。让我们从在新的浏览器选项卡中打开它,请注意有 5 个主要主干:
每个分支以及所有子分支主要由正在使用的包管理系统定义。
Now, as for how the ecosystem is connected. Each package manager is configured to connect only to its specified package tree, also called a repository. Debian-based systems connect to APT based trees, where you can download and install
.deb
files. Each of these package managers allows users to install custom trees. Ubuntu-based systems call them PPAs, or Personal Package Archives.Release Cycles
Each distribution, regardless of the package manger has a release cycle. Release cycles can be thought of as "locked repositories" or using the tree analogy: "healthy trees that don't grow anymore." The repositories only contain packages that belong to that certain release. In general, packages installed by the release are never altered, and only updated in rare cases i.e., when a critical bugfix is released (which is why you cannot find libuv-1.45 in the
jammy
release), but if you look inmantic
andnoble
, the next few codenames for Future Releases, you can see the package has been bumped (see Version Bumps below). Software like browsers and mail clients are generally released to thecontrib
(short for contributed) repository, which doesn't interfere with themain
repository. In Debian's terminology, I believe they call their contributed repositoryuniverse
, which fits rather well (every piece of user software under the sun can be put there). Each added package is compiled against the libraries and tools in themain
repository, packaged and uploaded to theuniverse
repository. This imitates the "locked repository" concept for software added by users or companies.In Ubuntu's case the release cycle generally occurs twice a year (once in April, and once in October, barring a minor version update [the 3rd version number]). You can see this by looking at the Ubuntu Release List. The accepted practice is to only use packages available in your release until that package is updated by the maintainer.
Note that some distributions use a rolling release model, specifically those that are source based. I can issue an update command on my source compiled Gentoo box, rebuild packages, and an hour later perform the same update and possibly update the same packages again.
Even our friends, or enemies depending on your preference, over at Microsoft have adopted a Release Model starting with Windows 10. The current release of Windows 11 is versioned as 23H2, or the 2nd half of 2023. The first major version of Windows 10 I remember was 1903, referring to March 2019. While Microsoft's "tree" isn't publicly available it is used to integrate updates based on bug fixes and user requests into future versions of Windows.
Why Version Locking Is Important
To understand why the locked concept is so important, imagine you owned a BMW anything. BMW's are mostly all hand built and hand tuned. Let's say that we decide we want to add Feature X from the 2025 model to our model we bought in 2023 without talking to BMW first.
I bolded that last bullet to tie all this together. In the above "upgrade" BMW is maintainer of the "locked repository." BMW owns or can access all the parts for most all of it's cars when asked. The special connector doesn't exist outside the tree. In the same way you can only add software or upgrades to your Ubuntu version, a.k.a. the cars in this story, if the software exists in the repository. Mixing repositories from different versions causes complete breakage. If Feature X needs to be added or upgraded in a previous version, the software is backported, and get's added to that particular version's
main
repository (the mechanic), and the version continues operating as intended (the car is repaired).Version Bumps
版本升级(即从 1.43 到 1.45)通常按如下方式完成:
LTS 版本
对于需要稳定性的用户,某些发行版使用长期服务版本的概念。这些通常是具有关键任务应用程序(例如 Web 服务器、防火墙或域控制器)的区域的首选。
您可以从 github 页面下载源代码。
https://github.com/libuv/libuv/releases
然后只需提取源文件并编译程序,然后安装即可。所有步骤都在 github 页面上。
https://github.com/libuv/libuv#build-instructions
另一种选择是查看是否有人拥有该项目的存储库。然后你可以使用“add-apt-repository”,然后像你想要的那样使用 apt 。