Ubuntu Pastebin

Paste from shadeslayer at Tue, 27 Jan 2015 13:20:45 +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
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
diff --git a/dci/mozilla.rb b/dci/mozilla.rb
index f31f995..7bb20bc 100644
--- a/dci/mozilla.rb
+++ b/dci/mozilla.rb
@@ -15,193 +15,201 @@ $logger = DCILogger.instance
 PACKAGE = ARGV[1]
 RELEASE = ARGV[2]
 
-def firefox_releases
-    require 'nokogiri'
-    threads = []
-    ubuntu_versions = []
-    upstream_versions = []
-    threads << Thread.new do
-        # Find the latest release from the Mozilla releases page
-        begin
-            doc = Nokogiri::HTML(open("https://www.mozilla.org/en-US/firefox/releases"))
-        rescue
-            sleep 30
-            retry
-        end
-
-        doc.css('li').each do |node|
-            text = node.text
-            match_data = text.match('(\d+[.]\d+)')
-            upstream_versions << match_data.string.to_f unless match_data.nil?
-        end
-
-        upstream_versions.uniq!
-        upstream_versions.sort!
-        puts "Upstream #{upstream_versions}"
+$logger.info("Building #{PACKAGE}")
+
+def package_releases
+  require 'nokogiri'
+  threads = []
+  ubuntu_versions = []
+  upstream_versions = []
+  threads << Thread.new do
+    # Find the latest release from the Mozilla releases page
+    begin
+      doc = Nokogiri::HTML(open("https://www.mozilla.org/en-US/#{PACKAGE}/releases"))
+    rescue
+      sleep 30
+      retry
     end
 
-    threads << Thread.new do
-        `rmadison -u ubuntu -a amd64 -s #{RELEASE} firefox`.to_str.each_line { |line|
-            match_data = line.match('(\d+[.]\d+)')
-            ubuntu_versions <<  match_data[0].to_f unless match_data.nil?
-        }
-
-        # Make sure we take the updates suite into account too
-        `rmadison -u ubuntu -a amd64 -s #{RELEASE}-updates firefox`.to_str.each_line { |line|
-            match_data = line.match('(\d+[.]\d+)')
-            ubuntu_versions <<  match_data[0].to_f unless match_data.nil?
-        }
-
-        ubuntu_versions.uniq!
-        ubuntu_versions.sort!
-        puts "Ubuntu #{ubuntu_versions}"
+    doc.css('li').each do |node|
+      text = node.text
+      match_data = text.match('(\d+[.]\d+)')
+      upstream_versions << match_data.string.to_f unless match_data.nil?
     end
 
-    ThreadsWait.all_waits(threads)
-    return { ubuntu: ubuntu_versions[-1], upstream: upstream_versions[-1] }
-end
+    upstream_versions.uniq!
+    upstream_versions.sort!
+    $logger.info("Upstream #{upstream_versions}")
+  end
 
-def run_cmd(cmd)
-    retry_count = 0
-    begin
-        if retry_count <= 5
-            fail unless system(cmd)
-        else
-            $logger.fatal("#{cmd} keeps failing! :(")
-            exit 1
-        end
-    rescue RuntimeError
-        $logger.warn("Trying to run #{cmd} again!")
-        retry_count += 1
-        sleep(retry_count * 20)
-        retry
+  threads << Thread.new do
+    `rmadison -u ubuntu -a amd64 -s #{RELEASE} #{PACKAGE}`.to_str.each_line do | line |
+      match_data = line.match('(\d+[.]\d+)')
+      ubuntu_versions <<  match_data[0].to_f unless match_data.nil?
+    end
+
+    # Make sure we take the updates suite into account too
+    `rmadison -u ubuntu -a amd64 -s #{RELEASE}-updates #{PACKAGE}`.to_str.each_line do | line |
+      match_data = line.match('(\d+[.]\d+)')
+      ubuntu_versions <<  match_data[0].to_f unless match_data.nil?
     end
