Skip to content

Commit 3cef0bf

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

File tree

9 files changed

+78
-51
lines changed

9 files changed

+78
-51
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: 52 additions & 34 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,20 +88,20 @@ 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

93100
# Install pypanda
94101
RUN cd /panda/panda/python/core && \
95102
python3 create_panda_datatypes.py --install && \
96103
PRETEND_VERSION=$(cat /tmp/savedversion) pip install .
97104
RUN python3 -m pip install --ignore-install pycparser && python3 -m pip install --force-reinstall --no-binary :all: cffi
98-
# Build a whl too
99105
RUN cd /panda/panda/python/core && \
100106
python3 create_panda_datatypes.py --install && \
101107
PRETEND_VERSION=$(cat /tmp/savedversion) python3 -m build --wheel .
@@ -106,41 +112,53 @@ RUN bash -c "ls $(pip show pandare | grep Location: | awk '{print $2}')/pandare/
106112

107113
# this layer is used to strip shared objects and change python data to be
108114
# symlinks to the installed panda data directory
109-
FROM installer as cleanup
110-
RUN find /usr/local/lib/panda -name "*.so" -exec strip {} \;
115+
FROM installer AS cleanup
116+
ARG INSTALL_PREFIX
117+
RUN find ${INSTALL_PREFIX}lib/panda -name "*.so" -exec strip {} \;
111118
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; \
119+
rm -rf $PKG/pc-bios && ln -s ${INSTALL_PREFIX}share/panda $PKG/pc-bios; \
113120
for arch in `find $PKG -name "*-softmmu" -type d -exec basename {} \;` ; do \
114121
ARCHP=$PKG/$arch; \
115122
SARCH=`echo $arch | cut -d'-' -f 1`; \
116123
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; \
124+
ln -s ${INSTALL_PREFIX}share/panda/llvm-helpers-$SARCH.bc $ARCHP/llvm-helpers-$SARCH.bc1; \
125+
ln -s ${INSTALL_PREFIX}bin/libpanda-$SARCH.so $ARCHP/libpanda-$SARCH.so; \
119126
rm -rf $ARCHP/panda/plugins; \
120-
ln -s /usr/local/lib/panda/$SARCH/ $ARCHP/panda/plugins; \
127+
ln -s ${INSTALL_PREFIX}lib/panda/$SARCH/ $ARCHP/panda/plugins; \
121128
done
122129

123130
### Copy files for panda+pypanda from installer - Stage 5
124-
FROM base as panda
131+
FROM base AS panda
132+
ARG INSTALL_PREFIX
133+
ARG TARGET_LIST
125134

126135
# Include dependency lists for packager
127136
COPY --from=base /tmp/base_dep.txt /tmp
128137
COPY --from=base /tmp/build_dep.txt /tmp
129138

130139
# Copy panda + libcapstone.so* + libosi libraries
131-
COPY --from=cleanup /usr/local /usr/local
140+
COPY --from=cleanup ${INSTALL_PREFIX} ${INSTALL_PREFIX}
132141
COPY --from=cleanup /usr/lib/libcapstone* /usr/lib/
133-
COPY --from=cleanup /lib/libosi.so /lib/libiohal.so /lib/liboffset.so /lib/
142+
# 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
143+
COPY --from=cleanup /usr/lib/libosi.so /usr/lib/libiohal.so /usr/lib/liboffset.so /usr/lib/x86_64-linux-gnu/
134144

135145
# 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-
146+
RUN LD_LIBRARY_PATH="" && \
147+
for arch in $(echo $TARGET_LIST | tr ',' ' '); do \
148+
if [ -z "$LD_LIBRARY_PATH" ]; then \
149+
LD_LIBRARY_PATH="${INSTALL_PREFIX}lib/python3.8/dist-packages/pandare/data/${arch}/panda/plugins/"; \
150+
else \
151+
LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${INSTALL_PREFIX}lib/python3.8/dist-packages/pandare/data/${arch}/panda/plugins/"; \
152+
fi \
153+
done && \
154+
echo "${LD_LIBRARY_PATH}" > /tmp/ld_library_path
155+
ENV LD_LIBRARY_PATH $(cat /tmp/ld_library_path)
156+
157+
# PANDA_PATH is used by rust plugins
158+
ENV PANDA_PATH ${INSTALL_PREFIX}lib/python3.8/dist-packages/pandare/data
141159

142160
# Ensure runtime dependencies are installed for our libpanda objects and panda plugins
143161
RUN ldconfig && \
144162
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
163+
if (ldd ${INSTALL_PREFIX}lib/python*/dist-packages/pandare/data/*-softmmu/libpanda-*.so | grep 'not found'); then exit 1; fi && \
164+
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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ 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
2525
python3-colorama
26+
python3-capstone
2627

2728
# apt-rdepends qemu-system-common
2829
acl

panda/dependencies/ubuntu_20.04_base.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@ 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
2424
python3-colorama
25+
python3-capstone
2526

2627
# Not sure what this one is needed for
2728
liblzo2-2

panda/dependencies/ubuntu_22.04_base.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@ 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
2424
python3-colorama
25+
python3-capstone
2526

2627
# Not sure what this one is needed for
2728
liblzo2-2
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/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)