Bug#531004: oxygen: Duplicate files could be linked
tags 531004 + patch
thanks
Hi,
the attached patch is a first attempt to symlink duplicate icons during the
oxygen-icons build.
Eckhart
Index: debian/control
===================================================================
--- debian/control (Revision 17552)
+++ debian/control (Arbeitskopie)
@@ -4,7 +4,7 @@
Maintainer: Debian Qt/KDE Maintainers <debian-qt-kde@lists.debian.org>
Uploaders: Sune Vuorela <debian@pusling.com>, Fathi Boudra <fabo@debian.org>,
Armin Berres <armin+debian@space-based.de>, Modestas Vainius <modax@debian.org>
-Build-Depends: debhelper (>= 7), cdbs, cmake
+Build-Depends: debhelper (>= 7), cdbs, cmake, fdupes
Standards-Version: 3.8.4
Homepage: http://www.kde.org/
Vcs-Browser: http://svn.debian.org/wsvn/pkg-kde/trunk/packages/oxygen-icons/#_trunk_packages_oxygen-icons_
Index: debian/rules
===================================================================
--- debian/rules (Revision 17552)
+++ debian/rules (Arbeitskopie)
@@ -5,3 +5,4 @@
binary-predeb/oxygen-icon-theme::
find $(CURDIR)/debian/oxygen-icon-theme -type d -print0 |xargs -0 rmdir --ignore-fail-on-non-empty
+ sh $(CURDIR)/debian/symlink_duplicates.sh $(CURDIR)/debian/oxygen-icon-theme/usr/share/icons
Index: debian/symlink_duplicates.sh
===================================================================
--- debian/symlink_duplicates.sh (Revision 0)
+++ debian/symlink_duplicates.sh (Revision 0)
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+# Identifies duplicate files and symlinks them
+# Argument: the root directory for the search
+
+relativePath() {
+ local targetDir=`dirname $1`
+ local targetBase=`basename $1`
+ local relativeToDir=`dirname $2`
+
+ # Remove common path prefix
+ while [ -n "$targetDir" ] && [ `echo $targetDir | cut -d / -f 1` = `echo $relativeToDir | cut -d / -f 1` ]; do
+ targetDir=`echo $targetDir | cut -s -d / -f 2-`
+ relativeToDir=`echo $relativeToDir | cut -s -d / -f 2-`
+ done
+
+ local result=""
+
+ # Climb up relativeToDir
+ while [ -n "$relativeToDir" ]; do
+ relativeToDir=`echo $relativeToDir | cut -s -d / -f 2-`
+ result="$result../"
+ done
+
+ # Climb down targetDir
+ if [ -n "$targetDir" ]; then
+ result="$result$targetDir/"
+ fi
+
+ echo "$result$targetBase"
+}
+
+
+echo "Symlinking duplicate files, this may take some time..."
+
+target=""
+fdupes -r $1 | while read line; do
+ if [ -z "$line" ]; then
+ # New group of duplicate files begins
+ target=""
+ elif [ -z "$target" ]; then
+ # Setting a new target for symlinking
+ target=$line
+ else
+ # Symlink duplicate
+ ln -sf "`relativePath $target $line`" "$line"
+ fi
+done
+
+echo "...finished"
Reply to: