better_cleaning_perl_packages patch applied

This commit is contained in:
Safa Arıman
2019-08-23 00:11:08 +03:00
parent 808252e0ab
commit 4f39953702
+32 -3
View File
@@ -27,6 +27,8 @@ from pisi.actionsapi.shelltools import system
from pisi.actionsapi.shelltools import can_access_file
from pisi.actionsapi.shelltools import export
from pisi.actionsapi.shelltools import unlink
from pisi.actionsapi.shelltools import unlinkDir
class ConfigureError(pisi.actionsapi.Error):
def __init__(self, value=''):
@@ -34,18 +36,21 @@ class ConfigureError(pisi.actionsapi.Error):
self.value = value
ctx.ui.error(value)
class MakeError(pisi.actionsapi.Error):
def __init__(self, value=''):
pisi.actionsapi.Error.__init__(self, value)
self.value = value
ctx.ui.error(value)
class InstallError(pisi.actionsapi.Error):
def __init__(self, value=''):
pisi.actionsapi.Error.__init__(self, value)
self.value = value
ctx.ui.error(value)
def configure(parameters = ''):
'''configure source with given parameters.'''
export('PERL_MM_USE_DEFAULT', '1')
@@ -56,6 +61,7 @@ def configure(parameters = ''):
if system('perl Makefile.PL %s PREFIX=/usr INSTALLDIRS=vendor DESTDIR=%s' % (parameters, get.installDIR())):
raise ConfigureError(_('Configure failed.'))
def make(parameters = ''):
'''make source with given parameters.'''
if can_access_file('Makefile'):
@@ -65,6 +71,7 @@ def make(parameters = ''):
if system('perl Build %s' % parameters):
raise MakeError(_('perl build failed.'))
def install(parameters = 'install'):
'''install source with given parameters.'''
if can_access_file('Makefile'):
@@ -75,12 +82,34 @@ def install(parameters = 'install'):
raise MakeError(_('perl install failed.'))
removePacklist()
removePodfiles()
def removePacklist():
def removePacklist(path='usr/lib/perl5/'):
''' cleans .packlist file from perl packages '''
path = '%s/%s' % (get.installDIR(), "/usr/lib/perl5/vendor_perl/%s/%s-linux-thread-multi/auto/" % (get.curPERL(), get.HOST().split("-")[0]))
for root, dirs, files in os.walk(path):
full_path = '%s/%s' % (get.installDIR(), path)
for root, dirs, files in os.walk(full_path):
for packFile in files:
if packFile == ".packlist":
if can_access_file('%s/%s' % (root, packFile)):
unlink('%s/%s' % (root, packFile))
removeEmptydirs(root)
def removePodfiles(path='usr/lib/perl5/'):
''' cleans *.pod files from perl packages '''
full_path = '%s/%s' % (get.installDIR(), path)
for root, dirs, files in os.walk(full_path):
for packFile in files:
if packFile.endswith(".pod"):
if can_access_file('%s/%s' % (root, packFile)):
unlink('%s/%s' % (root, packFile))
removeEmptydirs(root)
def removeEmptydirs(d):
''' remove empty dirs from perl package if exists after deletion .pod and .packlist files '''
if not os.listdir(d) and not d == get.installDIR():
unlinkDir(d)
d = d[:d.rfind("/")]
removeEmptydirs(d)