Skip to content

How to use update_git.sh in obs project

Michael Chang edited this page Oct 29, 2020 · 1 revision

Getting Started

Installing osc, git and quilt is pretty much enough to walk through the tutotial. Optionally you may have to install obs-service-download_files if you want to work on other version of grub.

Checkout OBS

First off, checkout grub2 project from openSUSE build service.

osc bco openSUSE:Factory/grub2
cd home:<user>:branches:Base:System/grub2

Work with quilt

You may use tradition quilt to manage patch series you're accustomed to it. There is no change in this regard, you can commit any patch the same way to the OBS build server then build up a package for you.

update_git.cfg

The update_git.cfg contains the setting for update_git.sh which is used for geneating patch series against source tarball built for given release/tag.

  • GIT_TREE: The git repository where the grub source is hosted and development is happening.
  • GIT_BRANCH: The branch used to build the package, it has to be on top of $GIT_UPSTREAM_TAG and use linear history (ie no merge commit)
  • GIT_UPSTREAM_TAG: The git tag/commit with which the source tarball used in the package is created.

Here is a sample file.

% cat update_git.cfg

GIT_TREE=https://github.com/openSUSE/grub2.git
GIT_BRANCH=opensuse/2.04
GIT_UPSTREAM_TAG=grub-2.04

Work with git

Now is the fun part. You can easily setup a local git cloned from remote source git to start your work with.

% ./update_git.sh --setup --clean-cache

The --clean-cache is optional, but is preferred in case the cache has been used by foreign projects. You only need to use ./update_git --setup if you know the cache is cleared or is being used by current project.

The --setup will create a local git clone in grub2.git and also switch to the target branch. Here you can check the result with update_git.cfg, they should be indentical.

% cd grub2.git
% git remote -v
origin	https://github.com/openSUSE/grub2.git (fetch)
origin	https://github.com/openSUSE/grub2.git (push)
% git --no-pager branch
* opensuse/2.04

Now everything is ready for you to work with git. You can either add new commits, cherry-pick other patch series or rebase to other branch etc. Once you have made your change to the source and want to test out the new package, you have to run:

% ./update_git.sh

The grub2.spec file and patch series will be updated with the changes you made. In addition a template entry is added to grub2.changes to help you in editing changes before commiting to OBS. FYR, the template looked like this.

-------------------------------------------------------------------
Wed Oct 28 16:11:26 UTC 2020 - Michael Chang <[email protected]>

- Patch queue updated from /home/mchang/obs/home:michael-chang:git_patches/grub2/grub2.git opensuse/2.04
* Patches dropped:
  update-news.patch

-------------------------------------------------------------------
Tue Oct 27 05:11:00 UTC 2020 - Michael Chang <[email protected]>

- Patch queue updated from https://github.com/openSUSE/grub2.git opensuse/2.04
* Patches added:
  ieee1275-Avoiding-many-unecessary-o.patch
  squash-ieee1275-Avoiding-many-unece.patch
  ofdisk-Keep-block-size-in-device-ha.patch

-------------------------------------------------------------------

Finally, if everything goes well, time to commit your changes to OBS.

% osc ar
% osc commit

Submit to openSUSE:Factory

If you want to submit the patch to openSUSE Factory. You have these options.

  1. Submit to upstream, this is preferred and will be availabe in later version.
  2. Send Pull request to the branch of openSUSE grub2 source git where the OBS project is set up to use. You can know the git source via update_git.cfg. The GIT_TREE and GIT_BRANCH is what you're looking for.
  3. Create OBS submit request to Base:System/grub2. Instead of accepting the SR (Submit Request), I would commit the patch to the branch of git project manually and superscede that request with the one generated from git source.

Work with GIT_UPSTREAM_TAG

Once you have rebased your GIT_BRANCH on top of new GIT_UPSTREAM_TAG and updated them in update_git.cfg, it is all up to you running.

./update_git.sh --update-version

It will perform following tasks for you.

  1. Update the Version tag in grub2.cfg to use GIT_UPSTREAM_TAG
  2. Use obs-service-download_files source serive to download source tarball and also validate Source URL in grub2.spec
  3. Update patch series in grub2.spec
  4. Update grub2.changes

Of course, not all GIT_UPSTREAM_TAG has corresponging source tarball available in Source URL. In this case, you might have to create source tarball on your own. So far we only implemented it for source tarball which is made availabe only to upstream's stable release.