From 40df8aa84bcdb13b5b7213d90eca04c3f4f6c6ac Mon Sep 17 00:00:00 2001 From: Mike Banon Date: Sun, 21 Feb 2021 19:20:40 +0300 Subject: tint: introduce the new tint build system with checksum verification Three stages of the new tint build system: 1) generate_core.sh extracts the core part from buildgcc script, most importantly the checksum calculation/verification functions. 2) tintify_core.sh adds the tint-specific footer/header to the core, such as the properties of current version including its checksum. 3) tint.sh - generated and "tintified" core script - builds a tint. Signed-off-by: Mike Banon Change-Id: Ib71f5b861ecf91949a5af12812258e60873f0498 Reviewed-on: https://review.coreboot.org/c/coreboot/+/50991 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer --- payloads/external/tint/Makefile | 73 +++- payloads/external/tint/generate_core.sh | 102 +++++ payloads/external/tint/libpayload_tint.patch | 470 ---------------------- payloads/external/tint/tint-0.05_libpayload.patch | 470 ++++++++++++++++++++++ payloads/external/tint/tintify_core.sh | 98 +++++ 5 files changed, 722 insertions(+), 491 deletions(-) create mode 100755 payloads/external/tint/generate_core.sh delete mode 100644 payloads/external/tint/libpayload_tint.patch create mode 100644 payloads/external/tint/tint-0.05_libpayload.patch create mode 100755 payloads/external/tint/tintify_core.sh (limited to 'payloads') diff --git a/payloads/external/tint/Makefile b/payloads/external/tint/Makefile index e57132c8e3..5bd9df5a4f 100644 --- a/payloads/external/tint/Makefile +++ b/payloads/external/tint/Makefile @@ -1,5 +1,25 @@ -project_url=https://mirror.fsf.org/trisquel/pool/main/t/tint/tint_0.05.tar.xz -archive_name=tint_0.05.tar.xz +# +# TINT build system - helps to securely download TINT with a checksum verification and build it. +# + +# +# Properties of the current TINT version +# + +TINT_VERSION=0.05 +TINT_EXT_VERSION=0.05 +TINT_ARCHIVE_LINK="https://mirror.fsf.org/trisquel/pool/main/t/tint/tint_${TINT_EXT_VERSION}.tar.xz" +TINT_ARCHIVE="tint_${TINT_VERSION}.tar.xz" +TINT_DIR="tint-${TINT_VERSION}" +TINT_SHA1SUM="859008216930a4584e622d0df41fd75c44d2b47f" + +# +# Locations of the input/output scripts +# + +buildgcc="./../../../util/crossgcc/buildgcc" +corescript="./core.sh" +tintified="./tint.sh" unexport KCONFIG_AUTOHEADER unexport KCONFIG_AUTOCONFIG @@ -10,28 +30,39 @@ unexport KCONFIG_NEGATIVES all: tint -tint: patch - echo " MAKE TINT " - $(MAKE) -C tint - -patch: download - cd tint; \ - if [ -e debian ]; then \ - rm -rf debian typedefs.h Makefile; \ - touch Makefile; \ - patch -l -p1 < ../libpayload_tint.patch; \ - fi +################################################################################ +# +# Three stages of TINT build system: +# +# 1) generate_core.sh extracts the core part from buildgcc script, +# most importantly the checksum calculation/verification functions. +# +# 2) tintify_core.sh adds the TINT-specific footer/header to the core, +# such as the properties of current version including its checksum. +# +# 3) tint.sh - generated and "tintified" core script - builds a TINT. +# +################################################################################ -download: - test -d tint || { wget $(project_url); \ - tar -xvf $(archive_name); \ - rm $(archive_name); \ - mv tint-0.05 tint; } +tint: + if [ ! -f ${tintified} ]; then \ + chmod +x "./generate_core.sh" ; \ + "./generate_core.sh" ${buildgcc} ${corescript} "prepare_before_patch" ; \ + chmod +x "./tintify_core.sh" ; \ + "./tintify_core.sh" ${corescript} ${tintified} \ + ${TINT_ARCHIVE_LINK} ${TINT_ARCHIVE} ${TINT_DIR} ${TINT_SHA1SUM} ; \ + fi ; \ + chmod +x ${tintified} + ${tintified} clean: - test -d tint && $(MAKE) -C tint clean || exit 0 + test -d "./tint/" && $(MAKE) -C "./tint/" clean || exit 0 distclean: - rm -rf tint + rm -rf "./tint/" + rm -f ${corescript} + rm -f ${tintified} + +.PHONY: tint clean distclean -.PHONY: download patch tint clean distclean +# diff --git a/payloads/external/tint/generate_core.sh b/payloads/external/tint/generate_core.sh new file mode 100755 index 0000000000..bb0de2d169 --- /dev/null +++ b/payloads/external/tint/generate_core.sh @@ -0,0 +1,102 @@ +#!/bin/sh +# +# generate_core.sh extracts the core part from buildgcc script, +# most importantly the checksum calculation/verification functions. +# +# Copyright (C) 2019 Mike Banon +# +############################################################################## +# +# USAGE: +# ./generate_core.sh prepare_before_patch +# where +# buildgcc - path to input buildgcc script +# corescript - path to output core part script +# prepare_before_patch - optional argument to insert prepare_${package} +# call into the unpack_and_patch function, e.g. +# for removing some files with rm command +# in order to reduce the size of patch file +# +############################################################################## + +buildgcc="$1" +corescript="$2" +prepare_before_patch="$3" + +# +# Imports the source file fragment between start and end into the +# destination file, optionally excluding the last line if not needed +# + +import_from_file() { + source="$1" + destination="$2" + start="$3" + end="$4" + last_line_disabled="$5" + if [ -z "${last_line_disabled}" ] ; then + sed -n "/^${start}/,/^${end}/{/^${start}/{p;n};{p}}" "$source" >> "$destination" + else + sed -n "/^${start}/,/^${end}/{/^${start}/{p;n};/^${end}/{q};{p}}" "$source" >> "$destination" + fi +} + +# +# Import the color defines together with UNAME/HALT_FOR_TOOLS variables +# + +import_from_file "$buildgcc" "$corescript" "red=" "HALT_FOR_TOOLS=0" || exit "$?" + +# +# Import the core functions +# + +FUNCTIONS="please_install searchtool download compute_hash error_hash_mismatch verify_hash unpack_and_patch" + +for F in $FUNCTIONS ; do + import_from_file "$buildgcc" "$corescript" "$F()" "}" || exit "$?" +done + +# +# Import a fragment where we find tar/patch/make and other essential tools +# + +import_from_file "$buildgcc" "$corescript" "# Find all the required tools" "# Allow" "last_line_disabled" || exit "$?" + +# +# Import a fragment with conditional exit if some required tools were not found +# + +import_from_file "$buildgcc" "$corescript" "if \[ \"\$HALT_FOR_TOOLS" "fi" || exit "$?" + +# +# Avoid the unnecessary subdirectories holding a single file each +# + +sed -i -e "s/patches\///g" "$corescript" +sed -i -e "s/sum\///g" "$corescript" +sed -i -e "s/tarballs\///g" "$corescript" +sed -i -e "s/cd tarballs || exit 1//g" "$corescript" +sed -i -e "s/cd \.\.//g" "$corescript" + +# +# Get the known checksum without using a dedicated single-line file +# + +sed -i -e "s/\tknown_hash=\"\$(get_known_hash.*/\tknown_hash=\"\$2\"/g" "$corescript" + +# +# Update the paths printed at the error messages +# + +sed -i -e "s/util\/crossgcc\///g" "$corescript" + +# +# Insert prepare_${package} function call between the unpack and patch operations +# + +if [ ! -z "${prepare_before_patch}" ] ; then + sed -i -e "/\$TAR \$FLAGS \"\$(basename \"\$archive\")\"/a prepare_\${package} || exit \"\$?\"" "$corescript" +fi + +# diff --git a/payloads/external/tint/libpayload_tint.patch b/payloads/external/tint/libpayload_tint.patch deleted file mode 100644 index 6c9594a369..0000000000 --- a/payloads/external/tint/libpayload_tint.patch +++ /dev/null @@ -1,470 +0,0 @@ -diff -rupN tint-0.05/config.h tint/config.h ---- tint-0.05/config.h 2001-12-08 00:03:24.000000000 +0100 -+++ tint/config.h 2021-02-09 08:00:00.000000000 +0200 -@@ -29,7 +29,15 @@ - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -+#include -+#include -+ -+#define curs_set(x) -+#define USE_RAND -+ - /* Score file */ -+#if 0 - const char scorefile[] = SCOREFILE; -+#endif - - #endif /* #ifndef CONFIG_H */ -diff -rupN tint-0.05/engine.c tint/engine.c ---- tint-0.05/engine.c 2005-07-17 13:26:22.000000000 +0200 -+++ tint/engine.c 2021-02-09 08:00:00.000000000 +0200 -@@ -27,10 +27,13 @@ - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -+#include "config.h" -+ -+#if 0 - #include - #include -+#endif - --#include "typedefs.h" - #include "utils.h" - #include "io.h" - #include "engine.h" -diff -rupN tint-0.05/engine.h tint/engine.h ---- tint-0.05/engine.h 2001-12-07 16:48:08.000000000 +0100 -+++ tint/engine.h 2021-02-09 08:00:00.000000000 +0200 -@@ -29,7 +29,7 @@ - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - --#include "typedefs.h" /* bool */ -+#include "curses.h" /* bool */ - - /* - * Macros -diff -rupN tint-0.05/io.c tint/io.c ---- tint-0.05/io.c 2010-06-23 15:05:12.000000000 +0100 -+++ tint/io.c 2021-02-09 08:00:00.000000000 +0200 -@@ -27,9 +27,13 @@ - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -+#include "config.h" -+ -+#if 0 - #include /* va_list(), va_start(), va_end() */ - #include /* gettimeofday() */ - #include /* gettimeofday() */ -+#endif - - #include "io.h" - -@@ -68,7 +72,11 @@ static int in_timeleft; - /* Initialize screen */ - void io_init () - { -+ curses_enable_serial(0); -+ curses_enable_vga(1); - initscr (); -+ halfdelay(1); -+ timeout(1); - start_color (); - curs_set (CURSOR_INVISIBLE); - out_attr = A_NORMAL; -@@ -177,11 +185,17 @@ void out_beep () - /* Read a character. Please note that you MUST call in_timeout() before in_getch() */ - int in_getch () - { -+#if 0 - struct timeval starttv,endtv; -+#endif - int ch; -+#if 0 - timeout (in_timeleft / 1000); - gettimeofday (&starttv,NULL); -+#endif - ch = getch (); -+ mdelay(150); -+#if 0 - gettimeofday (&endtv,NULL); - /* Timeout? */ - if (ch == ERR) -@@ -199,6 +213,7 @@ int in_getch () - in_timeleft -= endtv.tv_usec; - if (in_timeleft <= 0) in_timeleft = in_timetotal; - } -+#endif - return ch; - } - -diff -rupN tint-0.05/io.h tint/io.h ---- tint-0.05/io.h 2010-06-23 14:55:03.000000000 +0100 -+++ tint/io.h 2021-02-09 08:00:00.000000000 +0200 -@@ -30,7 +30,6 @@ - */ - - #include --#include - - /* - * Colors -diff -rupN tint-0.05/Makefile tint/Makefile ---- tint-0.05/Makefile 2010-06-23 15:06:11.000000000 +0200 -+++ tint/Makefile 2021-02-09 08:00:00.000000000 +0200 -@@ -0,0 +1,106 @@ -+ -+# -*- sh -*- -+ -+# Copyright (c) Abraham vd Merwe -+# All rights reserved. -+# -+# Redistribution and use in source and binary forms, with or without -+# modification, are permitted provided that the following conditions -+# are met: -+# 1. Redistributions of source code must retain the above copyright -+# notice, this list of conditions and the following disclaimer. -+# -+# 2. Redistributions in binary form must reproduce the above copyright -+# notice, this list of conditions and the following disclaimer in the -+# documentation and/or other materials provided with the distribution. -+# 3. Neither the name of the author nor the names of other contributors -+# may be used to endorse or promote products derived from this software -+# without specific prior written permission. -+# -+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -+# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ -+# in addition to the dependency below, create the file if it doesn't exist -+# to silence warnings about a file that would be generated anyway. -+$(if $(wildcard .xcompile),,$(eval $(shell ../../../../util/xcompile/xcompile $(XGCCPATH) > .xcompile || rm -f .xcompile))) -+.xcompile: ../../../../util/xcompile/xcompile -+ -+CONFIG_COMPILER_GCC := y -+ARCH-y := x86_32 -+ -+include .xcompile -+ -+src := $(CURDIR) -+srctree := $(src) -+tint_obj := $(src)/build -+ -+LIBCONFIG_PATH := $(realpath ../../../libpayload) -+LIBPAYLOAD_DIR := $(tint_obj)/libpayload -+HAVE_LIBPAYLOAD := $(wildcard $(LIBPAYLOAD_DIR)/lib/libpayload.a) -+LIB_CONFIG ?= configs/defconfig-tinycurses -+ -+# CFLAGS := -Wall -Werror -Os -+CFLAGS := -Wall -g -Os -+TARGET := tint -+OBJS := $(TARGET).o engine.o io.o utils.o -+ -+ARCH-y := x86_32 -+ -+CC := $(CC_$(ARCH-y)) -+AS := $(AS_$(ARCH-y)) -+OBJCOPY := $(OBJCOPY_$(ARCH-y)) -+ -+LPCC := CC="$(CC)" $(LIBPAYLOAD_DIR)/bin/lpgcc -+LPAS := AS="$(AS)" $(LIBPAYLOAD_DIR)/bin/lpas -+ -+# Make is silent per default, but 'make V=1' will show all compiler calls. -+ifneq ($(V),1) -+Q := @ -+endif -+ -+all: $(TARGET).elf -+# printf" CC $(CC)\n" -+ -+$(TARGET).elf: $(OBJS) libpayload -+ $(Q)printf " LPCC $(subst $(shell pwd)/,,$(@))\n" -+ $(Q)$(LPCC) -o $@ $(OBJS) -+ $(Q)$(OBJCOPY) --only-keep-debug $@ tint.debug -+ $(Q)$(OBJCOPY) --strip-debug $@ -+ $(Q)$(OBJCOPY) --add-gnu-debuglink=tint.debug $@ -+ -+%.o: %.c libpayload -+ $(Q)printf " LPCC $(subst $(shell pwd)/,,$(@))\n" -+ $(Q)$(LPCC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $< -+ -+%.S.o: %.S libpayload -+ $(Q)printf " LPAS $(subst $(shell pwd)/,,$(@))\n" -+ $(Q)$(LPAS) $(ASFLAGS) --32 -o $@ $< -+ -+ifneq ($(strip $(HAVE_LIBPAYLOAD)),) -+libpayload: -+ $(Q)printf "Found Libpayload $(LIBPAYLOAD_DIR).\n" -+else -+libpayload: -+ $(Q)printf "Building libpayload @ $(LIBCONFIG_PATH).\n" -+ $(Q)make -C $(LIBCONFIG_PATH) distclean -+ $(Q)make -C $(LIBCONFIG_PATH) defconfig KBUILD_DEFCONFIG=$(LIB_CONFIG) -+ $(Q)make -C $(LIBCONFIG_PATH) DESTDIR=$(tint_obj) install -+endif -+ -+clean: -+ $(Q)rm -f $(TARGET).elf $(TARGET).debug *.o -+ $(Q)rm .xcompile -+ -+distclean: clean -+ $(Q)rm -rf $(tint_obj) -+ -+ -+.PHONY: all clean do-it-all depend with-depends without-depends debian postinst -diff -rupN tint-0.05/tint.c tint/tint.c ---- tint-0.05/tint.c 2010-08-08 19:42:50.000000000 +0200 -+++ tint/tint.c 2021-02-09 08:00:00.000000000 +0200 -@@ -1,4 +1,3 @@ -- - /* - * Copyright (c) Abraham vd Merwe - * All rights reserved. -@@ -27,6 +26,7 @@ - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -+#if 0 - #include - #include - #include -@@ -34,8 +34,8 @@ - #include - #include - #include -+#endif - --#include "typedefs.h" - #include "utils.h" - #include "io.h" - #include "config.h" -@@ -304,7 +304,7 @@ static void showstatus (engine_t *engine - /***************************************************************************/ - - /* Header for scorefile */ --#define SCORE_HEADER "Tint 0.02b (c) Abraham vd Merwe - Scores" -+#define SCORE_HEADER "Tint 0.05 (c) Abraham vd Merwe - Scores" - - /* Header for score title */ - static const char scoretitle[] = "\n\t TINT HIGH SCORES\n\n\tRank Score Name\n\n"; -@@ -322,6 +322,7 @@ typedef struct - time_t timestamp; - } score_t; - -+#if 0 - static void getname (char *name) - { - struct passwd *pw = getpwuid (geteuid ()); -@@ -338,7 +339,9 @@ static void getname (char *name) - name[NAMELEN - 1] = '\0'; - } - } -+#endif - -+#if 0 - static void err1 () - { - fprintf (stderr,"Error creating %s\n",scorefile); -@@ -350,10 +353,11 @@ static void err2 () - fprintf (stderr,"Error writing to %s\n",scorefile); - exit (EXIT_FAILURE); - } -+#endif - - void showplayerstats (engine_t *engine) - { -- fprintf (stderr, -+ printf ( - "\n\t PLAYER STATISTICS\n\n\t" - "Score %11d\n\t" - "Efficiency %11d\n\t" -@@ -361,6 +365,7 @@ void showplayerstats (engine_t *engine) - GETSCORE (engine->score),engine->status.efficiency,GETSCORE (engine->score) / getsum ()); - } - -+#if 0 - static void createscores (int score) - { - FILE *handle; -@@ -395,7 +400,9 @@ static void createscores (int score) - fprintf (stderr,"%s",scoretitle); - fprintf (stderr,"\t 1* %7d %s\n\n",score,scores[0].name); - } -+#endif - -+#if 0 - static int cmpscores (const void *a,const void *b) - { - int result; -@@ -413,7 +420,9 @@ static int cmpscores (const void *a,cons - /* timestamps is equal */ - return 0; - } -+#endif - -+#if 0 - static void savescores (int score) - { - FILE *handle; -@@ -491,11 +500,13 @@ static void savescores (int score) - } - fprintf (stderr,"\n"); - } -+#endif - - /***************************************************************************/ - /***************************************************************************/ - /***************************************************************************/ - -+#if 0 - static void showhelp () - { - fprintf (stderr,"USAGE: tint [-h] [-l level] [-n] [-d] [-b char]\n"); -@@ -506,9 +517,11 @@ static void showhelp () - fprintf (stderr," -b Use this character to draw blocks instead of spaces\n"); - exit (EXIT_FAILURE); - } -+#endif - - static void parse_options (int argc,char *argv[]) - { -+#if 0 - int i = 1; - while (i < argc) - { -@@ -544,10 +557,12 @@ static void parse_options (int argc,char - } - i++; - } -+#endif - } - - static void choose_level () - { -+#if 0 - char buf[NAMELEN]; - - do -@@ -557,6 +572,8 @@ static void choose_level () - buf[strlen (buf) - 1] = '\0'; - } - while (!str2int (&level,buf) || level < MINLEVEL || level > MAXLEVEL); -+#endif -+ level = 1; - } - - /***************************************************************************/ -@@ -569,6 +586,8 @@ int main (int argc,char *argv[]) - int ch; - engine_t engine; - /* Initialize */ -+ if (CONFIG(LP_USB)) -+ usb_initialize(); - rand_init (); /* must be called before engine_init () */ - engine_init (&engine,score_function); /* must be called before using engine.curshape */ - finished = shownext = FALSE; -@@ -632,12 +651,14 @@ int main (int argc,char *argv[]) - /* pause */ - case 'p': - out_setcolor (COLOR_WHITE,COLOR_BLACK); -- out_gotoxy ((out_width () - 34) / 2,out_height () - 2); -+ out_gotoxy ((out_width () - 34) / 2,out_height () / 2); - out_printf ("Paused - Press any key to continue"); -+ refresh (); - while ((ch = in_getch ()) == ERR) ; /* Wait for a key to be pressed */ - in_flush (); /* Clear keyboard buffer */ -- out_gotoxy ((out_width () - 34) / 2,out_height () - 2); -+ out_gotoxy ((out_width () - 34) / 2,out_height () / 2); - out_printf (" "); -+ refresh (); - break; - /* unknown keypress */ - default: -@@ -672,12 +693,32 @@ int main (int argc,char *argv[]) - while (!finished); - /* Restore console settings and exit */ - io_close (); -+#if 0 - /* Don't bother the player if he want's to quit */ - if (ch != 'q') - { -+#endif - showplayerstats (&engine); -+#if 0 - savescores (GETSCORE (engine.score)); - } -+#endif -+ printf("Press 'q' to reboot...\n"); -+ refresh(); -+ for (;;) { -+ in_flush (); -+ while ((ch = in_getch ()) == ERR) ; /* Wait for a key to be pressed */ -+ if (ch == 'q') { /* reboot */ -+ outb(0x6, 0xcf9); -+ for(;;); //halt(); -+ } -+ else { -+ in_flush (); -+ } -+ } -+ -+#if 0 - exit (EXIT_SUCCESS); -+#endif - } - -diff -rupN tint-0.05/utils.c tint/utils.c ---- tint-0.05/utils.c 2001-12-07 16:49:19.000000000 +0100 -+++ tint/utils.c 2021-02-09 08:00:00.000000000 +0200 -@@ -27,11 +27,13 @@ - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -+#include "config.h" -+ -+#if 0 - #include - #include - #include -- --#include "typedefs.h" -+#endif - - /* - * Initialize random number generator -@@ -61,6 +63,7 @@ int rand_value (int range) - * Convert an str to long. Returns TRUE if successful, - * FALSE otherwise. - */ -+#if 0 - bool str2int (int *i,const char *str) - { - char *endptr; -@@ -69,3 +72,4 @@ bool str2int (int *i,const char *str) - return TRUE; - } - -+#endif -diff -rupN tint-0.05/utils.h tint/utils.h ---- tint-0.05/utils.h 2001-12-07 16:49:35.000000000 +0100 -+++ tint/utils.h 2021-02-09 08:00:00.000000000 +0200 -@@ -29,7 +29,7 @@ - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - --#include "typedefs.h" -+#include - - /* - * Initialize random number generator diff --git a/payloads/external/tint/tint-0.05_libpayload.patch b/payloads/external/tint/tint-0.05_libpayload.patch new file mode 100644 index 0000000000..6c9594a369 --- /dev/null +++ b/payloads/external/tint/tint-0.05_libpayload.patch @@ -0,0 +1,470 @@ +diff -rupN tint-0.05/config.h tint/config.h +--- tint-0.05/config.h 2001-12-08 00:03:24.000000000 +0100 ++++ tint/config.h 2021-02-09 08:00:00.000000000 +0200 +@@ -29,7 +29,15 @@ + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + ++#include ++#include ++ ++#define curs_set(x) ++#define USE_RAND ++ + /* Score file */ ++#if 0 + const char scorefile[] = SCOREFILE; ++#endif + + #endif /* #ifndef CONFIG_H */ +diff -rupN tint-0.05/engine.c tint/engine.c +--- tint-0.05/engine.c 2005-07-17 13:26:22.000000000 +0200 ++++ tint/engine.c 2021-02-09 08:00:00.000000000 +0200 +@@ -27,10 +27,13 @@ + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + ++#include "config.h" ++ ++#if 0 + #include + #include ++#endif + +-#include "typedefs.h" + #include "utils.h" + #include "io.h" + #include "engine.h" +diff -rupN tint-0.05/engine.h tint/engine.h +--- tint-0.05/engine.h 2001-12-07 16:48:08.000000000 +0100 ++++ tint/engine.h 2021-02-09 08:00:00.000000000 +0200 +@@ -29,7 +29,7 @@ + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +-#include "typedefs.h" /* bool */ ++#include "curses.h" /* bool */ + + /* + * Macros +diff -rupN tint-0.05/io.c tint/io.c +--- tint-0.05/io.c 2010-06-23 15:05:12.000000000 +0100 ++++ tint/io.c 2021-02-09 08:00:00.000000000 +0200 +@@ -27,9 +27,13 @@ + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + ++#include "config.h" ++ ++#if 0 + #include /* va_list(), va_start(), va_end() */ + #include /* gettimeofday() */ + #include /* gettimeofday() */ ++#endif + + #include "io.h" + +@@ -68,7 +72,11 @@ static int in_timeleft; + /* Initialize screen */ + void io_init () + { ++ curses_enable_serial(0); ++ curses_enable_vga(1); + initscr (); ++ halfdelay(1); ++ timeout(1); + start_color (); + curs_set (CURSOR_INVISIBLE); + out_attr = A_NORMAL; +@@ -177,11 +185,17 @@ void out_beep () + /* Read a character. Please note that you MUST call in_timeout() before in_getch() */ + int in_getch () + { ++#if 0 + struct timeval starttv,endtv; ++#endif + int ch; ++#if 0 + timeout (in_timeleft / 1000); + gettimeofday (&starttv,NULL); ++#endif + ch = getch (); ++ mdelay(150); ++#if 0 + gettimeofday (&endtv,NULL); + /* Timeout? */ + if (ch == ERR) +@@ -199,6 +213,7 @@ int in_getch () + in_timeleft -= endtv.tv_usec; + if (in_timeleft <= 0) in_timeleft = in_timetotal; + } ++#endif + return ch; + } + +diff -rupN tint-0.05/io.h tint/io.h +--- tint-0.05/io.h 2010-06-23 14:55:03.000000000 +0100 ++++ tint/io.h 2021-02-09 08:00:00.000000000 +0200 +@@ -30,7 +30,6 @@ + */ + + #include +-#include + + /* + * Colors +diff -rupN tint-0.05/Makefile tint/Makefile +--- tint-0.05/Makefile 2010-06-23 15:06:11.000000000 +0200 ++++ tint/Makefile 2021-02-09 08:00:00.000000000 +0200 +@@ -0,0 +1,106 @@ ++ ++# -*- sh -*- ++ ++# Copyright (c) Abraham vd Merwe ++# All rights reserved. ++# ++# Redistribution and use in source and binary forms, with or without ++# modification, are permitted provided that the following conditions ++# are met: ++# 1. Redistributions of source code must retain the above copyright ++# notice, this list of conditions and the following disclaimer. ++# ++# 2. Redistributions in binary form must reproduce the above copyright ++# notice, this list of conditions and the following disclaimer in the ++# documentation and/or other materials provided with the distribution. ++# 3. Neither the name of the author nor the names of other contributors ++# may be used to endorse or promote products derived from this software ++# without specific prior written permission. ++# ++# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ++# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, ++# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ++# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE ++# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ++# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ++# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER ++# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, ++# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ++# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ ++# in addition to the dependency below, create the file if it doesn't exist ++# to silence warnings about a file that would be generated anyway. ++$(if $(wildcard .xcompile),,$(eval $(shell ../../../../util/xcompile/xcompile $(XGCCPATH) > .xcompile || rm -f .xcompile))) ++.xcompile: ../../../../util/xcompile/xcompile ++ ++CONFIG_COMPILER_GCC := y ++ARCH-y := x86_32 ++ ++include .xcompile ++ ++src := $(CURDIR) ++srctree := $(src) ++tint_obj := $(src)/build ++ ++LIBCONFIG_PATH := $(realpath ../../../libpayload) ++LIBPAYLOAD_DIR := $(tint_obj)/libpayload ++HAVE_LIBPAYLOAD := $(wildcard $(LIBPAYLOAD_DIR)/lib/libpayload.a) ++LIB_CONFIG ?= configs/defconfig-tinycurses ++ ++# CFLAGS := -Wall -Werror -Os ++CFLAGS := -Wall -g -Os ++TARGET := tint ++OBJS := $(TARGET).o engine.o io.o utils.o ++ ++ARCH-y := x86_32 ++ ++CC := $(CC_$(ARCH-y)) ++AS := $(AS_$(ARCH-y)) ++OBJCOPY := $(OBJCOPY_$(ARCH-y)) ++ ++LPCC := CC="$(CC)" $(LIBPAYLOAD_DIR)/bin/lpgcc ++LPAS := AS="$(AS)" $(LIBPAYLOAD_DIR)/bin/lpas ++ ++# Make is silent per default, but 'make V=1' will show all compiler calls. ++ifneq ($(V),1) ++Q := @ ++endif ++ ++all: $(TARGET).elf ++# printf" CC $(CC)\n" ++ ++$(TARGET).elf: $(OBJS) libpayload ++ $(Q)printf " LPCC $(subst $(shell pwd)/,,$(@))\n" ++ $(Q)$(LPCC) -o $@ $(OBJS) ++ $(Q)$(OBJCOPY) --only-keep-debug $@ tint.debug ++ $(Q)$(OBJCOPY) --strip-debug $@ ++ $(Q)$(OBJCOPY) --add-gnu-debuglink=tint.debug $@ ++ ++%.o: %.c libpayload ++ $(Q)printf " LPCC $(subst $(shell pwd)/,,$(@))\n" ++ $(Q)$(LPCC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $< ++ ++%.S.o: %.S libpayload ++ $(Q)printf " LPAS $(subst $(shell pwd)/,,$(@))\n" ++ $(Q)$(LPAS) $(ASFLAGS) --32 -o $@ $< ++ ++ifneq ($(strip $(HAVE_LIBPAYLOAD)),) ++libpayload: ++ $(Q)printf "Found Libpayload $(LIBPAYLOAD_DIR).\n" ++else ++libpayload: ++ $(Q)printf "Building libpayload @ $(LIBCONFIG_PATH).\n" ++ $(Q)make -C $(LIBCONFIG_PATH) distclean ++ $(Q)make -C $(LIBCONFIG_PATH) defconfig KBUILD_DEFCONFIG=$(LIB_CONFIG) ++ $(Q)make -C $(LIBCONFIG_PATH) DESTDIR=$(tint_obj) install ++endif ++ ++clean: ++ $(Q)rm -f $(TARGET).elf $(TARGET).debug *.o ++ $(Q)rm .xcompile ++ ++distclean: clean ++ $(Q)rm -rf $(tint_obj) ++ ++ ++.PHONY: all clean do-it-all depend with-depends without-depends debian postinst +diff -rupN tint-0.05/tint.c tint/tint.c +--- tint-0.05/tint.c 2010-08-08 19:42:50.000000000 +0200 ++++ tint/tint.c 2021-02-09 08:00:00.000000000 +0200 +@@ -1,4 +1,3 @@ +- + /* + * Copyright (c) Abraham vd Merwe + * All rights reserved. +@@ -27,6 +26,7 @@ + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + ++#if 0 + #include + #include + #include +@@ -34,8 +34,8 @@ + #include + #include + #include ++#endif + +-#include "typedefs.h" + #include "utils.h" + #include "io.h" + #include "config.h" +@@ -304,7 +304,7 @@ static void showstatus (engine_t *engine + /***************************************************************************/ + + /* Header for scorefile */ +-#define SCORE_HEADER "Tint 0.02b (c) Abraham vd Merwe - Scores" ++#define SCORE_HEADER "Tint 0.05 (c) Abraham vd Merwe - Scores" + + /* Header for score title */ + static const char scoretitle[] = "\n\t TINT HIGH SCORES\n\n\tRank Score Name\n\n"; +@@ -322,6 +322,7 @@ typedef struct + time_t timestamp; + } score_t; + ++#if 0 + static void getname (char *name) + { + struct passwd *pw = getpwuid (geteuid ()); +@@ -338,7 +339,9 @@ static void getname (char *name) + name[NAMELEN - 1] = '\0'; + } + } ++#endif + ++#if 0 + static void err1 () + { + fprintf (stderr,"Error creating %s\n",scorefile); +@@ -350,10 +353,11 @@ static void err2 () + fprintf (stderr,"Error writing to %s\n",scorefile); + exit (EXIT_FAILURE); + } ++#endif + + void showplayerstats (engine_t *engine) + { +- fprintf (stderr, ++ printf ( + "\n\t PLAYER STATISTICS\n\n\t" + "Score %11d\n\t" + "Efficiency %11d\n\t" +@@ -361,6 +365,7 @@ void showplayerstats (engine_t *engine) + GETSCORE (engine->score),engine->status.efficiency,GETSCORE (engine->score) / getsum ()); + } + ++#if 0 + static void createscores (int score) + { + FILE *handle; +@@ -395,7 +400,9 @@ static void createscores (int score) + fprintf (stderr,"%s",scoretitle); + fprintf (stderr,"\t 1* %7d %s\n\n",score,scores[0].name); + } ++#endif + ++#if 0 + static int cmpscores (const void *a,const void *b) + { + int result; +@@ -413,7 +420,9 @@ static int cmpscores (const void *a,cons + /* timestamps is equal */ + return 0; + } ++#endif + ++#if 0 + static void savescores (int score) + { + FILE *handle; +@@ -491,11 +500,13 @@ static void savescores (int score) + } + fprintf (stderr,"\n"); + } ++#endif + + /***************************************************************************/ + /***************************************************************************/ + /***************************************************************************/ + ++#if 0 + static void showhelp () + { + fprintf (stderr,"USAGE: tint [-h] [-l level] [-n] [-d] [-b char]\n"); +@@ -506,9 +517,11 @@ static void showhelp () + fprintf (stderr," -b Use this character to draw blocks instead of spaces\n"); + exit (EXIT_FAILURE); + } ++#endif + + static void parse_options (int argc,char *argv[]) + { ++#if 0 + int i = 1; + while (i < argc) + { +@@ -544,10 +557,12 @@ static void parse_options (int argc,char + } + i++; + } ++#endif + } + + static void choose_level () + { ++#if 0 + char buf[NAMELEN]; + + do +@@ -557,6 +572,8 @@ static void choose_level () + buf[strlen (buf) - 1] = '\0'; + } + while (!str2int (&level,buf) || level < MINLEVEL || level > MAXLEVEL); ++#endif ++ level = 1; + } + + /***************************************************************************/ +@@ -569,6 +586,8 @@ int main (int argc,char *argv[]) + int ch; + engine_t engine; + /* Initialize */ ++ if (CONFIG(LP_USB)) ++ usb_initialize(); + rand_init (); /* must be called before engine_init () */ + engine_init (&engine,score_function); /* must be called before using engine.curshape */ + finished = shownext = FALSE; +@@ -632,12 +651,14 @@ int main (int argc,char *argv[]) + /* pause */ + case 'p': + out_setcolor (COLOR_WHITE,COLOR_BLACK); +- out_gotoxy ((out_width () - 34) / 2,out_height () - 2); ++ out_gotoxy ((out_width () - 34) / 2,out_height () / 2); + out_printf ("Paused - Press any key to continue"); ++ refresh (); + while ((ch = in_getch ()) == ERR) ; /* Wait for a key to be pressed */ + in_flush (); /* Clear keyboard buffer */ +- out_gotoxy ((out_width () - 34) / 2,out_height () - 2); ++ out_gotoxy ((out_width () - 34) / 2,out_height () / 2); + out_printf (" "); ++ refresh (); + break; + /* unknown keypress */ + default: +@@ -672,12 +693,32 @@ int main (int argc,char *argv[]) + while (!finished); + /* Restore console settings and exit */ + io_close (); ++#if 0 + /* Don't bother the player if he want's to quit */ + if (ch != 'q') + { ++#endif + showplayerstats (&engine); ++#if 0 + savescores (GETSCORE (engine.score)); + } ++#endif ++ printf("Press 'q' to reboot...\n"); ++ refresh(); ++ for (;;) { ++ in_flush (); ++ while ((ch = in_getch ()) == ERR) ; /* Wait for a key to be pressed */ ++ if (ch == 'q') { /* reboot */ ++ outb(0x6, 0xcf9); ++ for(;;); //halt(); ++ } ++ else { ++ in_flush (); ++ } ++ } ++ ++#if 0 + exit (EXIT_SUCCESS); ++#endif + } + +diff -rupN tint-0.05/utils.c tint/utils.c +--- tint-0.05/utils.c 2001-12-07 16:49:19.000000000 +0100 ++++ tint/utils.c 2021-02-09 08:00:00.000000000 +0200 +@@ -27,11 +27,13 @@ + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + ++#include "config.h" ++ ++#if 0 + #include + #include + #include +- +-#include "typedefs.h" ++#endif + + /* + * Initialize random number generator +@@ -61,6 +63,7 @@ int rand_value (int range) + * Convert an str to long. Returns TRUE if successful, + * FALSE otherwise. + */ ++#if 0 + bool str2int (int *i,const char *str) + { + char *endptr; +@@ -69,3 +72,4 @@ bool str2int (int *i,const char *str) + return TRUE; + } + ++#endif +diff -rupN tint-0.05/utils.h tint/utils.h +--- tint-0.05/utils.h 2001-12-07 16:49:35.000000000 +0100 ++++ tint/utils.h 2021-02-09 08:00:00.000000000 +0200 +@@ -29,7 +29,7 @@ + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +-#include "typedefs.h" ++#include + + /* + * Initialize random number generator diff --git a/payloads/external/tint/tintify_core.sh b/payloads/external/tint/tintify_core.sh new file mode 100755 index 0000000000..c2eb7e6b78 --- /dev/null +++ b/payloads/external/tint/tintify_core.sh @@ -0,0 +1,98 @@ +#!/bin/sh +# +# tintify_core.sh adds the TINT-specific footer/header to the core, +# such as the properties of current TINT version including its checksum. +# +# Copyright (C) 2019 Mike Banon +# +################################################################################ +# +# USAGE: +# ./tintify_core.sh \ +# +# where +# corescript - path to input core script +# tintified - path to output tint script +# +################################################################################ + +corescript="$1" +tintified="$2" + +# +# TINT-specific header +# + +# +# Insert the properties of the current TINT version +# + +echo "#!/bin/sh" > "$tintified" +echo "TINT_ARCHIVE_LINK=${3}" >> "$tintified" +echo "TINT_ARCHIVE=${4}" >> "$tintified" +echo "TINT_DIR=${5}" >> "$tintified" +echo "TINT_SHA1SUM=${6}" >> "$tintified" + +# +# Add the replace_plus_with_minus() function - needed to fix the version number +# + +echo "replace_plus_with_minus() {" >> "$tintified" +echo "for x in *\"+\"*; do" >> "$tintified" +echo "y=\$(printf %sa \"\$x\" | tr \"+\" \"-\")" >> "$tintified" +echo "mv -- \"\$x\" \"\${y%a}\"" >> "$tintified" +echo "done" >> "$tintified" +echo "}" >> "$tintified" + +# +# Add the prepare_TINT() function, it will remove the unneeded debian directory +# as well as typedefs.h and old Makefile to significantly reduce the patch size +# + +echo "prepare_TINT() {" >> "$tintified" +# echo "replace_plus_with_minus" >> "$tintified" +echo "if [ ! -z ./\${TINT_DIR} ] && [ -e ./\${TINT_DIR}/debian ] ; then" >> "$tintified" +echo "rm -rf ./\${TINT_DIR}/debian ./\${TINT_DIR}/typedefs.h ./\${TINT_DIR}/Makefile;" >> "$tintified" +echo "touch ./\${TINT_DIR}/Makefile;" >> "$tintified" +echo "fi" >> "$tintified" +echo "}" >> "$tintified" + +# +# Importing the core script +# + +cat "$corescript" >> "$tintified" + +# +# download() function adjustments - became necessary after a version number fix +# + +sed -i -e "/download() {/a package=\$1\narchive_link=\"\$(eval echo \\\\\$\$package\"_ARCHIVE_LINK\")\"" "$tintified" +sed -i -e "s/downloading from \$archive/&_link/g" "$tintified" +sed -i -e "s/\(download_showing_percentage \"\$archive\)./\1_link\"/g" "$tintified" + +# +# TINT-specific footer +# + +echo "if [ ! -d tint ] ; then" >> "$tintified" + +echo "printf \"Downloading and verifying TINT tarball ... \\n\"" >> "$tintified" +echo "download TINT || exit \"\$?\"" >> "$tintified" +echo "verify_hash TINT \${TINT_SHA1SUM} || exit \"\$?\"" >> "$tintified" +echo "printf \"Downloaded TINT tarball ... \${green}ok\${NC}\\n\"" >> "$tintified" + +echo "printf \"Unpacking and patching TINT... \\n\"" >> "$tintified" +echo "unpack_and_patch TINT || exit 1" >> "$tintified" +echo "printf \"Unpacked and patched TINT... \${green}ok\${NC}\\n\"" >> "$tintified" + +echo "mv ./\${TINT_DIR} ./tint" >> "$tintified" +echo "fi" >> "$tintified" + +echo "printf \"Building TINT ... \\n\"" >> "$tintified" +echo "make -C ./tint" >> "$tintified" +echo "printf \"TINT built ... \${green}ok\${NC}\\n\"" >> "$tintified" + +chmod +x "$tintified" + +# -- cgit v1.2.3