Skip to content

Commit

Permalink
Merge branch 'main' of https://extradummythicc@github.com/extradummyt…
Browse files Browse the repository at this point in the history
…hicc/yacd
  • Loading branch information
beer-psi committed Dec 18, 2021
2 parents 8178359 + 47ee9bb commit a063505
Show file tree
Hide file tree
Showing 11 changed files with 178 additions and 85 deletions.
14 changes: 14 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# shellcheck disable=SC2148
# Leave empty to be asked when running the build script
export NAME='sh0wer'
export VERSION='v0.0.1'
export ARCH=''

# Leave empty to include all kernel modules in the build
export KERNEL_MODULES=''

# Leave empty to get the latest release
export CHECKRA1N_AMD64='' # checkra1n binary for amd64
export CHECKRA1N_I486='' # checkra1n binary for i486
export SILEO='' # org.coolstar.sileo deb for iphoneos-arm
export ZSTD='' # latest gz-compressed zstd release from https://github.com/facebook/zstd
48 changes: 39 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,50 @@ jobs:
-
name: Install build dependencies
run: |
source ./.env
sudo apt-get update
sudo apt-get install -y --no-install-recommends wget debootstrap grub-pc-bin \
grub-efi-amd64-bin mtools squashfs-tools xorriso ca-certificates curl \
libusb-1.0-0-dev gcc make gzip xz-utils unzip libc6-dev
libusb-1.0-0-dev gcc make gzip unzip libc6-dev xz-utils
# gotta get 1.5.0
(
curl -LO https://github.com/facebook/zstd/releases/download/v1.5.0/zstd-1.5.0.tar.gz
sudo tar xf zstd-1.5.0.tar.gz -C /opt
cd /opt/zstd*
sudo make
sudo make install
)
-
name: Download odysseyra1n resources
run: |
source ./.env
[ -z "$SILEO" ] && {
SILEO="https://github.com$(curl -s https://github.com/Sileo/Sileo/releases | grep -Po "/Sileo\/Sileo/releases/download/[\d.]+/org\.coolstar\.sileo_[\d.]+_iphoneos-arm\.deb" | head -1)"
}
mkdir -p assets/odysseyra1n
(
cd assets/odysseyra1n
curl -sL -O https://github.com/coolstar/Odyssey-bootstrap/raw/master/bootstrap_1500.tar.gz \
-O https://github.com/coolstar/Odyssey-bootstrap/raw/master/bootstrap_1600.tar.gz \
-O https://github.com/coolstar/Odyssey-bootstrap/raw/master/bootstrap_1700.tar.gz \
-O "$SILEO" \
-O https://github.com/coolstar/Odyssey-bootstrap/raw/master/org.swift.libswift_5.0-electra2_iphoneos-arm.deb
gzip -dv ./*.tar.gz
tar -vc ./* | zstd -zcT0 --ultra -22 > odysseyra1n_resources.tar.zst
find ./* -not -name "odysseyra1n_resources.tar.zst" -delete
)
-
name: Build for x86_64
env:
ARCH: x86_64
run: |
sed -i "/Exit if user isn't root/aVERSION='$(cat version)'" build.sh
sed -i "s/ARCH=''/ARCH='x86_64'/" .env
sudo chmod 755 build.sh
sudo -E ./build.sh
-
name: Build for x86
env:
ARCH: x86
run: |
sed -i "s/ARCH='x86_64'/ARCH='x86'/" .env
sudo -E ./build.sh
-
name: Upload artifacts
Expand All @@ -51,7 +78,9 @@ jobs:
-
name: Get version information
run: |
echo "version=$(cat version)" >> $GITHUB_ENV
source ./.env
echo "version=$VERSION" >> $GITHUB_ENV
echo "name=$NAME" >> $GITHUB_ENV
echo "todayDate=$(date +%Y%m%dT%H%M%SZ)" >> $GITHUB_ENV
-
name: Create release
Expand All @@ -70,10 +99,11 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
todayDate: ${{ env.todayDate }}
version: ${{ env.version }}
name: ${{ env.name }}
run: |
set -x
mv ./artifact/yacd-$version-x86_64.iso ./artifact/yacd-$todayDate-x86_64.iso
mv ./artifact/yacd-$version-x86.iso ./artifact/yacd-$todayDate-x86.iso
mv ./artifact/$name-$version-x86_64.iso ./artifact/$name-$todayDate-x86_64.iso
mv ./artifact/$name-$version-x86.iso ./artifact/$name-$todayDate-x86.iso
assets=()
for asset in ./artifact/*; do
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
### Licensing for yacd, with exception to third party software as mentioned below
### Licensing for sh0wer, with exception to third party software as mentioned below

BSD Zero Clause License

Expand Down
16 changes: 6 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,18 @@ Download the appropriate ISO for your PC:
- `x86_64` is for 64-bit CPUs
- `x86` is for 32-bit CPUs

Windows users: If you don't know what type of CPU you have, open File Explorer, right click This PC and select Properties, look for the line "System type":
If you don't know what type of CPU you have, open File Explorer, right click This PC and select Properties, look for the line "System type":
- `x64-based processor` means your CPU is 64-bit
- `x86-based processor` means your CPU is 32-bit

Instructions
1. Get the latest "Release" ISO from the [Releases tab](https://github.com/extradummythicc/yacd/releases)
1. Get the latest "Release" ISO from the [Releases tab](https://github.com/extradummythicc/sh0wer/releases)
2. Get the ROSA Image Writer [here](http://wiki.rosalab.ru/en/images/6/62/RosaImageWriter-2.6.2-win.zip). If another USB flashing tool (like balenaEtcher) floats your boat, you can use it instead.
3. Open ROSA Image Writer and write the downloaded ISO to your USB
4. Reboot, enter your BIOS menu (you'll have to google for this) and select to boot from the USB.

After you're done using yacd, if you want to wipe your USB so you can use it normally, just use the "Clear" button inside ROSA.
After you're done using sh0wer, if you want to wipe your USB so you can use it normally, just use the "Clear" button inside ROSA.

# Building yacd
# Building sh0wer
## Installing build dependencies
### Debian and its derivatives
```
Expand All @@ -32,19 +31,16 @@ sudo apt-get install -y --no-install-recommends wget debootstrap grub-pc-bin \
libusb-1.0-0-dev gcc make gzip xz-utils unzip libc6-dev
```
## Environment variables
These environment variables can be set prior to executing the script
All build variables are inside the `.env` file.
```bash
VERSION="YOUR_VERSION"
ARCH="ARCHITECTURE_TO_BUILD" # Available architectures: x86_64 and x86
```

These variables set the download link for various resources.
They can be edited inside `build.sh`, however they are not needed:
```bash
# Leave empty to automatically grab the latest version
CHECKRA1N_AMD64=""
CHECKRA1N_I486=""
SILEO=""
ZSTD="" # gz-compressed archive of release from https://github.com/facebook/zstd
```

## Advanced: Kernel modules
Expand Down
145 changes: 90 additions & 55 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# YACD - Yet Another checkra1n Distribution
# sh0wer

# Exit if user isn't root
[ "$(id -u)" -ne 0 ] && {
Expand All @@ -10,10 +10,7 @@
# Stage 0: Get download links
# * If any link is filled, the script will download from that link.
# * If empty, get the latest version from the website.
KERNEL_MODULES="modules"
CHECKRA1N_AMD64=""
CHECKRA1N_I486=""
SILEO=""
source ./.env
[ -z "$CHECKRA1N_AMD64" ] && {
CHECKRA1N_AMD64=$(curl -s "https://checkra.in/releases/" | grep -Po "https://assets.checkra.in/downloads/linux/cli/x86_64/[0-9a-f]*/checkra1n")
}
Expand All @@ -23,6 +20,9 @@ SILEO=""
[ -z "$SILEO" ] && {
SILEO="https://github.com$(curl -s https://github.com/Sileo/Sileo/releases | grep -Po "/Sileo\/Sileo/releases/download/[\d.]+/org\.coolstar\.sileo_[\d.]+_iphoneos-arm\.deb" | head -1)"
}
[ -z "$ZSTD" ] && {
ZSTD="https://github.com$(curl -s https://github.com/facebook/zstd/releases | grep -Po "/facebook\/zstd/releases/download/v[\d.]+/zstd-[\d.]+\.tar\.gz" | head -1)"
}

