deb-package.sh 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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-musl"
  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. mkdir -p "${DEB_TMP_DIR}/usr/share/bash-completion/completions/"
  40. mkdir -p "${DEB_TMP_DIR}/usr/share/fish/vendor_completions.d/"
  41. mkdir -p "${DEB_TMP_DIR}/usr/share/zsh/vendor-completions/"
  42. chmod 755 -R "${DEB_TMP_DIR}"
  43. echo " -> extract executable"
  44. tar -xzf "${ARCH}.tar.gz"
  45. cp ${NAME} "${DEB_TMP_DIR}${DESTDIR}"
  46. chmod 755 "${DEB_TMP_DIR}${DESTDIR}/${NAME}"
  47. echo " -> compress man pages"
  48. gzip -cn9 target/man/eza.1 > "${DEB_TMP_DIR}${DOCDIR}man1/eza.1.gz"
  49. gzip -cn9 target/man/eza_colors.5 > "${DEB_TMP_DIR}${DOCDIR}man5/eza_colors.5.gz"
  50. gzip -cn9 target/man/eza_colors-explanation.5 > "${DEB_TMP_DIR}${DOCDIR}man5/eza_colors-explanation.5.gz"
  51. chmod 644 "${DEB_TMP_DIR}${DOCDIR}"/**/*.gz
  52. echo " -> copy completions"
  53. cp completions/bash/eza "${DEB_TMP_DIR}/usr/share/bash-completion/completions/"
  54. cp completions/fish/eza.fish "${DEB_TMP_DIR}/usr/share/fish/vendor_completions.d/"
  55. cp completions/zsh/_eza "${DEB_TMP_DIR}/usr/share/zsh/vendor-completions/"
  56. echo " -> create control file"
  57. touch "${DEB_TMP_DIR}/DEBIAN/control"
  58. cat > "${DEB_TMP_DIR}/DEBIAN/control" <<EOM
  59. Package: ${NAME}
  60. Version: ${VERSION}
  61. Section: utils
  62. Priority: optional
  63. Architecture: ${ARCH}
  64. Depends: libc6
  65. Maintainer: Sandro-Alessio Gierens <sandro@gierens.de>
  66. Description: Modern replacement for ls
  67. eza is a modern replacement for ls. It uses colours for information by
  68. default, helping you distinguish between many types of files, such as whether
  69. you are the owner, or in the owning group.
  70. .
  71. It also has extra features not present in the original ls, such as viewing the
  72. Git status for a directory, or recursing into directories with a tree view.
  73. EOM
  74. chmod 644 "${DEB_TMP_DIR}/DEBIAN/control"
  75. echo " -> copy changelog"
  76. cp CHANGELOG.md "${DEB_TMP_DIR}/usr/share/doc/${NAME}/changelog"
  77. gzip -cn9 "${DEB_TMP_DIR}/usr/share/doc/${NAME}/changelog" > "${DEB_TMP_DIR}/usr/share/doc/${NAME}/changelog.gz"
  78. rm "${DEB_TMP_DIR}/usr/share/doc/${NAME}/changelog"
  79. chmod 644 "${DEB_TMP_DIR}/usr/share/doc/${NAME}/changelog.gz"
  80. echo " -> create copyright file"
  81. touch "${DEB_TMP_DIR}/usr/share/doc/${NAME}/copyright"
  82. cat > "${DEB_TMP_DIR}/usr/share/doc/${NAME}/copyright" << EOM
  83. Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
  84. Upstream-Name: ${NAME}
  85. Upstream-Contact: Christina Sørensen <christina@cafkafk.com>
  86. Source: https://github.com/eza-community/eza/releases
  87. Files: *
  88. License: MIT
  89. Copyright: 2023 Christina Sørensen <christina@cafkafk.com>
  90. Files: debian/*
  91. License: MIT
  92. Copyright: 2023 Christina Sørensen <christina@cafkafk.com>
  93. License: MIT
  94. Permission is hereby granted, free of charge, to any person obtaining a copy
  95. of this software and associated documentation files (the "Software"), to deal
  96. in the Software without restriction, including without limitation the rights
  97. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  98. copies of the Software, and to permit persons to whom the Software is
  99. furnished to do so, subject to the following conditions:
  100. .
  101. The above copyright notice and this permission notice shall be included in all
  102. copies or substantial portions of the Software.
  103. .
  104. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  105. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  106. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  107. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  108. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  109. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  110. SOFTWARE.
  111. EOM
  112. chmod 644 "${DEB_TMP_DIR}/usr/share/doc/${NAME}/copyright"
  113. echo " -> build ${ARCH} package"
  114. dpkg-deb --build --root-owner-group "${DEB_TMP_DIR}" > /dev/null
  115. echo " -> cleanup"
  116. rm -rf "${DEB_TMP_DIR}" "${ARCH}.tar.gz" "${NAME}"
  117. # gierens: this does not work on my arch at the moment and
  118. # i'm verifying on the repo host anyway thus the || true
  119. echo " -> lint ${ARCH} package"
  120. lintian "${DEB_PACKAGE}" || true
  121. done