diff options
author | Mikhail Kobuk <m.kobuk@ispras.ru> | 2024-04-06 16:00:01 +0300 |
---|---|---|
committer | Mikhail Kobuk <m.kobuk@ispras.ru> | 2024-04-06 16:00:01 +0300 |
commit | 232c1cb726c809599ce69dbeda7f7f716f106801 (patch) | |
tree | 56d7b3f0222f24086bc968dd7d8ee0a4e59b4b7d | |
download | linux-232c1cb726c809599ce69dbeda7f7f716f106801.tar.gz |
Pre-EUPM build draft
TODO: convert to fakeroot
TODO: separate most modules
TODO: revise config
TODO: adjust logging
TODO: rework patch listing
TODO: update patch selection
-rw-r--r-- | Makefile | 99 | ||||
-rwxr-xr-x | build.sh | 34 | ||||
-rw-r--r-- | interliner.c | 78 | ||||
-rwxr-xr-x | patch.sh | 19 |
4 files changed, 230 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..35920e4 --- /dev/null +++ b/Makefile @@ -0,0 +1,99 @@ +VERSION=linux-6.8.4 +VERSION_DISTR = $(VERSION)-vmkos +VERSION_BUILD = $(VERSION_DISTR)=-night + +TRUSTED_KEYS = ABAF11C65A2970B130ABE3C479BE3E4300411886 # Linus Torvalds +TRUSTED_KEYS += 647F28654894E3BD457199BE38DBBDC86092693E # Greg Kroah-Hartman + +SRC_URL = https://cdn.kernel.org/pub/linux/kernel/v6.x/$(VERSION).tar.xz +# PGP_SGN_URL = https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.8.4.tar.sign + +CFLAGS = -std=gnu2x -Wall -Werror -Wno-pointer-sign -Werror=vla + +ifdef ONELINE_OUTPUT + # SED_SUBST = | stdbuf --output=L sed 's/^/\\e[0A\\e[K3<>/gi' + SED_SUBST = | stdbuf --output=L ./interliner +else +SED_SUBST= +endif + +SILENCE= +ifdef QUIET +SILENCE += >all.log +endif + +ifdef SILENT +SILENCE += 2>err.log +endif + +OUT_FMT = $(SED_SUBST) $(SILENCE) + +default: all + +all: pre_install install post_install clean clean_misc + +pre_install: interliner $(VERSION).tar + # rm -f linux-6.8.4.tar.xz + @printf "> MAKING::$@\n" + tar --skip-old-files -xvf linux-6.8.4.tar.xz 2>tar.err.log | grep -v "skipping existing file" | sed 's/^/\t=> /g' $(OUT_FMT) + @printf "> MAKING::$@::DONE\n" + +install: interliner $(VERSION) clear.ok patch patch.ok build build.ok + # @printf "> MAKING::$@\n" + @printf "> MAKING::$@::DONE\n" + + +post_install: interliner + # @printf "> MAKING::$@\n" + @printf "> MAKING::$@::DONE\n" + +.PHONY: pre_install install post_install + +$(VERSION).tar: $(VERSION).tar.xz $(VERSION).tar.sign + @printf "\t> MAKING::$@\n" + + xz -kd $(VERSION).tar.xz | sed 's/^/\t==> /g' $(OUT_FMT) + +ifdef NO_VERIFY + @printf "\t==> Will not verify\n" +else ifdef SKIP_VERIFY + @printf "\t==> Will not verify\n" +else + @printf "\t==> Verifying...\n" + + gpg2 --recv-keys $(TRUSTED_KEYS) $(OUT_FMT) + if [ "$$(gpg2 --logger-fd 1 --verify $(VERSION).tar.sign | grep 'Good signature')" == "" ]; then false; fi +endif + + @printf "\t> MAKING::$@::DONE\n" + +$(VERSION).tar.xz: + @printf "\t> MAKING::$@\n" + wget https://cdn.kernel.org/pub/linux/kernel/v6.x/$(VERSION).tar.xz | sed 's/^/\t==> /g' $(OUT_FMT) + @printf "\t> MAKING::$@::DONE\n" + +$(VERSION).tar.sign: + @printf "\t> MAKING::$@\n" + wget https://cdn.kernel.org/pub/linux/kernel/v6.x/$(VERSION).tar.sign | sed 's/^/\t==> /g' $(OUT_FMT) + @printf "\t> MAKING::$@::DONE\n" + +patch: ./patch.sh + @printf "\t> MAKING::$@\n" + ./patch.sh $(VERSION) skip | sed 's/^/\t==> /g' $(SED_SUBST) $(OUT_FMT) + @printf "\t> MAKING::$@::DONE\n" + +build: ./build.sh + @printf "\t> MAKING::$@\n" + ./build.sh $(VERSION) $(VERSION_BUILD) | sed 's/^/\t==> /g' $(SED_SUBST) $(OUT_FMT) + @printf "\t> MAKING::$@::DONE\n" + +interliner: interliner.c + +clean: interliner + rm -f *.tar *.sign *.sign?? *.xz $(OUT_FMT) + +clean_misc: interliner + rm -f *.tar *.sign *.sign?? $(OUT_FMT) + +clear.ok: + rm -f *.ok diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..cce1d75 --- /dev/null +++ b/build.sh @@ -0,0 +1,34 @@ +#! /bin/bash + +cd $1 + +if [ ! -f ".config" ]; then + cp -v ../config_base .config | sed 's/^/--> /g' +fi + +make olddefconfig | sed 's/^/--> /g' + + +flags="" + +if [ "$2" != "" ]; then + flags="$flags \"KERNELRELEASE=$2\"" + echo $flags POTATO + echo "appending 'KERNELRELEASE=$2'" | sed 's/^/--> /g' +fi + +make KERNELRELEASE="$2" -j16 | sed 's/^/--> /g' + +if [ "$?" != "0" ]; then + echo "MAKE FAIL []" + exit 1 +fi + +sudo make KERNELRELEASE="$2" -j16 modules_install | sed 's/^/--> /g' + +if [ "$?" != "0" ]; then + echo "MAKE FAIL [modules_install]" + exit 1 +fi + +touch ../build.ok diff --git a/interliner.c b/interliner.c new file mode 100644 index 0000000..17937df --- /dev/null +++ b/interliner.c @@ -0,0 +1,78 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include <fcntl.h> +#include <unistd.h> + +int +main(int argc, char *argv[]) +{ + //char *string = NULL; + //size_t sz = 0; + + int fd = open("log.log", O_WRONLY | O_CREAT | O_APPEND, 0660); + if (fd < 0) { + return 1; + } + + char msg[100] = "\nnew log =======\n"; + write(fd, &msg, sizeof(msg)); + + char sstring[4096] = {}; + ssize_t pos = 0; + + int c = getchar(); + while (c != EOF) { + switch (c) { + case '\n': + sstring[pos] = '\0'; + printf("\r%s", sstring); + fflush(stdout); + pos = 0; + break; + default: + sstring[pos++] = c; + break; + } + c = getchar(); + } + + putchar('\n'); + + //while (getline(&string, &sz, stdin) > 0) { + // if (!sz) { + // continue; + // } + + // char *reader = string; + // putchar(*reader); + // write(fd, reader, 1); + // fflush(stdout); + // char *writer = string; + + // while ((reader - string) < sz) { + // if (*reader == '\n') { + // *reader = '\0'; + // break; + // } + + // write(fd, "<", 1); + // write(fd, reader, 1); + // write(fd, ">", 1); + // *(reader++) = *(writer++); + // } + + // printf("\r%s", string); + // write(fd, "!", 1); + + // free(string); + // string = NULL; + //} + + close(fd); + + //free(string); + + return 0; +} diff --git a/patch.sh b/patch.sh new file mode 100755 index 0000000..fc1a6a3 --- /dev/null +++ b/patch.sh @@ -0,0 +1,19 @@ +#! /bin/bash + +cd $1 + +for pch in ../*.patch; do + printf "Applying patch %s...\n" "$pch" + patch -Np1 < "$pch" | sed 's/^/--> /g' + if [ "$?" == "0" ]; then + printf "[OK] Applying patch %s [OK]\n" "$pch" + else + printf "[ERR!!!] Applying patch %s [ERR!!!]\n" "$pch" + if [ "$2" != "skip" ]; then + echo "assuming error is critical, aborting\n" + exit 1 + fi + fi + + touch ../patch.ok +done |