Add cdrom mounting live environment.
This commit is contained in:
parent
3080a5f53c
commit
7a480897d7
4 changed files with 117 additions and 13 deletions
60
Makefile
60
Makefile
|
@ -71,10 +71,13 @@ else
|
|||
SORTIX_INCLUDE_SOURCE?=yes
|
||||
endif
|
||||
|
||||
ISO_MOUNT?=no
|
||||
|
||||
include build-aux/dirs.mak
|
||||
|
||||
BUILD_NAME:=sortix-$(RELEASE)-$(MACHINE)
|
||||
|
||||
CHAIN_INITRD:=$(SORTIX_BUILDS_DIR)/$(BUILD_NAME).chain.tar
|
||||
LIVE_INITRD:=$(SORTIX_BUILDS_DIR)/$(BUILD_NAME).live.tar
|
||||
OVERLAY_INITRD:=$(SORTIX_BUILDS_DIR)/$(BUILD_NAME).overlay.tar
|
||||
SRC_INITRD:=$(SORTIX_BUILDS_DIR)/$(BUILD_NAME).src.tar
|
||||
|
@ -446,6 +449,25 @@ release-all-archs:
|
|||
|
||||
# Initial ramdisk
|
||||
|
||||
$(CHAIN_INITRD).uuid:
|
||||
mkdir -p `dirname $@`
|
||||
uuidgen > $@
|
||||
|
||||
$(CHAIN_INITRD): $(CHAIN_INITRD).uuid sysroot
|
||||
mkdir -p `dirname $(CHAIN_INITRD)`
|
||||
rm -rf $(CHAIN_INITRD).d
|
||||
mkdir -p $(CHAIN_INITRD).d
|
||||
mkdir -p $(CHAIN_INITRD).d/etc
|
||||
echo "UUID=`cat $(CHAIN_INITRD).uuid` / iso9660 ro 0 1" > $(CHAIN_INITRD).d/etc/fstab
|
||||
mkdir -p $(CHAIN_INITRD).d/etc/init
|
||||
echo require chain exit-code > $(CHAIN_INITRD).d/etc/init/default
|
||||
mkdir -p $(CHAIN_INITRD).d/sbin
|
||||
cp "$(SYSROOT)/sbin/init" $(CHAIN_INITRD).d/sbin
|
||||
cp "$(SYSROOT)/sbin/iso9660fs" $(CHAIN_INITRD).d/sbin
|
||||
LC_ALL=C ls -A $(CHAIN_INITRD).d | \
|
||||
tar -cf $(CHAIN_INITRD) -C $(CHAIN_INITRD).d --numeric-owner --owner=0 --group=0 -T -
|
||||
rm -rf $(CHAIN_INITRD).d
|
||||
|
||||
$(LIVE_INITRD): sysroot
|
||||
mkdir -p `dirname $(LIVE_INITRD)`
|
||||
rm -rf $(LIVE_INITRD).d
|
||||
|
@ -495,6 +517,42 @@ $(SORTIX_BUILDS_DIR):
|
|||
|
||||
# Bootable images
|
||||
|
||||
ifeq ($(ISO_MOUNT),yes)
|
||||
|
||||
$(SORTIX_BUILDS_DIR)/$(BUILD_NAME).iso: sysroot $(CHAIN_INITRD) $(CHAIN_INITRD).uuid $(SORTIX_BUILDS_DIR)
|
||||
rm -rf $(SORTIX_BUILDS_DIR)/$(BUILD_NAME)-iso
|
||||
mkdir -p $(SORTIX_BUILDS_DIR)/$(BUILD_NAME)-iso
|
||||
mkdir -p $(SORTIX_BUILDS_DIR)/$(BUILD_NAME)-iso/boot
|
||||
cp "$(SYSROOT)/boot/sortix.bin" $(SORTIX_BUILDS_DIR)/$(BUILD_NAME)-iso/boot/sortix.bin
|
||||
cp $(CHAIN_INITRD) $(SORTIX_BUILDS_DIR)/$(BUILD_NAME)-iso/boot/sortix.initrd
|
||||
mkdir -p $(SORTIX_BUILDS_DIR)/$(BUILD_NAME)-iso/etc
|
||||
echo "UUID=`cat $(CHAIN_INITRD).uuid` / iso9660 ro 0 1" > $(SORTIX_BUILDS_DIR)/$(BUILD_NAME)-iso/etc/fstab
|
||||
mkdir -p $(SORTIX_BUILDS_DIR)/$(BUILD_NAME)-iso/etc/init
|
||||
echo require single-user exit-code > $(SORTIX_BUILDS_DIR)/$(BUILD_NAME)-iso/etc/init/default
|
||||
echo "root::0:0:root:/root:sh" > $(SORTIX_BUILDS_DIR)/$(BUILD_NAME)-iso/etc/passwd
|
||||
echo "include /etc/default/passwd.d/*" >> $(SORTIX_BUILDS_DIR)/$(BUILD_NAME)-iso/etc/passwd
|
||||
echo "root::0:root" > $(SORTIX_BUILDS_DIR)/$(BUILD_NAME)-iso/etc/group
|
||||
echo "include /etc/default/group.d/*" >> $(SORTIX_BUILDS_DIR)/$(BUILD_NAME)-iso/etc/group
|
||||
(echo 'channel = $(CHANNEL)' && \
|
||||
echo 'release_key = $(RELEASE_KEY)' && \
|
||||
echo 'release_sig_url = $(RELEASE_SIG_URL)') > $(SORTIX_BUILDS_DIR)/$(BUILD_NAME)-iso/etc/upgrade.conf
|
||||
mkdir -p $(SORTIX_BUILDS_DIR)/$(BUILD_NAME)-iso/root -m 700
|
||||
cp -RT "$(SYSROOT)/etc/skel" $(SORTIX_BUILDS_DIR)/$(BUILD_NAME)-iso/root
|
||||
(echo "You can view the documentation for new users by typing:" && \
|
||||
echo && \
|
||||
echo " man user-guide" && \
|
||||
echo && \
|
||||
echo "You can view the installation instructions by typing:" && \
|
||||
echo && \
|
||||
echo " man installation") > $(SORTIX_BUILDS_DIR)/$(BUILD_NAME)-iso/root/welcome
|
||||
if [ -d "$(SYSROOT_OVERLAY)" ]; then cp -RT "$(SYSROOT_OVERLAY)" $(SORTIX_BUILDS_DIR)/$(BUILD_NAME)-iso; fi
|
||||
mkdir -p $(SORTIX_BUILDS_DIR)/$(BUILD_NAME)-iso/boot/grub
|
||||
build-aux/iso-grub-cfg.sh --platform $(HOST) --version $(VERSION) --mount $(SORTIX_BUILDS_DIR)/$(BUILD_NAME)-iso
|
||||
grub-mkrescue -o $(SORTIX_BUILDS_DIR)/$(BUILD_NAME).iso sysroot $(SORTIX_BUILDS_DIR)/$(BUILD_NAME)-iso -- -volid Sortix -volset_id `cat $(CHAIN_INITRD).uuid`
|
||||
rm -rf $(SORTIX_BUILDS_DIR)/$(BUILD_NAME)-iso
|
||||
|
||||
else
|
||||
|
||||
$(SORTIX_BUILDS_DIR)/$(BUILD_NAME).iso: sysroot $(LIVE_INITRD) $(OVERLAY_INITRD) $(SRC_INITRD) $(SYSTEM_INITRD) $(SORTIX_BUILDS_DIR)
|
||||
rm -rf $(SORTIX_BUILDS_DIR)/$(BUILD_NAME)-iso
|
||||
mkdir -p $(SORTIX_BUILDS_DIR)/$(BUILD_NAME)-iso
|
||||
|
@ -535,6 +593,8 @@ else # none
|
|||
endif
|
||||
rm -rf $(SORTIX_BUILDS_DIR)/$(BUILD_NAME)-iso
|
||||
|
||||
endif
|
||||
|
||||
.PHONY: iso
|
||||
iso: $(SORTIX_BUILDS_DIR)/$(BUILD_NAME).iso
|
||||
|
||||
|
|
|
@ -23,8 +23,9 @@ set -e
|
|||
this=$(which -- "$0")
|
||||
thisdir=$(dirname -- "$this")
|
||||
|
||||
platform=
|
||||
directory=
|
||||
mount=false
|
||||
platform=
|
||||
version=
|
||||
|
||||
dashdash=
|
||||
|
@ -44,8 +45,9 @@ for argument do
|
|||
|
||||
case $dashdash$argument in
|
||||
--) dashdash=yes ;;
|
||||
--platform=*) platform=$parameter ;;
|
||||
--platform) previous_option=platform ;;
|
||||
--platform=*) platform=$parameter ;;
|
||||
--mount) mount=true ;;
|
||||
--version=*) version=$parameter ;;
|
||||
--version) previous_option=version ;;
|
||||
-*) echo "$0: unrecognized option $argument" >&2
|
||||
|
@ -111,13 +113,23 @@ isinset() {
|
|||
cd "$directory"
|
||||
|
||||
kernel=$(maybe_compressed boot/sortix.bin)
|
||||
live_initrd=$(maybe_compressed boot/live.tar)
|
||||
overlay_initrd=$(maybe_compressed boot/overlay.tar)
|
||||
src_initrd=$(maybe_compressed boot/src.tar)
|
||||
system_initrd=$(maybe_compressed boot/system.tar)
|
||||
ports=$(ls repository |
|
||||
grep -E '\.tix\.tar\.xz$' |
|
||||
sed -E 's/\.tix\.tar\.xz$//')
|
||||
if $mount; then
|
||||
initrd=$(maybe_compressed boot/sortix.initrd)
|
||||
initrds=$initrd
|
||||
else
|
||||
live_initrd=$(maybe_compressed boot/live.tar)
|
||||
overlay_initrd=$(maybe_compressed boot/overlay.tar)
|
||||
src_initrd=$(maybe_compressed boot/src.tar)
|
||||
system_initrd=$(maybe_compressed boot/system.tar)
|
||||
initrds="$system_initrd $src_initrd $live_initrd $overlay_initrd"
|
||||
fi
|
||||
if $mount; then
|
||||
ports=
|
||||
else
|
||||
ports=$(ls repository |
|
||||
grep -E '\.tix\.tar\.xz$' |
|
||||
sed -E 's/\.tix\.tar\.xz$//')
|
||||
fi
|
||||
|
||||
mkdir -p boot/grub
|
||||
mkdir -p boot/grub/init
|
||||
|
@ -183,6 +195,12 @@ fi
|
|||
|
||||
set version="$version"
|
||||
set machine="$machine"
|
||||
set mount=$mount
|
||||
if \$mount; then
|
||||
chain='-- /sbin/init --target=chain'
|
||||
else
|
||||
chain=
|
||||
fi
|
||||
set base_menu_title="Sortix \$version for \$machine"
|
||||
set menu_title="\$base_menu_title"
|
||||
set title_single_user='live environment'
|
||||
|
@ -204,6 +222,8 @@ set enable_sshd=false
|
|||
|
||||
export version
|
||||
export machine
|
||||
export mount
|
||||
export chain
|
||||
export base_menu_title
|
||||
export menu_title
|
||||
export title_single_user
|
||||
|
@ -304,9 +324,10 @@ esac
|
|||
cat << EOF
|
||||
hook_kernel_pre
|
||||
echo -n "Loading /$kernel ($(human_size $kernel)) ... "
|
||||
multiboot /$kernel \$no_random_seed \$enable_network_drivers "\$@"
|
||||
multiboot /$kernel \$no_random_seed \$enable_network_drivers \$chain "\$@"
|
||||
echo done
|
||||
hook_kernel_post
|
||||
# TODO: Injecting configuration doesn't work for mounted cdroms.
|
||||
if ! \$enable_dhclient; then
|
||||
echo -n "Disabling dhclient ... "
|
||||
module /boot/grub/init/furthermore --create-to /etc/init/network
|
||||
|
@ -331,7 +352,7 @@ cat << EOF
|
|||
echo done
|
||||
fi
|
||||
EOF
|
||||
for initrd in $system_initrd $src_initrd $live_initrd $overlay_initrd; do
|
||||
for initrd in $initrds; do
|
||||
if [ "$initrd" = "$src_initrd" ]; then
|
||||
cat << EOF
|
||||
if \$enable_src; then
|
||||
|
@ -427,9 +448,11 @@ menuentry "\$title_sysupgrade" '-- /sbin/init --target=sysupgrade'
|
|||
|
||||
cat << EOF
|
||||
|
||||
if ! $mount; then
|
||||
menuentry "Select ports..." {
|
||||
configfile /boot/grub/ports.cfg
|
||||
}
|
||||
fi
|
||||
|
||||
menuentry "Advanced..." {
|
||||
configfile /boot/grub/advanced.cfg
|
||||
|
@ -461,6 +484,7 @@ else
|
|||
}
|
||||
fi
|
||||
|
||||
if ! $mount; then
|
||||
if "\$enable_src"; then
|
||||
menuentry "Disable loading source code" {
|
||||
enable_src=false
|
||||
|
@ -472,6 +496,7 @@ else
|
|||
configfile /boot/grub/advanced.cfg
|
||||
}
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "\$enable_network_drivers" = --disable-network-drivers ]; then
|
||||
menuentry "Enable networking drivers" {
|
||||
|
@ -485,6 +510,7 @@ else
|
|||
}
|
||||
fi
|
||||
|
||||
if ! $mount; then
|
||||
if \$enable_dhclient; then
|
||||
menuentry "Disable DHCP client" {
|
||||
enable_dhclient=false
|
||||
|
@ -524,6 +550,7 @@ fi
|
|||
menuentry "Select binary packages..." {
|
||||
configfile /boot/grub/tix.cfg
|
||||
}
|
||||
fi
|
||||
|
||||
hook_advanced_menu_post
|
||||
EOF
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2015, 2016, 2017, 2020, 2021 Jonas 'Sortie' Termansen.
|
||||
* Copyright (c) 2015, 2016, 2017, 2020, 2021, 2022 Jonas 'Sortie' Termansen.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
|
@ -221,3 +221,17 @@ char** read_lines_file(const char* path, size_t* out_count)
|
|||
*out_count = count;
|
||||
return lines;
|
||||
}
|
||||
|
||||
// TODO: Hack to support installing from a read-only root filesystem.
|
||||
#undef mkdtemp
|
||||
char* mkdtemp_hack(char* templ)
|
||||
{
|
||||
if ( mkdtemp(templ) )
|
||||
return templ;
|
||||
if ( errno != EROFS )
|
||||
return NULL;
|
||||
memcpy(templ + 1, "dev", 3);
|
||||
mkdir("/dev/tmp", 01777);
|
||||
setenv("TMPDIR", "/dev/tmp", 1);
|
||||
return mkdtemp(templ);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2015, 2016, 2020 Jonas 'Sortie' Termansen.
|
||||
* Copyright (c) 2015, 2016, 2020, 2022 Jonas 'Sortie' Termansen.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
|
@ -28,4 +28,7 @@ void write_random_seed(const char* path);
|
|||
char* read_string_file(const char* path);
|
||||
char** read_lines_file(const char* path, size_t* out_count);
|
||||
|
||||
char* mkdtemp_hack(char* templ);
|
||||
#define mkdtemp mkdtemp_hack
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue