summaryrefslogtreecommitdiffstats
path: root/update
blob: 7edc609b4596c2d5624bca4773f013364adb387b (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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/bin/sh
export LC_ALL=C

do_clone()
{
    set -ex
    if ! test -e "$1" ; then
        git clone "$2" "$1"
    fi
    (
        cd "$1"
        git remote set-url origin "$2"
        git fetch
        git submodule update --init
    )
}

do_clone_all()
{
    do_clone "ffmpeg"     "https://github.com/FFmpeg/FFmpeg.git"
    #do_clone "fribidi"    "http://anongit.freedesktop.org/git/fribidi/fribidi.git"
    do_clone "libass"     "https://github.com/libass/libass.git"
    do_clone "libplacebo" "https://github.com/haasn/libplacebo.git"
    do_clone "mpv"        "https://github.com/mpv-player/mpv.git"
}

do_gitmaster()
{
    set -ex
    (
        cd "$1"
        git checkout origin/master
        git remote prune origin
    )
}

versort_with_prefix()
{
	# Emulate sort -V using a known prefix. Filter out anything else.
	sed -n -e "s/^$1\([0-9]\)/\\1/p" |\
		sort -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4 |\
		sed -e "s/^/$1/"
	# GNU version of the same:
	# grep "^$2[0-9]" | sort -V
}

do_releasetag()
{
    local prefix=  # by default, don't use a prefix
    case "$1" in
        ffmpeg) prefix=n;;  # e.g. n3.3.1
        mpv|libplacebo)    prefix=v;;  # e.g. v0.26.0
    esac

    (
        cd "$1"
        version=`git tag | grep -v rc | grep -v dev | versort_with_prefix "$prefix" | tail -n 1`
        git checkout refs/tags/"$version"
    )
}

do_fixedref()
{
    (
        cd "$1"
        git checkout "$2"
    )
}

# args: $1: project name, $2: release/master/@foo [,$3: non-empty to ignore the config file]
checkout()
{
    local branch="$2"
    if [ -z "$3" ] && [ -d config/ ] && [ -f config/branch-$1 ]; then
        branch="$(cat config/branch-$1)"
    fi

    case "$branch" in
        master)  do_gitmaster $1;;
        release) do_releasetag $1;;
        @*)      do_fixedref $1 "${branch#@}";;  # everything after the '@' prefix
        *)       >&2 printf "%s\n" "Error: Don't know how to checkout '$branch'"
                 return 1
    esac
}

# fallback targets: release/master/@foo if no config file
checkout_ffmpeg=master
#checkout_fribidi=release
checkout_libass=master
checkout_libplacebo=master
checkout_mpv=master


checkout_all()
{
    set -ex
    do_clone_all
    checkout ffmpeg $checkout_ffmpeg
    #$checkout fribidi $checkout_fribidi
    checkout libass $checkout_libass
    checkout libplacebo $checkout_libplacebo
    checkout mpv $checkout_mpv
}

do_update_debian_versions()
{
  scripts/debian-update-versions $1
}

if [ x"$1" != x"--skip-selfupdate" ]; then
    (
        set -ex
        git pull --rebase
    )
    exec "$0" --skip-selfupdate "$@"
fi
shift

# allow checkout master/release without checking the config files
case "$1" in
    --master)
        checkout_ffmpeg="master -"
        #checkout_fribidi="master -"
        checkout_libass="master -"
        checkout_libplacebo="master -"
        checkout_mpv="master -"
        ;;
    --release)
        checkout_ffmpeg="release -"
        checkout_mpv="release -"
        ;;
    '')
        ;;
    *)
        echo >&2 "$0 --master"
        echo >&2 "$0 --release"
        exit 0
        ;;
esac

checkout_all

do_update_debian_versions