Skip to content
Myr

Refactor creating deb package into separate script

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Which I think is cleaner than having it inline in the github actions yaml

authored by Thayne McCombs · committed by Thayne McCombs · parent 9f0fea6 · Browse files · 2 files+133 added−107 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+133 added−107 removed

  • other:+133 added−107 removed

2 files+133 added−107 removed

modified:.github/workflows/CICD.yml+5 added-107 removed
214 unmodified lines
215 - name: Create Debian package216 id: debian-package217 shell: bash218 if: startsWith(matrix.job.os, 'ubuntu')219 run: |220 COPYRIGHT_YEARS="2018 - "$(date "+%Y")221 DPKG_STAGING="${{ env.CICD_INTERMEDIATES_DIR }}/debian-package"222 DPKG_DIR="${DPKG_STAGING}/dpkg"223 mkdir -p "${DPKG_DIR}"219 run: bash scripts/create-deb.sh220 env:221 TARGET: ${{ matrix.job.target }}222 DPKG_VERSION: ${{ needs.crate_metadata.version }}223 BIN_PATH: ${{ steps.bin.outputs.BIN_PATH }}224225 DPKG_BASENAME=${{ needs.crate_metadata.outputs.name }}226 DPKG_CONFLICTS=${{ needs.crate_metadata.outputs.name }}-musl227 case ${{ matrix.job.target }} in *-musl*) DPKG_BASENAME=${{ needs.crate_metadata.outputs.name }}-musl ; DPKG_CONFLICTS=${{ needs.crate_metadata.outputs.name }} ;; esac;228 DPKG_VERSION=${{ needs.crate_metadata.outputs.version }}229230 unset DPKG_ARCH231 case ${{ matrix.job.target }} in232 aarch64-*-linux-*) DPKG_ARCH=arm64 ;;233 arm-*-linux-*hf) DPKG_ARCH=armhf ;;234 i686-*-linux-*) DPKG_ARCH=i686 ;;235 x86_64-*-linux-*) DPKG_ARCH=amd64 ;;236 *) DPKG_ARCH=notset ;;237 esac;238239 DPKG_NAME="${DPKG_BASENAME}_${DPKG_VERSION}_${DPKG_ARCH}.deb"240 echo "DPKG_NAME=${DPKG_NAME}" >> $GITHUB_OUTPUT241242 # Binary243 install -Dm755 "${{ steps.bin.outputs.BIN_PATH }}" "${DPKG_DIR}/usr/bin/${{ steps.bin.outputs.BIN_NAME }}"244245 # Man page246 install -Dm644 'doc/${{ needs.crate_metadata.outputs.name }}.1' "${DPKG_DIR}/usr/share/man/man1/${{ needs.crate_metadata.outputs.name }}.1"247 gzip -n --best "${DPKG_DIR}/usr/share/man/man1/${{ needs.crate_metadata.outputs.name }}.1"248249 # Autocompletion files250 install -Dm644 'autocomplete/fd.bash' "${DPKG_DIR}/usr/share/bash-completion/completions/${{ needs.crate_metadata.outputs.name }}"251 install -Dm644 'autocomplete/fd.fish' "${DPKG_DIR}/usr/share/fish/vendor_completions.d/${{ needs.crate_metadata.outputs.name }}.fish"252 install -Dm644 'autocomplete/_fd' "${DPKG_DIR}/usr/share/zsh/vendor-completions/_${{ needs.crate_metadata.outputs.name }}"253254 # README and LICENSE255 install -Dm644 "README.md" "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/README.md"256 install -Dm644 "LICENSE-MIT" "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/LICENSE-MIT"257 install -Dm644 "LICENSE-APACHE" "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/LICENSE-APACHE"258 install -Dm644 "CHANGELOG.md" "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/changelog"259 gzip -n --best "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/changelog"260261 cat > "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/copyright" <<EOF262 Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/263 Upstream-Name: ${{ needs.crate_metadata.outputs.name }}264 Source: ${{ needs.crate_metadata.outputs.homepage }}265266 Files: *267 Copyright: ${{ needs.crate_metadata.outputs.maintainer }}268 Copyright: $COPYRIGHT_YEARS ${{ needs.crate_metadata.outputs.maintainer }}269 License: Apache-2.0 or MIT270271 License: Apache-2.0272 On Debian systems, the complete text of the Apache-2.0 can be found in the273 file /usr/share/common-licenses/Apache-2.0.274275 License: MIT276 Permission is hereby granted, free of charge, to any277 person obtaining a copy of this software and associated278 documentation files (the "Software"), to deal in the279 Software without restriction, including without280 limitation the rights to use, copy, modify, merge,281 publish, distribute, sublicense, and/or sell copies of282 the Software, and to permit persons to whom the Software283 is furnished to do so, subject to the following284 conditions:285 .286 The above copyright notice and this permission notice287 shall be included in all copies or substantial portions288 of the Software.289 .290 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF291 ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED292 TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A293 PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT294 SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY295 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION296 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR297 IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER298 DEALINGS IN THE SOFTWARE.299 EOF300 chmod 644 "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/copyright"301302 # control file303 mkdir -p "${DPKG_DIR}/DEBIAN"304 cat > "${DPKG_DIR}/DEBIAN/control" <<EOF305 Package: ${DPKG_BASENAME}306 Version: ${DPKG_VERSION}307 Section: utils308 Priority: optional309 Maintainer: ${{ needs.crate_metadata.outputs.maintainer }}310 Homepage: ${{ needs.crate_metadata.outputs.homepage }}311 Architecture: ${DPKG_ARCH}312 Provides: ${{ needs.crate_metadata.outputs.name }}313 Conflicts: ${DPKG_CONFLICTS}314 Description: simple, fast and user-friendly alternative to find315 fd is a program to find entries in your filesystem.316 It is a simple, fast and user-friendly alternative to find.317 While it does not aim to support all of finds powerful functionality, it provides318 sensible (opinionated) defaults for a majority of use cases.319 EOF320321 DPKG_PATH="${DPKG_STAGING}/${DPKG_NAME}"322 echo "DPKG_PATH=${DPKG_PATH}" >> $GITHUB_OUTPUT323324 # build dpkg325 fakeroot dpkg-deb --build "${DPKG_DIR}" "${DPKG_PATH}"326225 - name: "Artifact upload: tarball"226 uses: actions/upload-artifact@master227 with:228 name: ${{ steps.package.outputs.PKG_NAME }}
37 unmodified lines
added:scripts/create-deb.sh+128 added
1#!/bin/bash2COPYRIGHT_YEARS="2018 - "$(date "+%Y")3MAINTAINER="David Peter <mail@david-peter.de>"4REPO="https://github.com/sharkdp/fd"5DPKG_STAGING="${CICD_INTERMEDIATES_DIR:-.}/debian-package"6DPKG_DIR="${DPKG_STAGING}/dpkg"7mkdir -p "${DPKG_DIR}"89if [[ -z "$TARGET" ]]; then10 TARGET="$(rustc -vV | sed -n 's|host: \(.*\)|\1|p')"11fi1213case "$TARGET" in14 *-musl*)15 DPKG_BASENAME=fd-musl16 DPKG_CONFLICTS=fd17 ;;18 *)19 DPKG_BASENAME=fd20 DPKG_CONFLICTS=fd-musl21 ;;22esac2324if [[ -z "$DPKG_VERSION" ]]; then25 DPKG_VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r .packages[0].version)26fi2728unset DPKG_ARCH29case "${TARGET}" in30 aarch64-*-linux-*) DPKG_ARCH=arm64 ;;31 arm-*-linux-*hf) DPKG_ARCH=armhf ;;32 i686-*-linux-*) DPKG_ARCH=i686 ;;33 x86_64-*-linux-*) DPKG_ARCH=amd64 ;;34 *) DPKG_ARCH=notset ;;35esac;3637DPKG_NAME="${DPKG_BASENAME}_${DPKG_VERSION}_${DPKG_ARCH}.deb"3839BIN_PATH=${BIN_PATH:-target/${TARGET}/release/fd}4041# Binary42install -Dm755 "${BIN_PATH}" "${DPKG_DIR}/usr/bin/fd"4344# Man page45install -Dm644 'doc/fd.1' "${DPKG_DIR}/usr/share/man/man1/fd.1"46gzip -n --best "${DPKG_DIR}/usr/share/man/man1/fd.1"4748# Autocompletion files49install -Dm644 'autocomplete/fd.bash' "${DPKG_DIR}/usr/share/bash-completion/completions/fd"50install -Dm644 'autocomplete/fd.fish' "${DPKG_DIR}/usr/share/fish/vendor_completions.d/fd.fish"51install -Dm644 'autocomplete/_fd' "${DPKG_DIR}/usr/share/zsh/vendor-completions/_fd"5253# README and LICENSE54install -Dm644 "README.md" "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/README.md"55install -Dm644 "LICENSE-MIT" "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/LICENSE-MIT"56install -Dm644 "LICENSE-APACHE" "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/LICENSE-APACHE"57install -Dm644 "CHANGELOG.md" "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/changelog"58gzip -n --best "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/changelog"5960cat > "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/copyright" <<EOF61Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/62Upstream-Name: fd63Source: ${REPO}6465Files: *66Copyright: ${MAINTAINER}67Copyright: $COPYRIGHT_YEARS ${MAINTAINER}68License: Apache-2.0 or MIT6970License: Apache-2.071 On Debian systems, the complete text of the Apache-2.0 can be found in the72 file /usr/share/common-licenses/Apache-2.0.7374License: MIT75 Permission is hereby granted, free of charge, to any76 person obtaining a copy of this software and associated77 documentation files (the "Software"), to deal in the78 Software without restriction, including without79 limitation the rights to use, copy, modify, merge,80 publish, distribute, sublicense, and/or sell copies of81 the Software, and to permit persons to whom the Software82 is furnished to do so, subject to the following83 conditions:84 .85 The above copyright notice and this permission notice86 shall be included in all copies or substantial portions87 of the Software.88 .89 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF90 ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED91 TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A92 PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT93 SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY94 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION95 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR96 IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER97 DEALINGS IN THE SOFTWARE.98EOF99 chmod 644 "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/copyright"100101 # control file102 mkdir -p "${DPKG_DIR}/DEBIAN"103 cat > "${DPKG_DIR}/DEBIAN/control" <<EOF104Package: ${DPKG_BASENAME}105Version: ${DPKG_VERSION}106Section: utils107Priority: optional108Maintainer: ${MAINTAINER}109Homepage: ${REPO}110Architecture: ${DPKG_ARCH}111Provides: fd112Conflicts: ${DPKG_CONFLICTS}113Description: simple, fast and user-friendly alternative to find114 fd is a program to find entries in your filesystem.115 It is a simple, fast and user-friendly alternative to find.116 While it does not aim to support all of finds powerful functionality, it provides117 sensible (opinionated) defaults for a majority of use cases.118EOF119120DPKG_PATH="${DPKG_STAGING}/${DPKG_NAME}"121122if [[ -n $GITHUB_OUTPUT ]]; then123 echo "DPKG_NAME=${DPKG_NAME}" >> "$GITHUB_OUTPUT"124 echo "DPKG_PATH=${DPKG_PATH}" >> "$GITHUB_OUTPUT"125fi126127# build dpkg128fakeroot dpkg-deb --build "${DPKG_DIR}" "${DPKG_PATH}"