Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Mar 23, 2024
0 parents commit 22c1810
Show file tree
Hide file tree
Showing 58 changed files with 2,839 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/build-bootstrap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Build bootstrap
on: [workflow_dispatch]
jobs:
build:
runs-on: ubuntu-latest
steps:
# - name: Fix permissions
# run: sudo chown -R $USER:$USER /home/runner/work/android-linux-bootstrap
- name: Checkout the code
uses: actions/checkout@v3
with:
submodules: true
- name: Install Depends
run: android-linux-bootstrap/install.sh
- name: Build Alpine
run: |
cd android-linux-bootstrap/scripts
./alpine-bootstraps.sh
- name: Alpine Linux Release
uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: ${{ secrets.TOKEN_GITHUB }}
automatic_release_tag: "latest-alpine"
prerelease: false
title: "Alpine"
files: |
./scripts/build/*.zip
- name: Build Ubuntu
run: |
cd android-linux-bootstrap/scripts
./ubuntu-bootstraps.sh
- name: Ubuntu Linux Release
uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: ${{ secrets.TOKEN_GITHUB }}
automatic_release_tag: "latest-ubuntu"
prerelease: false
title: "Ubuntu"
files: |
./scripts/build/*.zip
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*/build/

*.iso
*.tar.gz
alpine-shell/checkra1n
*.md

external/proot/build
external/minitar/build
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "external/proot"]
path = external/proot
url = https://github.com/feelfreelinux/build-proot-android
[submodule "external/minitar"]
path = external/minitar
url = https://github.com/green-green-avk/build-libarchive-minitar-android
9 changes: 9 additions & 0 deletions alpine-shell/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

iso/
alpine_rootfs/
*.iso

*.gz

build/
checkra1n
138 changes: 138 additions & 0 deletions alpine-shell/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
#!/bin/bash
#
# checkn1x build script
# https://asineth.me/checkn1x
#

mkdir -p build
cd build

export rootfs_folder=rootfs
export name_iso="custom-linux"
export alpine_version="3.19.0"

mkdir -p $rootfs_folder

mkdir -p iso/boot/grub

rm -rf ./$name_iso.iso
rm -rf iso/boot/initramfs.xz

if [ -d "$rootfs_folder/bin" ]
then
echo "Skip Extract Alpine Miniroot"
else
if [ -f "../alpine-minirootfs-$alpine_version-x86_64.tar.gz" ]
then
echo "Extract Alpien Miniroot"
tar -xzf ../alpine-minirootfs-$alpine_version-x86_64.tar.gz -C ./$rootfs_folder
else
echo "Download Alpine Root"
wget https://dl-cdn.alpinelinux.org/alpine/edge/releases/x86_64/alpine-minirootfs-$alpine_version-x86_64.tar.gz
echo "Extract Alpien Miniroot"
tar -xzf ../alpine-minirootfs-$alpine_version-x86_64.tar.gz -C ./$rootfs_folder
fi
fi


umount -v $rootfs_folder/dev >/dev/null 2>&1
umount -v $rootfs_folder/sys >/dev/null 2>&1
umount -v $rootfs_folder/proc >/dev/null 2>&1


mount -vo bind /dev $rootfs_folder/dev
mount -vt sysfs sysfs $rootfs_folder/sys
mount -vt proc proc $rootfs_folder/proc

echo "nameserver 8.8.8.8 \n\
nameserver 8.8.4.4" > $rootfs_folder/etc/resolv.conf

echo "Add Repo"
cat << ! > $rootfs_folder/etc/apk/repositories
https://dl-cdn.alpinelinux.org/alpine/v3.19/main
https://dl-cdn.alpinelinux.org/alpine/v3.19/community
https://dl-cdn.alpinelinux.org/alpine/edge/testing
!

