Skip to content

Commit 611587b

Browse files
committed
Fix layer for python3.8 and more debug output
1 parent 9bbfb18 commit 611587b

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ A script that prepares an AWS Lambda layer with diffoscope and some tools it nee
1111

1212
## How to use in Lambda
1313

14+
First, you need to set two environment variables:
15+
```bash
16+
MAGIC=/usr/share/misc/magic:/opt/magic
17+
LD_PRELOAD=/opt/lib/libarchive.so
18+
```
19+
20+
Second, use this snippet to run diffoscope:
1421
```python
1522
from diffoscope.logging import line_eraser, setup_logging
1623
from diffoscope.main import create_parser, run_diffoscope

make_layer.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,13 @@ docker run --rm -v $(pwd):/foo -w /foo lambci/lambda:build-$RUNTIME \
1818
cp --verbose /usr/bin/zipnote bin/ && \
1919
yum --assumeyes install libarchive && \
2020
cp --verbose /usr/lib64/libarchive.so.13 lib/libarchive.so && \
21-
cp --verbose /usr/lib64/libarchive.so.13 lib/libarchive.so.13 && \
2221
cp --verbose /usr/lib64/liblzo2.so.2 lib/ && \
23-
([[ $RUNTIME == 'python3.8' ]] && cp --verbose /usr/lib64/libmagic.so.1 lib/) && \
24-
([[ $RUNTIME == 'python3.8' ]] && cp --verbose /usr/lib64/libcrypto.so.10 lib/) && \
22+
([[ $RUNTIME == 'python3.8' ]] && cp --verbose /usr/bin/cmp bin/) && \
23+
([[ $RUNTIME == 'python3.8' ]] && cp --verbose /usr/bin/diff bin/) && \
24+
([[ $RUNTIME == 'python3.8' ]] && cp --verbose /usr/bin/file bin/) && \
25+
([[ $RUNTIME == 'python3.8' ]] && cp --verbose /usr/bin/zipinfo bin/) && \
26+
([[ $RUNTIME == 'python3.8' ]] && cp --verbose /usr/lib64/libxml2.so.2 lib/) && \
27+
([[ $RUNTIME == 'python3.8' ]] && curl 'https://kojipkgs.fedoraproject.org//packages/file/5.36/5.fc30/x86_64/file-libs-5.36-5.fc30.x86_64.rpm' --output - | rpm2cpio | cpio -idv && cp --verbose usr/share/misc/magic . && cp usr/lib64/libmagic.so.1 lib/) && \
2528
chown --verbose $(id --user):$(id --group) lib/* \
2629
"
2730
docker run --user $(id --user):$(id --group) --rm -v $(pwd):/foo -w /foo lambci/lambda:build-$RUNTIME \

run_tests.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/sh
2+
set -x
23
RUNTIME=${1:-python3.6}
34

45
rm -r opt
@@ -9,6 +10,6 @@ ldd bin/* || true
910
ldd lib/* || true
1011
cd ..
1112
ls -l
12-
docker run -e DOCKER_LAMBDA_DEBUG=1 --rm -v "$PWD":/var/task:ro,delegated -v "$PWD"/opt/:/opt:ro,delegated lambci/lambda:$RUNTIME tests.run 2> /tmp/test_results
13+
docker run -e MAGIC=/usr/share/misc/magic:/opt/magic -e LD_PRELOAD=/opt/lib/libarchive.so -e DOCKER_LAMBDA_DEBUG=1 --rm -v "$PWD":/var/task:ro,delegated -v "$PWD"/opt/:/opt:ro,delegated lambci/lambda:$RUNTIME tests.run 2> /tmp/test_results
1314
cat /tmp/test_results
1415
grep '^OK$' /tmp/test_results

tests.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def setUpClass(cls):
1919
"test/extension_2020_1_13_0.crx",
2020
"--text",
2121
report_file,
22+
"--debug",
2223
]
2324
)
2425
with open(report_file) as f:

0 commit comments

Comments
 (0)