Skip to content
This repository was archived by the owner on Jan 1, 2021. It is now read-only.

Commit 65b7041

Browse files
committed
Swap TCL's squashfs-tools for a static compiled version instead
For some reason, the latest 4.4 upload of squashfs-tools in TCL 10.x fails to extract many/most .tcz files from TCL. On the flip side, it's really easy to compile statically and the `Dockerfile` is much cleaner, so we're going with it.
1 parent 31e7643 commit 65b7041

3 files changed

Lines changed: 23 additions & 70 deletions

File tree

Dockerfile

Lines changed: 21 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -119,38 +119,27 @@ RUN mkdir -p proc; \
119119
echo -n docker > etc/sysconfig/tcuser; \
120120
tcl-chroot sh -c '. /etc/init.d/tc-functions && setupHome'
121121

122-
# packages (and their deps) that we either need for our "tce-load" patches or that dep on "...-KERNEL" which we don't need (since we build our own kernel)
123-
# http://distro.ibiblio.org/tinycorelinux/8.x/x86_64/tcz/squashfs-tools.tcz.dep
124-
# http://distro.ibiblio.org/tinycorelinux/8.x/x86_64/tcz/squashfs-tools.tcz.md5.txt
125-
# updated via "update.sh"
126-
ENV TCL_PACKAGES="squashfs-tools.tcz liblzma.tcz lzo.tcz libzstd.tcz" TCL_PACKAGE_MD5__squashfs_tools_tcz="a44331fa2117314e62267147b6876a49" TCL_PACKAGE_MD5__liblzma_tcz="846ce1b68690e46f61aff2f952da433f" TCL_PACKAGE_MD5__lzo_tcz="c9a1260675774c50cea1a490978b100d" TCL_PACKAGE_MD5__libzstd_tcz="a7f383473a4ced6c79e8b1a0cc9ad167"
127-
128-
RUN for package in $TCL_PACKAGES; do \
129-
eval 'md5="$TCL_PACKAGE_MD5__'"$(echo "$package" | sed -r 's/[^a-zA-Z0-9]+/_/g')"'"'; \
130-
echo "$md5 *$package" > "usr/local/tce.installed/optional/$package.md5.txt"; \
131-
for mirror in $TCL_MIRRORS; do \
132-
if \
133-
wget -O "usr/local/tce.installed/optional/$package" "$mirror/$TCL_MAJOR/x86_64/tcz/$package" \
134-
&& ( cd usr/local/tce.installed/optional && md5sum -c "$package.md5.txt" ) \
135-
; then \
136-
break; \
137-
fi; \
138-
done; \
139-
( cd usr/local/tce.installed/optional && md5sum -c "$package.md5.txt" ); \
140-
unsquashfs -dest . -force "usr/local/tce.installed/optional/$package"; \
141-
touch "usr/local/tce.installed/${package%.tcz}"; \
142-
# pretend this package has no deps (we already installed them)
143-
touch "usr/local/tce.installed/optional/$package.dep"; \
144-
done; \
145-
\
146-
tcl-chroot ldconfig; \
147-
for script in usr/local/tce.installed/*; do \
148-
[ -f "$script" ] || continue; \
149-
[ -x "$script" ] || continue; \
150-
tcl-chroot "$script"; \
151-
done; \
152-
\
153-
{ \
122+
# as of squashfs-tools 4.4, TCL's unsquashfs is broken... (fails to unsquashfs *many* core tcz files)
123+
# https://github.com/plougher/squashfs-tools/releases
124+
ENV SQUASHFS_VERSION 4.4
125+
RUN wget -O squashfs.tgz "https://github.com/plougher/squashfs-tools/archive/$SQUASHFS_VERSION.tar.gz"; \
126+
tar --directory=/usr/src --extract --file=squashfs.tgz; \
127+
make -C "/usr/src/squashfs-tools-$SQUASHFS_VERSION/squashfs-tools" \
128+
-j "$(nproc)" \
129+
# https://github.com/plougher/squashfs-tools/blob/4.4/squashfs-tools/Makefile#L1
130+
GZIP_SUPPORT=1 \
131+
# XZ_SUPPORT=1 \
132+
# LZO_SUPPORT=1 \
133+
# LZ4_SUPPORT=1 \
134+
# ZSTD_SUPPORT=1 \
135+
EXTRA_CFLAGS='-static' \
136+
EXTRA_LDFLAGS='-static' \
137+
INSTALL_DIR="$PWD/usr/local/bin" \
138+
install \
139+
; \
140+
tcl-chroot unsquashfs -v || :
141+
142+
RUN { \
154143
echo '#!/bin/bash -Eeux'; \
155144
echo 'tcl-chroot su -c "tce-load -wicl \"\$@\"" docker -- - "$@"'; \
156145
} > /usr/local/bin/tcl-tce-load; \

files/tce-load.patch

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Description: replace "mount" with "unsquashfs" and ignore "-KERNEL" deps
22
Author: Tatsushi Demachi, Tianon Gravi
33
Partial-Origin: https://github.com/tatsushid/docker-tinycore/blob/017b258a08a41399f65250c9865a163226c8e0bf/8.2/x86_64/src/tce-load.patch
4+
Unpatched-Source: https://github.com/tinycorelinux/Core-scripts/blob/19fed4fa59585899ef47163424b15f59f15d3e4d/usr/bin/tce-load
45

56
diff --git a/usr/bin/tce-load b/usr/bin/tce-load
67
index 1378b90..fea2aa8 100755
@@ -11,7 +12,7 @@ index 1378b90..fea2aa8 100755
1112
copyInstall() {
1213
[ -d /mnt/test ] || sudo /bin/mkdir -p /mnt/test
1314
- sudo /bin/mount $1 /mnt/test -t squashfs -o loop,ro,bs=4096
14-
+ sudo /usr/local/bin/unsquashfs -f -d /mnt/test $1
15+
+ sudo /usr/local/bin/unsquashfs -force -dest /mnt/test $1 || exit 1
1516
if [ "$?" == 0 ]; then
1617
if [ "$(ls -A /mnt/test)" ]; then
1718
yes "$FORCE" | sudo /bin/cp -ai /mnt/test/. / 2>/dev/null

update.sh

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,6 @@ major='10.x'
66
version='10.1' # TODO auto-detect latest
77
# 9.x doesn't seem to use ".../archive/X.Y.Z/..." in the same way as 8.x :(
88

9-
packages=(
10-
# needed for "tce-load.patch"
11-
squashfs-tools.tcz
12-
13-
# required for Docker, deps on "xyz-KERNEL.tcz"
14-
#iptables.tcz
15-
# fixed via tce-load patch instead (more sustainable)
16-
)
17-
189
mirrors=(
1910
http://distro.ibiblio.org/tinycorelinux
2011
http://repo.tinycorelinux.net
@@ -67,34 +58,6 @@ seds+=(
6758
-e 's/^ENV TCL_ROOTFS.*/ENV TCL_ROOTFS="'"$rootfs"'" TCL_ROOTFS_MD5="'"$rootfsMd5"'"/'
6859
)
6960

