[X2Go-Commits] [x2goclient] 55/217: deduplicate.sh: add new, more or less Proof of Concept, and Work in Progress file deduplication script.

git-admin at x2go.org git-admin at x2go.org
Sat Aug 27 19:24:35 CEST 2016


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

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

commit 692198113a825accf655881bab9e937bdfbddeae
Author: Mihai Moldovan <ionic at 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 102a856..fc542c5 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -132,6 +132,8 @@ x2goclient (4.0.5.2-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.
   * debian/control:
     - Maintainer change in package: X2Go Developers <x2go-dev at lists.x2go.org>.
     - Uploaders: add myself. Also, force a rebuild due to the changed
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


More information about the x2go-commits mailing list