Skip to content

git-import-srpm: add script to create source branches from srpm repository.#7

Open
casasnovas wants to merge 1 commit intomainfrom
quentin-import-srpm
Open

git-import-srpm: add script to create source branches from srpm repository.#7
casasnovas wants to merge 1 commit intomainfrom
quentin-import-srpm

Conversation

@casasnovas
Copy link
Collaborator

@casasnovas casasnovas commented Mar 13, 2026

On Debian derivatives, you'll need:
sudo apt-get install rpm

Simply run it inside a SRPM git repository and give it a revision (can be tag, branch, sha1, ...), e.g.:

CODE_REPO_PATH=/path/to/linux/repo SRPM_REPO_PATH=/path/kernel/srpm/repo git-import-srpm XS-8.2.1

To import all releases as branches, just pass --all:

git-import-srpm --all

By default, the SRPM_REPO_PATH is the current working directory. If no CODE_REPO_PATH is given, a default path is inferred that is ${SRPM_REPO_PATH}/../(linux|xen|qemu) (depending on the package being imported).

The script was used import all branches of qemu, xen and the Linux kernel released in current and prior XCP versions, e.g.:

The script gives idempotent runs, reconstructed git sha1 will stay the same across runs for a given srpm revision. The script will not touch any of your repository worktrees or indexes, so it is safe to run any time even if you are working in the source repo (patches are applied separately in a temporary worktree).

Note that for each srpm revision, the script will create two branches in the source repository, in the form:

/(xcpng|xenserver)-/(pre-base|base)

The pre-base ref will point to the upstream commit that was used as basis by the source RPM before applying patches. Effectively, the patch-set applied by a source rpm can be rev-listed with git log /pre-base../base which allows see-ing how the patchset evolved over time.

You can use git-review-rebase easily on two imports to see the changes in the patch-queues.

Original pull-request was on the
xcp repository but after discussion with the OS&Platform team, it was agreed it is better to have it here. Sub-sequent work could try and add github workflows to run this script automatically when we notice new SRPMs from XenServer, but right now it is a manual process (so is running import_srpm.py).

@casasnovas casasnovas requested a review from a team as a code owner March 13, 2026 10:34
@casasnovas casasnovas changed the title git-import-srpm: add script to create source branches from srpm repos… git-import-srpm: add script to create source branches from srpm repository. Mar 13, 2026
@fallen
Copy link

fallen commented Mar 16, 2026

This is a PR to merge in another non-main branch?
Is this on purpose?

@casasnovas
Copy link
Collaborator Author

This is a PR to merge in another non-main branch? Is this on purpose?

This is to merge to main, but I didn't find a nicer way to stack PR on top of each other than chosing its parent branch. If this gets approved before the others, I'll just rebase that one commit on top of main before pushing.

@casasnovas casasnovas force-pushed the quentin-git-review-rebase-added-ordering branch from 7af5a5f to 5c0cb13 Compare March 16, 2026 10:02
@fallen
Copy link

fallen commented Mar 16, 2026

This is a PR to merge in another non-main branch? Is this on purpose?

This is to merge to main, but I didn't find a nicer way to stack PR on top of each other than chosing its parent branch. If this gets approved before the others, I'll just rebase that one commit on top of main before pushing.

Oh, ok!

@casasnovas casasnovas force-pushed the quentin-import-srpm branch from 97f721a to 76d7132 Compare March 16, 2026 10:06
@casasnovas casasnovas changed the base branch from quentin-git-review-rebase-added-ordering to quentin-kabi March 16, 2026 10:06
@casasnovas
Copy link
Collaborator Author

casasnovas commented Mar 16, 2026

This is a PR to merge in another non-main branch? Is this on purpose?

This is to merge to main, but I didn't find a nicer way to stack PR on top of each other than chosing its parent branch. If this gets approved before the others, I'll just rebase that one commit on top of main before pushing.

Oh, ok!

I did the rebase now to make it less confusing. edit: for the other branches, that one actually depends on the prior two as it changes the README.md file, so I prefer to wait for the other two PRs to be merged to avoid having to deal with conflicts in the README.md.

@casasnovas casasnovas force-pushed the quentin-kabi branch 2 times, most recently from eeafee3 to 7b7b1ee Compare March 16, 2026 15:00
@casasnovas casasnovas deleted the branch main March 16, 2026 15:01
@casasnovas casasnovas closed this Mar 16, 2026
@casasnovas casasnovas reopened this Mar 16, 2026
@casasnovas casasnovas changed the base branch from quentin-kabi to main March 16, 2026 15:03
…itory.

On Debian derivatives, you'll need:
  sudo apt-get install rpm

Simply run it inside a SRPM git repository and give it a revision (can be
tag, branch, sha1, ...), e.g.:

```bash
CODE_REPO_PATH=/path/to/linux/repo SRPM_REPO_PATH=/path/kernel/srpm/repo git-import-srpm XS-8.2.1
```

To import all releases as branches, just pass --all:

```bash
git-import-srpm --all
```

By default, the `SRPM_REPO_PATH` is the current working directory. If no
`CODE_REPO_PATH` is given, a default path is inferred that is
`${SRPM_REPO_PATH}/../(linux|xen|qemu)` (depending on the package being
imported).

The script was used import all branches of qemu, xen and the Linux kernel
released in current and prior XCP versions, e.g.:

- xen branch example: https://github.com/xcp-ng/xen/tree/xen/xcpng-4.17.5-23.1/base
- qemu branch example: https://github.com/xcp-ng/qemu-dp/tree/qemu/xcpng-4.2.1-5.2.15.2/base
- linux branch example: https://github.com/xcp-ng/linux/tree/linux/xcpng-4.19.19-8.0.32.1/base

The script gives idempotent runs, reconstructed git sha1 will stay the same
across runs for a given srpm revision. The script will not touch any of your
repository worktrees or indexes, so it is safe to run any time even if you are
working in the source repo (patches are applied separately in a temporary worktree).

Note that for each srpm revision, the script will create two branches in the source
repository, in the form:

<product>/(xcpng|xenserver)-<version>/(pre-base|base)

The pre-base ref will point to the upstream commit that was used as basis
by the source RPM before applying patches. Effectively, the patch-set
applied by a source rpm can be rev-listed with `git log /pre-base../base`
which allows see-ing how the patchset evolved over time.

You can use `git-review-rebase` easily on two imports to see the changes in
the patch-queues.

Original pull-request was on the
[xcp](xcp-ng/xcp#781) repository but after
discussion with the OS&Platform team, it was agreed it is better to have it
here.  Sub-sequent work could try and add github workflows to run this
script automatically when we notice new SRPMs from XenServer, but right now
it is a manual process (so is running [import_srpm.py](https://github.com/xcp-ng/xcp/blob/master/scripts/import_srpm.py)).

Signed-off-by: Quentin Casasnovas <quentin.casasnovas@vates.tech>
@casasnovas casasnovas force-pushed the quentin-import-srpm branch from 76d7132 to 46cd37c Compare March 16, 2026 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants