Bump version to 24.04.3.4
[LibreOffice.git] / bin / pack-debug
blob70e3f80c7ed4de2547f7fbc5e78522f2a86cc3b8
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 type -P pigz &>/dev/null; then
17 GZIP=pigz
18 else
19 GZIP=gzip
22 if [ $# -gt 0 ]
23 then
24 for i in "$@"
26 case $i in
27 --only-rpm) ONLY_RPM=1;;
28 --only-deb) ONLY_DEB=1;;
29 *) echo "Usage: pack-debug [--only-rpm | --only-deb]" && exit 1;;
30 esac
31 done
34 # set install dirname and product version
35 if [ ! -f config.log ]; then
36 echo "config.log not found. Run this script from build root."
37 exit 1;
40 # create pack-debug.log file
41 echo create debug packages >$BUILD_LOG
43 eval $(grep ^INSTALLDIRNAME config.log)
45 # set package base name, eg. collaboraoffice
46 DEBUGSRC_PACKAGENAME=$INSTALLDIRNAME
48 #################################
49 # Function for re-build RPM files
50 #################################
51 function repack_rpm {
53 # set environment based on config.log
54 # for find-requires-x11.sh used by rpm __find_requires
55 eval $(grep ^PLATFORMID config.log)
56 export PLATFORMID
57 eval $(grep ^build_cpu config.log)
58 export build_cpu
60 ####################################
61 echo create RPM debug source package
62 ####################################
64 DEBUGSRC="$(find workdir -name ${DEBUGSRC_PACKAGENAME}.spec.log)"
66 # create spec file, based on the spec file of the brand package
68 cat $DEBUGSRC | awk '
69 /^Name:/ { print "Summary: Debug source for package "$2; print $0"-debugsource";next }
70 /^Group:/ { print $1" Development/Debug";next }
71 /^Brand module/ { print gensub("Brand module", "Source files", "");next }
72 /^%attr/ || /^Summary:/ { next }
73 {print}
74 END {
75 print "%defattr(-,root,root)"
77 ' > ${DEBUGSRC}-debugsource
78 buildroot=$(cat $DEBUGSRC-debugsource | awk '/^BuildRoot/{print$2}')
79 topdir=$(dirname $(dirname $buildroot))
80 mkdir -p $buildroot $topdir/RPMS/BUILD $topdir/RPMS/RPMS
81 rm -rf $buildroot
83 # create source file list
85 find $BUILD_PATH -name '*[.][hc]xx' -o -name '*[.][hc]' | grep -Ev '/(instdir|qa|DEBS)/' |
87 # list all directories for complete rpm remove
89 awk -v home=$BUILD_PATH '
91 split($0, a, home "/")
92 n=split(a[2], b, "/")
93 c=home
94 for(i=1;i<n;i++) {
95 c=c"/"b[i]
96 if(mem[c]!=1) print "%dir "c
97 mem[c]=1
99 print $0
100 }' >> ${DEBUGSRC}-debugsource
102 # start rpmbuild for debug source package
104 ln -s / $buildroot
106 # debug build source package
108 rpmbuild -bb --define "_unpackaged_files_terminate_build 0" --define "_binary_payload w1T.xzdio" ${DEBUGSRC}-debugsource --target $build_cpu --buildroot=$buildroot
111 echo Update RPM download tar.gz
112 rpmdir=$(echo $topdir | sed 's/_inprogress$//')
113 mv $topdir/RPMS/RPMS/*/*.rpm $rpmdir/RPMS/
114 cd $rpmdir/..
115 TARGET_RPM=$(ls *_download/*.tar.gz)
116 TARGET_DEBUG=$(echo $TARGET_RPM | sed 's/.tar.gz$/-debug.tar.gz/')
117 SOURCE_RPM=$(find *_rpm -type f | grep -v debug)
118 SOURCE_DEBUG=$(find *_rpm -type f | grep -E '(debug|readme|README)')
119 tar c $SOURCE_RPM | $GZIP >$TARGET_RPM
120 tar c $SOURCE_DEBUG | $GZIP >$TARGET_DEBUG
121 cd $BUILD_PATH
122 rm -rf $topdir
125 #################################
126 # Function for re-build DEB files
127 #################################
128 function repack_deb {
130 ####################################
131 echo create DEB debug source package
132 ####################################
134 DEBUGSRC=$BUILD_PATH/workdir/installation/CollaboraOffice/deb/listfile/en-US/epm_gid_Module_Root_Brand.lst
136 echo Base spec file: $DEBUGSRC
138 # create spec file, based on the spec file of the brand package
140 cat $DEBUGSRC | awk '
141 /^%product/ { print gensub("Brand module", "Debug source package", "", $0) ;next }
142 /^%description/ { print gensub("Brand module", "Debug source package", "", $0) ;next }
143 /^[cdf] / { next }
144 {print}
145 ' > ${DEBUGSRC}-debugsource
147 # create source file list
149 find $BUILD_PATH -name '*[.][hc]xx' -o -name '*[.][hc]' | grep -Ev '/(instdir|qa|DEBS)/' |
151 # list all directories
153 awk -v home=$BUILD_PATH '
155 split($0, a, home "/")
156 n=split(a[2], b, "/")
157 c=home
158 for(i=1;i<n;i++) {
159 c=c"/"b[i]
160 if(mem[c]!=1) print "d 755 root root "c" -"
161 mem[c]=1
163 print "f 644 root root "$0" "$0
164 }' >> ${DEBUGSRC}-debugsource
166 echo Spec file of debug source package: ${DEBUGSRC}-debugsource
168 # debug build source package
170 $BUILD_PATH/workdir/UnpackedTarball/epm/epm -f deb -g ${INSTALLDIRNAME}-debugsource ${DEBUGSRC}-debugsource --output-dir DEBS -v
172 echo Update DEB download tar.gz
174 debdir=$(ls -d $BUILD_PATH/workdir/installation/CollaboraOffice/deb/install/*_deb)
175 mv $BUILD_PATH/DEBS/*.deb $debdir/DEBS/
176 cd $debdir/..
177 TARGET_DEB=$(ls *_download/*.tar.gz)
178 TARGET_DEBUG=$(echo $TARGET_DEB | sed 's/.tar.gz$/-debug.tar.gz/')
179 SOURCE_DEB=$(find *_deb -type f | grep -v debug)
180 SOURCE_DEBUG=$(find *_deb -type f | grep -E '(debug|readme|README)')
181 tar c $SOURCE_DEB | $GZIP >$TARGET_DEB
182 tar c $SOURCE_DEBUG | $GZIP >$TARGET_DEBUG
184 cd $BUILD_PATH
185 rm -rf DEBS
188 # start deb re-build
189 test -z "$ONLY_RPM" -a "$(find workdir/installation/CollaboraOffice/deb/listfile -name '*.lst')" != "" && repack_deb >$BUILD_LOG 2>&1 || \
190 echo 'Skip DEB debug package generation (--only-rpm or missing EPM lst files).'
192 # start rpm re-build
193 test -z "$ONLY_DEB" -a "$(find workdir -name '*spec.log')" != "" && repack_rpm >>$BUILD_LOG 2>&1 || \
194 echo 'Skip RPM debug package generation (--only-deb or missing RPM spec files).'