aboutsummarylogtreecommitdiffstats
path: root/build.sh
blob: 5fa7e7f4e361ff5edabd833ff5b0ebee7ca64c32 (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/sh

set -euo pipefail

clean() {
    rm -f ./sigi-*.tar.gz ./sigi-*.tar.zst
    rm -rf ./pkg ./src
}

install() {
    # Assumes you are on Arch, btw.
    if ! makepkg
    then
        sha256sum ./sigi-*.tar.gz
        exit 1
    fi
    makepkg --printsrcinfo > .SRCINFO
}

check() {
    pkgdir="./pkg/sigi"
    if [ ! -x "$pkgdir/usr/bin/sigi" ]
    then
        >&2 echo "Sigi binary was not installed and executable"
        exit 1
    elif [ ! -f "$pkgdir/usr/share/man/man1/sigi.1.gz" ]
    then
        >&2 echo "Sigi man page was not installed"
        exit 1
    fi

    "$pkgdir"/usr/bin/sigi --version
}

push() {
    git push

    local branch="packaging/arch-aur"
    git branch -d $branch || true
    git checkout -b $branch
    git push mirror $branch
    git checkout master
    git branch -d $branch
}

bootstrap() {
    pacman -S git base-devel cargo
}

help() {
    echo "Usage: $0 [bootstrap|clean|install|check]..."
}

run() {
    case "$1" in
        bootstrap) bootstrap ;;
        clean)     clean     ;;
        install)   install   ;;
        check)     check     ;;
        push)      push      ;;
        *)         >&2 help
                   >&2 echo "Unknown target: $1"
                   exit 1 ;;
    esac
}

# Exit with help message if no input.
if [ "$*unset" = unset ]
then
    help && exit
fi

set -x

# Handle all args as run commands.
for cmd in "$@"
do
    run "$cmd"
done

# vim: set expandtab ts=4 sw=4