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