Update to use installer to produce disk images with bootloader
This commit is contained in:
parent
68e3308165
commit
47c0b7edad
8
.gitmodules
vendored
8
.gitmodules
vendored
|
@ -1,7 +1,3 @@
|
||||||
[submodule "bootloader"]
|
|
||||||
path = bootloader
|
|
||||||
url = https://gitlab.redox-os.org/redox-os/bootloader.git
|
|
||||||
branch = master
|
|
||||||
[submodule "cookbook"]
|
[submodule "cookbook"]
|
||||||
path = cookbook
|
path = cookbook
|
||||||
url = https://gitlab.redox-os.org/redox-os/cookbook.git
|
url = https://gitlab.redox-os.org/redox-os/cookbook.git
|
||||||
|
@ -26,7 +22,3 @@
|
||||||
path = relibc
|
path = relibc
|
||||||
url = https://gitlab.redox-os.org/redox-os/relibc.git
|
url = https://gitlab.redox-os.org/redox-os/relibc.git
|
||||||
branch = master
|
branch = master
|
||||||
[submodule "bootloader-coreboot"]
|
|
||||||
path = bootloader-coreboot
|
|
||||||
url = https://gitlab.redox-os.org/redox-os/bootloader-coreboot.git
|
|
||||||
branch = master
|
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit 91703d9efd0af54fa53627f63161c4b0f5a9554c
|
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit 6c31909f75f3d707efa606e546113ee508be0748
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit f1a806b28824d4dacaa93201470782b06a312cea
|
Subproject commit e8e4687c050f1fa783af783eac172e77ad3e752b
|
24
mk/config.mk
24
mk/config.mk
|
@ -56,30 +56,6 @@ INSTALLER=\
|
||||||
export PATH="$(PREFIX_PATH):$$PATH" && \
|
export PATH="$(PREFIX_PATH):$$PATH" && \
|
||||||
installer/target/release/redox_installer $(INSTALLER_FLAGS)
|
installer/target/release/redox_installer $(INSTALLER_FLAGS)
|
||||||
|
|
||||||
## Bootloader variables
|
|
||||||
ifeq ($(ARCH),x86_64)
|
|
||||||
BOOTLOADER_BIOS=build/bootloader.bin
|
|
||||||
BOOTLOADER_BIOS_LIVE=build/bootloader-live.bin
|
|
||||||
BOOTLOADER_EFI=build/bootloader.efi
|
|
||||||
BOOTLOADER_EFI_LIVE=build/bootloader-live.efi
|
|
||||||
BOOTLOADER_EFI_PATH=efi/boot/bootx64.efi
|
|
||||||
BOOTLOADER_TARGET=x86-unknown-none
|
|
||||||
else ifeq ($(ARCH),i686)
|
|
||||||
BOOTLOADER_BIOS=build/bootloader.bin
|
|
||||||
BOOTLOADER_BIOS_LIVE=build/bootloader-live.bin
|
|
||||||
BOOTLOADER_EFI_PATH=efi/boot/bootia32.efi
|
|
||||||
BOOTLOADER_TARGET=x86-unknown-none
|
|
||||||
else ifeq ($(ARCH),aarch64)
|
|
||||||
BOOTLOADER_EFI=build/bootloader.efi
|
|
||||||
BOOTLOADER_EFI_LIVE=build/bootloader-live.efi
|
|
||||||
BOOTLOADER_EFI_PATH=efi/boot/bootaa64.efi
|
|
||||||
BOOTLOADER_TARGET=aarch64-unknown-none
|
|
||||||
else
|
|
||||||
$(error Unsupported ARCH for bootloader "$(ARCH)")
|
|
||||||
endif
|
|
||||||
EFI_TARGET=$(ARCH)-unknown-uefi
|
|
||||||
PARTED=/sbin/parted
|
|
||||||
|
|
||||||
## Cross compiler variables
|
## Cross compiler variables
|
||||||
AR=$(TARGET)-gcc-ar
|
AR=$(TARGET)-gcc-ar
|
||||||
AS=$(TARGET)-as
|
AS=$(TARGET)-as
|
||||||
|
|
51
mk/disk.mk
51
mk/disk.mk
|
@ -1,22 +1,18 @@
|
||||||
build/harddrive.bin: build/filesystem.bin $(BOOTLOADER_EFI) $(BOOTLOADER_BIOS)
|
build/harddrive.bin: $(FILESYSTEM_CONFIG)
|
||||||
rm -f $@ $@.partial
|
$(HOST_CARGO) build --manifest-path installer/Cargo.toml --release
|
||||||
env \
|
mkdir -p build
|
||||||
PARTED=$(PARTED) \
|
rm -rf $@ $@.partial
|
||||||
BOOTLOADER_EFI=$(BOOTLOADER_EFI) \
|
fallocate --posix --length "$(FILESYSTEM_SIZE)MiB" $@.partial
|
||||||
BOOTLOADER_EFI_PATH=$(BOOTLOADER_EFI_PATH) \
|
$(INSTALLER) -c $(FILESYSTEM_CONFIG) $@.partial
|
||||||
BOOTLOADER_BIOS=$(BOOTLOADER_BIOS) \
|
mv $@.partial $@
|
||||||
./mk/disk.sh $@.partial $<
|
|
||||||
mv "$@.partial" "$@"
|
|
||||||
|
|
||||||
build/livedisk.bin: build/filesystem.bin $(BOOTLOADER_EFI_LIVE) $(BOOTLOADER_BIOS_LIVE)
|
build/livedisk.bin: $(FILESYSTEM_CONFIG)
|
||||||
rm -f $@ $@.partial
|
$(HOST_CARGO) build --manifest-path installer/Cargo.toml --release
|
||||||
env \
|
mkdir -p build
|
||||||
PARTED=$(PARTED) \
|
rm -rf $@ $@.partial
|
||||||
BOOTLOADER_EFI=$(BOOTLOADER_EFI_LIVE) \
|
fallocate --posix --length "$(FILESYSTEM_SIZE)MiB" $@.partial
|
||||||
BOOTLOADER_EFI_PATH=$(BOOTLOADER_EFI_PATH) \
|
$(INSTALLER) -c $(FILESYSTEM_CONFIG) --live $@.partial
|
||||||
BOOTLOADER_BIOS=$(BOOTLOADER_BIOS_LIVE) \
|
mv $@.partial $@
|
||||||
./mk/disk.sh $@.partial $<
|
|
||||||
mv "$@.partial" "$@"
|
|
||||||
|
|
||||||
build/livedisk.iso: build/livedisk.bin.gz
|
build/livedisk.iso: build/livedisk.bin.gz
|
||||||
rm -rf build/iso/
|
rm -rf build/iso/
|
||||||
|
@ -27,3 +23,22 @@ build/livedisk.iso: build/livedisk.bin.gz
|
||||||
-no-emul-boot -boot-load-size 4 -boot-info-table \
|
-no-emul-boot -boot-load-size 4 -boot-info-table \
|
||||||
build/iso/
|
build/iso/
|
||||||
isohybrid $@
|
isohybrid $@
|
||||||
|
|
||||||
|
mount: FORCE
|
||||||
|
mkdir -p build/filesystem/
|
||||||
|
$(HOST_CARGO) build --manifest-path redoxfs/Cargo.toml --release --bin redoxfs
|
||||||
|
redoxfs/target/release/redoxfs build/harddrive.bin build/filesystem/
|
||||||
|
sleep 2
|
||||||
|
pgrep redoxfs
|
||||||
|
|
||||||
|
mount_extra: FORCE
|
||||||
|
mkdir -p build/filesystem/
|
||||||
|
$(HOST_CARGO) build --manifest-path redoxfs/Cargo.toml --release --bin redoxfs
|
||||||
|
redoxfs/target/release/redoxfs build/extra.bin build/filesystem/
|
||||||
|
sleep 2
|
||||||
|
pgrep redoxfs
|
||||||
|
|
||||||
|
unmount: FORCE
|
||||||
|
sync
|
||||||
|
-$(FUMOUNT) build/filesystem/ || true
|
||||||
|
rm -rf build/filesystem/
|
||||||
|
|
81
mk/disk.sh
81
mk/disk.sh
|
@ -1,81 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
#TODO: move to installer
|
|
||||||
|
|
||||||
function usage {
|
|
||||||
echo "$0 [disk] [filesystem]" >&2
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
if [ -z "$1" ]
|
|
||||||
then
|
|
||||||
echo "invalid disk '$1'" >&2
|
|
||||||
usage
|
|
||||||
fi
|
|
||||||
DISK="$1"
|
|
||||||
|
|
||||||
if [ ! -f "$2" ]
|
|
||||||
then
|
|
||||||
echo "invalid filesystem '$2'" >&2
|
|
||||||
usage
|
|
||||||
fi
|
|
||||||
FILESYSTEM="$2"
|
|
||||||
|
|
||||||
MiB=1048576
|
|
||||||
|
|
||||||
set -ex
|
|
||||||
|
|
||||||
# Calculate filesystem partition size
|
|
||||||
fs_disk_size="$(du -m "${FILESYSTEM}" | cut -f1)"
|
|
||||||
fs_disk_blkcount="$(expr "${fs_disk_size}" \* "$(expr "${MiB}" / 512)")"
|
|
||||||
fs_start="2048"
|
|
||||||
fs_end="$(expr "${fs_start}" + "${fs_disk_blkcount}")"
|
|
||||||
fs_last="$(expr "${fs_end}" - 1)"
|
|
||||||
|
|
||||||
if [ -n "${BOOTLOADER_EFI}" ]
|
|
||||||
then
|
|
||||||
# Calculate EFI partition size
|
|
||||||
efi_disk_size="$(expr "$(du -m "${BOOTLOADER_EFI}" | cut -f1)" + 1)"
|
|
||||||
efi_disk_blkcount="$(expr "$efi_disk_size" \* "$(expr "${MiB}" / 512)")"
|
|
||||||
efi_start="${fs_end}"
|
|
||||||
efi_end="$(expr "${efi_start}" + "${efi_disk_blkcount}")"
|
|
||||||
efi_last="$(expr "${efi_end}" - 1)"
|
|
||||||
|
|
||||||
# Populate an EFI system partition
|
|
||||||
dd if=/dev/zero of="${DISK}.esp" bs="${MiB}" count="${efi_disk_size}"
|
|
||||||
mkfs.vfat "${DISK}.esp"
|
|
||||||
mmd -i "${DISK}.esp" efi
|
|
||||||
mmd -i "${DISK}.esp" efi/boot
|
|
||||||
mcopy -i "${DISK}.esp" "${BOOTLOADER_EFI}" "::${BOOTLOADER_EFI_PATH}"
|
|
||||||
|
|
||||||
disk_size="$(expr "${fs_disk_size}" + "${efi_disk_size}" + 2)"
|
|
||||||
else
|
|
||||||
disk_size="$(expr "${fs_disk_size}" + 2)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Create the disk
|
|
||||||
dd if=/dev/zero of="${DISK}" bs="${MiB}" count="${disk_size}"
|
|
||||||
|
|
||||||
# Create partition table
|
|
||||||
"${PARTED}" -s -a minimal "${DISK}" mklabel gpt
|
|
||||||
"${PARTED}" -s -a minimal "${DISK}" mkpart redox ext4 "${fs_start}s" "${fs_last}"s
|
|
||||||
if [ -n "${BOOTLOADER_EFI}" ]
|
|
||||||
then
|
|
||||||
"${PARTED}" -s -a minimal "${DISK}" mkpart EFI fat32 "${efi_start}"s "${efi_last}s"
|
|
||||||
"${PARTED}" -s -a minimal "${DISK}" set 2 boot on
|
|
||||||
"${PARTED}" -s -a minimal "${DISK}" set 2 esp on
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Write the partitions
|
|
||||||
dd if="${FILESYSTEM}" of="${DISK}" bs=512 seek="${fs_start}" count="${fs_disk_blkcount}" conv=notrunc
|
|
||||||
if [ -n "${BOOTLOADER_EFI}" ]
|
|
||||||
then
|
|
||||||
dd if="${DISK}.esp" of="${DISK}" bs=512 seek="${efi_start}" count="${efi_disk_blkcount}" conv=notrunc
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Write BIOS bootloader if applicable
|
|
||||||
if [ -n "${BOOTLOADER_BIOS}" ]
|
|
||||||
then
|
|
||||||
dd if="${BOOTLOADER_BIOS}" of="${DISK}" bs=1 count=446 conv=notrunc
|
|
||||||
dd if="${BOOTLOADER_BIOS}" of="${DISK}" bs=512 skip=34 seek=34 conv=notrunc
|
|
||||||
fi
|
|
|
@ -1,43 +0,0 @@
|
||||||
build/filesystem.bin: prefix $(FILESYSTEM_CONFIG)
|
|
||||||
mkdir -p build
|
|
||||||
$(HOST_CARGO) build --manifest-path cookbook/Cargo.toml --release
|
|
||||||
$(HOST_CARGO) build --manifest-path installer/Cargo.toml --release
|
|
||||||
$(HOST_CARGO) build --manifest-path redoxfs/Cargo.toml --release
|
|
||||||
-$(FUMOUNT) build/filesystem/ || true
|
|
||||||
rm -rf $@ $@.partial build/filesystem/
|
|
||||||
fallocate --posix --length "$(FILESYSTEM_SIZE)MiB" $@.partial
|
|
||||||
$(HOST_CARGO) run --release \
|
|
||||||
--manifest-path redoxfs/Cargo.toml \
|
|
||||||
--bin redoxfs-mkfs \
|
|
||||||
-- $(REDOXFS_MKFS_FLAGS) $@.partial
|
|
||||||
mkdir -p build/filesystem/
|
|
||||||
redoxfs/target/release/redoxfs $@.partial build/filesystem/
|
|
||||||
sleep 2
|
|
||||||
pgrep redoxfs
|
|
||||||
$(INSTALLER) -c $(FILESYSTEM_CONFIG) build/filesystem/
|
|
||||||
cp -v $(FILESYSTEM_CONFIG) build/filesystem/filesystem.toml
|
|
||||||
mkdir -pv build/filesystem/pkg
|
|
||||||
cp -v cookbook/build/id_ed25519.pub.toml build/filesystem/pkg/id_ed25519.pub.toml
|
|
||||||
sync
|
|
||||||
-$(FUMOUNT) build/filesystem/ || true
|
|
||||||
rm -rf build/filesystem/
|
|
||||||
mv $@.partial $@
|
|
||||||
|
|
||||||
mount: FORCE
|
|
||||||
mkdir -p build/filesystem/
|
|
||||||
$(HOST_CARGO) build --manifest-path redoxfs/Cargo.toml --release --bin redoxfs
|
|
||||||
redoxfs/target/release/redoxfs build/harddrive.bin build/filesystem/
|
|
||||||
sleep 2
|
|
||||||
pgrep redoxfs
|
|
||||||
|
|
||||||
mount_extra: FORCE
|
|
||||||
mkdir -p build/filesystem/
|
|
||||||
$(HOST_CARGO) build --manifest-path redoxfs/Cargo.toml --release --bin redoxfs
|
|
||||||
redoxfs/target/release/redoxfs build/extra.bin build/filesystem/
|
|
||||||
sleep 2
|
|
||||||
pgrep redoxfs
|
|
||||||
|
|
||||||
unmount: FORCE
|
|
||||||
sync
|
|
||||||
-$(FUMOUNT) build/filesystem/ || true
|
|
||||||
rm -rf build/filesystem/
|
|
Loading…
Reference in a new issue