forked from matrix/element-web
Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
commit
fcb705d79b
|
@ -14,6 +14,7 @@ import subprocess
|
||||||
import sys
|
import sys
|
||||||
import tarfile
|
import tarfile
|
||||||
import shutil
|
import shutil
|
||||||
|
import glob
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# python3
|
# python3
|
||||||
|
@ -66,7 +67,7 @@ class Deployer:
|
||||||
self.bundles_path = None
|
self.bundles_path = None
|
||||||
self.should_clean = False
|
self.should_clean = False
|
||||||
# filename -> symlink path e.g 'config.localhost.json' => '../localhost/config.json'
|
# filename -> symlink path e.g 'config.localhost.json' => '../localhost/config.json'
|
||||||
self.config_locations = {}
|
self.symlink_paths = {}
|
||||||
self.verify_signature = True
|
self.verify_signature = True
|
||||||
|
|
||||||
def deploy(self, tarball, extract_path):
|
def deploy(self, tarball, extract_path):
|
||||||
|
@ -98,11 +99,11 @@ class Deployer:
|
||||||
|
|
||||||
print ("Extracted into: %s" % extracted_dir)
|
print ("Extracted into: %s" % extracted_dir)
|
||||||
|
|
||||||
if self.config_locations:
|
if self.symlink_paths:
|
||||||
for config_filename, config_loc in self.config_locations.iteritems():
|
for link_path, file_path in self.symlink_paths.iteritems():
|
||||||
create_relative_symlink(
|
create_relative_symlink(
|
||||||
target=config_loc,
|
target=file_path,
|
||||||
linkname=os.path.join(extracted_dir, config_filename)
|
linkname=os.path.join(extracted_dir, link_path)
|
||||||
)
|
)
|
||||||
|
|
||||||
if self.bundles_path:
|
if self.bundles_path:
|
||||||
|
@ -165,9 +166,10 @@ if __name__ == "__main__":
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--config", nargs='?', default='./config.json', help=(
|
"--include", nargs='*', default='./config*.json', help=(
|
||||||
"Write a symlink at config.json in the extracted tarball to this \
|
"Symlink these files into the root of the deployed tarball. \
|
||||||
location. (Default: '%(default)s')"
|
Useful for config files and home pages. Supports glob syntax. \
|
||||||
|
(Default: '%(default)s')"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
|
@ -182,8 +184,8 @@ if __name__ == "__main__":
|
||||||
deployer.packages_path = args.packages_dir
|
deployer.packages_path = args.packages_dir
|
||||||
deployer.bundles_path = args.bundles_dir
|
deployer.bundles_path = args.bundles_dir
|
||||||
deployer.should_clean = args.clean
|
deployer.should_clean = args.clean
|
||||||
deployer.config_locations = {
|
|
||||||
"config.json": args.config,
|
for include in args.include:
|
||||||
}
|
deployer.symlink_paths.update({ os.path.basename(pth): pth for pth in glob.iglob(include) })
|
||||||
|
|
||||||
deployer.deploy(args.tarball, args.extract_path)
|
deployer.deploy(args.tarball, args.extract_path)
|
||||||
|
|
|
@ -15,6 +15,7 @@ import json, requests, tarfile, argparse, os, errno
|
||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
from urlparse import urljoin
|
from urlparse import urljoin
|
||||||
|
import glob
|
||||||
|
|
||||||
from flask import Flask, jsonify, request, abort
|
from flask import Flask, jsonify, request, abort
|
||||||
|
|
||||||
|
@ -188,15 +189,12 @@ if __name__ == "__main__":
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
def _raise(ex):
|
# --include ../../config.json ./localhost.json homepages/*
|
||||||
raise ex
|
|
||||||
|
|
||||||
# --config config.json=../../config.json --config config.localhost.json=./localhost.json
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--config", action="append", dest="configs",
|
"--include", nargs='*', default='./config*.json', help=(
|
||||||
type=lambda kv: kv.split("=", 1) if "=" in kv else _raise(Exception("Missing =")), help=(
|
"Symlink these files into the root of the deployed tarball. \
|
||||||
"A list of configs to symlink into the extracted tarball. \
|
Useful for config files and home pages. Supports glob syntax. \
|
||||||
For example, --config config.json=../config.json config2.json=../test/config.json"
|
(Default: '%(default)s')"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
|
@ -220,7 +218,9 @@ if __name__ == "__main__":
|
||||||
deployer = Deployer()
|
deployer = Deployer()
|
||||||
deployer.bundles_path = args.bundles_dir
|
deployer.bundles_path = args.bundles_dir
|
||||||
deployer.should_clean = args.clean
|
deployer.should_clean = args.clean
|
||||||
deployer.config_locations = dict(args.configs) if args.configs else {}
|
|
||||||
|
for include in args.include:
|
||||||
|
deployer.symlink_paths.update({ os.path.basename(pth): pth for pth in glob.iglob(include) })
|
||||||
|
|
||||||
|
|
||||||
# we don't pgp-sign jenkins artifacts; instead we rely on HTTPS access to
|
# we don't pgp-sign jenkins artifacts; instead we rely on HTTPS access to
|
||||||
|
@ -234,13 +234,13 @@ if __name__ == "__main__":
|
||||||
deploy_tarball(args.tarball_uri, build_dir)
|
deploy_tarball(args.tarball_uri, build_dir)
|
||||||
else:
|
else:
|
||||||
print(
|
print(
|
||||||
"Listening on port %s. Extracting to %s%s. Symlinking to %s. Jenkins URL: %s. Config locations: %s" %
|
"Listening on port %s. Extracting to %s%s. Symlinking to %s. Jenkins URL: %s. Include patterns: %s" %
|
||||||
(args.port,
|
(args.port,
|
||||||
arg_extract_path,
|
arg_extract_path,
|
||||||
" (clean after)" if deployer.should_clean else "",
|
" (clean after)" if deployer.should_clean else "",
|
||||||
arg_symlink,
|
arg_symlink,
|
||||||
arg_jenkins_url,
|
arg_jenkins_url,
|
||||||
deployer.config_locations,
|
deployer.symlink_paths,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
app.run(host="0.0.0.0", port=args.port, debug=True)
|
app.run(host="0.0.0.0", port=args.port, debug=True)
|
||||||
|
|
Loading…
Reference in New Issue