2017-10-23 07:41:28 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
# Building and packaging for release
|
|
|
|
|
|
|
|
set -ex
|
|
|
|
|
|
|
|
build() {
|
|
|
|
cargo build --target "$TARGET" --release --verbose
|
|
|
|
}
|
|
|
|
|
|
|
|
pack() {
|
|
|
|
local tempdir
|
|
|
|
local out_dir
|
|
|
|
local package_name
|
2018-08-19 15:30:59 +02:00
|
|
|
local gcc_prefix
|
2017-10-23 07:41:28 +02:00
|
|
|
|
|
|
|
tempdir=$(mktemp -d 2>/dev/null || mktemp -d -t tmp)
|
|
|
|
out_dir=$(pwd)
|
|
|
|
package_name="$PROJECT_NAME-$TRAVIS_TAG-$TARGET"
|
|
|
|
|
2018-08-19 15:30:59 +02:00
|
|
|
if [[ $TARGET == "arm-unknown-linux-gnueabihf" ]]; then
|
|
|
|
gcc_prefix="arm-linux-gnueabihf-"
|
|
|
|
else
|
|
|
|
gcc_prefix=""
|
|
|
|
fi
|
|
|
|
|
2017-10-23 07:41:28 +02:00
|
|
|
# create a "staging" directory
|
|
|
|
mkdir "$tempdir/$package_name"
|
|
|
|
mkdir "$tempdir/$package_name/autocomplete"
|
|
|
|
|
|
|
|
# copying the main binary
|
|
|
|
cp "target/$TARGET/release/$PROJECT_NAME" "$tempdir/$package_name/"
|
2018-08-19 15:30:59 +02:00
|
|
|
"${gcc_prefix}"strip "$tempdir/$package_name/$PROJECT_NAME"
|
2017-10-23 07:41:28 +02:00
|
|
|
|
|
|
|
# manpage, readme and license
|
|
|
|
cp "doc/$PROJECT_NAME.1" "$tempdir/$package_name"
|
|
|
|
cp README.md "$tempdir/$package_name"
|
|
|
|
cp LICENSE-MIT "$tempdir/$package_name"
|
|
|
|
cp LICENSE-APACHE "$tempdir/$package_name"
|
|
|
|
|
|
|
|
# various autocomplete
|
2017-12-10 08:01:32 +01:00
|
|
|
cp target/"$TARGET"/release/build/"$PROJECT_NAME"-*/out/"$PROJECT_NAME".bash "$tempdir/$package_name/autocomplete/${PROJECT_NAME}.bash-completion"
|
2017-10-23 07:41:28 +02:00
|
|
|
cp target/"$TARGET"/release/build/"$PROJECT_NAME"-*/out/"$PROJECT_NAME".fish "$tempdir/$package_name/autocomplete"
|
|
|
|
cp target/"$TARGET"/release/build/"$PROJECT_NAME"-*/out/_"$PROJECT_NAME" "$tempdir/$package_name/autocomplete"
|
|
|
|
|
|
|
|
# archiving
|
|
|
|
pushd "$tempdir"
|
|
|
|
tar czf "$out_dir/$package_name.tar.gz" "$package_name"/*
|
|
|
|
popd
|
|
|
|
rm -r "$tempdir"
|
|
|
|
}
|
|
|
|
|
2017-12-04 08:47:35 +01:00
|
|
|
make_deb() {
|
|
|
|
local tempdir
|
|
|
|
local architecture
|
|
|
|
local version
|
|
|
|
local dpkgname
|
|
|
|
local conflictname
|
|
|
|
|
|
|
|
case $TARGET in
|
|
|
|
x86_64*)
|
|
|
|
architecture=amd64
|
|
|
|
;;
|
|
|
|
i686*)
|
|
|
|
architecture=i386
|
|
|
|
;;
|
|
|
|
*)
|
2018-08-19 15:30:59 +02:00
|
|
|
echo "make_deb: skipping target '${TARGET}'" >&2
|
|
|
|
return 0
|
2017-12-04 08:47:35 +01:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
version=${TRAVIS_TAG#v}
|
|
|
|
if [[ $TARGET = *musl* ]]; then
|
2017-12-05 09:42:53 +01:00
|
|
|
dpkgname=$PROJECT_NAME-musl
|
|
|
|
conflictname=$PROJECT_NAME
|
2017-12-04 08:47:35 +01:00
|
|
|
else
|
2017-12-05 09:42:53 +01:00
|
|
|
dpkgname=$PROJECT_NAME
|
|
|
|
conflictname=$PROJECT_NAME-musl
|
2017-12-04 08:47:35 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
tempdir=$(mktemp -d 2>/dev/null || mktemp -d -t tmp)
|
|
|
|
|
|
|
|
# copy the main binary
|
2017-12-05 09:42:53 +01:00
|
|
|
install -Dm755 "target/$TARGET/release/$PROJECT_NAME" "$tempdir/usr/bin/$PROJECT_NAME"
|
2017-12-04 08:47:35 +01:00
|
|
|
strip "$tempdir/usr/bin/$PROJECT_NAME"
|
|
|
|
|
|
|
|
# manpage
|
|
|
|
install -Dm644 "doc/$PROJECT_NAME.1" "$tempdir/usr/share/man/man1/$PROJECT_NAME.1"
|
2018-01-04 19:48:59 +01:00
|
|
|
gzip --best "$tempdir/usr/share/man/man1/$PROJECT_NAME.1"
|
2017-12-04 08:47:35 +01:00
|
|
|
|
|
|
|
# readme and license
|
2017-12-05 09:42:53 +01:00
|
|
|
install -Dm644 README.md "$tempdir/usr/share/doc/$PROJECT_NAME/README.md"
|
|
|
|
install -Dm644 LICENSE-MIT "$tempdir/usr/share/doc/$PROJECT_NAME/LICENSE-MIT"
|
|
|
|
install -Dm644 LICENSE-APACHE "$tempdir/usr/share/doc/$PROJECT_NAME/LICENSE-APACHE"
|
2017-12-04 08:47:35 +01:00
|
|
|
|
|
|
|
# completions
|
2018-01-02 21:47:45 +01:00
|
|
|
install -Dm644 target/$TARGET/release/build/$PROJECT_NAME-*/out/$PROJECT_NAME.bash "$tempdir/usr/share/bash-completion/completions/${PROJECT_NAME}"
|
|
|
|
install -Dm644 target/$TARGET/release/build/$PROJECT_NAME-*/out/$PROJECT_NAME.fish "$tempdir/usr/share/fish/completions/$PROJECT_NAME.fish"
|
|
|
|
install -Dm644 target/$TARGET/release/build/$PROJECT_NAME-*/out/_$PROJECT_NAME "$tempdir/usr/share/zsh/vendor-completions/_$PROJECT_NAME"
|
2017-12-04 08:47:35 +01:00
|
|
|
|
|
|
|
# Control file
|
|
|
|
mkdir "$tempdir/DEBIAN"
|
|
|
|
cat > "$tempdir/DEBIAN/control" <<EOF
|
|
|
|
Package: $dpkgname
|
|
|
|
Version: $version
|
|
|
|
Section: utils
|
|
|
|
Priority: optional
|
2018-01-04 19:48:59 +01:00
|
|
|
Maintainer: David Peter <mail@david-peter.de>
|
2017-12-04 08:47:35 +01:00
|
|
|
Architecture: $architecture
|
2017-12-05 09:42:53 +01:00
|
|
|
Provides: $PROJECT_NAME
|
2017-12-04 08:47:35 +01:00
|
|
|
Conflicts: $conflictname
|
|
|
|
Description: Simple, fast and user-friendly alternative to find
|
2018-01-04 19:48:59 +01:00
|
|
|
While fd does not seek to mirror all of find's powerful functionality, it
|
|
|
|
provides sensible (opinionated) defaults for 80% of the use cases.
|
2017-12-04 08:47:35 +01:00
|
|
|
EOF
|
|
|
|
|
2018-01-04 19:48:59 +01:00
|
|
|
fakeroot dpkg-deb --build "$tempdir" "${dpkgname}_${version}_${architecture}.deb"
|
2017-12-04 08:47:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-10-23 07:41:28 +02:00
|
|
|
main() {
|
|
|
|
build
|
|
|
|
pack
|
2017-12-04 08:47:35 +01:00
|
|
|
if [[ $TARGET = *linux* ]]; then
|
|
|
|
make_deb
|
|
|
|
fi
|
2017-10-23 07:41:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
main
|