2018-02-07 06:46:05 +00:00
|
|
|
#!/usr/bin/env bash
|
2018-02-07 07:48:09 +00:00
|
|
|
root=$(cd "$(dirname "$0")/.."; pwd)
|
2018-02-07 03:05:37 +00:00
|
|
|
version=$(TZ=UTC date +v%Y%m%d)
|
2018-02-07 06:46:05 +00:00
|
|
|
cd "$root/build/release"
|
2018-02-07 03:05:37 +00:00
|
|
|
|
2018-02-07 06:46:05 +00:00
|
|
|
case $(uname -s) in
|
|
|
|
Darwin)
|
|
|
|
libclang=(lib/clang+llvm-*/lib/libclang.dylib)
|
2018-02-07 07:48:09 +00:00
|
|
|
strip_option="-x"
|
2018-02-07 03:05:37 +00:00
|
|
|
name=cquery-$version-x86_64-apple-darwin ;;
|
2018-02-07 06:46:05 +00:00
|
|
|
FreeBSD)
|
|
|
|
libclang=(lib/clang+llvm-*/lib/libclang.so.?)
|
2018-02-07 07:48:09 +00:00
|
|
|
strip_option="-s"
|
2018-02-07 06:46:05 +00:00
|
|
|
name=cquery-$version-x86_64-unknown-freebsd10 ;;
|
|
|
|
Linux)
|
|
|
|
libclang=(lib/clang+llvm-*/lib/libclang.so.?)
|
2018-02-07 07:48:09 +00:00
|
|
|
strip_option="-s"
|
2018-02-07 03:05:37 +00:00
|
|
|
name=cquery-$version-x86_64-unknown-linux-gnu ;;
|
2018-02-07 06:46:05 +00:00
|
|
|
*)
|
|
|
|
echo Unsupported >&2
|
|
|
|
exit 1 ;;
|
2018-02-07 03:05:37 +00:00
|
|
|
esac
|
|
|
|
|
|
|
|
pkg=$(mktemp -d)
|
2018-02-07 07:48:09 +00:00
|
|
|
mkdir "$pkg/$name"
|
2018-02-07 07:55:02 +00:00
|
|
|
rsync -rtLR bin "./${libclang[-1]}" ./lib/clang+llvm-*/lib/clang/*/include "$pkg/$name"
|
2018-02-07 03:05:37 +00:00
|
|
|
|
|
|
|
cd "$pkg"
|
2018-02-07 07:55:02 +00:00
|
|
|
strip "$strip_option" "$name/bin/cquery" "$name/${libclang[-1]}"
|
2018-02-07 06:46:05 +00:00
|
|
|
case $(uname -s) in
|
|
|
|
Darwin)
|
2018-02-07 08:41:59 +00:00
|
|
|
# https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/tar.1.html
|
|
|
|
# macOS's bsdtar is lack of flags to set uid/gid.
|
|
|
|
# First, we generate a list of file in mtree format.
|
2018-02-07 07:48:09 +00:00
|
|
|
tar -cf filelist --format=mtree --options="!all,time,mode,type" "$name"
|
2018-02-07 08:41:59 +00:00
|
|
|
# Then add a line "/set uid=0 gid=0" after the first line "#mtree".
|
2018-02-07 07:48:09 +00:00
|
|
|
awk '/#mtree/{print;print "/set uid=0 gid=0";next}1' filelist > newflielist
|
2018-02-07 08:41:59 +00:00
|
|
|
# Finally, use the list to generate the tarball.
|
2018-02-07 07:48:09 +00:00
|
|
|
tar -zcf "$root/build/$name.tar.gz" @newflielist ;;
|
2018-02-07 06:46:05 +00:00
|
|
|
Linux)
|
2018-02-07 07:48:09 +00:00
|
|
|
tar -Jcf "$root/build/$name.tar.xz" --owner 0 --group 0 $name ;;
|
2018-02-07 06:46:05 +00:00
|
|
|
*)
|
2018-02-07 07:48:09 +00:00
|
|
|
tar -Jcf "$root/build/$name.tar.xz" --uid 0 --gid 0 $name ;;
|
2018-02-07 06:46:05 +00:00
|
|
|
esac
|
2018-02-07 03:05:37 +00:00
|
|
|
rm -r "$pkg"
|