This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch bugfix/osx
in repository x2goclient.

commit b7704e9b8e964fa5fdf9f7d9d8af78a58d56e216
Author: Mihai Moldovan <io...@ionic.de>
Date:   Wed Aug 26 20:57:41 2015 +0200

    deduplicate.sh: add new, more or less Proof of Concept, and Work in 
Progress file deduplication script.
---
 debian/changelog |    2 ++
 deduplicate.sh   |   79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 81 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index bdcfe77..adfc747 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -129,6 +129,8 @@ x2goclient (4.0.5.3-0x2go1) UNRELEASED; urgency=medium
       just the library file name. Helps debugging.
     - macbuild.sh: also install libraries into staging area with intermediate
       library path. Putting everything into a single place is a stupid idea.
+    - deduplicate.sh: add new, more or less Proof of Concept, and Work in
+      Progress file deduplication script.
 
   [ Bernard Cafarelli ]
   * New upstream version (4.0.5.3):
diff --git a/deduplicate.sh b/deduplicate.sh
new file mode 100755
index 0000000..7c4de14
--- /dev/null
+++ b/deduplicate.sh
@@ -0,0 +1,79 @@
+#!/bin/bash
+
+typeset base_dir=""
+base_dir="${1:?"No base dir given."}"
+
+typeset -a special_files_regex
+special_files_regex+=( "pulseaudio/libpulsecommon-[0-9]\.[0-9]\.dylib" )
+
+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 = 0; i < ${#duplicates[@]}; ++i)); 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
+done
+
+echo "duplicates array after:"
+for entry in ${duplicates[@]}; do
+       echo "${entry}"
+done
+
+for entry in ${duplicates[@]}; do
+       echo "rm -v ${base_dir}/${entry}"
+       typeset -i i="0"
+       for ((i = 0; i < ${#all_files[@]}; ++i)); do
+               typeset all_entry="${all_files[${i}]}"
+               typeset relative_path="${all_entry##"${base_dir}/"}"
+               if [ "${relative_path}" = "${entry}" ]; then
+                       all_files[${i}]=""
+               fi
+       done
+done
+
+echo "New value for all_files:"
+for entry in ${all_files[@]}; do
+       echo "${entry}"
+done

--
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

Reply via email to