Skip to content

Commit edd51a8

Browse files
committed
Consolidating all installations to requirements.txt and other minor
fixes
1 parent 48bf566 commit edd51a8

File tree

11 files changed

+80
-57
lines changed

11 files changed

+80
-57
lines changed

.github/workflows/parallel_tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ on:
2020
jobs:
2121

2222
test_installer: # test install_ubuntu.sh
23-
runs-on: panda-arc # Note 22.04 would work, but it requires docker > 20.10.7 which is not on our CI box (yet)
23+
runs-on: panda-arc
2424
container:
25-
image: ubuntu:20.04
25+
image: ubuntu:22.04
2626
steps:
2727
- name: Update
2828
run: apt-get -qq update -y
@@ -31,9 +31,9 @@ jobs:
3131
- name: Set up Python
3232
uses: actions/setup-python@v5
3333
with:
34-
python-version: 3.9
34+
python-version: '3.10'
3535
- name: Install Python dev headers
36-
run: apt-get -qq install -y libpython3.9-dev
36+
run: apt-get -qq install -y libpython3.10-dev
3737
- uses: actions/checkout@v4 # Clones to $GITHUB_WORKSPACE. NOTE: this requires git > 2.18 (not on ubuntu 18.04 by default) to get .git directory
3838
- name: Lint PyPANDA with flake8
3939
run: |

Dockerfile

Lines changed: 54 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
ARG BASE_IMAGE="ubuntu:20.04"
22
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/"
44

55
### BASE IMAGE
6-
FROM $BASE_IMAGE as base
6+
FROM $BASE_IMAGE AS base
77
ARG BASE_IMAGE
8+
ARG INSTALL_PREFIX
89

910
# Copy dependencies lists into container. We copy them all and then do a mv because
1011
# 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 &
1617
# Base image just needs runtime dependencies
1718
RUN [ -e /tmp/base_dep.txt ] && \
1819
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 '^[^#]*') && \
2021
apt-get clean
2122

2223
### BUILD IMAGE - STAGE 2
2324
FROM base AS builder
2425
ARG BASE_IMAGE
2526
ARG TARGET_LIST
26-
ARG LIBOSI_VERSION
27+
ARG INSTALL_PREFIX
2728

2829
RUN [ -e /tmp/build_dep.txt ] && \
2930
apt-get -qq update && \
3031
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends $(cat /tmp/build_dep.txt | grep -o '^[^#]*') && \
3132
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" && \
3533
curl https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal
3634

3735
# Then install capstone from source
@@ -43,24 +41,31 @@ RUN cd /tmp && \
4341
ENV PATH="/root/.cargo/bin:${PATH}"
4442

4543
# 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
4750

4851
# Build and install panda
4952
# Copy repo root directory to /panda, note we explicitly copy in .git directory
5053
# 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)
5155
COPY . /panda/
5256
COPY .git /panda/
57+
RUN pip install -r /panda/panda/python/core/requirements.txt
5358

5459
# Note we diable NUMA for docker builds because it causes make check to fail in docker
5560
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 && \
5762
mkdir /panda/build && cd /panda/build && \
5863
python3 -m pip install setuptools_scm && \
5964
python3 -m pip install build && \
6065
python3 -m setuptools_scm -r .. --strip-dev 2>/dev/null >/tmp/savedversion && \
6166
/panda/configure \
6267
--target-list="${TARGET_LIST}" \
63-
--prefix=/usr/local \
68+
--prefix=${INSTALL_PREFIX} \
6469
--disable-numa \
6570
--enable-llvm && \
6671
rm -rf /panda/.git
@@ -69,7 +74,8 @@ RUN git -C /panda submodule update --init dtc && \
6974
RUN PRETEND_VERSION=$(cat /tmp/savedversion) make -C /panda/build -j "$(nproc)"
7075

7176
#### Develop setup: panda built + pypanda installed (in develop mode) - Stage 3
72-
FROM builder as developer
77+
FROM builder AS developer
78+
ARG INSTALL_PREFIX
7379
RUN cd /panda/panda/python/core && \
7480
python3 create_panda_datatypes.py && \
7581
PRETEND_VERSION=$(cat /tmp/savedversion) pip install -e . && \
@@ -82,22 +88,19 @@ RUN cd /panda/panda/python/core && \
8288
WORKDIR /panda/
8389

8490
#### Install PANDA + pypanda from builder - Stage 4
85-
FROM builder as installer
91+
FROM builder AS installer
92+
ARG INSTALL_PREFIX
8693
RUN make -C /panda/build install && \
87-
rm -r /usr/local/lib/panda/*/cosi \
88-
/usr/local/lib/panda/*/cosi_strace \
89-
/usr/local/lib/panda/*/gdb \
90-
/usr/local/lib/panda/*/snake_hook \
91-
/usr/local/lib/panda/*/rust_skeleton
94+
rm -r ${INSTALL_PREFIX}lib/panda/*/cosi \
95+
${INSTALL_PREFIX}lib/panda/*/cosi_strace \
96+
${INSTALL_PREFIX}lib/panda/*/gdb \
97+
${INSTALL_PREFIX}lib/panda/*/snake_hook \
98+
${INSTALL_PREFIX}lib/panda/*/rust_skeleton
9299

93-
# Install pypanda
94-
RUN cd /panda/panda/python/core && \
95-
python3 create_panda_datatypes.py --install && \
96-
PRETEND_VERSION=$(cat /tmp/savedversion) pip install .
97-
RUN python3 -m pip install --ignore-install pycparser && python3 -m pip install --force-reinstall --no-binary :all: cffi
98-
# Build a whl too
100+
# Install pypanda and build wheel
99101
RUN cd /panda/panda/python/core && \
100102
python3 create_panda_datatypes.py --install && \
103+
PRETEND_VERSION=$(cat /tmp/savedversion) pip install . && \
101104
PRETEND_VERSION=$(cat /tmp/savedversion) python3 -m build --wheel .
102105

103106
# BUG: PANDA sometimes fails to generate all the necessary files for PyPANDA. This is a temporary fix to detect and fail when this occurs
@@ -106,41 +109,53 @@ RUN bash -c "ls $(pip show pandare | grep Location: | awk '{print $2}')/pandare/
106109

107110
# this layer is used to strip shared objects and change python data to be
108111
# symlinks to the installed panda data directory
109-
FROM installer as cleanup
110-
RUN find /usr/local/lib/panda -name "*.so" -exec strip {} \;
112+
FROM installer AS cleanup
113+
ARG INSTALL_PREFIX
114+
RUN find ${INSTALL_PREFIX}lib/panda -name "*.so" -exec strip {} \;
111115
RUN PKG=`pip show pandare | grep Location: | awk '{print $2}'`/pandare/data; \
112-
rm -rf $PKG/pc-bios && ln -s /usr/local/share/panda $PKG/pc-bios; \
116+
rm -rf $PKG/pc-bios && ln -s ${INSTALL_PREFIX}share/panda $PKG/pc-bios; \
113117
for arch in `find $PKG -name "*-softmmu" -type d -exec basename {} \;` ; do \
114118
ARCHP=$PKG/$arch; \
115119
SARCH=`echo $arch | cut -d'-' -f 1`; \
116120
rm $ARCHP/libpanda-$SARCH.so $ARCHP/llvm-helpers-$SARCH.bc; \
117-
ln -s /usr/local/share/panda/llvm-helpers-$SARCH.bc $ARCHP/llvm-helpers-$SARCH.bc1; \
118-
ln -s /usr/local/bin/libpanda-$SARCH.so $ARCHP/libpanda-$SARCH.so; \
121+
ln -s ${INSTALL_PREFIX}share/panda/llvm-helpers-$SARCH.bc $ARCHP/llvm-helpers-$SARCH.bc1; \
122+
ln -s ${INSTALL_PREFIX}bin/libpanda-$SARCH.so $ARCHP/libpanda-$SARCH.so; \
119123
rm -rf $ARCHP/panda/plugins; \
120-
ln -s /usr/local/lib/panda/$SARCH/ $ARCHP/panda/plugins; \
124+
ln -s ${INSTALL_PREFIX}lib/panda/$SARCH/ $ARCHP/panda/plugins; \
121125
done
122126

