update_versions.sh 1.46 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#!/bin/bash

# TODO: use epm from the sources

fatal()
{
    exit 1
}

TDIR=~/epm-play-versions
EDIR=~/epm-errors
LDIR=~/epm-logs
mkdir -p $TDIR/ $EDIR/ $LDIR/

rm -f $EDIR/errors.txt

EPM=$(realpath $(dirname $0)/../bin/epm)

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
install_app()
{
    local app="$1"
    local applog="$1"
    local alt="$2"
    [ -n "$alt" ] && applog="$applog.$alt"

    echo "epm play $app $alt"
    $EPM play --verbose --auto $app $alt >$EDIR/$applog 2>&1 || return

    mv -f $EDIR/$applog $LDIR/$applog

    local pkgname="$($EPM play --package-name $app $alt)"
    $EPM print version for package $pkgname > $TDIR/$pkgname 2>$EDIR/$pkgname && rm -f $EDIR/$pkgname
    [ -s $TDIR/$pkgname ] || echo "empty file $TDIR/$pkgname" >>$EDIR/errors.txt
}

install_app_alt()
{
    local app="$1"
    local productalt="$($EPM play --product-alternatives $app)"

    if [ -z "$productalt" ] ; then
        install_app $app
        return
    fi

    # оставляем дефолтный вариант в конце в системе
    for i in $productalt "" ; do
        $EPM play --remove --auto $app
        install_app $app $i
    done
}

if [ -n "$1" ] ; then
    install_app_alt "$1"
    exit
fi

58 59
# install/update all
$EPM play --list-all --short | while read app ; do
60
    install_app_alt $app </dev/null
61 62
done

63 64 65 66 67 68 69
commit_git()
{
    cd "$1" || return
    [ -d .git ] || git init
    git add *
    git commit -m "updated"
}
70

71 72 73
commit_git $TDIR
commit_git $EDIR
commit_git $LDIR
74 75 76 77 78

cd $TMP
rm -rf tmp.* rpm-tmp.*

exit 0