setup fixes, but still nonfree ponyfiles are installed...

Signed-off-by: Mattias Andrée <maandree@operamail.com>
This commit is contained in:
Mattias Andrée 2012-12-22 00:59:12 +01:00
parent df5cb29bc5
commit aca1905f68

View file

@ -536,11 +536,14 @@ class Setup():
if ponymap is not None: if ponymap is not None:
ponymap.close() ponymap.close()
for sharedir in [sharedir[0] for sharedir in sharedirs]: for sharedir in [sharedir[0] for sharedir in sharedirs]: # TODO make this an opt-out option
if os.path.isdir(sharedir): if os.path.isdir(sharedir):
for sharefile in os.listdir(sharedir): for sharefile in os.listdir(sharedir):
if sharefile.endswith('.pony') and (sharefile != '.pony'): if sharefile.endswith('.pony') and (sharefile != '.pony'):
sharefile = sharedir + '/' + sharefile sharefile = sharedir + '/' + sharefile
if self.free and not Setup.validateFreedom(sharefile):
print('Skipping metadata correction for %s, did not pass validation process made by setup settings' % sharefile)
continue
for toolcommand in ('--dimensions', '--metadata'): for toolcommand in ('--dimensions', '--metadata'):
print('%s, %s, %s' % ('./ponysay-tool.py', toolcommand, sharefile)) print('%s, %s, %s' % ('./ponysay-tool.py', toolcommand, sharefile))
Popen(['./ponysay-tool.py', toolcommand, sharefile], stdin=PIPE, stdout=PIPE, stderr=PIPE).communicate() Popen(['./ponysay-tool.py', toolcommand, sharefile], stdin=PIPE, stdout=PIPE, stderr=PIPE).communicate()
@ -623,12 +626,12 @@ class Setup():
self.cp(False, src, dests) self.cp(False, src, dests)
for dir in sharedirs: for dir in sharedirs:
if conf[dir[0]] is not None: if conf[dir[0]] is not None:
self.cp(True, dir[0], [conf[dir[0]]], self.validateFreedom if self.free else None) self.cp(True, dir[0], [conf[dir[0]]], Setup.validateFreedom if self.free else None)
for file in sharefiles: for file in sharefiles:
if conf[file[0]] is not None: if conf[file[0]] is not None:
self.cp(False, 'share/' + file[1], [conf[file[0]]], self.validateFreedom if self.free else None) self.cp(False, 'share/' + file[1], [conf[file[0]]], Setup.validateFreedom if self.free else None)
for file in miscfiles: for file in miscfiles:
self.cp(False, file[0], [conf[file[0]]], self.validateFreedom if self.free else None) self.cp(False, file[0], [conf[file[0]]], Setup.validateFreedom if self.free else None)
print() print()
@ -784,13 +787,15 @@ class Setup():
''' '''
Check whethera file is fully free Check whether a file is fully free
''' '''
def validateFreedom(self, filename): @staticmethod
if filename.endswith('.pony') and not (filename == '.pony'): def validateFreedom(filename):
if not os.path.isdir(filename):
if filename.endswith('.pony') and (filename != '.pony') and not filename.endswith('/.pony'):
with open(filename, 'rb') as file: with open(filename, 'rb') as file:
data = file.read.decode('utf8', 'replace') data = file.read().decode('utf8', 'replace')
if data.startswith('$$$\n') and ('\n$$$\n' in data): if data.startswith('$$$\n') and ('\n$$$\n' in data) and not data.startswith('$$$\n$$$\n'):
data = data[4 : data.find('\n$$$\n')].split('\n') data = data[4 : data.find('\n$$$\n')].split('\n')
for line in data: for line in data:
if ':' not in line: if ':' not in line:
@ -852,9 +857,9 @@ class Setup():
if os.path.exists(src) and os.path.islink(src): if os.path.exists(src) and os.path.islink(src):
links.append((os.path.isdir(src), src, [dest + '/' + file])) links.append((os.path.isdir(src), src, [dest + '/' + file]))
else: else:
self.cp(os.path.isdir(src), src, [dest + '/' + file]) self.cp(os.path.isdir(src), src, [dest + '/' + file], validatehook)
for link in links: for link in links:
self.cp(link[0], link[1], link[2]) self.cp(link[0], link[1], link[2], validatehook)
if self.linking != COPY: if self.linking != COPY:
for dest in destinations[1:]: for dest in destinations[1:]:
print('Creating symbolic link %s with target directory %s' % (dest, target)) print('Creating symbolic link %s with target directory %s' % (dest, target))