build_clean.sh 1.59 KB
Newer Older
1 2 3 4 5 6 7 8
#!/bin/bash


die() {
    echo "$*" >&2
    exit 1
}

9 10 11 12 13
usage() {
    echo "USAGE: $0 [-h|--help|-?|help]"
    echo
    echo "Does all the steps from a clean working directory to an RPM of NetworkManager"
    echo
14 15 16 17 18 19 20 21 22 23 24 25
}


ORIGDIR="$(readlink -f "$PWD")"
SCRIPTDIR="$(dirname "$(readlink -f "$0")")"
GITDIR="$(cd "$SCRIPTDIR" && git rev-parse --show-toplevel || die "Could not get GITDIR")"


[[ -x "$SCRIPTDIR"/build.sh ]] || die "could not find \"$SCRIPTDIR/build.sh\""

cd "$GITDIR" || die "could not change to $GITDIR"

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
IGNORE_DIRTY=0
GIT_CLEAN=0

for A; do
    case "$A" in
        -h|--help|-\?|help)
            usage
            exit 0
            ;;
        -f|--force)
            IGNORE_DIRTY=1
            ;;
        -c|--clean)
            GIT_CLEAN=1
            ;;
        *)
            usage
            die "Unexpected argument \"$A\""
            ;;
    esac
done

if [[ $GIT_CLEAN == 1 ]]; then
    git clean -fdx :/
fi

if [[ $IGNORE_DIRTY != 1 ]]; then
    # check for a clean working directory.
    # We ignore the /contrib directory, because this is where the automation
    # scripts and the build results will be.
    if [[ "x$(git clean -ndx | grep '^Would remove contrib/.*$' -v)" != x ]]; then
        die "The working directory is not clean. Refuse to run. Try    git clean -e /contrib -dx -n"
    fi
    if [[ "x$(git status --porcelain)" != x ]]; then
        die "The working directory has local changes. Refuse to run. Try $0 --force"
    fi
62 63 64
fi

./autogen.sh --enable-gtk-doc || die "Error autogen.sh"
65

66 67 68 69 70
make -j 10 || die "Error make"

make distcheck || die "Error make distcheck"

"$SCRIPTDIR"/build.sh
71