Skip to content

Instantly share code, notes, and snippets.

@CodeMan99
Last active July 21, 2024 00:54
Show Gist options
  • Save CodeMan99/727c033122016245ec5449884002c9ec to your computer and use it in GitHub Desktop.
Save CodeMan99/727c033122016245ec5449884002c9ec to your computer and use it in GitHub Desktop.
Chimera Linux via Docker
chimera-*.pub
chimera-linux-*.tar.gz
sha256sums.txt
sha256sums.txt.minisig
#!/usr/bin/env bash
set -e
REPO_NAME="chimera-linux"
RELEASE="${RELEASE:-latest}"
RELEASE_BASE_URL="https://repo.chimera-linux.org/live/$RELEASE"
SHA256_FILENAME="sha256sums.txt"
IMAGE_TAG="${REPO_NAME}:$RELEASE"
IMAGE_ID="$(docker image ls -q "$IMAGE_TAG")"
if [ -f "$SHA256_FILENAME" -a -n "$IMAGE_ID" ]; then {
MTIME="$(stat -c %y "$SHA256_FILENAME")"
curl -s -S -z "$SHA256_FILENAME" -o "$SHA256_FILENAME" "$RELEASE_BASE_URL/$SHA256_FILENAME"
if [[ "$MTIME" = "$(stat -c %y "$SHA256_FILENAME")" ]]; then {
printf "No update to %s detected, and docker image already exists.\n\n%s %s\n" "$SHA256_FILENAME" "$IMAGE_ID" "$IMAGE_TAG"
false
} fi
} else {
curl -s -S -o "$SHA256_FILENAME" "$RELEASE_BASE_URL/$SHA256_FILENAME"
} fi
ARCH="x86_64"
BOOT="ROOTFS"
TYPE="bootstrap" # bootstrap, minimal, core, full
EXT="tar.gz"
read -ra LINE < <(grep -E "${REPO_NAME}-${ARCH}-${BOOT}-[0-9]{8}-${TYPE}.${EXT}" "$SHA256_FILENAME")
SHA256SUM="${LINE[0]}"
FILENAME="${LINE[1]}"
DATE_TAG="$(cut -d- -f5 <<< "$FILENAME")"
if hash minisign 2> /dev/null; then
curl -s -S -o "${SHA256_FILENAME}.minisig" "$RELEASE_BASE_URL/${SHA256_FILENAME}.minisig"
curl -s -S -L -o "chimera-${DATE_TAG}.pub" "https://raw.githubusercontent.com/chimera-linux/cports/master/main/chimera-image-keys/files/${DATE_TAG}.pub"
minisign -Vm "$SHA256_FILENAME" -p "chimera-${DATE_TAG}.pub"
fi
printf "%9s: %s\n" \
"sha256sum" "$SHA256SUM" \
"filename" "$FILENAME" \
"url" "$RELEASE_BASE_URL/$FILENAME"
curl -sSL https://qwerty.sh | sh -s - --sha256="$SHA256SUM" -o "$FILENAME" "$RELEASE_BASE_URL/$FILENAME"
docker tag $(docker import --change 'ENTRYPOINT ["/usr/bin/sh"]' "$FILENAME") "$IMAGE_TAG"
@CodeMan99
Copy link
Author

Example output.

$ ./download-chimera-linux.sh
Signature and comment signature verified
Trusted comment: timestamp:1706664798   file:sha256sums.txt     hashed
sha256sum: 19ab0d2775170f1c14f9c7059f283092ffcfc4ed8b1c61662875ca2ab8f06328
 filename: chimera-linux-x86_64-ROOTFS-20240122-core.tar.gz
      url: https://repo.chimera-linux.org/live/latest/chimera-linux-x86_64-ROOTFS-20240122-core.tar.gz
--- sha256 -----------------------------------------------------------------
Expected:   19ab0d2775170f1c14f9c7059f283092ffcfc4ed8b1c61662875ca2ab8f06328
Downloaded: 19ab0d2775170f1c14f9c7059f283092ffcfc4ed8b1c61662875ca2ab8f06328
----------------------------------------------------------------------------
Output already exists and is valid: chimera-linux-x86_64-ROOTFS-20240122-core.tar.gz
$ docker image ls
REPOSITORY                      TAG               IMAGE ID       CREATED         SIZE
chimera-linux                   latest            40777a5fd3a1   3 seconds ago   98.5MB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment