测试RPM包安装

发布于 2024-08-08 17:02:03 字数 566 浏览 2 评论 0原文

我们使用 rpm 在内部部署我们的 Web 应用程序。 rpm 安装文件、配置 apache、cron、日志记录等。

我想构建一个 rpm 的测试版本,它安装在不同的位置,并具有不同的 apache、cron 和日志记录配置。应该可以在同一台机器上安装生产和测试 rpm。

安装了两个 rpm 后,我会得到类似的结果,

/opt/app/www/...
/opt/app-test/www/...
/etc/httpd/conf.d/app.conf
/etc/httpd/conf.d/app-test.conf
/etc/cron.d/app
/etc/cron.d/app-test
/etc/init.d/app
/etc/init.d/app-test

什么是实现此目的的好方法?

  • 复制规范并将所有内容重命名为“test”?
  • 为生产/测试创建不同的子包?
  • 使用 rpm 宏来更改规范中的位置和名称?
  • 使用 rpm --relocate?

是否有任何现有的 rpm 可以尝试执行此操作,我可以查看?

We are using rpm to deploy our web applications internally. The rpm installs the files, configures apache, cron, logging and so on.

I would like to build a test version of the rpm that installs in a different location with a different configuration for apache, cron and logging. It should be possible to install both the production and test rpm on the same machine.

With both rpms installed i would have something like

/opt/app/www/...
/opt/app-test/www/...
/etc/httpd/conf.d/app.conf
/etc/httpd/conf.d/app-test.conf
/etc/cron.d/app
/etc/cron.d/app-test
/etc/init.d/app
/etc/init.d/app-test

What would be a good way to achieve this?

  • Copy the spec and rename everything to "test"?
  • Create different subpackages for prod/test?
  • Use rpm macros to alter the location and names in the spec?
  • Use rpm --relocate?

Is there any existing rpm that tries to do this that i can look at?

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

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

发布评论

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

评论(2

旧瑾黎汐 2024-08-15 17:02:03

在我的规范文件中,我使用内置宏然后,使用测试帐户(不是 root)和自定义的 ~/.rpmmacros,我更改默认前缀:

%_prefix %{_home}

工作正常。

您甚至可以创建一个测试 rpm 数据库:

$ rpmdb --initdb --dbpath /home/test/var/lib/rpm

并将其放入您的 .rpmmacros 中:

%_dbpath /home/test/var/lib/rpm
%_rpmlock_path %{_dbpath}/__db.000

In my spec files, I use the built-in macros and then, with a test account (not root) and a customized ~/.rpmmacros, I change the default prefix:

%_prefix %{_home}

Works fine.

You can even create a test rpm database:

$ rpmdb --initdb --dbpath /home/test/var/lib/rpm

and put this in your .rpmmacros:

%_dbpath /home/test/var/lib/rpm
%_rpmlock_path %{_dbpath}/__db.000
世态炎凉 2024-08-15 17:02:03

即使您有不同的解决方案,我还是决定建议另一种方法来实现这一目标。不过虚拟化并没有什么问题。无论如何,这可能是一个更好的解决方案,因为我认为在与生产相同的机器上运行测试环境并不安全/可靠。也就是说......

我可能会使用一个规范文件作为模板,然后是这样的:

...
# somwwhere in the beginning of spec
%global testrel test

#rest of document
Source0: tarball-with-things%{?testrel}.tar.bz
...
%if ${?testrel:1}${!?testrel:0}
# this will execute only in test rpm
%endif
...

请注意,特别是 %{?testrel} 宏是有趣的事情。它使您能够同时更新两个版本的内容,但如果您希望保留一个版本或另一个版本的特定内容,您仍然可以。它也不需要对数据库、~/.rpmmacros 中的自定义宏进行任何更改(这将根据构建它的系统而变化)

Even though you have a different solution, I decided to suggest another way to achieve this. Nothing wrong with virtualization though. Probably a better solution anyway since running a test environment on the same machine as production is not safe/secure I guess. That said...

I would probably use one spec file as a template and then this:

...
# somwwhere in the beginning of spec
%global testrel test

#rest of document
Source0: tarball-with-things%{?testrel}.tar.bz
...
%if ${?testrel:1}${!?testrel:0}
# this will execute only in test rpm
%endif
...

Note that especailly the %{?testrel} macro is the interesting thing. It enables you to update things simultaneously for both versions, but if you wish to keep something specific to one version or the other you still can. It also doesn't require any changes to the database, custom macros in ~/.rpmmacros (which would change depending on the system it's being built on)

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