Skip to content

Commit

Permalink
fix deploy script
Browse files Browse the repository at this point in the history
  • Loading branch information
EthanArbuckle committed Jan 1, 2021
1 parent 8f30db3 commit c747e8a
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions repo/push_deb_to_repo.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import gzip
import hashlib
import os
import subprocess
from typing import Optional
import sys
from pathlib import Path
import hashlib
import tempfile
import gzip

from pathlib import Path
from typing import Optional

REPO_IP_ADDRESS = "206.189.219.64"
REPO_PATH = "/var/www/repo.ghostbin.co"
Expand Down Expand Up @@ -38,10 +38,10 @@ def run(deb_to_upload: Path) -> None:
# Upload the Release file
release_file_path = Path(__file__).parent / "Release"
send_file(release_file_path.as_posix(), "Release")

# Generate the Package info
package_info = run_local_command(f"dpkg -I {deb_to_upload.as_posix()} control")

# Generate hashes and add them to package info
with open(deb_to_upload.as_posix(), mode="rb") as debf:
deb_contents = debf.read()
Expand All @@ -58,17 +58,17 @@ def run(deb_to_upload: Path) -> None:
# Add deb name to package file
remote_deb_location = f"debs/{deb_to_upload.name}"
package_info += f"Filename: {remote_deb_location}\n"

# Gzip package file and upload
# with tempfile.NamedTemporaryFile(mode="wb") as packagef
with open("Packages.gz", mode="wb") as packagef, gzip.GzipFile(fileobj=packagef, mode="wb") as gzout:
with tempfile.NamedTemporaryFile(mode="wb", delete=False) as packagef, gzip.GzipFile(fileobj=packagef, mode="wb") as gzout:
# Write contents to temp file
gzout.write(package_info.encode("utf-8"))
gzout.flush()
gzout.close()
packagef.close()
# Send to server
send_file(packagef.name, "Packages.gz")
os.remove(packagef.name)

# Upload deb
send_file(deb_to_upload.as_posix(), remote_deb_location)
Expand All @@ -80,6 +80,6 @@ def run(deb_to_upload: Path) -> None:

if len(sys.argv) < 2 or ".deb" not in sys.argv[1]:
raise Exception("No deb provided")

provided_deb = Path(sys.argv[1])
run(provided_deb)

0 comments on commit c747e8a

Please sign in to comment.