libdeb.sh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. #!/bin/bash
  2. # Creates a .deb package for searx-qt
  3. # run from: searx-qt root (where setup.py is).
  4. PKGNAME=
  5. VERSION=
  6. REL=
  7. ARCH=
  8. MAINTAINER=
  9. DESC=
  10. URL=
  11. MAKEDEPENDS=
  12. DEPENDS=
  13. ROOT=$(pwd)
  14. SRCDIR=$(realpath "src")
  15. PKGDIR=$(realpath "pkg")
  16. if [[ ! -d "${SRCDIR}" ]]; then
  17. mkdir "${SRCDIR}"
  18. fi
  19. function get_sources() {
  20. :
  21. }
  22. function prepare() {
  23. :
  24. }
  25. function build() {
  26. :
  27. }
  28. function package() {
  29. :
  30. }
  31. function check_deps() {
  32. MISSING=()
  33. for pkg in "${MAKEDEPENDS[@]}"; do
  34. dpkg -s "${pkg}" > /dev/null 2>&1
  35. if [[ $? -ne 0 ]]; then
  36. MISSING+=("${pkg}")
  37. fi
  38. done
  39. for pkg in "${DEPENDS[@]}"; do
  40. dpkg -s "${pkg}" > /dev/null 2>&1
  41. if [[ $? -ne 0 ]]; then
  42. MISSING+=("${pkg}")
  43. fi
  44. done
  45. if [[ ${#MISSING[@]} -ne 0 ]]; then
  46. echo "The following packages are missing, please install them first:"
  47. echo ""
  48. echo " ${MISSING[@]}"
  49. echo ""
  50. exit 1
  51. fi
  52. }
  53. function exec() {
  54. # Check dependencies
  55. check_deps
  56. # Make sure the pkg dir is fresh
  57. if [[ -d "${PKGDIR}" ]]; then
  58. rm -rf "${PKGDIR}"
  59. fi
  60. mkdir "${PKGDIR}"
  61. # Get the sources
  62. get_sources
  63. if [[ $? -ne 0 ]]; then
  64. exit 1
  65. fi
  66. # Prepare
  67. prepare
  68. if [[ $? -ne 0 ]]; then
  69. exit 1
  70. fi
  71. # Build the sources
  72. build
  73. if [[ $? -ne 0 ]]; then
  74. exit 1
  75. fi
  76. # Package
  77. package
  78. if [[ $? -ne 0 ]]; then
  79. exit 1
  80. fi
  81. mkdir "${PKGDIR}/DEBIAN"
  82. echo "Package: ${PKGNAME}
  83. Version: ${VERSION}
  84. Maintainer: ${MAINTAINER}
  85. Depends: ${DEPENDS}
  86. Architecture: ${ARCH}
  87. Homepage: ${URL}
  88. Description: ${DESC}" \
  89. > "${PKGDIR}/DEBIAN/control"
  90. dpkg --build "${PKGDIR}"
  91. if [[ $? -ne 0 ]]; then
  92. exit 1
  93. fi
  94. cd "${ROOT}"
  95. mv pkg.deb "${PKGNAME}-${VERSION}-${REL}_${ARCH}.deb"
  96. }