echo "Add Install Package Core"
cat << ! | chroot $rootfs_folder /usr/bin/env PATH=/usr/bin:/bin:/usr/sbin:/sbin /bin/sh
apk update
apk upgrade
apk add alpine-base ncurses-terminfo-base udev usbmuxd libusbmuxd-progs openssh-client sshpass usbutils
apk add --no-scripts linux-lts linux-firmware-none
rc-update add bootmisc
rc-update add hwdrivers
rc-update add udev
rc-update add udev-trigger
rc-update add udev-settle
!


# # kernel modules
# cat << ! > $rootfs_folder/etc/mkinitfs/features.d/azkadev.modules
# kernel/drivers/usb/host
# kernel/drivers/hid/usbhid
# kernel/drivers/hid/hid-generic.ko
# kernel/drivers/hid/hid-cherry.ko
# kernel/drivers/hid/hid-apple.ko
# kernel/net/ipv4
# !

# chroot $rootfs_folder /usr/bin/env PATH=/usr/bin:/bin:/usr/sbin:/sbin \
# /sbin/mkinitfs -F "azkadev" -k -t /tmp -q $(ls $rootfs_folder/lib/modules)

# rm -rfv $rootfs_folder/lib/modules
# mv -v $rootfs_folder/tmp/lib/modules $rootfs_folder/lib
# find $rootfs_folder/lib/modules/* -type f -name "*.ko" | xargs -n1 -P`nproc` -- strip -v --strip-unneeded
# find $rootfs_folder/lib/modules/* -type f -name "*.ko" | xargs -n1 -P`nproc` -- xz --x86 -v9eT0
# sudo depmod -b $rootfs_folder $(ls $rootfs_folder/lib/modules)


echo "Umount"
umount -v $rootfs_folder/dev >/dev/null 2>&1
umount -v $rootfs_folder/sys >/dev/null 2>&1
umount -v $rootfs_folder/proc >/dev/null 2>&1


# kernel modules
cat << ! > $rootfs_folder/etc/inittab
# /etc/inittab
::sysinit:/sbin/openrc sysinit
::wait:/sbin/openrc default
tty1::respawn:/bin/login -f root
tty2::respawn:/bin/login -f root
tty3::respawn:/bin/login -f root
tty4::respawn:/bin/login -f root
tty5::respawn:/bin/login -f root
::ctrlaltdel:/sbin/reboot -f
# Stuff to do before rebooting
::shutdown:/sbin/openrc shutdown
!


ln -sv sbin/init $rootfs_folder/init
ln -sv ../../etc/terminfo $rootfs_folder/usr/share/terminfo # fix ncurses

cp -av $rootfs_folder/boot/vmlinuz-lts iso/boot/vmlinuz
cat << ! > iso/boot/grub/grub.cfg
insmod all_video
echo 'Custom Alpine Linux'
linux /boot/vmlinuz quiet loglevel=3
initrd /boot/initramfs.xz
boot
!

# initramfs
pushd $rootfs_folder
rm -rfv boot/*
rm -rfv tmp/*
rm -rfv var/cache/*
find . | cpio -oH newc | xz -C crc32 --x86 -vz9eT0 > ../iso/boot/initramfs.xz
popd

# iso creation
grub-mkrescue -o "./$name_iso.iso" iso --compress=xz

# sudo chroot alpine_rootfs /usr/bin/env PATH=/usr/bin:/bin:/usr/sbin:/sbin /bin/sh
echo "Test Script: sudo qemu-system-x86_64 -cpu host -smp cores=4 -enable-kvm -m 4G -cdrom build/$name_iso.iso"
qemu-system-x86_64 -cpu host -smp cores=4 -enable-kvm -m 4G -cdrom ./$name_iso.iso
12 changes: 12 additions & 0 deletions alpine-shell/clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
#
# checkn1x build script
# https://asineth.me/checkn1x
#

echo "Umount"
umount -v $rootfs_folder/dev >/dev/null 2>&1
umount -v $rootfs_folder/sys >/dev/null 2>&1
umount -v $rootfs_folder/proc >/dev/null 2>&1

rm -rf build
Binary file added alpine-shell/icon_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added alpine-shell/icon_light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions android-linux-bootstrap/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
scripts/build
7 changes: 7 additions & 0 deletions android-linux-bootstrap/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# /bin/sh

cd scripts/


./alpine-bootstraps.sh
./ubuntu-bootstraps.sh
67 changes: 67 additions & 0 deletions android-linux-bootstrap/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# /bin/sh
echo "started install Dependencies"

export DEBIAN_FRONTEND=noninteractive

export ANDROID_SDK="$HOME/Android/Sdk"
export ANDROID_SDK_ROOT="$HOME/Android/Sdk"
export ANDROID_HOME="$HOME/Android/Sdk"
export PATH="$ANDROID_HOME/cmdline-tools/latest/bin/:$PATH"
export PATH="$ANDROID_HOME/cmdline-tools/latest/:$PATH"
export PATH="$ANDROID_HOME/emulator/:$PATH"
export PATH="$ANDROID_HOME/platform-tools/:$PATH"
export PATH="$ANDROID_SDK:$PATH"
export PATH="$PATH:$HOME/development/flutter/bin"

echo "export ANDROID_SDK=$HOME/Android/Sdk" >> ~/.bashrc
echo "export ANDROID_SDK_ROOT=$HOME/Android/Sdk" >> ~/.bashrc
echo "export ANDROID_HOME=$HOME/Android/Sdk" >> ~/.bashrc
echo "export PATH=$ANDROID_HOME/cmdline-tools/latest/bin/:$PATH" >> ~/.bashrc
echo "export PATH=$ANDROID_HOME/cmdline-tools/latest/:$PATH" >> ~/.bashrc
echo "export PATH=$ANDROID_HOME/emulator/:$PATH" >> ~/.bashrc
echo "export PATH=$ANDROID_HOME/platform-tools/:$PATH" >> ~/.bashrc
echo "export PATH=$ANDROID_SDK:$PATH" >> ~/.bashrc
echo "export PATH=$PATH:$HOME/development/flutter/bin" >> ~/.bashrc
mkdir "$HOME/development/"

source ~/.bashrc

sudo apt-get update

sudo apt-get install -y --no-install-recommends \
wget \
curl \
make \
git \
zlib1g-dev \
libssl-dev \
gperf \
cmake \
clang \
libc++-dev \
libc++abi-dev \
php-cli \
g++ \
ninja-build \
pkg-config \
libgtk-3-dev \
liblzma-dev \
xz-utils \
unzip \
xvfb \
openjdk-11-jdk

mkdir -p $HOME/Android/Sdk/cmdline-tools
wget -q https://dl.google.com/android/repository/commandlinetools-linux-7583922_latest.zip -O /tmp/tools.zip
unzip -q /tmp/tools.zip -d $HOME/Android/Sdk/cmdline-tools
sudo cp -rf $HOME/Android/Sdk/cmdline-tools/cmdline-tools $HOME/Android/Sdk/cmdline-tools/latest
echo "export PATH=$PATH:$HOME/Android/Sdk/cmdline-tools/latest/bin" >> ~/.bashrc

yes "y" | sdkmanager
yes "y" | sdkmanager --update
yes "y" | sdkmanager "platform-tools"
yes "y" | sdkmanager "platforms;android-30"
yes "y" | sdkmanager "patcher;v4"
yes "y" | sdkmanager "build-tools;30.0.2"
yes "y" | sdkmanager "ndk;21.3.6528147"
yes "y" | sdkmanager --licenses
7 changes: 7 additions & 0 deletions android-linux-bootstrap/scripts/add-user.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/system/bin/sh
# generate user files in the bootstrap

mkdir -p bootstrap/home/$1
echo "$1:x:$USER_ID:$USER_ID:guest:/home/$1:/bin/sh" >> bootstrap/etc/passwd
echo "$1 ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/$1
chmod 0440 /etc/sudoers.d/$1
Loading

0 comments on commit 22c1810

Please sign in to comment.