blob: fa1ac5f98dcbb661d2a029548d17d0cfeb9e0cc7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
#!/usr/bin/env bash
VERSION=0.1.4
DESTDIR=~/.suckless
BUILDDIR=~/.suckless-build
die() {
echo "${@:2}"
exit $1
}
usage() {
die $1 "Usage: suckless-rebuild dmenu|dwm|slstatus|st <config.h>"
}
version() {
die $1 "suckless-build $VERSION"
}
case $1 in
dmenu|dwm|slstatus|st ) software=$1; config=$2 ;;
-V|--version ) version 0 ;;
-h|--help) usage 0 ;;
* ) usage 1 ;;
esac
if [[ ${#@} != 2 ]]; then
usage 1
fi
if [[ ! -d /usr/src/$software ]]; then
die 1 "'an9wer-$software' may not be installed."
fi
if [[ ! -f $config ]]; then
die 1 "'$config' is not a regular file."
fi
# Move last build directory
if [[ -e $BUILDDIR/$software ]]; then
temp=$(mktemp -u -d /tmp/$software.XXXXX)
mv "$BUILDDIR/$software" "$temp"
fi
mkdir -p "$BUILDDIR"
cp -r /usr/src/$software "$BUILDDIR/$software"
cp -f "$config" "$BUILDDIR/$software/config.h"
cd "$BUILDDIR/$software"
if make &> build.log && make PREFIX="$DESTDIR" install &> build.log; then
echo "Done! Recommend to add '~/.suckless/bin' to \$PATH to use new builded $software."
else
echo "Some error occurred, check '$BUILDDIR/$software/build.log' to find more."
fi
if [[ -v temp ]]; then
sed -i "1i The last build directory was moved to $temp\n" build.log
fi
# vim: set filetype=sh:
|