70-
archPackages=()
71-
archPackagesMd5s=()
72-
declare -A seen=()
73-
set -- "${packages[@]}"
74-
while [ "$#" -gt 0 ]; do
75-
package="$1"; shift
76-
[ -z "${seen[$package]:-}" ] || continue
77-
seen[$package]=1
78-
79-
packageMd5="$(fetch "$arch/tcz/$package.md5.txt")"
80-
packageMd5="${packageMd5%% *}"
81-
82-
archPackages+=( "$package" )
83-
archPackagesMd5s+=(
84-
'TCL_PACKAGE_MD5__'"$(echo "$package" | sed -r 's/[^a-zA-Z0-9]+/_/g')"'="'"$packageMd5"'"'
85-
)
86-
87-
if packageDeps="$(
88-
fetch "$arch/tcz/$package.dep" \
89-
| grep -vE -- '-KERNEL'
90-
)"; then
91-
set -- $packageDeps "$@"
92-
fi
93-
done
94-
seds+=(
95-
-e 's!^ENV TCL_PACKAGES.*!ENV TCL_PACKAGES="'"${archPackages[*]}"'" '"${archPackagesMd5s[*]}"'!'
96-
)
97-
9861
kernelVersion="$(
9962
wget -qO- 'https://www.kernel.org/releases.json' \
10063
| jq -r --arg base "$kernelBase" '.releases[] | .version | select(startswith($base + "."))'

0 commit comments

Comments
 (0)