diff --git a/scripts/make-sfx.sh b/scripts/make-sfx.sh index 8c1b2afd..3718658c 100755 --- a/scripts/make-sfx.sh +++ b/scripts/make-sfx.sh @@ -311,6 +311,7 @@ sfx_out=../dist/copyparty-$CSN echo cleanup find -name '*.pyc' -delete find -name __pycache__ -delete +find -name py.typed -delete # especially prevent osx from leaking your lan ip (wtf apple) find -type f \( -name .DS_Store -or -name ._.DS_Store \) -delete diff --git a/scripts/sfx.py b/scripts/sfx.py index 52ef23dd..d80576ed 100644 --- a/scripts/sfx.py +++ b/scripts/sfx.py @@ -142,6 +142,7 @@ def testchk(cdata): def encode(data, size, cksum, ver, ts): """creates a new sfx; `data` should yield bufs to attach""" + nb = 0 nin = 0 nout = 0 skip = False @@ -151,6 +152,7 @@ def encode(data, size, cksum, ver, ts): for ln in src.split("\n"): if ln.endswith("# skip 0"): skip = False + nb = 9 continue if ln.endswith("# skip 1") or skip: @@ -160,6 +162,13 @@ def encode(data, size, cksum, ver, ts): if ln.strip().startswith("# fmt: "): continue + if ln: + nb = 0 + else: + nb += 1 + if nb > 2: + continue + unpk += ln + "\n" for k, v in [ @@ -177,7 +186,7 @@ def encode(data, size, cksum, ver, ts): unpk = unpk.replace("\t ", "\t\t") with open("sfx.out", "wb") as f: - f.write(unpk.encode("utf-8") + b"\n\n# eof\n# ") + f.write(unpk.encode("utf-8").rstrip(b"\n") + b"\n\n\n# eof\n# ") for buf in data: ebuf = buf.replace(b"\n", b"\n#n").replace(b"\r", b"\n#r") f.write(ebuf)