diff options
author | an9wer | 2020-05-18 17:12:43 +0800 |
---|---|---|
committer | an9wer | 2020-05-18 17:12:43 +0800 |
commit | 153723269029a0704e22a391127ed814a5b6d526 (patch) | |
tree | 139e5f7ceae70e8403082aa5e2af833a38a03467 /suckless-rebuild | |
download | aur-153723269029a0704e22a391127ed814a5b6d526.tar.gz |
[0.1.0-1] Add rebuild for st
Diffstat (limited to 'suckless-rebuild')
-rwxr-xr-x | suckless-rebuild | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/suckless-rebuild b/suckless-rebuild new file mode 100755 index 000000000000..213a9a743aeb --- /dev/null +++ b/suckless-rebuild @@ -0,0 +1,51 @@ +#!/usr/bin/env bash + +DESTDIR=~/.suckless +BUILDDIR=~/.suckless-build + +usage() { + echo "Usage: suckless-rebuild st <config.h>" + exit 1 +} + +if [[ ${#@} != 2 || $1 =~ ^-h$|^--help$ || $2 =~ ^-h$|^--help$ ]]; then + echo "Usage: suckless-rebuild st <config.h>" + exit 1 +fi + +tool=$1 +config=$2 + +if [[ ! $tool =~ ^st$ ]]; then + echo "Unknown suckless tool '$tool'." + exit 1 +fi +if [[ ! -d /usr/src/$tool ]]; then + echo "'an9wer-$tool' may not be installed." + exit 1 +fi +if [[ ! -f $config ]]; then + echo "'$config' is not a regular file." + exit 1 +fi + +if [[ -e $BUILDDIR/$tool ]]; then + temp=$(mktemp -u -d /tmp/$tool.XXXXX) + mv "$BUILDDIR/$tool" "$temp" +fi + +mkdir -p "$BUILDDIR" +cp -r /usr/src/st "$BUILDDIR/$tool" +cp -f "$config" "$BUILDDIR/$tool" + +cd "$BUILDDIR/$tool" +if make &> build.log && make PREFIX="$DESTDIR" install &> build.log; then + echo "Done! Recommend to add '~/.suckless/bin' to \$PATH to use new builded st." +else + echo "Some error occurred, check '$BUILDDIR/$tool/build.log' to find more." +fi +if [[ -v temp ]]; then + sed -i "1i The last built directory was moved to $temp\n" build.log +fi + +# vim: set filetype=sh: |