Technology‎ > ‎

An even smarter way of importing a new package in Fedora

posted Sep 21, 2011, 10:26 PM by Garrett Holmstrom   [ updated Sep 21, 2011, 11:19 PM ]
The recommended way to import a new package in Fedora is to take the source RPM that was approved in its package review and run fedpkg import foo.src.rpm on it to import the entire thing at once. This loses the history of the package before its approval. But if you keep the package's history in a git repository until it is time to import it into Fedora, then you can simply add that history to Fedora's repository.

Adding pre-existing package history to Fedora

Mathieu Bridon wrote a blog post that walks one through a procedure for making this happen. First we have to add the history from Fedora's git repository to the repository you already have. Since we want to replace our existing master branch with Fedora's, we rename it, add the Fedora repository's data to our repository, and check out Fedora's master branch in its place:
  1. git branch -m master local-master
  2. git remote add origin git+ssh://username@pkgs.fedoraproject.org/pkgname
  3. git fetch origin
  4. git checkout -b master origin/master
Mathieu then walks us through a convoluted sequence of branches, merges, and rebases that combine the two histories. But all we really want to do is replay our local-master branch's commits onto Fedora's master branch, so we can tell git to do this by handing a list of these commits to git cherry-pick, which does just that:
  1. git cherry-pick $(git rev-list --reverse local-master)
That's it! Now you can upload your sources with fedpkg new-sources, build your package, and continue working with it as with any other package's repository. You can also delete your old local-master branch with git branch -d local-master.

Saving work on other branches

What if you have more branches? Just merge what you did in the master branch!
  1. fedpkg switch-branch f16
  2. git merge master
  3. fedpkg switch-branch f15
  4. git merge master
  5. ...
Comments