deb-package.sh 3.9 KB

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