README: add some information about required system packages
[mplayer-build.git] / script / export
blobe6ac62baf149ac74c36600af04cdc0e7219403b1
1 #!/usr/bin/env python
3 import os
4 from helpers import run_command
5 from optparse import OptionParser
7 def write(local_path, path, revision, outdir):
8 if os.system("(cd %s && git archive --format=tar --prefix=%s/ %s | (cd %s && tar xf -))" % (local_path, path, revision, outdir)) != 0:
9 raise OSError
11 def subrev(revision, name):
12 return run_command(("git", "ls-tree", revision, name)).split()[2]
14 def export(revision, outdir, mt):
15 os.mkdir(outdir)
16 if mt:
17 ffmpeg = "ffmpeg-mt"
18 open(outdir + '/ffmpeg-mt-enabled', 'w').close()
19 else:
20 ffmpeg = "ffmpeg"
21 open(outdir + '/ffmpeg-mt-disabled', 'w').close()
22 if os.path.exists('ffmpeg-mt-enabled'):
23 local_ffmpeg = 'ffmpeg-mt'
24 else:
25 local_ffmpeg = 'ffmpeg'
26 mplayer_rev = subrev(revision, "mplayer")
27 libass_rev = subrev(revision, "libass")
28 ffmpeg_rev = subrev(revision, ffmpeg)
29 os.chdir(local_ffmpeg)
30 swscale_rev = subrev(ffmpeg_rev, "libswscale")
31 os.chdir('..')
32 os.chdir('mplayer')
33 version = run_command('git describe --match v[0-9]* --always ' +
34 mplayer_rev).strip()
35 os.chdir('..')
36 write('.', '.', revision, outdir)
37 os.putenv('PYTHONDONTWRITEBYTECODE', '1')
38 os.system("cd %s && ./init --init-optionfiles-only" % outdir)
39 for name in 'clean disable-mt enable-mt init update'.split():
40 os.remove(outdir + '/' + name)
41 write('mplayer', "mplayer", mplayer_rev, outdir)
42 f = open(outdir + '/mplayer/snapshot_version', 'w')
43 f.write(version)
44 f.close()
45 write('libass', "libass", libass_rev, outdir)
46 write(local_ffmpeg, ffmpeg, ffmpeg_rev, outdir)
47 write(local_ffmpeg + '/libswscale', ffmpeg + '/libswscale', swscale_rev,
48 outdir)
51 def main():
52 usage = "usage: [options] revision outdir"
53 parser = OptionParser(usage=usage)
54 parser.add_option('--disable-mt', action='store_false', dest="mt",
55 help='use non-mt FFmpeg')
56 parser.set_defaults(mt=True)
57 options, args = parser.parse_args()
58 if len(args) != 2:
59 parser.error("incorrect number of arguments")
60 export(args[0], args[1], options.mt)
62 main()