This repository has been archived by the owner on Sep 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 73034ca
Showing
44 changed files
with
13,633 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
*tar* | ||
|
||
build/ | ||
|
||
ikeda | ||
ikeda_mount/ | ||
|
||
busybox* | ||
!busybox-version | ||
|
||
linux* | ||
!linux-version | ||
|
||
bash* | ||
!bash-version | ||
|
||
!zsh-version | ||
|
||
musl* | ||
musl-cross-make/ | ||
musl-out/ | ||
!musl-version | ||
!musl.config.mak | ||
|
||
kernel-headers/ | ||
|
||
!startup | ||
!sg-targets |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# ![](ikeda-icon.png) Ikeda | ||
Ikeda is a WIP BusyBox and musl-libc based Linux System | ||
|
||
![](ikeda.png) | ||
|
||
## Build Dependencies (for void or arch) | ||
- `base-devel` | ||
- `bc` | ||
- `git` | ||
- `musl` | ||
- `elfutils` | ||
- `flex` | ||
- `cmake` | ||
- `qemu` | ||
- `wget` | ||
- `openssl` | ||
|
||
Note: some distros will also require you to install `foo-devel`, `foo-dev`, or `libfoo` variants of certain packages. | ||
|
||
## General build: | ||
- `./build.sh` | ||
|
||
## Script notes: | ||
- Script will download and compile bits as needed | ||
- To force a re-compile of Linux, delete `work/linux-${kernel_version}/arch/x86_64/boot/bzImage` | ||
- To force a re-compile of BuxyBox, delete `work/busybox-${busybox_version}/busybox` | ||
- To force a re-compile of Bash, delete `work/bash-${bash_version}/out/bin/bash` | ||
- To force a re-compile of MUSL toolchain, delete `work/musl-out` | ||
- Alternatively, run `./clean.sh` to force rebuild and reclones of everything. | ||
- Use `./build.sh test -ng` to run qemu in TTY, rather than X/Wayland | ||
|
||
## Why the name? | ||
https://en.wikipedia.org/wiki/Ikeda_map | ||
|
||
## Sources: | ||
- Toolchain | ||
|
||
https://github.com/MichielDerhaeg/build-linux | ||
- Musl libc | ||
|
||
https://www.musl-libc.org/ | ||
- ZSH Project | ||
|
||
https://sourceforge.net/p/zsh/code/ci/master/tree/ | ||
- Our ZSH binary | ||
|
||
https://github.com/romkatv/zsh-bin | ||
|
||
## Notes: | ||
|
||
#### BusyBox | ||
|
||
Derhaeg's original BusyBox config was taken from Arch Linux, if any issues arise we can attempt to use Arch Linux's latest BusyBox config in its place. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#!/bin/bash | ||
|
||
cores=$(nproc) | ||
|
||
kernel_version=$(cat linux-version) | ||
busybox_version=$(cat busybox-version) | ||
bash_version=$(cat bash-version) | ||
|
||
base=$(pwd) | ||
|
||
tgt=$(losetup -P -f --show ikeda) | ||
mkdir ikeda_mount | ||
mkfs.ext4 ${tgt}p1 | ||
mount ${tgt}p1 ikeda_mount | ||
|
||
echo "Making raw filesystem" | ||
|
||
pushd ikeda_mount | ||
|
||
mkdir -p usr/{sbin,bin} bin sbin boot | ||
mkdir -p {dev,etc,home,lib,mnt,opt,proc,srv,sys,run} | ||
mkdir -p var/{lib,lock,log,run,spool,cache} | ||
install -d -m 0750 root | ||
install -d -m 1777 tmp | ||
mkdir -p usr/{include,lib,share,src,local} | ||
|
||
ln -s bin/bash usr/bin/zsh | ||
|
||
echo "Copying linux-${kernel_version} and busybox-${busybox_version}" | ||
cp ../linux-${kernel_version}/arch/x86_64/boot/bzImage boot/bzImage | ||
cp ../busybox-${busybox_version}/busybox usr/bin/busybox | ||
for util in $(./usr/bin/busybox --list-full); do | ||
ln -s /usr/bin/busybox $util | ||
done | ||
mkdir -p usr/share/udhcpc | ||
cp -rv ../busybox-${busybox_version}/examples/udhcp/* usr/share/udhcpc/. | ||
|
||
echo "Installing musl-${musl_version} . . ." | ||
cp -r ../musl-out/* usr/. | ||
|
||
echo "Installing bash-${bash_version} . . ." | ||
cp -rv ../bash-${bash_version}/out/* usr/. | ||
|
||
echo "Unpacking statically prebuilt zsh . . ." | ||
pushd usr | ||
curl -LO https://github.com/romkatv/zsh-bin/releases/download/v6.0.0/zsh-5.8-linux-x86_64.tar.gz | ||
tar -xf zsh-5.8-linux-x86_64.tar.gz | ||
rm zsh-5.8-linux-x86_64.tar.gz | ||
popd | ||
|
||
echo "Installing GRUB" | ||
grub-install --modules=part_msdos --target=i386-pc --boot-directory="$PWD/boot" ${tgt} | ||
partuuid=$(fdisk -l ../ikeda | grep "Disk identifier" | awk '{split($0,a,": "); print a[2]}' | sed 's/0x//g') | ||
mkdir -p boot/grub | ||
echo "linux /boot/bzImage quiet root=PARTUUID=${partuuid}-01" > boot/grub/grub.cfg | ||
echo "boot" >> boot/grub/grub.cfg | ||
|
||
popd | ||
|
||
echo "Final filesystem setup" | ||
cp -r filesystem/* ikeda_mount/. | ||
chmod -R -x ikeda_mount/etc/* | ||
chmod -R +x ikeda_mount/etc/init.d/* | ||
|
||
printf "Would you like a RootFS tarball? (y/N): " | ||
read RFS | ||
|
||
if [[ "$RFS" == "y" ]]; then | ||
rm ikeda.tar.gz | ||
pushd ikeda_mount && tar -czf ../ikeda.tar.gz * && popd | ||
fi | ||
|
||
umount -v ikeda_mount | ||
rm -rf ikeda_mount |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,234 @@ | ||
#!/bin/bash | ||
|
||
rootdir=$(pwd) | ||
|
||
if [[ ! -d build ]]; then | ||
./clean.sh | ||
fi | ||
|
||
pushd build | ||
|
||
cores=$(nproc) | ||
|
||
kernel_version=$(cat linux-version) | ||
busybox_version=$(cat busybox-version) | ||
bash_version=$(cat bash-version) | ||
# check `musl.config.mak` for MUSL toolchain versions | ||
|
||
printsection() { | ||
echo "----------" | ||
echo "$1" | ||
echo "----------" | ||
} | ||
|
||
confirm() { | ||
echo "$1" | ||
printf "Press enter to continue" | ||
read | ||
} | ||
|
||
getlinux() { | ||
echo "Getting kernel source" | ||
if [ ! -f linux-${kernel_version}.tar.xz ]; then | ||
wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-${kernel_version}.tar.xz | ||
fi | ||
|
||
if [ -d linux-${kernel_version} ]; then | ||
rm -rf linux-${kernel_version} | ||
fi | ||
|
||
tar -xf linux-${kernel_version}.tar.xz | ||
|
||
} | ||
|
||
makekernel() { | ||
|
||
printsection "Making Kernel" | ||
|
||
if [ ! -d linux-${kernel_version} ]; then | ||
echo "Ensuring source" | ||
getlinux | ||
fi | ||
|
||
if [ ! -f linux-${kernel_version}/arch/x86_64/boot/bzImage ]; then | ||
echo "Doing build." | ||
echo "Applying default config" | ||
cd linux-${kernel_version} | ||
make defconfig | ||
sed "s/=m/=y/" -i .config | ||
echo "Building" | ||
make -j${cores} | ||
cd ../ | ||
else | ||
echo "Kernel exists. Not rebuilding." | ||
echo "Delete linux-${kernel_version}/arch/x86_64/boot/bzImage to force a rebuild." | ||
fi | ||
|
||
} | ||
|
||
getbusybox() { | ||
echo "Ensuring busybox" | ||
if [[ ! -f busybox-${busybox_version}.tar.bz2 ]]; then | ||
wget https://busybox.net/downloads/busybox-${busybox_version}.tar.bz2 | ||
fi | ||
|
||
if [ -d busybox-${busybox_version} ]; then | ||
rm -rf busybox-${busybox_version} | ||
fi | ||
|
||
tar -xf busybox-${busybox_version}.tar.bz2 | ||
|
||
} | ||
|
||
buildbusybox() { | ||
|
||
printsection "Making BusyBox" | ||
|
||
if [ ! -f busybox-${busybox_version}/busybox ]; then | ||
if [ ! -d busybox-${busybox_version} ]; then | ||
getbusybox | ||
fi | ||
|
||
if [ -d kernel-headers ]; then | ||
pushd kernel-headers && git pull && popd | ||
else | ||
git clone https://github.com/sabotage-linux/kernel-headers | ||
fi | ||
|
||
cp bb-config busybox-${busybox_version}/.config | ||
pushd busybox-${busybox_version} && make CC=musl-gcc && cp .config ../bb-config && popd | ||
else | ||
echo "Not building BusyBox (program exists)" | ||
echo "Delete busybox-${busybox_version}/busybox to force a rebuild." | ||
fi | ||
|
||
} | ||
|
||
getbash() { | ||
printsection "Fetching bash" | ||
|
||
if [ ! -d bash-${bash_version} ]; then | ||
wget https://ftp.gnu.org/gnu/bash/bash-${bash_version}.tar.gz | ||
fi | ||
|
||
tar -xf bash-${bash_version}.tar.gz | ||
|
||
} | ||
|
||
buildbash() { | ||
printsection "Building bash" | ||
|
||
if [ ! -d bash-${bash_version} ]; then | ||
getbash | ||
fi | ||
if [ ! -f bash-${bash_version}/out/bin/bash ]; then | ||
pushd bash-${bash_version} && CC="musl-gcc -static" ./configure --without-bash-malloc --prefix="$(pwd)/out" && make -j${cores} && make install && popd | ||
fi | ||
|
||
} | ||
|
||
ensure_musl() { | ||
printsection "Checking MUSL source" | ||
|
||
if [ ! -d musl-cross-make ]; then | ||
git clone https://github.com/richfelker/musl-cross-make | ||
else | ||
pushd musl-cross-make && git pull && popd | ||
fi | ||
} | ||
|
||
musl() { | ||
printsection "Making MUSL" | ||
ensure_musl | ||
|
||
FP="$PWD/musl-out" | ||
cp musl.config.mak musl-cross-make/config.mak | ||
sed -i "s|SOMEPATHHERE|$FP|g" musl-cross-make/config.mak | ||
|
||
if [ ! -d musl-out ]; then | ||
mkdir musl-out | ||
pushd musl-cross-make | ||
make -j${cores} | ||
make install | ||
popd | ||
else | ||
echo "Not rebuilding MUSL stuff" | ||
fi | ||
|
||
} | ||
|
||
sg() { | ||
echo "We're in $PWD" | ||
if [[ -f static-get ]]; then | ||
rm static-get | ||
fi | ||
curl -LO https://raw.githubusercontent.com/minos-org/minos-static/master/static-get | ||
chmod +x static-get | ||
|
||
if [[ ! -f ../sg-targets ]]; then | ||
echo "Not using static-get for anything" | ||
else | ||
pushd filesystem/usr | ||
for tgt in $(cat ${rootdir}/sg-targets); do | ||
echo "Getting $tgt" | ||
../../static-get $tgt | ||
tar -xvf *tar* | ||
rm *tar* | ||
done | ||
popd | ||
fi | ||
|
||
} | ||
|
||
image() { | ||
makekernel | ||
buildbusybox | ||
buildbash | ||
musl | ||
sg | ||
|
||
printsection "Making final image" | ||
|
||
if [ -d ikeda_mount ]; then | ||
sudo rm ikeda_mount -rf | ||
fi | ||
|
||
if [ -f ikeda ]; then | ||
rm ikeda | ||
fi | ||
|
||
echo "Making Ikeda Linux image" | ||
fallocate -l1500M ikeda | ||
( | ||
echo "n" | ||
echo | ||
echo | ||
echo | ||
echo | ||
echo "w" | ||
) | fdisk ikeda | ||
|
||
sudo ./as_root.sh | ||
|
||
} | ||
|
||
test() { | ||
if [[ ! -f ikeda ]]; then | ||
image | ||
fi | ||
|
||
if [[ "$1" == "-ng" ]]; then | ||
qemu-system-x86_64 -enable-kvm -nographic ikeda | ||
else | ||
qemu-system-x86_64 -enable-kvm ikeda | ||
fi | ||
} | ||
|
||
# this is the main reason I want to re-write as a Makefile tbh | ||
if [[ "$1" == "" || "$1" == "test" ]]; then | ||
test "$2" | ||
elif [[ "$1" == "image" ]]; then | ||
image | ||
fi | ||
|
||
popd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
rm -rf build/ | ||
cp -r src build |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.