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
@@ -53,13 +53,13 @@ COPY .git /panda/
53
53
54
54
# Note we diable NUMA for docker builds because it causes make check to fail in docker
55
55
RUN git -C /panda submodule update --init dtc && \
56
- git -C /panda rev-parse HEAD > /usr/local /panda_commit_hash && \
56
+ git -C /panda rev-parse HEAD > ${INSTALL_PREFIX} /panda_commit_hash && \
57
57
mkdir /panda/build && cd /panda/build && \
58
58
python3 -m pip install setuptools_scm && \
59
59
python3 -m setuptools_scm -r .. --strip-dev 2>/dev/null >/tmp/savedversion && \
60
60
/panda/configure \
61
61
--target-list="${TARGET_LIST}" \
62
- --prefix=/usr/local \
62
+ --prefix=${INSTALL_PREFIX} \
63
63
--disable-numa \
64
64
--enable-llvm && \
65
65
rm -rf /panda/.git
@@ -69,9 +69,9 @@ RUN PRETEND_VERSION=$(cat /tmp/savedversion) make -C /panda/build -j "$(nproc)"
69
69
70
70
# ### Develop setup: panda built + pypanda installed (in develop mode) - Stage 3
71
71
FROM builder as developer
72
+ ARG INSTALL_PREFIX
72
73
RUN cd /panda/panda/python/core && \
73
74
PRETEND_VERSION=$(cat /tmp/savedversion) python3 setup.py develop && \
74
- ldconfig && \
75
75
update-alternatives --install /usr/bin/python python /usr/bin/python3 10 && \
76
76
cd /panda && \
77
77
( git config --get-regexp http > /dev/null && \
@@ -81,17 +81,17 @@ WORKDIR /panda/
81
81
82
82
# ### Install PANDA + pypanda from builder - Stage 4
83
83
FROM builder as installer
84
+ ARG INSTALL_PREFIX
84
85
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
86
+ rm -r ${INSTALL_PREFIX} /lib/panda/*/cosi \
87
+ ${INSTALL_PREFIX} /lib/panda/*/cosi_strace \
88
+ ${INSTALL_PREFIX} /lib/panda/*/gdb \
89
+ ${INSTALL_PREFIX} /lib/panda/*/snake_hook \
90
+ ${INSTALL_PREFIX} /lib/panda/*/rust_skeleton
90
91
91
92
# Install pypanda
92
93
RUN cd /panda/panda/python/core && \
93
94
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
95
# Build a whl too
96
96
RUN cd /panda/panda/python/core && \
97
97
PRETEND_VERSION=$(cat /tmp/savedversion) python3 setup.py bdist_wheel
@@ -103,40 +103,46 @@ RUN bash -c "ls $(pip show pandare | grep Location: | awk '{print $2}')/pandare/
103
103
# this layer is used to strip shared objects and change python data to be
104
104
# symlinks to the installed panda data directory
105
105
FROM installer as cleanup
106
- RUN find /usr/local/lib/panda -name "*.so" -exec strip {} \;
106
+ ARG INSTALL_PREFIX
107
+ RUN find ${INSTALL_PREFIX}/lib/panda -name "*.so" -exec strip {} \;
107
108
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; \
109
+ rm -rf $PKG/pc-bios && ln -s ${INSTALL_PREFIX} /share/panda $PKG/pc-bios; \
109
110
for arch in `find $PKG -name "*-softmmu" -type d -exec basename {} \; ` ; do \
110
111
ARCHP=$PKG/$arch; \
111
112
SARCH=`echo $arch | cut -d'-' -f 1`; \
112
113
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; \
114
+ ln -s ${INSTALL_PREFIX} /share/panda/llvm-helpers-$SARCH.bc $ARCHP/llvm-helpers-$SARCH.bc1; \
115
+ ln -s ${INSTALL_PREFIX} /bin/libpanda-$SARCH.so $ARCHP/libpanda-$SARCH.so; \
115
116
rm -rf $ARCHP/panda/plugins; \
116
- ln -s /usr/local /lib/panda/$SARCH/ $ARCHP/panda/plugins; \
117
+ ln -s ${INSTALL_PREFIX} /lib/panda/$SARCH/ $ARCHP/panda/plugins; \
117
118
done
118
119
119
120
# ## Copy files for panda+pypanda from installer - Stage 5
120
121
FROM base as panda
122
+ ARG INSTALL_PREFIX
123
+ ARG TARGET_LIST
121
124
122
125
# Include dependency lists for packager
123
126
COPY --from=base /tmp/base_dep.txt /tmp
124
127
COPY --from=base /tmp/build_dep.txt /tmp
125
128
126
129
# Copy panda + libcapstone.so* + libosi libraries
127
- COPY --from=cleanup /usr/local /usr/local
130
+ COPY --from=cleanup ${INSTALL_PREFIX} ${INSTALL_PREFIX}
128
131
COPY --from=cleanup /usr/lib/libcapstone* /usr/lib/
129
132
COPY --from=cleanup /lib/libosi.so /lib/libiohal.so /lib/liboffset.so /lib/
130
133
131
134
# 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
135
+ RUN LD_LIBRARY_PATH="" && \
136
+ for arch in $(echo $TARGET_LIST | tr ',' ' ' ); do \
137
+ LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${INSTALL_PREFIX}/lib/python3.8/dist-packages/pandare/data/${arch}/panda/plugins/" ; \
138
+ done && \
139
+ export LD_LIBRARY_PATH
136
140
141
+ # PANDA_PATH is used by rust plugins
142
+ ENV PANDA_PATH ${INSTALL_PREFIX}/lib/python3.8/dist-packages/pandare/data
137
143
138
144
# Ensure runtime dependencies are installed for our libpanda objects and panda plugins
139
145
RUN ldconfig && \
140
146
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
147
+ if (ldd ${INSTALL_PREFIX} /lib/python*/dist-packages/pandare/data/*-softmmu/libpanda-*.so | grep 'not found' ); then exit 1; fi && \
148
+ if (ldd ${INSTALL_PREFIX} /lib/python*/dist-packages/pandare/data/*-softmmu/panda/plugins/*.so | grep 'not found' ); then exit 1; fi
0 commit comments