# Stage 1: User input
# Ask for the version and architecture if variables are empty
Expand Down Expand Up @@ -66,9 +66,9 @@ done
umount work/chroot/sys
umount work/chroot/dev
} > /dev/null 2>&1
rm -rf work/
rm -rf work

set -e -u -v
set -e -u -x

start_time="$(date -u +%s)"

Expand All @@ -81,7 +81,7 @@ start_time="$(date -u +%s)"
# * Stripping unneeded kernel modules
# * Remove unneeded files and directories
mkdir -p work/chroot work/iso/live work/iso/boot/grub
debootstrap --variant=minbase --arch="$REPO_ARCH" stable work/chroot 'http://deb.debian.org/debian/'
debootstrap --variant=minbase --arch="$REPO_ARCH" sid work/chroot 'http://deb.debian.org/debian/'
mount --bind /proc work/chroot/proc
mount --bind /sys work/chroot/sys
mount --bind /dev work/chroot/dev
Expand All @@ -91,40 +91,72 @@ cat << ! | chroot work/chroot /usr/bin/env PATH=/usr/bin:/bin:/usr/sbin:/sbin /b
# Set debian frontend to noninteractive
export DEBIAN_FRONTEND=noninteractive
# Install requiered packages
apt-get install -y --no-install-recommends linux-image-$KERNEL_ARCH live-boot \
systemd systemd-sysv usbmuxd libusbmuxd-tools openssh-client sshpass xz-utils dialog
# Install required packages
apt-get update
apt-get install -y --no-install-recommends busybox linux-image-$KERNEL_ARCH live-boot \
systemd systemd-sysv usbmuxd libusbmuxd-tools openssh-client sshpass dialog \
build-essential curl ca-certificates
curl -LO $ZSTD
tar xf zstd*.tar.gz -C /opt
(
cd /opt/zstd*
make
make install
)
rm -rf zstd*.tar.gz /opt/zstd*
ln -sf /usr/local/bin/zstd /usr/bin/zstd
!
sed -i 's/COMPRESS=gzip/COMPRESS=xz/' work/chroot/etc/initramfs-tools/initramfs.conf

