bin/pack-debug | 152 ------------------------------- config_host.mk.in | 2 configure.ac | 8 + solenv/bin/modules/installer.pm | 53 ++++++++++ solenv/bin/modules/installer/epmfile.pm | 20 ++++ solenv/bin/modules/installer/splitdbg.pm | 121 ++++++++++++++++++++++++ 6 files changed, 202 insertions(+), 154 deletions(-)
New commits: commit 9bf6834fa685b7b33883dfbf93d3e68ed74f1c96 Author: Andras Timar <andras.ti...@collabora.com> AuthorDate: Sat Jan 29 17:42:00 2022 +0100 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Mon Jan 31 22:25:56 2022 +0100 [cp] create debuginfo packages in one round Change-Id: I644af21de7d184daa902f1ef47c813647baa2799 diff --git a/bin/pack-debug b/bin/pack-debug index 3e9b3fd2a6c0..70e3f80c7ed4 100755 --- a/bin/pack-debug +++ b/bin/pack-debug @@ -107,78 +107,9 @@ cat $DEBUGSRC | awk ' rpmbuild -bb --define "_unpackaged_files_terminate_build 0" --define "_binary_payload w1T.xzdio" ${DEBUGSRC}-debugsource --target $build_cpu --buildroot=$buildroot -################################################################### -echo create rpm debug info packages by processing logged spec files -################################################################### - -for i in $BUILD_PATH/workdir/installation/CollaboraOffice/rpm/logging/*/*.spec.log -do - - # repackage only rpm packages with non-stripped so files - - if grep -q '^%attr.*[.]\(so\|bin\)\([.].*\)\?\"' $i - then - echo ================ $i ================ - pack=$(cat $i | awk '/^Name/{print$2}') - buildroot=$(cat $i | awk '/^BuildRoot/{print$2}') - topdir=$(dirname $(dirname $buildroot)) - rpmdir=$(echo $topdir | sed 's/_inprogress$//') - - # create empty buildroot directory - - rm -rf $buildroot - mkdir -p $buildroot $topdir/RPMS/BUILD $topdir/RPMS/RPMS - cd $buildroot - - echo REBUILD: $rpmdir/RPMS/${pack}-[0-9]*.rpm - - # extract rpm package - - rpm2cpio $rpmdir/RPMS/${pack}-[0-9]*.rpm | cpio -idmv - - # create stripped libraries and linked debug info files - - for j in $(cat $i | awk '/^%attr.*libpython.*[.]so.*-gdb[.]py.*?"$/{next} /^%attr.*[.](so|bin)([.].*)?"$/{print$2}') - do - so=$(echo $j | tr -d '"') - cd ./$(dirname $so) - so=$(basename $so) - objcopy --only-keep-debug $so $so.dbg - objcopy --strip-debug $so - objcopy --add-gnu-debuglink=$so.dbg $so - cd $buildroot - done - - # copy files for double package generation (using hard links) - - cp -rl $buildroot $buildroot.copy - - # stripped package - - rpmbuild -bb --define "_unpackaged_files_terminate_build 0" --define "_binary_payload w1T.xzdio" $i --target $build_cpu --buildroot=$buildroot - rm -rf $buildroot - mv $buildroot.copy $buildroot - mkdir -p $topdir/RPMS/BUILD $topdir/RPMS/RPMS - - # create spec file for the debug info package - - cat $i | awk ' - /^Name:/ { print "Summary: Debug information for package "$2; print $0"-debuginfo";next } - /^Group:/ { print $1" Development/Debug";next } - /^%attr.*libpython.*[.]so.*-gdb[.]py.*?"$/ { next } - /^%attr.*[.](so|bin)([.].*)?"$/ { print substr($0, 1, length($0) - 1)".dbg\""; next } - /^%attr/ || /^Summary:/ { next } - {print} - ' > ${i}-debuginfo - - # create debug info package - - rpmbuild -bb --define "_unpackaged_files_terminate_build 0" --define "_binary_payload w1T.xzdio" ${i}-debuginfo --target $build_cpu --buildroot=$buildroot - fi -done echo Update RPM download tar.gz - +rpmdir=$(echo $topdir | sed 's/_inprogress$//') mv $topdir/RPMS/RPMS/*/*.rpm $rpmdir/RPMS/ cd $rpmdir/.. TARGET_RPM=$(ls *_download/*.tar.gz) @@ -238,87 +169,6 @@ cat $DEBUGSRC | awk ' $BUILD_PATH/workdir/UnpackedTarball/epm/epm -f deb -g ${INSTALLDIRNAME}-debugsource ${DEBUGSRC}-debugsource --output-dir DEBS -v -###################################################################### -echo create DEB debug info packages by processing logged EPM lst files -###################################################################### - -for i in $BUILD_PATH/workdir/installation/CollaboraOffice/deb/listfile/en-US/*.lst -do - - # repackage only deb packages with non-stripped so files - - if grep -q '^f .*[.]\(so\|bin\)\([.].*\)\?$' $i - then - echo ================ $i ================ - TARGET_NAME=$INSTALLDIRNAME"$(echo $(basename $i) | awk ' - /epm_gid_Module_Optional_Firebird.lst/{print"basis-firebird"} - /epm_gid_Module_Optional_Gnome.lst/{print"basis-gnome-integration"} - /epm_gid_Module_Optional_Grfflt.lst/{print"basis-graphicfilter"} - /epm_gid_Module_Optional_Kde.lst/{print"basis-kde-integration"} - /epm_gid_Module_Optional_OGLTrans.lst/{print"basis-ogltrans"} - /epm_gid_Module_Optional_PostgresqlSdbc.lst/{print"basis-postgresql-sdbc"} - /epm_gid_Module_Pdfimport.lst/{print"basis-extension-pdf-import"} - /epm_gid_Module_Prg_Base_Bin.lst/{print"basis-base"} - /epm_gid_Module_Prg_Calc_Bin.lst/{print"basis-calc"} - /epm_gid_Module_Prg_Impress_Bin.lst/{print"basis-impress"} - /epm_gid_Module_Prg_Math_Bin.lst/{print"basis-math"} - /epm_gid_Module_Prg_Wrt_Bin.lst/{print"basis-writer"} - /epm_gid_Module_Pyuno.lst/{print"basis-pyuno"} - /epm_gid_Module_Reportbuilder.lst/{print"basis-extension-report-builder"} - /epm_gid_Module_Root_Brand.lst/{print""} - /epm_gid_Module_Root.lst/{print"basis-core"} - /epm_gid_Module_Root_Ure_Hidden.lst/{print"-ure"} - ')" - echo TARGET NAME: $TARGET_NAME - - # create stripped libraries and linked debug info files - - for j in $(cat $i | awk '/^f .*libpython.*[.]so.*-gdb[.]py.*$/{next} /^f .*[.](so|bin)([.].*)?$/{print$6}') - do - cd $(dirname $j) - so=$(basename $j) - # remove old temporary files - rm -f $so.copy $so.dbg - # keep original file - cp $so $so.copy - objcopy --only-keep-debug $so $so.dbg - objcopy --strip-debug $so - objcopy --add-gnu-debuglink=$so.dbg $so - cd $BUILD_PATH - done - - # create stripped package - - $BUILD_PATH/workdir/UnpackedTarball/epm/epm -f deb -g $TARGET_NAME $i --output-dir DEBS -v - - # create spec file for the debug info package - - cat $i | awk ' - /^%product/ { print gensub("%product", "%product Debug info package of", "", $0);next } - /^%description/ { print gensub("%description", "%description Debug info package of", "", $0);next } - /^f .*libpython.*[.]so.*-gdb[.]py.*$/ { next } - /^f .*[.](so|bin)([.].*)?$/ { print $1,$2,$3,$4,$5".dbg",$6".dbg"; next } - /^[cf] / { next } - {print} - ' > ${i}-debuginfo - - # create debug info package - $BUILD_PATH/workdir/UnpackedTarball/epm/epm -f deb -g ${TARGET_NAME}-debuginfo $i-debuginfo --output-dir DEBS -v - - # restore original non stripped library files - - for j in $(cat $i | awk '/^f .*libpython.*[.]so.*-gdb[.]py.*$/{next} /^f .*[.](so|bin)([.].*)?$/{print$6}') - do - cd $(dirname $j) - so=$(basename $j) - rm $so.dbg - # restore original file - mv -f $so.copy $so - cd $BUILD_PATH - done - fi -done - echo Update DEB download tar.gz debdir=$(ls -d $BUILD_PATH/workdir/installation/CollaboraOffice/deb/install/*_deb) diff --git a/config_host.mk.in b/config_host.mk.in index d00f868e2757..04f950592f32 100644 --- a/config_host.mk.in +++ b/config_host.mk.in @@ -127,6 +127,7 @@ export DISABLE_CVE_TESTS=@DISABLE_CVE_TESTS@ export DISABLE_DYNLOADING=@DISABLE_DYNLOADING@ export DISABLE_OPENSSL=@DISABLE_OPENSSL@ export DISABLE_PYTHON=@DISABLE_PYTHON@ +export DISABLE_STRIP=@DISABLE_STRIP@ export DLOPEN_LIBS=@DLOPEN_LIBS@ export DLLTOOL=@DLLTOOL@ export DOCDIR=@DOCDIR@ @@ -203,6 +204,7 @@ export ENABLE_SDREMOTE_BLUETOOTH=@ENABLE_SDREMOTE_BLUETOOTH@ export ENABLE_SILENT_MSI=@ENABLE_SILENT_MSI@ export ENABLE_SKIA=@ENABLE_SKIA@ export ENABLE_SKIA_DEBUG=@ENABLE_SKIA_DEBUG@ +export ENABLE_STRIP=@ENABLE_STRIP@ export ENABLE_SYMBOLS_FOR=@ENABLE_SYMBOLS_FOR@ export ENABLE_VALGRIND=@ENABLE_VALGRIND@ export ENABLE_VLC=@ENABLE_VLC@ diff --git a/configure.ac b/configure.ac index a50e35e599d5..b9be6613c297 100644 --- a/configure.ac +++ b/configure.ac @@ -4612,16 +4612,24 @@ if test -z "$enable_symbols"; then fi if test "$enable_symbols" = yes; then ENABLE_SYMBOLS_FOR=all + ENABLE_STRIP= + DISABLE_STRIP=1 AC_MSG_RESULT([yes]) elif test "$enable_symbols" = no; then ENABLE_SYMBOLS_FOR= + ENABLE_STRIP=1 + DISABLE_STRIP= AC_MSG_RESULT([no]) else # Selective debuginfo. ENABLE_SYMBOLS_FOR="$enable_symbols" + ENABLE_STRIP= + DISABLE_STRIP=1 AC_MSG_RESULT([for "$enable_symbols"]) fi AC_SUBST(ENABLE_SYMBOLS_FOR) +AC_SUBST(ENABLE_STRIP) +AC_SUBST(DISABLE_STRIP) if test -n "$with_android_ndk" -a \( -n "$ENABLE_SYMBOLS" -o -n "$ENABLE_DEBUG" -o -n "$ENABLE_DBGUTIL" \) -a "$ENABLE_DEBUGINFO_FOR" = "all"; then # Building on Android with full symbols: without enough memory the linker never finishes currently. 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 7b5a5da77198..fc8374aa8c21 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..cab93ee6386b --- /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 =~ /with debug_info/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;