Commit 9ca97aa1818560f94ff791111c50dd544985483a

Authored by André Breves
Committed by Perry Werneck
1 parent fce56922
Exists in develop

Update to macOS Sonoma

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