Skip to content
Myr

create-deb.sh

This file

Path

scripts/create-deb.sh

134 lines · 4.6 KiB · Shell

Last changed by

Merge pull request #1593 from sharkdp/deb-improvementsThayne McCombsbefore adoption9cf415c

History of this file

Take it

Merge pull request #1593 from sharkdp/deb-improvementsThayne McCombsbefore adoption9cf415c

lines 1–134why, one step back
1#!/bin/bash
2COPYRIGHT_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="fd, fd-find"17 ;;18 *)19 DPKG_BASENAME=fd20 DPKG_CONFLICTS="fd-musl, fd-find"21 ;;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"5960# Create symlinks so fdfind can be used as well:61ln -s "/usr/bin/fd" "${DPKG_DIR}/usr/bin/fdfind"62ln -s './fd.bash' "${DPKG_DIR}/usr/share/bash-completion/completions/fdfind"63ln -s './fd.fish' "${DPKG_DIR}/usr/share/fish/vendor_completions.d/fdfind.fish"64ln -s './_fd' "${DPKG_DIR}/usr/share/zsh/vendor-completions/_fdfind"6566cat > "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/copyright" <<EOF67Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/68Upstream-Name: fd69Source: ${REPO}7071Files: *72Copyright: ${MAINTAINER}73Copyright: $COPYRIGHT_YEARS ${MAINTAINER}74License: Apache-2.0 or MIT7576License: Apache-2.077 On Debian systems, the complete text of the Apache-2.0 can be found in the78 file /usr/share/common-licenses/Apache-2.0.7980License: MIT81 Permission is hereby granted, free of charge, to any82 person obtaining a copy of this software and associated83 documentation files (the "Software"), to deal in the84 Software without restriction, including without85 limitation the rights to use, copy, modify, merge,86 publish, distribute, sublicense, and/or sell copies of87 the Software, and to permit persons to whom the Software88 is furnished to do so, subject to the following89 conditions:90 .91 The above copyright notice and this permission notice92 shall be included in all copies or substantial portions93 of the Software.94 .95 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF96 ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED97 TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A98 PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT99 SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY100 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION101 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR102 IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER103 DEALINGS IN THE SOFTWARE.104EOF105 chmod 644 "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/copyright"106107 # control file108 mkdir -p "${DPKG_DIR}/DEBIAN"109 cat > "${DPKG_DIR}/DEBIAN/control" <<EOF110Package: ${DPKG_BASENAME}111Version: ${DPKG_VERSION}112Section: utils113Priority: optional114Maintainer: ${MAINTAINER}115Homepage: ${REPO}116Architecture: ${DPKG_ARCH}117Provides: fd118Conflicts: ${DPKG_CONFLICTS}119Description: simple, fast and user-friendly alternative to find120 fd is a program to find entries in your filesystem.121 It is a simple, fast and user-friendly alternative to find.122 While it does not aim to support all of finds powerful functionality, it provides123 sensible (opinionated) defaults for a majority of use cases.124EOF125126DPKG_PATH="${DPKG_STAGING}/${DPKG_NAME}"127128if [[ -n $GITHUB_OUTPUT ]]; then129 echo "DPKG_NAME=${DPKG_NAME}" >> "$GITHUB_OUTPUT"130 echo "DPKG_PATH=${DPKG_PATH}" >> "$GITHUB_OUTPUT"131fi132133# build dpkg134fakeroot dpkg-deb --build "${DPKG_DIR}" "${DPKG_PATH}"