build: fixed some bodges

This commit is contained in:
Strix 2023-10-14 22:39:40 +02:00
parent 61e3c450b7
commit 6e30a8bed7
No known key found for this signature in database
GPG key ID: 49B2E37B8915B774

View file

@ -3,16 +3,24 @@ import tarfile
with open("./package.toml", mode='r') as mani: with open("./package.toml", mode='r') as mani:
data = mani.read() data = mani.read()
with open("./mock.pkg", mode='wb') as pkg: with open("./sample.pkg", mode='wb') as pkg:
print("building header...") print("building header...")
pkg.write(bytes([0x01, (len(data) >> 8) & 0xFF, len(data) & 0xFF])) pkg.write(bytes([0x01, (len(data) >> 8) & 0xFF, len(data) & 0xFF]))
print("writing manifest into pkg...") print("writing manifest into pkg...")
pkg.write(data.encode("utf-8")) pkg.write(data.encode("utf-8"))
with tarfile.TarFile("/tmp/pkgtar", 'w') as pkgtar: with tarfile.TarFile("/tmp/pkgtar", 'w') as pkgtar:
print("tarring ./pkg...")
os.chdir("pkg")
for root, dirs, files in os.walk("."): for root, dirs, files in os.walk("."):
for file in files: for file in files:
print(f"\33[2Kadd: {file}", end="\r", flush=True) print(f"\33[2Kadd: {os.path.join(root, file)}", end="\r", flush=True)
pkgtar.add(os.path.join(root, file)) pkgtar.add(os.path.join(root, file))
os.chdir("..")
for root, dirs, files in os.walk("pkgr"):
for file in files:
print(f"\33[2Kadd: {os.path.join(root, file)}", end="\r", flush=True)
pkgtar.add(os.path.join(root, file))
print("\33[2K", end="\r", flush=True)
with open("/tmp/pkgtar", 'rb') as pkgtar: with open("/tmp/pkgtar", 'rb') as pkgtar:
print("appending pkgtar to pkg...") print("appending pkgtar to pkg...")
pkg.write(pkgtar.read()) pkg.write(pkgtar.read())