opkg.py/get_file_list(): Add xz support

Open data.tar.xz if gz payload is not present. This change allows xz
payloads to be archived in filelist.

However, only python3's tarfile has xz support. This therefore only
works if opkg-make-index's shebang is overridden to run in python3.

Signed-off-by: Haris Okanovic <haris.okanovic@ni.com>
Signed-off-by: Alejandro del Castillo <alejandro.delcastillo@ni.com>
This commit is contained in:
Haris Okanovic
2019-11-25 13:37:22 -06:00
committed by Alejandro del Castillo
parent 03a7c66c6d
commit 9b2e2b989b

View File

@@ -408,8 +408,12 @@ class Package(object):
return []
f = open(self.fn, "rb")
ar = arfile.ArFile(f, self.fn)
tarStream = ar.open("data.tar.gz")
tarf = tarfile.open("data.tar.gz", "r", tarStream)
try:
tarStream = ar.open("data.tar.gz")
tarf = tarfile.open("data.tar.gz", "r", tarStream)
except IOError:
tarStream = ar.open("data.tar.xz")
tarf = tarfile.open("data.tar.xz", "r:xz", tarStream)
self.file_list = tarf.getnames()
self.file_list = [["./", ""][a.startswith("./")] + a for a in self.file_list]