Free/libre software for Kobo ebook readers
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

123 lines
4.1 KiB

  1. #!/bin/bash
  2. # Copyright (c) 2015, Cosmin Gorgovan <cosmin at linux-geek dot org>
  3. # All rights reserved.
  4. #
  5. # Redistribution and use in source and binary forms, with or without
  6. # modification, are permitted provided that the following conditions are met:
  7. #
  8. # 1. Redistributions of source code must retain the above copyright notice, this
  9. # list of conditions and the following disclaimer.
  10. # 2. Redistributions in binary form must reproduce the above copyright notice,
  11. # this list of conditions and the following disclaimer in the documentation
  12. # and/or other materials provided with the distribution.
  13. #
  14. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  15. # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  16. # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  17. # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
  18. # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  19. # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  20. # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  21. # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22. # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  23. # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. available_targets=("linux-backports" "firmware-okreader")
  25. print_usage() {
  26. echo "Usage: fetch_sources.sh [TARGET]"
  27. echo "Valid targets are: "
  28. echo " all select all targets"
  29. for target in ${available_targets[*]}; do
  30. echo " $target"
  31. done
  32. }
  33. is_target() {
  34. for target in ${available_targets[*]}; do
  35. if [ $1 == $target ] ; then
  36. return 1
  37. fi
  38. done
  39. return 0
  40. }
  41. parse_args() {
  42. if [ $# -lt "1" ] ; then
  43. print_usage
  44. exit 1
  45. fi
  46. for arg in "$@"; do
  47. if [ $arg == all ] ; then
  48. targets=${available_targets[*]}
  49. else
  50. is_target $arg
  51. if [ $? == 1 ] ; then
  52. targets[${#targets[*]}]=$arg
  53. else
  54. echo "Error: Unrecognized target $arg"
  55. echo
  56. print_usage
  57. exit 1
  58. fi
  59. fi
  60. done
  61. }
  62. fetch_and_unpack_archive() {
  63. if [ -d src/$3 ] ; then
  64. echo "Warn: $2 already unpacked"
  65. return
  66. fi
  67. if [ -f src/$2 ] ; then
  68. echo "Info: $2 already downloaded"
  69. else
  70. wget $1 -O ./src/$2
  71. fi
  72. if [ $(sha256sum src/$2 | awk '{ print $1 }') != $4 ] ; then
  73. echo "Error: wrong checksum for $2"
  74. return
  75. fi
  76. tar xf src/$2 -C ./src/
  77. }
  78. fetch_and_verify() {
  79. if [ -f $2 ] ; then
  80. echo "Info: $2 already exists"
  81. else
  82. wget $1 -O $2
  83. fi
  84. if [ $(sha256sum $2 | awk '{ print $1 }') != $3 ] ; then
  85. echo "Error: wrong checksum for $2"
  86. rm $2
  87. return
  88. fi
  89. }
  90. targets=()
  91. parse_args $@
  92. for target in ${targets[*]}; do
  93. case $target in
  94. linux-backports)
  95. fetch_and_unpack_archive "https://www.kernel.org/pub/linux/kernel/projects/backports/stable/v3.14.22/backports-3.14.22-1.tar.xz" "backports-3.14.22-1.tar.xz" "backports-3.14.22-1" "a1b6a03647624545d77559db7cc33027aa4dcd882b48247287697dc6a255e3ac"
  96. ;;
  97. firmware-okreader)
  98. mkdir -p src/firmware-okreader/lib/firmware/brcm
  99. fetch_and_verify https://raw.githubusercontent.com/allwinner-ics/lichee_linux-3.0/e1a12df96abab1805df4e4b46b3ef7759cca0f84/modules/wifi/bcm40181/open-src/src/dhd/linux/NVRAM.txt src/firmware-okreader/lib/firmware/brcm/brcmfmac43362-sdio.txt 4542dd0adc727f56b4870e52388b47c9ae4afb9a4bbd7b7c30de9714af1aa173
  100. fetch_and_verify https://git.kernel.org/cgit/linux/kernel/git/firmware/linux-firmware.git/plain/brcm/brcmfmac43362-sdio.bin?id=b794c5039dcf0b7ebfeb58929d035f7a1d4c80dd src/firmware-okreader/lib/firmware/brcm/brcmfmac43362-sdio.bin 5783fd90528cc7ae421b6a6056b1572a3840eac4559b26d299d1acae17523e42
  101. fetch_and_verify https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/plain/LICENCE.broadcom_bcm43xx?id=b794c5039dcf0b7ebfeb58929d035f7a1d4c80dd src/firmware-okreader/lib/firmware/brcm/LICENCE.broadcom b16056fc91b82a0e3e8de8f86c2dac98201aa9dc3cbd33e8d38f1b087fcec30d
  102. ;;
  103. esac
  104. done