diff --git a/fonts/layer_builder.sh b/fonts/layer_builder.sh index 0d8951a..20cb972 100755 --- a/fonts/layer_builder.sh +++ b/fonts/layer_builder.sh @@ -7,9 +7,9 @@ cd /tmp yumdownloader \ dejavu-sans-fonts \ dejavu-fonts-common \ - xorg-x11-fonts-Type1 $@ + xorg-x11-fonts-Type1 "$@" -rpmdev-extract *rpm +rpmdev-extract -- *rpm mkdir /opt/fonts cp -P -r /tmp/*/usr/share/fonts/* /opt/fonts diff --git a/weasyprint/lambda_function.py b/weasyprint/lambda_function.py index bb3619b..f851020 100644 --- a/weasyprint/lambda_function.py +++ b/weasyprint/lambda_function.py @@ -14,7 +14,7 @@ def lambda_handler(event, context): content_type = "application/pdf" method = "write_pdf" elif ext == ".png": - content_type = f"image/png" + content_type = "image/png" method = "write_png" else: raise ValueError("File extension {ext} is not supported.") diff --git a/weasyprint/layer_builder.sh b/weasyprint/layer_builder.sh index 4e3c983..bc50d35 100755 --- a/weasyprint/layer_builder.sh +++ b/weasyprint/layer_builder.sh @@ -16,37 +16,24 @@ yumdownloader --resolve \ libblkid.x86_64 \ glib2.x86_64 \ -rpmdev-extract *rpm +rpmdev-extract -- *rpm mkdir /opt/lib cp -P -r /tmp/*/usr/lib64/* /opt/lib # pixbuf need list loaders cache # https://developer.gnome.org/gdk-pixbuf/stable/gdk-pixbuf-query-loaders.html PIXBUF_BIN=$(find /tmp -name gdk-pixbuf-query-loaders-64) -export GDK_PIXBUF_MODULEDIR=$(find /opt/lib/gdk-pixbuf-2.0/ -name loaders) +GDK_PIXBUF_MODULEDIR=$(find /opt/lib/gdk-pixbuf-2.0/ -name loaders) +export GDK_PIXBUF_MODULEDIR $PIXBUF_BIN > /opt/lib/loaders.cache # pixbuf need mime database # https://www.linuxtopia.org/online_books/linux_desktop_guides/gnome_2.14_admin_guide/mimetypes-database.html cp -r /usr/share/mime /opt/lib/mime -export RUNTIME=$(echo $AWS_EXECUTION_ENV | cut -d _ -f 3) -mkdir -p /opt/python/lib/$RUNTIME/site-packages -python -m pip install weasyprint -t /opt/python/lib/$RUNTIME/site-packages - -# fix dlopen(3) calls -cd /opt/python/lib/$RUNTIME/site-packages -sed -i "s/'libgdk_pixbuf-2.0.so'/'libgdk_pixbuf-2.0.so.0'/" cairocffi/pixbuf.py -sed -i "s/'libgobject-2.0.so'/'libgobject-2.0.so.0'/" cairocffi/pixbuf.py -sed -i "s/'libglib-2.0.so'/'libglib-2.0.so.0'/" cairocffi/pixbuf.py -sed -i "s/'libcairo.so'/'libcairo.so.2'/" cairocffi/__init__.py -sed -i "s/'libfontconfig.so'/'libfontconfig.so.1'/" weasyprint/fonts.py -sed -i "s/'libpangoft2-1.0.so'/'libpangoft2-1.0.so.0'/" weasyprint/fonts.py -sed -i "s/'libgobject-2.0.so'/'libgobject-2.0.so.0'/" weasyprint/fonts.py -sed -i "s/'libpango-1.0.so'/'libpango-1.0.so.0'/" weasyprint/fonts.py -sed -i "s/'libpangocairo-1.0.so'/'libpangocairo-1.0.so.0'/" weasyprint/fonts.py -sed -i "s/'libgobject-2.0.so'/'libgobject-2.0.so.0'/" weasyprint/text.py -sed -i "s/'libpango-1.0.so'/'libpango-1.0.so.0'/" weasyprint/text.py -sed -i "s/'libpangocairo-1.0.so'/'libpangocairo-1.0.so.0'/" weasyprint/text.py +RUNTIME=$(echo "$AWS_EXECUTION_ENV" | cut -d _ -f 3) +export RUNTIME +mkdir -p "/opt/python/lib/$RUNTIME/site-packages" +python -m pip install "weasyprint>=52.2" -t "/opt/python/lib/$RUNTIME/site-packages" cd /opt zip -r9 /out/layer.zip lib/* python/* diff --git a/wkhtmltox/layer_builder.sh b/wkhtmltox/layer_builder.sh index 418305c..d2dfe98 100644 --- a/wkhtmltox/layer_builder.sh +++ b/wkhtmltox/layer_builder.sh @@ -17,7 +17,7 @@ yumdownloader --resolve \ expat.x86_64 \ libuuid.x86_64 \ -rpmdev-extract *rpm +rpmdev-extract -- *rpm mkdir /opt/lib cp -P -r /tmp/*/usr/lib64/* /opt/lib/