Fix broken Makefile.am
[lxde/lxde-common.git] / icon-theme / prevent-dup.py
... / ...
CommitLineData
1#!/usr/bin/env python
2import os, sys
3os.system( 'fdupes -r nuoveXT2 > dups.txt' )
4excludes=['gnome', 'redhat', 'xfce', 'mozilla', 'thunderbird', 'evolution', 'rythmbox', 'stock', 'gtk']
5
6def is_not_generic( file ):
7 for exclude in excludes:
8 if file.find( exclude ) != -1:
9 return True
10
11 if os.path.basename(file).startswith('k'): # don't use kde icon
12 return True
13
14 return False
15
16def get_common_dir( path1, path2 ):
17
18 while path1 != '' and path2 != '':
19 path1 = os.path.dirname(path1)
20 path2 = os.path.dirname(path2)
21 if path1 == path2:
22 return path1+'/'
23
24 return ''
25
26def get_relative_path( file, relative_to ):
27 prefix = get_common_dir( file, relative_to )
28 prefix_len = len(prefix)
29 rest = relative_to[ prefix_len : ]
30 n = rest.count( '/' )
31 prefix=''
32 while n > 0:
33 prefix += '../'
34 n = n - 1
35 return prefix + relative_to[ prefix_len : ]
36
37
38files=[]
39f = open( 'dups.txt', 'r' )
40generic=''
41
42print '''EXTRA_DIST=AUTHORS COPYING
43
44dist-hook:
45\tcp -raf nuoveXT2 $(distdir)/nuoveXT2
46\trm -rf `find $(distdir)/nuoveXT2 -name '*.svn'`
47
48uninstall-hook:
49\trm -rf $(datadir)/icons/nuoveXT2
50
51install-data-hook:
52\tcp -raf --no-preserve=ownership nuoveXT2 $(datadir)/icons'''
53
54for line in f:
55 file = line.rstrip()
56 if file != '':
57 if generic != '' or is_not_generic( file ):
58 files.append( file )
59 else:
60 generic = file
61 else:
62 if generic == '':
63 generic = files[0]
64 del files[0]
65 for file in files:
66 os.system( 'rm -f %s' % file )
67 print '\t$(LN_S) %s $(datadir)/icons/%s' % (get_relative_path(file, generic), file)
68 files=[]
69 generic=''
70
71f.close()