Branch synchronization with RHEL 8.8.0

This commit is contained in:
Miroslav Rezanina 2023-04-04 09:13:43 -04:00 committed by Stepan Oksanichenko
parent 69ede9ce7b
commit 1b8ac8e0df
4 changed files with 132 additions and 2 deletions

7
.gitignore vendored
View File

@ -1,2 +1,7 @@
*~
*.log
*.tar.gz
*.rpm
Sys-Virt-v*/
x86_64/
SOURCES/Sys-Virt-v8.0.0.tar.gz
/Sys-Virt-v8.0.0.tar.gz

1
.perl-Sys-Virt.metadata Normal file
View File

@ -0,0 +1 @@
8b2ec05c0cd17a0d161e74d9ca4120be3f921f7b Sys-Virt-v8.0.0.tar.gz

View File

@ -1 +0,0 @@
perl-Sys-Virt package is retired for CS-428

125
update-patches.pl Executable file
View File

@ -0,0 +1,125 @@
#!/usr/bin/perl
#
# Update the local patches and RPM spec with patches from
# an upstream tree with matching branch name.
#
# For example
#
# - Checkout upstream GIT repo for virt-viewer
# - Create a branch name matching current RHEL (eg rhel-6.4)
# - Populate the branch by cherry-picking patches from master
#
# This script will then
#
# - Setup the upstream GIT repo as a remote named 'upstream'
# - Extract version number from RPM spec
# - Look for a tag 'v$VERSION' in upstream GIT
# - Run 'git format-patches v$VERSION..upstream/rhel-6.4'
# - Re-write the RPM spec to update all PatchNNN lines
#
# The only manual step required is to fill in the changelog
#
use strict;
use warnings;
my $gitupstream = "git+ssh://git.engineering.redhat.com/srv/git/users/berrange/perl-Sys-Virt-rhel.git";
my $rpmspec = "perl-Sys-Virt.spec";
open SPEC, "$rpmspec" or die "cannot read $rpmspec: $!";
my @spec = <SPEC>;
close SPEC;
my $version;
foreach my $line (@spec) {
if ($line =~ /^Version:\s*(\S+)\s*$/) {
$version = $1;
}
}
die "cannot find Version: line in RPM spec"
unless $version;
my $gittag = "v" . $version;
open GIT, "-|", "git", "branch" or die "cannot run git branch: $!";
my $gitbranch;
while (<GIT>) {
if (/^\*\s+(\S+)\s*$/) {
$gitbranch = $1;
}
}
close GIT;
die "cannot find current git branch" unless $gitbranch;
die "can only deal with rhel/stream branches" unless $gitbranch =~ /(rhel|stream)/;
my $haveupstream;
open GIT, "-|", "git", "remote" or die "cannot run git remote: $!";
while (<GIT>) {
if (/upstream/) {
$haveupstream = 1;
}
}
close GIT;
unless ($haveupstream) {
`git remote add upstream $gitupstream`;
}
`git fetch upstream`;
$haveupstream = 0;
open GIT, "-|", "git", "branch", "-a" or die "cannot find git branch -a: $!";
while (<GIT>) {
if (m,upstream/$gitbranch,) {
$haveupstream = 1;
}
}
close GIT;
die "cannot find upstream/$gitbranch" unless $haveupstream;
`git format-patch --no-signature -N $gittag..upstream/$gitbranch`;
opendir DH, "." or die "cannot read current directory: $!";
my @patches
= grep {
/^\d\d\d.*\.patch/
} readdir(DH);
closedir DH;
@patches = sort @patches;
shift @patches if @patches && $patches[0] =~ /0000-/;
open SPEC, ">$rpmspec" or die "cannot update $rpmspec: $!";
foreach my $line (@spec) {
print SPEC $line unless $line =~ /Patch/ && $line !~ /Patch0:/;
my $i;
if ($line =~ /Patch0/) {
for ($i = 0 ; $i <= $#patches ; $i++) {
printf SPEC "Patch%d: %s\n", $i+1, $patches[$i];
}
}
}
close SPEC or die "cannot save $rpmspec: $!";
if (@patches) {
`git add *.patch $rpmspec`;
}