logo

live-bootstrap

Mirror of <https://github.com/fosslinux/live-bootstrap>
commit: 0d4394aa0d7f9704698dbd98984795c55c2c6332
parent 86048719970fee11ba8990268ccbc0bc3fc242bb
Author: rick-masters <grick23@gmail.com>
Date:   Sat, 20 May 2023 15:16:27 +0000

Build kexec-linux later as a package for musl lib calls instead of asm.

Diffstat:

Msysa/SHA256SUMS.pkgs1+
Asysa/kexec-linux-1.0.0/files/kexec-linux.c78++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asysa/kexec-linux-1.0.0/kexec-linux-1.0.0.sh15+++++++++++++++
Asysa/kexec-linux-1.0.0/mk/main.mk4++++
Dsysa/kexec-linux/kexec-linux.checksums1-
Dsysa/kexec-linux/kexec-linux.kaem16----------------
Dsysa/kexec-linux/src/kexec-linux.c91-------------------------------------------------------------------------------
Msysa/run.kaem6------
Msysa/run2.sh2++
9 files changed, 100 insertions(+), 114 deletions(-)

diff --git a/sysa/SHA256SUMS.pkgs b/sysa/SHA256SUMS.pkgs @@ -62,6 +62,7 @@ d85cff8f9ff76533287891ec2019416fa585815e514743e5b76efd9f17f5ef5c grep-3.7_0.tar b38422d646590600444f0ff12fee6fd738baaf471338aa67899db950d3521127 guile-3.0.9_0.tar.bz2 8d2015b87337abbf287f7a39ee4cf53514120b5d3e90a93fe7d533dcc43f14fa help2man-1.36.4_0.tar.bz2 3f06d1a7f1b1770d4550ff6316c7f06fd26e30bddad7c1b665f1fae80e409c8c kbd-1.15_0.tar.bz2 +6cb8bd6df0472665cd82ef4f4eae8368543a4d04eb90ec5f6cf4f224d1e16e51 kexec-linux-1.0.0_0.tar.bz2 2a661da13801028f5af98e5d9f6de417c21c90df1bcef4809caf0c2094fdd8f4 kexec-tools-2.0.22_0.tar.bz2 e89e4fc8ba4f917f4f609ba781fc13e43d31479d47a9da2ba3bc7ce5fcbbe6b3 libarchive-3.5.2_0.tar.bz2 36550df491767bb24d2ccab304ce70a3b4956e7c0c0e0c343d922fd57cdafbdd libatomic_ops-7.6.10_0.tar.bz2 diff --git a/sysa/kexec-linux-1.0.0/files/kexec-linux.c b/sysa/kexec-linux-1.0.0/files/kexec-linux.c @@ -0,0 +1,78 @@ +/* SPDX-FileCopyrightText: 2023 Richard Masters <grick23@gmail.com> */ +/* SPDX-License-Identifier: MIT */ +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <sys/reboot.h> +#include <sys/stat.h> +#include <time.h> + +int append_file(FILE *dst_file, char *src_file_name); + + +int main(int argc, char **argv) { + char *ramdrive_file_name, *kernel_file_name, *initramfs_file_name; + FILE *ramdrive_file; + struct stat stats; + + if (argc < 3) { + puts("Usage: fiwix-kexec-linux <ram-drive-name> <kernel-file-name> <initramfs-file-name>"); + exit(1); + } + + ramdrive_file_name = argv[1]; + kernel_file_name = argv[2]; + initramfs_file_name = argv[3]; + + + ramdrive_file = fopen(ramdrive_file_name, "wb"); + + /* Write length of kernel */ + if (stat(kernel_file_name, &stats) == 0) { + fwrite(&stats.st_size, 4, 1, ramdrive_file); + } else { + fprintf(stderr, "Cannot stat kernel file '%s'\n", kernel_file_name); + exit(1); + } + + /* Write length of initramfs */ + if (stat(initramfs_file_name, &stats) == 0) { + fwrite(&stats.st_size, 4, 1, ramdrive_file); + } else { + fprintf(stderr, "Cannot stat initramfs file '%s'\n", initramfs_file_name); + exit(1); + } + + if (append_file(ramdrive_file, kernel_file_name)) { + fprintf(stderr, "Cannot append kernel '%s'\n", kernel_file_name); + exit(1); + } + if (append_file(ramdrive_file, initramfs_file_name)) { + fprintf(stderr, "Cannot append initramfs '%s'\n", initramfs_file_name); + exit(1); + } + fclose(ramdrive_file); + + /* Flush ram drive writes to device */ + sync(); + + /* Perform syscall reboot to initiate kexec */ + reboot(RB_HALT_SYSTEM); +} + +int append_file(FILE *dst_file, char *src_file_name) { + FILE *src_file; + char buff[BUFSIZ]; + size_t n; + + if (src_file = fopen(src_file_name, "rb")) { + while ((n = fread(buff, 1, BUFSIZ, src_file)) != 0) { + fwrite(buff, 1, n, dst_file ); + } + fclose(src_file); + return 0; + } else { + printf("Cannot open file '%s'\n", src_file_name); + return 1; + } +} diff --git a/sysa/kexec-linux-1.0.0/kexec-linux-1.0.0.sh b/sysa/kexec-linux-1.0.0/kexec-linux-1.0.0.sh @@ -0,0 +1,15 @@ +#!/bin/bash +# SPDX-FileCopyrightText: 2023 Richard Masters <grick23@gmail.com> +# SPDX-License-Identifier: MIT +src_get() { + : +} + +src_unpack() { + dirname=kexec-linux-1.0.0 + mkdir ${dirname} +} + +src_install() { + install -D "kexec-linux" "${DESTDIR}${PREFIX}/bin/kexec-linux" +} diff --git a/sysa/kexec-linux-1.0.0/mk/main.mk b/sysa/kexec-linux-1.0.0/mk/main.mk @@ -0,0 +1,4 @@ +# SPDX-FileCopyrightText: 2023 Richard Masters <grick23@gmail.com> +# SPDX-License-Identifier: MIT +kexec-linux: kexec-linux.c + gcc -static -m32 -march=i386 -o $@ $^ diff --git a/sysa/kexec-linux/kexec-linux.checksums b/sysa/kexec-linux/kexec-linux.checksums @@ -1 +0,0 @@ -c0993adf00bd2c110539a310246f0e50d727e09701ed187827c71c64021431f4 /usr/bin/kexec-linux diff --git a/sysa/kexec-linux/kexec-linux.kaem b/sysa/kexec-linux/kexec-linux.kaem @@ -1,16 +0,0 @@ -# SPDX-FileCopyrightText: 2023 Richard Masters <grick23@gmail.com> -# SPDX-License-Identifier: MIT -cd src -tcc -static -m32 -march=i386 -std=c89 -I../../tcc/tcc-0.9.27/include -o ${bindir}/kexec-linux kexec-linux.c -cd .. - -# Checksums -if match x${UPDATE_CHECKSUMS} xTrue; then - sha256sum /usr/bin/kexec-linux - sha256sum -o ${pkg}.checksums \ - /usr/bin/kexec-linux - - cp ${pkg}.checksums ${srcdir} -else - sha256sum -c ${pkg}.checksums -fi diff --git a/sysa/kexec-linux/src/kexec-linux.c b/sysa/kexec-linux/src/kexec-linux.c @@ -1,91 +0,0 @@ -/* SPDX-FileCopyrightText: 2023 Richard Masters <grick23@gmail.com> */ -/* SPDX-License-Identifier: MIT */ -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <sys/stat.h> -#include <time.h> - -int append_file(FILE *dst_file, char *src_file_name); - - -int main(int argc, char **argv) { - char *ramdrive_file_name, *kernel_file_name, *initramfs_file_name; - FILE *ramdrive_file; - struct stat stats; - - if (argc < 3) { - puts("Usage: fiwix-kexec-linux <ram-drive-name> <kernel-file-name> <initramfs-file-name>"); - exit(1); - } - - ramdrive_file_name = argv[1]; - kernel_file_name = argv[2]; - initramfs_file_name = argv[3]; - - - ramdrive_file = fopen(ramdrive_file_name, "wb"); - - /* Write length of kernel */ - if (stat(kernel_file_name, &stats) == 0) { - fwrite(&stats.st_size, sizeof(stats.st_size), 1, ramdrive_file); - } else { - fprintf(stderr, "Cannot stat kernel file '%s'\n", kernel_file_name); - exit(1); - } - - /* Write length of initramfs */ - if (stat(initramfs_file_name, &stats) == 0) { - fwrite(&stats.st_size, sizeof(stats.st_size), 1, ramdrive_file); - } else { - fprintf(stderr, "Cannot stat initramfs file '%s'\n", initramfs_file_name); - exit(1); - } - - if (append_file(ramdrive_file, kernel_file_name)) { - fprintf(stderr, "Cannot append kernel '%s'\n", kernel_file_name); - exit(1); - } - if (append_file(ramdrive_file, initramfs_file_name)) { - fprintf(stderr, "Cannot append initramfs '%s'\n", initramfs_file_name); - exit(1); - } - fclose(ramdrive_file); - - /* Perform syscall sync */ - __asm__ __volatile__( - "movl $0x00000024, %%eax\n\t" - "int $0x80\n\t" - : /* no output */ - : /* no input */ - ); - - /* Perform syscall reboot to initiate kexec */ - __asm__ __volatile__( - "movl $0x58, %%eax\n\t" - "movl $0xfee1dead, %%ebx\n\t" - "movl $0x28121969, %%ecx\n\t" - "movl $0xcdef0123, %%edx\n\t" - "movl $0x00, %%esi\n\t" - "int $0x80\n\t" - : /* no output */ - : /* no input */ - ); -} - -int append_file(FILE *dst_file, char *src_file_name) { - FILE *src_file; - char buff[BUFSIZ]; - size_t n; - - if (src_file = fopen(src_file_name, "rb")) { - while ((n = fread(buff, 1, BUFSIZ, src_file)) != 0) { - fwrite(buff, 1, n, dst_file ); - } - fclose(src_file); - return 0; - } else { - printf("Cannot open file '%s'\n", src_file_name); - return 1; - } -} diff --git a/sysa/run.kaem b/sysa/run.kaem @@ -73,12 +73,6 @@ if match x${BUILD_FIWIX} xTrue; then cd ${pkg} kaem --verbose --file ${pkg}.kaem cd .. - - # Live boot loader for Fiwix to Linux - pkg="kexec-linux" - cd ${pkg} - kaem --verbose --file ${pkg}.kaem - cd .. fi if match x${KERNEL_BOOTSTRAP} xTrue; then diff --git a/sysa/run2.sh b/sysa/run2.sh @@ -91,6 +91,8 @@ grep --no-filename '^build' "${SOURCES}"/run*.sh | grep -v musl-1.2.3 | sed "s/b done if [ "${CHROOT}" = False ] || [ "${BUILD_KERNELS}" = True ]; then + build kexec-linux-1.0.0 + build kexec-tools-2.0.22 build linux-4.9.10