5 from helpers import run_command
6 from optparse import OptionParser
8 def write(path, revision, outdir):
9 if os.system(b"(cd " +path +b" && git archive --format=tar --prefix=" +path +b"/ " +revision + b" | (cd " +outdir + b" && tar xf -))") != 0:
12 def subrev(revision, name):
13 return run_command(("git", "ls-tree", revision, name)).split()[2]
15 def export(revision, outdir):
17 mplayer_rev = subrev(revision, "mplayer")
18 libass_rev = subrev(revision, "libass")
19 libav_rev = subrev(revision, "libav")
21 version = run_command(b'git describe --match v[0-9]* --always ' +
24 write(b'.',revision, outdir)
25 os.putenv('PYTHONDONTWRITEBYTECODE', '1')
26 os.system(b"cd " +outdir +b" && ./init --init-optionfiles-only")
27 for name in b'clean init update'.split():
28 os.remove(outdir + b'/' + name)
29 numeric_rev = run_command(b'git rev-parse ' + revision)
30 with open(outdir + b'/wrapper_export_version', 'wb') as f:
32 write(b'mplayer', mplayer_rev, outdir)
33 with open(outdir + b'/mplayer/snapshot_version', 'wb') as f:
35 write(b'libass', libass_rev, outdir)
36 os.system(b"cd " +outdir + b"/libass && autoreconf -ivf")
37 write(b'libav', libav_rev, outdir)
41 usage = "usage: [options] revision outdir"
42 parser = OptionParser(usage=usage)
43 options, args = parser.parse_args()
45 parser.error("incorrect number of arguments")
46 export(args[0].encode('ascii'), args[1].encode(sys.getfilesystemencoding()))