The livecd.ubuntu-cpc.ext4 that is present in each build (plus kernel and initrd) are not renamed from /build/binary/boot/filsystem.ext4 and friends until after the binary hooks are run, so this patch moves from trying to perform this cleanup in a binary hook. Now the cleanup will be run at the end of live-build/binary for the ubuntu-cpc project.ubuntu/disco
parent
0d56c46d24
commit
740c6ab42b
@ -1,47 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
#-*- encoding: utf-8 -*-
|
|
||||||
"""
|
|
||||||
The final hook is run after all other binary hooks.
|
|
||||||
"""
|
|
||||||
import glob
|
|
||||||
import os
|
|
||||||
|
|
||||||
|
|
||||||
def remove_implicit_files():
|
|
||||||
"""
|
|
||||||
Remove output files not created by explicitly specified image targets
|
|
||||||
|
|
||||||
This uses the 'explicit_provides' file generated by the 'make-hooks'
|
|
||||||
script. If the file is empty, all output will be saved.
|
|
||||||
"""
|
|
||||||
explicit = set()
|
|
||||||
with open('./config/hooks/explicit_provides', 'r', encoding='utf-8') as fp:
|
|
||||||
for filename in fp:
|
|
||||||
explicit.add(filename.rstrip())
|
|
||||||
|
|
||||||
if not explicit:
|
|
||||||
print('remove_implicit_files: explicit_provides is empty '
|
|
||||||
'all binary output will be included')
|
|
||||||
quit()
|
|
||||||
|
|
||||||
all = set(glob.glob('livecd.ubuntu-cpc.*'))
|
|
||||||
implicit = all - explicit
|
|
||||||
|
|
||||||
print('remove_implicit_files: all artifacts considered: {}'.format(all))
|
|
||||||
print('remove_implicit_files: explict artifacts to keep: '
|
|
||||||
'{}'.format(explicit))
|
|
||||||
print('remove_implicit_files: implicit artifacts to remove: '
|
|
||||||
'{}'.format(implicit))
|
|
||||||
|
|
||||||
for file in implicit:
|
|
||||||
print('remove_implicit_files: removing {} '
|
|
||||||
'{} bytes'.format(file, os.stat(file).st_size))
|
|
||||||
if os.path.islink(file):
|
|
||||||
os.unlink(file)
|
|
||||||
elif os.path.isfile(file):
|
|
||||||
os.remove(file)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
print('Running {}'.format(__file__))
|
|
||||||
remove_implicit_files()
|
|
@ -0,0 +1,40 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
#-*- encoding: utf-8 -*-
|
||||||
|
"""
|
||||||
|
Remove output files not created by explicitly specified image targets
|
||||||
|
|
||||||
|
This uses the 'explicit_provides' file generated by the 'make-hooks'
|
||||||
|
script. If the file is empty, all output will be saved.
|
||||||
|
"""
|
||||||
|
import glob
|
||||||
|
import os
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
print('Running {}'.format(__file__))
|
||||||
|
scriptname = os.path.basename(__file__)
|
||||||
|
explicit = set()
|
||||||
|
with open('./config/hooks.d/explicit_provides', 'r',
|
||||||
|
encoding='utf-8') as fp:
|
||||||
|
for filename in fp:
|
||||||
|
explicit.add(filename.rstrip())
|
||||||
|
|
||||||
|
if not explicit:
|
||||||
|
print('{}: explicit_provides is empty. '
|
||||||
|
'All binary output will be included'.format(scriptname))
|
||||||
|
quit()
|
||||||
|
|
||||||
|
all = set(glob.glob('livecd.ubuntu-cpc.*'))
|
||||||
|
implicit = all - explicit
|
||||||
|
|
||||||
|
print('{}: all artifacts considered: {}'.format(scriptname, all))
|
||||||
|
print('{}: explict artifacts to keep: {}'.format(scriptname, explicit))
|
||||||
|
print('{}: implicit artifacts to remove: {}'.format(scriptname, implicit))
|
||||||
|
|
||||||
|
for file in implicit:
|
||||||
|
if os.path.islink(file):
|
||||||
|
print('{}: unlinking {}'.format(scriptname, file))
|
||||||
|
os.unlink(file)
|
||||||
|
elif os.path.isfile(file):
|
||||||
|
print('{}: removing {} '
|
||||||
|
'{} bytes'.format(scriptname, file, os.stat(file).st_size))
|
||||||
|
os.remove(file)
|
Loading…
Reference in new issue