initial commit
This commit is contained in:
commit
bb75408ea4
9 files changed
+1536
No files matched your search
@@ -0,0 +1,4 @@
|
|||||||
|
out
|
||||||
|
build
|
||||||
|
downloads
|
||||||
|
.log
|
||||||
Executable
+90
@@ -0,0 +1,90 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Script to build linux install media image
|
||||||
|
version=0.0.1
|
||||||
|
# TolaMironcenko is licensed under MIT
|
||||||
|
|
||||||
|
. ./colors.sh
|
||||||
|
. ./funcs.sh
|
||||||
|
|
||||||
|
#------------ config ------------------
|
||||||
|
root=$(pwd)
|
||||||
|
disk="sdz"
|
||||||
|
distro_name="Simple"
|
||||||
|
distro_desc="Simple linux distro"
|
||||||
|
distro_codename="zero_zero_one"
|
||||||
|
hyperv_support="false"
|
||||||
|
out=$root/out
|
||||||
|
build=$root/build
|
||||||
|
kernel=""
|
||||||
|
busybox=""
|
||||||
|
sourcesfilename=sources.txt
|
||||||
|
initramfsfile=$root/initramfs/initramfs.txt
|
||||||
|
initramfspath=$build/initramfs
|
||||||
|
rootfsfile=$root/rootfs/rootfs.txt
|
||||||
|
rootfspath=$build/rootfs
|
||||||
|
#--------------------------------------
|
||||||
|
|
||||||
|
#-------- check root ------------------
|
||||||
|
if [ $(id -u) -ne 0 ]; then
|
||||||
|
printf "$URED** You are not root\n$RESET"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
#--------------------------------------
|
||||||
|
|
||||||
|
mkdir $out
|
||||||
|
mkdir $root/.log
|
||||||
|
|
||||||
|
download_sources() {
|
||||||
|
printf "$UGREEN** Downloading sources\n$RESET"
|
||||||
|
cat $sourcesfilename
|
||||||
|
if [ ! -d downloads ]; then mkdir downloads; fi
|
||||||
|
wget --input-file=$sourcesfilename --continue --directory-prefix=$root/downloads
|
||||||
|
check $? "Download sources"
|
||||||
|
}
|
||||||
|
|
||||||
|
initramfs() {
|
||||||
|
printf "$UGREEN** Building initramfs\n$RESET"
|
||||||
|
rm -r $initramfspath;
|
||||||
|
mkdir -p $initramfspath;
|
||||||
|
cd $initramfspath;
|
||||||
|
mkdir -p $(cat $initramfsfile);
|
||||||
|
cp $root/initramfs/init.in $initramfspath/init
|
||||||
|
chmod 755 $initramfspath/init
|
||||||
|
rm -r $build/busybox
|
||||||
|
mkdir -p $build/busybox
|
||||||
|
cd $build/busybox
|
||||||
|
tar -xjf $root/downloads/busybox-1.36.1.tar.bz2
|
||||||
|
check $? "Extract busybox"
|
||||||
|
cd busybox-1.36.1
|
||||||
|
cp $root/busybox/busybox-initramfs-config .config
|
||||||
|
export PATH=$PATH:/opt/toolchains/x86_64-buildroot-linux-uclibc-gcc/bin
|
||||||
|
printf "$UGREEN** Configuring busybox\n$RESET"
|
||||||
|
make CROSS_COMPILE=x86_64-buildroot-linux-uclibc- oldconfig &> $root/.log/busybox-configure.log
|
||||||
|
check $? "Configure busybox all logs in .log"
|
||||||
|
printf "$UGREEN** Building busybox\n$RESET"
|
||||||
|
make CROSS_COMPILE=x86_64-buildroot-linux-uclibc- -j16 &> $root/.log/busybox-build.log
|
||||||
|
check $? "Build busybox all logs in .log"
|
||||||
|
cp busybox $initramfspath/bin
|
||||||
|
cd $initramfspath/bin
|
||||||
|
for i in $(./busybox --list); do ln -s busybox $i; done
|
||||||
|
cd ..
|
||||||
|
find . | cpio -H newc -o | gzip > ../initramfs.img
|
||||||
|
check $? "Build initramfs.img image"
|
||||||
|
cd $root
|
||||||
|
}
|
||||||
|
|
||||||
|
rootfs() {
|
||||||
|
rm -rv $rootfspath
|
||||||
|
mkdir -pv $rootfspath
|
||||||
|
cd $rootfspath
|
||||||
|
mkdir -pv $(cat $rootfsfile)
|
||||||
|
}
|
||||||
|
|
||||||
|
clean() {
|
||||||
|
rm -rv $out
|
||||||
|
rm -rv $build
|
||||||
|
}
|
||||||
|
|
||||||
|
# download_sources
|
||||||
|
initramfs
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,74 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#reset
|
||||||
|
RESET="\033[0m"
|
||||||
|
|
||||||
|
#regularcolrs
|
||||||
|
GREEN="\033[0;32m" #GREEN
|
||||||
|
BLUE="\033[0;34m" #BLUE
|
||||||
|
YELLOW="\033[1;33m" #YELLOW
|
||||||
|
RED="\033[0;31m" #RED
|
||||||
|
BLACK="\033[0;30m" #BLACK
|
||||||
|
PURPLE="\033[0;35m" #PURPLE
|
||||||
|
CYAN="\033[0;36m" #CYAN
|
||||||
|
WHITE="\033[0;37m" #WHITE
|
||||||
|
|
||||||
|
#bold
|
||||||
|
BBLACK="\033[1;30m" #BLACK
|
||||||
|
BRED="\033[1;31m" #RED
|
||||||
|
BGREEN="\033[1;32m" #GREEN
|
||||||
|
BYELLOW="\033[1;33m" #YELLOW
|
||||||
|
BBLUE="\033[1;34m" #BLUE
|
||||||
|
BPURPLE="\033[1;35m" #PURPLE
|
||||||
|
BCYAN="\033[1;36m" #CYAN
|
||||||
|
BWHITE="\033[1;37m" #WHITE
|
||||||
|
|
||||||
|
#Underline
|
||||||
|
UBLACK="\033[4;30m" #BLACK
|
||||||
|
URED="\033[4;31m" #RED
|
||||||
|
UGREEN="\033[4;32m" #GREEN
|
||||||
|
UYELLOW="\033[4;33m" #YELLOW
|
||||||
|
UBLUE="\033[4;34m" #BLUE
|
||||||
|
UPURPLE="\033[4;35m" #PURPLE
|
||||||
|
UCYAN="\033[4;36m" #CYAN
|
||||||
|
UWHITE="\033[4;37m" #WHITE
|
||||||
|
|
||||||
|
#Background
|
||||||
|
ON_BLACK="\033[40m" #BLACK
|
||||||
|
ON_RED="\033[41m" #RED
|
||||||
|
ON_GREEN="\033[42m" #GREEN
|
||||||
|
ON_YELLOW="\033[43m" #YELLOW
|
||||||
|
ON_BLUE="\033[44m" #BLUE
|
||||||
|
ON_PURPLE="\033[45m" #PURPLE
|
||||||
|
ON_CYAN="\033[46m" #CYAN
|
||||||
|
ON_WHITE="\033[47m" #WHITE
|
||||||
|
|
||||||
|
#HighIntensity
|
||||||
|
IBLACK="\033[0;90m" #BLACK
|
||||||
|
IRED="\033[0;91m" #RED
|
||||||
|
IGREEN="\033[0;92m" #GREEN
|
||||||
|
IYELLOW="\033[0;93m" #YELLOW
|
||||||
|
IBLUE="\033[0;94m" #BLUE
|
||||||
|
IPURPLE="\033[0;95m" #PURPLE
|
||||||
|
ICYAN="\033[0;96m" #CYAN
|
||||||
|
IWHITE="\033[0;97m" #WHITE
|
||||||
|
|
||||||
|
#BoldHighIntensity
|
||||||
|
BIBLACK="\033[1;90m" #BLACK
|
||||||
|
BIRED="\033[1;91m" #RED
|
||||||
|
BIGREEN="\033[1;92m" #GREEN
|
||||||
|
BIYELLOW="\033[1;93m" #YELLOW
|
||||||
|
BIBLUE="\033[1;94m" #BLUE
|
||||||
|
BIPURPLE="\033[1;95m" #PURPLE
|
||||||
|
BICYAN="\033[1;96m" #CYAN
|
||||||
|
BIWHITE="\033[1;97m" #WHITE
|
||||||
|
|
||||||
|
#HighIntensitybackgrounds
|
||||||
|
ON_IBLACK="\033[0;100m" #BLACK
|
||||||
|
ON_IRED="\033[0;101m" #RED
|
||||||
|
ON_IGREEN="\033[0;102m" #GREEN
|
||||||
|
ON_IYELLOW="\033[0;103m" #YELLOW
|
||||||
|
ON_IBLUE="\033[0;104m" #BLUE
|
||||||
|
ON_IPURPLE="\033[0;105m" #PURPLE
|
||||||
|
ON_ICYAN="\033[0;106m" #CYAN
|
||||||
|
ON_IWHITE="\033[0;107m" #WHITE
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. ./colors.sh
|
||||||
|
|
||||||
|
check() {
|
||||||
|
if [ $1 -ne 0 ]; then
|
||||||
|
printf "$URED** ERROR: $2\n$RESET"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
printf "$UGREEN** SUCCESS: $2\n$RESET"
|
||||||
|
}
|
||||||
@@ -0,0 +1,109 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
problem()
|
||||||
|
{
|
||||||
|
printf "Encountered a problem!\n\nDropping you to a shell.\n\n"
|
||||||
|
sh
|
||||||
|
}
|
||||||
|
|
||||||
|
no_device()
|
||||||
|
{
|
||||||
|
printf "The device %s, which is supposed to contain the\n" $1
|
||||||
|
printf "root file system, does not exist.\n"
|
||||||
|
printf "Please fix this problem and exit this shell.\n\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
no_mount()
|
||||||
|
{
|
||||||
|
printf "Could not mount device %s\n" $1
|
||||||
|
printf "Sleeping forever. Please reboot and fix the kernel command line.\n\n"
|
||||||
|
printf "Maybe the device is formatted with an unsupported file system?\n\n"
|
||||||
|
printf "Or maybe filesystem type autodetection went wrong, in which case\n"
|
||||||
|
printf "you should add the rootfstype=... parameter to the kernel command line.\n\n"
|
||||||
|
printf "Available partitions:\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
do_mount_root()
|
||||||
|
{
|
||||||
|
mkdir /.root
|
||||||
|
[ -n "$rootflags" ] && rootflags="$rootflags,"
|
||||||
|
rootflags="$rootflags$ro"
|
||||||
|
|
||||||
|
case "$root" in
|
||||||
|
/dev/* ) device=$root ;;
|
||||||
|
UUID=* ) eval $root; device="$(findfs UUID=$UUID)" ;;
|
||||||
|
PARTUUID=*) eval $root; device="/dev/disk/by-partuuid/$PARTUUID" ;;
|
||||||
|
LABEL=* ) eval $root; device="/dev/disk/by-label/$LABEL" ;;
|
||||||
|
"" ) echo "No root device specified." ; problem ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
while [ ! -b "$device" ] ; do
|
||||||
|
no_device $device
|
||||||
|
problem
|
||||||
|
done
|
||||||
|
|
||||||
|
if ! mount -n -t "$rootfstype" -o "$rootflags" "$device" /.root ; then
|
||||||
|
no_mount $device
|
||||||
|
cat /proc/partitions
|
||||||
|
while true ; do sleep 10000 ; done
|
||||||
|
else
|
||||||
|
echo "Successfully mounted device $root"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
init=/sbin/init
|
||||||
|
root=
|
||||||
|
rootdelay=
|
||||||
|
rootfstype=auto
|
||||||
|
ro="ro"
|
||||||
|
rootflags=
|
||||||
|
device=
|
||||||
|
resume=
|
||||||
|
noresume=false
|
||||||
|
|
||||||
|
mount -n -t devtmpfs dev /dev
|
||||||
|
mount -n -t proc proc /proc
|
||||||
|
mount -n -t sysfs sys /sys
|
||||||
|
mount -n -t tmpfs run /run
|
||||||
|
|
||||||
|
mkdir -p /dev/pts
|
||||||
|
|
||||||
|
#mountpoint -q proc || mount -t proc proc proc
|
||||||
|
#mountpoint -q sys || mount -t sysfs sys sys
|
||||||
|
#mknod /dev/null c 1 3
|
||||||
|
#if ! mountpoint -q dev
|
||||||
|
#then
|
||||||
|
# mount -t tmpfs -o size=64k,mode=0755 tmpfs dev
|
||||||
|
#mount -t tmpfs -o mode=1777 tmpfs tmp
|
||||||
|
#mkdir -p dev/pts
|
||||||
|
#mdev -s
|
||||||
|
#fi
|
||||||
|
|
||||||
|
read -r cmdline < /proc/cmdline
|
||||||
|
|
||||||
|
for param in $cmdline ; do
|
||||||
|
case $param in
|
||||||
|
init=* ) init=${param#init=} ;;
|
||||||
|
root=* ) root=${param#root=} ;;
|
||||||
|
rootdelay=* ) rootdelay=${param#rootdelay=} ;;
|
||||||
|
rootfstype=*) rootfstype=${param#rootfstype=} ;;
|
||||||
|
rootflags=* ) rootflags=${param#rootflags=} ;;
|
||||||
|
resume=* ) resume=${param#resume=} ;;
|
||||||
|
noresume ) noresume=true ;;
|
||||||
|
ro ) ro="ro" ;;
|
||||||
|
rw ) ro="rw" ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -n "$rootdelay" ]; then sleep "$rootdelay"; fi
|
||||||
|
do_mount_root
|
||||||
|
|
||||||
|
for i in run tmp dev proc sys; do
|
||||||
|
[ -d /.root/$i ] || mkdir /.root/$i
|
||||||
|
mount -o bind /$i /.root/$i
|
||||||
|
done
|
||||||
|
mount -t devpts none /.root/dev/pts
|
||||||
|
|
||||||
|
echo 0 > /proc/sys/kernel/printk
|
||||||
|
|
||||||
|
exec switch_root /.root "$init" "$@"
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
bin
|
||||||
|
dev
|
||||||
|
mnt
|
||||||
|
proc
|
||||||
|
root
|
||||||
|
sys
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
boot
|
||||||
|
dev
|
||||||
|
etc
|
||||||
|
etc/init.d
|
||||||
|
etc/network
|
||||||
|
etc/network/if-down.d
|
||||||
|
etc/network/if-post-down.d
|
||||||
|
etc/network/if-pre-up.d
|
||||||
|
etc/network/if-up.d
|
||||||
|
etc/rc.d
|
||||||
|
home
|
||||||
|
mnt
|
||||||
|
opt
|
||||||
|
proc
|
||||||
|
root
|
||||||
|
run
|
||||||
|
srv
|
||||||
|
sys
|
||||||
|
usr
|
||||||
|
usr/bin
|
||||||
|
usr/include
|
||||||
|
usr/lib
|
||||||
|
usr/local
|
||||||
|
usr/local/bin
|
||||||
|
usr/share
|
||||||
|
usr/src
|
||||||
|
var
|
||||||
|
var/log
|
||||||
|
var/run
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
https://www.kernel.org/pub/linux/kernel/v6.x/linux-6.7.4.tar.xz
|
||||||
|
https://busybox.net/downloads/busybox-1.36.1.tar.bz2
|
||||||
Reference in new issue
Block a user