123127
### Copy files for panda+pypanda from installer - Stage 5
124-
FROM base as panda
128+
FROM base AS panda
129+
ARG INSTALL_PREFIX
130+
ARG TARGET_LIST
125131

126132
# Include dependency lists for packager
127133
COPY --from=base /tmp/base_dep.txt /tmp
128134
COPY --from=base /tmp/build_dep.txt /tmp
129135

130136
# Copy panda + libcapstone.so* + libosi libraries
131-
COPY --from=cleanup /usr/local /usr/local
137+
COPY --from=cleanup ${INSTALL_PREFIX} ${INSTALL_PREFIX}
132138
COPY --from=cleanup /usr/lib/libcapstone* /usr/lib/
133-
COPY --from=cleanup /lib/libosi.so /lib/libiohal.so /lib/liboffset.so /lib/
139+
# TODO: Once PR, https://github.com/panda-re/libosi/pull/17 is in, libosi installs to /usr/lib/x86_64-linux-gnu instead of /usr/lib
140+
COPY --from=cleanup /usr/lib/libosi.so /usr/lib/libiohal.so /usr/lib/liboffset.so /usr/lib/x86_64-linux-gnu/
134141

135142
# Workaround issue #901 - ensure LD_LIBRARY_PATH contains the panda plugins directories
136-
#ARG TARGET_LIST="x86_64-softmmu,i386-softmmu,arm-softmmu,ppc-softmmu,mips-softmmu,mipsel-softmmu"
137-
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/
138-
#PANDA_PATH is used by rust plugins
139-
ENV PANDA_PATH /usr/local/lib/python3.8/dist-packages/pandare/data
140-
143+
RUN LD_LIBRARY_PATH="" && \
144+
for arch in $(echo $TARGET_LIST | tr ',' ' '); do \
145+
if [ -z "$LD_LIBRARY_PATH" ]; then \
146+
LD_LIBRARY_PATH="${INSTALL_PREFIX}lib/python3.8/dist-packages/pandare/data/${arch}/panda/plugins/"; \
147+
else \
148+
LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${INSTALL_PREFIX}lib/python3.8/dist-packages/pandare/data/${arch}/panda/plugins/"; \
149+
fi \
150+
done && \
151+
echo "${LD_LIBRARY_PATH}" > /tmp/ld_library_path
152+
ENV LD_LIBRARY_PATH $(cat /tmp/ld_library_path)
153+
154+
# PANDA_PATH is used by rust plugins
155+
ENV PANDA_PATH ${INSTALL_PREFIX}lib/python3.8/dist-packages/pandare/data
141156

142157
# Ensure runtime dependencies are installed for our libpanda objects and panda plugins
143158
RUN ldconfig && \
144159
update-alternatives --install /usr/bin/python python /usr/bin/python3 10 && \
145-
if (ldd /usr/local/lib/python*/dist-packages/pandare/data/*-softmmu/libpanda-*.so | grep 'not found'); then exit 1; fi && \
146-
if (ldd /usr/local/lib/python*/dist-packages/pandare/data/*-softmmu/panda/plugins/*.so | grep 'not found'); then exit 1; fi
160+
if (ldd ${INSTALL_PREFIX}lib/python*/dist-packages/pandare/data/*-softmmu/libpanda-*.so | grep 'not found'); then exit 1; fi && \
161+
if (ldd ${INSTALL_PREFIX}lib/python*/dist-packages/pandare/data/*-softmmu/panda/plugins/*.so | grep 'not found'); then exit 1; fi

panda/debian/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
panda.deb
1+
*.deb
2+
*.whl

panda/dependencies/ubuntu_18.04_base.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ unzip
1818
# pyperipheral (only needed for armel)
1919
libpython3-dev
2020

21-
# pypanda dependencies
21+
# panda python dependencies
2222
genisoimage
2323
libffi-dev
2424
python3-protobuf

panda/dependencies/ubuntu_20.04_base.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ wget
1717
# pyperipheral (only needed for armel)
1818
libpython3-dev
1919

20-
# pypanda dependencies
20+
# panda python dependencies
2121
genisoimage
2222
libffi-dev
2323
python3-protobuf

panda/dependencies/ubuntu_22.04_base.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ wget
1717
# pyperipheral (only needed for armel)
1818
libpython3-dev
1919

20-
# pypanda dependencies
20+
# panda python dependencies
2121
genisoimage
2222
libffi-dev
2323
python3-protobuf
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Jinja2==3.1.2
1+
Jinja2>=3.1.4
22
MarkupSafe==2.1.3

panda/python/core/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ data
88
a
99
__pycache__
1010
*.egg-info
11+
.eggs/

panda/python/core/pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ requires-python = ">=3.6"
3434
dependencies = [
3535
"cffi>=1.14.3",
3636
"protobuf>=4.25.1",
37-
"colorama"
37+
"colorama",
38+
"capstone==5.0.3"
3839
]
3940

4041
[tool.setuptools_scm]

panda/python/core/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
cffi>=1.14.3
22
protobuf>=4.25.1
33
colorama
4+
capstone==5.0.3

panda/scripts/install_ubuntu.sh

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,15 @@ fi
2323
# Note package names should be consistent across Ubuntu versions.
2424
lsb_release --help &>/dev/null || $SUDO apt-get update -qq && $SUDO apt-get -qq install -y --no-install-recommends lsb-release
2525
git --help &>/dev/null || $SUDO apt-get -qq update && $SUDO apt-get -qq install -y --no-install-recommends git
26+
$SUDO apt-get install -y --no-install-recommends curl jq
2627

2728
# some globals
28-
LIBOSI_VERSION="0.1.7"
29+
# TODO: Why is curl -s failing in panda-arc? For now, I'll put a fallback version
30+
LIBOSI_VERSION=$(curl -s https://api.github.com/repos/panda-re/libosi/releases/latest | jq -r .tag_name)
31+
if [ -z "$LIBOSI_VERSION" ]; then
32+
# TODO: Update this, once this PR is in, https://github.com/panda-re/libosi/pull/17
33+
LIBOSI_VERSION="v0.1.9"
34+
fi
2935
UBUNTU_VERSION=$(lsb_release -r | awk '{print $2}')
3036
PANDA_GIT="https://github.com/panda-re/panda.git"
3137

@@ -76,7 +82,6 @@ if [ $version -eq 18 ]; then
7682
$SUDO apt-get update
7783
fi
7884

79-
8085
# Dependencies are for a major version, but the filenames include minor versions
8186
# So take our major version, find the first match in dependencies directory and run with it.
8287
# This will give us "./panda/dependencies/ubuntu:20.04" where ubuntu:20.04_build.txt or 20.04_base.txt exists
@@ -120,17 +125,12 @@ fi
120125
# if the windows introspection library is not installed, clone and install
121126
if [[ !$(dpkg -l | grep -q libosi) ]]; then
122127
pushd /tmp
123-
curl -LJO https://github.com/panda-re/libosi/releases/download/v${LIBOSI_VERSION}/libosi_${UBUNTU_VERSION}.deb
128+
curl -LJO https://github.com/panda-re/libosi/releases/download/${LIBOSI_VERSION}/libosi_${UBUNTU_VERSION}.deb
124129
$SUDO dpkg -i /tmp/libosi_${UBUNTU_VERSION}.deb
125130
rm -rf /tmp/libosi_${UBUNTU_VERSION}.deb
126131
popd
127132
fi
128133

129-
# PyPANDA needs CFFI from pip (the version in apt is too old)
130-
# Install system-wide since PyPANDA install will also be system-wide
131-
$SUDO python3 -m pip install pip
132-
$SUDO python3 -m pip install "cffi>1.14.3"
133-
134134
progress "Trying to update DTC submodule"
135135
git submodule update --init dtc || true
136136

@@ -139,6 +139,10 @@ if [ -d "build" ]; then
139139
rm -rf "build"
140140
fi
141141

142+
# PyPANDA needs CFFI from pip (the version in apt is too old)
143+
# Install system-wide since PyPANDA install will also be system-wide
144+
$SUDO pip install -r ./panda/python/core/requirements.txt
145+
142146
progress "Building PANDA..."
143147
mkdir build
144148
pushd build

0 commit comments

Comments
 (0)