Skip to content

Commit b57a68a

Browse files
committed
Prebuild fw2tar dependencies
1 parent 8911a6a commit b57a68a

File tree

1 file changed

+29
-12
lines changed

1 file changed

+29
-12
lines changed

Dockerfile

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,29 @@ RUN if [ ! -z "${OVERRIDE_VERSION}" ]; then \
295295
echo "Generating version from git"; \
296296
fi;
297297

298+
### Build fw2tar deps ahead of time ###
299+
FROM $BASE_IMAGE as fw2tar_dep_builder
300+
ENV DEBIAN_FRONTEND=noninteractive
301+
302+
COPY ./dependencies/fw2tar.txt /tmp/fw2tar.txt
303+
RUN apt-get update && apt-get install -y -q git $(cat /tmp/fw2tar.txt)
304+
305+
ARG DOWNLOAD_TOKEN
306+
ARG FW2TAR_TAG
307+
RUN git clone --depth=1 -b ${FW2TAR_TAG} https://${DOWNLOAD_TOKEN}:@github.com/rehosting/fw2tar.git /tmp/fw2tar
308+
RUN git clone --depth=1 https://github.com/davidribyrne/cramfs.git /cramfs && \
309+
cd /cramfs && make
310+
RUN git clone --depth=1 https://github.com/rehosting/unblob.git /unblob
311+
312+
RUN mkdir -p -m 0600 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts
313+
ARG SSH
314+
RUN --mount=type=ssh git clone git@github.com:rehosting/fakeroot.git /fakeroot && \
315+
sed -i 's/^# deb-src/deb-src/' /etc/apt/sources.list && \
316+
apt-get update && apt-get build-dep -y fakeroot && \
317+
cd /fakeroot && ./bootstrap && ./configure && make || true
318+
319+
# Create empty directory to copy if it doesn't exist
320+
RUN mkdir /fakeroot || true
298321

299322
### MAIN CONTAINER ###
300323
FROM $BASE_IMAGE AS penguin
@@ -437,16 +460,14 @@ CMD ["/usr/local/bin/banner.sh"]
437460
COPY ./local_package[s] /tmp/local_packages
438461

439462
# ====================== Finish setting up fw2tar ======================
440-
ARG DOWNLOAD_TOKEN
441-
ARG FW2TAR_TAG
442-
RUN git clone --depth=1 -b ${FW2TAR_TAG} https://${DOWNLOAD_TOKEN}:@github.com/rehosting/fw2tar.git /tmp/fw2tar
463+
COPY --from=fw2tar_dep_builder /tmp/fw2tar /tmp/fw2tar
443464

444465
# CramFS no longer in apt - needed by binwalk
445-
RUN git clone --depth=1 https://github.com/davidribyrne/cramfs.git /cramfs && \
446-
cd /cramfs && make && make install
466+
COPY --from=fw2tar_dep_builder /cramfs /cramfs
467+
RUN cd /cramfs && make && make install
447468

448469
# Clone unblob fork then install with poetry
449-
RUN git clone --depth=1 https://github.com/rehosting/unblob.git /unblob
470+
COPY --from=fw2tar_dep_builder /unblob /unblob
450471
RUN cd /unblob && poetry install --no-dev
451472

452473
# Explicitly install unblob deps - mostly captured above, but some of the .debs get updated and installed via curl
@@ -459,12 +480,8 @@ RUN chmod -R 777 /root/
459480
# Try to install custom fakeroot. This is optional - we have regular fakeroot. If we're building
460481
# with host SSH keys, we can do this, otherwise we'll just skip it
461482
# Setup ssh keys for github.com
462-
RUN mkdir -p -m 0600 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts
463-
ARG SSH
464-
RUN --mount=type=ssh git clone git@github.com:rehosting/fakeroot.git /fakeroot && \
465-
sed -i 's/^# deb-src/deb-src/' /etc/apt/sources.list && \
466-
apt-get update && apt-get build-dep -y fakeroot && \
467-
cd /fakeroot && ./bootstrap && ./configure && make && make install -k || true
483+
COPY --from=fw2tar_dep_builder /fakeroot /fakeroot
484+
RUN cd /fakeroot && make install -k || true
468485

469486
# Patch to fix unblob #767 that hasn't yet been upstreamed. Pip install didn't work. I don't understand poetry
470487
#RUN pip install git+https://github.com/qkaiser/arpy.git

0 commit comments

Comments
 (0)