From 4ed6b038ba8acd59ed58c888fbd18355b8955eba Mon Sep 17 00:00:00 2001 From: Adam Hupp Date: Thu, 3 Jun 2021 06:43:08 -0700 Subject: fix alpine library loading --- magic/loader.py | 5 +++++ test/Dockerfile_alpine | 4 ---- test/Dockerfile_archlinux | 5 ----- test/Dockerfile_bionic | 8 -------- test/Dockerfile_centos7 | 5 ----- test/Dockerfile_centos8 | 9 --------- test/Dockerfile_focal | 8 -------- test/Dockerfile_xenial | 8 -------- test/docker/alpine | 4 ++++ test/docker/archlinux | 5 +++++ test/docker/bionic | 8 ++++++++ test/docker/centos7 | 5 +++++ test/docker/centos8 | 9 +++++++++ test/docker/focal | 8 ++++++++ test/docker/xenial | 8 ++++++++ test_docker.sh | 17 ++++------------- 16 files changed, 56 insertions(+), 60 deletions(-) delete mode 100755 test/Dockerfile_alpine delete mode 100755 test/Dockerfile_archlinux delete mode 100755 test/Dockerfile_bionic delete mode 100644 test/Dockerfile_centos7 delete mode 100644 test/Dockerfile_centos8 delete mode 100755 test/Dockerfile_focal delete mode 100755 test/Dockerfile_xenial create mode 100755 test/docker/alpine create mode 100755 test/docker/archlinux create mode 100755 test/docker/bionic create mode 100644 test/docker/centos7 create mode 100644 test/docker/centos8 create mode 100755 test/docker/focal create mode 100755 test/docker/xenial diff --git a/magic/loader.py b/magic/loader.py index d6e179b..931f161 100644 --- a/magic/loader.py +++ b/magic/loader.py @@ -29,6 +29,11 @@ def _lib_candidates(): yield './%s.dll' % (i,) yield find_library(i) + elif sys.platform == 'linux': + # This is necessary because alpine is bad + yield 'libmagic.so.1' + + def load_lib(): for lib in _lib_candidates(): diff --git a/test/Dockerfile_alpine b/test/Dockerfile_alpine deleted file mode 100755 index f8ec79e..0000000 --- a/test/Dockerfile_alpine +++ /dev/null @@ -1,4 +0,0 @@ -FROM alpine:latest -RUN apk add python3 python2 libmagic -COPY . /python-magic -CMD cd /python-magic/test && python3 ./run.py diff --git a/test/Dockerfile_archlinux b/test/Dockerfile_archlinux deleted file mode 100755 index fc96c44..0000000 --- a/test/Dockerfile_archlinux +++ /dev/null @@ -1,5 +0,0 @@ -FROM archlinux:latest -RUN yes | pacman -Syyu --overwrite '*' -RUN yes | pacman -S python python2 file which -COPY . /python-magic -CMD cd /python-magic/test && python3 ./run.py diff --git a/test/Dockerfile_bionic b/test/Dockerfile_bionic deleted file mode 100755 index e335b8e..0000000 --- a/test/Dockerfile_bionic +++ /dev/null @@ -1,8 +0,0 @@ -FROM ubuntu:bionic -RUN apt-get update -RUN apt-get -y install python -RUN apt-get -y install python3 -RUN apt-get -y install locales -RUN locale-gen en_US.UTF-8 -COPY . /python-magic -CMD cd /python-magic/test && python3 ./run.py diff --git a/test/Dockerfile_centos7 b/test/Dockerfile_centos7 deleted file mode 100644 index f2ac6e4..0000000 --- a/test/Dockerfile_centos7 +++ /dev/null @@ -1,5 +0,0 @@ -FROM centos:7 -RUN yum -y update -RUN yum -y install file-devel python3 python2 which -COPY . /python-magic -CMD cd /python-magic/test && SKIP_FROM_DESCRIPTOR=1 python3 ./run.py diff --git a/test/Dockerfile_centos8 b/test/Dockerfile_centos8 deleted file mode 100644 index 968f6b6..0000000 --- a/test/Dockerfile_centos8 +++ /dev/null @@ -1,9 +0,0 @@ -FROM centos:8 -RUN yum -y update -RUN yum -y install file-libs python3 python2 which glibc-locale-source -RUN yum reinstall glibc-common -y && \ - localedef -i en_US -f UTF-8 en_US.UTF-8 && \ - echo "LANG=en_US.UTF-8" > /etc/locale.conf -ENV LANG en_US.UTF-8 -COPY . /python-magic -CMD cd /python-magic/test && python3 ./run.py diff --git a/test/Dockerfile_focal b/test/Dockerfile_focal deleted file mode 100755 index 74e4d78..0000000 --- a/test/Dockerfile_focal +++ /dev/null @@ -1,8 +0,0 @@ -FROM ubuntu:focal -RUN apt-get update -RUN apt-get -y install python2 -RUN apt-get -y install python3 -RUN apt-get -y install locales -RUN locale-gen en_US.UTF-8 -COPY . /python-magic -CMD cd /python-magic/test && python3 ./run.py diff --git a/test/Dockerfile_xenial b/test/Dockerfile_xenial deleted file mode 100755 index bc0440b..0000000 --- a/test/Dockerfile_xenial +++ /dev/null @@ -1,8 +0,0 @@ -FROM ubuntu:xenial -RUN apt-get update -RUN apt-get -y install python -RUN apt-get -y install python3 -RUN apt-get -y install locales -RUN locale-gen en_US.UTF-8 -COPY . /python-magic -CMD cd /python-magic/test && python3 ./run.py diff --git a/test/docker/alpine b/test/docker/alpine new file mode 100755 index 0000000..eb511d7 --- /dev/null +++ b/test/docker/alpine @@ -0,0 +1,4 @@ +FROM python:3.8-alpine3.12 +RUN apk add python3 python2 libmagic +COPY . /python-magic +CMD cd /python-magic/test && python3 ./run.py diff --git a/test/docker/archlinux b/test/docker/archlinux new file mode 100755 index 0000000..fc96c44 --- /dev/null +++ b/test/docker/archlinux @@ -0,0 +1,5 @@ +FROM archlinux:latest +RUN yes | pacman -Syyu --overwrite '*' +RUN yes | pacman -S python python2 file which +COPY . /python-magic +CMD cd /python-magic/test && python3 ./run.py diff --git a/test/docker/bionic b/test/docker/bionic new file mode 100755 index 0000000..e335b8e --- /dev/null +++ b/test/docker/bionic @@ -0,0 +1,8 @@ +FROM ubuntu:bionic +RUN apt-get update +RUN apt-get -y install python +RUN apt-get -y install python3 +RUN apt-get -y install locales +RUN locale-gen en_US.UTF-8 +COPY . /python-magic +CMD cd /python-magic/test && python3 ./run.py diff --git a/test/docker/centos7 b/test/docker/centos7 new file mode 100644 index 0000000..f2ac6e4 --- /dev/null +++ b/test/docker/centos7 @@ -0,0 +1,5 @@ +FROM centos:7 +RUN yum -y update +RUN yum -y install file-devel python3 python2 which +COPY . /python-magic +CMD cd /python-magic/test && SKIP_FROM_DESCRIPTOR=1 python3 ./run.py diff --git a/test/docker/centos8 b/test/docker/centos8 new file mode 100644 index 0000000..968f6b6 --- /dev/null +++ b/test/docker/centos8 @@ -0,0 +1,9 @@ +FROM centos:8 +RUN yum -y update +RUN yum -y install file-libs python3 python2 which glibc-locale-source +RUN yum reinstall glibc-common -y && \ + localedef -i en_US -f UTF-8 en_US.UTF-8 && \ + echo "LANG=en_US.UTF-8" > /etc/locale.conf +ENV LANG en_US.UTF-8 +COPY . /python-magic +CMD cd /python-magic/test && python3 ./run.py diff --git a/test/docker/focal b/test/docker/focal new file mode 100755 index 0000000..74e4d78 --- /dev/null +++ b/test/docker/focal @@ -0,0 +1,8 @@ +FROM ubuntu:focal +RUN apt-get update +RUN apt-get -y install python2 +RUN apt-get -y install python3 +RUN apt-get -y install locales +RUN locale-gen en_US.UTF-8 +COPY . /python-magic +CMD cd /python-magic/test && python3 ./run.py diff --git a/test/docker/xenial b/test/docker/xenial new file mode 100755 index 0000000..bc0440b --- /dev/null +++ b/test/docker/xenial @@ -0,0 +1,8 @@ +FROM ubuntu:xenial +RUN apt-get update +RUN apt-get -y install python +RUN apt-get -y install python3 +RUN apt-get -y install locales +RUN locale-gen en_US.UTF-8 +COPY . /python-magic +CMD cd /python-magic/test && python3 ./run.py diff --git a/test_docker.sh b/test_docker.sh index 57d5328..59d6b7c 100755 --- a/test_docker.sh +++ b/test_docker.sh @@ -5,17 +5,8 @@ set -e -function TestInContainer { - local name="$1" - local TAG="python_magic/${name}:latest" - docker build -t $TAG -f "test/Dockerfile_${name}" . - docker run "python_magic/${name}:latest" -} +NAME=`basename $1` +TAG="python_magic/${NAME}:latest" +docker build -t $TAG -f $1 . +docker run $TAG -TestInContainer "xenial" -TestInContainer "bionic" -TestInContainer "focal" -TestInContainer "centos7" -TestInContainer "centos8" -TestInContainer "archlinux" -TestInContainer "alpine" -- cgit v1.2.1