sc: filter: rtf: use a separate document stream
[LibreOffice.git] / bin / merge-app-bundles
blob2a2200f1c44d49f135d3390b458fa3d6ac10a479
1 #!/usr/bin/env 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 # Exit on errors
10 set -e
12 # Use of unset variable is an error
13 set -u
15 # If any part of a pipeline of commands fails, the whole pipeline fails
16 set -o pipefail
18 if [ `uname` != Darwin ]; then
19 echo This is for macOS only >&2
20 exit 1
23 if [ $# != 3 ]; then
24 echo Usage: $0 app-bundle-1 app-bundle-2 output-app-bundle
25 exit 1
28 if [ -d "$3" ]; then
29 echo The directory $3 exists already
30 exit 1
33 if [ -f "$3" ]; then
34 echo $3 exists and is a file
35 exit 1
38 if [ ! -d "$1" ]; then
39 echo No such directory: $1
40 exit 1
43 if [ ! -d "$2" ]; then
44 echo No such directory: $2
45 exit 1
48 ONE=$(cd "$1" && /bin/pwd)
49 TWO=$(cd "$2" && /bin/pwd)
50 mkdir "$3"
51 OUT=$(cd "$3" && /bin/pwd)
53 # Create all directories
55 cd "$ONE"
56 find . -type d -print
57 ) |
59 cd "$OUT"
60 while read dirname; do
61 mkdir -p "$dirname"
62 done
65 # Check which files in 1 exist in 2, and if they are executable, merge them into a fat copy. For
66 # other files, just use one copy, assuming they are equivalent in most cases.
68 cd "$ONE"
69 find . -type l -or -type f
70 ) |
72 cd "$TWO"
73 while read fname; do
74 if test -L "$fname"; then
75 ln -s $(readlink "$fname") "$OUT/$fname"
76 elif test -f "$fname"; then
77 case "$fname" in
78 *.so | \
79 *.dylib | \
80 *.dylib.* | \
81 */Frameworks/LibreOfficePython.framework/Versions/*/LibreOfficePython | \
82 */Frameworks/LibreOfficePython.framework/Versions/*/Resources/Python.app/Contents/MacOS/LibreOfficePython | \
83 */Library/Spotlight/OOoSpotlightImporter.mdimporter/Contents/MacOS/OOoSpotlightImporter)
84 lipo -create -output "$OUT/$fname" "$fname" "$ONE/$fname"
86 # Ignore differences in these files. Let's hope it's just the timestamps.
87 *.ot[tp] | \
88 *.bau | \
89 *.pyc | \
90 */_sysconfigdata_m_darwin_darwin.py | \
91 */Contents/Resources/firebird/security3.fdb | \
92 */Contents/Resources/autocorr/acor_*.dat | \
93 */Contents/Resources/resource/*/LC_MESSAGES/*.mo | \
94 */Contents/Resources/config/images_*.zip)
95 cp "$fname" "$OUT/$fname"
98 case $(file --brief "$fname") in
99 Mach-O\ 64-bit\ executable\ *)
100 lipo -create -output "$OUT/$fname" "$fname" "$ONE/$fname"
103 cmp -s "$fname" "$ONE/$fname" ||
104 echo "$fname differs and is not an executable!?" >&2
105 cp "$fname" "$OUT/$fname"
106 esac
107 esac
108 else
109 # We ignore some files that can't be built for macOS on arm64 for now
110 case "$fname" in
111 ./Contents/Frameworks/LibreOfficePython.framework/Versions/3.7/lib/python*/lib-dynload/_ctypes.cpython-*m.so)
114 echo "$fname does not exist in $TWO" >&2
116 esac
117 cp "$ONE/$fname" "$OUT/$fname"
119 done
122 # Look for files in 2 that don't exist in 1
124 cd "$TWO"
125 find . -type f -print
128 cd "$ONE"
129 while read fname; do
130 if test -f "$fname"; then
132 else
133 echo "$fname does not exist in $ONE" >&2
134 cp "$TWO/$fname" "$OUT/$fname"
136 done
139 # Local Variables:
140 # tab-width: 4
141 # indent-tabs-mode: nil
142 # fill-column: 100
143 # End: