【Ovirt 笔记】ovirt-engine.spec 配置分析与整理
分析整理的版本为 Ovirt 3.4.5 版本。
制作 RPM 软件包并不是一件复杂的工作,其中的关键在于编写 SPEC 软件包形容文件。这个文件中包含了软件包的名字、版本、类别、说明摘要、创立时要执行什么指令、安装时要执行什么操作、以及软件包所要包含的文件列表 等等。
制作 engine RPM 包的准备工作
安装rpm-build
yum install rpm-build新建 engine 发布所需文件夹
- 在 root 根目录下,新建 rpmbuild 文件夹(/root/rpmbuild)
- 在 rpmbuild 目录下,新建:
- BUILD(项目解压包后存放的目录 /root/rpmbuild/BUILD)
- BUILDROOT(项目解压包过程中的临时目录 /root/rpmbuild/BUILDROOT)
- RPMS(打包完成后 rpm 包的存放路径 /root/rpmbuild/RPMS)
- SOURCES(源码压缩包存放的路径,源码压缩包名称需要与 SPECS/ovirt-engine.spec 中指定的名称一致 /root/rpmbuild/SOURCES)
- SPECS(spec 文档放置的路径 /root/rpmbuild/SPECS)
- SRPMS(源码 rpm 包存放的路径 /root/rpmbuild/SRPMS)
压缩源码工程目录
- 对开发环境下的源码工程 ovirt-engine 进行压缩,执行:
zip -r root-3.4.5-scm-sources.zip ovirt-engine- 源码压缩包名称需要与 SPECS/ovirt-engine.spec 中指定的名称一致(Source0:root-3.4.5-scm-sources.zip)
- 由于源码编译针对所有的浏览器进行,因而速度很慢,假如只是为了测试打包环境,可以修改源码中的 Makefile 文件中。将
BUILD_FLAGS:=$(BUILD_FLAGS) -D gwt.locale=en_US,zh_CN注释掉,改为BUILD_FLAGS:=$(BUILD_FLAGS) -D gwt.locale=en_US,zh_CN -D gwt.userAgent=gecko1_8。 - 压缩前,需要对在工程目录下执行 make clean(不要使用 mvn clean 可能会清理不干净)命令,清理编译结果文件等。
- 拷贝 root-3.4.5-scm-sources.zip 压缩包文件至 /root/rpmbuild/SOURCES 下。
执行打包命令
- cd /root/rpmbuild 下,执行:
rpmbuild -ba SPECS/ovirt-engine.spec| 参数 | 形容 |
|---|---|
| -bp | 解决 spec 文件的 pre 部分 |
| -bc | 解决 spec 文件的 pre 和 build 部分 |
| -bi | 解决 spec 文件的 pre、build 和 install 部分 |
| -bl | 校验 spec 文件的 files 部分 |
| -bb | 根据 spec 文件构建二进制 RPM |
| -bs | 根据 spec 文件构建源代码 RPM |
| -ba | 根据 spec 文件同时构建二进制 RPM 和源代码 RPM |
| –clean | 完成打包后清理 BUILD 下的文件目录 |
| –nobuild | 不进行 BUILD 的阶段 |
| –rmsource | 完成打包后清理 SOURCES |
| –rmspec | 完成打包后清理 SPEC 文件 |
| –macros=<FILE:…> | 读<FILE:…>文件代替默认文件 |
| –showrc | 显示最终的配置信息 |
| –quiet | 提供一些的信息 |
| -v,–verbose | 提供大量的详细的信息 |
| –version | 显示 PRM 包的版本 |
- 打包后的 rpm 软件包在 /root/rpmbuild/RPMS/noarch 目录中,可以通过命令查看配置信息
rpm --showrc sdcvm-3.4.5-0.5.15.sdcos.noarch.rpm[root@localhost noarch]# rpm --showrc sdcvm-3.4.5-0.5.15.sdcos.noarch.rpmARCHITECTURE AND OS:build arch : x86_64compatible build archs: x86_64 noarchbuild os : Linuxcompatible build os's : Linuxinstall arch : x86_64install os : Linuxcompatible archs : x86_64 amd64 em64t athlon noarch i686 i586 i486 i386 fatcompatible os's : LinuxRPMRC VALUES:optflags : %{__global_cflags} -m64 -mtune=genericFeatures supported by rpmlib: rpmlib(BuiltinLuaScripts) = 4.2.2-1 rpmlib(CompressedFileNames) = 3.0.4-1 rpmlib(ConcurrentAccess) = 4.1-1 rpmlib(ExplicitPackageProvide) = 4.0-1 rpmlib(FileCaps) = 4.6.1-1 rpmlib(FileDigests) = 4.6.0-1 rpmlib(HeaderLoadSortsTags) = 4.0.1-1 rpmlib(PartialHardlinkSets) = 4.0.4-1 rpmlib(PayloadFilesHavePrefix) = 4.0-1 rpmlib(PayloadIsBzip2) = 3.0.5-1 rpmlib(PayloadIsLzma) = 4.4.2-1 rpmlib(PayloadIsXz) = 5.2-1 rpmlib(ScriptletInterpreterArgs) = 4.0.3-1 rpmlib(TildeInVersions) = 4.10.0-1 rpmlib(VersionedDependencies) = 3.0.3-1========================......- 可以通过命令查看软件包内容
rpm -qlp sdcvm-3.4.5-0.5.15.sdcos.noarch.rpm[root@localhost noarch]# rpm -qlp sdcvm-3.4.5-0.5.15.sdcos.noarch.rpm /etc/ovirt-engine/etc/ovirt-engine/branding/etc/ovirt-engine/branding/00-ovirt.brand/etc/ovirt-engine/engine.conf/etc/ovirt-engine/engine.conf.d/etc/ovirt-engine/engine.conf.d/README/etc/pki/ovirt-engine/publicKey.keystore/etc/sdcvm/usr/share/doc/sdcvm-3.4.5/usr/share/doc/sdcvm-3.4.5/LICENSE/usr/share/java/ovirt-engine/usr/share/java/ovirt-engine/authentication.jar/usr/share/java/ovirt-engine/branding.jar/usr/share/java/ovirt-engine/common.jar/usr/share/java/ovirt-engine/compat.jar/usr/share/java/ovirt-engine/utils.jar/usr/share/java/sdcvm/usr/share/ovirt-engine/usr/share/ovirt-engine/bin......ovirt-engine.spec 语法分析整理
- %global 定义全局宏
......%global ovirt_product_name SdcOS Enterprise Virtualization Manager%global ovirt_product_name_short SDC-VM%global ovirt_product_group Management/SdcOS%global ovirt_user_description oVirt Manager%global engine_cache %{_localstatedir}/cache/%{engine_name}%global engine_data %{_datadir}/%{engine_name}%global engine_doc %{_docdir}/%{engine_name}%global engine_ear %{engine_data}/engine.ear%global engine_etc %{_sysconfdir}/%{engine_name}%global engine_java %{_javadir}/%{engine_name}%global engine_jboss_modules %{engine_data}/modules%global engine_log %{_localstatedir}/log/%{engine_name}%global engine_name ovirt-engine%global engine_pki %{_sysconfdir}/pki/%{engine_name}%global engine_restapi_war %{engine_ear}/restapi.war%global engine_legacy_restapi_war %{engine_ear}/legacy_restapi.war%global engine_run %{_localstatedir}/run/%{engine_name}%global engine_state %{_localstatedir}/lib/%{engine_name}%global engine_tmp %{_localstatedir}/tmp/%{engine_name}......- %if %else 与 %endif 条件语句块
%if 0%{?_ovirt_build_ut:1}%global ovirt_build_ut %{_ovirt_build_ut}%else%global ovirt_build_ut 1%endif其中 0%{?_ovirt_build_ut:1} 是条件,0 为假,非 0 为真。
- ?: 结构
%{?变量:动作} 其中 {} 用于控制范围,而 ? 号和 : 号是分割符。? 号判断变量能否定义,定义了就为真,否则就为假,为真执行动作。例子中 _ovirt_build_ut 变量存在则输出 1,0 加上 1 非 0 所以 %if 为真,执行 %global ovirt_build_ut %{_ovirt_build_ut} 全局宏赋值。相反 %if 0 为假,执行 %global ovirt_build_ut 1。
- Name 软件包的名称,后面可使用 %{name} 的方式引用
Name: sdcvm- Version 软件的实际版本号,后面可使用 %{version} 引用
Version: 3.4.5- Release 发布序列号,后面可使用 %{release} 引用
Release: 0.5.15.sdcos- Summary 软件包的内容概要
Summary: Management server for SdcOS Virtualization- Group 软件分组,软件包所属类别
参考分组类别:
| 组名 | 说明 |
|---|---|
| Amusements/Games | 娱乐/游戏 |
| Amusements/Graphics | 娱乐/图形 |
| Applications/Archiving | 应用/文档 |
| Applications/Communications | 应用/通讯 |
| Applications/Databases | 应用/数据库 |
| Applications/Editors | 应用/编辑器 |
| Applications/Emulators | 应用/仿真器 |
| Applications/Engineering | 应用/工程 |
| Applications/File | 应用/文件 |
| Applications/Internet | 应用/因特网 |
| Applications/Multimedia | 应用/多媒体 |
| Applications/Productivity | 应用/产品 |
| Applications/Publishing | 应用/印刷 |
| Applications/System | 应用/系统 |
| Applications/Text | 应用/文本 |
| Development/Debuggers | 开发/调试器 |
| Development/Languages | 开发/语言 |
| Development/Libraries | 开发/函数库 |
| Development/System | 开发/系统 |
| Development/Tools | 开发/工具 |
| Documentation | 文档 |
| System Environment/Base | 系统环境/基础 |
| System Environment/Daemons | 系统环境/守护 |
| System Environment/Kernel | 系统环境/内核 |
| System Environment/Libraries | 系统环境/函数库 |
| System Environment/Shells | 系统环境/接口 |
| User Interface/Desktops | 客户界面/桌面 |
| User Interface/X | 客户界面/X窗口 |
| User Interface/X Hardware Support | 客户界面/X硬件支持 |
Group: Management/SdcOS- License 软件受权方式,通常为 GPL
BSD 开源协议
BSD 开源协议是一个给于使用者很大自由的协议。基本上使用者可以”为所欲为”,可以自由的使用,修改源代码,也可以将修改后的代码作为开源或者者专有软件再发布。
但”为所欲为”的前提当你发布使用了BSD协议的代码,或者则以 BSD 协议代码为基础做二次开发自己的产品时,需要满足三个条件:
1)假如再发布的产品中包含源代码,则在源代码中必需带有原来代码中的 BSD 协议。
2)假如再发布的只是二进制类库/软件,则需要在类库/软件的文档和版权公告中包含原来代码中的 BSD 协议。
3)不可以用开源代码的作者/机构名字和原来产品的名字做市场推广。
BSD 代码鼓励代码共享,但需要尊重代码作者的著作权。BSD 因为允许使用者修改和重新发布代码,也允许使用或者在 BSD 代码上开发商业软件发布和销售,因而是对 商业集成很友好的协议。而很多的公司企业在选用开源产品的时候都首选 BSD 协议,由于可以完全控制这些第三方的代码,在必要的时候可以修改或者者二次开发。
ASL 开源协议
ASL 许可证被开源软件广泛使用,并且得到了 开放源码促进会(Open Source Initiative)的认可。它是一种不设限的许可证(permissive license),允许软件的商业性开发和垄断式发布。以ASL发布的代码,可以被合并入闭源的专有软件(proprietary product),并且在各种各样的限制性条件下发布。
需要满足的条件也和 BSD 相似:
1)需要给代码的客户一份 Apache Licence
2)假如你修改了代码,需要再被修改的文件中说明。
3)在延伸的代码中(修改和有源代码衍生的代码中)需要带有原来代码中的协议,商标,专利公告和其余原来作者规定需要包含的说明。
4)假如再发布的产品中包含一个 Notice 文件,则在 Notice 文件中需要带有 Apache Licence。你可以在 Notice 中添加自己的许可,但不可以体现为对 Apache Licence 构成更改。
GPL
我们很熟习的 Linux 就是采用了GPL。GPL 协议和 BSD, Apache Licence 等鼓励代码重用的许可很不一样。GPL 的出发点是代码的开源/免费使用和引用/修改/衍生代码的开源/免费使用,但不允许修改后和衍生的代 码做为闭源的商业软件发布和销售。这也就是为什么我们能用免费的各种 linux,包括商业公司的 linux 和 linux 上各种各样的由个人,组织,以及商业软件公司开发的免费软件了。
GPL 协议的主要内容是只需在一个软件中使用(”使用”指类库引用,修改后的代码或者者衍生代码)GPL 协议的产品,则该软件产品必需也采用GPL协议,既必需也是开源和免费。这就是所谓的”传染性”。GPL 协议的产品作为一个单独的产品使用没有任何疑问, 还可以享受免费的优势。
因为 GPL 严格要求使用了 GPL 类库的软件产品必需使用 GPL 协议,对于使用 GPL 协议的开源代码,商业软件或者者对代码有保密要求的部门就不适合集成/采用作为类库和二次开发的基础。
其它细节如再发布的时候需要伴随 GPL 协议等和 BSD/Apache 等相似。
LGPL
LGPL 是 GPL 的一个为主要为类库使用设计的开源协议。和 GPL 要求任何使用/修改/衍生之 GPL 类库的的软件必需采用 GPL 协议不同。LGPL 允许商业软件通过类库引用(link)方式使用 LGPL 类库而不需要开源商业软件的代码。这使得采用 LGPL 协议的开源代码可以被商业软件作为类库引用并 发布和销售。
但是假如修改 LGPL 协议的代码或者者衍生,则所有修改的代码,涉及修改部分的额外代码和衍生的代码都必需采用 LGPL 协议。因而 LGPL 协议的开源 代码很适合作为第三方类库被商业软件引用,但不适合希望以 LGPL 协议代码为基础,通过修改和衍生的方式做二次开发的商业软件采用。
GPL/LGPL 都保障原作者的知识产权,避免有人利用开源代码复制并开发相似的产品。
MIT
MIT 是和 BSD 一样宽范的许可协议,作者只想保留版权,而无任何其余了限制。也就是说,你必需在你的发行版里包含原许可协议的公告,无论你是以二进制发布的还是以源代码发布的。
License: ASL 2.0Packager 打包者的信息,姓名以及邮箱等,处于同一行。
Vendor 软件开发者名字,发行商或者打包组织的信息。
URL 软件的主页
Source 源代码包,可以带多个用 Source1、Source2 等源,后面也可以用 %{source1}、%{source2} 引用。
Source0: root-3.4.5-scm-sources.zip- BuildArch 指编译的目标解决器架构,通常都是以 /usr/lib/rpm/marcros 中的内容为默认值
BuildArch: noarch- Requires 该 rpm 包所依赖的软件包名称,可以用 >= 或者 <= 表示大于或者小于某一特定版本。
Requires: %{name}-backend = %{version}-%{release}Requires: %{name}-cliRequires: %{name}-dbscripts = %{version}-%{release}Requires: %{name}-restapi = %{version}-%{release}Requires: %{name}-tools = %{version}-%{release}Requires: %{name}-userportal = %{version}-%{release}Requires: %{name}-webadmin-portal = %{version}-%{release}Requires: %{name}-websocket-proxy >= %{version}-%{release}Requires: sdcvm-dependencies >= 3.4.1-1Requires: javaRequires: java-1.7.0-openjdk >= 1:1.7.0.9-2.3.3.2Requires: jpackage-utilsRequires: sdcvm-image-uploader >= 3.4.3Requires: sdcvm-iso-uploader >= 3.4.4Requires: sdcvm-log-collector >= 3.4.5Requires: postgresql-server >= 8.4.7Requires: ws-commons-utilRequires: yum-plugin-versionlock......- BuildRequires 构建时依赖
BuildRequires: java-develBuildRequires: jpackage-utilsBuildRequires: makeBuildRequires: python- Conflicts 指定冲突
Conflicts: java-1.7.0-openjdk = 1:1.7.0.45-2.4.3.3.el6- Obsoletes 指定废弃依赖
Obsoletes: %{name}-config < 3.3.0- Provides 指明本软件提供少量特定的功能,以便其余 RPM 识别
Provides: %{name}-config = %{version}-%{release}- %package 定义子包,当定义一个子包时,必需至少包含 Summary、Group,任何没有指定的选项将用父包的选项,如版本等。
%package lib- %description 软件包详细说明,可写在多个行上。
%descriptionSdcOS Enterprise Virtualization is a feature-rich server virtualization managementsystem that provides advanced capabilities for managing SdcOSvirtualization infrastructure for Servers and Desktops.- %pre 这个段是预解决段,通常用来执行少量解开源程序包的命令,为下一步的编译安装作准备。
%pre backend%ovirt_create_user_engine- %post rpm 包安装后执行的脚本
%post backend%if %{ovirt_install_systemd}%systemd_post ovirt-engine.service%endif%if %{ovirt_install_systemv}chkconfig --add ovirt-engine%endif- %preun rpm 包卸载前执行的脚本
%preun backend%if %{ovirt_install_systemd}%systemd_preun ovirt-engine.service%endif- %postun rpm 包卸载后执行的脚本
%postun backend%if %{ovirt_install_systemd}%systemd_postun ovirt-engine.service%endif%prep 预解决脚本,这个段是预解决段,通常用来执行少量解开源程序包的命令,为下一步的编译安装作准备。
%build 建立段,所要执行的命令为生成软件包服务,如 make 命令。
%buildmake %{make_common_opts}- %install 安装段,其中的命令在安装软件包时将执行,如 make install 命令。
%installrm -fr "%{buildroot}"make %{make_common_opts} install DESTDIR="%{buildroot}"- %files 文件段,用于定义软件包所包含的文件,分为三类–说明文档(doc),配置文件(config)及执行程序,还可定义文件存取权限,拥有者及组别。
%files%dir %attr(-, %{engine_user}, %{engine_group}) %{engine_cache}%dir %attr(-, %{engine_user}, %{engine_group}) %{engine_log}%dir %attr(-, %{engine_user}, %{engine_group}) %{engine_log}/dump%dir %{engine_data}%dir %{engine_data}/bin%dir %{engine_data}/branding%dir %{engine_data}/conf%dir %{engine_data}/engine.ear%dir %{engine_data}/services%dir %{engine_etc}%dir %{engine_etc}/branding%dir %{engine_java}%doc LICENSE%ghost %config(noreplace) %{engine_etc}/engine.conf%{engine_data}/branding/ovirt.brand/%{engine_etc}/branding/00-ovirt.brand%{engine_etc}/engine.conf.d/%{engine_java}/authentication.jar%{engine_java}/branding.jar%{engine_java}/common.jar%{engine_java}/compat.jar%{engine_java}/utils.jar%{engine_pki}/publicKey.keystore......注意:%install 部分使用的是绝对路径,而 %file 部分使用则是相对路径
- %dir 仅是一个空目录打进包里。
- %doc 表示这是文档文件。
- %ghost 该文件不应该包含在包中,一般是日志文件,其文件属性很重要,但是文件内容不重要,用了这个选项后,仅将其文件属性加入包中。
- %attr(mode, user, group) filename 控制文件的权限如 %attr(0644,root,root) /etc/engine.conf
- %config 标志该文件是一个配置文件,假如指定目录已有该文件,进行覆盖。
- %config(noreplace) 标志该文件是一个配置文件,假如指定目录已有该文件,不进行覆盖。
%config %{_sysconfdir}/logrotate.d/ovirt-engine- %setup 解压源代码,将当前目录改为源代码解压之后产生的目录。
| 参数 | 说明 |
|---|---|
| -q | 在安静模式下且最少输出 |
| -D | 在解压之前禁止删除目录 |
| -a number | 在改变目录后,仅解压给定数字的源码,如 -a 0 for source0 |
| -n newdir | 将软件包解压到 newdir 目录 |
| -c | 解压缩之前先产生目录 |
| -b number | 包含多个源文件时,将第 num 个 source 文件解压缩 |
| -T | 不使用 default 的解压缩操作 |
%setup -q -T -b 0 -n ovirt-engine- %changelog 修改日志段。可以将软件的每次修改记录到这里,保存到发布的软件包中,以便查询之用。每一个修改日志都有这样一种格式:第一行是:* 星期 月 日 年 修改人 电子信箱。其中:星期、月份均用英文形式的前 3 个 字母,用中文会报错。接下来的行写的是修改了什么地方,可写多行。一般以减号开始,便于后续的查阅。
%changelog* Mon Jan 27 2015 Max Kovgan <mvk@redhat.com> - 3.4.5- BZ#1169352 BZ#1151053 BZ#1166010 BZ#1147396 BZ#1169404 BZ#1180072 BZ#1171467 BZ#1154184* Mon Nov 10 2014 Barak Korren <bkorren@redhat.com> - 3.4.4- BZ#1135112 BZ#1141761 BZ#1152448 BZ#1154569 BZ#1155557 BZ#1155571 BZ#1155573 BZ#1155649 BZ#1155698 BZ#1155906 BZ#1155920 BZ#1155986 BZ#1155987 BZ#1156012 BZ#1157212 BZ#1157678 BZ#1158042 BZ#1158090 BZ#1159751 BZ#1159761 BZ#1159849 BZ#1161923* Tue Oct 13 2014 David Caro <dcaro@redhat.com> - 3.4.3- BZ#1128461 BZ#1147909 BZ#1122945 BZ#1134825 BZ#1131021 BZ#1136010 BZ#1130887 BZ#1147609 BZ#1147827 BZ#1131856 BZ#1147396 BZ#1135939 BZ#1142203 BZ#1142418 BZ#1138249 BZ#1139211 BZ#1099505 BZ#1128462 BZ#1136031 BZ#1135920 BZ#1122932 BZ#1138753 BZ#1150545 BZ#1151410 BZ#1135939 BZ#1151822 BZ#1142203 BZ#1145779 BZ#1126430......宏
使用 百分号 加命令关键字是调用宏,所有的宏都可以在 /usr/lib/rpm/macros 里找到。
vi /usr/lib/rpm/macros# ---- Generally useful path macros.#%__awk gawk%__bzip2 /usr/bin/bzip2%__cat /bin/cat%__chgrp /bin/chgrp%__chmod /bin/chmod%__chown /bin/chown%__cp /bin/cp%__cpio /bin/cpio%__file /usr/bin/file%__gpg /usr/bin/gpg%__grep /bin/grep%__gzip /usr/bin/gzip%__id /usr/bin/id%__install /usr/bin/install%__ln_s ln -s# Deprecated, use %__xz instead.%__lzma %__xz --format=lzma......其余相关
- %ifarch 判断解决器结构,%ifnoarch 与之相反
%ifarch sparc s390- %ifos 判断操作系统,%ifnoos 与之相反
%ifos linuxpatch 补丁源码,可使用 patch1、patch2 等标识多个补丁,使用 %{patch0} 引用。
%define 定义宏
ovirt-engine.spec 内容分析整理
定制板块
- 根据传递的参数,指定能否进行快速构建、最小构建,能否构建 UT、GWT、LOCALE。
- 参数可以通过 -D 方式指定
rpmbuild -ba SPECS/ovirt-engine.spec -D 'ovirt_build_quick 1'全局变量定义
- 定义目录、权限、标记位等
%global ovirt_product_name SdcOS Enterprise Virtualization Manager%global ovirt_product_name_short SDC-VM%global ovirt_product_group Management/SdcOS%global ovirt_user_description oVirt Manager%global engine_cache %{_localstatedir}/cache/%{engine_name}%global engine_data %{_datadir}/%{engine_name}%global engine_doc %{_docdir}/%{engine_name}%global engine_ear %{engine_data}/engine.ear%global engine_etc %{_sysconfdir}/%{engine_name}%global engine_java %{_javadir}/%{engine_name}%global engine_jboss_modules %{engine_data}/modules%global engine_log %{_localstatedir}/log/%{engine_name}%global engine_name ovirt-engine%global engine_pki %{_sysconfdir}/pki/%{engine_name}%global engine_restapi_war %{engine_ear}/restapi.war%global engine_legacy_restapi_war %{engine_ear}/legacy_restapi.war%global engine_run %{_localstatedir}/run/%{engine_name}%global engine_state %{_localstatedir}/lib/%{engine_name}%global engine_tmp %{_localstatedir}/tmp/%{engine_name}%global engine_gid 108%global engine_group ovirt%global engine_uid 108%global engine_user ovirt%global vdsm_description Node Virtualization Manager%global vdsm_gid 36%global vdsm_group kvm%global vdsm_uid 36%global vdsm_user vdsm| 变量 | 值 | 变量说明 | 值说明 | 备注 |
|---|---|---|---|---|
| ovirt_build_ut | 0 | 能否可以设置测试参数 | 否 | |
| ovirt_build_gwt | 0 | 能否可以设置 GWT 构造相关参数 | 否 | |
| ovirt_build_locales | 0 | 能否可以设置 GWT 本地化相关参数 | 否 | |
| __jar_repack | 0 | 能否将 jar 包重新打包,会执行 brp-java-repack-jars | 否 | |
| ovirt_build_quick | 空 | 能否快速构建 | 否 | 参数不为空即是 |
| ovirt_build_minimal | 空 | 能否最小构建 | 否 | 参数不为空即是 |
| _jarsign_opts | –unsign=/usr/share/ovirt-engine | 无签名目录 | 指定无签名目录 | |
| fedora | 空 | 能否 fedora 版本 | 参数不为空即是 | |
| rhel | 空 | 能否 rhel 版本 | 参数不为空即是 | |
| ovirt_install_systemd | 1 | 能否安装 systemd | 非 0 为是 | |
| ovirt_install_systemv | 0 | 能否安装 system V | 是 | |
| ovirt_install_poms | 0 | 能否升级 maven 的 artifacts 以及文件的映射关系 | 否 | |
| ovirt_require_maven | 1 | 能否添加 maven 依赖 | 是 | |
| ovirt_product_name | SdcOS Enterprise Virtualization Manager | 产品名称 | ||
| ovirt_product_name_short | SDC-VM | 产品简称 | ||
| ovirt_product_group | Management/SdcOS | 产品组类别 | ||
| ovirt_user_description | oVirt Manager | 客户形容信息 | ||
| engine_name | ovirt-engine | 名称 | ||
| engine_cache | %{_localstatedir}/cache/%{engine_name} | engine 缓存目录 | /var/cache/ovirt-engine | |
| engine_data | %{_datadir}/%{engine_name} | engine 数据目录 | /usr/share/ovirt-engine | |
| engine_doc | %{_docdir}/%{engine_name} | engine 文档目录 | /usr/doc/ovirt-engine | |
| engine_ear | %{engine_data}/engine.ear | engine ear 所在目录 | /usr/share/ovirt-engine/engine.ear | |
| engine_etc | %{_sysconfdir}/%{engine_name} | etc 目录下 engine 配置目录 | /etc/ovirt-engine | |
| engine_java | %{_javadir}/%{engine_name} | java 目录下 engine 目录 | /usr/share/ovirt-engine/java/ovirt-engine | |
| engine_jboss_modules | %{engine_data}/modules | engine jboss 板块化相关目录 | /usr/share/ovirt-engine/modules | |
| engine_log | %{_localstatedir}/log/%{engine_name} | engine 日志目录 | /var/log/ovirt-engine | |
| engine_pki | %{_sysconfdir}/pki/%{engine_name} | engine 加密相关目录 | /etc/pki/ovirt-engine | |
| engine_restapi_war | %{engine_ear}/restapi.war | engine rest api 项目路径 | /usr/share/ovirt-engine/engine.ear/restapi.war | |
| engine_legacy_restapi_war | %{engine_ear}/legacy_restapi.war | engine rest api legacy 项目路径 | /usr/share/ovirt-engine/engine.ear/legacy_restapi.war | |
| engine_run | %{_localstatedir}/run/%{engine_name} | engine 运行目录 | /var/run/ovirt-engine | |
| engine_state | %{_localstatedir}/lib/%{engine_name} | engine 状态目录 | /var/lib/ovirt-engine | |
| engine_tmp | %{_localstatedir}/tmp/%{engine_name} | engine 临时文件目录 | /var/tmp/ovirt-engine | |
| engine_gid | 108 | engine 组ID | ||
| engine_group | ovirt | engine 组名 | ||
| engine_uid | 108 | engine 客户ID | ||
| engine_user | ovirt | engine 客户名 | ||
| vdsm_description | Node Virtualization Manager | vdsm 形容信息 | ||
| vdsm_gid | 36 | vdsm 组ID | ||
| vdsm_group | kvm | vdsm 组名 | ||
| vdsm_uid | 36 | vdsm 客户ID | ||
| vdsm_user | vdsm | vdsm 客户名 | ||
| openstack_java_version | 3.0.2 | OpenStack 软件包最低版本 | ||
| sdcvm_dependencies_slot | 3.4 | 板块化依赖的版本位置 |
系统宏变量说明
| 变量 | 值 |
|---|---|
| %{buildroot} | /root/rpmbuild/BUILDROOT |
| %{_bindir} | /usr/bin |
| %{_mandir} | /usr/share/man |
| %{_sysconfdir} | /etc |
| %{_initddir} | |
| %{_unitdir} | |
| %{_mavenpomdir} |
定义软件包基本属性
Name: sdcvmVersion: 3.4.5Release: 0.5.15.sdcosSummary: Management server for SdcOS VirtualizationGroup: %{ovirt_product_group}License: ASL 2.0Packager: Vendor: URL: # Acquire brew/mead pre-built resources.Source0: root-3.4.5-scm-sources.zipBuildArch: noarch定义软件包依赖关系
Requires: %{name}-backend = %{version}-%{release}Requires: %{name}-cliRequires: %{name}-dbscripts = %{version}-%{release}Requires: %{name}-restapi = %{version}-%{release}Requires: %{name}-tools = %{version}-%{release}Requires: %{name}-userportal = %{version}-%{release}Requires: %{name}-webadmin-portal = %{version}-%{release}Requires: %{name}-websocket-proxy >= %{version}-%{release}Requires: sdcvm-dependencies >= 3.4.1-1Requires: javaRequires: java-1.7.0-openjdk >= 1:1.7.0.9-2.3.3.2Requires: jpackage-utilsRequires: sdcvm-image-uploader >= 3.4.3Requires: sdcvm-iso-uploader >= 3.4.4Requires: sdcvm-log-collector >= 3.4.5Requires: postgresql-server >= 8.4.7Requires: ws-commons-utilRequires: yum-plugin-versionlock定义 lib 子包基本属性及依赖
%package libSummary: %{ovirt_product_name_short} libraryGroup: %{ovirt_product_group}Requires: python-daemon- 定义 lib 形容信息
%description lib%{ovirt_product_name_short} library定义 backend 子包基本属性及依赖
%package backendSummary: Engine core of %{ovirt_product_name_short}Group: %{ovirt_product_group}Requires: %{name} = %{version}-%{release}Requires: %{name}-lib >= %{version}-%{release}Requires: httpdRequires: javaRequires: logrotateRequires: bzip2Requires: mailcapRequires: mod_sslRequires: novncRequires: opensslRequires: ovirt-host-deploy-java >= 1.2.2Requires: python-cheetahRequires: spice-html5Requires: sdcvm-branding-rhev >= 3.4.0-0.3%if %{ovirt_install_systemd}Requires(post): systemdRequires(preun): systemdRequires(postun): systemd%endif- 定义 backend 形容信息
%description backendThe backend engine of %{ovirt_product_name_short}安装 backend 之前执行
- 创立安装客户与权限
%pre backend%ovirt_create_user_engine%global ovirt_create_user_engine \%_ovirt_create_user %{engine_user} %{engine_uid} %{engine_group} %{engine_gid} "%{ovirt_user_description}" %{engine_state}安装 backend 之后执行
- 添加 ovirt-engine 服务
%if %{ovirt_install_systemd}%systemd_post ovirt-engine.service%endif%if %{ovirt_install_systemv}chkconfig --add ovirt-engine%endif卸载 backend 之前执行
- 中止 ovirt-engine 服务
%preun backend%if %{ovirt_install_systemd}%systemd_preun ovirt-engine.service%endif%if %{ovirt_install_systemv}if [ $1 -eq 0 ]; then service ovirt-engine stop > /dev/null 2>&1 || true chkconfig --del ovirt-enginefi%endif卸载 backend 之后执行
- 删除 ovirt-engine 服务
%postun backend%if %{ovirt_install_systemd}%systemd_postun ovirt-engine.service%endif定义 desktopManager 子包基本属性及依赖
%package desktopManagerSummary: desktopManager of %{ovirt_product_name_short}Group: %{ovirt_product_group}Requires: %{name} = %{version}-%{release}Requires: %{name}-lib >= %{version}-%{release}Requires: httpdRequires: javaRequires: %{name}-backend >= %{version}-%{release}- 定义 desktopManager 形容信息
%description desktopManagerThe desktopManager of %{ovirt_product_name_short}安装 desktopManager 之后执行
- 执行代码拷贝和数据库表格创立
cp -af %{engine_ear}/desktopManager.war/page/welcome.js %{engine_ear}/welcome.war/js/welcome.jscp -af %{engine_ear}/desktopManager.war/page/welcome.src.js %{engine_ear}/welcome.war/js/welcome.src.jscp -af %{engine_ear}/desktopManager.war/page/ovirt-engine.jsp %{engine_ear}/welcome.war/WEB-INF/ovirt-engine.jspcp -af %{engine_ear}/desktopManager.war/page/style.css %{engine_ear}/welcome.war/welcome/style.csssh %{engine_ear}/desktopManager.war/dbscript/updatepgsql.sh卸载 desktopManager 之后执行
- 执行代码删除和数据库表格删除
if [ -f %{engine_ear}/desktopManager.war/ui/un-index.html ]; thenmv -f %{engine_ear}/desktopManager.war/ui/un-index.html %{engine_ear}/desktopManager.war/ui/index.htmlfish %{engine_ear}/desktopManager.war/dbscript/delpgsql.sh定义 restapi 子包基本属性及依赖
Summary: RESTful API for %{ovirt_product_name_short}Group: %{ovirt_product_group}Requires: %{name} = %{version}-%{release}- 定义 restapi 形容信息
%description restapiThe RESTful API for %{ovirt_product_name_short}安装 restapi 之后执行
- 升级 maven 的 artifacts 以及文件的映射关系,由 Apache Ant 或者 MVN rpmbuild 实现。
%post restapi%if %{ovirt_install_poms}%update_maven_depmap%endif卸载 restapi 之后执行
- 升级 maven 的 artifacts 以及文件的映射关系,由 Apache Ant 或者 MVN rpmbuild 实现。
%postun restapi%if %{ovirt_install_poms}%update_maven_depmap%endif定义 setup-base 子包基本属性及依赖
%package setup-baseSummary: %{ovirt_product_name_short} suite base setup components.Group: %{ovirt_product_group}Requires: %{name}-lib >= %{version}-%{release}Requires: bind-utilsRequires: iprouteRequires: libxml2-pythonRequires: logrotateRequires: otopi >= 1.2.3- 定义 setup-base 形容信息
%description setup-base%{ovirt_product_name_short} suite base setup components.安装 setup-base 之前执行
- 创立 engine 相关客户和权限
%pre setup-base%ovirt_create_user_engine%global ovirt_create_user_engine \%_ovirt_create_user %{engine_user} %{engine_uid} %{engine_group} %{engine_gid} "%{ovirt_user_description}" %{engine_state}定义 setup 子包基本属性及依赖
%package setupSummary: Setup and upgrade scripts for %{ovirt_product_name_short}Group: %{ovirt_product_group}Requires: %{name}-setup-plugin-ovirt-engine = %{version}-%{release}Requires: sdcvm-setup-plugins >= 3.4.4- 定义 setup 形容信息
%description setupSetup and upgrade scripts for %{ovirt_product_name_short}定义 setup-plugin-ovirt-engine 子包基本属性及依赖
%package setup-plugin-ovirt-engineSummary: Setup and upgrade specific plugins for %{ovirt_product_name_short}Group: %{ovirt_product_group}Requires: %{name}-setup-plugin-ovirt-engine-common = %{version}-%{release}Requires: %{name} >= 3.3.1Conflicts: %{name} < 3.3.1- 定义 setup-plugin-ovirt-engine 形容信息
%description setup-plugin-ovirt-engineSetup and upgrade specific plugins for %{ovirt_product_name_short}安装 setup-plugin-ovirt-engine 之前执行
- 创立 vdsm 相关客户和权限
%pre setup-plugin-ovirt-engine%ovirt_create_user_vdsm%global ovirt_create_user_vdsm \%_ovirt_create_user %{vdsm_user} %{vdsm_uid} %{vdsm_group} %{vdsm_gid} "%{vdsm_description}" /var/lib/vdsm定义 setup-plugin-ovirt-engine-common 子包基本属性及依赖
%package setup-plugin-ovirt-engine-commonSummary: Setup and upgrade common plugins for %{ovirt_product_name_short}Group: %{ovirt_product_group}Requires: %{name}-setup-base = %{version}-%{release}Requires: cracklib-pythonRequires: libselinux-pythonRequires: m2cryptoRequires: nfs-utilsRequires: policycoreutils-pythonRequires: python-psycopg2Requires: yum- 定义 setup-plugin-ovirt-engine-common 形容信息
%description setup-plugin-ovirt-engine-commonSetup and upgrade common plugins for %{ovirt_product_name_short}定义 dbscripts 子包基本属性及依赖
%package dbscriptsSummary: Database scripts for %{ovirt_product_name_short}Group: %{ovirt_product_group}Requires: %{name} = %{version}-%{release}- 定义 dbscripts 形容信息
%description dbscriptsDatabase scripts for %{ovirt_product_name_short}定义 userportal 子包基本属性及依赖
%package userportalSummary: User Portal of %{ovirt_product_name_short}Group: %{ovirt_product_group}Requires: %{name} = %{version}-%{release}- 定义 userportal 形容信息
%description userportalThe user portal interface to %{ovirt_product_name_short}定义 webadmin-portal 子包基本属性及依赖
%package webadmin-portalSummary: Web Admin Portal of %{ovirt_product_name_short}Group: %{ovirt_product_group}Requires: %{name} = %{version}-%{release}- 定义 webadmin-portal 形容信息
%description webadmin-portalThe web administration interface to %{ovirt_product_name_short}定义 tools 子包基本属性及依赖
%package toolsSummary: %{ovirt_product_name_short} ToolsGroup: %{ovirt_product_group}Requires: %{name} = %{version}-%{release}Requires: %{name}-lib >= %{version}-%{release}Requires: javaRequires: logrotate- 指定废弃的依赖包
Obsoletes: %{name}-config < 3.3.0Obsoletes: %{name}-genericapi < 3.3.0Obsoletes: %{name}-notification-service < 3.3.0Obsoletes: %{name}-tools-common < 3.3.0- 指定特定功能依赖包
Provides: %{name}-config = %{version}-%{release}Provides: %{name}-genericapi = %{version}-%{release}Provides: %{name}-notification-service = %{version}-%{release}Provides: %{name}-tools-common = %{version}-%{release}- 定义 tools 形容信息
%description tools%{ovirt_product_name_short} Tools安装 tools 之前执行
- 创立客户及设置权限
%pre tools%ovirt_create_user_engine安装 tools 之后执行
- 增加 ovirt-engine-notifier 服务
%post tools%if %{ovirt_install_systemd}%systemd_post ovirt-engine-notifier.service%endif%if %{ovirt_install_systemv}chkconfig --add ovirt-engine-notifier%endif- 升级 maven 的 artifacts 以及文件的映射关系,由 Apache Ant 或者 MVN rpmbuild 实现。
%if %{ovirt_install_poms}%update_maven_depmap%endif卸载 tools 之前执行
- 中止 ovirt-engine-notifier 服务
%preun tools%if %{ovirt_install_systemd}%systemd_preun ovirt-engine-notifier.service%endif%if %{ovirt_install_systemv}if [ $1 -eq 0 ]; then service ovirt-engine-notifier stop > /dev/null 2>&1 || true chkconfig --del ovirt-engine-notifierfi%endif卸载 tools 之后执行
- 删除 ovirt-engine-notifier 服务
%postun tools%if %{ovirt_install_systemd}%systemd_postun ovirt-engine-notifier.service%endif- 升级 maven 的 artifacts 以及文件的映射关系,由 Apache Ant 或者 MVN rpmbuild 实现。
%if %{ovirt_install_poms}%update_maven_depmap%endif定义 websocket-proxy 子包基本属性及依赖
%package websocket-proxySummary: %{ovirt_product_name_short} Websocket ProxyGroup: %{ovirt_product_group}Requires: %{name}-lib >= %{version}-%{release}Requires: m2cryptoRequires: python-websockifyRequires: %{name}-setup-plugin-websocket-proxy >= %{version}-%{release}- 定义 websocket-proxy 形容信息
%description websocket-proxy%{ovirt_product_name_short} Websocket Proxy安装 websocket-proxy 之前执行
- 创立 engine 相关客户和权限
%pre setup-base%ovirt_create_user_engine安装 websocket-proxy 之后执行
- 增加 ovirt-websocket-proxy 服务
%post websocket-proxy%if %{ovirt_install_systemd}%systemd_post ovirt-websocket-proxy.service%endif%if %{ovirt_install_systemv}chkconfig --add ovirt-websocket-proxy%endif卸载 websocket-proxy 之前执行
- 中止 ovirt-websocket-proxy 服务
%preun websocket-proxy%if %{ovirt_install_systemd}%systemd_preun ovirt-websocket-proxy.service%endif%if %{ovirt_install_systemv}if [ $1 -eq 0 ]; then service ovirt-websocket-proxy stop > /dev/null 2>&1 || true chkconfig --del ovirt-websocket-proxyfi%endif卸载 websocket-proxy 之后执行
- 删除 ovirt-websocket-proxy 服务
%postun websocket-proxy%if %{ovirt_install_systemd}%systemd_postun ovirt-websocket-proxy.service%endif定义 setup-plugin-websocket-proxy 子包基本属性及依赖
Summary: Setup and upgrade specific plugins for websocket-proxyRequires: %{name}-setup-base = %{version}-%{release}- 定义 setup-plugin-websocket-proxy 形容信息
%description setup-plugin-websocket-proxySetup and upgrade specific plugins for websocket-proxy定义 setup-plugin-allinone 子包基本属性及依赖
Summary: All-in-one plugin for %{ovirt_product_name_short}'s setupGroup: %{ovirt_product_group}Requires: %{name}-sdk-python >= 3.4.3.0Requires: %{name}-setup-plugin-ovirt-engine = %{version}-%{release}Requires: openssh-serverRequires: ovirt-host-deploy >= 1.2.2Requires: ovirt-host-deploy-offline >= 1.2.1- 定义 setup-plugin-allinone 形容信息
%description setup-plugin-allinoneAll-in-one plugin for %{ovirt_product_name_short}'s setup预解决脚本
- 静默解压源码,放入新目录 ovirt-engine 中。
%prep# Collect brew/mead binary artifacts%setup -q -T -b 0 -n ovirt-engine编译源码构建包
%buildmake %{make_common_opts}%global make_common_opts \\\ -j1 \\\ BUILD_GWT=%{ovirt_build_gwt} \\\ BUILD_LOCALES=%{ovirt_build_locales} \\\ BUILD_UT=%{ovirt_build_ut} \\\ BUILD_VALIDATION=0 \\\ PACKAGE_NAME=%{name} \\\ RPM_VERSION=%{version} \\\ RPM_RELEASE=%{release} \\\ DISPLAY_VERSION=%{version}-%{release} \\\ ENGINE_NAME=%{engine_name} \\\ LOCALSTATE_DIR=%{_localstatedir} \\\ PREFIX=%{_prefix} \\\ SYSCONF_DIR=%{_sysconfdir} \\\ BIN_DIR=%{_bindir} \\\ PID_DIR=%{_localstatedir}/run \\\ DATAROOT_DIR=%{_datadir} \\\ MAN_DIR=%{_mandir} \\\ DOC_DIR=%{_docdir} \\\ PYTHON=%{__python} \\\ PYTHON_DIR=%{python_sitelib} \\\ JAVA_DIR=%{_javadir} \\\ MAVENPOM_DIR=%{_mavenpomdir} \\\ PKG_SYSCONF_DIR=%{engine_etc} \\\ PKG_DOC_DIR=%{engine_doc} \\\ PKG_EAR_DIR=%{engine_ear} \\\ PKG_PKI_DIR=%{engine_pki} \\\ PKG_JBOSS_MODULES=%{engine_jboss_modules} \\\ PKG_CACHE_DIR=%{engine_cache} \\\ PKG_LOG_DIR=%{engine_log} \\\ PKG_TMP_DIR=%{engine_tmp} \\\ PKG_STATE_DIR=%{engine_state} \\\ PKG_USER=%{engine_user} \\\ PKG_GROUP=%{engine_group} \\\ JBOSS_HOME=/usr/share/jbossas \\\ MAVEN_OUTPUT_DIR=. \\\ %{?BUILD_FLAGS:BUILD_FLAGS="%{BUILD_FLAGS}"} \\\ %{?EXTRA_BUILD_FLAGS:EXTRA_BUILD_FLAGS="%{EXTRA_BUILD_FLAGS}"}安装执行包到虚拟机目录
%installrm -fr "%{buildroot}"make %{make_common_opts} install DESTDIR="%{buildroot}"- 编译 python 文件
# Compile python files%{__python} -m compileall -f -q -d / "%{buildroot}"%{__python} -O -m compileall -f -q -d / "%{buildroot}"- 创立指定目录,并设置权限
install -dm 755 "%{buildroot}/%{engine_state}"/{content,setup/answers}install -dm 755 "%{buildroot}/%{engine_log}"/{host-deploy,setup,notifier,engine-manage-domains,dump}install -dm 755 "%{buildroot}/%{engine_cache}"install -dm 755 "%{buildroot}/%{engine_run}/notifier"Usage: install [OPTION]... [-T] SOURCE DEST or: install [OPTION]... SOURCE... DIRECTORY or: install [OPTION]... -t DIRECTORY SOURCE... or: install [OPTION]... -d DIRECTORY...| intall 参数 | 说明 |
|---|---|
| –backup[=CONTROL] | 为每个已存在的目的地文件进行备份。 |
| -b | 相似 –backup,但不接受任何参数。 |
| -c | 此选项不作解决。 |
| -d,–directory | 所有参数都作为目录解决,而且会创立指定目录的所有主目录。 |
| -D | 创立<目的地>前的所有主目录,而后将<来源>复制至 <目的地>;在第一种使用格式中有用。 |
| -g,–group=组 | 自行设定所属组,而不是进程目前的所属组。 |
| -m,–mode=模式 | 自行设定权限模式 (像chmod),而不是rwxr-xr-x。 |
| -o,–owner=所有者 | 自行设定所有者 (只适用于超级客户)。 |
| -p,–preserve-timestamps | 以<来源>文件的访问/修改时间作为相应的目的地文件的时间属性。 |
| -s,–strip | 用strip命令删除symbol table,只适用于第一及第二种使用格式。 |
| -S,–suffix=后缀 | 自行指定备份文件的<后缀>。 |
| -v,–verbose | 解决每个文件/目录时印出名称。 |
| –help | 显示此帮助信息并离开。 |
| –version | 显示版本信息并离开。 |
- 为选定的应用程序强制强制/ SSL。
for war in restapi legacy_restapi userportal webadmin; do sed -i \ 's#<transport-guarantee>NONE</transport-guarantee>#<transport-guarantee>CONFIDENTIAL</transport-guarantee>#' \ "%{buildroot}%{engine_ear}/${war}.war/WEB-INF/web.xml"done选定了 restapi.war、legacy_restapi.war、userportal.war、webadmin.war。
- 移动 jar 包到指定位置
while read lib_path; do java_path="%{engine_java}/$(basename "${lib_path}")" if ! [ -e "%{buildroot}/${java_path}" ] && [ -f "%{buildroot}/${lib_path}" ]; then cp "%{buildroot}/${lib_path}" "%{buildroot}/${java_path}" fi rm -f "%{buildroot}/${lib_path}" ln -s "${java_path}" "%{buildroot}${lib_path}"done << __EOF__%{engine_ear}/bll.jar%{engine_ear}/docs.war/WEB-INF/lib/branding.jar%{engine_ear}/legacy_restapi.war/WEB-INF/lib/branding.jar%{engine_ear}/lib/vdsbroker.jar%{engine_ear}/restapi.war/WEB-INF/lib/branding.jar%{engine_ear}/scheduler.jar%{engine_ear}/userportal.war/WEB-INF/lib/branding.jar%{engine_ear}/webadmin.war/WEB-INF/lib/branding.jar%{engine_ear}/welcome.war/WEB-INF/lib/branding.jar%{engine_jboss_modules}/org/ovirt/engine/core/authentication/main/authentication.jar%{engine_jboss_modules}/org/ovirt/engine/core/common/main/common.jar%{engine_jboss_modules}/org/ovirt/engine/core/compat/main/compat.jar%{engine_jboss_modules}/org/ovirt/engine/core/dal/main/dal.jar%{engine_jboss_modules}/org/ovirt/engine/core/searchbackend/main/searchbackend.jar%{engine_jboss_modules}/org/ovirt/engine/core/tools/main/tools.jar%{engine_jboss_modules}/org/ovirt/engine/core/utils/main/utils.jar%{engine_restapi_war}/WEB-INF/lib/interface-common-jaxrs.jar%{engine_restapi_war}/WEB-INF/lib/restapi-definition.jar%{engine_restapi_war}/WEB-INF/lib/restapi-jaxrs.jar%{engine_restapi_war}/WEB-INF/lib/restapi-types.jar__EOF__- 控制兼容性
%if "%{name}" != "%{engine_name}"ln -s "%{engine_name}" "%{buildroot}%{engine_java}/../%{name}"%endif- 注册 pom,安装 maven 的 artifacts 以及文件的映射关系
for pom in %{buildroot}%{_mavenpomdir}/*.pom; do pomdir="$(dirname "${pom}")" pom="$(basename "${pom}")" jpppom="JPP.${pom}" mv "${pomdir}/${pom}" "${pomdir}/${jpppom}" artifact_id="$(echo "${pom}" | sed -e 's/^%{name}-//' -e 's/\.pom//')" if [ -f "%{buildroot}%{engine_java}/${artifact_id}.jar" ]; then %add_maven_depmap "${jpppom}" "%{name}/${artifact_id}.jar" else %add_maven_depmap "${jpppom}" fidone- 建立 JBOSS 依赖关系链接
while read dst src; do [ -z "${dst}" ] && continue [ -z "${src}" ] && src="$(basename "${dst}")" dst="%{engine_jboss_modules}/${dst}" src="%{_javadir}/${src}" rm -f "%{buildroot}${dst}" ln -s "${src}" "%{buildroot}${dst}"done << __EOF__org/apache/ws/commons/main/ws-commons-util.jarorg/ovirt/otopi/main/otopi.jar otopi/otopi.jarorg/ovirt/ovirt-host-deploy/main/ovirt-host-deploy.jar ovirt-host-deploy/ovirt-host-deploy.jar%if 0%{?fedora}%if %{fedora} >= 19com/mchange/c3p0/main/c3p0.jarcom/woorea/openstack/sdk/main/glance-client.jar openstack-java-sdk/glance-client.jarcom/woorea/openstack/sdk/main/glance-model.jar openstack-java-sdk/glance-model.jarcom/woorea/openstack/sdk/main/keystone-client.jar openstack-java-sdk/keystone-client.jarcom/woorea/openstack/sdk/main/keystone-model.jar openstack-java-sdk/keystone-model.jarcom/woorea/openstack/sdk/main/openstack-client.jar openstack-java-sdk/openstack-client.jarcom/woorea/openstack/sdk/main/quantum-client.jar openstack-java-sdk/quantum-client.jarcom/woorea/openstack/sdk/main/quantum-model.jar openstack-java-sdk/quantum-model.jarcom/woorea/openstack/sdk/main/resteasy-connector.jar openstack-java-sdk/resteasy-connector.jarorg/aopalliance/main/aopalliance.jar......- 注册服务
%if %{ovirt_install_systemd}install -dm 755 "%{buildroot}%{_unitdir}"for service in ovirt-engine ovirt-engine-notifier ovirt-websocket-proxy; do cp "%{buildroot}%{engine_data}/services/${service}/${service}.systemd" "%{buildroot}%{_unitdir}/${service}.service"done%endif%if %{ovirt_install_systemv}install -dm 755 "%{buildroot}%{_initddir}"for service in ovirt-engine ovirt-engine-notifier ovirt-websocket-proxy; do cp "%{buildroot}%{engine_data}/services/${service}/${service}.sysv" "%{buildroot}%{_initddir}/${service}"done%endif- 少量配置文件及目录的定制
| 序号 | 定制说明 |
|---|---|
| 1 | install -d “%{buildroot}%{_sysconfdir}/ovirt-engine-setup.conf.d” |
| 2 | cat > “%{buildroot}%{_sysconfdir}/ovirt-engine-setup.conf.d/10-packaging.conf” |
| 3 | cat > “%{buildroot}%{_sysconfdir}/ovirt-engine-setup.conf.d/10-packaging-aio.conf” |
| 4 | install -d “%{buildroot}%{_sysconfdir}/ovirt-host-deploy.conf.d” |
| 5 | cat > “%{buildroot}%{_sysconfdir}/ovirt-host-deploy.conf.d/10-packaging-aio.conf” |
| 6 | ln -s /usr/share/spice “%{buildroot}%{engine_data}/files/spice” |
| 7 | touch “%{buildroot}%{engine_data}/setup/ovirt-engine-setup-ghost” |
| 8 | touch “%{buildroot}%{engine_etc}/engine.conf” |
| 9 | touch “%{buildroot}%{engine_etc}/notifier/notifier.conf” |
| 10 | touch “%{buildroot}%{engine_pki}/cacert.template” |
| 11 | touch “%{buildroot}%{engine_pki}/cert.template” |
| 12 | touch “%{buildroot}%{engine_pki}/database.txt” |
| 13 | touch “%{buildroot}%{engine_pki}/serial.txt” |
| 14 | install -d “%{buildroot}%{engine_etc}/sysprep” |
| 15 | touch “%{buildroot}%{engine_etc}/sysprep/sysprep.2k12x64” |
| 16 | touch “%{buildroot}%{engine_etc}/sysprep/sysprep.2k3” |
| 17 | touch “%{buildroot}%{engine_etc}/sysprep/sysprep.2k8” |
| 18 | touch “%{buildroot}%{engine_etc}/sysprep/sysprep.2k8x86” |
| 19 | touch “%{buildroot}%{engine_etc}/sysprep/sysprep.2k8x64” |
| 20 | touch “%{buildroot}%{engine_etc}/sysprep/sysprep.w7” |
| 21 | touch “%{buildroot}%{engine_etc}/sysprep/sysprep.w7x64” |
| 22 | touch “%{buildroot}%{engine_etc}/sysprep/sysprep.w8” |
| 23 | touch “%{buildroot}%{engine_etc}/sysprep/sysprep.w8x64” |
| 24 | touch “%{buildroot}%{engine_etc}/sysprep/sysprep.xp” |
| 25 | install -d “%{buildroot}%{_sysconfdir}/firewalld/services” |
| 26 | touch “%{buildroot}%{_sysconfdir}/firewalld/services/ovirt.xml” |
| 27 | mkdir %{buildroot}%{engine_ear}/tmp |
| 28 | mv %{buildroot}%{engine_ear}/desktopManager.war %{buildroot}%{engine_ear}/tmp/desktopManager.war |
- 修改 MANIFEST.MF 文件内容
perl -i -pe 'BEGIN{undef $/;} s/Name: [^\n]+\n( [^\n]+\n)*([^\s]+-Digest: [^\n]+\n(\s)?)+(Magic: [^\n]+\n)?\n//mgs' "%{buildroot}%{engine_ear}/META-INF/MANIFEST.MF"perl -i -pe 's/^SHA1-Digest: [^\n]+\n//g' "%{buildroot}%{engine_ear}/META-INF/MANIFEST.MF"Usage: perl [switches] [--] [programfile] [arguments]| perl 参数 | 说明 |
|---|---|
| -0[octal] | 指定记录分隔符(0,假如没有参数) |
| -a | 与 -n 或者者 -p 一起使用,负责打开自动拆分模式,用于对空白字符进行隐式拆分,用空格分隔$_并保存到 @F 中,相当于 @F=split ”。 |
| -c | 只检查 Perl 脚本语法,而不执行脚本。 |
| -d[:debugger] | 对脚本打开 Perl调试器。 |
| -D[number/list] | 设置 Perl 的调试标记(请先检查 Perl 的安装情况,确保已经安装了调试器),若要观察 Perl 是如何执行脚本的,可使用 -D14。 |
| -e program | 用于在命令行而不是在脚本中执行 Perl 命令。 |
| -F/pattern/ | 规定拆分输入行时使用的模式。模式是位于斜杠、单引号或者双引号之间的正则表达式。例如,-F/:+/ 表示在一个或者多个冒号上拆分输入行,假如 -a 依然起作用的话,则打开它。 |
| -i[extension] | 在使用 <> 循环遍历文件时启用原位编辑模式。 假如没有规定扩展名的话,则原位修改各行内容,否则使用扩展名来修改输入文件名(以便充任备份文件),并使用原位编辑的原文件名创立输出文件。 这也是所有 print 语句选择的文件句柄。 |
| -Idirectory | 与 -P选项一起使用,负责告诉 C 预解决程序查找包含的文件,其默认目录包括 /usr/included、/usr/lib/perl 以及当前目录。 |
| -l[octal] | 启用自动行结束解决。假如使用了 -n 或者者 -p 选项,则去掉终止符。把位数(八进制) 赋值给 |
-[mM][-]module execute “use/no module…” before executing program
-h |打印 Perl 的命令选项列表。
-p |假设循环为 n,但是打印行,相似于SED。
卸载执行包之前
- 备份 PKI
if [ -d "%{engine_pki}" ]; then dest="%{engine_pki}/../%{engine_name}-backups/%{engine_name}-$(date +"%%Y%%m%%d%%H%%M%%S")" mkdir -p "${dest}" cp -pR "%{engine_pki}" "${dest}"fi安装执行包之后
- 升级 maven 的 artifacts 以及文件的映射关系,由 Apache Ant 或者 MVN rpmbuild 实现。
卸载执行包之后
- 删除缓存、PKI
rm -rf "%{engine_cache}"rm -rf "%{engine_pki}"- 升级 maven 的 artifacts 以及文件的映射关系,由 Apache Ant 或者 MVN rpmbuild 实现。
安装执行包之前
- 创立 engine 客户及权限
打包文件目录解决,权限设置
| 序号 | 文件目录说明 |
|---|---|
| 1 | %dir %attr(-, %{engine_user}, %{engine_group}) %{engine_cache} |
| 2 | %dir %attr(-, %{engine_user}, %{engine_group}) %{engine_log} |
| 3 | %dir %attr(-, %{engine_user}, %{engine_group}) %{engine_log}/dump |
| 4 | %dir %{engine_data} |
| 5 | %dir %{engine_data}/bin |
| 6 | %dir %{engine_data}/branding |
| 7 | %dir %{engine_data}/conf |
| 8 | %dir %{engine_data}/engine.ear |
| 9 | %dir %{engine_data}/services |
| 10 | %dir %{engine_etc} |
| 11 | %dir %{engine_etc}/branding |
| 12 | %dir %{engine_java} |
| 13 | %doc LICENSE |
| 14 | %{engine_data}/branding/ovirt.brand/ |
| 15 | %{engine_etc}/branding/00-ovirt.brand |
| 16 | %{engine_etc}/engine.conf.d/ |
| 17 | %{engine_java}/authentication.jar |
| 18 | %{engine_java}/branding.jar |
| 19 | %{engine_java}/common.jar |
| 20 | %{engine_java}/compat.jar |
| 21 | %{engine_java}/utils.jar |
| 22 | %{engine_pki}/publicKey.keystore |
- 兼容性解决
%if "%{name}" != "%{engine_name}"%{_javadir}/%{name}%endif打包 lib 子包,文件目录解决,权限设置
| 序号 | 文件目录说明 |
|---|---|
| 1 | %{engine_data}/bin/java-home |
| 2 | %{python_sitelib}/ovirt_engine/ |
打包 desktopManager 子包,文件目录解决,权限设置
| 序号 | 文件目录说明 |
|---|---|
| 1 | %{engine_ear}/tmp/desktopManager.war |
打包 backend 子包,文件目录解决,权限设置
| 序号 | 文件目录说明 |
|---|---|
| 1 | %attr(-, %{engine_user}, %{engine_group}) %{engine_log}/host-deploy |
| 2 | %attr(-, %{engine_user}, %{engine_group}) %{engine_state}/content |
| 3 | %config %{_sysconfdir}/logrotate.d/ovirt-engine |
| 4 | %dir %attr(-, %{engine_user}, %{engine_group}) %{engine_state} |
| 5 | %dir %{engine_data}/bin |
| 6 | %dir %{engine_data}/ui-plugins |
| 7 | %dir %{engine_ear} |
| 8 | %{engine_data}/conf/osinfo-defaults.properties |
| 9 | %{engine_data}/conf/sysprep/ |
| 10 | %{engine_data}/files/ |
| 11 | %{engine_doc}/AuditLogMessages.properties |
| 12 | %{engine_ear}/META-INF |
| 13 | %{engine_ear}/bll.jar |
| 14 | %{engine_ear}/docs.war/ |
| 15 | %{engine_ear}/lib |
| 16 | %{engine_ear}/root.war/ |
| 17 | %{engine_ear}/scheduler.jar |
| 18 | %{engine_ear}/services.war/ |
| 19 | %{engine_ear}/welcome.war/ |
| 20 | %{engine_etc}/osinfo.conf.d/ |
| 21 | %{engine_java}/bll.jar |
| 22 | %{engine_java}/dal.jar |
| 23 | %{engine_java}/scheduler.jar |
| 24 | %{engine_java}/searchbackend.jar |
| 25 | %{engine_java}/vdsbroker.jar |
| 26 | %{engine_jboss_modules}/ |
| 27 | %{engine_data}/services/ovirt-engine |
- PKI 相关文件解决
| 序号 | 文件目录说明 |
|---|---|
| 1 | %config(noreplace) %{engine_pki}/cacert.template.in |
| 2 | %config(noreplace) %{engine_pki}/cert.template.in |
| 3 | %config(noreplace) %{engine_pki}/openssl.conf |
| 4 | %dir %attr(-, %{engine_user}, %{engine_group}) %{engine_pki} |
| 5 | %dir %attr(-, %{engine_user}, %{engine_group}) %{engine_pki}/certs |
| 6 | %dir %attr(-, %{engine_user}, %{engine_group}) %{engine_pki}/private |
| 7 | %dir %attr(-, %{engine_user}, %{engine_group}) %{engine_pki}/requests |
| 8 | %dir %{engine_pki}/keys |
| 9 | %{engine_data}/bin/pki-common.sh |
| 10 | %{engine_data}/bin/pki-create-ca.sh |
| 11 | %{engine_data}/bin/pki-enroll-pkcs12.sh |
| 12 | %{engine_data}/bin/pki-enroll-request.sh |
| 13 | %{engine_data}/bin/pki-pkcs12-extract.sh |
打包 setup-base 子包,文件目录解决,权限设置
| 序号 | 文件目录说明 |
|---|---|
| 1 | %config %{_sysconfdir}/logrotate.d/ovirt-engine-setup |
| 2 | %dir %{engine_data}/setup/bin/ |
| 3 | %dir %{engine_log}/setup |
| 4 | %{_bindir}/engine-cleanup |
| 5 | %{_bindir}/engine-setup |
| 6 | %{_mandir}/man8/engine-cleanup.* |
| 7 | %{_mandir}/man8/engine-setup.* |
| 8 | %{engine_data}/bin/ovirt-engine-log-setup-event.sh |
| 9 | %{engine_data}/conf/iptables.default.in |
| 10 | %{engine_data}/setup/bin/ovirt-engine-remove |
| 11 | %{engine_data}/setup/bin/ovirt-engine-setup |
| 12 | %{engine_data}/setup/bin/ovirt-engine-setup.env |
| 13 | %{engine_data}/setup/ovirt_engine_setup/ |
| 14 | %{engine_data}/setup/plugins/*/base/ |
| 15 | %{engine_state}/backups/ |
| 16 | %{engine_state}/setup/ |
打包 setup 子包,文件目录解决,权限设置
| 序号 | 文件目录说明 |
|---|---|
| 1 | %{_bindir}/%{name}-setup |
| 2 | %{_bindir}/%{name}-upgrade |
| 3 | %{_bindir}/%{name}-check-update |
| 4 | %{_bindir}/%{name}-cleanup |
| 5 | %{_mandir}/man8/%{name}-setup.* |
打包 setup-plugin-ovirt-engine 子包,文件目录解决,权限设置
| 序号 | 文件目录说明 |
|---|---|
| 1 | %config %{_sysconfdir}/ovirt-engine-setup.conf.d/10-packaging.conf |
| 2 | %{_bindir}/engine-upgrade-check |
| 3 | %{engine_data}/conf/ovirt-engine-proxy.conf.v2.in |
| 4 | %{engine_data}/conf/ovirt-engine-root-redirect.conf.in |
| 5 | %{engine_data}/firewalld/ovirt-engine/ |
| 6 | %{engine_data}/setup/bin/ovirt-engine-rename |
| 7 | %{engine_data}/setup/bin/ovirt-engine-upgrade-check |
| 8 | %{engine_data}/setup/dbutils/ |
| 9 | %{engine_data}/setup/plugins/*/ovirt-engine/ |
| 10 | %{engine_data}/setup/plugins/ovirt-engine-rename/ |
打包 setup-plugin-ovirt-engine-common 子包,文件目录解决,权限设置
| 序号 | 文件目录说明 |
|---|---|
| 1 | %{engine_data}/setup/plugins/*/ovirt-engine-common/ |
打包 setup-plugin-websocket-proxy 子包,文件目录解决,权限设置
| 序号 | 文件目录说明 |
|---|---|
| 1 | %{engine_data}/firewalld/websocket-proxy/ |
| 2 | %{engine_data}/setup/plugins/*/websocket_proxy/ |
打包 setup-plugin-allinone 子包,文件目录解决,权限设置
| 序号 | 文件目录说明 |
|---|---|
| 1 | %config %{_sysconfdir}/ovirt-engine-setup.conf.d/10-packaging-aio.conf |
| 2 | %config %{_sysconfdir}/ovirt-host-deploy.conf.d/10-packaging-aio.conf |
| 3 | %{engine_data}/firewalld/aio/ |
打包 dbscripts 子包,文件目录解决,权限设置
| 序号 | 文件目录说明 |
|---|---|
| 1 | %{engine_data}/dbscripts/ |
打包 restapi 子包,文件目录解决,权限设置
| 序号 | 文件目录说明 |
|---|---|
| 1 | %{engine_java}/interface-common-jaxrs.jar |
| 2 | %{engine_java}/restapi-definition.jar |
| 3 | %{engine_java}/restapi-jaxrs.jar |
| 4 | %{engine_java}/restapi-types.jar |
| 5 | %{engine_restapi_war}/ |
| 6 | %{engine_legacy_restapi_war}/ |
打包 userportal 子包,文件目录解决,权限设置
| 序号 | 文件目录说明 |
|---|---|
| 1 | %config %{engine_etc}/usbfilter.txt |
| 2 | %{engine_ear}/userportal.war |
打包 webadmin-portal 子包,文件目录解决,权限设置
| 序号 | 文件目录说明 |
|---|---|
| 1 | %{engine_ear}/webadmin.war |
| 2 | %files websocket-proxy |
| 3 | %{engine_data}/services/ovirt-websocket-proxy |
| 4 | %{engine_etc}/ovirt-websocket-proxy.conf.d/ |
打包 tools 子包,文件目录解决,权限设置
| 序号 | 文件目录说明 |
|---|---|
| 1 | %config %{_sysconfdir}/logrotate.d/ovirt-engine-notifier |
| 2 | %config %{engine_etc}/notifier/log4j.xml |
| 3 | %config(noreplace) %{engine_etc}/engine-config/engine-config.conf |
| 4 | %config(noreplace) %{engine_etc}/engine-manage-domains/engine-manage-domains.conf |
| 5 | %dir %attr(-, %{engine_user}, %{engine_group}) %{engine_log}/notifier |
| 6 | %dir %attr(-, %{engine_user}, %{engine_group}) %{engine_run}/notifier |
| 7 | %dir %{engine_etc}/engine-config |
| 8 | %dir %{engine_etc}/engine-manage-domains |
| 9 | %dir %{engine_etc}/notifier |
| 10 | %{_bindir}/engine-backup |
| 11 | %{_bindir}/engine-config |
| 12 | %{_bindir}/engine-manage-domains |
| 13 | %{_mandir}/man8/engine-backup.* |
| 14 | %{_mandir}/man8/engine-config.* |
| 15 | %{_mandir}/man8/engine-manage-domains.* |
| 16 | %{engine_data}/bin/engine-backup.sh |
| 17 | %{engine_data}/bin/engine-config.sh |
| 18 | %{engine_data}/bin/engine-manage-domains.sh |
| 19 | %{engine_data}/bin/engine-prolog.sh |
| 20 | %{engine_data}/conf/jaas.conf |
| 21 | %{engine_data}/services/ovirt-engine-notifier |
| 22 | %{engine_etc}/engine-config/engine-config.*properties |
| 23 | %{engine_etc}/notifier/notifier.conf.d/ |
| 24 | %{engine_java}/tools.jar |
记录日志
* Mon Jan 27 2015 Max Kovgan <mvk@redhat.com> - 3.4.5- BZ#1169352 BZ#1151053 BZ#1166010 BZ#1147396 BZ#1169404 BZ#1180072 BZ#1171467 BZ#1154184* Mon Nov 10 2014 Barak Korren <bkorren@redhat.com> - 3.4.4- BZ#1135112 BZ#1141761 BZ#1152448 BZ#1154569 BZ#1155557 BZ#1155571 BZ#1155573 BZ#1155649 BZ#1155698 BZ#1155906 BZ#1155920 BZ#1155986 BZ#1155987 BZ#1156012 BZ#1157212 BZ#1157678 BZ#1158042 BZ#1158090 BZ#1159751 BZ#1159761 BZ#1159849 BZ#11619231. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长!
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是摆设,本站源码仅提供给会员学习使用!
7. 如遇到加密压缩包,请使用360解压,如遇到无法解压的请联系管理员
开心源码网 » 【Ovirt 笔记】ovirt-engine.spec 配置分析与整理