deb-package.sh 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. #!/bin/bash -e
  2. REPO_URL="https://github.com/eza-community/eza"
  3. NAME="eza"
  4. DESTDIR=/usr/bin
  5. DOCDIR=/usr/share/man/
  6. TAG=$(git describe --tags --abbrev=0)
  7. VERSION=${TAG:1}
  8. echo "checkout tag ${TAG}"
  9. git checkout --quiet "${TAG}"
  10. echo "build man pages"
  11. just man
  12. declare -A TARGETS
  13. TARGETS["amd64"]="x86_64-unknown-linux-gnu"
  14. TARGETS["arm64"]="aarch64-unknown-linux-gnu"
  15. TARGETS["armhf"]="arm-unknown-linux-gnueabihf"
  16. echo "download release notes"
  17. RELEASE_NOTES=$(curl -s ${REPO_URL}/releases/tag/"${TAG}")
  18. for ARCH in "${!TARGETS[@]}"; do
  19. echo "building ${ARCH} package:"
  20. DEB_TMP_DIR="${NAME}_${VERSION}_${ARCH}"
  21. DEB_PACKAGE="${NAME}_${VERSION}_${ARCH}.deb"
  22. TARGET=${TARGETS[$ARCH]}
  23. echo " -> downloading ${TARGET} archive"
  24. wget -q -O "${ARCH}.tar.gz" "${REPO_URL}/releases/download/${TAG}/${NAME}_${TARGET}.tar.gz"
  25. echo " -> verifying ${TARGET} archive"
  26. CHECKSUM=$(md5sum "${ARCH}.tar.gz" | cut -d ' ' -f 1)
  27. echo " checksum: ${CHECKSUM}"
  28. grep -q "${CHECKSUM}" <<< "${RELEASE_NOTES}" \
  29. || (echo "checksum mismatch" && exit 1)
  30. echo " checksum ok"
  31. echo " -> creating directory structure"
  32. mkdir -p "${DEB_TMP_DIR}"
  33. mkdir -p "${DEB_TMP_DIR}"${DESTDIR}
  34. mkdir -p "${DEB_TMP_DIR}"${DOCDIR}
  35. mkdir -p "${DEB_TMP_DIR}"${DOCDIR}/man1
  36. mkdir -p "${DEB_TMP_DIR}"${DOCDIR}/man5
  37. mkdir -p "${DEB_TMP_DIR}"/DEBIAN
  38. mkdir -p "${DEB_TMP_DIR}"/usr/share/doc/${NAME}
  39. chmod 755 -R "${DEB_TMP_DIR}"
  40. echo " -> extract executable"
  41. tar -xzf "${ARCH}.tar.gz"
  42. cp ${NAME} "${DEB_TMP_DIR}"${DESTDIR}
  43. chmod 755 "${DEB_TMP_DIR}"${DESTDIR}/${NAME}
  44. echo " -> compress man pages"
  45. gzip -cn9 target/man/eza.1 > "${DEB_TMP_DIR}"${DOCDIR}man1/eza.1.gz
  46. gzip -cn9 target/man/eza_colors.5 > "${DEB_TMP_DIR}"${DOCDIR}man5/eza_colors.5.gz
  47. gzip -cn9 target/man/eza_colors-explanation.5 > "${DEB_TMP_DIR}"${DOCDIR}man5/eza_colors-explanation.5.gz
  48. chmod 644 "${DEB_TMP_DIR}"${DOCDIR}/**/*.gz
  49. echo " -> create control file"
  50. touch "${DEB_TMP_DIR}"/DEBIAN/control
  51. cat > "${DEB_TMP_DIR}"/DEBIAN/control <<EOM
  52. Package: ${NAME}
  53. Version: ${VERSION}
  54. Section: utils
  55. Priority: optional
  56. Architecture: ${ARCH}
  57. Depends: libc6
  58. Maintainer: Sandro-Alessio Gierens <sandro@gierens.de>
  59. Description: Modern replacement for ls
  60. eza is a modern replacement for ls. It uses colours for information by
  61. default, helping you distinguish between many types of files, such as whether
  62. you are the owner, or in the owning group.
  63. .
  64. It also has extra features not present in the original ls, such as viewing the
  65. Git status for a directory, or recursing into directories with a tree view.
  66. EOM
  67. chmod 644 "${DEB_TMP_DIR}"/DEBIAN/control
  68. echo " -> copy changelog"
  69. cp CHANGELOG.md "${DEB_TMP_DIR}"/usr/share/doc/${NAME}/changelog
  70. gzip -cn9 "${DEB_TMP_DIR}"/usr/share/doc/${NAME}/changelog > "${DEB_TMP_DIR}"/usr/share/doc/${NAME}/changelog.gz
  71. rm "${DEB_TMP_DIR}"/usr/share/doc/${NAME}/changelog
  72. chmod 644 "${DEB_TMP_DIR}"/usr/share/doc/${NAME}/changelog.gz
  73. echo " -> create copyright file"
  74. touch "${DEB_TMP_DIR}"/usr/share/doc/${NAME}/copyright
  75. cat > "${DEB_TMP_DIR}"/usr/share/doc/${NAME}/copyright << EOM
  76. Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
  77. Upstream-Name: ${NAME}
  78. Upstream-Contact: Christina Sørensen <christina@cafkafk.com>
  79. Source: https://github.com/eza-community/eza/releases
  80. Files: *
  81. License: MIT
  82. Copyright: 2023 Christina Sørensen <christina@cafkafk.com>
  83. Files: debian/*
  84. License: MIT
  85. Copyright: 2023 Christina Sørensen <christina@cafkafk.com>
  86. License: MIT
  87. Permission is hereby granted, free of charge, to any person obtaining a copy
  88. of this software and associated documentation files (the "Software"), to deal
  89. in the Software without restriction, including without limitation the rights
  90. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  91. copies of the Software, and to permit persons to whom the Software is
  92. furnished to do so, subject to the following conditions:
  93. .
  94. The above copyright notice and this permission notice shall be included in all
  95. copies or substantial portions of the Software.
  96. .
  97. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  98. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  99. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  100. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  101. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  102. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  103. SOFTWARE.
  104. EOM
  105. chmod 644 "${DEB_TMP_DIR}"/usr/share/doc/${NAME}/copyright
  106. echo " -> build ${ARCH} package"
  107. dpkg-deb --build --root-owner-group "${DEB_TMP_DIR}" > /dev/null
  108. echo " -> cleanup"
  109. rm -rf "${DEB_TMP_DIR}" "${ARCH}".tar.gz ${NAME}
  110. # gierens: this does not work on my arch at the moment and
  111. # i'm verifying on the repo host anyway thus the || true
  112. echo " -> lint ${ARCH} package"
  113. lintian "${DEB_PACKAGE}" || true
  114. done