Skip to content

Commit

Permalink
Merge pull request #30 from innovarew/main
Browse files Browse the repository at this point in the history
Update from main to 14.x-x86
  • Loading branch information
innovarew authored Feb 2, 2024
2 parents 0b54300 + 2925af4 commit a69f915
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 47 deletions.
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
#
# @description Dockerfile, for building innovarew/docker-tinycore
# @author innovarew <innovarew at github.com> (c) Copyright 2022
# @url github.com/innovarew/docker-tinycore
#

FROM scratch
MAINTAINER "innovarew <innovarew at github.com> (c) Copyright 2022"
LABEL author="@author innovarew <innovarew at github.com> (c) Copyright 2022."
ARG TC_VER=14.x-x86

ADD data/rootfs-$TC_VER.tar.xz /
Expand Down
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#
# @description Makefile, for building innovarew/docker-tinycore
# @author innovarew <innovarew at github.com> (c) Copyright 2022
# @url github.com/innovarew/docker-tinycore
#

# Set tinycore release
TC_URL=http://tinycorelinux.net/14.x/x86_64/
TC_VER=$(shell echo "${TC_URL}" | awk -F/ '{print $$4"-"$$5}')
Expand All @@ -7,6 +13,6 @@ all: rootfs build run
rootfs:
scripts/tc-docker tce_rootfs_init
build:
docker build --build-arg TC_VER=${TC_VER} -t tinycore:${TC_VER} -t tinycore:latest .
docker build --build-arg TC_VER=${TC_VER} -t tinycore:${TC_VER} -t docker-tinycore-local:latest .
run:
docker run -it tinycore:latest /bin/sh
docker run -it docker-tinycore-local:latest /bin/sh
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

## Quick guide

