The Birdfont Source Code


All Repositories / birdfont.git / blob – RSS feed

install.py

This file is a part of the Birdfont project.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git

Revisions

View the latest version of install.py.
Mark font as modified in Beziér tool
1 #!/usr/bin/python 2 """ 3 Copyright (C) 2013 2014 2015 Johan Mattsson 4 5 This program is free software: you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation, either version 3 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program. If not, see <http://www.gnu.org/licenses/>. 17 """ 18 19 import os 20 import subprocess 21 import glob 22 import platform 23 import sys 24 from optparse import OptionParser 25 from scripts import config 26 from scripts import version 27 from scripts.run import run 28 29 def getDest (file, dir): 30 f = dest + prefix + dir + '/' 31 s = file.rfind ('/') 32 if s > -1: 33 f += file[s + 1:] 34 else: 35 f += file 36 return f 37 38 def getDestRoot (file, dir): 39 f = dest + dir + '/' 40 s = file.rfind ('/') 41 if s > -1: 42 f += file[s + 1:] 43 else: 44 f += file 45 return f 46 47 def install (file, dir, mode): 48 f = getDest (file, dir) 49 print ("install: " + f) 50 run ('install -d ' + dest + prefix + dir) 51 run ('install -m ' + `mode` + ' ' + file + ' ' + dest + prefix + dir + '/') 52 installed.write (f + "\n") 53 54 def install_root (file, dir, mode): 55 f = getDestRoot (file, dir) 56 print ("install: " + f) 57 run ('install -d ' + dest + dir) 58 run ('install -m ' + `mode` + ' ' + file + ' ' + dest + dir + '/') 59 60 def link (dir, file, linkname): 61 f = getDest (linkname, dir) 62 print ("install link: " + f) 63 run ('cd ' + dest + prefix + dir + ' && ln -sf ' + file + ' ' + linkname) 64 installed.write (f + "\n") 65 66 if not os.path.exists ("build/configured"): 67 print ("Project is not configured") 68 exit (1) 69 70 parser = OptionParser() 71 parser.add_option ("-d", "--dest", dest="dest", help="install to this directory", metavar="DEST") 72 parser.add_option ("-m", "--nogzip", dest="nogzip", help="don't gzip manpages", default=False) 73 parser.add_option ("-n", "--manpages-directory", dest="mandir", help="put man pages in this directory under prefix") 74 parser.add_option ("-l", "--libdir", dest="libdir", help="path to directory for shared libraries (lib or lib64).") 75 parser.add_option ("-c", "--skip-command-line-tools", dest="nocli", help="don't install command line tools") 76 parser.add_option ("-a", "--apport", dest="apport", help="install apport scripts", default=True) 77 78 (options, args) = parser.parse_args() 79 80 if not options.dest: 81 options.dest = "" 82 83 if not options.nocli: 84 options.nocli = False 85 86 nogzip = options.nogzip 87 88 if not options.mandir: 89 mandir = "/man/man1" 90 else: 91 mandir = options.mandir 92 93 prefix = config.PREFIX 94 dest = options.dest 95 96 # create uninstall file 97 installed = open ('build/installed', 'w') 98 installed.write ('build/installed\n') 99 100 # install it: 101 install ('resources/icons.bf', '/share/birdfont', 644) 102 install ('resources/bright.theme', '/share/birdfont', 644) 103 install ('resources/dark.theme', '/share/birdfont', 644) 104 install ('resources/high_contrast.theme', '/share/birdfont', 644) 105 install ('resources/key_bindings.xml', '/share/birdfont', 644) 106 install ('resources/roboto.bf', '/share/birdfont', 644) 107 install ('resources/linux/birdfont_window_icon.png', '/share/birdfont', 644) 108 install ('resources/linux/birdfont.desktop', '/share/applications', 644) 109 install ('resources/ucd.sqlite', '/share/birdfont', 644) 110 install ('resources/codepages.sqlite', '/share/birdfont', 644) 111 112 install ('resources/linux/256x256/birdfont.png', '/share/icons/hicolor/256x256/apps', 644) 113 install ('resources/linux/128x128/birdfont.png', '/share/icons/hicolor/128x128/apps', 644) 114 install ('resources/linux/48x48/birdfont.png', '/share/icons/hicolor/48x48/apps', 644) 115 116 install ('resources/linux/birdfont.appdata.xml', '/share/appdata', 644) 117 118 if os.path.isfile ('build/bin/birdfont'): 119 install ('build/bin/birdfont', '/bin', 755) 120 121 if not options.nocli: 122 install ('build/bin/birdfont-autotrace', '/bin', 755) 123 install ('build/bin/birdfont-export', '/bin', 755) 124 install ('build/bin/birdfont-import', '/bin', 755) 125 126 #library 127 if not options.libdir: 128 129 if platform.dist()[0] == 'Ubuntu' or platform.dist()[0] == 'Debian': 130 process = subprocess.Popen(['dpkg-architecture', '-qDEB_HOST_MULTIARCH'], stdout=subprocess.PIPE) 131 out, err = process.communicate() 132 libdir = '/lib/' + out.rstrip ('\n') 133 else: 134 p = platform.machine() 135 if p == 'i386' or p == 's390' or p == 'ppc' or p == 'armv7hl': 136 libdir = '/lib' 137 elif p == 'x86_64' or p == 's390x' or p == 'ppc64': 138 libdir = '/lib64' 139 else: 140 libdir = '/lib' 141 else: 142 libdir = options.libdir 143 144 if os.path.isfile ('build/bin/libbirdfont.so.' + version.SO_VERSION): 145 install ('build/bin/libbirdfont.so.' + version.SO_VERSION, libdir, 644) 146 link (libdir, 'libbirdfont.so.' + version.SO_VERSION, ' libbirdfont.so.' + version.SO_VERSION_MAJOR) 147 link (libdir, 'libbirdfont.so.' + version.SO_VERSION, ' libbirdfont.so') 148 elif os.path.isfile ('build/libbirdfont.so.' + version.SO_VERSION): 149 install ('build/libbirdfont.so.' + version.SO_VERSION, libdir, 644) 150 link (libdir, 'libbirdfont.so.' + version.SO_VERSION, ' libbirdfont.so.' + version.SO_VERSION_MAJOR) 151 link (libdir, 'libbirdfont.so.' + version.SO_VERSION, ' libbirdfont.so') 152 elif os.path.isfile ('build/bin/libbirdfont.' + version.SO_VERSION + '.dylib'): 153 install ('build/bin/libbirdfont.' + version.SO_VERSION + '.dylib', libdir, 644) 154 link (libdir, 'libbirdfont.' + version.SO_VERSION + '.dylib', ' libbirdfont.dylib.' + version.SO_VERSION_MAJOR) 155 link (libdir, 'libbirdfont.' + version.SO_VERSION + '.dylib', ' libbirdfont.dylib') 156 else: 157 print ("Can't find libbirdfont.") 158 exit (1) 159 160 if os.path.isfile ('build/bin/libbirdxml.so.' + version.LIBBIRDXML_SO_VERSION): 161 install ('build/bin/libbirdxml.so.' + version.LIBBIRDXML_SO_VERSION, libdir, 644) 162 link (libdir, 'libbirdxml.so.' + version.LIBBIRDXML_SO_VERSION, ' libbirdxml.so.' + version.LIBBIRDXML_SO_VERSION_MAJOR) 163 link (libdir, 'libbirdxml.so.' + version.LIBBIRDXML_SO_VERSION, ' libbirdxml.so') 164 elif os.path.isfile ('build/libbirdxml.so.' + version.LIBBIRDXML_SO_VERSION): 165 install ('build/libbirdxml.so.' + version.LIBBIRDXML_SO_VERSION, libdir, 644) 166 link (libdir, 'libbirdxml.so.' + version.LIBBIRDXML_SO_VERSION, ' libbirdxml.so.' + version.LIBBIRDXML_SO_VERSION_MAJOR) 167 link (libdir, 'libbirdxml.so.' + version.LIBBIRDXML_SO_VERSION, ' libbirdxml.so') 168 elif os.path.isfile ('build/bin/libbirdxml.' + version.LIBBIRDXML_SO_VERSION + '.dylib'): 169 install ('build/bin/libbirdxml.' + version.LIBBIRDXML_SO_VERSION + '.dylib', libdir, 644) 170 link (libdir, 'libbirdxml.' + version.LIBBIRDXML_SO_VERSION + '.dylib', ' libbirdxml.dylib.' + version.LIBBIRDXML_SO_VERSION_MAJOR) 171 link (libdir, 'libbirdxml.' + version.LIBBIRDXML_SO_VERSION + '.dylib', ' libbirdxml.dylib') 172 else: 173 print ("Can't find libbirdxml.") 174 exit (1) 175 176 177 if "bsd" in sys.platform: 178 install ('build/libbirdfont.so.' + '${LIBbirdfont_VERSION}', '/lib', 644) 179 install ('build/libbirdxml.so.' + '${LIBbirdxml_VERSION}', '/lib', 644) 180 install ('build/libbirdgems.so.' + '${LIBbirdgems_VERSION}', '/lib', 644) 181 elif os.path.isfile ('build/bin/libbirdgems.so.' + version.LIBBIRDGEMS_SO_VERSION): 182 install ('build/bin/libbirdgems.so.' + version.LIBBIRDGEMS_SO_VERSION, libdir, 644) 183 link (libdir, 'libbirdgems.so.' + version.LIBBIRDGEMS_SO_VERSION, ' libbirdgems.so.' + version.LIBBIRDXML_SO_VERSION_MAJOR) 184 link (libdir, 'libbirdgems.so.' + version.LIBBIRDGEMS_SO_VERSION, ' libbirdgems.so') 185 elif os.path.isfile ('build/libbirdgems.so.' + version.LIBBIRDGEMS_SO_VERSION): 186 install ('build/libbirdgems.so.' + version.LIBBIRDGEMS_SO_VERSION, libdir, 644) 187 link (libdir, 'libbirdgems.so.' + version.LIBBIRDGEMS_SO_VERSION, ' libbirdgems.so.' + version.LIBBIRDGEMS_SO_VERSION_MAJOR) 188 link (libdir, 'libbirdgems.so.' + version.LIBBIRDGEMS_SO_VERSION, ' libbirdgems.so') 189 elif os.path.isfile ('build/bin/libbirdgems.' + version.LIBBIRDGEMS_SO_VERSION + '.dylib'): 190 install ('build/bin/libbirdgems.' + version.LIBBIRDGEMS_SO_VERSION + '.dylib', libdir, 644) 191 link (libdir, 'libbirdgems.' + version.LIBBIRDGEMS_SO_VERSION + '.dylib', ' libbirdgems.dylib.' + version.LIBBIRDGEMS_SO_VERSION_MAJOR) 192 link (libdir, 'libbirdgems.' + version.LIBBIRDGEMS_SO_VERSION + '.dylib', ' libbirdgems.dylib') 193 else: 194 print ("Can't find libbirdgems, version: " + version.LIBBIRDGEMS_SO_VERSION) 195 exit (1) 196 197 198 #manpages 199 200 if not nogzip: 201 install ('build/birdfont.1.gz', mandir, 644) 202 203 if not options.nocli: 204 install ('build/birdfont-autotrace.1.gz', mandir, 644) 205 install ('build/birdfont-export.1.gz', mandir, 644) 206 install ('build/birdfont-import.1.gz', mandir, 644) 207 else: 208 install ('resources/linux/birdfont.1', mandir, 644) 209 210 if not options.nocli: 211 install ('resources/linux/birdfont-autotrace.1', mandir, 644) 212 install ('resources/linux/birdfont-export.1', mandir, 644) 213 install ('resources/linux/birdfont-import.1', mandir, 644) 214 215 #translations 216 for lang_dir in glob.glob('build/locale/*'): 217 lc = lang_dir.replace ('build/locale/', "") 218 install ('build/locale/' + lc + '/LC_MESSAGES/birdfont.mo', '/share/locale/' + lc + '/LC_MESSAGES' , 644); 219 220 #file type 221 install ('resources/linux/birdfont.xml', '/share/mime/packages', 644) 222 223 #apport hooks 224 if options.apport == "True": 225 install ('resources/birdfont.py', '/share/apport/package-hooks', 644) 226 install ('resources/source_birdfont.py', '/share/apport/package-hooks', 644) 227 install_root ('resources/birdfont-crashdb.conf', '/etc/apport/crashdb.conf.d', 644) 228 229 installed.close () 230