Skip to content

Instantly share code, notes, and snippets.

@nikoheikkila
Last active March 19, 2016 12:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nikoheikkila/7910586 to your computer and use it in GitHub Desktop.
Save nikoheikkila/7910586 to your computer and use it in GitHub Desktop.
Bash: Upgrade WeeChat
#!/bin/bash -eu
#
# build.sh
#
# Builds the development version WeeChat with CMake
# Place this script in the build directory of WeeChat
# @author Niko Heikkilä <yo@nikoheikkila.com>
# Paths
ROOTDIR=$HOME/weechat
TARGET=$HOME/.weechat
# Settings for Git
BRANCH="master"
REMOTE="origin"
# Amount of concurrent jobs
JOBS=2
if [[ ! -d "$ROOTDIR"/.git ]]; then
echo "-- ERROR: Not a git repository."
exit 1
else
cd "$ROOTDIR"
git fetch "$REMOTE"
UPDATES=$(git log HEAD.."$REMOTE"/"$BRANCH" --oneline)
fi
if [[ "$UPDATES" != "" ]]; then
echo "-- Updates found. Merging."
git merge "$REMOTE"/"$BRANCH"
echo "-- Building WeeChat from source files."
if [[ ! -d "$ROOTDIR"/build ]]; then
mkdir -p "$ROOTDIR"/build
fi
cd "$ROOTDIR"/build
cmake "$ROOTDIR" -DCMAKE_INSTALL_PREFIX="$TARGET"
make --jobs="$JOBS"
echo "-- Installing WeeChat to ${TARGET}"
make install
echo "-- Installation complete."
else
echo "-- No new updates. Goodbye!"
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment