This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient.
commit 727b1f4e9a1f965f7f7e194a3cc822d9c433ae24 Author: Mihai Moldovan <io...@ionic.de> Date: Thu Sep 24 04:18:25 2015 +0200 macbuild.sh: merge deduplicate.sh content in. Also enable the functionality "for real", not just as a dry-run. --- debian/changelog | 2 + macbuild.sh | 196 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 198 insertions(+) diff --git a/debian/changelog b/debian/changelog index 0e04ce6..50eccea 100644 --- a/debian/changelog +++ b/debian/changelog @@ -153,6 +153,8 @@ x2goclient (4.0.5.3-0x2go1) UNRELEASED; urgency=medium - deduplicate.sh: remove some noisy debug output. - macbuild.sh: replace tabs with two spaces. No functional changes. - deduplicate.sh: replace tabs with two spaces. No functional changes. + - macbuild.sh: merge deduplicate.sh content in. Also enable the + functionality "for real", not just as a dry-run. -- X2Go Release Manager <git-ad...@x2go.org> Mon, 19 Sep 2016 09:07:07 +0200 diff --git a/macbuild.sh b/macbuild.sh index 80999bd..3fe7447 100755 --- a/macbuild.sh +++ b/macbuild.sh @@ -97,6 +97,50 @@ repeat_str() { # INPUT COUNT return 0 } +typeset -a otool_fail_str +otool_fail_str=( "is not an object file" + "can't open file" + "Archive : " ) + +parse_otool_output() { +#set -x + typeset raw_output="${@}" + + typeset fail_str="" + for fail_str in "${otool_fail_str[@]}"; do + if echo "${raw_output}" | grep -q "${fail_str}"; then + return 1 + fi + done + + typeset tmp_regex='^[[:space:]]+(.*)[[:space:]]\(compatibility version .*, current version .*\)' + + + # In this special case, we do not want read to perform any word splitting. + typeset oldifs="${IFS}" + IFS='' + + # Used for skipping the first matching entry - which should typically be the ID line... + # That's a very naïve way to do this. Maybe there should be a bit more magic + # to catch this more reliably. + typeset -i first="1" + + typeset line="" + while read -r line; do + if [[ "${line}" =~ ${tmp_regex} ]]; then + if [ "${first}" -ne "1" ]; then + echo "${BASH_REMATCH[1]}" + else + first="0" + fi + fi + done <<< "${raw_output}" + + IFS="${oldifs}" +#set +x + return 0 +} + MATCH_HELP='(^((-h)|(--help))([ ]|$))|([ ]+((-h)|(--help))([ ]|$))' [ -n "${*}" ] && [[ "${*}" =~ ${MATCH_HELP} ]] && usage @@ -130,6 +174,11 @@ PULSEAUDIO_LIBRARIES=( "libpulse-simple.0.dylib" "pulse-6.0" "pulseaudio" ) +typeset -a special_files_regex +special_files_regex+=( "pulseaudio/libpulsecommon-[0-9]\.[0-9]\.dylib" ) + +typeset -r dependency_base_format='@executable_path/../Frameworks/' + : ${SDK:="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk"} : ${MACOSX_DEPLOYMENT_TARGET:="10.7"} : ${FORCE_STDLIB:="0"} @@ -334,6 +383,153 @@ if [ "${BUNDLE}" = "1" ]; then fi done + phase "Deduplicating PulseAudio libraries and dependencies" + typeset -r base_dir="$(lazy_canonical_path "${FRAMEWORKS_DIR}")" + + typeset -a all_files + typeset entry="" + while read -r -d '' entry; do + all_files+=( "${entry}" ) + done < <(find "${base_dir}" -type 'f' -print0) + + typeset -a top_files + for entry in "${all_files[@]}"; do + typeset relative_path="${entry##"${base_dir}/"}" + typeset tmp_regex='^[^/]+$' + if [[ "${relative_path}" =~ ${tmp_regex} ]]; then + echo "${relative_path} is top file, adding to array." + top_files+=( "${relative_path}" ) + fi + done + + typeset -a duplicates + for entry in "${all_files[@]}"; do + typeset relative_path="${entry##"${base_dir}/"}" + typeset file_name="$(basename "${entry}")" + typeset top_entry="" + for top_entry in "${top_files[@]}"; do + if [ "${top_entry}" != "${relative_path}" ]; then + if [ "${file_name}" = "${top_entry}" ]; then + echo "Adding duplicate: ${relative_path}" + duplicates+=( "${relative_path}" ) + fi + fi + done + done + + echo "duplicates array before:" + for entry in "${duplicates[@]}"; do + echo "${entry}" + done + + typeset -i i="0" + for i in "${!duplicates[@]}"; do + entry="${duplicates[${i}]}" + typeset special_file_regex="" + for special_file_regex in "${special_files_regex[@]}"; do + typeset tmp_regex='^'"${special_file_regex}"'$' + if [[ "${entry}" =~ ${tmp_regex} ]]; then + mv -v "${base_dir}/$(basename "${entry}")" "${base_dir}/$(dirname "${special_file_regex}")/" + duplicates[${i}]="$(basename "${entry}")" + echo "Renamed ${entry} in duplicates array to ${duplicates[${i}]}" + fi + done + done + + echo "duplicates array after:" + for entry in "${duplicates[@]}"; do + echo "${entry}" + done + + for entry in "${duplicates[@]}"; do + rm -v "${base_dir}/${entry}" + typeset -i i="0" + for i in "${!all_files[@]}"; do + typeset all_entry="${all_files[${i}]}" + typeset relative_path="${all_entry##"${base_dir}/"}" + if [ "${relative_path}" = "${entry}" ]; then + unset all_files[${i}] + fi + done + done + + echo "New value for all_files:" + for entry in "${all_files[@]}"; do + echo "${entry}" + done + + echo "Duplicates-to-real map:" + # Build complementary array to duplicates. + typeset -a to_files + for entry in "${duplicates[@]}"; do + typeset filename="$(basename "${entry}")" + + typeset all_entry="" + for all_entry in "${all_files[@]}"; do + typeset all_entry_filename="$(basename "${all_entry}")" + + if [ -n "${filename}" ] && [ -n "${all_entry_filename}" ]; then + if [ "${filename}" = "${all_entry_filename}" ]; then + typeset dependency_format="$(lazy_canonical_path "${dependency_base_format}/${all_entry##${base_dir}}")" + to_files+=( "${dependency_format}" ) + + echo "${entry} => ${dependency_format}" + + # There should be only one entry matching, so we can save a bit of time and break out of the loop. + # Even more importantly, we only want one entry for each duplicates entry anyway... + break + fi + else + echo "ERROR: empty file name while matching duplicates with non-duplicates." >&2 + echo "ERROR: duplicate entry: \"${entry}\"" >&2 + echo "ERROR: real entry: \"${all_entry}\"" >&2 + exit 1 + fi + done + done + + # Try to fixup files broken by duplicates removal. + for all_entry in "${all_files[@]}"; do + typeset otool_out="$(otool -L "${all_entry}")" + + # Don't merge the declaration and initialization with the real value assignment. + # We need the return value of parse_otool_output(), but running + # typeset foo="$(bar)" will give us the return value of typeset, not bar(). + typeset dependencies="" + dependencies="$(parse_otool_output "${otool_out}")" + + if [ "${?}" -eq "0" ]; then + typeset line="" + while read -r line; do + #echo "dependency of ${all_entry}: ${line}" + + typeset duplicate_entry="" + typeset -i i="0" + for i in "${!duplicates[@]}"; do + typeset duplicate_entry="${duplicates[${i}]}" + #echo "checking for duplicate ${duplicate_entry}" + typeset duplicate_format="$(lazy_canonical_path "${dependency_base_format}/${duplicate_entry}")" + + if [ -n "${line}" ] && [ -n "${duplicate_format}" ]; then + if [ "${line}" = "${duplicate_format}" ]; then + install_name_tool -change "${line}" "${to_files[${i}]}" "${all_entry}" + fi + else + echo "ERROR: empty file name while replacing duplicate dependencies." >&2 + echo "ERROR: for file ${all_entry}" >&2 + echo "ERROR: at dependency ${line}" >&2 + echo "ERROR: duplicate entry: \"${duplicate_entry}\"" >&2 + echo "ERROR: dependency: \"${line}\"" >&2 + exit 1 + fi + done + done <<< "${dependencies}" + else + echo "WARNING: otool returned error for file: ${all_entry}" >&2 + echo "WARNING: skipping." >&2 + fi + done + phase "Bundling up using macdeployqt" macdeployqt "${APPBUNDLE}" -verbose=2 -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git _______________________________________________ x2go-commits mailing list x2go-commits@lists.x2go.org http://lists.x2go.org/listinfo/x2go-commits