コード例 #1
0
def main():
    sh('rm -rf ${DEBUG_WORLD}')
    sh('mkdir -p ${DEBUG_WORLD}')

    info('Saving debug information in ${{DEBUG_WORLD}}')

    for root, dirs, files in os.walk(e('${WORLD_DESTDIR}/')):
        for name in files:
            filename = os.path.join(root, name)
            relpath = os.path.relpath(filename, e('${WORLD_DESTDIR}'))
            destpath = os.path.join(e('${DEBUG_WORLD}'), relpath)

            ext = os.path.splitext(name)[1]

            if ext == '.ko':
                continue

            if relpath.startswith(('boot', 'usr/local/lib/grub')):
                continue

            if ext == '.c':
                make_dir(destpath)
                shutil.move(filename, destpath)
                for f in os.listdir(root):
                    if f.endswith('.html'):
                        html_path = os.path.join(root, f)
                        if 'Generated by Cython' in open(html_path).read():
                            relpath = os.path.relpath(html_path,
                                                      e('${WORLD_DESTDIR}'))
                            destpath = os.path.join(e('${DEBUG_WORLD}'),
                                                    relpath)
                            shutil.move(html_path, destpath)
                continue

            if ext == '.html':
                continue

            if not is_elf(filename):
                continue

            make_dir(destpath)

            # We need to remove any flags on protected files and restore
            # them after stripping
            flags = os.stat(filename).st_flags
            os.chflags(filename, 0)

            if not relpath.startswith('rescue'):
                sh('objcopy --only-keep-debug ${filename} ${destpath}.debug')
                sh('objcopy --strip-unneeded ${filename}', nofail=True)
                sh('objcopy --add-gnu-debuglink="${destpath}.debug" ${filename}',
                   log='/dev/null',
                   nofail=True)
            else:
                sh('strip ${filename}')

            os.chflags(filename, flags)
コード例 #2
0
def main():
    sh('rm -rf ${DEBUG_WORLD}')
    sh('mkdir -p ${DEBUG_WORLD}')

    info('Saving debug information in ${{DEBUG_WORLD}}')

    for root, dirs, files in os.walk(e('${WORLD_DESTDIR}/')):
        for name in files:
            filename = os.path.join(root, name)
            relpath = os.path.relpath(filename, e('${WORLD_DESTDIR}'))
            destpath = os.path.join(e('${DEBUG_WORLD}'), relpath)

            ext = os.path.splitext(name)[1]

            if ext == '.ko':
                continue

            if relpath.startswith(('boot', 'usr/local/lib/grub')):
                continue

            if ext == '.c':
                make_dir(destpath)
                shutil.move(filename, destpath)
                for f in os.listdir(root):
                    if f.endswith('.html'):
                        html_path = os.path.join(root, f)
                        if 'Generated by Cython' in open(html_path).read():
                            relpath = os.path.relpath(html_path, e('${WORLD_DESTDIR}'))
                            destpath = os.path.join(e('${DEBUG_WORLD}'), relpath)
                            shutil.move(html_path, destpath)
                continue

            if ext == '.html':
                continue

            if not is_elf(filename):
                continue

            make_dir(destpath)

            # We need to remove any flags on protected files and restore
            # them after stripping
            flags = os.stat(filename).st_flags
            os.chflags(filename, 0)

            if not relpath.startswith('rescue'):
                sh('objcopy --only-keep-debug ${filename} ${destpath}.debug')
                sh('objcopy --strip-unneeded ${filename}')
                sh('objcopy --add-gnu-debuglink="${destpath}.debug" ${filename}', log='/dev/null', nofail=True)
            else:
                sh('strip ${filename}')

            os.chflags(filename, flags)
コード例 #3
0
def main(destdir):
    # Kill all binaries that are non for AMD64 arch
    for root, dirs, files in os.walk(destdir):
        for name in files:
            filename = os.path.join(root, name)

            if not is_elf(filename):
                continue

            ret = sh_str('file ${filename}')
            if 'x86-64' not in ret and '80386' not in ret:
                os.unlink(filename)
コード例 #4
0
def clean_ufs_image():
    sh('${BUILD_ROOT}/build/customize/remove-bits.py ${INSTUFS_DESTDIR}')

    # Strip binaries
    for root, dirs, files in os.walk(e('${INSTUFS_DESTDIR}/')):
        for name in files:
            filename = os.path.join(root, name)
            if os.path.splitext(name)[1] == '.ko':
                continue

            if not is_elf(filename):
                continue

            # We need to remove any flags on protected files and restore
            # them after stripping
            flags = os.stat(filename).st_flags
            os.chflags(filename, 0)
            sh('strip ${filename}')
            os.chflags(filename, flags)
コード例 #5
0
ファイル: create-iso.py プロジェクト: abwaters/freenas-build
def clean_ufs_image():
    sh('${BUILD_ROOT}/build/customize/remove-bits.py ${INSTUFS_DESTDIR}')

    # Strip binaries
    for root, dirs, files in os.walk(e('${INSTUFS_DESTDIR}/')):
        for name in files:
            filename = os.path.join(root, name)
            if os.path.splitext(name)[1] == '.ko':
                continue

            if not is_elf(filename):
                continue

            # We need to remove any flags on protected files and restore
            # them after stripping
            flags = os.stat(filename).st_flags
            os.chflags(filename, 0)
            sh('strip ${filename}')
            os.chflags(filename, flags)
コード例 #6
0
ファイル: build-debug.py プロジェクト: abwaters/freenas-build
def main():
    sh('rm -rf ${DEBUG_WORLD}')
    sh('mkdir -p ${DEBUG_WORLD}')

    info('Saving debug information in ${{DEBUG_WORLD}}')

    for root, dirs, files in os.walk(e('${WORLD_DESTDIR}/')):
        for name in files:
            filename = os.path.join(root, name)
            relpath = os.path.relpath(filename, e('${WORLD_DESTDIR}'))
            destpath = os.path.join(e('${DEBUG_WORLD}'), relpath)

            if os.path.splitext(name)[1] == '.ko':
                continue

            if relpath.startswith(('boot', 'usr/local/lib/grub')):
                continue

            if not is_elf(filename):
                continue

            try:
                os.makedirs(os.path.dirname(destpath))
            except OSError as err:
                if err.errno != errno.EEXIST:
                    raise

            # We need to remove any flags on protected files and restore
            # them after stripping
            flags = os.stat(filename).st_flags
            os.chflags(filename, 0)

            if not relpath.startswith('rescue'):
                sh('objcopy --only-keep-debug ${filename} ${destpath}.debug')
                sh('objcopy --strip-unneeded ${filename}')
                sh('objcopy --add-gnu-debuglink="${destpath}.debug" ${filename}', log='/dev/null', nofail=True)
            else:
                sh('strip ${filename}')

            os.chflags(filename, flags)