This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
# usage: rpmpatch specfile [--localname name] files... | |
# example: rpmpatch kernel.spec --localname .mytest ../SOURCES/00* | |
require "optparse" | |
localname = nil | |
opts = OptionParser.new | |
opts.on("--localname NAME"){|v| localname = v } | |
opts.parse!(ARGV) | |
specfile = ARGV[0] | |
ARGV.shift | |
spec = File.read(specfile, :encoding => Encoding::UTF_8) | |
if localname != nil then | |
bid = "# % define buildid .local\n" | |
spec.gsub!(bid, "%define buildid #{localname}\n") | |
end | |
m = "Patch999999: linux-kernel-test.patch\n" | |
patches = ARGV | |
patchnum = 10000 | |
spec.gsub!(m) { | |
s = m | |
s += "\n" | |
for patch in patches | |
s += "Patch#{patchnum += 1}: #{File.basename(patch)}\n" | |
end | |
s | |
} | |
apply = "ApplyOptionalPatch linux-kernel-test.patch\n" | |
spec.gsub!(apply) { | |
s = apply | |
s += "\n" | |
for patch in patches | |
s += "ApplyPatch #{File.basename(patch)}\n" | |
end | |
s | |
} | |
File.rename(specfile, specfile + ".old") | |
File.write(specfile, spec) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% cd rpmbuild/SPECS | |
% rpmpatch kernel.spec --localname .mytest ../SOURCES/00*.patch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment