2 # Copyright 2013 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
6 # Script to install the Chrome OS fonts on Linux.
7 # This script can be run manually (as root), but is also run as part
8 # install-build-deps.sh.
15 # Taken from the media-fonts/notofonts ebuild in chromiumos-overlay.
17 URL
= ('https://commondatastorage.googleapis.com/chromeos-localmirror/'
18 'distfiles/notofonts-%s.tar.bz2') % (VERSION
)
19 FONTS_DIR
= '/usr/local/share/fonts'
22 if not sys
.platform
.startswith('linux'):
23 print "Error: %s must be run on Linux." % __file__
27 print "Error: %s must be run as root." % __file__
30 if not os
.path
.isdir(FONTS_DIR
):
31 print "Error: Destination directory does not exist: %s" % FONTS_DIR
34 dest_dir
= os
.path
.join(FONTS_DIR
, 'chromeos')
36 stamp
= os
.path
.join(dest_dir
, ".stamp02")
37 if os
.path
.exists(stamp
):
38 with
open(stamp
) as s
:
40 print "Chrome OS fonts already up-to-date in %s." % dest_dir
43 if os
.path
.isdir(dest_dir
):
44 shutil
.rmtree(dest_dir
)
46 os
.chmod(dest_dir
, 0755)
48 print "Installing Chrome OS fonts to %s." % dest_dir
49 tarball
= os
.path
.join(dest_dir
, os
.path
.basename(URL
))
50 subprocess
.check_call(['curl', '-L', URL
, '-o', tarball
])
51 subprocess
.check_call(['tar', '--no-same-owner', '--no-same-permissions',
52 '-xf', tarball
, '-C', dest_dir
])
55 readme
= os
.path
.join(dest_dir
, "README")
56 with
open(readme
, 'w') as s
:
57 s
.write("This directory and its contents are auto-generated.\n")
58 s
.write("It may be deleted and recreated. Do not modify.\n")
59 s
.write("Script: %s\n" % __file__
)
61 with
open(stamp
, 'w') as s
:
64 for base
, dirs
, files
in os
.walk(dest_dir
):
66 os
.chmod(os
.path
.join(base
, dir), 0755)
68 os
.chmod(os
.path
.join(base
, file), 0644)
72 if __name__
== '__main__':
73 sys
.exit(main(sys
.argv
[1:]))