summaryrefslogtreecommitdiff
path: root/debug/PackageKit/PackageKit.rb
blob: f093de715de638f1af67e2fd12056c90290c78a2 (plain)
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
#!/usr/bin/env ruby
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.

# frozen_string_literal: true

# This script creates a debug PackageKit build used for development.
# For the script to work PackageKit source should be in the ./PackageKit
# directory alongside this script.

require 'rake/file_utils'
require 'pathname'
require 'rake'
require 'open3'

CWD = Pathname.new Dir.pwd
SOURCE = CWD + 'PackageKit'
TMP = CWD + 'tmp'
DESTINATION = CWD + 'package'
BUILD = 1
ARCH = `uname -m`.strip

FileUtils.rm_rf [TMP, DESTINATION]
Dir.mkdir TMP

version = `git -C #{SOURCE} describe --tags --abbrev=0`
  .strip
  .delete_prefix('PACKAGEKIT_')
  .gsub('_', '.')

sh 'meson',
  '--buildtype=debug',
  '--prefix=/usr',
  '--libdir=/usr/lib64',
  '--localstatedir=/var',
  '--mandir=/usr/man',
  '--sysconfdir=/etc',
  '-Dsystemd=false',
  '-Doffline_update=false',
  '-Dbash_completion=false',
  '-Dbash_completion_not_found=false',
  '-Dpackaging_backend=slack',
  '-Ddaemon_tests=true',
  TMP.to_s,
  SOURCE.to_s

sh({ 'DESTDIR' => DESTINATION.to_s },
  'ninja', '-C', TMP.to_s, 'install')

actual_mandir = DESTINATION + 'usr/share/man/man1'
mandir = DESTINATION + 'usr/man/man1'
FileUtils.mkdir_p mandir
Dir.new(actual_mandir).each_child do |entry|
  manpage = actual_mandir + entry

  Open3.popen3 'gzip', '--stdout', '-9', manpage.to_s do |stdin, stdout, stderr, wait_thr|
    File.open (mandir + "#{entry}.gz").to_s, 'wb' do |file|
      stdin.close

      IO.copy_stream stdout, file
      IO.copy_stream stderr, $stderr

      stdout.close
      stderr.close
      wait_thr.value
    end
  end
end
FileUtils.rm_rf (DESTINATION + 'usr/share/man').to_s

Dir.chdir DESTINATION
package_path = CWD + "PackageKit-#{version}-#{ARCH}-#{BUILD}_debug.txz"
puts "Building #{package_path}"
system '/sbin/makepkg', '-l', 'y', '-c', 'n', package_path.to_s