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

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

commit eb0516725e539956e8ace640c772c3ff8b8522cb
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 0fafe8f..5221fd0 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -103,6 +103,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.
 
  -- X2Go Release Manager <git-ad...@x2go.org>  Mon, 19 Sep 2016 09:07:07 +0200
 
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