KXStudio Website https://kx.studio/
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.

generate-repo-page.sh 11KB

5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. #!/bin/bash
  2. set -e
  3. cd $(dirname "${0}")
  4. REPO_TARGET="${1}"
  5. if [ -z "${REPO_TARGET}" ]; then
  6. echo "usage: ${0} <apps|plugins>"
  7. exit 1
  8. fi
  9. PACKAGES_ARCHS=("amd64" "arm64" "armhf" "i386")
  10. PACKAGES_BLACKLIST=("carla-bridge-linux32" "carla-bridge-linux64" "distrho-src" "lv2vst" "wineasio-amd64")
  11. PACKAGES_WHITELIST=("cadence" "catia" "claudia" "impro-visor")
  12. PACKAGES_SEPARATE_DATA=("hybridreverb2")
  13. PACKAGES_BASE_URL="http://ppa.launchpad.net/kxstudio-debian/${REPO_TARGET}/ubuntu/"
  14. rm -f Packages.gz Packages
  15. mkdir -p pool-cache
  16. wget -q http://ppa.launchpad.net/kxstudio-debian/${REPO_TARGET}/ubuntu/dists/bionic/main/binary-amd64/Packages.gz
  17. gzip -d Packages.gz
  18. PACKAGES=$(cat Packages | grep "Package: " | sed "s/Package: //g" | sort)
  19. function is_blacklisted() {
  20. local TEST="${1}"
  21. local PACKAGE
  22. for PACKAGE in ${PACKAGES_BLACKLIST[@]}; do
  23. if [ ${TEST} = ${PACKAGE} ]; then
  24. return 0
  25. fi
  26. done
  27. return 1
  28. }
  29. function is_whitelisted() {
  30. local TEST="${1}"
  31. local PACKAGE
  32. for PACKAGE in ${PACKAGES_WHITELIST[@]}; do
  33. if [ ${TEST} = ${PACKAGE} ]; then
  34. return 0
  35. fi
  36. done
  37. return 1
  38. }
  39. function has_data_package() {
  40. local TEST="${1}-data"
  41. local PACKAGE
  42. for PACKAGE in ${PACKAGES[@]}; do
  43. if [ ${TEST} = ${PACKAGE} ]; then
  44. return 0
  45. fi
  46. done
  47. return 1
  48. }
  49. function has_separate_data_package() {
  50. local TEST="${1}"
  51. local PACKAGE
  52. for PACKAGE in ${PACKAGES_SEPARATE_DATA[@]}; do
  53. if [ ${TEST} = ${PACKAGE} ]; then
  54. return 0
  55. fi
  56. done
  57. return 1
  58. }
  59. function get_homepage() {
  60. local SOURCE="${1}"
  61. local VERSION="${2}"
  62. local SRC_FILENAME="${SOURCE}_$(echo ${VERSION} | sed 's/:/./').dsc"
  63. local SRC_LETTER=$(echo "${SOURCE}" | head -c 1)
  64. if [ ! -f "pool-cache/${SRC_FILENAME}" ]; then
  65. wget -q -O "pool-cache/${SRC_FILENAME}" "${PACKAGES_BASE_URL}/pool/main/${SRC_LETTER}/${SOURCE}/${SRC_FILENAME}"
  66. if [ $? != 0 ]; then
  67. rm -f "pool-cache/${SRC_FILENAME}"
  68. return 1
  69. fi
  70. fi
  71. cat "pool-cache/${SRC_FILENAME}" | awk 'sub("Homepage: ","")'
  72. return 0
  73. }
  74. function get_vcs_page() {
  75. local SOURCE="${1}"
  76. local VERSION="${2}"
  77. local SRC_FILENAME="${SOURCE}_$(echo ${VERSION} | sed 's/:/./').dsc"
  78. local SRC_LETTER=$(echo "${SOURCE}" | head -c 1)
  79. if [ ! -f "pool-cache/${SRC_FILENAME}" ]; then
  80. wget -q -O "pool-cache/${SRC_FILENAME}" "${PACKAGES_BASE_URL}/pool/main/${SRC_LETTER}/${SOURCE}/${SRC_FILENAME}"
  81. if [ $? != 0 ]; then
  82. rm -f "pool-cache/${SRC_FILENAME}"
  83. return 1
  84. fi
  85. fi
  86. cat "pool-cache/${SRC_FILENAME}" | awk 'sub("Kxstudio-Vcs: ","")'
  87. return 0
  88. }
  89. for PACKAGE in ${PACKAGES[@]}; do
  90. if is_blacklisted ${PACKAGE} || echo "${PACKAGE}" | grep -q -- "-static"; then
  91. continue
  92. fi
  93. PACKAGE_LINESTART=$(cat Packages | grep -x -n "Package: ${PACKAGE}" | cut -d ':' -f 1 | sort | tail -n 1)
  94. PACKAGE_NUMLINES=$(cat Packages | tail -n +$((${PACKAGE_LINESTART} + 1)) | grep -n "Package: " | head -n 1 | cut -d ':' -f 1)
  95. if [ -n "${PACKAGE_NUMLINES}" ]; then
  96. PACKAGE_DETAILS=$(cat Packages | tail -n +${PACKAGE_LINESTART} | head -n ${PACKAGE_NUMLINES})
  97. else
  98. PACKAGE_DETAILS=$(cat Packages | tail -n +${PACKAGE_LINESTART})
  99. fi
  100. PACKAGE_FILENAME=$(echo "${PACKAGE_DETAILS}" | awk 'sub("Filename: ","")')
  101. if echo "${PACKAGE_FILENAME}" | grep -q "_all.deb" && ! is_whitelisted "${PACKAGE}"; then
  102. continue
  103. fi
  104. PACKAGE_DATA=$(has_data_package "${PACKAGE}" && echo "${PACKAGE}-data" || echo)
  105. if [ -z "${PACKAGE_DATA}" ] && echo "${PACKAGE}" | grep -q -- \-; then
  106. PACKAGE_MAIN=$(echo "${PACKAGE}" | cut -d '-' -f 1)
  107. PACKAGE_DATA=$(has_data_package "${PACKAGE_MAIN}" && echo "${PACKAGE_MAIN}-data" || echo)
  108. fi
  109. PACKAGE_DESCRIPTION=$(echo "${PACKAGE_DETAILS}" | awk 'sub("Description: ","")')
  110. PACKAGE_PROVIDES=$(echo "${PACKAGE_DETAILS}" | awk 'sub("Provides: ","")')
  111. PACKAGE_SIZE=$(echo "${PACKAGE_DETAILS}" | grep -v "Installed-Size:" | awk 'sub("Size: ","")')
  112. PACKAGE_RVERSION=$(echo "${PACKAGE_DETAILS}" | awk 'sub("Version: ","")' | cut -d ':' -f 2)
  113. PACKAGE_VERSION=$(echo "${PACKAGE_RVERSION}" | cut -d '-' -f 1)
  114. PACKAGE_SOURCE=$(echo "${PACKAGE_DETAILS}" | awk 'sub("Source: ","")')
  115. if [ -z "${PACKAGE_SOURCE}" ]; then
  116. PACKAGE_SOURCE="${PACKAGE}"
  117. fi
  118. PACKAGE_HOMEPAGE=$(get_homepage "${PACKAGE_SOURCE}" "${PACKAGE_RVERSION}")
  119. PACKAGE_VCS_PAGE=$(get_vcs_page "${PACKAGE_SOURCE}" "${PACKAGE_RVERSION}")
  120. if echo "${PACKAGE_FILENAME}" | grep -q "carla-bridge-win64_"; then
  121. PACKAGE="carla-bridge-win"
  122. PACKAGE_DESCRIPTION="carla windows bridge"
  123. fi
  124. echo "<div class=\"repository-package\" id=\"${PACKAGE}\">"
  125. # screenshot
  126. SCREENSHOT=${PACKAGE}
  127. if [ ! -f "./screenshots/${SCREENSHOT}.png" ]; then
  128. SCREENSHOT=$(echo "${SCREENSHOT}" | sed "s/-lv2//g" | sed "s/-vst2//g" | sed "s/-vst3//g" | sed "s/-vst//g")
  129. if [ ! -f "./screenshots/${SCREENSHOT}.png" ]; then
  130. SCREENSHOT=""
  131. fi
  132. fi
  133. if [ -n "${SCREENSHOT}" ]; then
  134. echo "<div class=\"img_clickable\"><img src=\"/repo/screenshots/${SCREENSHOT}.png\" alt=\"${PACKAGE}\" class=\"img_thumb_150\"/>"
  135. echo "<div class=\"img_clickable_overlay\"><img src=\"/repo/screenshots/${SCREENSHOT}.png\" alt=\"${PACKAGE}\"/></div>"
  136. echo "</div>"
  137. else
  138. echo "<div><img src=\"/repo/screenshots/nogui.png\" alt=\"${PACKAGE}\" class=\"img_thumb_150\"/></div>"
  139. fi
  140. # full table
  141. echo "<div><table>"
  142. echo "<tr><td>Package Name:</td><td><a href=\"#${PACKAGE}\" style=\"text-decoration:none;color:#D6D6D6;\">${PACKAGE}</a></td></tr>"
  143. echo "<tr><td>Description:</td><td>${PACKAGE_DESCRIPTION}</td></tr>"
  144. if [ -n "${PACKAGE_HOMEPAGE}" ] || [ -n "${PACKAGE_VCS_PAGE}" ]; then
  145. echo "<tr><td>Useful links:</td><td>"
  146. if [ -n "${PACKAGE_HOMEPAGE}" ]; then
  147. echo "<a href=\"${PACKAGE_HOMEPAGE}\" target=\"_blank\">Homepage</a>&nbsp;&nbsp;"
  148. fi
  149. if [ -n "${PACKAGE_VCS_PAGE}" ]; then
  150. echo "<a href=\"${PACKAGE_VCS_PAGE}\" target=\"_blank\">VCS</a>&nbsp;&nbsp;"
  151. fi
  152. echo "</td></tr>"
  153. fi
  154. echo "<tr><td>Version:</td><td>${PACKAGE_VERSION}</td></tr>"
  155. echo "<tr><td>Package size:</td><td>"
  156. if [ ${PACKAGE_SIZE} -gt 1048576 ]; then
  157. echo "$((${PACKAGE_SIZE} / 1024 / 1024))Mb"
  158. else
  159. echo "$((${PACKAGE_SIZE} / 1024))Kb"
  160. fi
  161. if [ -n "${PACKAGE_DATA}" ]; then
  162. PACKAGE_DATA_LINESTART=$(cat Packages | grep -x -n "Package: ${PACKAGE_DATA}" | cut -d ':' -f 1 | sort | tail -n 1)
  163. PACKAGE_DATA_NUMLINES=$(cat Packages | tail -n +$((${PACKAGE_DATA_LINESTART} + 1)) | grep -n "Package: " | head -n 1 | cut -d ':' -f 1)
  164. if [ -n "${PACKAGE_DATA_NUMLINES}" ]; then
  165. PACKAGE_DATA_DETAILS=$(cat Packages | tail -n +${PACKAGE_DATA_LINESTART} | head -n ${PACKAGE_DATA_NUMLINES})
  166. else
  167. PACKAGE_DATA_DETAILS=$(cat Packages | tail -n +${PACKAGE_DATA_LINESTART})
  168. fi
  169. PACKAGE_DATA_SIZE=$(echo "${PACKAGE_DATA_DETAILS}" | grep -v "Installed-Size:" | awk 'sub("Size: ","")')
  170. if [ ${PACKAGE_DATA_SIZE} -gt 1048576 ]; then
  171. echo "+ $((${PACKAGE_DATA_SIZE} / 1024 / 1024))Mb (data)"
  172. else
  173. echo "+ $((${PACKAGE_DATA_SIZE} / 1024))Kb (data)"
  174. fi
  175. fi
  176. echo "</td></tr>"
  177. if [ ${REPO_TARGET} = "plugins" ]; then
  178. if [ -z "${PACKAGE_PROVIDES}" ]; then
  179. echo "<tr><td>Provides:</td><td>??</td></tr>"
  180. else
  181. echo "<tr><td>Provides:</td><td>"
  182. if echo "${PACKAGE_PROVIDES}" | grep -q standalone-plugin; then
  183. echo "Standalone "
  184. fi
  185. if echo "${PACKAGE_PROVIDES}" | grep -q ladspa-plugin; then
  186. echo "LADSPA "
  187. fi
  188. if echo "${PACKAGE_PROVIDES}" | grep -q dssi-plugin; then
  189. echo "DSSI "
  190. fi
  191. if echo "${PACKAGE_PROVIDES}" | grep -q lv2-plugin; then
  192. echo "LV2 "
  193. fi
  194. if echo "${PACKAGE_PROVIDES}" | grep -q vst-plugin; then
  195. echo "VST2 "
  196. fi
  197. if echo "${PACKAGE_PROVIDES}" | grep -q vst3-plugin; then
  198. echo "VST3 "
  199. fi
  200. echo "</td></tr>"
  201. fi
  202. fi
  203. echo "<tr><td>Downloads:</td><td>"
  204. if echo "${PACKAGE_FILENAME}" | grep -q "carla-bridge-win64_"; then
  205. # amd64
  206. echo "<a href=\"${PACKAGES_BASE_URL}${PACKAGE_FILENAME}\" target=\"_blank\">amd64</a>&nbsp;&nbsp;"
  207. # i386
  208. PACKAGE_FILENAME_ARCHED=$(echo "${PACKAGE_FILENAME}" | sed "s/-win64_/-win32_/g" | sed "s/_amd64.deb/_i386.deb/g")
  209. echo "<a href=\"${PACKAGES_BASE_URL}${PACKAGE_FILENAME_ARCHED}\" target=\"_blank\">i386</a>&nbsp;&nbsp;(install both)"
  210. elif echo "${PACKAGE_FILENAME}" | grep -q "carla-vst-wine_"; then
  211. # amd64
  212. echo "<a href=\"${PACKAGES_BASE_URL}${PACKAGE_FILENAME}\" target=\"_blank\">amd64</a>&nbsp;&nbsp;"
  213. # i386
  214. PACKAGE_FILENAME_ARCHED=$(echo "${PACKAGE_FILENAME}" | sed "s/_amd64.deb/_i386.deb/g")
  215. echo "<a href=\"${PACKAGES_BASE_URL}${PACKAGE_FILENAME_ARCHED}\" target=\"_blank\">i386</a>&nbsp;&nbsp;"
  216. elif echo "${PACKAGE_FILENAME}" | grep -q "wineasio_"; then
  217. # amd64
  218. PACKAGE_FILENAME_ARCHED=$(echo "${PACKAGE_FILENAME}" | sed "s/wineasio_/wineasio-amd64_/g")
  219. echo "<a href=\"${PACKAGES_BASE_URL}${PACKAGE_FILENAME_ARCHED}\" target=\"_blank\">amd64</a>&nbsp;&nbsp;"
  220. # i386
  221. PACKAGE_FILENAME_ARCHED=$(echo "${PACKAGE_FILENAME}" | sed "s/wineasio_/wineasio-i386_/g" | sed "s/_amd64.deb/_i386.deb/g")
  222. echo "<a href=\"${PACKAGES_BASE_URL}${PACKAGE_FILENAME_ARCHED}\" target=\"_blank\">i386</a>&nbsp;&nbsp;"
  223. elif echo "${PACKAGE_FILENAME}" | grep -q "_all.deb"; then
  224. echo "<a href=\"${PACKAGES_BASE_URL}${PACKAGE_FILENAME}\" target=\"_blank\">all</a>&nbsp;&nbsp;"
  225. else
  226. for ARCH in ${PACKAGES_ARCHS[@]}; do
  227. PACKAGE_FILENAME_ARCHED=$(echo "${PACKAGE_FILENAME}" | sed "s/_amd64.deb/_${ARCH}.deb/g")
  228. echo "<a href=\"${PACKAGES_BASE_URL}${PACKAGE_FILENAME_ARCHED}\" target=\"_blank\">${ARCH}</a>&nbsp;&nbsp;"
  229. done
  230. fi
  231. if [ -n "${PACKAGE_DATA}" ]; then
  232. if has_separate_data_package ${PACKAGE}; then
  233. PACKAGE_FILENAME_DATA=$(echo "${PACKAGE_FILENAME}" | sed "s|/${PACKAGE}|/${PACKAGE_DATA}|g" | sed "s/_amd64.deb/_all.deb/g")
  234. else
  235. PACKAGE_FILENAME_DATA=$(echo "${PACKAGE_FILENAME}" | sed "s|/${PACKAGE}_|/${PACKAGE_DATA}_|g" | sed "s/_amd64.deb/_all.deb/g")
  236. fi
  237. echo "<a href=\"${PACKAGES_BASE_URL}${PACKAGE_FILENAME_DATA}\" target=\"_blank\">data</a>"
  238. fi
  239. echo "</td></tr>"
  240. echo "</table></div></div>"
  241. # separator
  242. echo "<br/>"
  243. echo
  244. done
  245. rm -f Packages.gz Packages