# Strip unneeded kernel modules
sed -i '/^[[:blank:]]*#/d;s/#.*//;/^$/d' $KERNEL_MODULES
modules_to_keep=()
while IFS="" read -r p || [ -n "$p" ]
do
modules_to_keep+=("-not" "-name" "$p")
done < $KERNEL_MODULES
find work/chroot/lib/modules/*/kernel/* -type f "${modules_to_keep[@]}" -delete
find work/chroot/lib/modules/*/kernel/* -type d -empty -delete

# Compress remaining kernel modules
sed -i 's/COMPRESS=gzip/COMPRESS=zstd/' work/chroot/etc/initramfs-tools/initramfs.conf
sed -i 's/zstd -q -19 -T0/zstd -q --ultra -22 -T0/g' work/chroot/sbin/mkinitramfs

# Debloating Debian
# * Removing unneeded kernel modules (360MB size reduction)
# if [ -n "$KERNEL_MODULES" ]; then
# cat work/chroot/etc/initramfs-tools/modules >> "$KERNEL_MODULES"
# sed -i '/^[[:blank:]]*#/d;s/#.*//;/^$/d' "$KERNEL_MODULES"
# modules_to_keep=()
# while IFS="" read -r p || [ -n "$p" ]
# do
# modules_to_keep+=("-not" "-name" "$p")
# done < "$KERNEL_MODULES"
# find work/chroot/lib/modules/*/kernel/* -type f "${modules_to_keep[@]}" -delete
# find work/chroot/lib/modules/*/kernel/* -type d -empty -delete
# fi
# * Compress remaining kernel modules (like 3MB size reduction)
find work/chroot/lib/modules/*/kernel/* -type f -name "*.ko" -exec strip --strip-unneeded {} +
find work/chroot/lib/modules/*/kernel/* -type f -name "*.ko" -exec xz --x86 -e9T0 {} +
depmod -b work/chroot "$(basename "$(find work/chroot/lib/modules/* -maxdepth 0)")"

chroot work/chroot update-initramfs -u

# Remove unneeded files and folders
# * Purge a bunch of packages that won't be used anyway
cat << ! | chroot work/chroot /usr/bin/env PATH=/usr/bin:/bin:/usr/sbin:/sbin /bin/bash
dpkg -P --force-all cpio gzip libgpm2 apt
export DEBIAN_FRONTEND=noninteractive
apt-get -y purge make dpkg-dev g++ gcc libc-dev make build-essential curl ca-certificates perl-modules-5.32 perl libdpkg-perl
apt-get -y autoremove
dpkg -P --force-all apt cpio gzip libgpm2
dpkg -P --force-all initramfs-tools initramfs-tools-core
dpkg -P --force-all debconf libdebconfclient0
dpkg -P --force-all init-system-helpers
dpkg -P --force-all dpkg perl-base
!

# * Replacing coreutils with their Debian equivalents (123MB size reduction)
cat << "!" | chroot work/chroot /bin/bash
ln -sfv "$(command -v busybox)" /usr/bin/which
busybox --list | egrep -v "(busybox)|(init)" | while read -r line; do
if which $line &> /dev/null; then # If command exists
if [ "$(stat -c%s $(which $line))" -gt 16 ]; then # And we can gain storage space from making a symlink (symlinks are 16 bytes)
ln -sfv "$(which busybox)" "$(which $line)" # Then make one (ignore nonexistent commands /shrug)
fi
fi
done
!

# * Empty unused directories
(
cd work/chroot
# Empty some directories to make the system smaller
rm -f etc/mtab \
etc/fstab \
etc/ssh/ssh_host* \
Expand All @@ -148,25 +180,29 @@ dpkg -P --force-all dpkg perl-base
# Copying scripts & Downloading resources
mkdir -p work/chroot/opt/odysseyra1n work/chroot/opt/a9x
cp scripts/* work/chroot/usr/local/bin
cat assets/.dialogrc > work/chroot/root/.dialogrc
cp assets/.dialogrc work/chroot/root/.dialogrc
cp assets/PongoConsolidated.bin work/chroot/opt/a9x
(
cd work/chroot/usr/local/bin
curl -sLO "$CHECKRA1N"
chmod a+x ./*
)
(
cd work/chroot/opt/odysseyra1n
curl -sL -O https://github.com/coolstar/Odyssey-bootstrap/raw/master/bootstrap_1500.tar.gz \
-O https://github.com/coolstar/Odyssey-bootstrap/raw/master/bootstrap_1600.tar.gz \
-O https://github.com/coolstar/Odyssey-bootstrap/raw/master/bootstrap_1700.tar.gz \
-O "$SILEO" \
-O https://github.com/coolstar/Odyssey-bootstrap/raw/master/org.swift.libswift_5.0-electra2_iphoneos-arm.deb
# Rolling everything into one xz-compressed tarball (reduces size hugely)
gzip -dv ./*.tar.gz
tar -vc ./* | xz --arm -zvce9T 0 > odysseyra1n_resources.tar.xz
find ./* -not -name "odysseyra1n_resources.tar.xz" -exec rm {} +
)
if [ "$GITHUB_ACTIONS" = true ]; then
cp assets/odysseyra1n/odysseyra1n_resources.tar.zst work/chroot/opt/odysseyra1n
else
(
cd work/chroot/opt/odysseyra1n
curl -sL -O https://github.com/coolstar/Odyssey-bootstrap/raw/master/bootstrap_1500.tar.gz \
-O https://github.com/coolstar/Odyssey-bootstrap/raw/master/bootstrap_1600.tar.gz \
-O https://github.com/coolstar/Odyssey-bootstrap/raw/master/bootstrap_1700.tar.gz \
-O "$SILEO" \
-O https://github.com/coolstar/Odyssey-bootstrap/raw/master/org.swift.libswift_5.0-electra2_iphoneos-arm.deb
# Rolling everything into one zstd-compressed tarball (reduces size hugely)
gzip -dv ./*.tar.gz
tar -vc ./* | zstd -zcT0 --ultra -22 > odysseyra1n_resources.tar.zst
find ./* -not -name "odysseyra1n_resources.tar.zst" -exec rm {} +
)
fi


# Configuring autologin
Expand All @@ -182,42 +218,41 @@ Type=idle
cat << ! > work/iso/boot/grub/grub.cfg
insmod all_video
echo ''
echo ' _ '
echo ' _ _ __ _ ___ __| |'
echo '| | | |/ _ |/ __/ _ |'
echo '| |_| | (_| | (_| (_| |'
echo ' \__, |\__,_|\___\__,_|'
echo ' |___/'
echo ' .-. '
echo ' ( ). '
echo ' (___(__) '
echo " ' ' ' ' "
echo " ' ' ' ' "
echo ''
echo 'Yet Another checkra1n Distribution'
echo ' by beerpsi'
linux /boot/vmlinuz boot=live quiet
echo ' sh0wer '
echo ' by beerpsi '
linux /boot/vmlinuz boot=live
initrd /boot/initrd.img
boot
!

# * Change hostname
# * configure .bashrc
# * configure .dialogrc
echo 'yacd' > work/chroot/etc/hostname
echo "$NAME" > work/chroot/etc/hostname
cat << ! > work/chroot/root/.bashrc
export VERSION='$VERSION'
export DIALOGRC=/root/.dialogrc
/usr/local/bin/menu
!

# Stage 4: Build the ISO
# * Make an xz-compressed squashfs
# * Make an zstd-compressed squashfs
umount work/chroot/proc
umount work/chroot/sys
umount work/chroot/dev
cp work/chroot/vmlinuz work/iso/boot
cp work/chroot/initrd.img work/iso/boot
mksquashfs work/chroot work/iso/live/filesystem.squashfs -noappend -e boot -comp xz -Xbcj x86 -Xdict-size 100%
mksquashfs work/chroot work/iso/live/filesystem.squashfs -noappend -e boot -comp zstd -Xcompression-level 22

## Creates output ISO dir (easier for GitHub Actions)
mkdir -p out
grub-mkrescue -o "out/yacd-$VERSION-$ARCH.iso" work/iso \
grub-mkrescue -o "out/$NAME-$VERSION-$ARCH.iso" work/iso \
--compress=xz \
--fonts='' \
--locales='' \
Expand All @@ -226,4 +261,4 @@ grub-mkrescue -o "out/yacd-$VERSION-$ARCH.iso" work/iso \
end_time="$(date -u +%s)"
elapsed_time="$((end_time - start_time))"

echo "Built yacd-$VERSION-$ARCH in $((elapsed_time / 60)) minutes and $((elapsed_time % 60)) seconds."
echo "Built $NAME-$VERSION-$ARCH in $((elapsed_time / 60)) minutes and $((elapsed_time % 60)) seconds."
Loading

0 comments on commit a063505

Please sign in to comment.