diff --git a/.gitignore b/.gitignore index f801c72..99b2782 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/.perl-Sys-Virt.metadata b/.perl-Sys-Virt.metadata new file mode 100644 index 0000000..04d17a2 --- /dev/null +++ b/.perl-Sys-Virt.metadata @@ -0,0 +1 @@ +8b2ec05c0cd17a0d161e74d9ca4120be3f921f7b Sys-Virt-v8.0.0.tar.gz diff --git a/dead.package.c9s b/dead.package.c9s deleted file mode 100644 index 6db2b81..0000000 --- a/dead.package.c9s +++ /dev/null @@ -1 +0,0 @@ -perl-Sys-Virt package is retired for CS-428 \ No newline at end of file diff --git a/update-patches.pl b/update-patches.pl new file mode 100755 index 0000000..244fd8c --- /dev/null +++ b/update-patches.pl @@ -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 = ; +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 () { + 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 () { + 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 () { + 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`; +}