#!/bin/bash COPYRIGHT_YEARS="2018 - "$(date "+%Y") MAINTAINER="David Peter " REPO="https://github.com/sharkdp/fd" DPKG_STAGING="${CICD_INTERMEDIATES_DIR:-.}/debian-package" DPKG_DIR="${DPKG_STAGING}/dpkg" mkdir -p "${DPKG_DIR}" if [[ -z "$TARGET" ]]; then TARGET="$(rustc -vV | sed -n 's|host: \(.*\)|\1|p')" fi case "$TARGET" in *-musl*) DPKG_BASENAME=fd-musl DPKG_CONFLICTS="fd, fd-find" ;; *) DPKG_BASENAME=fd DPKG_CONFLICTS="fd-musl, fd-find" ;; esac if [[ -z "$DPKG_VERSION" ]]; then DPKG_VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r .packages[0].version) fi unset DPKG_ARCH case "${TARGET}" in aarch64-*-linux-*) DPKG_ARCH=arm64 ;; arm-*-linux-*hf) DPKG_ARCH=armhf ;; i686-*-linux-*) DPKG_ARCH=i686 ;; x86_64-*-linux-*) DPKG_ARCH=amd64 ;; *) DPKG_ARCH=notset ;; esac; DPKG_NAME="${DPKG_BASENAME}_${DPKG_VERSION}_${DPKG_ARCH}.deb" BIN_PATH=${BIN_PATH:-target/${TARGET}/release/fd} # Binary install -Dm755 "${BIN_PATH}" "${DPKG_DIR}/usr/bin/fd" # Man page install -Dm644 'doc/fd.1' "${DPKG_DIR}/usr/share/man/man1/fd.1" gzip -n --best "${DPKG_DIR}/usr/share/man/man1/fd.1" # Autocompletion files install -Dm644 'autocomplete/fd.bash' "${DPKG_DIR}/usr/share/bash-completion/completions/fd" install -Dm644 'autocomplete/fd.fish' "${DPKG_DIR}/usr/share/fish/vendor_completions.d/fd.fish" install -Dm644 'autocomplete/_fd' "${DPKG_DIR}/usr/share/zsh/vendor-completions/_fd" # README and LICENSE install -Dm644 "README.md" "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/README.md" install -Dm644 "LICENSE-MIT" "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/LICENSE-MIT" install -Dm644 "LICENSE-APACHE" "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/LICENSE-APACHE" install -Dm644 "CHANGELOG.md" "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/changelog" gzip -n --best "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/changelog" # Create symlinks so fdfind can be used as well: ln -s "/usr/bin/fd" "${DPKG_DIR}/usr/bin/fdfind" ln -s './fd.bash' "${DPKG_DIR}/usr/share/bash-completion/completions/fdfind" ln -s './fd.fish' "${DPKG_DIR}/usr/share/fish/vendor_completions.d/fdfind.fish" ln -s './_fd' "${DPKG_DIR}/usr/share/zsh/vendor-completions/_fdfind" cat > "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/copyright" < "${DPKG_DIR}/DEBIAN/control" <> "$GITHUB_OUTPUT" echo "DPKG_PATH=${DPKG_PATH}" >> "$GITHUB_OUTPUT" fi # build dpkg fakeroot dpkg-deb --build "${DPKG_DIR}" "${DPKG_PATH}"