vcl: allow for overriding the default PDF rendering resolution
[LibreOffice.git] / bin / pack-debug
blob67c4cd50150de9170909a1a826a8c61828bf4603
1 #!/bin/bash
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 # create debuginfo and debugsource packages from LO rpm & deb files
10 # (generated by using --enable-symbols)
12 # build path
13 export BUILD_PATH=$PWD
14 export BUILD_LOG=$BUILD_PATH/pack-debug.log
16 if [ $# -gt 0 ]
17 then
18 for i in "$@"
20 case $i in
21 --only-rpm) ONLY_RPM=1;;
22 --only-deb) ONLY_DEB=1;;
23 *) echo "Usage: pack-debug [--only-rpm | --only-deb]" && exit 1;;
24 esac
25 done
28 # set install dirname and product version
29 if [ ! -f config.log ]; then
30 echo "config.log not found. Run this script from build root."
31 exit 1;
34 # create pack-debug.log file
35 echo create debug packages >$BUILD_LOG
37 eval $(grep ^INSTALLDIRNAME config.log)
38 eval $(grep ^PRODUCTVERSION config.log)
40 # set package base name, eg. collaboraoffice6.4
41 DEBUGSRC_PACKAGENAME=$INSTALLDIRNAME$PRODUCTVERSION
43 #################################
44 # Function for re-build RPM files
45 #################################
46 function repack_rpm {
48 # set environment based on config.log
49 # for find-requires-x11.sh used by rpm __find_requires
50 eval $(grep ^PLATFORMID config.log)
51 export PLATFORMID
52 eval $(grep ^build_cpu config.log)
53 export build_cpu
55 ####################################
56 echo create RPM debug source package
57 ####################################
59 DEBUGSRC="$(find workdir -name ${DEBUGSRC_PACKAGENAME}.spec.log)"
61 # create spec file, based on the spec file of the brand package
63 cat $DEBUGSRC | awk '
64 /^Name:/ { print "Summary: Debug source for package "$2; print $0"-debugsource";next }
65 /^Group:/ { print $1" Development/Debug";next }
66 /^Brand module/ { print gensub("Brand module", "Source files", "");next }
67 /^%attr/ || /^Summary:/ { next }
68 {print}
69 END {
70 print "%defattr(-,root,root)"
72 ' > ${DEBUGSRC}-debugsource
73 buildroot=$(cat $DEBUGSRC-debugsource | awk '/^BuildRoot/{print$2}')
74 topdir=$(dirname $(dirname $buildroot))
75 mkdir -p $buildroot $topdir/RPMS/BUILD $topdir/RPMS/RPMS
76 rm -rf $buildroot
78 # create source file list
80 find $BUILD_PATH -name '*[.][hc]xx' -o -name '*[.][hc]' | grep -Ev '/(instdir|qa|DEBS)/' |
82 # list all directories for complete rpm remove
84 awk -v home=$BUILD_PATH '
86 split($0, a, home "/")
87 n=split(a[2], b, "/")
88 c=home
89 for(i=1;i<n;i++) {
90 c=c"/"b[i]
91 if(mem[c]!=1) print "%dir "c
92 mem[c]=1
94 print $0
95 }' >> ${DEBUGSRC}-debugsource
97 # start rpmbuild for debug source package
99 ln -s / $buildroot
101 # debug build source package
103 rpmbuild -bb --define "_unpackaged_files_terminate_build 0" ${DEBUGSRC}-debugsource --target $build_cpu --buildroot=$buildroot
105 ###################################################################
106 echo create rpm debug info packages by processing logged spec files
107 ###################################################################
109 for i in $BUILD_PATH/workdir/installation/CollaboraOffice/rpm/logging/*/*.spec.log
112 # repackage only rpm packages with non-stripped so files
114 if grep -q '^%attr.*[.]\(so\|bin\)\([.].*\)\?\"' $i
115 then
116 echo ================ $i ================
117 pack=$(cat $i | awk '/^Name/{print$2}')
118 buildroot=$(cat $i | awk '/^BuildRoot/{print$2}')
119 topdir=$(dirname $(dirname $buildroot))
120 rpmdir=$(echo $topdir | sed 's/_inprogress$//')
122 # create empty buildroot directory
124 rm -rf $buildroot
125 mkdir -p $buildroot $topdir/RPMS/BUILD $topdir/RPMS/RPMS
126 cd $buildroot
128 echo REBUILD: $rpmdir/RPMS/${pack}-[0-9]*.rpm
130 # extract rpm package
132 rpm2cpio $rpmdir/RPMS/${pack}-[0-9]*.rpm | cpio -idmv
134 # create stripped libraries and linked debug info files
136 for j in $(cat $i | awk '/^%attr.*libpython.*[.]so.*-gdb[.]py.*?"$/{next} /^%attr.*[.](so|bin)([.].*)?"$/{print$2}')
138 so=$(echo $j | tr -d '"')
139 cd ./$(dirname $so)
140 so=$(basename $so)
141 objcopy --only-keep-debug $so $so.dbg
142 objcopy --strip-debug $so
143 objcopy --add-gnu-debuglink=$so.dbg $so
144 cd $buildroot
145 done
147 # copy files for double package generation (using hard links)
149 cp -rl $buildroot $buildroot.copy
151 # stripped package
153 rpmbuild -bb --define "_unpackaged_files_terminate_build 0" $i --target $build_cpu --buildroot=$buildroot
154 rm -rf $buildroot
155 mv $buildroot.copy $buildroot
156 mkdir -p $topdir/RPMS/BUILD $topdir/RPMS/RPMS
158 # create spec file for the debug info package
160 cat $i | awk '
161 /^Name:/ { print "Summary: Debug information for package "$2; print $0"-debuginfo";next }
162 /^Group:/ { print $1" Development/Debug";next }
163 /^%attr.*libpython.*[.]so.*-gdb[.]py.*?"$/ { next }
164 /^%attr.*[.](so|bin)([.].*)?"$/ { print substr($0, 1, length($0) - 1)".dbg\""; next }
165 /^%attr/ || /^Summary:/ { next }
166 {print}
167 ' > ${i}-debuginfo
169 # create debug info package
171 rpmbuild -bb --define "_unpackaged_files_terminate_build 0" ${i}-debuginfo --target $build_cpu --buildroot=$buildroot
173 done
175 echo Update RPM download tar.gz
177 mv $topdir/RPMS/RPMS/*/*.rpm $rpmdir/RPMS/
178 cd $rpmdir/..
179 TARGET_RPM=$(ls *_download/*.tar.gz)
180 TARGET_DEBUG=$(echo $TARGET_RPM | sed 's/.tar.gz$/-debug.tar.gz/')
181 SOURCE_RPM=$(find *_rpm -type f | grep -v debug)
182 SOURCE_DEBUG=$(find *_rpm -type f | grep -E '(debug|readme|README)')
183 tar c $SOURCE_RPM | gzip >$TARGET_RPM
184 tar c $SOURCE_DEBUG | gzip >$TARGET_DEBUG
185 cd $BUILD_PATH
186 rm -rf $topdir
189 #################################
190 # Function for re-build DEB files
191 #################################
192 function repack_deb {
194 ####################################
195 echo create DEB debug source package
196 ####################################
198 DEBUGSRC=$BUILD_PATH/workdir/installation/CollaboraOffice/deb/listfile/en-US/epm_gid_Module_Root_Brand.lst
200 echo Base spec file: $DEBUGSRC
202 # create spec file, based on the spec file of the brand package
204 cat $DEBUGSRC | awk '
205 /^%product/ { print gensub("Brand module", "Debug source package", "", $0) ;next }
206 /^%description/ { print gensub("Brand module", "Debug source package", "", $0) ;next }
207 /^[cdf] / { next }
208 {print}
209 ' > ${DEBUGSRC}-debugsource
211 # create source file list
213 find $BUILD_PATH -name '*[.][hc]xx' -o -name '*[.][hc]' | grep -Ev '/(instdir|qa|DEBS)/' |
215 # list all directories
217 awk -v home=$BUILD_PATH '
219 split($0, a, home "/")
220 n=split(a[2], b, "/")
221 c=home
222 for(i=1;i<n;i++) {
223 c=c"/"b[i]
224 if(mem[c]!=1) print "d 755 root root "c" -"
225 mem[c]=1
227 print "f 644 root root "$0" "$0
228 }' >> ${DEBUGSRC}-debugsource
230 echo Spec file of debug source package: ${DEBUGSRC}-debugsource
232 # debug build source package
234 $BUILD_PATH/workdir/UnpackedTarball/epm/epm -f deb -g ${INSTALLDIRNAME}${PRODUCTVERSION}-debugsource ${DEBUGSRC}-debugsource --output-dir DEBS -v
236 ######################################################################
237 echo create DEB debug info packages by processing logged EPM lst files
238 ######################################################################
240 for i in $BUILD_PATH/workdir/installation/CollaboraOffice/deb/listfile/en-US/*.lst
243 # repackage only deb packages with non-stripped so files
245 if grep -q '^f .*[.]\(so\|bin\)\([.].*\)\?$' $i
246 then
247 echo ================ $i ================
248 TARGET_NAME=$INSTALLDIRNAME"$(echo $(basename $i) | awk '
249 /epm_gid_Module_Optional_Firebird.lst/{print"basis6.4-firebird"}
250 /epm_gid_Module_Optional_Gnome.lst/{print"basis6.4-gnome-integration"}
251 /epm_gid_Module_Optional_Grfflt.lst/{print"basis6.4-graphicfilter"}
252 /epm_gid_Module_Optional_Kde.lst/{print"basis6.4-kde-integration"}
253 /epm_gid_Module_Optional_OGLTrans.lst/{print"basis6.4-ogltrans"}
254 /epm_gid_Module_Optional_PostgresqlSdbc.lst/{print"basis6.4-postgresql-sdbc"}
255 /epm_gid_Module_Pdfimport.lst/{print"basis6.4-extension-pdf-import"}
256 /epm_gid_Module_Prg_Base_Bin.lst/{print"basis6.4-base"}
257 /epm_gid_Module_Prg_Calc_Bin.lst/{print"basis6.4-calc"}
258 /epm_gid_Module_Prg_Impress_Bin.lst/{print"basis6.4-impress"}
259 /epm_gid_Module_Prg_Math_Bin.lst/{print"basis6.4-math"}
260 /epm_gid_Module_Prg_Wrt_Bin.lst/{print"basis6.4-writer"}
261 /epm_gid_Module_Pyuno.lst/{print"basis6.4-pyuno"}
262 /epm_gid_Module_Reportbuilder.lst/{print"basis6.4-extension-report-builder"}
263 /epm_gid_Module_Root_Brand.lst/{print"6.4"}
264 /epm_gid_Module_Root.lst/{print"basis6.4-core"}
265 /epm_gid_Module_Root_Ure_Hidden.lst/{print"6.4-ure"}
266 ' | sed s/6.4/$PRODUCTVERSION/g)"
267 echo TARGET NAME: $TARGET_NAME
269 # create stripped libraries and linked debug info files
271 for j in $(cat $i | awk '/^f .*libpython.*[.]so.*-gdb[.]py.*$/{next} /^f .*[.](so|bin)([.].*)?$/{print$6}')
273 cd $(dirname $j)
274 so=$(basename $j)
275 # remove old temporary files
276 rm -f $so.copy $so.dbg
277 # keep original file
278 cp $so $so.copy
279 objcopy --only-keep-debug $so $so.dbg
280 objcopy --strip-debug $so
281 objcopy --add-gnu-debuglink=$so.dbg $so
282 cd $BUILD_PATH
283 done
285 # create stripped package
287 $BUILD_PATH/workdir/UnpackedTarball/epm/epm -f deb -g $TARGET_NAME $i --output-dir DEBS -v
289 # create spec file for the debug info package
291 cat $i | awk '
292 /^%product/ { print gensub("%product", "%product Debug info package of", "", $0);next }
293 /^%description/ { print gensub("%description", "%description Debug info package of", "", $0);next }
294 /^f .*libpython.*[.]so.*-gdb[.]py.*$/ { next }
295 /^f .*[.](so|bin)([.].*)?$/ { print $1,$2,$3,$4,$5".dbg",$6".dbg"; next }
296 /^[cf] / { next }
297 {print}
298 ' > ${i}-debuginfo
300 # create debug info package
301 $BUILD_PATH/workdir/UnpackedTarball/epm/epm -f deb -g ${TARGET_NAME}-debuginfo $i-debuginfo --output-dir DEBS -v
303 # restore original non stripped library files
305 for j in $(cat $i | awk '/^f .*libpython.*[.]so.*-gdb[.]py.*$/{next} /^f .*[.](so|bin)([.].*)?$/{print$6}')
307 cd $(dirname $j)
308 so=$(basename $j)
309 rm $so.dbg
310 # restore original file
311 mv -f $so.copy $so
312 cd $BUILD_PATH
313 done
315 done
317 echo Update DEB download tar.gz
319 debdir=$(ls -d $BUILD_PATH/workdir/installation/CollaboraOffice/deb/install/*_deb)
320 mv $BUILD_PATH/DEBS/*.deb $debdir/DEBS/
321 cd $debdir/..
322 TARGET_DEB=$(ls *_download/*.tar.gz)
323 TARGET_DEBUG=$(echo $TARGET_DEB | sed 's/.tar.gz$/-debug.tar.gz/')
324 SOURCE_DEB=$(find *_deb -type f | grep -v debug)
325 SOURCE_DEBUG=$(find *_deb -type f | grep -E '(debug|readme|README)')
326 tar c $SOURCE_DEB | gzip >$TARGET_DEB
327 tar c $SOURCE_DEBUG | gzip >$TARGET_DEBUG
329 cd $BUILD_PATH
330 rm -rf DEBS
333 # start deb re-build
334 test -z "$ONLY_RPM" -a "$(find workdir/installation/CollaboraOffice/deb/listfile -name '*.lst')" != "" && repack_deb >$BUILD_LOG 2>&1 || \
335 echo 'Skip DEB debug package generation (--only-rpm or missing EPM lst files).'
337 # start rpm re-build
338 test -z "$ONLY_DEB" -a "$(find workdir -name '*spec.log')" != "" && repack_rpm >>$BUILD_LOG 2>&1 || \
339 echo 'Skip RPM debug package generation (--only-deb or missing RPM spec files).'