Lovenemesis (talk | contribs) |
Lovenemesis (talk | contribs) |
||
Line 89: | Line 89: | ||
[[Image:GitCommit.png]] | [[Image:GitCommit.png]] | ||
=== | === 切换分支(Git 导出) === | ||
双击需要的本地分支就可以切换分支。当前导出的分支在右侧项目名称上有标示。在切换分支前确定已经提交、还原或者隐藏了更改。参考 [http://www.kernel.org/pub/software/scm/git/docs/ Git] 和 [http://wiki.eclipse.org/EGit/User_Guide EGit] 文档来了解更多这方面内容。 | |||
=== Prepare Sources for a Local Build === | === Prepare Sources for a Local Build === |
Revision as of 14:53, 27 October 2010
什么是 Eclipse Fedora Packager?
Eclipse Fedora Packager 是一个 Eclipse 插件。它帮助习惯于使用 IDE (比如 Eclipse IDE)的 Fedora 打包者们在 Eclipse 中完成 Fedora 打包 RPM 的工作,而无须纠结于命令行中(大多数情况 :-))。
Eclipse Fedora Packager 包含的部分功能为:
- 方便的 Git 克隆和分支切换
- 包含语法高亮、自动补全、更新日志完善的 RPM Spec 文件编辑器(快捷键 <Ctrl>+<Alt>+C)
- 下载代码包以及上传新代码包
- 准备本地编译(仅执行 spec 文件中的 %prep 部分)
- 按照当前 Spec 文件生成 SRPM 包
- 执行本地编译
- 推送至 Koji(Fedora 编译系统)
- Mock 编译
- 推送 Bodhi 更新
- Eclipse Git 支持(通过 EGit, 请参考 EGit 文档)
Eclipse Fedora Packager 自 F14 对于所有 Fedora 用户可用。想要尝试?使用如下命令来安装:
$ pkcon install eclipse-fedorapackager
使用 Eclipse Fedorapackager
从 Fedora 14 开始, Fedora 使用 Git 版本控制系统来跟踪需要打包的文件。参阅 dist-git 文档 来深入了解 dist-git 的信息。幸运的是,dist-git 如何工作对于使用 Eclipse Fedora Packager plug-in 并不重要。和以往的 CVS 相比,Git 只是采取了略有不同的途径去完成打包工作。
初始设定
这一步对于使用未设定 FAS 证书的新打包者只需要完成一次。如果确认已经完成过此设置并且正常的话,可以跳过此步骤。下面的步骤解释如何为FAS account 设定这些证书。
首先,安装 fedora-packager
RPM 包:
$ pkcon install fedora-packager
然后运行以下命令,然胡根据提示操作:
$ fedora-packager-setup
这些完成后就可以使用 Eclipse Fedorapackager 了。启动 Eclipse,赶紧开始吧~
导入一个 Fedora Git 项目
开始很简单的,使用 "File" => "Import" => "Git" => "Projects from Fedora Git"。这将克隆所指定的 Git 仓库并且创建需要的本地分支。方便期间,"Git Repositories" 视图将会在克隆进程结束后开启。
该图显示 Fedora Git 导入对话框的样子。下一步,指定准备打包的包名称。
下图显示的是新项目创建完成的样子。注意在 Git 仓库视图中的分支和项目右侧的 "[eclipse-fedorapackager master]" 标示。在这里,eclipse-fedorapackager 代表 Git 仓库名,master 代表当前导出的分支。
Fedora 打包工作
在 Fedora Git 项目创建完成后,为目标发行版打包所需的所有文件都可以直接在刚刚创建的 Eclipse 项目中找到。例如,为 Fedora 13 打包所需的文件都放置在分支 f13/master 中。分支 master 对应当前的 Fedora 开发版本 Fedora rawhide。下面将简要描述下打包软件所需要注意的一系列事宜。如果不按照这个顺序去做也是可以的,但是记住一定要在尝试 Koji 编译前推送本地修改到公共仓库。
上传需要打包的的源代码文件
要在 Eclipse Fedora Packager 中上传新的源代码,首先下载上有的源代码并将下载好的的源代码和 Eclipse 项目放在同一个文件夹下。 如果这个步骤是在 Eclipse 之外完成的,别忘记刷新项目(F5)让文件被识别出来。另一个下载源代码的方式是直接使用 RPM 编辑器。查阅他的文档获取更这方面的多信息。 一旦新的源代码文件在项目中就绪,就可以上传到临时缓冲区中:右键点击文件 => "Fedora Packager" => Upload This File => Replace/Add File。这样既可以添加新文件到编译软件包,亦可以替换 sources
中的当前内容,并包含一个当前选中文件的 MD5 校验和。
上传到临时缓冲区需要一个有效的证书。若是过期了,可以通过在终端执行以下命令生成一个新的:
$ fedora-cert -n
下载打包所需的源代码文件
要为已有的软件包下载编译所需要的源代码,右键点击 spec 文件 => "Fedora Packager" => Download Sources。这将下载所有列举在 sources
部分的源代码。
使用 Spec 文件编辑器
Eclipse Fedora Packager 使用来自 Eclipse Linux Tools 项目 的 RPM Editor 和 ChangeLog 插件。举例来说,一条新的更新日志可以通过快捷键 <CTRL>+<ALT>+C 轻松的插入到 spec 文件中(当然首先应该定下合理的“更新日志”要求)。使用 <CTRL>+<SPACE> 自动补全本地安装的软件包。同时,可以使用右键点击 spec文件 => “Run Rpmlint”的方式运行 rpmline。更多的内容请察看 spec 文件编辑器视频录像:http://www.eclipse.org/downloads/download.php?file=/technology/linuxtools/videos/specfile-demo.ogg 或者 "Specfile Editor User Guide": Help => Help Contents => Specfile Editor User Guide.
提交更改到本地 Git 仓库
在添加/更改 spec 文件、补丁之后,需要将这些变化提交到仓库去。这样操作:
- 选择需要提交的文件(或者选择 Fedora Git Project 然后在提交对话框出现时选择需要提交的 unstaged 文件)。
- 右键,选择 "Team" => "Commit..."
切换分支(Git 导出)
双击需要的本地分支就可以切换分支。当前导出的分支在右侧项目名称上有标示。在切换分支前确定已经提交、还原或者隐藏了更改。参考 Git 和 EGit 文档来了解更多这方面内容。
Prepare Sources for a Local Build
Eclipse Fedora Packager will download and prepare sources by right-clicking on the spec-file => “Fedora Packager” => “Prepare Sources for Build”.
Build RPM for a Local Architecture
This is a great way to test if the spec-file actually builds at all. Once the RPM has been successfully built locally, it is recommended further testing be carried out on the spec-file by completing a build in a chroot'ed environment using {{{mock}}}. Both ways are supported by Eclipse Fedora Packager.
The RPM can be built locally by selecting the spec-file => right-click => “Fedora Packager” => “Build for Local Architecture”. Output of the RPM build will appear on the Eclipse console.
Using mock-builds is a great way to test the “Requires/BuildRequires” of a spec-file. Select the spec-file => right-click => “Fedora Packager” => “Local Build Using Mock”. Be aware that this may take a long time (>20 minutes) and requires the mock package to be installed. Use Eclipse's “Run in Background” functionality for convenience.
Make Locally Committed Changes Public (Git Push)
The changes are ready to be pushed (or published) publicly when the locally committed changes are satisfying. Remember, Git allows history to be rewritten before changes are made public. See the Git and EGit documentation for more information. To bring the local repository in sync with origin:
- Select the Fedora Git project
- Right-click, "Team" => "Push..."
- Select the Git repository to be pushed to (usually this is kept unchanged)
- Select the Git references to be pushed
- Carry out the push operation
The Git push dialog.
Select the Git references to push. In this example, branches master and f14/master will get pushed. Keep in mind that source and destination references are the same for Eclipse Fedora Packager. Clicking the “Add all branches spec” button is a convenience that pushes all commits to all local branches.
Pushing a Build to Koji
Once satisfied with a spec-file, upload the sources of the package, commit the changes to the local repository, and then push the local changes to the remote repository. When this is done, push a build to Koji by right-clicking the spec-file => “Fedora Packager” => “Push to Koji”.
Eclipse will pop up a message with the Koji URL to track your build. This is an example of how the message may look:
This should be enough information to track the builds.
Pushing a Bohi Update
After successfully building the RPMs, use Eclipse Fedora Packager to push an update for those packages. To do so, select the spec-file => right click => "Fedora Packager" => "Bodhi Update". When creating a Bodhi update using Eclipse Fedora Packager, similar information is required as needed by the Bodhi Web interface. Once an update has successfully been created, the pushed update will be visible on the Bodhi updates website. The status of updates can also be tracked there.
Feedback/Reporting Bugs
If a bug is found in the Eclipse Fedora Packager, please feel free to open a ticket at https://fedorahosted.org/eclipse-fedorapackager/report/1 (a FAS username is required to create tickets). Alternatively, try this query on RedHat Bugzilla in order to find already existing bugs. Thanks!