1
1
ARG BASE_IMAGE="ubuntu:20.04"
2
2
ARG TARGET_LIST="x86_64-softmmu,i386-softmmu,arm-softmmu,aarch64-softmmu,ppc-softmmu,mips-softmmu,mipsel-softmmu,mips64-softmmu,mips64el-softmmu"
3
3
ARG LIBOSI_VERSION="v0.1.7"
4
+ ARG INSTALL_PREFIX="/usr/local"
4
5
5
6
# ## BASE IMAGE
6
7
FROM $BASE_IMAGE as base
7
8
ARG BASE_IMAGE
9
+ ARG INSTALL_PREFIX
8
10
9
11
# Copy dependencies lists into container. We copy them all and then do a mv because
10
12
# we need to transform base_image into a windows compatible filename which we can't
@@ -24,14 +26,12 @@ FROM base AS builder
24
26
ARG BASE_IMAGE
25
27
ARG TARGET_LIST
26
28
ARG LIBOSI_VERSION
29
+ ARG INSTALL_PREFIX
27
30
28
31
RUN [ -e /tmp/build_dep.txt ] && \
29
32
apt-get -qq update && \
30
33
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends $(cat /tmp/build_dep.txt | grep -o '^[^#]*' ) && \
31
34
apt-get clean && \
32
- python3 -m pip install --upgrade --no-cache-dir pip && \
33
- python3 -m pip install --upgrade --no-cache-dir "cffi>1.14.3" && \
34
- python3 -m pip install --upgrade --no-cache-dir "capstone" && \
35
35
curl https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal
36
36
37
37
# Then install capstone from source
@@ -48,18 +48,20 @@ RUN cd /tmp && curl -LJO https://github.com/panda-re/libosi/releases/download/${
48
48
# Build and install panda
49
49
# Copy repo root directory to /panda, note we explicitly copy in .git directory
50
50
# Note .dockerignore file keeps us from copying things we don't need
51
+ # PyPANDA needs CFFI from pip (the version in apt is too old)
51
52
COPY . /panda/
52
53
COPY .git /panda/
54
+ RUN pip install -r /panda/panda/python/core/requirements.txt
53
55
54
56
# Note we diable NUMA for docker builds because it causes make check to fail in docker
55
57
RUN git -C /panda submodule update --init dtc && \
56
- git -C /panda rev-parse HEAD > /usr/local /panda_commit_hash && \
58
+ git -C /panda rev-parse HEAD > ${INSTALL_PREFIX} /panda_commit_hash && \
57
59
mkdir /panda/build && cd /panda/build && \
58
60
python3 -m pip install setuptools_scm && \
59
61
python3 -m setuptools_scm -r .. --strip-dev 2>/dev/null >/tmp/savedversion && \
60
62
/panda/configure \
61
63
--target-list="${TARGET_LIST}" \
62
- --prefix=/usr/local \
64
+ --prefix=${INSTALL_PREFIX} \
63
65
--disable-numa \
64
66
--enable-llvm && \
65
67
rm -rf /panda/.git
@@ -69,9 +71,9 @@ RUN PRETEND_VERSION=$(cat /tmp/savedversion) make -C /panda/build -j "$(nproc)"
69
71
70
72
# ### Develop setup: panda built + pypanda installed (in develop mode) - Stage 3
71
73
FROM builder as developer
74
+ ARG INSTALL_PREFIX
72
75
RUN cd /panda/panda/python/core && \
73
76
PRETEND_VERSION=$(cat /tmp/savedversion) python3 setup.py develop && \
74
- ldconfig && \
75
77
update-alternatives --install /usr/bin/python python /usr/bin/python3 10 && \
76
78
cd /panda && \
77
79
( git config --get-regexp http > /dev/null && \
@@ -81,17 +83,17 @@ WORKDIR /panda/
81
83
82
84
# ### Install PANDA + pypanda from builder - Stage 4
83
85
FROM builder as installer
86
+ ARG INSTALL_PREFIX
84
87
RUN make -C /panda/build install && \
85
- rm -r /usr/local /lib/panda/*/cosi \
86
- /usr/local /lib/panda/*/cosi_strace \
87
- /usr/local /lib/panda/*/gdb \
88
- /usr/local /lib/panda/*/snake_hook \
89
- /usr/local /lib/panda/*/rust_skeleton
88
+ rm -r ${INSTALL_PREFIX} /lib/panda/*/cosi \
89
+ ${INSTALL_PREFIX} /lib/panda/*/cosi_strace \
90
+ ${INSTALL_PREFIX} /lib/panda/*/gdb \
91
+ ${INSTALL_PREFIX} /lib/panda/*/snake_hook \
92
+ ${INSTALL_PREFIX} /lib/panda/*/rust_skeleton
90
93
91
94
# Install pypanda
92
95
RUN cd /panda/panda/python/core && \
93
96
PRETEND_VERSION=$(cat /tmp/savedversion) python3 setup.py install
94
- RUN python3 -m pip install --ignore-install pycparser && python3 -m pip install --force-reinstall --no-binary :all: cffi
95
97
# Build a whl too
96
98
RUN cd /panda/panda/python/core && \
97
99
PRETEND_VERSION=$(cat /tmp/savedversion) python3 setup.py bdist_wheel
@@ -103,40 +105,46 @@ RUN bash -c "ls $(pip show pandare | grep Location: | awk '{print $2}')/pandare/
103
105
# this layer is used to strip shared objects and change python data to be
104
106
# symlinks to the installed panda data directory
105
107
FROM installer as cleanup
106
- RUN find /usr/local/lib/panda -name "*.so" -exec strip {} \;
108
+ ARG INSTALL_PREFIX
109
+ RUN find ${INSTALL_PREFIX}/lib/panda -name "*.so" -exec strip {} \;
107
110
RUN PKG=`pip show pandare | grep Location: | awk '{print $2}' `/pandare/data; \
108
- rm -rf $PKG/pc-bios && ln -s /usr/local /share/panda $PKG/pc-bios; \
111
+ rm -rf $PKG/pc-bios && ln -s ${INSTALL_PREFIX} /share/panda $PKG/pc-bios; \
109
112
for arch in `find $PKG -name "*-softmmu" -type d -exec basename {} \; ` ; do \
110
113
ARCHP=$PKG/$arch; \
111
114
SARCH=`echo $arch | cut -d'-' -f 1`; \
112
115
rm $ARCHP/libpanda-$SARCH.so $ARCHP/llvm-helpers-$SARCH.bc; \
113
- ln -s /usr/local /share/panda/llvm-helpers-$SARCH.bc $ARCHP/llvm-helpers-$SARCH.bc1; \
114
- ln -s /usr/local /bin/libpanda-$SARCH.so $ARCHP/libpanda-$SARCH.so; \
116
+ ln -s ${INSTALL_PREFIX} /share/panda/llvm-helpers-$SARCH.bc $ARCHP/llvm-helpers-$SARCH.bc1; \
117
+ ln -s ${INSTALL_PREFIX} /bin/libpanda-$SARCH.so $ARCHP/libpanda-$SARCH.so; \
115
118
rm -rf $ARCHP/panda/plugins; \
116
- ln -s /usr/local /lib/panda/$SARCH/ $ARCHP/panda/plugins; \
119
+ ln -s ${INSTALL_PREFIX} /lib/panda/$SARCH/ $ARCHP/panda/plugins; \
117
120
done
118
121
119
122
# ## Copy files for panda+pypanda from installer - Stage 5
120
123
FROM base as panda
124
+ ARG INSTALL_PREFIX
125
+ ARG TARGET_LIST
121
126
122
127
# Include dependency lists for packager
123
128
COPY --from=base /tmp/base_dep.txt /tmp
124
129
COPY --from=base /tmp/build_dep.txt /tmp
125
130
126
131
# Copy panda + libcapstone.so* + libosi libraries
127
- COPY --from=cleanup /usr/local /usr/local
132
+ COPY --from=cleanup ${INSTALL_PREFIX} ${INSTALL_PREFIX}
128
133
COPY --from=cleanup /usr/lib/libcapstone* /usr/lib/
129
134
COPY --from=cleanup /lib/libosi.so /lib/libiohal.so /lib/liboffset.so /lib/
130
135
131
136
# Workaround issue #901 - ensure LD_LIBRARY_PATH contains the panda plugins directories
132
- # ARG TARGET_LIST="x86_64-softmmu,i386-softmmu,arm-softmmu,ppc-softmmu,mips-softmmu,mipsel-softmmu"
133
- ENV LD_LIBRARY_PATH /usr/local/lib/python3.8/dist-packages/pandare/data/x86_64-softmmu/panda/plugins/:/usr/local/lib/python3.8/dist-packages/pandare/data/i386-softmmu/panda/plugins/:/usr/local/lib/python3.8/dist-packages/pandare/data/arm-softmmu/panda/plugins/:/usr/local/lib/python3.8/dist-packages/pandare/data/ppc-softmmu/panda/plugins/:/usr/local/lib/python3.8/dist-packages/pandare/data/mips-softmmu/panda/plugins/:/usr/local/lib/python3.8/dist-packages/pandare/data/mipsel-softmmu/panda/plugins/
134
- # PANDA_PATH is used by rust plugins
135
- ENV PANDA_PATH /usr/local/lib/python3.8/dist-packages/pandare/data
137
+ RUN LD_LIBRARY_PATH="" && \
138
+ for arch in $(echo $TARGET_LIST | tr ',' ' ' ); do \
139
+ LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${INSTALL_PREFIX}/lib/python3.8/dist-packages/pandare/data/${arch}/panda/plugins/" ; \
140
+ done && \
141
+ export LD_LIBRARY_PATH
136
142
143
+ # PANDA_PATH is used by rust plugins
144
+ ENV PANDA_PATH ${INSTALL_PREFIX}/lib/python3.8/dist-packages/pandare/data
137
145
138
146
# Ensure runtime dependencies are installed for our libpanda objects and panda plugins
139
147
RUN ldconfig && \
140
148
update-alternatives --install /usr/bin/python python /usr/bin/python3 10 && \
141
- if (ldd /usr/local /lib/python*/dist-packages/pandare/data/*-softmmu/libpanda-*.so | grep 'not found' ); then exit 1; fi && \
142
- if (ldd /usr/local /lib/python*/dist-packages/pandare/data/*-softmmu/panda/plugins/*.so | grep 'not found' ); then exit 1; fi
149
+ if (ldd ${INSTALL_PREFIX} /lib/python*/dist-packages/pandare/data/*-softmmu/libpanda-*.so | grep 'not found' ); then exit 1; fi && \
150
+ if (ldd ${INSTALL_PREFIX} /lib/python*/dist-packages/pandare/data/*-softmmu/panda/plugins/*.so | grep 'not found' ); then exit 1; fi
0 commit comments