drivers/wifi: Remove unnecessary data structure copy
[coreboot2.git] / payloads / external / tint / tintify_core.sh
blob0cd659912a57d8db5b019c84a92bbda7175cbd4a
1 #!/bin/sh
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.
6 # Copyright (C) 2019 Mike Banon <mikebdp2@gmail.com>
8 ################################################################################
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
17 ################################################################################
19 corescript="$1"
20 tintified="$2"
23 # TINT-specific header
27 # Insert the properties of the current TINT version
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"
39 # Add the replace_plus_with_minus() function - needed to fix the version number
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"
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
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"
63 # Importing the core script
66 cat "$corescript" >> "$tintified"
69 # download() function adjustments - became necessary after a version number fix
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"
77 # TINT-specific footer
80 echo "if [ ! -d tint ] ; then" >> "$tintified"
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"
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"
91 echo "mv ./\${TINT_DIR} ./tint" >> "$tintified"
92 echo "fi" >> "$tintified"
94 echo "printf \"Building TINT ... \\n\"" >> "$tintified"
95 echo "make -C ./tint" >> "$tintified"
96 echo "printf \"TINT built ... \${green}ok\${NC}\\n\"" >> "$tintified"
98 chmod +x "$tintified"