Ubuntu Pastebin

Paste from a at Mon, 12 Jan 2015 09:55:11 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env ruby

ENV['PATH'] = '/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin'
if Process.uid == 0
    File.open('/etc/apt/apt.conf.d/apt-cacher', 'w') { |file| file.puts('Acquire::http { Proxy "http://10.0.3.1:3142"; };') }
    exit 1 unless system("apt-get update")
    exit 1 unless system("apt-get install -y ruby ruby-dev")
    exit 1 unless system("gem install jenkins_api_client oauth")
end

require "fileutils"
require_relative "lib/debian/changelog"
require_relative "lib/lp"

eval %x[grep VERSION_ID /etc/os-release].strip
DISTRIB_CODENAME = %x[grep DISTRIB_CODENAME /etc/lsb-release].strip.split("=")[-1]

_version = "5.4.0"
job_dist = ARGV[0]
job_type = ARGV[1]
job_name = ARGV[2]

source_name = nil
Dir.chdir("packaging") do
    changelog = Changelog.new
    source_name = changelog.name
end

ppa = Launchpad::Rubber::from_url("https://api.launchpad.net/devel/~kubuntu-ci/+archive/ubuntu/stage")
distro_series = Launchpad::Rubber::from_url("https://api.launchpad.net/devel/ubuntu/#{DISTRIB_CODENAME}")
begin
    source = ppa.getPublishedSources(:source_name => source_name,
                                     :distro_series => distro_series)[0] # This is sorted
rescue
    # no source in ppa yet
    puts "Found no previous upload in PPA..."
    source = nil
end

Dir.mkdir("build-area") unless File.exist?("build-area")
Dir.chdir("build-area") do
    # cleanup previous builds - drop changes, that way we can retain the packages
    # while avoiding conflicts with debsign/dput wildcards.
    Dir.glob("*.changes").each { |c| File.delete(c) }

    # Get orig tar.
    tar = "#{job_name}-#{_version}.tar.xz"
    unless File.exist?(tar)
        raise "tar download failed" unless system("wget http://download.qt-project.org/official_releases/qt/5.4/#{_version}/submodules/#{job_name}-#{_version}.tar.xz")
    end
    base = File.basename(tar, ".tar.xz")
    split_base = base.split("-")
    version = split_base.pop
    name = split_base.join("-")
    orig_tar= "#{name}_#{version}.orig.tar.xz"
    File.delete(orig_tar) if File.exist?(orig_tar)
    raise "failed to symlink orig tar" unless system("ln -s #{tar} #{orig_tar}")
end

# Figure out the version to use
pkg_version = nil
# FIXME: _version needs to be compared with what is in the PPA to bump it
if source
    ppa_too_old = system("dpkg --compare-versions #{_version} gt #{source.source_package_version}")
    unless ppa_too_old
        pkg_version = source.source_package_version
        match = pkg_version.match(/(.*~ppa)(\d+)/)
        # Bump the ppa revision.
        pkg_version = match[1] + (match[2].to_i + 1).to_s
    end
end
if pkg_version.nil? # Fallback
    pkg_version = "#{_version}-0ubuntu1~ubuntu#{VERSION_ID}~ppa1"
end

Dir.chdir("build-area") do
    FileUtils.rm_rf("#{job_name}-#{_version}")
    Dir.mkdir("#{job_name}-#{_version}")
    `tar -xf "#{job_name}_#{_version}.orig.tar.xz" -C #{job_name}-#{_version} --strip-components 1`
    `cp -rv ../packaging/* #{job_name}-#{_version}/`
    Dir.chdir("#{job_name}-#{_version}") do
        FileUtils.rm_rf(".bzr")
        FileUtils.rm_rf(".git")
        raise unless system({'DEBFULLNAME' => 'Kubuntu CI',
                             'DEBEMAIL' => 'kubuntu-ci@lists.launchpad.net'},
                            "dch -v #{pkg_version} -D #{DISTRIB_CODENAME} -b 'PPA Build'")
        raise unless system("dpkg-buildpackage -S -us -uc -sa")
    end
end

# Source package now exist in build-area/.
# Yield back to jenkins script to do host things...
Download as text