WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: script to full run all TC pakages from a chroot  (Read 485 times)

Offline nick65go

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 933
script to full run all TC pakages from a chroot
« on: September 08, 2025, 05:12:46 AM »
@Rich and @GNUuser, thank you for your FetchExt.sh
regarding https://forum.tinycorelinux.net/index.php?action=post;board=36.0
"Re: Script to download extensions+dependencies on other"

My naive contribution is here for a full running TC from a chroot., not only downloading tczs.
In a chroot we do not need the kernel (vmlinuz) neither its modules.
- So instead of vmlinuz + core.gz (= rootfs.gz + modules.gz) we could use just use roofs.gz
- In a chroot the host kernel (ex: 6.16.x) can be different from original Tc kernel (ex: 6.12.x).
- Plus host user can be (uid=1000, gid=1000) different from default TC user(uid=1001, gid=50), for some protection.

I tested my script using a host with Wayland server. I mounted just just /proc and /dev (no need to mount /sys or /tmp). The downloaded TCZ (running from chroot) will be saved locally on host, so no need to downloaded them again. Basically it functions like a real in RAM tiny-core distro.
tested commands:
- tce (CLI app) to download tc applets (ex:editor, cpanel etc)
- tce-download -wo libXau (testing on-demand is working).
- tce-load -i fluff (working from CLI shell).- fluff, editor, etc (all runs OK)

PS: I will publish the script soon, from another machine.
« Last Edit: September 08, 2025, 05:25:33 AM by nick65go »

Offline nick65go

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 933
Re: script to full run all TC pakages from a chroot
« Reply #1 on: September 08, 2025, 05:24:48 AM »
Here is the script, tested from an Archlinux type distro.
Code: [Select]
!/bin/sh
START="001"
[ -d $START ] || mkdir -p $START/{cpio,ram,tcz}

echo "Download rootfs64.gz from web server"
URL="https://mirrors.dotsrc.org/tinycorelinux/16.x/x86_64/release/distribution_files"
MINI="rootfs64.gz"
[ ! -f $START/cpio/$MINI ] || wget -c -O $START/cpio/$MINI $URL/$MINI

echo "all files stay virgin in tmp RAM"
sudo mount -t tmpfs none $START/ram

echo "extract all files except /dev*"
cd $START/ram
bsdcpio -i -f ^dev  < ../cpio/rootfs64.gz
sudo chown root usr/bin/sudo
sudo chown root:root etc/sudoers

# simulate non-volatile tcedir, colect them in ./tcz
mkdir -p tce dev home/tc
sudo mount --bind ../tcz tce
ln -s /tce etc/sysconfig/tcedir
chmod a+rw tce
cp etc/profile home/tc/.profile

echo "busybox need /proc mounted"
sudo mount -t proc /proc proc
# sudo mknod -m +rw dev/null c 1 3
sudo mount -t devtmpfs --rbind --make-rslave /dev dev

echo enable network in guest/chroot
cp /etc/resolv.conf etc

# to run GUI in guesr when Xorg in host
mkdir tmp/.X11-unix
sudo mount --rbind /tmp/.X11-unix tmp/.X11-unix
echo "export DISPLAY=:0" >> home/tc/.profile
cp /run/user/100/xath* home/tc/.Xauthority
chmod a+r home/tc/.Xauthority

# to run GUI in guest when Wayland in host
mkdir -p run/user/1000
sudo mount --bind /run/user/1000 run/user/1000

sudo chroot . /bin/login -f tc
FYI: do not forget to un-mount all mounted folders (dev proc tce run ram etc) when you finish with your chroot.
I think this chroot is lighter than other solutions (maybe not as safely as docker or virtual machine). YMMV.