Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0f1f702c66 |
@@ -0,0 +1,39 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# mudler <mudler@sabayon.org>
|
||||||
|
# Edit: create a truncated tbz2 with just data
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
from portage import xpak
|
||||||
|
|
||||||
|
def usage():
|
||||||
|
sys.stderr.write("usage: %s <tbz2_file>\n" % os.path.basename(sys.argv[0]))
|
||||||
|
|
||||||
|
def main():
|
||||||
|
if len(sys.argv) != 2:
|
||||||
|
usage()
|
||||||
|
return 1
|
||||||
|
|
||||||
|
input_file = sys.argv[1]
|
||||||
|
|
||||||
|
if not os.path.isfile(input_file):
|
||||||
|
usage()
|
||||||
|
return 1
|
||||||
|
|
||||||
|
output_file = input_file
|
||||||
|
if output_file.endswith('.tbz2'):
|
||||||
|
output_file = output_file[:-5]
|
||||||
|
output_file += '.truncated'
|
||||||
|
|
||||||
|
t = xpak.tbz2(input_file)
|
||||||
|
t.scan()
|
||||||
|
f = open(input_file, 'rb')
|
||||||
|
data = f.read(os.stat(input_file).st_size - t.xpaksize)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
f = open(output_file, 'wb')
|
||||||
|
f.write(data)
|
||||||
|
f.close()
|
||||||
|
return 0
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
sys.exit(main())
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
from portage import xpak
|
||||||
|
|
||||||
|
def usage():
|
||||||
|
sys.stderr.write("usage: %s <tbz2_file>\n" % os.path.basename(sys.argv[0]))
|
||||||
|
|
||||||
|
def main():
|
||||||
|
if len(sys.argv) != 2:
|
||||||
|
usage()
|
||||||
|
return 1
|
||||||
|
|
||||||
|
input_file = sys.argv[1]
|
||||||
|
|
||||||
|
if not os.path.isfile(input_file):
|
||||||
|
usage()
|
||||||
|
return 1
|
||||||
|
|
||||||
|
output_file = input_file
|
||||||
|
if output_file.endswith('.tbz2'):
|
||||||
|
output_file = output_file[:-5]
|
||||||
|
output_file += '.xpak'
|
||||||
|
|
||||||
|
t = xpak.tbz2(input_file)
|
||||||
|
t.scan()
|
||||||
|
f = open(input_file, 'rb')
|
||||||
|
f.seek(-t.xpaksize, 2)
|
||||||
|
data = f.read()
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
f = open(output_file, 'wb')
|
||||||
|
f.write(data)
|
||||||
|
f.close()
|
||||||
|
return 0
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
sys.exit(main())
|
||||||
Reference in New Issue
Block a user