From d1e98ff646d11381b83fa0f7abb9914b88f107d9 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Tue, 29 Jun 2021 09:06:06 +0200 Subject: [PATCH] Add PackageKit test script --- .gitignore | 1 + debug/PackageKit/PackageKit.rb | 75 ++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100755 debug/PackageKit/PackageKit.rb diff --git a/.gitignore b/.gitignore index 188a4c4..f027354 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,4 @@ /config/config.rb /vendor/ /.bundle/ +/debug/PackageKit/PackageKit/ diff --git a/debug/PackageKit/PackageKit.rb b/debug/PackageKit/PackageKit.rb new file mode 100755 index 0000000..efeb233 --- /dev/null +++ b/debug/PackageKit/PackageKit.rb @@ -0,0 +1,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 'fileutils' +require 'pathname' +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('_', '.') + +exec_result = system '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 +raise 'Meson build failed' unless exec_result + +exec_result = system({'DESTDIR' => DESTINATION.to_s}, 'ninja', '-C', TMP.to_s, 'install') +raise 'Ninja installation failed' unless exec_result + +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