about summary refs log blame commit diff stats
path: root/tools/iso/linux
blob: 09401f115b73f3f43878db214be2107bc9c8cb32 (plain) (tree)
generated by cgit-pink 1.4.1-2-gfad0 (git 2.36.2.497.gbbea4dcf42) at 2024-10-31 15:23:49 +0000
' href='#n45'>45
         

                                                                           
 
                                                             

               
                                                                             




                                              
               
    
                                        


        
                                                    

                                
             
                                                                                                 
       
 
                        
    
                                 
                                                           

  
                                
                 

                                                          
                                                                  

                               
                                                                                                                                   
                             
                                               
 
                                         
                           


                                                                
 
                                  

                                                                                
                                                             




                                 
                                    
#!/bin/sh
# Package up an ELF binary generated by Mu into a bootable ISO image with a
# Linux kernel.
#
# Must be run on Linux, and from the top-level mu/ directory.
#
# Dependencies:
#   apt install build-essential flex bison wget libelf-dev libssl-dev xorriso
#
# Based on http://minimal.linux-bg.org (GPLv3)

set -e

if [ $# -ne 1 ]
then
  echo "Usage: `basename $0` <elf file>"
  exit 1
fi

echo "=== constructing initramfs out of SubX binary"
rm -rf tmp_linux/isoimage
mkdir -p tmp_linux/isoimage/boot
cp -i $1 init
echo init | cpio -R root:root -H newc -o | xz -9 --check=none > tmp_linux/isoimage/boot/rootfs.xz
rm init

if [ ! -d kernel.linux ]
then
  echo "=== cloning linux kernel"
  git clone https://github.com/akkartik/kernel kernel.linux
fi

echo "=== building linux kernel"
( cd kernel.linux
  make bzImage -j $(grep ^processor /proc/cpuinfo | wc -l)
)
cp *.linux/arch/x86/boot/bzImage tmp_linux/isoimage/boot/kernel.xz

echo "=== downloading syslinux"
test -f tmp_linux/syslinux-6.03.tar.xz  ||  wget https://kernel.org/pub/linux/utils/boot/syslinux/syslinux-6.03.tar.xz -P tmp_linux
echo "=== unpacking syslinux"
tar xf tmp_linux/syslinux-*.tar.xz -C tmp_linux

mkdir -p tmp_linux/isoimage/boot/syslinux
cp tools/iso/syslinux.cfg \
   tmp_linux/syslinux-*/bios/core/isolinux.bin \
   tmp_linux/syslinux-*/bios/com32/elflink/ldlinux/ldlinux.c32 \
   tmp_linux/isoimage/boot/syslinux

echo "=== generating mu_linux.iso"
# 'hybrid' ISO can also be used on non-optical media such as a disk or USB stick
xorriso -as mkisofs \
  -isohybrid-mbr tmp_linux/syslinux-*/bios/mbr/isohdpfx.bin \
  -c boot/syslinux/boot.cat \
  -b boot/syslinux/isolinux.bin \
    -no-emul-boot \
    -boot-load-size 4 \
    -boot-info-table \
  tmp_linux/isoimage -o mu_linux.iso