deb-package.sh 5.6 KB

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