summarylogtreecommitdiffstats
path: root/aurbuild
blob: 084a528b11c36cc3729a0814116d63f5bc99064a (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
#!/usr/bin/env bash

if [ ! -f ~/.avr ]; then
    echo "configuration file not found:"
    echo "$ cat ~/.avr
[build]
    repositoryName=avr
    repositoryLocation=/foo/avr/x86_64
"
    exit 1
fi

function getconfig {
    git config -f ~/.avr --get "$1"
}

location="$(pwd)"

function released_version {
    name=$1

    pacman -Ss $name | grep -e "^$(getconfig build.repositoryName)/$name " | cut -d" " -f2
}

current_arch=$(uname -m)

packages=()
echo "initializing build queue"
for name in $(find . -mindepth 1 -maxdepth 1 -type d -not -name "\.*"); do
    source $(basename $name)/PKGBUILD

    package=$pkgname
    local_version="${pkgver}-${pkgrel}"
    remote_version="$(released_version $package)"

    if [ -f $package/.norelease ] || [ -f $package/.norelease.$current_arch ]; then
        echo "  disabled: $package (explicit)"
    elif [ -f $package/.forcerelease ]; then
        echo "  enabled: $package ($local_version) (explicit)"
        packages+=($package)
    elif [ "$local_version" == "$(echo -e "$local_version\n$remote_version" | sort -V | head -n1)" ]; then
        echo "  disabled: $package (local version $local_version <= remote version $remote_version)"
    elif [[ ! " ${arch[*]} " =~ " any " ]] && [[ ! " ${arch[*]} " =~ " $current_arch " ]]; then
        echo "  disabled: $package (arch not targeted in PKGBUILD: $current_arch)"
    else
        echo "  enabled: $package ($local_version)"
        packages+=($package)
    fi
done

repository_location=$(getconfig build.repositoryLocation)
failures=()
for package in ${packages[@]} ; do
    cd "$location/$package"

    makepkg $*

    if [ $? -eq 0 ]; then
        rsync -avhP *.tar.zst $repository_location
        rsync -avhP *.tar.zst.sig $repository_location
    else
        failures+=($package)
    fi
done

cd "$location"

if [ ${#failures[@]} -gt 0 ]; then
    echo "failed to build ${#failures[@]} package(s):"
    for package in ${failures[@]} ; do
        echo "  $package"
    done
    exit 1
fi