File: get-gtk-files.py

package info (click to toggle)
solfege 3.16.4-2
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 34,472 kB
  • ctags: 5,287
  • sloc: python: 22,642; xml: 14,196; ansic: 4,682; makefile: 621; sh: 287
file content (96 lines) | stat: -rw-r--r-- 3,571 bytes parent folder | download
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
#!/usr/bin/python
import sys
import urllib
import os
import zipfile
import glob
cachedir = "../pkg-cache"
srcdir = "../src-cache"


def gnome_bin_url(app, ver):
    short_ver = "%s.%s" % (ver.split(".")[0], ver.split(".")[1])
    return "http://ftp.gnome.org/pub/gnome/binaries/win32/%(app)s/%(short_ver)s/%(app)s_%(ver)s_win32.zip" % locals()

def gnome_src_url(app, ver):
    short_ver = "%s.%s" % (ver.split(".")[0], ver.split(".")[1])
    ver = ver.split("-")[0]
    return"http://ftp.gnome.org/pub/gnome/sources/%(app)s/%(short_ver)s/%(app)s-%(ver)s.tar.bz2" % locals()

urls = {}
for app, ver in (("glib", "2.22.3-1"),
     ("gtk+", "2.18.5-1"),
     ("pango", "1.26.1-1"),
     ("atk", "1.28.0-1")):
    urls[app] = {'bin': gnome_bin_url(app, ver),
                 'src': gnome_src_url(app, ver)}
urls['cairo'] = {
    'bin': "http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/cairo_1.8.8-3_win32.zip",
    'src': "http://cairographics.org/releases/cairo-1.8.8.tar.gz"}
urls['zlib'] = {
    'bin': "http://www.zlib.net/zlib124-dll.zip",
    'src': "http://www.zlib.net/zlib-1.2.4.tar.gz",
}
urls['fontconfig'] = {
    'bin': "http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/fontconfig_2.8.0-1_win32.zip",
    'src': "http://www.fontconfig.org/release/fontconfig-2.8.0.tar.gz",
}
urls['freetype'] = {
    'bin': "http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/freetype_2.3.11-1_win32.zip",
    'src': "http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/freetype-2.3.9.tar.bz2",
}
urls['expat'] = {
    'bin': "http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/expat_2.0.1-1_win32.zip",
    'src': "http://downloads.sourceforge.net/project/expat/expat/2.0.1/expat-2.0.1.tar.gz",
}
urls['gettext-runtime'] = {
  'bin': "http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/gettext-runtime-0.17-1.zip",
  'src': "http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/gettext-0.17.tar.gz"}
urls['libpng'] = {
    'bin': "http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/libpng_1.2.39-1_win32.zip",
    'src': "http://download.sourceforge.net/libpng/libpng-1.2.39.tar.gz"
}
urls['libtiff'] = {
    'bin': "http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/libtiff-3.8.2.zip",
    'src': "ftp://ftp.remotesensing.org/pub/libtiff/tiff-3.9.1.tar.gz"
}


def get_files(key, savedir):
    if not os.path.exists(savedir):
        os.mkdir(savedir)
    for app in urls:
        if key not in urls[app]:
            continue
        url = urls[app][key]
        fn = os.path.join(savedir, url.split("/")[-1])
        if not os.path.exists(fn):
            print "Downloading:", fn
            sys.stdout.flush()
            urllib.urlretrieve(url, fn)
        else:
            print "File already here:", fn

def unpack():
    for app in urls:
        f = os.path.join(cachedir, urls[app]['bin'].split("/")[-1])
        print "unzipping:", f
        sys.stdout.flush()
        z = zipfile.ZipFile(f)
        for n in z.namelist():
            if n.endswith("/"):
                continue
            dir = os.path.join("win32", os.path.dirname(n))
            if not os.path.exists(dir):
                os.makedirs(dir)
            outfile = open(os.path.join("win32", n), 'wb')
            outfile.write(z.read(n))
            outfile.close()

if sys.argv[1] == 'bin':
    get_files('bin', cachedir)
elif sys.argv[1] == 'src':
    get_files('src', scdir)
elif sys.argv[1] == 'unpack':
    unpack()