SHARE
TWEET

csb_patcher.sh v0.53 BETA public release

a guest May 26th, 2019 126 in 245 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh
  2. #
  3. #          csb_patcher.sh: coreboot and SeaBIOS patcher script.
  4. #
  5. #  Conveniently and securely gets, checks SHA256 and installs some of my
  6. # patches from this page - https://review.coreboot.org/q/status:open+mikeb
  7. #   and also gets a collection of useful floppy-based operating systems.
  8. #      Please send your feedback to Mike Banon <mikebdp2@gmail.com>
  9. #
  10.  
  11. enter=$( printf '\015' )
  12. ctrl_c=$( printf '\003' )
  13. ctrl_x=$( printf '\030' )
  14. ctrl_z=$( printf '\032' )
  15.  
  16. # Prints a question line '$1' and then waits for Y/N input from a user.
  17. yesno () {
  18.     printf '%b [Y/N] ' "$1"
  19.     old_stty_cfg=$( stty -g )
  20.     stty raw -echo
  21.     while true ; do
  22.         answer=$( head -c 1 )
  23.         case $answer in *"$ctrl_c"*|"$ctrl_x"*|"$ctrl_z"*)
  24.             stty "$old_stty_cfg"
  25.             printf "TERMINATED\n"
  26.             exit 1
  27.             ;;
  28.             *"y"*|"Y"*)
  29.             stty "$old_stty_cfg"
  30.             printf "YES\n"
  31.             return 0
  32.             ;;
  33.             *"n"*|"N"*)
  34.             stty "$old_stty_cfg"
  35.             printf "NO\n"
  36.             return 1
  37.             ;;
  38.         esac
  39.     done
  40. }
  41.  
  42. # Waits until a user presses Enter.
  43. encontinue () {
  44.     printf "\npress [ENTER] to continue... "
  45.     old_stty_cfg=$( stty -g )
  46.     stty raw -echo
  47.     while true ; do
  48.         answer=$( head -c 1 )
  49.         case $answer in *"$ctrl_c"*|"$ctrl_x"*|"$ctrl_z"*)
  50.             stty "$old_stty_cfg"
  51.             printf "TERMINATED\n"
  52.             exit 1
  53.             ;;
  54.             *"$enter"*)
  55.             stty "$old_stty_cfg"
  56.             printf "\n"
  57.             return 0
  58.             ;;
  59.     esac
  60.     done
  61. }
  62.  
  63. # Checks if a file '$1' exists.
  64. file_exists () {
  65.     if [ ! -f "$1" ] ; then
  66.         printf "\n\e[1;33mWARNING\e[0m: \e[1m$1\e[0m is not found !\n"
  67.         encontinue
  68.         return 1
  69.     else
  70.         return 0
  71.     fi
  72. }
  73.  
  74. # Force removes a file '$2' and then copies a file '$1' to '$2'.
  75. copier () {
  76.     if [ -f "$1" ] ; then
  77.         rm -f $2
  78.         cp $1 $2
  79.         return 0
  80.     else
  81.         return 1
  82.     fi
  83. }
  84.  
  85. # Force removes a file '$2' and then moves a file '$1' to '$2'.
  86. mover () {
  87.     if [ -f "$1" ] ; then
  88.         rm -f $2
  89.         mv $1 $2
  90.         return 0
  91.     else
  92.         return 1
  93.     fi
  94. }
  95.  
  96. # Downloads a file '$2' from a link '$1' and checks if this file has been downloaded successfully.
  97. wgetter () {
  98.     rm -f $2
  99.     wget $1
  100.     if [ -f "$2" ] ; then
  101.         file_size=$(($( wc -c < "$2" )))
  102.         if [ "$file_size" -eq "0" ] ; then
  103.             rm -f $2
  104.         fi
  105.     fi
  106.     if [ ! -f "$2" ] ; then
  107.         printf "\n\e[1;33mWARNING\e[0m: can't download a \e[1m$2\e[0m file !\n"
  108.         printf "         Please check your Internet connection and try again.\n"
  109.         encontinue
  110.         return 1
  111.     else
  112.         return 0
  113.     fi
  114. }
  115.  
  116. # Unzips the archive '$1', optional '$2' for -j path inside the archive, and then force removes it.
  117. unzipper () {
  118.     if [ -f "$1" ] ; then
  119.         if [ -z "$2" ] ; then
  120.             unzip $1
  121.         else
  122.             unzip -j $1 $2
  123.         fi
  124.         rm -f $1
  125.         return 0
  126.     else
  127.         return 1
  128.     fi
  129. }
  130.  
  131. # Expands a file '$1' with zeroes using a dd to '$2' size - e.g. to a standard floppy size 1474560.
  132. expander () {
  133.     if [ -f "$1" ] && [ ! -z "$2" ] ; then
  134.         file_size=$(($( wc -c < "$1" )))
  135.         if [ "$file_size" -lt "$2" ] ; then
  136.             dd if=/dev/zero of=$1 bs=1 count=1 seek="$(( $2 - 1 ))" conv=notrunc iflag=nocache
  137.         fi
  138.         return 0
  139.     else
  140.         return 1
  141.     fi
  142. }
  143.  
  144. # Compares sha256sum of '$1.img' floppy image with '$2' and creates a hidden '.$1' file if matches.
  145. floppy_verifier () {
  146.     rm -f ./.$1
  147.     cd ..
  148.     if [ ! -z "$2" ] ; then
  149.         sha256sum_correct="$2  ./floppies/$1.img"
  150.         sha256sum_my=$( sha256sum ./floppies/$1.img )
  151.         printf "\n=== sha256sum should be:\n\e[1m$sha256sum_correct\e[0m\n"
  152.         if [ "$sha256sum_my" = "$sha256sum_correct" ] ; then
  153.             printf "^^^ this is correct, ./floppies/\e[1m$1.img\e[0m is verified and could be added.\n\n"
  154.             cd ./floppies/
  155.             touch ./.$1
  156.             return 0
  157.         else
  158.             printf "\e[1m^^^ ! MISMATCH for ./floppies/$1.img ! Check sha256sum manually: sha256sum ./floppies/$1.img\e[0m\n"
  159.             encontinue
  160.             cd ./floppies/
  161.             return 1
  162.         fi
  163.     else
  164.         printf "\n\e[1;33mWARNING\e[0m: ./floppies/\e[1m$1.img\e[0m - is a rolling release, its' SHA256 checksum"
  165.         printf "\n         is changing constantly and not provided by $1 project, so not checked.\n"
  166.         encontinue
  167.         cd ./floppies/
  168.         touch ./.$1
  169.         return 0
  170.     fi
  171. }
  172.  
  173. # Downloads a collection of floppies, for the purpose of adding them later to a coreboot ROM image.
  174. floppy_mass_downloader () {
  175.     if [ ! -d ./floppies/ ]; then
  176.         mkdir ./floppies/
  177.     fi
  178.     cd ./floppies/
  179.     # KOLIBRI
  180.     if wgetter "https://builds.kolibrios.org/eng/latest-img.7z" ./latest-img.7z ; then
  181.         rm -f ./kolibri.img
  182.         7za x ./latest-img.7z
  183.         rm -f ./latest-img.7z
  184.            floppy_verifier "kolibri" "" # IS A ROLLING RELEASE, NO SHA256 VERIFICATION
  185.     fi
  186.     # FREEDOS
  187.     if wgetter "https://www.freedos.org/download/download/FD12FLOPPY.zip" ./FD12FLOPPY.zip ; then
  188.         unzipper ./FD12FLOPPY.zip "FLOPPY.img"
  189.         mover ./FLOPPY.img ./freedos.img
  190.            floppy_verifier "freedos" "de2fb84dc2f132324549e89d58c6383497ec1af538c5b0ecde389fb748b9d537"
  191.     fi
  192.     # MICHALOS
  193.     printf "\n\e[1;33mWARNING\e[0m: getting ./floppies/\e[1mmichalos.img\e[0m could take a couple of minutes...\n\n"
  194.     if wgetter "--content-disposition -c https://sourceforge.net/projects/michalos/files/MichalOS%202.0%20Beta%204/MichalOS.zip" ./MichalOS.zip ; then
  195.         unzipper ./MichalOS.zip "disk_images/michalos.flp"
  196.         mover ./michalos.flp ./michalos.img
  197.           floppy_verifier "michalos" "431ef7c6c814a9d2ba472bd1e2b9325ee29342ec3e38927e5cc546fd5e33a19e"
  198.     fi
  199.     # SNOWDROP
  200.     if wgetter "http://sebastianmihai.com/downloads/snowdrop/snowdrop.img" ./snowdrop.img ; then
  201.           floppy_verifier "snowdrop" "" # IS A ROLLING RELEASE, NO SHA256 VERIFICATION
  202.     fi
  203.     # FIWIX
  204.     if wgetter "--output-document=fiwix.img https://www.fiwix.org/fiwix-1.0.1-i386-initrd.img" ./fiwix.img ; then
  205.              floppy_verifier "fiwix" "dbec2994ec619c9954327ab0b983ab24cd362406a2e515c35c79c79bd6417cfd"
  206.     fi
  207.     # MEMTEST
  208.     if wgetter "https://www.memtest.org/download/5.01/memtest86+-5.01.floppy.zip" ./memtest86+-5.01.floppy.zip ; then
  209.         unzipper ./memtest86+-5.01.floppy.zip "floppy/memtestp.bin"
  210.         expander ./memtestp.bin 1474560
  211.         mover ./memtestp.bin ./memtest.img
  212.            floppy_verifier "memtest" "364535abd0d105da9396df6015e480c4d4c52b07dcc4e1d4756bde8ef87a30f1"
  213.     fi
  214.     # TATOS
  215.     if wgetter "--output-document=tatos.img https://github.com/tatimmer/tatOS/raw/master/tatOS.img" ./tatos.img ; then
  216.         expander ./tatos.img 1474560
  217.              floppy_verifier "tatos" "2c66f884498a4fe7b469bc213aebfccd84a09fd7ace1b3b4b3e747e2392c35d1"
  218.     fi
  219.     # PLOP
  220.     if wgetter "https://download.plop.at/files/bootmngr/plpbt-5.0.15.zip" ./plpbt-5.0.15.zip ; then
  221.         unzipper ./plpbt-5.0.15.zip "plpbt-5.0.15/plpbt.img"
  222.         mover ./plpbt.img ./plop.img
  223.               floppy_verifier "plop" "f170759966ec4efe60c8531158344a234d7543c8de81e54c8c1bb9d2d69eaf27"
  224.     fi
  225.     # FLOPPYBIRD
  226.     if wgetter "https://github.com/mikebdp2/floparchive/raw/master/floppies_extra/floppybird.img" ./floppybird.img ; then
  227.         floppy_verifier "floppybird" "5db1b469e25e9eda7b8c0f666d6b655bab083c85618a9453ee72f1201cca840f"
  228.     fi
  229.     # Some floppies have the weird permissions after their extraction
  230.     floppies=$( find . -name "*.img" )
  231.     if [ ! -z "$floppies" ] ; then
  232.         chmod 755 ./*.img
  233.     fi
  234.     # Return back to ./coreboot/
  235.     cd ..
  236.     return 0
  237. }
  238.  
  239. # Adds a './pci1002,$1.rom' to coreboot '$3' ROM using '$2' cbfstool, printing '$4'/'$5'/'$6' info.
  240. atombios_adder () {
  241.     if file_exists "$2" && file_exists "$3" ; then
  242.         if [ -f "./pci1002,$1.rom" ] ; then
  243.             if yesno "\nAdd a ./\e[1mpci1002,$1.rom\e[0m for \e[1m$5 : $6\e[0m to your $3 now? \e[1m~$4\e[0m" ; then
  244.                 printf "Adding...\n"
  245.                 $2 $3 add -f ./pci1002,$1.rom -n pci1002,$1.rom -t optionrom
  246.             else
  247.                 printf "\n\e[1mYou can add it later by running:\e[0m"
  248.                 printf "\n\e[1m        $2 $3 add -f ./pci1002,$1.rom -n pci1002,$1.rom -t optionrom\e[0m\n\n"
  249.             fi
  250.             return 0
  251.         else
  252.             printf "\n\e[1;33mWARNING\e[0m: cannot find ./\e[1mpci1002,$1.rom\e[0m ,"
  253.             printf "\n         please re-apply \e[1mAMD atombios\e[0m patch.\n"
  254.             encontinue
  255.             return 1
  256.         fi
  257.     else
  258.         return 1
  259.     fi
  260. }
  261.  
  262. # Adds a '$1.img' floppy image to coreboot '$3' ROM using '$2' cbfstool, printing '$4' size info.
  263. floppy_adder () {
  264.     if file_exists "$2" && file_exists "$3" ; then
  265.         if [ -f "./floppies/$1.img" ] ; then
  266.             if [ -f "./floppies/.$1" ] ; then
  267.                 if printf "$1" | grep -q "plop" ; then
  268.                     printf "\n\e[1;33mWARNING\e[0m: ./floppies/\e[1m$1.img\e[0m - is proprietary: all its' source code is closed!"
  269.                     printf "\n         Add it only if you really need it and trust the author of $1 project.\n"
  270.                     encontinue
  271.                 fi
  272.                 if yesno "\nAdd a ./floppies/\e[1m$1.img\e[0m to your $3 now? \e[1m~$4\e[0m" ; then
  273.                     printf "Adding...\n"
  274.                     $2 $3 add -f ./floppies/$1.img -n floppyimg/$1.lzma -t raw -c lzma
  275.                 else
  276.                     printf "\n\e[1mYou can add it later by running:\e[0m"
  277.                     printf "\n\e[1m        $2 $3 add -f ./floppies/$1.img -n floppyimg/$1.lzma -t raw -c lzma\e[0m\n\n"
  278.                 fi
  279.                 return 0
  280.             else
  281.                 printf "\n\e[1;33mWARNING\e[0m: there was a SHA256 mismatch for ./floppies/\e[1m$1.img\e[0m -"
  282.                 printf "\n         check sha256sum manually: sha256sum ./floppies/\e[1m$1.img\e[0m\n"
  283.                 encontinue
  284.                 return 1
  285.             fi
  286.         else
  287.             printf "\n\e[1;33mWARNING\e[0m: cannot find ./floppies/\e[1m$1.img\e[0m , please re-download.\n"
  288.             printf "\n         please re-download a set of floppies.\n"
  289.             encontinue
  290.             return 1
  291.         fi
  292.     else
  293.         return 1
  294.     fi
  295. }
  296.  
  297. # Adds a set of AtomBIOS/floppies ('$1') to coreboot '$3' ROM copied to '$4', using '$2' cbfstool.
  298. cbfs_mass_adder () {
  299.     if [ ! -f "./MAINTAINERS" ] || \
  300.         ! grep -cq "how to submit coreboot changes" ./MAINTAINERS ; then
  301.         printf "\n\e[1;33mWARNING\e[0m: not sure if I am inside the coreboot directory,"
  302.         printf "\n         trying to add a \e[1m$1\e[0m set from here - could fail.\n\n"
  303.     fi
  304.     if file_exists "$2" && file_exists "$3" ; then
  305.         if printf "$1" | grep -q "atom" || printf "$1" | grep -q "flop" ; then
  306.             copier $3 $4
  307.             printf "\n\e[1m=== $4 - initial memory map\e[0m\n\n"
  308.             $2 $4 print
  309.             printf "\n"
  310.             if printf "$1" | grep -q "atom" ; then
  311. ###
  312. ### https://review.coreboot.org/c/coreboot/+/31944
  313. ### G505S AtomBIOS ROMs: known good binaries with a script to check their SHA256
  314. ###
  315.            csb_patcher "atombios" "31944"  "5" "4f46bfc" "bea3e5d0109f79e84589e32b32b654fcff18190b640730b853d2270cf5155568" "$1" "AMD "
  316.                 atombios_adder "990b" "$2" "$4" "62K" "Lenovo G505S with A10-5750M"  "iGPU HD-8650G"
  317.                 atombios_adder "6663" "$2" "$4" "33K" "Lenovo G505S with A10-5750M"  "dGPU HD-8570M"
  318.                 atombios_adder "6665" "$2" "$4" "32K" "Lenovo G505S with A10-5750M"  "dGPU R5-M230"
  319.                 atombios_adder "9830" "$2" "$4" "59K" "ASUS AM1I-A with Athlon-5370" "iGPU HD-8400 / R3-Series"
  320.                 atombios_adder "990c" "$2" "$4" "62K" "ASUS A88XM-E with A10-6700"   "iGPU HD-8670D"
  321.             fi
  322.             if printf "$1" | grep -q "flop" ; then
  323.                 if [ ! -d "./floppies/" ] ; then
  324.                     floppy_downloader
  325.                 fi
  326.                 # Default boot order: the last floppy added - is the first floppy to boot!
  327.                 floppy_adder "floppybird" "$2" "$4"    "2K"
  328.                       floppy_adder "plop" "$2" "$4"   "74K"
  329.                      floppy_adder "tatos" "$2" "$4"   "60K"
  330.                    floppy_adder "memtest" "$2" "$4"   "44K"
  331.                      floppy_adder "fiwix" "$2" "$4"  "458K"
  332.                   floppy_adder "snowdrop" "$2" "$4"  "126K"
  333.                   floppy_adder "michalos" "$2" "$4"  "268K"
  334.                    floppy_adder "freedos" "$2" "$4"  "698K"
  335.                    floppy_adder "kolibri" "$2" "$4" "1256K"
  336.             fi
  337.             printf "\n\e[1m=== $4 - final memory map\e[0m\n\n"
  338.             $2 $4 print
  339.             printf "\n"
  340.             return 0
  341.         else
  342.             return 1
  343.         fi
  344.     else
  345.         return 1
  346.     fi
  347. }
  348.  
  349. # Finds the files of '$1' extension, saves the result to '$2' log and prints a message with '$3'.
  350. csb_finder () {
  351.     files=$( find . -name "*.$1" )
  352.     if [ ! -z "$files" ] ; then
  353.         printf "%25s\n" "*.$1 - YES" >> $2
  354.         printf "\n\e[1;33mWARNING\e[0m: found \e[1m*.$1\e[0m files at these locations:\n"
  355.         printf "$files"
  356.         printf "\n  That means - Some patches $3\n"
  357.         encontinue
  358.         return 0
  359.     else
  360.         printf "%24s\n" "*.$1 - NO" >> $2
  361.         return 1
  362.     fi
  363. }
  364.  
  365. # Prints a csb_patcher_log '$1' with a custom highlighting.
  366. csb_printer () {
  367.     while IFS= read -r line
  368.     do
  369.         if printf "$line" | grep -q "YES" ; then
  370.             printf "${line%???}\e[1;"
  371.             if printf "$line" | grep -q "*." ; then
  372.                 if printf "$line" | grep -q "*.rej" ; then
  373.                     printf "31mYES" # RED
  374.                 else
  375.                     printf "33mYES" # YELLOW
  376.                 fi
  377.             else
  378.                 printf "32mYES" # GREEN
  379.             fi
  380.         else
  381.             if printf "$line" | grep -q "NO" ; then
  382.                 printf "${line%??}\e[1;"
  383.                 if printf "$line" | grep -q "*." ; then
  384.                     printf "32mNO" # GREEN
  385.                 else
  386.                     printf "33mNO" # YELLOW
  387.                 fi
  388.             else
  389.                 if printf "$line" | grep -q "FAILURE_1" ; then
  390.                     printf "${line%?????????}\e[1;31mFAILURE_1" # RED
  391.                 else
  392.                     if printf "$line" | grep -q "FAILURE_2" ; then
  393.                         printf "${line%?????????}\e[1;31mFAILURE_2" # RED
  394.                     else
  395.                         if printf "$line" | grep -q "FAILURE_3" ; then
  396.                             printf "${line%?????????}\e[1;31mFAILURE_3" # RED
  397.                         else
  398.                             if printf "$line" | grep -q "\\\\" ; then
  399.                                 printf "\e[1m${line%?????}\\\\\!//"
  400.                             else
  401.                                 printf "\e[1m$line"
  402.                             fi
  403.                         fi
  404.                     fi
  405.                 fi
  406.             fi
  407.         fi
  408.         printf "\e[0m\n"
  409.     done < "$1"
  410.     return 0
  411. }
  412.  
  413. #
  414. # Conveniently and securely gets, checks SHA256 and installs a patch.
  415. # Arguments are the patch properties:
  416. #     $1 - new diff name, could be also a part of extracted scripts' filename
  417. #     $2 - change ID number,       part of download link to review.coreboot.org
  418. #     $3 - change revision number, part of download link to review.coreboot.org
  419. #     $4 - diff filename inside the downloaded archive, will be renamed to $1
  420. #     $5 - diff known good SHA256 checksum, will be used for SHA256 verification
  421. #     $6 - filepath where to save a csb_patcher_log which will be printed later
  422. #     $7 - info about the target of a patch, if not specified ("") it is common
  423. #
  424. csb_patcher () {
  425.     if ! wgetter "https://review.coreboot.org/changes/$2/revisions/$3/patch?zip" ./patch\?zip ; then
  426.         printf "\e[1m^^^ ! Can't download a $7$1 patch ! Check your Internet.\e[0m\n"
  427.         printf "%31s\n" "$7$1 - FAILURE_1" >> $6
  428.         csb_printer "$6"
  429.         exit 1
  430.     fi
  431.     unzipper ./patch\?zip
  432.     mover ./$4.diff ./$1.diff
  433.     sha256sum_correct="$5  ./$1.diff"
  434.     sha256sum_my=$( sha256sum ./$1.diff )
  435.     printf "\n=== sha256sum should be:\n\e[1m$sha256sum_correct\e[0m\n"
  436.     if [ "$sha256sum_my" = "$sha256sum_correct" ] ; then
  437.         printf "^^^ this is correct, "
  438.         title=$( grep "Subject" ./$1.diff )
  439.         title=${title#?????????????????}
  440.         if [ $1 = "dgpu" ] ; then
  441.             printf "will extract a \e[1m$7$1\e[0m patch now...\n"
  442.             rm -f ./sha256sums_$1_correct.txt
  443.             rm -f ./*_$1_patches.sh
  444.             patch -p1 < ./$1.diff
  445.             chmod +x ./*_$1_patches.sh
  446.             ./get_$1_patches.sh
  447.             if ! ./check_$1_patches.sh ; then
  448.                 printf "%31s\n" "$7$1 - FAILURE_3" >> $6
  449.                 csb_printer "$6"
  450.                 exit 1
  451.             fi
  452.         else
  453.             printf "\e[1m$7$1\e[0m patch could be applied now...\n"
  454.         fi
  455.         if [ $1 = "dgpu" ] || [ $1 = "atombios" ] || \
  456.            [ $1 = "tint" ] || [ $1 = "seabios" ] ; then
  457.             printf "\n\n\e[1;32m[PATCH]\e[0m $title\n\n"
  458.             if [ ! -f "./MAINTAINERS" ] || \
  459.                 ! grep -cq "how to submit coreboot changes" ./MAINTAINERS ; then
  460.                     printf "\n\e[1;33mWARNING\e[0m: not sure if I am inside the coreboot directory,"
  461.                     printf "\n         trying to apply a \e[1m$7$1\e[0m patch from here - could fail.\n\n"
  462.             fi
  463.             if [ -f "./.$1" ] ; then
  464.                 printf "\n\e[1;33mWARNING\e[0m: found a '.$1' hidden file at the current directory,"
  465.                 printf "\n         maybe you have applied this patch already.\n\n"
  466.             fi
  467.             if yesno "Apply a \e[1m$7$1\e[0m patch now?" ; then
  468.                 printf "\n"
  469.                 if [ $1 = "dgpu" ] ; then
  470.                     ./apply_$1_patches.sh
  471.                 else
  472.                     if [ $1 = "atombios" ] ; then
  473.                         rm -f ./sha256sums_$1_correct.txt
  474.                         rm -f ./*_$1_roms.sh
  475.                         rm -f ./pci1002\,*.rom
  476.                         rm -f ./pci1002\,*.rom.txt
  477.                     fi
  478.                     if [ $1 = "tint" ] ; then
  479.                         rm -f ./payloads/external/tint/tint.sh
  480.                         rm -f ./payloads/external/tint/*_core.sh
  481.                         rm -f ./payloads/external/tint/tint-0.04-nmu1_libpayload.patch
  482.                     fi
  483.                     if [ $1 = "seabios" ] ; then
  484.                         rm -f ./payloads/external/SeaBIOS/*.patch
  485.                     fi
  486.                     patch -p1 < ./$1.diff
  487.                     if [ $1 = "atombios" ] ; then
  488.                         chmod +x ./*_$1_roms.sh
  489.                         ./extract_$1_roms.sh
  490.                         printf "\n"
  491.                         if ! ./check_$1_roms.sh ; then
  492.                             printf "%31s\n" "$7$1 - FAILURE_3" >> $6
  493.                             csb_printer "$6"
  494.                             exit 1
  495.                         fi
  496.                     fi
  497.                     if [ $1 = "tint" ] ; then
  498.                         chmod +x ./payloads/external/tint/*_core.sh
  499.                     fi
  500.                 fi
  501.                 touch ".$1"
  502.                 printf "%25s\n" "$7$1 - YES" >> $6
  503.                 if [ $1 = "atombios" ] ; then
  504.                     encontinue
  505.                 fi
  506.             else
  507.                 printf "%24s\n" "$7$1 - NO" >> $6
  508.                 printf "\n\e[1mYou can apply it later by running:\e[0m"
  509.                 if [ $1 = "dgpu" ] ; then
  510.                     printf "\n\e[1m        ./apply_$1_patches.sh\e[0m\n"
  511.                 else
  512.                     printf "\n\e[1m        patch -p1 < ./$1.diff\e[0m\n"
  513.                 fi
  514.                 encontinue
  515.             fi
  516.         fi
  517.         if printf "$1" | grep -q "config" ; then
  518.             rm -f ./configs/$1_*
  519.             patch -p1 < ./$1.diff
  520.             printf "\n\n\e[1;32m[PATCH]\e[0m $title\n\n"
  521.             config_name=$( ls ./configs | grep "$1" )
  522.             printf "\n\e[1m$config_name could now be found at ./configs/\e[0m"
  523.             printf "\n\e[1mTo use it, it should be copied to '.config' of your ./coreboot directory.\e[0m\n\n"
  524.             if [ -f "./.config" ] ; then
  525.                 printf "\n\e[1;33mWARNING\e[0m: copying it to ./.config will overwrite your current '.config'\n\n"
  526.             fi
  527.             if yesno "Copy it to ./.config now?" ; then
  528.                 copier ./configs/$config_name ./.config
  529.                 printf "\n"
  530.                 printf "%25s\n" "$7$1 - YES" >> $6
  531.             else
  532.                 printf "%24s\n" "$7$1 - NO" >> $6
  533.                 printf "\n\e[1mYou can copy it later by running:\e[0m"
  534.                 printf "\n\e[1m        cp ./configs/$config_name ./.config\e[0m\n\n"
  535.             fi
  536.             printf "\n\e[1;33mWARNING\e[0m: important README at the beginning of ./$1.diff\n"
  537.             encontinue
  538.         fi
  539.         return 0
  540.     else
  541.         printf "\e[1m^^^ ! MISMATCH for a $7$1 patch ! Check sha256sum manually: sha256sum ./$1.diff\e[0m\n"
  542.         printf "%31s\n" "$7$1 - FAILURE_2" >> $6
  543.         csb_printer "$6"
  544.         exit 1
  545.     fi
  546. }
  547.  
  548. #
  549. # Conveniently and securely gets, checks SHA256 and applies my collection of unofficial patches.
  550. #     $1 - filepath where to save a csb_patcher_log which will be printed later
  551. #
  552. csb_mass_patcher () {
  553. ###
  554. ### https://review.coreboot.org/c/coreboot/+/31929
  555. ### G505S dGPU support: scripts for applying the unofficial (not-merged-yet) patches
  556. ###
  557.                csb_patcher "dgpu" "31929"  "9" "26ebc2c" "ba8fb7ba4a28a14bf2384a750c566514399ee9f753249897a6d49e03f7de5629" "$1" "G505S "
  558. ###
  559. ### https://review.coreboot.org/c/coreboot/+/31944
  560. ### G505S AtomBIOS ROMs: known good binaries with a script to check their SHA256
  561. ###
  562.            csb_patcher "atombios" "31944"  "5" "4f46bfc" "bea3e5d0109f79e84589e32b32b654fcff18190b640730b853d2270cf5155568" "$1" "AMD "
  563. ###
  564. ### https://review.coreboot.org/c/coreboot/+/23856
  565. ### tint: introduce the new tint build system with checksum verification
  566. ###
  567.                csb_patcher "tint" "23856" "14" "3c1d87e" "9f02732da84df6618d32a58aaced666da85772c29a763f46962f1c1ce77966d3" "$1" ""
  568. ###
  569. ### https://review.coreboot.org/c/coreboot/+/32351
  570. ### SeaBIOS - unofficial patches: advanced_bootmenu and multiple_floppies
  571. ###
  572.             csb_patcher "seabios" "32351"  "2" "358edcd" "a2b3475c4a7dffa5ee82e41eb5ea8d6a7783f96eb3862a530f2ee6e48b23dbe2" "$1" ""
  573. ###
  574. ### https://review.coreboot.org/c/coreboot/+/32352
  575. ### configs: add Lenovo G505S sample configuration (use with dGPU patches)
  576. ###
  577. csb_patcher "config.lenovo_g505s" "32352"  "5" "7635ff7" "b30883ab8d56cf3a928aa8e5b1f2ea428268318ed7f646651724490cb5985425" "$1" ""
  578.     return 0
  579. }
  580.  
  581. #
  582. # MAIN PART OF A CSB_PATCHER SCRIPT
  583. #
  584.  
  585. if [ -z "$1" ] ; then
  586.     csb_patcher_log="./.csb_patcher"
  587.     rm -f $csb_patcher_log
  588.     printf '\n\n'                                      >> $csb_patcher_log
  589.     printf '                \\\\!//\n'                 >> $csb_patcher_log
  590.     printf '                (o o)\n'                   >> $csb_patcher_log
  591.     printf '            oOOo-(_)-oOOo\n'               >> $csb_patcher_log
  592.     printf 'Hi! I am coreboot and SeaBIOS patcher\n'   >> $csb_patcher_log
  593.     printf 'Please send your feedback to\n'            >> $csb_patcher_log
  594.     printf '      Mike Banon <mikebdp2@gmail.com>\n'   >> $csb_patcher_log
  595.     csb_printer $csb_patcher_log
  596.     encontinue
  597.     printf '\n=== CSB_PATCHER LOG. Patches applied?\n' >> $csb_patcher_log
  598.  
  599.     csb_mass_patcher $csb_patcher_log
  600.  
  601.     if yesno "\n\nDownload a \e[1mfloppies\e[0m collection?" ; then
  602.         printf "\n"
  603.         floppy_mass_downloader
  604.                       printf "%25s\n" "floppies - YES" >> $csb_patcher_log
  605.     else
  606.         printf "\n"
  607.                       printf "%24s\n" "floppies - NO"  >> $csb_patcher_log
  608.     fi
  609.  
  610.     printf '==================== Bad files found?\n'   >> $csb_patcher_log
  611.     csb_finder "orig" "$csb_patcher_log" "applied correctly although at slightly different lines, can ignore it."
  612.      csb_finder "rej" "$csb_patcher_log" "perhaps failed to apply, could result in a broken build! \e[1;31mPlease report\e[0m"
  613.  
  614.     printf '==================== After building :\n'   >> $csb_patcher_log
  615.     printf './csb_patcher.sh atom\n'                   >> $csb_patcher_log
  616.     printf '  to add the AtomBIOS to coreboot.rom\n\n' >> $csb_patcher_log
  617.     printf './csb_patcher.sh flop\n'                   >> $csb_patcher_log
  618.     printf '  to add the floppies to coreboot.rom\n\n' >> $csb_patcher_log
  619.     printf './csb_patcher.sh atomflop\n'               >> $csb_patcher_log
  620.     printf '  both AtomBIOS VGA ROMs and floppies\n\n' >> $csb_patcher_log
  621.     csb_printer "$csb_patcher_log"
  622. else
  623.     cbfs_mass_adder "$1" "./build/cbfstool" "./build/coreboot.rom" "./build/coreflop.rom"
  624. fi
  625.  
  626. exit 0
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top