diff options
author | Andras Timar <andras.timar@collabora.com> | 2018-04-23 20:18:45 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2022-02-13 12:49:20 +0100 |
commit | 9562f667fb35f9af5709b6cc75e74cfc93b445b3 (patch) | |
tree | 9a9fd32c661b8a3fc1414a29dc9f2f8ed2e202f2 /solenv | |
parent | 003c8b9f89be4f99c2f23cb1d49c08f8d9562221 (diff) |
[cp] Allow creation of debuginfo and debugsource rpm/deb packages
Change-Id: Idae5128b58e4cd6f61b8e83664098d195ca67072
Diffstat (limited to 'solenv')
-rw-r--r-- | solenv/bin/modules/installer.pm | 53 | ||||
-rw-r--r-- | solenv/bin/modules/installer/epmfile.pm | 20 | ||||
-rw-r--r-- | solenv/bin/modules/installer/splitdbg.pm | 121 |
3 files changed, 191 insertions, 3 deletions
diff --git a/solenv/bin/modules/installer.pm b/solenv/bin/modules/installer.pm index a4075fec5126..fc4996d3caf4 100644 --- a/solenv/bin/modules/installer.pm +++ b/solenv/bin/modules/installer.pm @@ -45,6 +45,7 @@ use installer::scpzipfiles; use installer::scriptitems; use installer::setupscript; use installer::simplepackage; +use installer::splitdbg qw(splitdbg_libraries); use installer::strip qw(strip_libraries); use installer::systemactions; use installer::windows::assembly; @@ -1042,6 +1043,7 @@ sub run { strip_libraries($filesinpackage, $languagestringref); } + if ( $installer::globals::simple ) { installer::worker::install_simple($onepackagename, $$languagestringref, $dirsinpackage, $filesinpackage, $linksinpackage, $unixlinksinpackage); } @@ -1053,16 +1055,37 @@ sub run { # Example for a link: l 000 root sys /usr/bin/linkname filename # The source field specifies the file to link to + # check if we have to create a debug info package + my $dbg = 0; + my $debugfilelist; + if ( !($installer::globals::strip) ) + { + $debugfilelist = splitdbg_libraries($filesinpackage, $languagestringref); + if ( $#{$debugfilelist} > -1 ) + { + $dbg = 1; + } + } + my $epmfilename = "epm_" . $onepackagename . ".lst"; + my $dbgepmfilename = "epm_" . $onepackagename . ".debug.lst"; installer::logger::print_message( "... creating epm list file $epmfilename ... \n" ); + if ($dbg) + { + installer::logger::print_message( "... creating epm list file $dbgepmfilename ... \n" ); + } my $completeepmfilename = $listfiledir . $installer::globals::separator . $epmfilename; + my $completedbgepmfilename = $listfiledir . $installer::globals::separator . $dbgepmfilename; + my @epmfile = (); + my @dbgepmfile = (); my $epmheaderref = installer::epmfile::create_epm_header($allvariableshashref, $filesinproductlanguageresolvedarrayref, $languagesarrayref, $onepackage); installer::epmfile::adding_header_to_epm_file(\@epmfile, $epmheaderref); + my $dbgepmheaderref; # adding directories, files and links into epm file @@ -1091,6 +1114,17 @@ sub run { installer::epmfile::resolve_path_in_epm_list_before_packaging(\@epmfile, $completeepmfilename, "UREPACKAGEPREFIX", $allvariableshashref->{'UREPACKAGEPREFIX'}); installer::files::save_file($completeepmfilename ,\@epmfile); + if ($dbg) + { + $onepackage->{'packagename'} .= "-debuginfo"; + $onepackage->{'description'} .= " (debug info)"; + $dbgepmheaderref = installer::epmfile::create_epm_header($allvariableshashref, $filesinproductlanguageresolvedarrayref, $languagesarrayref, $onepackage); + installer::epmfile::adding_header_to_epm_file(\@dbgepmfile, $dbgepmheaderref); + installer::epmfile::put_directories_into_epmfile($dirsinpackage, \@dbgepmfile, $allvariableshashref, $packagerootpath); + installer::epmfile::put_files_into_dbgepmfile($debugfilelist, \@dbgepmfile ); + installer::files::save_file($completedbgepmfilename ,\@dbgepmfile); + } + { # changing into the "install" directory to create installation sets @@ -1133,9 +1167,18 @@ sub run { # Install: rpm -i --prefix=/opt/special --nodeps so8m35.rpm installer::epmfile::create_new_directory_structure($newepmdir); - $installer::globals::postprocess_specialepm = 1; - # solaris patch not needed anymore + # package the debug info if required + + if ($dbg) + { + installer::epmfile::call_epm($epmexecutable, $completedbgepmfilename, $packagename . "-debuginfo", $includepatharrayref); + my $newdbgepmdir = installer::epmfile::prepare_packages($loggingdir, $packagename . "-debuginfo", $staticpath, $relocatablepath, $onepackage, $allvariableshashref, $debugfilelist, $languagestringref); + installer::epmfile::create_packages_without_epm($newdbgepmdir, $packagename . "-debuginfo", $includepatharrayref, $allvariableshashref, $languagestringref); + installer::epmfile::remove_temporary_epm_files($newdbgepmdir, $loggingdir, $packagename . "-debuginfo"); + installer::epmfile::create_new_directory_structure($newdbgepmdir); + } + $installer::globals::postprocess_specialepm = 1; } } @@ -1157,7 +1200,11 @@ sub run { installer::logger::print_message( "... starting unpatched epm ... \n" ); } - if ( $installer::globals::call_epm ) { installer::epmfile::call_epm($epmexecutable, $completeepmfilename, $packagename, $includepatharrayref); } + installer::epmfile::call_epm($epmexecutable, $completeepmfilename, $packagename, $includepatharrayref); + if ($dbg) + { + installer::epmfile::call_epm($epmexecutable, $completedbgepmfilename, $packagename . "-debuginfo", $includepatharrayref); + } if (($installer::globals::isrpmbuild) || ($installer::globals::issolarispkgbuild) || ($installer::globals::debian)) { diff --git a/solenv/bin/modules/installer/epmfile.pm b/solenv/bin/modules/installer/epmfile.pm index 495366823604..e0d985be52be 100644 --- a/solenv/bin/modules/installer/epmfile.pm +++ b/solenv/bin/modules/installer/epmfile.pm @@ -196,6 +196,26 @@ sub put_files_into_epmfile } } +sub put_files_into_dbgepmfile +{ + my ($filesinproductarrayref, $epmfileref) = @_; + + for ( my $i = 0; $i <= $#{$filesinproductarrayref}; $i++ ) + { + my $onefile = ${$filesinproductarrayref}[$i]; + + my $unixrights = $onefile->{'UnixRights'}; + my $destination = $onefile->{'destination'} . ".dbg"; + my $sourcepath = $onefile->{'sourcepath'} . ".dbg"; + my $filetype = "f"; + my $group = "root"; + + my $line = "$filetype $unixrights root $group $destination $sourcepath\n"; + + push(@{$epmfileref}, $line); + } +} + sub put_links_into_epmfile { my ($linksinproductarrayref, $epmfileref) = @_; diff --git a/solenv/bin/modules/installer/splitdbg.pm b/solenv/bin/modules/installer/splitdbg.pm new file mode 100644 index 000000000000..60c0c1bde024 --- /dev/null +++ b/solenv/bin/modules/installer/splitdbg.pm @@ -0,0 +1,121 @@ +# +# This file is part of the LibreOffice project. +# +# 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 http://mozilla.org/MPL/2.0/. +# + +package installer::splitdbg; + +use strict; +use warnings; + +use base 'Exporter'; + +use installer::globals; +use installer::logger; +use installer::pathanalyzer; +use installer::systemactions; + +our @EXPORT_OK = qw(splitdbg_libraries); + +sub _need_to_splitdbg +{ + my ( $filename ) = @_; + + my $splitdbg = 0; + + # Check using the "file" command + + $filename =~ s/'/'\\''/g; + open (FILE, "file '$filename' |"); + my $fileoutput = <FILE>; + close (FILE); + + if (( $fileoutput =~ /not stripped/i ) && ( $fileoutput =~ /\bELF\b/ )) { $splitdbg = 1; } + + return $splitdbg; +} + +sub _do_splitdbg +{ + my ( $filename ) = @_; + + my $systemcall = "objcopy --only-keep-debug $filename $filename.dbg && "; + $systemcall .= "objcopy --strip-debug $filename && "; + $systemcall .= "objcopy --add-gnu-debuglink=$filename.dbg $filename"; + + my $returnvalue = system($systemcall); + + my $infoline = "Systemcall: $systemcall\n"; + push( @installer::globals::logfileinfo, $infoline); + + if ($returnvalue) + { + $infoline = "ERROR: Could not split debug info of $filename!\n"; + push( @installer::globals::logfileinfo, $infoline); + } + else + { + $infoline = "SUCCESS: Split debug info of $filename!\n"; + push( @installer::globals::logfileinfo, $infoline); + } +} + +sub splitdbg_libraries +{ + my ( $filelist, $languagestringref ) = @_; + + my @debugfilelist = (); + + installer::logger::include_header_into_logfile("Splitting debuginfo from files:"); + + my $splitdbgdirbase = installer::systemactions::create_directories("splitdbg", $languagestringref); + + if (! grep {$_ eq $splitdbgdirbase} @installer::globals::removedirs) + { + push(@installer::globals::removedirs, $splitdbgdirbase); + } + + for ( my $i = 0; $i <= $#{$filelist}; $i++ ) + { + my $sourcefilename = ${$filelist}[$i]->{'sourcepath'}; + + if ( _need_to_splitdbg($sourcefilename) ) + { + my $shortfilename = $sourcefilename; + installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$shortfilename); + + my $infoline = "Split debuginfo: $shortfilename\n"; + push(@installer::globals::logfileinfo, $infoline); + + # copy file into directory for split debuginfo libraries + + my $onelanguage = ${$filelist}[$i]->{'specificlanguage'}; + + # files without language into directory "00" + + if ($onelanguage eq "") { $onelanguage = "00"; } + + my $splitdbgdir = $splitdbgdirbase . $installer::globals::separator . $onelanguage; + installer::systemactions::create_directory($splitdbgdir); # creating language specific subdirectories + + my $destfilename = $splitdbgdir . $installer::globals::separator . $shortfilename; + installer::systemactions::copy_one_file($sourcefilename, $destfilename); + + # change sourcepath in files collector + + ${$filelist}[$i]->{'sourcepath'} = $destfilename; + + # split debuginfo from file + + _do_splitdbg($destfilename); + + push(@debugfilelist, ${$filelist}[$i]); + } + } + return \@debugfilelist; +} + +1; |