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