Linux 存储库管理器如何自我更新的设计原则?

发布于 2024-09-28 01:15:56 字数 356 浏览 5 评论 0原文

我知道还有其他应用程序,但考虑到 yum/apt-get/aptitude/pacman 是 Linux 发行版的核心包管理器。

今天我在我的 Fedora 13 盒子上看到:

(7/7): yum-3.2.28-4.fc13_3.2.28-5.fc13.noarch.drpm       |  42 kB     00:00     

我开始想知道这样的包如何自我更新?需要怎样的设计来确保程序能够自我更新?

也许这个问题太笼统了,但我觉得SO比程序员更合适。SE对于这样的问题本质上更具技术性。如果这个问题有更合适的地方,请随时告诉我,我可以关闭,或者主持人可以移动。

谢谢。

I know there are other applications also, but considering yum/apt-get/aptitude/pacman are you core package managers for linux distributions.

Today I saw on my fedora 13 box:

(7/7): yum-3.2.28-4.fc13_3.2.28-5.fc13.noarch.drpm       |  42 kB     00:00     

And I started to wonder how does such a package update itself? What design is needed to ensure a program can update itself?

Perhaps this question is too general but I felt SO was more appropriate than programmers.SE for such a question being that it is more technical in nature. If there is a more appropriate place for this question feel free to let me know and I can close or a moderator can move.

Thanks.

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

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

发布评论

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

评论(2

裂开嘴轻声笑有多痛 2024-10-05 01:15:56

我不知道那些特定的系统是如何工作的,但是......

  • 现代unix系统通常会容忍覆盖正在运行的可执行文件而不会出现问题,所以理论上你可以这样做。
  • 您可以在 chroot 监狱中执行此操作,然后进行移动或类似操作以减少系统易受攻击的时间。添加一个日志文件系统,这会更安全一些。

我想到包管理器还需要将包访问数据库保存在内存中,以确保避免出现竞争条件。同样,chroot 监狱和复制选项可作为风险较低的替代方案。

I've no idea how those particular systems work, but...

  • Modern unix systems will generally tolerate overwriting a running executable without a hiccup, so in theory you could just do it.
  • You could do it in a chroot jail and then move or something similar to reduce the time during which the system is vulnerable. Add a journalling filesystem and this is a little safer still.

It occurs to me that the package-manager needs to hold the package access database in memory as well to insure against a race condition there. Again, the chroot jail and copy option is available as a lower risk alternative.

小帐篷 2024-10-05 01:15:56

我开始想知道这样的包如何自我更新?什么
需要设计来确保程序能够自我更新吗?

就像很多事情一样,你不需要专门“设计”来解决这个问题……但你确实需要意识到某些“陷阱”。

例如,Unix 通过引用计数 inode 来提供帮助,因此“您”可以删除仍在使用的文件,这很好。然而,这意味着您必须做一些事情,例如,如果您有插件,那么您需要在运行启动事务之前加载所有插件......即使插件只会在最后运行交易的版本(因为最后可能有不同的版本)。

您还需要执行一些操作来确保您正在更新的任何内容都有效,例如: 在删除旧文件之前先放下新文件。并且不要截断旧文件,只需取消链接即可。但这些也对你有帮助:)。

使用与您通信的外部问题可能会很棘手(因为您无法在更新后执行旧版本的新副本)。但这并不经常发生,当它发生时,它是为了下载之类的事情......这可以在任何更新之前很容易地发生。

还有一些事情在 yum/apt 等 cmd 行客户端中并不需要担心,例如,如果您有一个程序将运行 2 个以上的“更新”,那么如果第一次更新是针对软件包的,那么您可能会遇到问题经理。降级让这变得更加有趣:)。
另外,类似守护进程的进程基本上不应该“加载”包管理器,但与其他陷阱一样......无论如何,出于其他原因,您倾向于遵循这一点。

And I started to wonder how does such a package update itself? What
design is needed to ensure a program can update itself?

It's like a lot of things, you don't need to "design" specifically to solve this problem ... but you do need to be aware of certain "gotchas".

For instance Unix helps by reference counting inodes so "you" can delete a file you are still using, and it's fine. However this implies a few things you have to do, for instance if you have plugins then you need to load them all before you run start a transaction ... even if the plugin would only run at the end of the transaction (because you might have a different version at the end).

There are also some things that you need to do to make sure that anything you are updating works, like: Put new files down before removing old files. And don't truncate old files, just unlink. But those also help you :).

Using external problems, which you communicate with, can be tricky (because you can't exec a new copy of the old version after it's been updated). But this isn't often done, and when it is it's for things like downloading ... which can somewhat easily be made to happen before any updates.

There are also things which aren't a concern in the cmd line clients like yum/apt, for instance if you have a program which is going to run 2+ "updates" then you can have problems if the first update was to the package manager. downgrades make this even more fun :).
Also daemon like processes should basically never "load" the package manager, but as with other gotchas ... you tend to want to follow this anyway, for other reasons.

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