Permalink
Browse files

Download teleproxy 0.1.1 and include it in install/packages

  • Loading branch information...
ark3 committed Oct 12, 2018
1 parent 30491fc commit 27cbd9934c75320130b00653d49ef6567155c53b
Showing with 82 additions and 2 deletions.
  1. +3 −1 install.sh
  2. +7 −1 packaging/deploy.py
  3. +10 −0 packaging/package_linux.py
  4. +62 −0 packaging/retrieve-teleproxy.py
@@ -19,10 +19,11 @@ trap "rm -rf $BLDDIR" EXIT
DIST="${BLDDIR}/dist"
mkdir -p "${DIST}"
# Build executables in dist
# Build/retrieve executables into dist
cd "${SRCDIR}"
python3 packaging/build-telepresence.py "${DIST}/telepresence"
python3 packaging/build-sshuttle.py "${DIST}/sshuttle-telepresence"
python3 packaging/retrieve-teleproxy.py "${DIST}/teleproxy"
# Place binaries
install -d "${BINDIR}"
@@ -32,6 +33,7 @@ install \
install -d "${LIBEXECDIR}"
install \
"${DIST}/sshuttle-telepresence" \
"${DIST}/teleproxy" \
"${LIBEXECDIR}"
# Make sure things appear to run
@@ -147,18 +147,24 @@ def build_executables():
cwd="/source"
)
con.execute_sh("python3 packaging/build-sshuttle.py", cwd="/source")
con.execute_sh("python3 packaging/retrieve-teleproxy.py", cwd="/source")
con.copy_from("/source/dist/telepresence", str(DIST))
con.copy_from("/source/dist/sshuttle-telepresence", str(DIST))
con.copy_from("/source/dist/teleproxy-darwin-amd64", str(DIST))
con.copy_from("/source/dist/teleproxy-linux-amd64", str(DIST))
def make_archive(version):
"""Make a tar archive of the binaries in dist"""
"""
Make a Mac-specific tar archive of the appropriate executables in dist.
"""
name_ver = "telepresence-{}".format(version)
tf_path = DIST / "{}.tar.gz".format(name_ver)
tf = tarfile.open(str(tf_path), "x:gz")
contents = (
("telepresence", "bin/telepresence"),
("sshuttle-telepresence", "libexec/sshuttle-telepresence"),
("teleproxy-darwin-amd64", "libexec/teleproxy"),
)
for src_name, dst_name in contents:
src = DIST / src_name
@@ -51,6 +51,8 @@ def prep_to_build() -> Container:
con.execute_sh("gem install -q --no-ri --no-rdoc fpm")
con.copy_to(str(DIST / "telepresence"), "/usr/bin")
con.copy_to(str(DIST / "sshuttle-telepresence"), "/usr/libexec")
con.copy_to(str(DIST / "teleproxy-linux-amd64"), "/usr/libexec")
con.execute_sh("mv teleproxy-linux-amd64 teleproxy", cwd="/usr/libexec")
return con
@@ -73,6 +75,7 @@ def build_package(
fpm_trailer = [
"/usr/bin/telepresence",
"/usr/libexec/sshuttle-telepresence",
"/usr/libexec/teleproxy",
]
target_path = DIST / name
target_path.mkdir()
@@ -100,6 +103,13 @@ def test_package(image: str, package: Path, install_cmd: str):
con.execute_sh("python3 --version")
con.execute_sh("telepresence --version")
con.execute_sh("/usr/libexec/sshuttle-telepresence --version")
teleproxy_smoke_test = (
"[ $(/usr/libexec/teleproxy --help 2>&1 | " +
" sed 's/ .*//') = 'Usage' ] && " +
"echo 'Teleproxy smoke test succeeded' || " +
"(echo 'Teleproxy smoke test failed' ; exit 1)"
)
con.execute_sh(teleproxy_smoke_test)
def get_upload_commands(system, release, package):
@@ -0,0 +1,62 @@
#!/usr/bin/env python3
"""
Retrieve the right version of teleproxy
"""
from pathlib import Path
from urllib.request import urlopen
import sys
TELEPROXY_BASE = "https://s3.amazonaws.com/datawire-static-files/teleproxy/"
TELEPROXY_VERSION = "0.1.1"
def retrieve_teleproxy(version, go_os, go_arch, output):
"""
Fetch externally-built teleproxy binary
"""
url = TELEPROXY_BASE + "{}/{}/{}/teleproxy".format(version, go_os, go_arch)
try:
with urlopen(url) as down, output.open("wb") as out:
while True:
data = down.read(2**18)
if not data:
break
out.write(data)
output.chmod(0o755)
except Exception:
print(url)
print(output)
raise
print("Downloaded {}".format(output))
def main():
"""
Set things up then call the code that retrieves binaries
"""
# See `go tool dist list` for Go OS and arch options
go_arch = "amd64"
# Make a list of required downloads
downloads = []
if len(sys.argv) > 1:
# Install script usage; just download the required version
go_os = sys.platform
downloads.append((go_os, go_arch, Path(sys.argv[1])))
else:
# Deploy script usage; download everything
dist = Path(__file__).absolute().resolve().parent.parent / "dist"
dist.mkdir(parents=True, exist_ok=True)
ptn = "teleproxy-{}-{}"
for go_os in "darwin", "linux":
filename = ptn.format(go_os, go_arch)
downloads.append((go_os, go_arch, dist / filename))
# Download
for go_os, go_arch, target in downloads:
retrieve_teleproxy(TELEPROXY_VERSION, go_os, go_arch, target)
if __name__ == "__main__":
main()

0 comments on commit 27cbd99

Please sign in to comment.