Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
khcrysalis committed Jun 13, 2024
1 parent 991044e commit d737393
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 147 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
fail-fast: false
matrix:
arch: [ amd64, i686, aarch64, armv7 ]
arch: [ x86_64, x86, aarch64, armv7 ]
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -27,7 +27,7 @@ jobs:
env:
ARCH: ${{ matrix.arch }}
run: |
sudo -E ./build.sh RELEASE
sudo -E ./build.sh
- name: Prepare artifact
run: |
Expand Down
48 changes: 0 additions & 48 deletions .github/workflows/nightly.yml

This file was deleted.

156 changes: 64 additions & 92 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Made with <3 https://github.com/palera1n/palen1x
# Modified from https://github.com/asineth0/checkn1x & https://github.com/raspberryenvoie/odysseyn1x :3

# Exit if user isn't root

[ "$(id -u)" -ne 0 ] && {
echo 'Please run as root'
exit 1
Expand All @@ -13,120 +13,89 @@
GREEN="$(tput setaf 2)"
BLUE="$(tput setaf 6)"
NORMAL="$(tput sgr0)"
cat << EOF
Welcome to ${GREEN}&&&%##%%(${NORMAL}
${GREEN}&&&&&&&&&&&%#&&%%%${NORMAL}
${GREEN}&&&&&&&&&&&&&&&&&&%%#&&&%%%${NORMAL}
${BLUE}&&&&&&&&${NORMAL}#############${GREEN}&&&%%&%%&&&&%%%${NORMAL}
${BLUE}%%%%%%%%%%%%&&&${NORMAL}# ${BLUE}palen1x${NORMAL} #${GREEN}%&&&&%%%%%%%%%%%%${NORMAL}
${BLUE}#######((((###%%%%%${NORMAL}#############${GREEN}&%%%%%%%${NORMAL}
${BLUE}######/ ########%%%%&&&&&&&%%${NORMAL}
${BLUE}((((((((((((######%%%%%%%${NORMAL}
${BLUE}(((((((((#####%%*${NORMAL}
${BLUE}/(((((##${NORMAL} build script
EOF
# Ask for the version and architecture if variables are empty

while [ -z "$VERSION" ]; do
printf 'Version: '
read -r VERSION
done
until [ "$ARCH" = 'amd64' ] || [ "$ARCH" = 'i686' ] || [ "$ARCH" = 'aarch64' ] || [ "$ARCH" = 'armv7' ]; do
echo '1 amd64'
echo '2 i686'

until [ "$ARCH" = 'x86_64' ] || [ "$ARCH" = 'x86' ] || [ "$ARCH" = 'aarch64' ] || [ "$ARCH" = 'armv7' ]; do
echo '1 x86_64'
echo '2 x86'
echo '3 aarch64'
echo '4 armv7'
printf 'Which architecture? amd64 (default), i686, or aarch64 or armv7'
printf 'Which architecture? x86_64 (default), x86, or aarch64 or armv7: '
read -r input_arch
[ "$input_arch" = 1 ] && ARCH='amd64'
[ "$input_arch" = 2 ] && ARCH='i686'
[ "$input_arch" = 1 ] && ARCH='x86_64'
[ "$input_arch" = 2 ] && ARCH='x86'
[ "$input_arch" = 3 ] && ARCH='aarch64'
[ "$input_arch" = 4 ] && ARCH='armv7'
[ -z "$input_arch" ] && ARCH='amd64'
[ -z "$input_arch" ] && ARCH='x86_64'
done

# Install dependencies to build palen1x
apt-get update
apt-get install -y --no-install-recommends wget gawk debootstrap mtools xorriso ca-certificates curl libusb-1.0-0-dev gcc make gzip xz-utils unzip libc6-dev

download_version=$(curl -s https://api.github.com/repos/palera1n/palera1n/releases | grep -m 1 -o '"tag_name": "[^"]*' | sed 's/"tag_name": "//')
# Get proper files
if [ "$1" = "RELEASE" ]; then
case "$ARCH" in
'amd64')
ROOTFS='https://dl-cdn.alpinelinux.org/alpine/v3.17/releases/x86_64/alpine-minirootfs-3.17.3-x86_64.tar.gz'
PALERA1N="https://github.com/palera1n/palera1n/releases/download/$(download_version)/palera1n-linux-x86_64"
;;
'i686')
ROOTFS='https://dl-cdn.alpinelinux.org/alpine/v3.17/releases/x86/alpine-minirootfs-3.17.3-x86.tar.gz'
PALERA1N="https://github.com/palera1n/palera1n/releases/download/$(download_version)/palera1n-linux-x86"
;;
'aarch64')
ROOTFS='https://dl-cdn.alpinelinux.org/alpine/v3.17/releases/aarch64/alpine-minirootfs-3.17.3-aarch64.tar.gz'
PALERA1N="https://github.com/palera1n/palera1n/releases/download/$(download_version)/palera1n-linux-arm64"
;;
'armv7')
ROOTFS='https://dl-cdn.alpinelinux.org/alpine/v3.17/releases/armv7/alpine-minirootfs-3.17.3-armv7.tar.gz'
PALERA1N="https://github.com/palera1n/palera1n/releases/download/$(download_version)/palera1n-linux-armel"
;;
esac
echo "INFO: RELEASE CHOSEN"
elif [ "$1" = "NIGHTLY" ]; then


url="https://cdn.nickchan.lol/palera1n/artifacts/c-rewrite/main/"
latest_build=0
html=$(curl -s "$url")
latest_build=$(echo "$html" | awk -F'href="' '{print $2}' | awk -F'/' 'NF>1{print $1}' | sort -nr | head -1)

case "$ARCH" in
'amd64')
ROOTFS='https://dl-cdn.alpinelinux.org/alpine/v3.17/releases/x86_64/alpine-minirootfs-3.17.3-x86_64.tar.gz'
PALERA1N="https://cdn.nickchan.lol/palera1n/artifacts/c-rewrite/main/$latest_build/palera1n-linux-x86_64"
;;
'i686')
ROOTFS='https://dl-cdn.alpinelinux.org/alpine/v3.17/releases/x86/alpine-minirootfs-3.17.3-x86.tar.gz'
PALERA1N="https://cdn.nickchan.lol/palera1n/artifacts/c-rewrite/main/$latest_build/palera1n-linux-x86"
;;
'aarch64')
ROOTFS='https://dl-cdn.alpinelinux.org/alpine/v3.17/releases/aarch64/alpine-minirootfs-3.17.3-aarch64.tar.gz'
PALERA1N="https://cdn.nickchan.lol/palera1n/artifacts/c-rewrite/main/$latest_build/palera1n-linux-arm64"
;;
'armv7')
ROOTFS='https://dl-cdn.alpinelinux.org/alpine/v3.17/releases/armv7/alpine-minirootfs-3.17.3-armv7.tar.gz'
PALERA1N="https://cdn.nickchan.lol/palera1n/artifacts/c-rewrite/main/$latest_build/palera1n-linux-armel"
;;
esac
echo "INFO: NIGHTLY CHOSEN"
elif [[ -z "$BUILD_TYPE" ]]; then
echo "ERROR: NO BUILD TYPE CHOSEN"
exit 1
fi

# Clean up previous attempts
PALERA1N_PREFIX="https://github.com/palera1n/palera1n/releases/download/$download_version/palera1n-linux-"
USBMUXD_PREFIX="https://cdn.nickchan.lol/palera1n/artifacts/usbmuxd-static/usbmuxd-linux-"
PATH_VERSION="v3.20"
ROOTFS_VERSION="3.20.0"
ROOTFS_PREFIX="https://dl-cdn.alpinelinux.org/alpine/${PATH_VERSION}/releases"

case "$ARCH" in
'x86_64')
ROOTFS="${ROOTFS_PREFIX}/x86_64/alpine-minirootfs-${ROOTFS_VERSION}-x86_64.tar.gz"
PALERA1N="${PALERA1N_PREFIX}x86_64"
USBMUXD="${USBMUXD_PREFIX}x86_64"
;;
'x86')
ROOTFS="${ROOTFS_PREFIX}/x86/alpine-minirootfs-${ROOTFS_VERSION}-x86.tar.gz"
PALERA1N="${PALERA1N_PREFIX}x86"
USBMUXD="${USBMUXD_PREFIX}x86"
;;
'aarch64')
ROOTFS="${ROOTFS_PREFIX}/aarch64/alpine-minirootfs-${ROOTFS_VERSION}-aarch64.tar.gz"
PALERA1N="${PALERA1N_PREFIX}arm64"
USBMUXD="${USBMUXD_PREFIX}arm64"
;;
'armv7')
ROOTFS="${ROOTFS_PREFIX}/armv7/alpine-minirootfs-${ROOTFS_VERSION}-armv7.tar.gz"
PALERA1N="${PALERA1N_PREFIX}armel"
USBMUXD="${USBMUXD_PREFIX}armel"
;;
esac

echo $PALERA1N
echo $USBMUXD
echo $ROOTFS

# Clean
umount -v work/rootfs/{dev,sys,proc} >/dev/null 2>&1
rm -rf work
mkdir -pv work/{rootfs,iso/boot/grub}
cd work

# Fetch ROOTFS
#
curl -sL "$ROOTFS" | tar -xzC rootfs
mount -vo bind /dev rootfs/dev
mount -vt sysfs sysfs rootfs/sys
mount -vt proc proc rootfs/proc
cp /etc/resolv.conf rootfs/etc
cat << ! > rootfs/etc/apk/repositories
http://dl-cdn.alpinelinux.org/alpine/v3.12/main
http://dl-cdn.alpinelinux.org/alpine/v3.14/main
http://dl-cdn.alpinelinux.org/alpine/edge/community
http://dl-cdn.alpinelinux.org/alpine/edge/testing
!

sleep 2
# ROOTFS packages & services

#
cat << ! | chroot rootfs /usr/bin/env PATH=/usr/bin:/usr/local/bin:/bin:/usr/sbin:/sbin /bin/sh
apk update
apk upgrade
apk add bash alpine-base usbmuxd ncurses udev openssh-client sshpass newt
apk add bash alpine-base ncurses udev openssh-client sshpass newt
apk add --no-scripts linux-lts linux-firmware-none
rc-update add bootmisc
rc-update add hwdrivers
Expand All @@ -146,48 +115,51 @@ kernel/net/ipv4
!
chroot rootfs /usr/bin/env PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin \
/sbin/mkinitfs -F "palen1x" -k -t /tmp -q $(ls rootfs/lib/modules)
rm -rfv rootfs/lib/modules
rm -rf rootfs/lib/modules
mv -v rootfs/tmp/lib/modules rootfs/lib
find rootfs/lib/modules/* -type f -name "*.ko" -exec strip -v --strip-unneeded {} \; -exec xz --x86 -v9eT0 \;

find 'rootfs/lib/modules' -type f -name "*.ko" -exec strip -v --strip-unneeded {} +
find 'rootfs/lib/modules' -type f -name "*.ko" -exec xz --x86 -ze9T0 {} +

depmod -b rootfs $(ls rootfs/lib/modules)

# Echo TUI configurations
# create config shit
echo 'palen1x' > rootfs/etc/hostname
echo "PATH=$PATH:$HOME/.local/bin" > rootfs/root/.bashrc # d
echo "export PALEN1X_VERSION='$VERSION'" > rootfs/root/.bashrc
echo '/usr/bin/palen1x_menu' >> rootfs/root/.bashrc
echo "Rootless" > rootfs/usr/bin/.jbtype
echo "" > rootfs/usr/bin/.args
echo "-l" > rootfs/usr/bin/.args

# Unmount fs
umount -v rootfs/{dev,sys,proc}

# Fetch palera1n-c
#
curl -Lo rootfs/usr/bin/palera1n "$PALERA1N"
chmod +x rootfs/usr/bin/palera1n

# Copy files
curl -Lo rootfs/usr/sbin/usbmuxd "$USBMUXD"
chmod +x rootfs/usr/sbin/usbmuxd

cp -av ../inittab rootfs/etc
cp -v ../scripts/* rootfs/usr/bin
chmod -v 755 rootfs/usr/local/bin/*
ln -sv sbin/init rootfs/init
ln -sv ../../etc/terminfo rootfs/usr/share/terminfo # fix ncurses

# Boot config
cp -av rootfs/boot/vmlinuz-lts iso/boot/vmlinuz
cat << ! > iso/boot/grub/grub.cfg
insmod all_video
echo 'palen1x $VERSION'
linux /boot/vmlinuz quiet loglevel=3
linux /boot/vmlinuz console=tty0 fbcon=nodefer fbcon=logo-count:1
initrd /boot/initramfs.xz
boot
!

# initramfs
pushd rootfs
rm -rfv tmp/* boot/* var/cache/* etc/resolv.conf
rm -rf tmp/* boot/* var/cache/* etc/resolv.conf
find . | cpio -oH newc | xz -C crc32 --x86 -vz9eT$(nproc --all) > ../iso/boot/initramfs.xz
popd

# ISO creation
grub-mkrescue -o "palen1x-$ARCH.iso" iso --compress=xz
grub-mkrescue -o "palen1x-$ARCH-$VERSION.iso" iso --compress=xz
3 changes: 1 addition & 2 deletions scripts/palen1x_menu
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env bash
# Load functions and variables
. /usr/bin/common
PALEN1X_VERSION="1.1.0"

export NEWT_COLORS='root=,black
border=white,black
Expand All @@ -22,7 +21,7 @@ whiptail_height="$(($(tput lines) - 6))"
whiptail_width="$(($(tput cols) - 20))"

while true; do
CHOICE="$(whiptail --nocancel --title "palen1x $PALEN1X_VERSION | use arrow keys" --menu '' $whiptail_height $whiptail_width 9 \
CHOICE="$(whiptail --nocancel --title "palen1x | use arrow keys" --menu '' $whiptail_height $whiptail_width 9 \
'1' 'palera1n' \
'2' 'SSH' \
'3' 'Shell' \
Expand Down
4 changes: 2 additions & 2 deletions scripts/palera1n_options
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ if [ "$jbtype" = "Rootless" ]; then
"5") output5="-v";;
esac
done
echo "$output1 $output2 $output3 $output4 $output5" > /usr/bin/.args
echo "-l $output1 $output2 $output3 $output4 $output5" > /usr/bin/.args
/usr/bin/palera1n_menu
else
echo "Cancelled"
Expand Down Expand Up @@ -70,7 +70,7 @@ elif [ "$jbtype" = "Rootful" ]; then
"8") output8="-v";;
esac
done
echo "$output1 $output2 $output3 $output4 $output5 $output6 $output7 $output8" > /usr/bin/.args
echo "-f $output1 $output2 $output3 $output4 $output5 $output6 $output7 $output8" > /usr/bin/.args
/usr/bin/palera1n_menu
else
echo "Cancelled"
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.1.0
v1.1.1

0 comments on commit d737393

Please sign in to comment.