aboutsummaryrefslogtreecommitdiffstats
path: root/src/blogc-github-lambda/lambda_function.py
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2016-12-14 00:39:40 +0100
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2016-12-14 00:39:40 +0100
commit40bda8a04d397e72763bd74a8e76d7b14845a5a3 (patch)
tree22c8e1ff31378afa2d2577ec69641efbdd4d1b12 /src/blogc-github-lambda/lambda_function.py
parent83e050d5b93ac66832605c7193223720d99cb4a3 (diff)
downloadblogc-40bda8a04d397e72763bd74a8e76d7b14845a5a3.tar.gz
blogc-40bda8a04d397e72763bd74a8e76d7b14845a5a3.tar.bz2
blogc-40bda8a04d397e72763bd74a8e76d7b14845a5a3.zip
github-lambda: improve handling of busybox symlinks
Diffstat (limited to 'src/blogc-github-lambda/lambda_function.py')
-rw-r--r--src/blogc-github-lambda/lambda_function.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/blogc-github-lambda/lambda_function.py b/src/blogc-github-lambda/lambda_function.py
index 9320544..ad4614d 100644
--- a/src/blogc-github-lambda/lambda_function.py
+++ b/src/blogc-github-lambda/lambda_function.py
@@ -22,15 +22,25 @@ import urllib2
import shutil
cwd = os.path.dirname(os.path.abspath(__file__))
+bindir = os.path.join(cwd, 'bin')
-os.environ['PATH'] = '%s:%s' % (os.path.join(cwd, 'bin'),
- os.environ.get('PATH', ''))
+os.environ['PATH'] = '%s:%s' % (bindir, os.environ.get('PATH', ''))
GITHUB_AUTH = os.environ.get('GITHUB_AUTH')
if GITHUB_AUTH is not None and ':' not in GITHUB_AUTH:
GITHUB_AUTH = boto3.client('kms').decrypt(
CiphertextBlob=base64.b64decode(GITHUB_AUTH))['Plaintext']
+# this is just a safeguard, just in case lambda stops supporting symlinks
+# in zip files
+for binary in subprocess.check_output([os.path.join(bindir, 'busybox'),
+ '--list']).split():
+ dst = os.path.join(bindir, binary)
+ if not os.path.islink(dst):
+ os.symlink('busybox', dst)
+ else:
+ break
+
def get_tarball(repo_name):
tarball_url = 'https://api.github.com/repos/%s/tarball/master' % repo_name
@@ -144,9 +154,9 @@ def lambda_handler(event, context):
repo_name = payload['repository']['name']
repo_full_name = payload['repository']['full_name']
rootdir = get_tarball(repo_full_name)
- rv = subprocess.call([os.path.join(cwd, 'bin', 'make'), '-C', rootdir,
+ rv = subprocess.call([os.path.join(bindir, 'make'), '-C', rootdir,
'OUTPUT_DIR=_build',
- 'BLOGC=%s' % os.path.join(cwd, 'bin', 'blogc')],
+ 'BLOGC=%s' % os.path.join(bindir, 'blogc')],
stdout=None if debug else subprocess.PIPE,
stderr=None if debug else subprocess.PIPE)
if rv != 0: