folder reorganization.
This commit is contained in:
9
.gitignore
vendored
Normal file
9
.gitignore
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
# artifacts
|
||||
outputs/
|
||||
artifacts/
|
||||
dependencies/
|
||||
|
||||
# Compiled Python bytecode
|
||||
*.py[cod]
|
||||
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
cd "$(dirname "$0")"
|
||||
dir=$(dirname "$0")
|
||||
echo $dir
|
||||
cat ./filesystem_containerfile | /usr/bin/podman build -f - -t patronagefs:latest
|
||||
podman run --rm -d --name patronagefs patronagefs:latest /bin/bash -c "while true; do sleep 1; done"
|
||||
podman export -o ./patronagefs.tar patronagefs
|
||||
echo 'exported.'
|
||||
podman stop patronagefs
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
cd "$(dirname "$0")"
|
||||
dir=$(dirname "$0")
|
||||
echo $dir
|
||||
[[ -d ./linux ]] || git clone --depth 1 https://github.com/torvalds/linux.git ./linux
|
||||
cat ./build_containerfile | /usr/bin/podman build --volume /lib/modules:/lib/modules:z -f - -t patronagekernel:latest .
|
||||
nice -n 20 /usr/bin/podman run -it --volume /lib/modules:/lib/modules:z --volume ./linux:/linux patronagekernel:latest
|
||||
cd $dir
|
||||
rm -rf initram/
|
||||
mkdir -p initram
|
||||
mkdir -p initram/{bin,dev,etc,lib,proc,sbin,sys,tmp,usr}
|
||||
mkdir -p initram/usr/{bin,sbin}
|
||||
mkdir -p initram/etc/{bin,sbin}
|
||||
mkdir -p initram/lib/modules/
|
||||
cp busybox ./initram/bin/
|
||||
#cp ./linux/drivers/block/nbd.ko initram/lib/modules/
|
||||
#cp ./linux/modules.builtin initram/lib/modules/
|
||||
#cp ./linux/modules.order initram/lib/modules/
|
||||
|
||||
chmod +x $dir/initram/bin/busybox
|
||||
$dir/initram/bin/busybox --install -s "$dir/initram/bin/"
|
||||
cp $dir/init.sh $dir/initram/init
|
||||
cp $dir/linux/arch/x86_64/boot/bzImage $dir/bzImage.efi
|
||||
chmod +x $dir/initram/init
|
||||
cd $dir/initram/
|
||||
echo $dir
|
||||
find . -print0 | cpio --null -ov --format=newc | gzip -9 > $dir/initramfs.cpio.gz
|
||||
echo "created iniramfs"
|
||||
@@ -3,6 +3,6 @@ run apt-get update
|
||||
run apt-get upgrade -y
|
||||
run apt-get install -y bison flex gcc make libncurses-dev git bc build-essential git libncurses5-dev lzop perl libssl-dev bison flex kmod device-tree-compiler dwarves libelf-dev libdwarf-dev libdw-dev python3 gawk zstd
|
||||
workdir /linux
|
||||
add ./container_cmd.sh /
|
||||
add ./config/container_cmd.sh /
|
||||
run chmod +x /container_cmd.sh
|
||||
cmd ["/usr/bin/bash","-c","/container_cmd.sh"]
|
||||
34
config/container_cmd.sh
Executable file
34
config/container_cmd.sh
Executable file
@@ -0,0 +1,34 @@
|
||||
set -e
|
||||
cores=$(nproc)
|
||||
echo "${cores}"
|
||||
/usr/bin/make clean
|
||||
/usr/bin/make defconfig
|
||||
sed -i 's/CONFIG_SYSTEM_TRUSTED_KEYS="\.\*"/CONFIG_SYSTEM_TRUSTED_KEYS=""/' ./.config
|
||||
sed -i 's/CONFIG_SYSTEM_REVOCATION_KEYS="\.\*"/CONFIG_SYSTEM_REVOCATION_KEYS=""/' ./.config
|
||||
sed -i 's/CONFIG_EFI_STUB="\.\*"/CONFIG_EFI_STUB="y"/' ./.config
|
||||
echo "CONFIG_FB_EFI=y" >> ./.config
|
||||
echo "CONFIG_EFI=y" >> ./.config
|
||||
echo "CONFIG_SYSFB=y" >> ./.config
|
||||
echo "CONFIG_FB=y" >> ./.config
|
||||
echo "CONFIG_VIRTIO=y" >> ./.config
|
||||
echo "CONFIG_FRAMEBUFFER_CONSOLE=y" >> ./.config
|
||||
echo "CONFIG_DRM_VIRTIO_GPU=y" >> ./.config
|
||||
echo "CONFIG_VIRTIO_PCI=y" >> ./.config
|
||||
echo "CONFIG_VIRTIO_BLK=y" >> ./.config
|
||||
echo "CONFIG_SCSI_VIRTIO=y" >> ./.config
|
||||
echo "CONFIG_VIRTIO_NET=y" >> ./.config
|
||||
echo "CONFIG_VIRTIO_CONSOLE=y" >> ./.config
|
||||
echo "CONFIG_VIRTIO_PCI_LIB=y" >> ./.config
|
||||
echo "CONFIG_VIRTIO_PCI_LIB_LEGACY=y" >> ./.config
|
||||
echo "CONFIG_VIRTIO_MENU=y" >> ./.config
|
||||
echo "CONFIG_VIRTIO_BALLOON=y" >> ./.config
|
||||
echo "CONFIG_VIRTIO_MEM=y" >> ./.config
|
||||
echo "CONFIG_VIRTIO_MMIO=y" >> ./.config
|
||||
echo "CONFIG_VIRTIO_MMIO_CMDLINE_DEVICES=y" >> ./.config
|
||||
echo "CONFIG_VIRTIO_IOMMU=y" >> ./.config
|
||||
echo "CONFIG_VIRTIO_FS=y" >> ./.config
|
||||
echo "CONFIG_PCI=y" >> ./.config
|
||||
echo "CONFIG_PCI_HOST_GENERIC=y" >> ./.config
|
||||
echo "CONFIG_DRM=y" >> ./.config
|
||||
/usr/bin/make olddefconfig
|
||||
/usr/bin/make -j ${cores}
|
||||
5
config/filesystem_cmd.sh
Normal file
5
config/filesystem_cmd.sh
Normal file
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
fakechroot
|
||||
debootstrap --version
|
||||
debootstrap --variant=fakechroot --arch amd64 bionic /tmp/rootfs/ http://archive.ubuntu.com/ubuntu
|
||||
11
config/filesystem_containerfile
Executable file
11
config/filesystem_containerfile
Executable file
@@ -0,0 +1,11 @@
|
||||
FROM ubuntu:latest
|
||||
run ls /
|
||||
run apt-get update
|
||||
run apt-get install -y pacstrap
|
||||
run mkdir -p /tmp/
|
||||
run mkdir -p /tmp/rootfs/
|
||||
workdir /linux
|
||||
add ./config/filesystem_cmd.sh /
|
||||
add ./config/polystrap.cfg /tmp
|
||||
run chmod +x /filesystem_cmd.sh
|
||||
cmd ["/usr/bin/bash","-c","/filesystem_cmd.sh"]
|
||||
@@ -1,16 +1,20 @@
|
||||
set timeout=1
|
||||
set default=0
|
||||
echo 'loading modules..'
|
||||
insmod normal
|
||||
insmod fat
|
||||
insmod part_gpt
|
||||
insmod gzio
|
||||
insmod ext
|
||||
|
||||
echo 'loading menu..'
|
||||
set root='(hd0,gpt1)'
|
||||
ls (hd0,gpt1)/EFI/patronage/
|
||||
menuentry "PatronageOS" {
|
||||
ls (hd0,gpt1)/EFI/patronage/
|
||||
|
||||
linux /EFI/patronage/bzImage boot=/init
|
||||
echo 'loaded kernel...'
|
||||
initrd /EFI/patronage/initramfs.cpio.gz
|
||||
echo 'loaded initial ramdisk...'
|
||||
boot
|
||||
echo 'done.'
|
||||
}
|
||||
@@ -1,13 +1,20 @@
|
||||
#!/bin/busybox sh
|
||||
/bin/busybox echo 'mounting filesystems and devices..'
|
||||
/bin/busybox mount -t devtmpfs devtmpfs /dev
|
||||
/bin/busybox mount -t proc proc /proc
|
||||
/bin/busybox mount -t sysfs none /sys
|
||||
/bin/busybox mount -t sysfs none /run
|
||||
/bin/busybox mkdir -p /newroot
|
||||
/bin/busybox mount /dev/sda2 /newroot
|
||||
#/bin/busybox mount --move /sys /newroot
|
||||
#/bin/busybox mount --move /dev /newroot
|
||||
#/bin/busybox mount --move /proc /newroot
|
||||
|
||||
#exec /bin/busybox sh
|
||||
|
||||
#/bin/busybox ln -s "/lib/modules/" "/lib/modules/$(uname -r)"
|
||||
#depmod -a
|
||||
#/bin/busybox modprobe nbd max_part=2
|
||||
|
||||
/bin/busybox echo 'switching root.'
|
||||
exec switch_root /newroot /bin/systemd
|
||||
#exec /bin/busybox sh
|
||||
|
||||
9
config/polystrap.cfg
Normal file
9
config/polystrap.cfg
Normal file
@@ -0,0 +1,9 @@
|
||||
# /tmp/polystrap.cfg
|
||||
[system]
|
||||
target = amd64-linux-gnu
|
||||
rootfs = /tmp/rootfs
|
||||
host = host
|
||||
download = http://deb.debian.org/debian
|
||||
distribution = bullseye
|
||||
components = main contrib non-free
|
||||
architectures = amd64
|
||||
@@ -1,16 +0,0 @@
|
||||
set -e
|
||||
cores=$(nproc)
|
||||
echo "${cores}"
|
||||
/usr/bin/make clean
|
||||
/usr/bin/make defconfig
|
||||
#cat /boot/config-$(uname -r) > ./linux/.config
|
||||
sed -i 's/CONFIG_SYSTEM_TRUSTED_KEYS="\.\*"/CONFIG_SYSTEM_TRUSTED_KEYS=""/' ./.config
|
||||
sed -i 's/CONFIG_SYSTEM_REVOCATION_KEYS="\.\*"/CONFIG_SYSTEM_REVOCATION_KEYS=""/' ./.config
|
||||
sed -i 's/CONFIG_EFI_STUB="\.\*"/CONFIG_EFI_STUB="n"/' ./.config
|
||||
echo "CONFIG_FB_EFI=y" >> ./.config
|
||||
echo "CONFIG_EFI=y" >> ./.config
|
||||
echo "CONFIG_SYSFB=y" >> ./.config
|
||||
echo "CONFIG_FB=y" >> ./.config
|
||||
echo "CONFIG_FRAMEBUFFER_CONSOLE=y" >> ./.config
|
||||
/usr/bin/make olddefconfig
|
||||
/usr/bin/make -j ${cores}
|
||||
@@ -1,19 +0,0 @@
|
||||
from ubuntu:latest
|
||||
run apt-get update
|
||||
run apt-get upgrade -y
|
||||
run apt-get install -y python3 htop opensnitch
|
||||
run apt-get install -y qemu-system python3-bpfcc python3-pip bpfcc-tools ipset
|
||||
run pip install --break-system-packages dnslib psutil
|
||||
run apt-get install -y ufw ubuntu-gnome-desktop ubuntu-gnome-default-settings
|
||||
run apt-get install -y doas lm-sensors gnome-shell-extension-prefs gnome-software-plugin-flatpak gnome-tweaks flatpak snapd net-tools iputils-ping
|
||||
run apt-get install -y bluetooth gnome-bluetooth pulseaudio-module-bluetooth pulseaudio
|
||||
run apt-get install -y systemd-resolved
|
||||
run flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
|
||||
run echo "permit persist :sudo as root" >> /etc/doas.conf
|
||||
run usermod -a -G sudo ubuntu
|
||||
run yes defaultpass | passwd ubuntu
|
||||
#run systemctl start snapd.service
|
||||
#run systemctl start flatpak.service
|
||||
#run snap install brave
|
||||
#run flatpak install flathub org.keepassxc.KeePassXC
|
||||
cmd ["/usr/bin/bash"]
|
||||
4
scripts/boot_image.sh
Executable file
4
scripts/boot_image.sh
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
cd "$(dirname "$0")"
|
||||
dir=$(dirname "$0")
|
||||
qemu-system-x86_64 -bios /usr/share/ovmf/OVMF.fd -drive format=raw,file='./boot_image.img' -usbdevice tablet -m 4G -smp 2 -vga std -enable-kvm -machine type=pc-q35-3.1,accel=kvm,kernel_irqchip=on
|
||||
11
scripts/build_filesystem.sh
Executable file
11
scripts/build_filesystem.sh
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
cd "$(dirname "$0")"
|
||||
cd ..
|
||||
echo $PWD
|
||||
mkdir -p outputs/root
|
||||
cat ./config/filesystem_containerfile | /usr/bin/podman build -f - -t patronagefs:latest .
|
||||
podman run --rm -it --volume ./outputs/root:/tmp/rootfs/:exec --name patronagefs patronagefs:latest
|
||||
echo 'exported.'
|
||||
|
||||
|
||||
@@ -7,12 +7,14 @@ set -e
|
||||
cd "$(dirname "$0")"
|
||||
dir=$(dirname "$0")
|
||||
echo "${dir}"
|
||||
sync
|
||||
if mountpoint -q "$dir/mnt/efi"; then
|
||||
umount "$dir/mnt/efi"
|
||||
fi
|
||||
if mountpoint -q "$dir/mnt/sys"; then
|
||||
umount "$dir/mnt/sys"
|
||||
fi
|
||||
echo 'creating image..'
|
||||
disk="boot_image.img"
|
||||
mnt="/mnt"
|
||||
efi_part="1"
|
||||
@@ -26,31 +28,29 @@ parted -s "$disk" set "$root_part" boot on
|
||||
parted -s "$disk" print
|
||||
kpartx -d "$disk"
|
||||
kpartx -avs "$disk"
|
||||
|
||||
echo 'mounting image as loopback device..'
|
||||
loop="$(kpartx -l boot_image.img | grep -ow 'loop[0-9]*' | head -n 1)"
|
||||
disk_efi="${loop}p1"
|
||||
disk_sys="${loop}p2"
|
||||
|
||||
echo 'formatting image partitions..'
|
||||
mkfs.fat -F32 -n EFI /dev/mapper/${disk_efi}
|
||||
mkfs.ext4 -L ROOT /dev/mapper/${disk_sys}
|
||||
echo 'creating mount points..'
|
||||
rm -rf $dir/mnt/
|
||||
mkdir -p $dir/mnt/
|
||||
mkdir -p $dir/mnt/{efi,sys,grub}
|
||||
echo 'mounting loopback devices..'
|
||||
mount -t vfat /dev/mapper/${disk_efi} $dir/mnt/efi
|
||||
mount -t ext4 /dev/mapper/${disk_sys} $dir/mnt/sys
|
||||
echo 'copying filesystem to mounted image'
|
||||
tar -xvf ./patronagefs.tar --directory $dir/mnt/sys/
|
||||
echo 'copied...'
|
||||
echo "${loop}"
|
||||
echo "${disk_efi}"
|
||||
echo "${disk_sys}"
|
||||
|
||||
#--grub-mkdevicemap=$dir/mnt/device.map
|
||||
#echo "(hd0) /dev/${disk_grub}" > $dir/mnt/device.map
|
||||
#--efi-directory=$dir/mnt/efi --boot-directory=$dir/mnt/grub --root-directory=$dir/mnt/sys
|
||||
grub-install --target=x86_64-efi --recheck --no-floppy --efi-directory=$dir/mnt/efi --boot-directory=$dir/mnt/efi --root-directory=$dir/mnt/sys --bootloader-id=patronage /dev/$loop
|
||||
#umount $dir/mnt/image
|
||||
#lsblk -f
|
||||
echo 'installing grub..'
|
||||
echo "loop dev: ${loop}"
|
||||
echo "efi loop: ${disk_efi}"
|
||||
echo "sys loop: ${disk_sys}"
|
||||
grub-install -s --compress=gz --target=x86_64-efi --recheck --no-floppy --efi-directory=$dir/mnt/efi --boot-directory=$dir/mnt/efi --root-directory=$dir/mnt/sys --bootloader-id=patronage /dev/$loop
|
||||
echo 'copying filesystem to mounted image..'
|
||||
tar -xf ./patronagefs.tar --directory $dir/mnt/sys/
|
||||
echo 'copied..'
|
||||
echo 'copying boot files..'
|
||||
mkdir -p $dir/mnt/efi/boot/
|
||||
cp $dir/initramfs.cpio.gz $dir/mnt/efi/
|
||||
mkdir -p $dir/mnt/efi/EFI/patronage/
|
||||
@@ -66,16 +66,20 @@ cp $dir/initramfs.cpio.gz $dir/mnt/efi/EFI/patronage/
|
||||
cp $dir/grub.cfg $dir/mnt/efi/EFI/patronage/
|
||||
#cp $dir/grub.cfg $dir/mnt/sys/boot/grub/
|
||||
cp $dir/grub.cfg $dir/mnt/efi/EFI/BOOT/
|
||||
echo 'unmounting..'
|
||||
|
||||
|
||||
|
||||
|
||||
sync
|
||||
#exit
|
||||
if mountpoint -q "$dir/mnt/efi"; then
|
||||
umount "$dir/mnt/efi"
|
||||
sync
|
||||
#fuser -kmv "$dir/mnt/efi"
|
||||
umount -lf "$dir/mnt/efi"
|
||||
fi
|
||||
|
||||
if mountpoint -q "$dir/mnt/sys"; then
|
||||
umount "$dir/mnt/sys"
|
||||
sync
|
||||
#fuser -kmv "$dir/mnt/sys"
|
||||
umount -lf "$dir/mnt/sys"
|
||||
fi
|
||||
|
||||
kpartx -d boot_image.img
|
||||
chmod 777 ./boot_image.img
|
||||
echo 'image built..'
|
||||
29
scripts/build_initramfs.sh
Executable file
29
scripts/build_initramfs.sh
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
cd "$(dirname "$0")"
|
||||
cd ..
|
||||
echo $PWD
|
||||
echo "cleaning filesystem and creating initram directories"
|
||||
rm -rf ./dependencies/initram/
|
||||
mkdir -p ./dependencies/
|
||||
mkdir -p ./outputs/
|
||||
mkdir -p ./dependencies/initram/{bin,dev,etc,lib,proc,sbin,sys,tmp,usr}
|
||||
mkdir -p ./dependencies/initram/usr/{bin,sbin}
|
||||
mkdir -p ./dependencies/initram/etc/{bin,sbin}
|
||||
mkdir -p ./dependencies/initram/lib/modules/
|
||||
echo "installing busybox"
|
||||
cp ./busybox ./dependencies/initram/bin/
|
||||
chmod +x ./dependencies/initram/bin/busybox
|
||||
./dependencies/initram/bin/busybox --install -s "./dependencies/initram/bin/"
|
||||
cp ./config/init.sh ./dependencies/initram/init
|
||||
chmod +x ./dependencies/initram/init
|
||||
echo "copying kernel"
|
||||
cp ./dependencies/linux/arch/x86_64/boot/bzImage ./outputs/bzImage.efi
|
||||
cd ./dependencies/initram
|
||||
cd "$(dirname "$0")"
|
||||
cd ..
|
||||
cd ./dependencies/initram
|
||||
echo $PWD
|
||||
find . -type f -name "*" -exec chmod +x {} +
|
||||
find . -print0 | cpio --null -ov --format=newc | gzip -9 > ../../outputs/initramfs.cpio.gz
|
||||
echo "created initramfs."
|
||||
17
scripts/build_kernel.sh
Executable file
17
scripts/build_kernel.sh
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
cd "$(dirname "$0")"
|
||||
cd ..
|
||||
mkdir -p ./dependencies
|
||||
rootdir=$(dirname "$0")
|
||||
dir=./$(dirname "$0")
|
||||
cd dependencies
|
||||
[[ -d ./linux ]] || git clone --depth 1 https://github.com/torvalds/linux.git ./linux
|
||||
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
cd ..
|
||||
echo $PWD
|
||||
cat ./config/build_containerfile | /usr/bin/podman build --volume /lib/modules:/lib/modules:z -f - -t patronagekernel:latest .
|
||||
nice -n 20 /usr/bin/podman run -it --volume /lib/modules:/lib/modules:z --volume ./dependencies/linux:/linux patronagekernel:latest
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
qemu-system-x86_64 -bios /usr/share/ovmf/OVMF.fd -drive format=raw,file='./boot_image.img' -usbdevice tablet -m 4G -smp 2 -vga virtio -enable-kvm -machine type=pc-q35-3.1,accel=kvm,kernel_irqchip=on
|
||||
Reference in New Issue
Block a user