Update mplayer submodule
[mplayer-build.git] / script / update
blobac9949dd42134368f4d79050848ce0d8863b6d22
1 #!/usr/bin/env python3
3 import os
4 from os import path
5 from subprocess import check_call
7 from helpers import GitWrapper, run_command
9 def main():
10     git = GitWrapper()
12     # Update from versions using a submodule name different from "libav"
13     p = None
14     if path.exists('ffmpeg-mt/.git'):
15         p = 'ffmpeg-mt'
16     else:
17         p = 'ffmpeg'
18     switch_to_libav = not path.exists('libav/.git') and p
19     if switch_to_libav:
20         if p == 'ffmpeg-mt' and path.exists('ffmpeg-mt/libswscale/.git'):
21             # Update from old version with libswscale as submodule
22             os.system('cd ffmpeg-mt && rm -rf libswscale')
23         os.rename(p, 'libav')
24         try:
25             # Rename the build dir mainly to get it cleaned up -
26             # incremental builds probably won't work due to wrong absolute
27             # paths recorded in .d files.
28             os.rename('ffmpeg_build', 'libav_build')
29         except:
30             pass
31         if path.exists('ffmpeg_options') and not path.exists('libav_options'):
32             os.rename('ffmpeg_options', 'libav_options')
33         for fname in ('ffmpeg-mt-enabled', 'ffmpeg-mt-disabled'):
34             if path.exists(fname):
35                 os.remove(fname)
36         check_call('git submodule init libav'.split())
38     config = git.get_config()
39     submodules = git.get_submodules()
40     # Update existing submodules, but don't check out new ones
41     for p in submodules:
42         if not b'submodule.'+p+b'.url' in config:
43             continue
44         if not path.exists(path.join(p, b'.git')):
45             continue
46         check_call('git submodule update'.split() + [p])
47     def cmd():
48         check_call('git submodule update --init'.split())
49     git.foreach_submodule(cmd)
51     if switch_to_libav:
52         print()
53         print("The ffmpeg-mt submodule directory has been renamed to libav.")
54         print("The contents of the submodule have already been based on")
55         print("the Libav project for some time (FFmpeg-mt was merged to it).")
56         print("The ffmpeg_options file has been renamed to libav_options.")
57         print("You should run ./clean before recompiling due to the switch.")
59 main()