Created
April 14, 2011 20:06
-
-
Save tbielawa/920368 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
class Builder | |
@rpm_build_command = "" | |
def initialize(package_name, version, mock_chroot, build_target) | |
@package_name = package_name | |
@version = version | |
@full_name = "#{@package_name}-#{@version}" | |
@mock_chroot = mock_chroot | |
@build_target = build_target | |
@srpm_path = "/var/lib/mock/#{@mock_chroot}/result" | |
@sdist = "dist/#{@full_name}.tar.gz" | |
@specfile = "#{@package_name}.spec" | |
end | |
def setup_sdist | |
`./setup.py sdist` | |
end | |
def build_srpm | |
build_command = "mock -r #{@mock_chroot} --buildsrpm --sources #{@sdist} --spec #{@specfile}" | |
result_glob = @srpm_path + "/" + @full_name + "*.src.rpm" | |
self.setup_sdist unless File.exists? @sdist | |
puts "Building srpm for #{@mock_chroot} with this command:" | |
puts build_command | |
`#{build_command}` | |
# Do a check here so we can return something useful. | |
results = Dir[result_glob] | |
if results.count == 0 | |
return nil | |
else | |
@srpm = results.first | |
return true | |
end | |
end | |
def build_rpm | |
build_command = "#{@rpm_build_command} build --scratch #{@build_target} #{@srpm}" | |
# Run the build_command..... This can take a while to complete... | |
puts "Building rpm for #{@mock_chroot} with this command:" | |
puts build_command | |
# Execute the build | |
`#{build_command}` | |
end | |
def srpm | |
@srpm | |
end | |
end | |
class BrewBuilder < Builder | |
def initialize(package_name, version, mock_chroot, build_target) | |
super(package_name, version, mock_chroot, build_target) | |
@rpm_build_command = "brew" | |
end | |
end | |
class KojiBuilder < Builder | |
def initialize(package_name, version, mock_chroot, build_target) | |
super(package_name, version, mock_chroot, build_target) | |
@rpm_build_command = "koji" | |
end | |
end | |
def make_release | |
builders = Array.new | |
name = "python-taboot" | |
version = `make version` | |
version = version.strip | |
builders.push BrewBuilder.new(name, version, "epel-5-i386", "brew-5E") | |
builders.push BrewBuilder.new(name, version, "epel-6-i386", "brew-6E") | |
builders.push KojiBuilder.new(name, version, "fedora-14-i386", "dist-f14") | |
builders.each { |builder| builder.build_srpm } | |
builders.each { |builder| builder.build_rpm } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment