This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit 0e5b5c0b7be2ad562a229de8b7dd39b52e30e7c2 Author: Mihai Moldovan <ionic@ionic.de> Date: Thu Sep 24 03:50:54 2015 +0200 deduplicate.sh: replace tabs with two spaces. No functional changes. --- debian/changelog | 1 + deduplicate.sh | 290 +++++++++++++++++++++++++++--------------------------- 2 files changed, 146 insertions(+), 145 deletions(-) diff --git a/debian/changelog b/debian/changelog index b77391f..52d8c22 100644 --- a/debian/changelog +++ b/debian/changelog @@ -171,6 +171,7 @@ x2goclient (4.0.5.2-0x2go1) UNRELEASED; urgency=medium - deduplicate.sh: add WARNING to status message. - 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. [ Mike DePaulo ] * New upstream release (4.0.5.2): diff --git a/deduplicate.sh b/deduplicate.sh index c298194..636ea5c 100755 --- a/deduplicate.sh +++ b/deduplicate.sh @@ -10,200 +10,200 @@ typeset -r dependency_base_format='@executable_path/../Frameworks/' typeset -a otool_fail_str otool_fail_str=( "is not an object file" - "can't open file" - "Archive : " ) + "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}" + 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 + return 0 } lazy_canonical_path() { - typeset path="${1}" + typeset path="${1}" - typeset old_path="" - while [ "${old_path}" != "${path}" ]; do - old_path="${path}" - path="${path//\/\///}" - done + typeset old_path="" + while [ "${old_path}" != "${path}" ]; do + old_path="${path}" + path="${path//\/\///}" + done - printf "${old_path}" + printf "${old_path}" } typeset -a all_files typeset entry="" while read -r -d '' entry; do - all_files+=( "${entry}" ) + 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 + 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 + 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}" + 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 - echo "mv \"${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 + 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 + echo "mv \"${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}" + echo "${entry}" done for entry in "${duplicates[@]}"; do - echo "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 + echo "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}" + 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 + 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 - echo "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 + 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 + echo "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 -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git