SHA256
commit
01490efee1
7 files changed
+244
No files matched your search
@@ -0,0 +1 @@
|
||||
/target
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
create_config() {
|
||||
CONFIG=$(cat <<EOF
|
||||
set timeout=60
|
||||
set default=0
|
||||
|
||||
menuentry "SemiOS LiveCD (Copy to RAM)" {
|
||||
search --no-floppy --set=root --file /boot/linux.img
|
||||
|
||||
linux /boot/linux.img early_mount=LABEL=SEMIOS:/livecd root=live:/livecd/rootfs.img copytoram ro
|
||||
initrd /boot/initramfs.img
|
||||
}
|
||||
EOF
|
||||
)
|
||||
echo "${CONFIG}" > "$1/grub.cfg"
|
||||
}
|
||||
|
||||
copy_kernel() {
|
||||
mkdir -p "$1/isoroot/boot"
|
||||
local kprefix=$(packie --chroot "$1/root" print "package.prefix.linux")
|
||||
cp "$1/root/${kprefix}/vmlinuz" "$1/isoroot/boot/linux.img" 2> /dev/null || \
|
||||
cp "$1/root/${kprefix}/vmlinux" "$1/isoroot/boot/linux.img" 2> /dev/null || \
|
||||
exit 1
|
||||
cp "$1/root/${kprefix}/initramfs.img" "$1/isoroot/boot/initramfs.img"
|
||||
}
|
||||
|
||||
grub_arch() {
|
||||
case "${ARCH}" in
|
||||
aarch64-semios-linux)
|
||||
echo arm64-efi
|
||||
;;
|
||||
riscv64-semios-linux)
|
||||
echo riscv64-efi
|
||||
;;
|
||||
x86_64-semios-linux)
|
||||
echo x86_64-efi
|
||||
;;
|
||||
*)
|
||||
echo "mkliveimage: Unsupported architecture for ISO builds"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
efi_image_name() {
|
||||
case "${ARCH}" in
|
||||
aarch64-semios-linux)
|
||||
echo "BOOTAA64.EFI"
|
||||
;;
|
||||
riscv64-semios-linux)
|
||||
echo "BOOTRISCV64.EFI"
|
||||
;;
|
||||
x86_64-semios-linux)
|
||||
echo "BOOTX64.EFI"
|
||||
;;
|
||||
*)
|
||||
echo "mkliveimage: Unsupported architecture for ISO builds"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
create_efiboot_img() {
|
||||
dd if=/dev/zero of="$1/efiboot.img" bs=1M count=16
|
||||
mkfs.vfat -n EFIBOOT "$1/efiboot.img"
|
||||
if [ "${SUDO}" -eq 1 ]; then
|
||||
sudo mount --mkdir -o "uid=$(id -u)" "$1/efiboot.img" "$1/efiboot" || exit 1
|
||||
else
|
||||
mount --mkdir "$1/efiboot.img" "$1/efiboot" || exit 1
|
||||
fi
|
||||
mkdir -p "$1/efiboot/EFI/BOOT"
|
||||
grub-mkstandalone -o "$1/efiboot/EFI/BOOT/$(efi_image_name)" -O "$(grub_arch)" \
|
||||
--fonts "" --themes "" --locales "" \
|
||||
--install-modules "part_gpt part_msdos fat linux search boot normal gzio iso9660" \
|
||||
"boot/grub/grub.cfg=$1/grub.cfg"
|
||||
if [ "${SUDO}" -eq 1 ]; then
|
||||
sudo umount "$1/efiboot" || exit 1
|
||||
else
|
||||
umount "$1/efiboot" || exit 1
|
||||
fi
|
||||
mv "$1/efiboot.img" "$1/isoroot/efiboot.img"
|
||||
}
|
||||
|
||||
create_iso() {
|
||||
if [ "$(uname -s)" -eq "Linux" ]; then
|
||||
mkfs.erofs -z lz4 -L "SEMIOSLIVEROOT" --mkfs-time --all-root "$1/rootfs.img" "$1/root"
|
||||
create_config "$1"
|
||||
create_efiboot_img $1
|
||||
mkdir -p "$1/isoroot"
|
||||
cp "$1/rootfs.img" "$1/isoroot/rootfs.img"
|
||||
copy_kernel "$1"
|
||||
xorriso -as mkisofs -r -V "SEMIOS" \
|
||||
-J -joliet-long \
|
||||
-iso-level 3 \
|
||||
-e "efiboot.img" -no-emul-boot \
|
||||
-isohybrid-gpt-basdat \
|
||||
-o "${OUTPUT}" "$1/isoroot"
|
||||
else
|
||||
echo "Unsupported kernel."
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
create_tarball() {
|
||||
if [ "$(uname -s)" -eq "Linux" ]; then
|
||||
unshare -U \
|
||||
tar -cvvzf "$(realpath ${OUTPUT})" --numeric-owner --acls --xattrs -C "$1/root" .
|
||||
else
|
||||
echo "Unsupported kernel."
|
||||
fi
|
||||
}
|
||||
Executable
+100
@@ -0,0 +1,100 @@
|
||||
#!/bin/mksh
|
||||
|
||||
scriptdir=$(dirname $0)
|
||||
libdir="${scriptdir}/lib"
|
||||
targetdir="${scriptdir}/target"
|
||||
profilesdir="${scriptdir}/profiles"
|
||||
|
||||
source "${scriptdir}/config.sh"
|
||||
eval "$@"
|
||||
|
||||
usage() {
|
||||
echo "usage: mkliveimage [VAR1=var1 VAR2=var2 ...]"
|
||||
echo
|
||||
echo "Variables":
|
||||
echo " PROFILE=<profile> Base image profile."
|
||||
echo " VERSION=<version> Version of the operating system. [default: latest]"
|
||||
echo " SNAPSHOT=[1|0] Build the image using the latest packages. [default: 0]"
|
||||
echo " ARCH=<triple> Architecture triple. [default: system]"
|
||||
echo " OUTPUTDIR=<path> Output directory. [default: ${targetdir}]"
|
||||
echo " OUTPUT=<path> Output file. (ignores OUTPUTDIR if this is set)"
|
||||
echo " SUDO=[1|0] Use sudo on operations that may require root. [default: 0]"
|
||||
echo
|
||||
echo "Available profiles:"
|
||||
ls "${profilesdir}" | sed 's/^/ /; s/\.sh$//'
|
||||
exit 1
|
||||
}
|
||||
|
||||
default_arch() {
|
||||
if [ $(uname -s) -eq "Linux" ]; then
|
||||
local KERNELTYPE="linux"
|
||||
fi
|
||||
|
||||
local MACHINETYPE=$(uname -m)
|
||||
|
||||
echo "${MACHINETYPE}-semios-${KERNELTYPE}"
|
||||
}
|
||||
|
||||
default_output_filename() {
|
||||
current_date=$(date +%Y%m%d)
|
||||
if [ "${SNAPSHOT}" -eq "1" ]; then
|
||||
echo "SemiOS-${PROFILE}-${VERSION}-snapshot-${current_date}-${ARCH}${FORMAT}"
|
||||
else
|
||||
echo "SemiOS-${PROFILE}-${VERSION}-${ARCH}${FORMAT}"
|
||||
fi
|
||||
}
|
||||
|
||||
begin_root() {
|
||||
rm -rf "$1"
|
||||
mkdir -p "$1" "$1/var/config/packie/repos.d" "$1/dev" "$1/sys" "$1/proc" "$1/etc" "$1/tmp"
|
||||
echo "${REPOS}" > "$1/var/config/packie/repos.d/10-distribution.toml"
|
||||
if [ -L "/etc/resolv.conf" -o -e "/etc/resolv.conf" ]; then
|
||||
cp "/etc/resolv.conf" "$1/etc/resolv.conf"
|
||||
fi
|
||||
if [ -L "/var/config/resolv.conf" -o -e "/var/config/resolv.conf" ]; then
|
||||
cp "/var/config/resolv.conf" "$1/var/config/resolv.conf"
|
||||
fi
|
||||
}
|
||||
|
||||
end_root() {
|
||||
rm -rf "$1/etc" "$1/var/cache/"*
|
||||
}
|
||||
|
||||
ARCH=$(default_arch)
|
||||
|
||||
if [ -z "${PROFILE}" ]; then
|
||||
usage
|
||||
fi
|
||||
if [ ! -e "${profilesdir}/${PROFILE}.sh" ]; then
|
||||
echo "mkliveimage: Profile \"${PROFILE}\" does not exist."
|
||||
usage
|
||||
fi
|
||||
source "${profilesdir}/${PROFILE}.sh"
|
||||
|
||||
if [ -z "${OUTPUT}" ]; then
|
||||
OUTPUT="${OUTPUTDIR}/$(default_output_filename)"
|
||||
fi
|
||||
|
||||
workdir="${targetdir}/work.$(default_output_filename)"
|
||||
begin_root "${workdir}/root"
|
||||
|
||||
packie --chroot "${workdir}/root" update || exit 1
|
||||
packie --chroot "${workdir}/root" install -y "${PACKAGES[@]}" || exit 1
|
||||
|
||||
end_root "${workdir}/root"
|
||||
|
||||
case "${FORMAT}" in
|
||||
.tar.*)
|
||||
source "${libdir}/tarball.sh"
|
||||
create_tarball "${workdir}"
|
||||
;;
|
||||
.iso)
|
||||
source "${libdir}/isoimage.sh"
|
||||
create_iso "${workdir}"
|
||||
;;
|
||||
*)
|
||||
echo "mkliveimage: FATAL: Profile \"${PROFILE}\" issued an illegal format \"${FORMAT}\"."
|
||||
echo "mkliveimage: FATAL: Aborting."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
@@ -0,0 +1,21 @@
|
||||
FORMAT=".iso"
|
||||
PACKAGES=(
|
||||
"SemiOS.Assembly.CoreRuntime @${ARCH}"
|
||||
"SemiOS.Assembly.Cli @${ARCH}"
|
||||
"SemiOS.Assembly.Networking @${ARCH}"
|
||||
"linux @${ARCH}"
|
||||
"airup @${ARCH}"
|
||||
)
|
||||
#REPOS=$(cat <<EOF
|
||||
#[official]
|
||||
#url = "https://mirror2.semilabs.org/semios/official/"
|
||||
#EOF
|
||||
#)
|
||||
REPOS=$(cat <<EOF
|
||||
[official]
|
||||
url = "http://192.168.3.73:8009/semios/official/"
|
||||
|
||||
[temporary]
|
||||
url = "http://192.168.64.1/temporary/"
|
||||
EOF
|
||||
)
|
||||
@@ -0,0 +1,11 @@
|
||||
FORMAT=".tar.gz"
|
||||
PACKAGES=(
|
||||
"SemiOS.Assembly.CoreRuntime @${ARCH}"
|
||||
"SemiOS.Assembly.Cli @${ARCH}"
|
||||
"SemiOS.Assembly.Networking @${ARCH}"
|
||||
)
|
||||
REPOS=$(cat <<EOF
|
||||
[official]
|
||||
url = "https://mirror2.semilabs.org/semios/official/"
|
||||
EOF
|
||||
)
|
||||
Reference in new issue
Block a user