首页 文章

测试RPM包的安装

提问于
浏览
0

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

我想 Build 一个rpm的测试版本,它安装在不同的位置,具有不同的apache,cron和logging配置 . 应该可以在同一台机器上安装 生产环境 和测试rpm .

安装了两个rpms,我会有类似的东西

/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"?

  • 为prod / test创建不同的子包?

  • 使用rpm宏来改变规范中的位置和名称?

  • 使用rpm --relocate?

是否有任何现有的rpm试图这样做,我可以看看?

2 回答

  • 1

    在我的spec文件中,我使用built-in macros,然后使用测试帐户(不是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
    
  • 0

    即使您有不同的解决方案,我还是建议采用另一种方法来实现这一目标 . 但虚拟化没有错 . 可能是一个更好的解决方案,因为在同一台机器上运行测试环境因为 生产环境 不安全/安全我猜 . 那说......

    我可能会使用一个spec文件作为模板然后这个:

    ...
    # 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} 宏是有趣的 . 它使您可以同时更新两个版本的内容,但如果您希望保留特定于某个版本或其他版本的内容,您仍然可以 . 它也没有't require any changes to the database, custom macros in ~/.rpmmacros (which would change depending on the system it'正在 Build )

相关问题