+
+    ubuntu_versions.uniq!
+    ubuntu_versions.sort!
+    puts "Ubuntu #{ubuntu_versions}"
+  end
+
+  ThreadsWait.all_waits(threads)
+  { ubuntu: ubuntu_versions[-1], upstream: upstream_versions[-1] }
+end
+
+def bump_version
+  changelog = Changelog.new
+  version = "1000~#{changelog.version(Changelog::BASE)}"
+  if DEBIAN_RELEASES.include? RELEASE
+    version += '-1'
+    File.open('debian/config/mozconfig.in', 'a') { |f|
+      f.puts("ac_add_options --enable-gstreamer=1.0\n")
+    }
+  else
+    version += '-0ubuntu1'
+  end
+  version += "~#{DateTime.now.strftime('%Y%m%d.%H%M')}"
+  $logger.info("New version is going to be #{version}")
+  `dch -v "#{version}" "[CI Build] #{PACKAGE} with KDE integration"`
+
+  # Rename orig
+  File.rename("../#{PACKAGE}_#{changelog.version(Changelog::BASE)}.orig.tar.bz2",
+              "../#{PACKAGE}_#{new_changelog.version(Changelog::BASE)}.orig.tar.bz2")
+end
+
+def install_kde_js
+  $logger.info('Modifying debian/rules')
+  rules = File.read('debian/rules')
+  rules.gsub!(/pre-build.*$/) do | m |
+    m += "\n\tmkdir -p $(MOZ_DISTDIR)/bin/defaults/pref/\n\tcp $(CURDIR)/debian/kde.js $(MOZ_DISTDIR)/bin/defaults/pref/kde.js"
+  end
+  File.write('debian/rules', rules)
+end
+
+def add_dummy_package
+  # Add dummy package
+  control = File.read('debian/control.in')
+  control += "\nPackage: @MOZ_PKG_NAME@-plasma
+  Architecture: any
+  Depends: @MOZ_PKG_NAME@ (= ${binary:Version}), firefox-kde-support
+  Description:
+  Install this package if you'd like #{PACKAGE} with Plasma integration
+  "
+  File.write('debian/control.in', control)
+
+  File.open("debian/#{PACKAGE}-plasma.pref", 'w') do |f|
+    f.puts("Package: *
+    Pin: release o=LP-PPA-moz-plasma-builds
+    Pin-Priority: 1000
+
+    Package: *
+    Pin: release o=LP-PPA-moz-plasma-releases
+    Pin-Priority: 1000
+    ")
+  end
+
+  File.open("debian/#{PACKAGE}-plasma.install", 'w') do |f|
+    f.puts("debian/#{PACKAGE}-plasma.pref etc/apt/preferences.d/")
+  end
 end
 
 def build_firefox
-    release_info = firefox_releases
-    if release_info[:ubuntu] < release_info[:upstream]
-        $logger.error("Can't build new firefox, Ubuntu hasn't updated the package!")
-        exit 0
+  Dir.chdir('build') do
+
+    system("hg clone http://www.rosenauer.org/hg/mozilla/#firefox#{release_info[:ubuntu].to_i} suse")
+
+    firefox_dir = Dir["firefox-*"][0]
+    Dir.chdir(firefox_dir) do
+      bump_version
+
+      `cp ../suse/firefox-kde.patch ../suse/mozilla-kde.patch debian/patches/`
+      `cp ../suse/MozillaFirefox/kde.js debian/`
+
+      system("quilt pop -a")
+      # Need to remove unity menubar from patches first since it interferes with the KDE patches
+      system("quilt delete unity-menubar.patch")
+
+      $logger.info("Adding Firefox KDE patches")
+      File.open('debian/patches/series', 'a') { |f|
+        # Please preserve this order of patch
+        f.puts("mozilla-kde.patch\nfirefox-kde.patch\nunity-menubar.patch\n")
+      }
+
+      system('quilt push -fa')
+      system('quilt refresh')
+      install_kde_js
+      add_dummy_package
+
+      $logger.info("Building the source package")
+      # TODO: Fix the control file parser to take optional build-deps into account
+      # control = DebianControl.new
+      # control.parse!
+      # build_depends = []
+      # control.source['build-depends'].each do |dep|
+      #     build_depends << dep.name
+      # end
+      # fail "Failed to install build deps!" unless system("apt-get -y install #{build_depends.join(' ')}")
+      system("apt-get -y build-dep firefox")
+      system("debian/rules debian/control")
+      `dch --release --distribution #{RELEASE} ""`
     end
 
-    `rm -rf build`
-    Dir.mkdir('build')
-    Dir.chdir('build') {
-        dci_run_cmd("pull-lp-source -m http://127.0.0.1:3142/ubuntu firefox #{RELEASE}")
-
-        system("hg clone http://www.rosenauer.org/hg/mozilla/#firefox#{release_info[:ubuntu].to_i} suse")
-
-        firefox_dir = Dir["firefox-*"][0]
-        Dir.chdir(firefox_dir) {
-            changelog = Changelog.new
-            version = "1000~#{changelog.version(Changelog::BASE)}"
-            if DEBIAN_RELEASES.include? RELEASE
-                version += '-1'
-                File.open('debian/config/mozconfig.in', 'a') { |f|
-                    f.puts("ac_add_options --enable-gstreamer=1.0\n")
-                }
-            else
-                version += '-0ubuntu1'
-            end
-            version += "~#{DateTime.now.strftime('%Y%m%d.%H%M')}"
-            $logger.info("New version is going to be #{version}")
-            `dch -v "#{version}" "Firefox with KDE integration [CI Build]"`
-
-            new_changelog = Changelog.new
-
-            `cp ../suse/firefox-kde.patch ../suse/mozilla-kde.patch debian/patches/`
-            `cp ../suse/MozillaFirefox/kde.js debian/`
-
-            # Rename orig
-            File.rename("../firefox_#{changelog.version(Changelog::BASE)}.orig.tar.bz2", "../firefox_#{new_changelog.version(Changelog::BASE)}.orig.tar.bz2")
-
-            system("quilt pop -a")
-            # Need to remove unity menubar from patches first since it interferes with the KDE patches
-            system("quilt delete unity-menubar.patch")
-
-            $logger.info("Adding Firefox KDE patches")
-            File.open('debian/patches/series', 'a') { |f|
-                # Please preserve this order of patch
-                f.puts("mozilla-kde.patch\nfirefox-kde.patch\nunity-menubar.patch\n")
-            }
-
-            system("quilt push -fa")
-            system("quilt refresh")
-            $logger.info("Modifying debian/rules")
-            rules = File.read('debian/rules')
-            rules.gsub!(/pre-build.*$/) {|m|
-                m += "\n\tmkdir -p $(MOZ_DISTDIR)/bin/defaults/pref/\n\tcp $(CURDIR)/debian/kde.js $(MOZ_DISTDIR)/bin/defaults/pref/kde.js"
-            }
-            File.write('debian/rules', rules)
-
-            # Add dummy package
-            control = File.read('debian/control.in')
-            control += "\nPackage: @MOZ_PKG_NAME@-plasma
-Architecture: any
-Depends: @MOZ_PKG_NAME@ (= ${binary:Version}), firefox-kde-support
-Description: Safe and easy web browser from Mozilla - Plasma edition
- Firefox delivers safe, easy web browsing. A familiar user interface,
- enhanced security features including protection from online identity theft,
- and integrated search let you get the most out of the web.
- .
- Install this package if you'd like Firefox with Plasma integration
- "
-            File.write('debian/control.in', control)
-
-            File.open('debian/firefox-plasma.pref', 'w') { |f|
-                f.puts("Package: *
-Pin: release o=LP-PPA-moz-plasma-builds
-Pin-Priority: 1000
-
-Package: *
-Pin: release o=LP-PPA-moz-plasma-releases
-Pin-Priority: 1000
-")
-            }
-
-            File.open('debian/firefox-plasma.install', 'w') { |f|
-                f.puts('debian/firefox-plasma.pref etc/apt/preferences.d/')
-            }
-
-            $logger.info("Building the source package")
-            # TODO: Fix the control file parser to take optional build-deps into account
-            # control = DebianControl.new
-            # control.parse!
-            # build_depends = []
-            # control.source['build-depends'].each do |dep|
-            #     build_depends << dep.name
-            # end
-            # fail "Failed to install build deps!" unless system("apt-get -y install #{build_depends.join(' ')}")
-            system("apt-get -y build-dep firefox")
-            system("debian/rules debian/control")
-            `dch --release --distribution #{RELEASE} ""`
-        }
-
-        # Need to sync since tar goes a bit bonkers about things being
-        # named differently
-        `sync`
-
-        # Run dpkg-buildpackage in new dir
-        firefox_dir = Dir["firefox-*"][0]
-        Dir.chdir(firefox_dir) {
-            dci_run_cmd("dpkg-buildpackage -S -sa -uc -us")
-        }
-
-        system("dcmd cp firefox*.changes /build/")
+    # Need to sync since tar goes a bit bonkers about things being
+    # named differently
+    `sync`
+
+    # Run dpkg-buildpackage in new dir
+    firefox_dir = Dir["firefox-*"][0]
+    Dir.chdir(firefox_dir) {
+      dci_run_cmd("dpkg-buildpackage -S -sa -uc -us")
     }
+
+    system("dcmd cp firefox*.changes /build/")
+  end
 end
 
 def build_thunderbird
-    $logger.info("Needs implementing")
+  Dir.chdir('build') do
+    thunderbird_dir = Dir["thunderbird-*"][0]
+    Dir.chdir(thunderbird_dir) do
+      bump_version
+
+      open('debian/patches/mozilla-kde.patch', 'wb') do | file |
+        file << open('https://build.opensuse.org/source/openSUSE:Factory/MozillaThunderbird/mozilla-kde.patch').read
+      end
+      filterdiff = `filterdiff --addprefix=mozilla/ --strip 1 debian/patches/mozilla-kde.patch`
+      File.write('debian/patches/mozilla-kde.patch', filterdiff)
+      File.write('debian/patches/series', "mozilla-kde.patch -p0\n", mode: 'a')
+      system('quilt push -fa')
+      system('quilt refresh')
+      install_kde_js
+    end
+  end
 end
 
-dci_run_cmd("apt-get update")
-system("apt-get -y install ubuntu-dev-tools mercurial ruby-nokogiri distro-info")
+dci_run_cmd('apt-get update')
+system('apt-get -y install ubuntu-dev-tools mercurial ruby-nokogiri distro-info')
 
 UBUNTU_RELEASES = `ubuntu-distro-info -a`.split
 DEBIAN_RELEASES = `debian-distro-info -a`.split
 
+release_info = package_releases
+if release_info[:ubuntu] < release_info[:upstream]
+  $logger.error("Can't build new #{PACKAGE}, Ubuntu hasn't updated the package!")
+  exit 0
+end
+
+`rm -rf build`
+Dir.mkdir('build')
+Dir.chdir('build') do
+  dci_run_cmd("pull-lp-source -m http://127.0.0.1:3142/ubuntu #{PACKAGE} #{RELEASE}")
+end
 
 build_firefox if PACKAGE == 'firefox'
 build_thunderbird if PACKAGE == 'thunderbird'
Download as text