To build on top of it, just pull from the [docker-tinycore package](https://github.com/innovarew/docker-tinycore/pkgs/container/docker-tinycore/versions)
To build on top of it, just pull from the [docker-tinycore package](https://github.com/innovarew/docker-tinycore/pkgs/container/docker-tinycore/)

~~~
echo FROM ghcr.io/innovarew/docker-tinycore > Dockerfile
Expand All @@ -22,24 +22,25 @@ docker build -t docker-tinycore-scratch .
To run, just `docker run` as show below:

~~~
sudo docker run -it ghcr.io/innovarew/docker-tinycore
sudo docker run -it ghcr.io/innovarew/docker-tinycore:latest
~~~

To build locally, just `make` as show below:

~~~
# prepare the rootfs, build, and run the container
sudo make TC_URL=http://tinycorelinux.net/13.x/x86_64/
sudo make TC_URL=http://tinycorelinux.net/14.x/x86_64/
~~~

## Supported versions

Ready to use docker images from [docker-tinycore](https://github.com/innovarew/docker-tinycore/pkgs/container/docker-tinycore/versions):
Ready to use docker images from [docker-tinycore](https://github.com/innovarew/docker-tinycore/pkgs/container/docker-tinycore/) (see link on how-to use):

| Release/Arch | Docker Image |
| -------------- | ---------------------------------------------------- |
| [latest](https://github.com/innovarew/docker-tinycore/) | `FROM ghcr.io/innovarew/docker-tinycore:latest` |
| Release/Arch | Docker Image |
| -------------- | ----------------------------------------------------------------------------------------------------------------- |
| [latest](https://github.com/innovarew/docker-tinycore/) | `FROM ghcr.io/innovarew/docker-tinycore:latest` |
| [14.x-x86_64](https://github.com/innovarew/docker-tinycore/tree/14.x-x86_64)| `FROM ghcr.io/innovarew/docker-tinycore:14.x-x86_64` |
| [14.x-x86](https://github.com/innovarew/docker-tinycore/tree/14.x-x86) | `FROM ghcr.io/innovarew/docker-tinycore:14.x-x86` |
| [13.x-x86_64](https://github.com/innovarew/docker-tinycore/tree/13.x-x86_64)| `FROM ghcr.io/innovarew/docker-tinycore:13.x-x86_64` |
| [12.x-x86_64](https://github.com/innovarew/docker-tinycore/tree/12.x-x86_64)| `FROM ghcr.io/innovarew/docker-tinycore:12.x-x86_64` |
| [11.x-x86_64](https://github.com/innovarew/docker-tinycore/tree/11.x-x86_64)| `FROM ghcr.io/innovarew/docker-tinycore:11.x-x86_64` |
Expand All @@ -52,15 +53,15 @@ What goes on under the hood is shown below:
~~~
cat > Dockerfile <<EOF
FROM scratch
ADD data/rootfs-x86_64-13.x.tar.xz /
ADD data/rootfs-x86_64-14.x.tar.xz /
EOF
# unpack tinycore rootfs, sudo needed to unpack cpio proper perms
sudo scripts/tc-docker tce_rootfs_init data/
# build and run the tinycore docker container
sudo docker build -t tinycore:latest .
sudo docker run -it tinycore:latest /bin/sh
sudo docker build -t docker-tinycore-local:latest .
sudo docker run -it docker-tinycore-local:latest /bin/sh
~~~

## Overview
Expand Down
80 changes: 45 additions & 35 deletions scripts/tc-docker
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/sh
#
# @file tc-docker
# @version v1.0
# @description tinycore (tc) in docker
# @author innovarew <box> (c) Copyright 2022.
# @description tc-docker, helper script for building innovarew/docker-tinycore
# @author innovarew <innovarew at github.com> (c) Copyright 2022 GPLv2
# @copyright All rights reserved. Read LICENSE.txt file for the license terms.
# @url github.com/innovarew/docker-tinycore
#
# Changelog:
#
Expand All @@ -15,19 +15,29 @@
# v1.0 Initial version
#
# 26/08/2023 innovarew
# v1.1 Bump version
# v1.1 Bump version x86_64
#
# 02/02/2024 innovarew
# v1.2 Bump version x86
#

PROGNAME=${0##*/}
PROGAUTHOR="innovarew <box> (c) 2022."
PROGVERSION=v1.2
PROGAUTHOR="innovarew"
PROGURL="https://github.com/innovarew/docker-tinycore"

set -euf

TC_ARCH=${TC_ARCH:-x86_64}
TC_URL=${TC_URL:-http://tinycorelinux.net/14.x/${TC_ARCH}}
ISO_URL=${ISO_URL:-$TC_URL/release/TinyCorePure64-current.iso}
TC_ISO=${TC_ISO:-$TC_URL/release/TinyCorePure64-current.iso}
TCZ_URL=$TC_URL/tcz
TC_CPIO=${TC_CPIO:-corepure64.gz}

if [ "$TC_ARCH" = "x86" ]; then
TC_CPIO=core.gz
TC_ISO=$TC_URL/release/TinyCore-current.iso
fi

TCE_DIR=$PWD/data/tce/optional
if grep -qi tinycore /etc/os-release
Expand All @@ -38,14 +48,14 @@ fi

tce_rootfs_init()
{
TC_VER=$(echo $TC_URL | awk -F/ '{print $4"-"$5}')
TC_VER=$(echo "$TC_URL" | awk -F/ '{print $4"-"$5}')
TC_TAR="rootfs-$TC_VER.tar.xz"
TC_PATCH="rootfs-$TC_VER.patch"

echo "# $ISO_URL"
echo "# $TC_ISO"
(
rm -r data/tce
mkdir -p $TCE_DIR
mkdir -p "$TCE_DIR"

rm -rf data/root
rm -rf data/tinycore
Expand All @@ -57,31 +67,31 @@ tce_rootfs_init()
tce_rootfs_unpack "$@"

# rootfs contains .ko.gz not used by docker
find $PWD/root/ -name '*.ko.gz' -exec rm {} \;
find "$PWD/root/" -name '*.ko.gz' -exec rm {} \;

# get unsquashfs into container to unpack tcz
tce_install liblzma.tcz $PWD/root/
tce_install squashfs-tools.tcz $PWD/root/
tce_install liblzma.tcz "$PWD/root/"
tce_install squashfs-tools.tcz "$PWD/root/"

patch -p2 < $TC_PATCH
patch -p2 < "$TC_PATCH"
)

(cd data/root; tar cJf "../$TC_TAR" .)
}

tce_rootfs_unpack()
{
ISO_FILE=$(basename "$ISO_URL")
ISO_FILE="${TC_ISO##*/}"

wget -qc "$ISO_URL"
# wget -qc "$ISO_URL.md5.txt" && md5sum -c $(basename "$ISO_URL.md5.txt")
wget -qc "$TC_ISO"
# wget -qc "$TC_ISO.md5.txt" && md5sum -c $(basename "$TC_ISO.md5.txt")

if [ ! -d "tinycore" ]
then
mkdir -p tinycore
7z x -otinycore "$ISO_FILE" >/dev/null
mkdir -p root
(cd root; zcat ../tinycore/boot/corepure64.gz | cpio --extract)
(cd root; zcat "../tinycore/boot/$TC_CPIO" | cpio --extract)
fi
}

Expand All @@ -107,33 +117,33 @@ tce_install()
local app=$1
local root=$2

if [ -e $root/usr/local/tce.installed/${app%.tcz} ]
if [ -e "$root/usr/local/tce.installed/${app%.tcz}" ]
then
usage "warn: $app already installed in $root"
fi

(
tce_cddir

if wget -qc $TCZ_URL/$app.dep
if wget -qc "$TCZ_URL/$app.dep"
then
for dep in `cat $app.dep`
for dep in $(cat "$app.dep")
do
tce_install $dep $root
done
fi

wget -qc $TCZ_URL/$app
wget -qc $TCZ_URL/$app.md5.txt
[ -e "$app.md5.txt" ] && md5sum -c $app.md5.txt
wget -qc "$TCZ_URL/$app"
wget -qc "$TCZ_URL/$app.md5.txt"
[ -e "$app.md5.txt" ] && md5sum -c "$app.md5.txt"

if [ -n "$UNSQUASHFS" ]
then
unsquashfs -n -d "$root" -f $app >/dev/null
unsquashfs -n -d "$root" -f "$app" >/dev/null

# update system
mkdir -p $root/usr/local/tce.installed/
touch $root/usr/local/tce.installed/${app%.tcz}
mkdir -p "$root/usr/local/tce.installed/"
touch "$root/usr/local/tce.installed/${app%.tcz}"
fi

# update libs
Expand All @@ -150,8 +160,8 @@ tce_info()
local app=$1
(
tce_cddir
[ ! -e $app.info ] && wget -qc $TCZ_URL/$app.info
cat $app.info
[ ! -e "$app.info" ] && wget -qc "$TCZ_URL/$app.info"
cat "$app.info"
)
}

Expand All @@ -161,8 +171,8 @@ tce_list()
local app=$1
(
tce_cddir
[ ! -e $app.list ] && wget -qc $TCZ_URL/$app.list
cat $app.list
[ ! -e "$app.list" ] && wget -qc "$TCZ_URL/$app.list"
cat "$app.list"
)
}

Expand All @@ -172,25 +182,25 @@ tce_dep()
local app=$1
(
tce_cddir
[ ! -e $app.list ] && wget -qc $TCZ_URL/$app.dep
cat $app.dep
[ ! -e "$app.list" ] && wget -qc "$TCZ_URL/$app.dep"
cat "$app.dep"
)
}

tce_search()
{
(
tce_cddir
wget -qc $TCZ_URL
cat $(basename "$TCZ_URL")
wget -qc "$TCZ_URL"
cat "${TCZ_URL##*/}"
)
}

usage()
{
if [ $# -eq 0 ]
then
echo "usage: $PROGNAME [tce_rootfs_init|tce_install] # @version $PROGVERSION @copyright $PROGAUTHOR";
echo "usage: $PROGNAME [tce_rootfs_init|tce_install] # @version $PROGVERSION (c) $PROGAUTHOR $PROGURL";
exit;
else
echo "$@"
Expand Down

0 comments on commit a69f915

Please sign in to comment.