add linux
This commit is contained in:
parent
dbdc494392
commit
29e2614225
@ -11,13 +11,10 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake.d/")
|
||||
find_package(NTFS3g REQUIRED)
|
||||
find_package(CoreUtils REQUIRED)
|
||||
find_package(MTools REQUIRED)
|
||||
# TODO: find_package for python (for GRUB)
|
||||
find_package(Python REQUIRED) # for GRUB
|
||||
# TODO: find_package for bison (for GRUB)
|
||||
# TODO: find_package for flex (for GRUB)
|
||||
# TODO: find_package for sfdisk (for disk image generation)
|
||||
# TODO: find_package for mkfs.vfat (for GRUB)
|
||||
# TODO: add mmd to mtools
|
||||
# TODO: add mkdir to coreutils
|
||||
|
||||
# make c drive mount point
|
||||
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lindows_c")
|
||||
@ -44,6 +41,27 @@ ExternalProject_Add(GRUB
|
||||
INSTALL_COMMAND make install
|
||||
)
|
||||
|
||||
# build linux
|
||||
add_executable(LinuxConfig IMPORTED)
|
||||
set_property(TARGET LinuxConfig PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/src/linux/config)
|
||||
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/linux")
|
||||
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/linux/modules")
|
||||
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/linux/headers")
|
||||
ExternalProject_Add(Linux
|
||||
GIT_REPOSITORY "https://github.com/torvalds/linux"
|
||||
GIT_TAG "v6.7"
|
||||
GIT_PROGRESS TRUE
|
||||
UPDATE_COMMAND ""
|
||||
CONFIGURE_COMMAND ${CoreUtils_Copy_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/src/linux/config .config
|
||||
BUILD_COMMAND make
|
||||
BUILD_IN_SOURCE TRUE
|
||||
INSTALL_COMMAND ${CoreUtils_Copy_EXECUTABLE} arch/x86_64/boot/bzImage ${CMAKE_CURRENT_BINARY_DIR}/linux
|
||||
COMMAND make modules_install INSTALL_MOD_PATH=${CMAKE_CURRENT_BINARY_DIR}/linux/modules
|
||||
COMMAND make headers_install INSTALL_HDR_PATH=${CMAKE_CURRENT_BINARY_DIR}/linux/headers
|
||||
STEP_TARGETS install
|
||||
)
|
||||
ExternalProject_Add_StepDependencies(Linux configure LinuxConfig)
|
||||
|
||||
# this should probably be a shell script, i unfortunately do not care
|
||||
add_custom_command(OUTPUT lindows_c.img
|
||||
# create empty 128MiB disk image
|
||||
@ -63,26 +81,30 @@ add_custom_command(OUTPUT lindows_c.img
|
||||
lindows_c
|
||||
|
||||
# create system folders
|
||||
COMMAND mkdir ARGS lindows_c/Windows
|
||||
COMMAND mkdir ARGS lindows_c/Windows/GRUB
|
||||
COMMAND mkdir ARGS lindows_c/Windows/GRUB/x86_64-efi
|
||||
COMMAND ${CoreUtils_Mkdir_EXECUTABLE} ARGS lindows_c/Windows
|
||||
COMMAND ${CoreUtils_Mkdir_EXECUTABLE} ARGS lindows_c/Windows/GRUB
|
||||
COMMAND ${CoreUtils_Mkdir_EXECUTABLE} ARGS lindows_c/Windows/GRUB/x86_64-efi
|
||||
|
||||
# grub stuff
|
||||
COMMAND cp ${CMAKE_CURRENT_BINARY_DIR}/grub/lib/grub/x86_64-efi/* lindows_c/Windows/GRUB/x86_64-efi
|
||||
|
||||
# copy linux kernel from host please replace with custom kernel
|
||||
COMMAND cp ARGS /boot/vmlinuz-linux lindows_c/Windows/vmlinuz-linux
|
||||
COMMAND ${CoreUtils_Copy_EXECUTABLE} ARGS ${CMAKE_CURRENT_BINARY_DIR}/grub/lib/grub/x86_64-efi/* lindows_c/Windows/GRUB/x86_64-efi
|
||||
COMMAND ${CoreUtils_Copy_EXECUTABLE} ARGS ${CMAKE_CURRENT_SOURCE_DIR}/src/grub/grub.cfg lindows_c/Windows/GRUB/grub.cfg
|
||||
# install the kernel
|
||||
COMMAND ${CoreUtils_Copy_EXECUTABLE} ARGS ${CMAKE_CURRENT_BINARY_DIR}/linux/bzImage lindows_c/Windows/vmlinux.exe
|
||||
|
||||
# create users folder
|
||||
COMMAND mkdir ARGS lindows_c/Users
|
||||
COMMAND ${CoreUtils_Mkdir_EXECUTABLE} ARGS lindows_c/Users
|
||||
|
||||
# unmount filesystem
|
||||
COMMAND "umount" ARGS lindows_c
|
||||
|
||||
DEPENDS
|
||||
Linux-install
|
||||
src/grub/grub.cfg
|
||||
)
|
||||
|
||||
# this makes the efi system partition
|
||||
add_custom_command(OUTPUT lindows_efi.img
|
||||
COMMAND mkdir ARGS -p lindows_efi/
|
||||
COMMAND ${CoreUtils_Mkdir_EXECUTABLE} ARGS -p lindows_efi/
|
||||
COMMAND "${CMAKE_CURRENT_BINARY_DIR}/grub/bin/grub-mkimage" ARGS
|
||||
-p /Windows/GRUB
|
||||
-O x86_64-efi
|
||||
@ -94,9 +116,10 @@ add_custom_command(OUTPUT lindows_efi.img
|
||||
of=lindows_efi.img
|
||||
bs=1M
|
||||
count=33
|
||||
COMMAND mkfs.vfat lindows_efi.img -F 32
|
||||
COMMAND mmd -i lindows_efi.img ::/EFI
|
||||
COMMAND mmd -i lindows_efi.img ::/EFI/BOOT
|
||||
#COMMAND mkfs.vfat lindows_efi.img -F 32
|
||||
COMMAND ${MTools_Format_EXECUTABLE} -i lindows_efi.img
|
||||
COMMAND ${MTools_Mkdir_EXECUTABLE} -i lindows_efi.img ::/EFI
|
||||
COMMAND ${MTools_Mkdir_EXECUTABLE} -i lindows_efi.img ::/EFI/BOOT
|
||||
COMMAND ${MTools_Copy_EXECUTABLE} -i lindows_efi.img lindows_efi/grubx64.efi ::/EFI/BOOT/BOOTX64.EFI
|
||||
DEPENDS src/grub/grub-early.cfg
|
||||
)
|
||||
@ -105,8 +128,8 @@ add_custom_command(OUTPUT lindows_efi.img
|
||||
add_custom_command(OUTPUT lindows.img
|
||||
COMMAND echo ARGS label: gpt > disk.sfdisk
|
||||
COMMAND echo ARGS unit: sectors >> disk.sfdisk
|
||||
COMMAND echo ARGS 1MiB 33MiB C12A7328-F81F-11D2-BA4B-00A0C93EC93B - >> disk.sfdisk
|
||||
COMMAND echo ARGS 34MiB 128MiB EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 - >> disk.sfdisk
|
||||
COMMAND echo ARGS start=1MiB, size=33MiB, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B >> disk.sfdisk
|
||||
COMMAND echo ARGS start=34MiB, size=128MiB, type=EBD0A0A2-B9E5-4433-87C0-68B6B72699C7, uuid=48D29DA8-2FF8-4F23-BA1A-0E8CCFC329E2 >> disk.sfdisk
|
||||
COMMAND "${CoreUtils_dd_EXECUTABLE}" ARGS
|
||||
if=/dev/zero
|
||||
of=lindows.img
|
||||
|
@ -21,27 +21,28 @@ Defines the following variables:
|
||||
True if the system has coreutils
|
||||
``CoreUtils_dd_EXECUTABLE``
|
||||
Path to dd
|
||||
``CoreUtils_Mkdir_EXECUTABLE``
|
||||
Path to mkdir
|
||||
``CoreUtils_Copy_EXECUTABLE``
|
||||
|
||||
#]=============================]
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
# dd
|
||||
find_program(CoreUtils_dd_EXECUTABLE
|
||||
NAMES dd
|
||||
)
|
||||
find_program(CoreUtils_dd_EXECUTABLE NAMES dd)
|
||||
|
||||
# mkdir
|
||||
find_program(CoreUtils_Mkdir_EXECUTABLE NAMES mkdir)
|
||||
|
||||
# cp
|
||||
find_program(CoreUtils_Copy_EXECUTABLE NAMES cp)
|
||||
|
||||
find_package_handle_standard_args(CoreUtils
|
||||
FOUND_VAR CoreUtils_FOUND
|
||||
REQUIRED_VARS
|
||||
CoreUtils_dd_EXECUTABLE
|
||||
CoreUtils_Mkdir_EXECUTABLE
|
||||
CoreUtils_Copy_EXECUTABLE
|
||||
)
|
||||
|
||||
# coreutils really only looks good lowercase, but it doesnt fit with cmakes other stuff then
|
||||
if (CoreUtils_Found)
|
||||
# add dd
|
||||
add_executable(CoreUtils::dd UNKNOWN IMPORTED)
|
||||
set_target_properties(CoreUtils::dd PROPERTIES
|
||||
IMPORTED_LOCATION "${CoreUtils_dd_EXECUTABLE}"
|
||||
)
|
||||
endif()
|
||||
|
@ -15,6 +15,8 @@ Defines the following variables:
|
||||
Path to mformat
|
||||
``MTools_Copy_EXECUTABLE``
|
||||
Path to mcopy
|
||||
``MTools_Mkdir_EXECUTABLE``
|
||||
Path to mmd
|
||||
|
||||
#]=============================]
|
||||
|
||||
@ -26,9 +28,13 @@ find_program(MTools_Format_EXECUTABLE NAMES mformat)
|
||||
# mcopy
|
||||
find_program(MTools_Copy_EXECUTABLE NAMES mcopy)
|
||||
|
||||
# mmd
|
||||
find_program(MTools_Mkdir_EXECUTABLE NAMES mmd)
|
||||
|
||||
find_package_handle_standard_args(MTools
|
||||
FOUND_VAR MTools_FOUND
|
||||
REQUIRED_VARS
|
||||
MTools_Format_EXECUTABLE
|
||||
MTools_Copy_EXECUTABLE
|
||||
MTools_Mkdir_EXECUTABLE
|
||||
)
|
||||
|
8
cmake.d/FindPython.cmake
Normal file
8
cmake.d/FindPython.cmake
Normal file
@ -0,0 +1,8 @@
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_program(Python_EXECUTABLE NAMES python)
|
||||
|
||||
find_package_handle_standard_args(Python
|
||||
REQUIRED_VARS
|
||||
Python_EXECUTABLE
|
||||
)
|
@ -1,2 +1,6 @@
|
||||
set root=(hd0,gpt2)
|
||||
set prefix=($root)/Windows/GRUB
|
||||
|
||||
insmod normal
|
||||
|
||||
normal
|
||||
|
6
src/grub/grub.cfg
Normal file
6
src/grub/grub.cfg
Normal file
@ -0,0 +1,6 @@
|
||||
# clear screen
|
||||
clear
|
||||
|
||||
# boot
|
||||
linux /Windows/vmlinux.exe console=tty0 console=ttyS0
|
||||
boot
|
5395
src/linux/config
Normal file
5395
src/linux/config
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user