aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2016-12-27 03:57:49 +0100
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2016-12-27 03:57:49 +0100
commit879e295de04bc0699462c959a1d331dcf5446345 (patch)
tree998d651a0a38b310dc396994c80d5b693d2ec225
parent7adc75dedf789c61ca15b0ccf239367b171be30c (diff)
downloadblogc-879e295de04bc0699462c959a1d331dcf5446345.tar.gz
blogc-879e295de04bc0699462c959a1d331dcf5446345.tar.bz2
blogc-879e295de04bc0699462c959a1d331dcf5446345.zip
github-lambda: drop external dependencies
-rwxr-xr-xbuild-aux/travis-build-github-lambda.sh42
-rwxr-xr-xbuild-aux/travis-build.sh29
-rw-r--r--src/blogc-github-lambda/lambda_function.py18
3 files changed, 26 insertions, 63 deletions
diff --git a/build-aux/travis-build-github-lambda.sh b/build-aux/travis-build-github-lambda.sh
deleted file mode 100755
index 6a46c05..0000000
--- a/build-aux/travis-build-github-lambda.sh
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/bin/bash
-
-set -ex
-
-PV_DEPS=2
-
-PN_DEPS="blogc-lambda-deps"
-P_DEPS="${PN_DEPS}-${PV_DEPS}"
-A_DEPS="${P_DEPS}.tar.xz"
-SRC_DEPS="https://travis-distfiles.rgm.io/${PN_DEPS}/${P_DEPS}/${P_DEPS}.tar.xz"
-
-rm -rf root build
-mkdir -p root build
-
-wget -c "${SRC_DEPS}" "${SRC_DEPS}.sha512"
-sha512sum -c "${A_DEPS}.sha512"
-tar -xvf "${A_DEPS}" -C root/
-
-pushd build > /dev/null
-../configure \
- CFLAGS="-Wall -g -O0" \
- --disable-ronn \
- --disable-silent-rules \
- --disable-tests \
- --disable-valgrind \
- --disable-git-receiver \
- --disable-runserver \
- --enable-make-embedded
-popd > /dev/null
-
-make -C build LDFLAGS="-all-static" blogc
-
-PV="$(grep PACKAGE_VERSION build/config.h | cut -d\" -f2)"
-
-install -m 755 build/blogc root/bin/blogc
-install -m 644 src/blogc-github-lambda/lambda_function.py root/lambda_function.py
-install -m 644 LICENSE root/licenses/blogc
-strip root/bin/blogc
-
-pushd root/ > /dev/null
-zip --symlinks -rq "../blogc-github-lambda-${PV}.zip" *
-popd > /dev/null
diff --git a/build-aux/travis-build.sh b/build-aux/travis-build.sh
index 8725a0b..223d145 100755
--- a/build-aux/travis-build.sh
+++ b/build-aux/travis-build.sh
@@ -2,16 +2,15 @@
set -ex
-if [[ "x${TARGET}" = "xblogc-github-lambda" ]]; then
- build-aux/travis-build-github-lambda.sh
- exit $?
-fi
-
MAKE_CONFIGURE="--enable-make"
if [[ "x${TARGET}" = "xblogc-make-embedded" ]]; then
MAKE_CONFIGURE="--enable-make-embedded"
TARGET="check"
fi
+if [[ "x${TARGET}" = "xblogc-github-lambda" ]]; then
+ MAKE_CONFIGURE="--enable-make-embedded"
+fi
+
rm -rf build
mkdir -p build
@@ -28,4 +27,22 @@ pushd build > /dev/null
${MAKE_CONFIGURE}
popd > /dev/null
-make -C build "${TARGET}"
+if [[ "x${TARGET}" = "xblogc-github-lambda" ]]; then
+ make -C build LDFLAGS="-all-static" blogc
+
+ rm -rf root
+ mkdir -p root
+
+ PV="$(grep PACKAGE_VERSION build/config.h | cut -d\" -f2)"
+
+ install -m 755 build/blogc root/blogc
+ install -m 644 src/blogc-github-lambda/lambda_function.py root/lambda_function.py
+ install -m 644 LICENSE root/LICENSE
+ strip root/blogc
+
+ pushd root/ > /dev/null
+ zip --symlinks -rq "../blogc-github-lambda-${PV}.zip" *
+ popd > /dev/null
+else
+ make -C build "${TARGET}"
+fi
diff --git a/src/blogc-github-lambda/lambda_function.py b/src/blogc-github-lambda/lambda_function.py
index 3f7d13d..44f1bc9 100644
--- a/src/blogc-github-lambda/lambda_function.py
+++ b/src/blogc-github-lambda/lambda_function.py
@@ -22,9 +22,7 @@ import urllib2
import shutil
cwd = os.path.dirname(os.path.abspath(__file__))
-bindir = os.path.join(cwd, 'bin')
-
-os.environ['PATH'] = '%s:%s' % (bindir, os.environ.get('PATH', ''))
+os.environ['PATH'] = '%s:%s' % (cwd, os.environ.get('PATH', ''))
s3 = boto3.resource('s3')
@@ -33,16 +31,6 @@ 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 # if one symlink exists, all the others will likely exist
-
def get_tarball(repo_name):
tarball_url = 'https://api.github.com/repos/%s/tarball/master' % repo_name
@@ -157,8 +145,8 @@ def lambda_handler(event, context):
stream = None if debug else subprocess.PIPE
rootdir = get_tarball(payload['repository']['full_name'])
- rv = subprocess.call([os.path.join(bindir, 'make'), '-C', rootdir,
- 'BLOGC=%s' % os.path.join(bindir, 'blogc'),
+ rv = subprocess.call(['make', '-C', rootdir,
+ 'BLOGC=%s' % os.path.join(cwd, 'blogc'),
'OUTPUT_DIR=_build'],
stdout=stream, stderr=stream)
if rv != 0: