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.
 
 
 
 
 

182 lines
4.9 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=("u-boot" "linux-image" "linux-modules" "firmware-okreader" "koreader" "kobo-hwconfig")
  25. print_usage() {
  26. echo "Usage: build.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. compile_uboot() {
  63. cd src/u-boot
  64. make mx50_rdp_config
  65. make -j$(($(nproc)+1))
  66. cd ../../
  67. }
  68. compile_linux_image() {
  69. cd src/linux
  70. make mx50_kobo_defconfig
  71. make -j$(($(nproc)+1)) uImage
  72. cd ../../
  73. }
  74. compile_linux_modules() {
  75. cd src/linux
  76. make -j$(($(nproc)+1)) modules
  77. cd ../../
  78. patch -N -p1 < src/linux_backports.patch
  79. cd src/backports-3.14.22-1
  80. KLIB_BUILD=../linux/ make defconfig-brcmfmac
  81. KLIB_BUILD=../linux/ make -j$(($(nproc)+1))
  82. cd ../
  83. mkdir -p linux-okreader-modules/lib/modules/2.6.35.3-850-gbc67621+/
  84. cp backports-3.14.22-1/drivers/net/wireless/brcm80211/brcmfmac/brcmfmac.ko linux-okreader-modules/lib/modules/2.6.35.3-850-gbc67621+/
  85. cp backports-3.14.22-1/drivers/net/wireless/brcm80211/brcmutil/brcmutil.ko linux-okreader-modules/lib/modules/2.6.35.3-850-gbc67621+/
  86. cp backports-3.14.22-1/net/wireless/cfg80211.ko linux-okreader-modules/lib/modules/2.6.35.3-850-gbc67621+/
  87. cp backports-3.14.22-1/compat/compat.ko linux-okreader-modules/lib/modules/2.6.35.3-850-gbc67621+/
  88. cp linux/drivers/usb/gadget/g_file_storage.ko linux-okreader-modules/lib/modules/2.6.35.3-850-gbc67621+/
  89. cp linux/drivers/mmc/card/sdio_wifi_pwr.ko linux-okreader-modules/lib/modules/2.6.35.3-850-gbc67621+/
  90. cp linux/drivers/usb/gadget/arcotg_udc.ko linux-okreader-modules/lib/modules/2.6.35.3-850-gbc67621+/
  91. dpkg-deb -b linux-okreader-modules .
  92. cd ..
  93. }
  94. compile_firmware_okreader() {
  95. cd src
  96. dpkg-deb -b firmware-okreader .
  97. cd ..
  98. }
  99. compile_koreader() {
  100. cd src/koreader
  101. # Remove previous builds
  102. rm *.targz *.tar.gz *.zip
  103. make fetchthirdparty
  104. make TARGET=kobo koboupdate
  105. cd ../koreader-pkg
  106. rm -Rf opt
  107. mkdir opt
  108. cd opt
  109. tar xf ../../koreader/koreader-kobo-arm-linux-gnueabihf*.targz
  110. cp ../../../files/okreader.sh koreader/
  111. cp ../../../files/disable-wifi.sh koreader/
  112. cp ../../../files/enable-wifi.sh koreader/
  113. cp ../../../files/obtain-ip.sh koreader/
  114. cp ../../../files/release-ip.sh koreader/
  115. chmod +x koreader/disable-wifi.sh
  116. chmod +x koreader/enable-wifi.sh
  117. chmod +x koreader/obtain-ip.sh
  118. chmod +x koreader/release-ip.sh
  119. chmod +x koreader/restore-wifi-async.sh
  120. cp ../../../files/defaults.persistent.lua koreader/
  121. mkdir koreader/bin
  122. echo "ntpdate pool.ntp.org" > koreader/bin/ntpd
  123. chmod +x koreader/bin/ntpd
  124. cd ../../
  125. dpkg-deb -b koreader-pkg .
  126. cd ../
  127. }
  128. compile_kobo_hwconfig() {
  129. make pkg -C ./src/kobo_hwconfig/
  130. }
  131. targets=()
  132. parse_args $@
  133. for target in ${targets[*]}; do
  134. case $target in
  135. u-boot)
  136. compile_uboot
  137. ;;
  138. linux-image)
  139. compile_linux_image
  140. ;;
  141. linux-modules)
  142. compile_linux_modules
  143. ;;
  144. firmware-okreader)
  145. compile_firmware_okreader
  146. ;;
  147. koreader)
  148. compile_koreader
  149. ;;
  150. kobo-hwconfig)
  151. compile_kobo_hwconfig
  152. ;;
  153. esac
  154. done