Increase max ELF program sections processed for core files
To fix packcore test failure in sles12
@@ -10,7 +10,7 @@ import shutil
import stat
import sys
from optparse import OptionParser
-from subprocess import Popen, PIPE
+from subprocess import Popen, PIPE, STDOUT
def _getPlatformInfo():
@@ -28,7 +28,17 @@ def _getPlatformInfo():
def _getFileInfo(coreFile):
- cmd = Popen(['/usr/bin/file', coreFile], stdout=PIPE)
+ cmd = Popen(['/usr/bin/file', '--version'], stdout=PIPE, stderr=STDOUT)
+ fileVersion = cmd.communicate()[0].split()[0].strip()
+ # file allow setting parameters from command line from version 5.21, refer:
+ # https://github.com/file/file/commit/6ce24f35cd4a43c4bdd249e8e0c4952c1f8eac67
+ # Set ELF program sections processed for core files to suppres "too many
+ # program headers" output
+ opts = ['/usr/bin/file']
+ if fileVersion >= 'file-5.21':
+ opts += ['-P', 'elf_phnum=2048']
+ opts += [coreFile]
+ cmd = Popen(opts, stdout=PIPE)
return cmd.communicate()[0]
