bin/pack-debug |  321 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 321 insertions(+)

New commits:
commit 0c19de75b26a4b0c9d6607496fc8867d1a0117a1
Author: László Németh <[email protected]>
Date:   Thu Dec 15 17:33:17 2016 +0100

    script for generating debug packages
    
    Change-Id: I89be53e5fea3b9928d960604d050db47383baae3

diff --git a/bin/pack-debug b/bin/pack-debug
new file mode 100755
index 0000000..f5a31ac
--- /dev/null
+++ b/bin/pack-debug
@@ -0,0 +1,321 @@
+#!/bin/sh
+# create debuginfo and debugsource packages from LO rpm & deb files
+# (generated by using --enable-symbols)
+#
+# Usage:
+#
+# cd /opt/lo_installation_path
+# dbg_pkg
+# # or
+# # PACKAGENAME=collaboraoffice5.1 dbg_pkg # if building in a different path
+
+# build path
+export BUILD_PATH=$PWD
+
+# set package base name, eg. collaboraoffice5.1
+# based on the actual directory, eg. /opt/collaboraoffice5.1,
+# or checking the PACKAGENAME environmental variable
+
+if [ -z "$PACKAGENAME" ]
+then
+DEBUGSRC_PACKAGENAME=$(basename $BUILD_PATH)
+else
+DEBUGSRC_PACKAGENAME=$PACKAGENAME
+fi
+echo PACKAGE NAME: $DEBUGSRC_PACKAGENAME
+
+# set install dirname and product version
+eval $(grep ^INSTALLDIRNAME config.log)
+eval $(grep ^PRODUCTVERSION config.log)
+
+#################################
+# Function for re-build RPM files
+#################################
+function repack_rpm {
+
+# set environment based on config.log
+# for find-requires-x11.sh used by rpm __find_requires
+eval $(grep ^PLATFORMID config.log)
+export PLATFORMID
+eval $(grep ^build_cpu config.log)
+export build_cpu
+
+#########################################
+# create source package
+# (use PACKAGENAME environmental variable
+# to find "$PACKAGENAME".spec.log)
+#########################################
+
+DEBUGSRC="$(find workdir -name ${DEBUGSRC_PACKAGENAME}.spec.log)"
+
+echo Base spec file: $DEBUGSRC
+
+if [ -z "$DEBUGSRC" ]
+then
+ echo "Missing ${DEBUGSRC_PACKAGENAME}.spec.log in workdir/, specify spec.log 
file name in PACKAGENAME"
+ echo "For example: PACKAGENAME=collaboraoffice5.1 dbg_pkg"
+ exit 1
+fi
+
+# create spec file, based on the spec file of the brand package
+
+cat $DEBUGSRC | awk '
+       /^Name:/ { print "Summary: Debug source for package "$2; print 
$0"-debugsource";next }
+       /^Group:/ { print $1" Development/Debug";next }
+       /^Brand module/ { print gensub("Brand module", "Source files", "");next 
}
+       /^%attr/ || /^Summary:/ { next }
+       {print}
+       END { 
+               print "%defattr(-,root,root)" 
+       }
+ ' > ${DEBUGSRC}-debugsource
+ buildroot=$(cat $DEBUGSRC-debugsource | awk '/^BuildRoot/{print$2}')
+ topdir=$(dirname $(dirname $buildroot))
+ mkdir -p $buildroot $topdir/RPMS/BUILD $topdir/RPMS/RPMS
+ rm -rf $buildroot
+
+ # create source file list
+
+ find $BUILD_PATH -name '*[.][hc]xx' -o -name '*[.][hc]' | grep -Ev 
'/(workdir|qa|DEBS)/' | grep -E '/(source|inc)/' |
+
+ # list all directories for complete rpm remove
+
+ awk -v home=$BUILD_PATH '
+       {
+               split($0, a, home "/")
+               n=split(a[2], b, "/")
+               c=home
+               for(i=1;i<n;i++) {
+                       c=c"/"b[i]
+                       if(mem[c]!=1) print "%dir "c
+                       mem[c]=1
+               }
+               print $0
+       }' >> ${DEBUGSRC}-debugsource
+
+ echo Spec file of debug source package: ${DEBUGSRC}-debugsource
+
+ echo Start rpmbuild for debug source package...
+
+ ln -s / $buildroot
+
+ # debug build source package
+
+ rpmbuild -bb --define "_unpackaged_files_terminate_build  0" 
${DEBUGSRC}-debugsource --target $build_cpu --buildroot=$buildroot
+
+#################################
+# 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$//')
+       echo $rpmdir
+
+       # 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.*[.](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 -
+       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" $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.*[.](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" 
${i}-debuginfo --target $build_cpu --buildroot=$buildroot
+ fi
+done
+
+echo Place of the debug and stripped rpm packages:
+echo $topdir/RPMS/RPMS/
+}
+
+#################################
+# Function for re-build DEB files
+#################################
+function repack_deb {
+
+#########################################
+# create deb source package
+# (use PACKAGENAME environmental variable
+# to find "$PACKAGENAME".spec.log)
+#########################################
+
+DEBUGSRC=$BUILD_PATH/workdir/installation/CollaboraOffice/deb/listfile/en-US/epm_gid_Module_Root_Brand.lst
+
+echo Base spec file: $DEBUGSRC
+
+# create spec file, based on the spec file of the brand package
+
+cat $DEBUGSRC | awk '
+       /^%product/ { print gensub("Brand module", "Debug source package", "", 
$0) ;next }
+       /^%description/ { print gensub("Brand module", "Debug source package", 
"", $0) ;next }
+       /^[cdf] / { next }
+       {print}
+ ' > ${DEBUGSRC}-debugsource
+
+ # create source file list
+
+ find $BUILD_PATH -name '*[.][hc]xx' -o -name '*[.][hc]' | grep -Ev 
'/(workdir|qa|DEBS)/' | grep -E '/(source|inc)/' |
+
+ # list all directories
+
+ awk -v home=$BUILD_PATH '
+       {
+               split($0, a, home "/")
+               n=split(a[2], b, "/")
+               c=home
+               for(i=1;i<n;i++) {
+                       c=c"/"b[i]
+                       if(mem[c]!=1) print "d 755 root root "c" -"
+                       mem[c]=1
+               }
+               print "f 644 root root "$0" "$0
+       }' >> ${DEBUGSRC}-debugsource
+
+ echo Spec file of debug source package: ${DEBUGSRC}-debugsource
+
+ # debug build source package
+
+ $BUILD_PATH/workdir/UnpackedTarball/epm/epm -f deb -g 
${INSTALLDIRNAME}${PRODUCTVERSION}-debugsource ${DEBUGSRC}-debugsource 
--output-dir DEBS -v
+
+####################################
+# 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_Gnome.lst/{print"basis5.1-gnome-integration"}
+       /epm_gid_Module_Optional_Grfflt.lst/{print"basis5.1-graphicfilter"}
+       /epm_gid_Module_Optional_OGLTrans.lst/{print"basis5.1-ogltrans"}
+       
/epm_gid_Module_Optional_PostgresqlSdbc.lst/{print"basis5.1-postgresql-sdbc"}
+       /epm_gid_Module_Pdfimport.lst/{print"basis5.1-extension-pdf-import"}
+       /epm_gid_Module_Prg_Base_Bin.lst/{print"basis5.1-base"}
+       /epm_gid_Module_Prg_Calc_Bin.lst/{print"basis5.1-calc"}
+       /epm_gid_Module_Prg_Impress_Bin.lst/{print"basis5.1-impress"}
+       /epm_gid_Module_Prg_Math_Bin.lst/{print"basis5.1-math"}
+       /epm_gid_Module_Prg_Wrt_Bin.lst/{print"basis5.1-writer"}
+       /epm_gid_Module_Pyuno.lst/{print"basis5.1-pyuno"}
+       /epm_gid_Module_Root_Brand.lst/{print"5.1"}
+       /epm_gid_Module_Root.lst/{print"basis5.1-core"}
+       /epm_gid_Module_Root_Ure_Hidden.lst/{print"5.1-ure"}
+       ' | sed s/5.1/$PRODUCTVERSION/g)"
+       echo TARGET NAME: $TARGET_NAME
+
+       # create stripped libraries and linked debug info files
+
+       for j in $(cat $i | awk '/^f .*[.](so|bin)([.].*)?$/{print$6}')
+       do
+               cd $(dirname $j)
+               so=$(basename $j)
+               # keep not stripped version
+               echo "$(file $so)" | grep -q 'not stripped' && cp $so $so.copy
+               objcopy --only-keep-debug $so $so.dbg
+               objcopy --strip-debug $so
+               objcopy --add-gnu-debuglink=$so.dbg $so
+               cd -
+       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 "%product Debug info package of "$0 ;next }
+               /^%description/ { print "%description Debug info package of "$0 
;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 .*[.](so|bin)([.].*)?$/{print$6}')
+       do
+               cd $(dirname $j)
+               so=$(basename $j)
+               rm $so.dbg
+               echo "$(file $so)" | grep -q 'not stripped' || mv $so.copy $so
+               cd -
+       done
+
+
+ fi
+done
+
+echo Place of the debug and stripped deb packages:
+echo $BUILD_PATH/DEBS
+}
+
+# start deb re-build
+test "$(find workdir/installation/CollaboraOffice/deb/listfile -name '*.lst')" 
!= "" && repack_deb || \
+       echo 'Missing EPM lst files. Skip DEB debug package generation.'
+
+# start rpm re-build
+test "$(find workdir -name '*spec.log')" != "" && repack_rpm || \
+       echo 'Missing RPM spec files. Skip RPM debug package generation.'
+
+
+
+
_______________________________________________
Libreoffice-commits mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to