1
0

deb-package.sh 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. #!/bin/bash
  2. if [ -z "$1" ]
  3. then
  4. echo "Usage: deb-package.sh <version>"
  5. echo ""
  6. echo "Package the given version number into a .deb package."
  7. echo "Example: deb-package.sh 0.10.7"
  8. exit 1
  9. fi
  10. DESTDIR=/usr/bin
  11. DOCDIR=/usr/share/man/
  12. NAME="eza"
  13. VERSION=$1
  14. ARCH="amd64"
  15. DEB_TMP_DIR="${NAME}_${VERSION}_${ARCH}"
  16. DEB_PACKAGE="${NAME}_${VERSION}_${ARCH}.deb"
  17. cargo build --release --features vendored-libgit2
  18. just man
  19. read -r -d '' DEB_CONTROL << EOM
  20. Package: ${NAME}
  21. Version: ${VERSION}
  22. Section: utils
  23. Priority: optional
  24. Architecture: ${ARCH}
  25. Depends: libc6
  26. Maintainer: Sandro-Alessio Gierens <sandro@gierens.de>
  27. Description: Modern replacement for ls
  28. eza is a modern replacement for ls. It uses colours for information by
  29. default, helping you distinguish between many types of files, such as whether
  30. you are the owner, or in the owning group.
  31. .
  32. It also has extra features not present in the original ls, such as viewing the
  33. Git status for a directory, or recursing into directories with a tree view.
  34. EOM
  35. read -r -d '' DEB_COPYRIGHT << EOM
  36. Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
  37. Upstream-Name: ${NAME}
  38. Upstream-Contact: Christina Sørensen <christina@cafkafk.com>
  39. Source: https://github.com/eza-community/eza/releases
  40. Files: *
  41. License: MIT
  42. Copyright: 2023 Christina Sørensen <christina@cafkafk.com>
  43. Files: debian/*
  44. License: MIT
  45. Copyright: 2023 Christina Sørensen <christina@cafkafk.com>
  46. License: MIT
  47. Permission is hereby granted, free of charge, to any person obtaining a copy
  48. of this software and associated documentation files (the "Software"), to deal
  49. in the Software without restriction, including without limitation the rights
  50. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  51. copies of the Software, and to permit persons to whom the Software is
  52. furnished to do so, subject to the following conditions:
  53. .
  54. The above copyright notice and this permission notice shall be included in all
  55. copies or substantial portions of the Software.
  56. .
  57. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  58. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  59. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  60. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  61. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  62. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  63. SOFTWARE.
  64. EOM
  65. # create temporary build directory
  66. mkdir -p ${DEB_TMP_DIR}
  67. # create directory structure
  68. mkdir -p ${DEB_TMP_DIR}${DESTDIR}
  69. mkdir -p ${DEB_TMP_DIR}${DOCDIR}
  70. mkdir -p ${DEB_TMP_DIR}${DOCDIR}/man1
  71. mkdir -p ${DEB_TMP_DIR}${DOCDIR}/man5
  72. mkdir -p ${DEB_TMP_DIR}/DEBIAN
  73. mkdir -p ${DEB_TMP_DIR}/usr/share/doc/${NAME}
  74. # fix directory permissions
  75. chmod 755 -R ${DEB_TMP_DIR}
  76. # binary
  77. cp target/release/${NAME} ${DEB_TMP_DIR}${DESTDIR}
  78. chmod 755 ${DEB_TMP_DIR}${DESTDIR}/${NAME}
  79. # man page
  80. gzip -cn9 target/man/eza.1 > ${DEB_TMP_DIR}${DOCDIR}man1/eza.1.gz
  81. gzip -cn9 target/man/eza_colors.5 > ${DEB_TMP_DIR}${DOCDIR}man5/eza_colors.5.gz
  82. gzip -cn9 target/man/eza_colors-explanation.5 > ${DEB_TMP_DIR}${DOCDIR}man5/eza_colors-explanation.5.gz
  83. chmod 644 ${DEB_TMP_DIR}${DOCDIR}/**/*.gz
  84. # control file
  85. touch ${DEB_TMP_DIR}/DEBIAN/control
  86. echo "${DEB_CONTROL}" > ${DEB_TMP_DIR}/DEBIAN/control
  87. chmod 644 ${DEB_TMP_DIR}/DEBIAN/control
  88. # changelog
  89. cp CHANGELOG.md ${DEB_TMP_DIR}/usr/share/doc/${NAME}/changelog
  90. gzip -cn9 ${DEB_TMP_DIR}/usr/share/doc/${NAME}/changelog > ${DEB_TMP_DIR}/usr/share/doc/${NAME}/changelog.gz
  91. rm ${DEB_TMP_DIR}/usr/share/doc/${NAME}/changelog
  92. chmod 644 ${DEB_TMP_DIR}/usr/share/doc/${NAME}/changelog.gz
  93. # copyright file
  94. touch ${DEB_TMP_DIR}/usr/share/doc/${NAME}/copyright
  95. echo "${DEB_COPYRIGHT}" > ${DEB_TMP_DIR}/usr/share/doc/${NAME}/copyright
  96. chmod 644 ${DEB_TMP_DIR}/usr/share/doc/${NAME}/copyright
  97. # build package
  98. dpkg-deb --build --root-owner-group ${DEB_TMP_DIR}
  99. # clean up
  100. rm -rf ${DEB_TMP_DIR}
  101. # test package
  102. lintian ${DEB_PACKAGE}