| 1 | #!/bin/sh |
| 2 | # |
| 3 | # tintify_core.sh adds the TINT-specific footer/header to the core, |
| 4 | # such as the properties of current TINT version including its checksum. |
| 5 | # |
| 6 | # Copyright (C) 2019 Mike Banon <[email protected]> |
| 7 | # |
| 8 | ################################################################################ |
| 9 | # |
| 10 | # USAGE: |
| 11 | # ./tintify_core.sh <corescript> <tintified> \ |
| 12 | # <TINT_BASE_URL> <TINT_ARCHIVE> <TINT_DIR> <TINT_SHA1SUM> |
| 13 | # where |
| 14 | # corescript - path to input core script |
| 15 | # tintified - path to output tint script |
| 16 | # |
| 17 | ################################################################################ |
| 18 | |
| 19 | corescript="$1" |
| 20 | tintified="$2" |
| 21 | |
| 22 | # |
| 23 | # TINT-specific header |
| 24 | # |
| 25 | |
| 26 | # |
| 27 | # Insert the properties of the current TINT version |
| 28 | # |
| 29 | |
| 30 | echo "#!/bin/sh" > "$tintified" |
| 31 | echo "TINT_BASE_URL=${3}" >> "$tintified" |
| 32 | echo "TINT_ARCHIVE=${4}" >> "$tintified" |
| 33 | echo "TINT_ARCHIVE_LINK=${3}/${4}" >> "$tintified" |
| 34 | echo "TINT_DIR=${5}" >> "$tintified" |
| 35 | echo "TINT_SHA1SUM=${6}" >> "$tintified" |
| 36 | echo "USE_COREBOOT_MIRROR=0" >> "$tintified" |
| 37 | |
| 38 | # |
| 39 | # Add the replace_plus_with_minus() function - needed to fix the version number |
| 40 | # |
| 41 | |
| 42 | echo "replace_plus_with_minus() {" >> "$tintified" |
| 43 | echo "for x in *\"+\"*; do" >> "$tintified" |
| 44 | echo "y=\$(printf %sa \"\$x\" | tr \"+\" \"-\")" >> "$tintified" |
| 45 | echo "mv -- \"\$x\" \"\${y%a}\"" >> "$tintified" |
| 46 | echo "done" >> "$tintified" |
| 47 | echo "}" >> "$tintified" |
| 48 | |
| 49 | # |
| 50 | # Add the prepare_TINT() function, it will remove the unneeded debian directory |
| 51 | # as well as typedefs.h and old Makefile to significantly reduce the patch size |
| 52 | # |
| 53 | |
| 54 | echo "prepare_TINT() {" >> "$tintified" |
| 55 | # echo "replace_plus_with_minus" >> "$tintified" |
| 56 | echo "if [ ! -z ./\${TINT_DIR} ] && [ -e ./\${TINT_DIR}/debian ] ; then" >> "$tintified" |
| 57 | echo "rm -rf ./\${TINT_DIR}/debian ./\${TINT_DIR}/typedefs.h ./\${TINT_DIR}/Makefile;" >> "$tintified" |
| 58 | echo "touch ./\${TINT_DIR}/Makefile;" >> "$tintified" |
| 59 | echo "fi" >> "$tintified" |
| 60 | echo "}" >> "$tintified" |
| 61 | |
| 62 | # |
| 63 | # Importing the core script |
| 64 | # |
| 65 | |
| 66 | cat "$corescript" >> "$tintified" |
| 67 | |
| 68 | # |
| 69 | # download() function adjustments - became necessary after a version number fix |
| 70 | # |
| 71 | |
| 72 | sed -i -e "/download() {/a package=\$1\narchive_link=\"\$(eval echo \\\\\$\$package\"_ARCHIVE_LINK\")\"" "$tintified" |
| 73 | sed -i -e "s/downloading from \$archive/&_link/g" "$tintified" |
| 74 | sed -i -e "s/\(download_showing_percentage \"\$archive\)./\1_link\"/g" "$tintified" |
| 75 | |
| 76 | # |
| 77 | # TINT-specific footer |
| 78 | # |
| 79 | |
| 80 | echo "if [ ! -d tint ] ; then" >> "$tintified" |
| 81 | |
| 82 | echo "printf \"Downloading and verifying TINT tarball ... \\n\"" >> "$tintified" |
| 83 | echo "download TINT || exit \"\$?\"" >> "$tintified" |
| 84 | echo "verify_hash TINT \${TINT_SHA1SUM} || exit \"\$?\"" >> "$tintified" |
| 85 | echo "printf \"Downloaded TINT tarball ... \${green}ok\${NC}\\n\"" >> "$tintified" |
| 86 | |
| 87 | echo "printf \"Unpacking and patching TINT... \\n\"" >> "$tintified" |
| 88 | echo "unpack_and_patch TINT || exit 1" >> "$tintified" |
| 89 | echo "printf \"Unpacked and patched TINT... \${green}ok\${NC}\\n\"" >> "$tintified" |
| 90 | |
| 91 | echo "mv ./\${TINT_DIR} ./tint" >> "$tintified" |
| 92 | echo "fi" >> "$tintified" |
| 93 | |
| 94 | echo "printf \"Building TINT ... \\n\"" >> "$tintified" |
| 95 | echo "make -C ./tint" >> "$tintified" |
| 96 | echo "printf \"TINT built ... \${green}ok\${NC}\\n\"" >> "$tintified" |
| 97 | |
| 98 | chmod +x "$tintified" |
| 99 | |
| 100 | # |