Skip to content

Commit

Permalink
Containerised build environment
Browse files Browse the repository at this point in the history
Create a Dockerfile to enable a portable build environment. The Dockerfile is based on Ubuntu 24.04, and uses multiple stages to produce a minimal final product, with the final image size sitting at about 75mb.
This branch also incorporates the updates prepared by @cole-h to update to squashfs-tools 4.4 in devttys0#56.
Finally, building on newer GCC highlights a dangling pointer error in LzmaEnc.c. I have separated the fix for this problem into a dedicated patch file for ease of review.
  • Loading branch information
aliask committed Oct 16, 2024
1 parent bd864a1 commit 9fc10a3
Show file tree
Hide file tree
Showing 4 changed files with 4,778 additions and 4,503 deletions.
40 changes: 40 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FROM ubuntu:24.04 AS builder

RUN --mount=type=cache,target=/var/cache/apt,id=builder-apt-cache \
--mount=type=cache,target=/var/lib/apt,id=builder-apt-lib \
apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
git \
liblzma-dev \
liblzo2-dev \
patch \
zlib1g-dev \
&& mkdir -p /sasquatch

WORKDIR /sasquatch

ADD https://downloads.sourceforge.net/project/squashfs/squashfs/squashfs4.4/squashfs4.4.tar.gz .
RUN tar -zxvf squashfs4.4.tar.gz

COPY patches /sasquatch/patches
RUN patch -d squashfs4.4 -p1 < patches/0_sasquatch_4.4.patch && \
patch -d squashfs4.4 -p1 < patches/1_fix_dangling_pointer.patch && \
cd squashfs4.4/squashfs-tools && \
make

FROM ubuntu:24.04

RUN --mount=type=cache,target=/var/cache/apt,id=runtime-apt-cache \
--mount=type=cache,target=/var/lib/apt,id=runtime-apt-lib \
apt-get update && \
apt-get install -y --no-install-recommends \
liblzma5 \
liblzo2-2 \
zlib1g

COPY --from=builder /sasquatch/squashfs4.4/squashfs-tools/sasquatch /usr/local/bin/sasquatch

WORKDIR /work

ENTRYPOINT [ "/usr/local/bin/sasquatch" ]
20 changes: 10 additions & 10 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# Script to download squashfs-tools v4.3, apply the patches, perform a clean build, and install.
# Script to download squashfs-tools v4.4, apply the patches, perform a clean build, and install.

# If not root, perform 'make install' with sudo
if [ $UID -eq 0 ]
Expand All @@ -18,20 +18,20 @@ fi
# Make sure we're working in the same directory as the build.sh script
cd $(dirname `readlink -f $0`)

# Download squashfs4.3.tar.gz if it does not already exist
if [ ! -e squashfs4.3.tar.gz ]
# Download squashfs4.4.tar.gz if it does not already exist
if [ ! -e squashfs4.4.tar.gz ]
then
wget https://downloads.sourceforge.net/project/squashfs/squashfs/squashfs4.3/squashfs4.3.tar.gz
wget https://downloads.sourceforge.net/project/squashfs/squashfs/squashfs4.4/squashfs4.4.tar.gz
fi

# Remove any previous squashfs4.3 directory to ensure a clean patch/build
rm -rf squashfs4.3
# Remove any previous squashfs4.4 directory to ensure a clean patch/build
rm -rf squashfs4.4

# Extract squashfs4.3.tar.gz
tar -zxvf squashfs4.3.tar.gz
# Extract squashfs4.4.tar.gz
tar -zxvf squashfs4.4.tar.gz

# Patch, build, and install the source
cd squashfs4.3
patch -p0 < ../patches/patch0.txt
cd squashfs4.4
patch -p1 < ../patches/*.patch
cd squashfs-tools
make && $SUDO make install
Loading

0 comments on commit 9fc10a3

Please sign in to comment.