Commit abc94626f5d4680ee834bd8acab3e318570bcf92
Committed by
GitHub
Exists in
develop
Merge pull request #60 from andrebreves/master
Fix bundle script for macOS Sonoma
Showing
1 changed file
with
30 additions
and
16 deletions
Show diff stats
macos/bundle
... | ... | @@ -5,7 +5,7 @@ set -Eeuo pipefail |
5 | 5 | check_dependencies() { |
6 | 6 | local unavailable=() |
7 | 7 | for dependency in "${@:-$(</dev/stdin)}"; do |
8 | - if [[ ! -x "$(command -v ${dependency})" ]]; then unavailable+=("${dependency}"); fi | |
8 | + if [[ ! -x "$(command -v "${dependency}")" ]]; then unavailable+=("${dependency}"); fi | |
9 | 9 | done |
10 | 10 | if [[ ${#unavailable[@]} == 1 ]]; then |
11 | 11 | echo "Dependency '${unavailable[*]}' not found." |
... | ... | @@ -18,7 +18,7 @@ check_dependencies() { |
18 | 18 | |
19 | 19 | find_lib() { |
20 | 20 | # https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/UsingDynamicLibraries.html |
21 | - local libs_path="${HOME}/lib /usr/local/lib /usr/lib" | |
21 | + local libs_path="${HOME}/lib $(brew --prefix)/lib /usr/lib" | |
22 | 22 | for lib in "${@:-$(</dev/stdin)}"; do |
23 | 23 | local found="" |
24 | 24 | if [[ -f "${lib}" ]]; then |
... | ... | @@ -73,17 +73,25 @@ bundle_cp() { |
73 | 73 | cp "${source}" "${target}" |
74 | 74 | chmod u+w "${target}" |
75 | 75 | |
76 | - if [[ "${id}" != "" ]]; then install_name_tool -id "${id}" "${target}"; fi | |
77 | - install_name_tool -add_rpath "@executable_path/../Frameworks" "${target}" | |
76 | + if [[ "${id}" != "" ]]; then install_name_tool -id "${id}" "${target}" 2> /dev/null; fi | |
77 | + install_name_tool -add_rpath "@executable_path/../Frameworks" "${target}" 2> /dev/null | |
78 | 78 | |
79 | 79 | for old_install_name in $(otool -L "${target}" | grep '^\t' | cut -c 2- | sed -n "s/\(.*\) (.*)/\1/p"); do |
80 | 80 | if [[ "${old_install_name}" == "${id}" ]]; then continue; fi |
81 | - local lib="$(find_lib "${old_install_name}")" | |
81 | + if [[ "${old_install_name}" =~ ${system_libs} ]]; then continue; fi | |
82 | + local lib | |
83 | + if [[ "${old_install_name}" =~ ^@loader_path.* ]]; then | |
84 | + lib="$(find_lib "$(dirname "${source}")/${old_install_name//@loader_path/}")" | |
85 | + else | |
86 | + lib="$(find_lib "${old_install_name}")" | |
87 | + fi | |
82 | 88 | local new_install_name="$(bundle_cp "${lib}")" |
83 | 89 | if [[ "${new_install_name}" != "" ]]; then |
84 | - install_name_tool -change "${old_install_name}" "${new_install_name}" "${target}" | |
90 | + install_name_tool -change "${old_install_name}" "${new_install_name}" "${target}" 2> /dev/null | |
85 | 91 | fi |
86 | 92 | done |
93 | + # https://stackoverflow.com/a/71753248/6910609 | |
94 | + codesign --force -s - "${target}" 2> /dev/null | |
87 | 95 | echo >&2 "${target}" |
88 | 96 | done |
89 | 97 | } |
... | ... | @@ -113,9 +121,9 @@ bundle_cache() { |
113 | 121 | check_dependencies otool grep cut sed greadlink qlmanage sips iconutil |
114 | 122 | |
115 | 123 | # Creates temporary directory |
116 | -echo "Creating temporary directory" | |
124 | +echo "* Creating temporary directory" | |
117 | 125 | tmp="$(mktemp -d)" |
118 | -trap 'echo "Removing temporary directory \"${tmp}\""; rm -rf "${tmp}"' EXIT | |
126 | +trap 'echo "* Removing temporary directory \"${tmp}\""; rm -rf "${tmp}"' EXIT | |
119 | 127 | |
120 | 128 | bundle="pw3270.app" |
121 | 129 | bundle_path="${bundle}/Contents" |
... | ... | @@ -129,17 +137,15 @@ mkdir -p "${bundle_path}" |
129 | 137 | cp "Info.plist" "${bundle_path}" |
130 | 138 | |
131 | 139 | mkdir -p "${res_path}" |
132 | -cp -r "../ui" "${res_path}" | |
140 | +cp -r "../ui/macos.ui.xml" "${res_path}/pw3270.ui.xml" | |
133 | 141 | cp -r "$(brew --prefix)/share/pw3270/remap" "${res_path}" |
134 | 142 | cp "$(brew --prefix)/share/pw3270/colors.conf" "${res_path}" |
135 | 143 | |
136 | 144 | # Bundle GLib schemas |
137 | -echo "Bundling GLib schemas" | |
145 | +echo "* Bundling GLib schemas" | |
138 | 146 | mkdir -p "${tmp}/schemas" |
139 | - | |
140 | -cp "$(brew --prefix)$(pkg-config gtk+-3.0 --variable=prefix)/share/glib-2.0/schemas/pw3270*.gschema.xml" "${tmp}/schemas" | |
147 | +cp "../schemas/"*".gschema.xml" "${tmp}/schemas" | |
141 | 148 | cp "$(pkg-config gtk+-3.0 --variable=prefix)/share/glib-2.0/schemas/org.gtk.Settings."*".gschema.xml" "${tmp}/schemas" |
142 | - | |
143 | 149 | glib-compile-schemas --targetdir="${res_path}" "${tmp}/schemas" |
144 | 150 | |
145 | 151 | # Create the GTK settings file |
... | ... | @@ -152,7 +158,7 @@ gtk-print-preview-command="open -b com.apple.Preview %f" |
152 | 158 | EOF |
153 | 159 | |
154 | 160 | # Make icon bundle |
155 | -echo "Creating app icon bundle" | |
161 | +echo "* Creating app icon bundle" | |
156 | 162 | iconset="${tmp}/pw3270.iconset" |
157 | 163 | rm -fr "${iconset}" |
158 | 164 | mkdir -p "${iconset}" |
... | ... | @@ -168,34 +174,41 @@ iconutil -c icns -o "${res_path}/pw3270.icns" "${iconset}" |
168 | 174 | |
169 | 175 | |
170 | 176 | # Copy icons |
177 | +echo "* Copying icons" | |
171 | 178 | mkdir -p "${res_path}/icons" |
172 | 179 | cp -r "$(brew --prefix adwaita-icon-theme)/share/icons/" "${res_path}/icons" |
173 | 180 | cp -r "$(brew --prefix hicolor-icon-theme)/share/icons/" "${res_path}/icons" |
174 | 181 | mogrify -format png -path "${res_path}" -background transparent "../branding/*.svg" |
175 | 182 | |
176 | 183 | # Copy themes |
184 | +echo "* Copying themes" | |
177 | 185 | mkdir -p "${res_path}/themes" |
178 | 186 | cp -a "$(brew --prefix gtk+3)/share/themes/Mac" "${res_path}/themes" |
179 | 187 | |
180 | 188 | # Copy mime database |
189 | +echo "* Copying mime database" | |
181 | 190 | mkdir -p "${res_path}/mime" |
182 | 191 | cp "$(pkg-config shared-mime-info --variable=prefix)/share/mime/mime.cache" "${res_path}/mime" |
183 | 192 | |
184 | 193 | # Copy executables |
194 | +echo "* Copying executables" | |
185 | 195 | mkdir -p "${exe_path}" |
186 | 196 | bundle_cp "../.bin/Release/pw3270" |
187 | 197 | cp "launcher.sh" "${exe_path}" |
188 | 198 | |
189 | 199 | # Bundle GdkPixbuf Image Loader Modules |
200 | +echo "* Bundling GdkPixbuf Image Loader Modules" | |
190 | 201 | gdk-pixbuf-query-loaders | bundle_cache > "${res_path}/gdk-loaders.cache" |
191 | 202 | |
192 | 203 | # Bundle GTK+ Input Method Modules |
204 | +echo "* Bundling GTK+ Input Method Modules" | |
193 | 205 | gtk_prefix="$(pkg-config gtk+-3.0 --variable prefix)" |
194 | 206 | gtk-query-immodules-3.0 | bundle_cache \ |
195 | 207 | | sed "s|${gtk_prefix}/share/locale|@executable_path/../Resources/locale|g" \ |
196 | 208 | > "${res_path}/gtk.immodules" |
197 | 209 | |
198 | 210 | # Bundle print backends |
211 | +echo "* Bundling print backends" | |
199 | 212 | mkdir -p "${lib_path}/printbackends" |
200 | 213 | for backend in "$(pkg-config gtk+-3.0 --variable=prefix)/lib/gtk-3.0/$(pkg-config gtk+-3.0 --variable=gtk_binary_version)/printbackends/"*.so; do |
201 | 214 | bundle_cp "${backend}" |
... | ... | @@ -206,7 +219,8 @@ done |
206 | 219 | # TODO: gerar o Info.plist com a versão do macOS $(sw_vers -productVersion) |
207 | 220 | |
208 | 221 | # Bundle locale |
222 | +echo "* Bundling locale" | |
209 | 223 | mkdir -p "${res_path}/locale" |
210 | 224 | cp -r "../.bin/locale/" "${res_path}/locale" |
211 | -cp "$(brew --prefix)/share/locale/pt_BR/LC_MESSAGES/lib3270.mo" "${res_path}/locale/pt_BR/LC_MESSAGES" | |
212 | -cp "$(brew --prefix)/share/locale/pt_BR/LC_MESSAGES/libv3270.mo" "${res_path}/locale/pt_BR/LC_MESSAGES" | |
225 | +cp "$(brew --prefix)/share/locale/pt_BR/LC_MESSAGES/lib3270"*".mo" "${res_path}/locale/pt_BR/LC_MESSAGES" | |
226 | +cp "$(brew --prefix)/share/locale/pt_BR/LC_MESSAGES/libv3270"*".mo" "${res_path}/locale/pt_BR/LC_MESSAGES" | ... | ... |