gencontrol
1 #!/usr/bin/python 2 # coding=utf-8 3 # build hostmot2 firmwares 4 # Copyright © 2009 Jeff Epler <jepler@unpythonic.net> 5 # 6 # This program is free software; you can redistribute it and/or modify 7 # it under the terms of the GNU General Public License as published by 8 # the Free Software Foundation; either version 2 of the License, or 9 # (at your option) any later version. 10 # 11 # This program is distributed in the hope that it will be useful, 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 # GNU General Public License for more details. 15 # 16 # You should have received a copy of the GNU General Public License 17 # along with this program; if not, write to the Free Software 18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 import os 20 import sys 21 22 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.normpath(__file__)))) 23 import cards 24 25 path_compat = { 26 'i43_200': '7i43/*S.BIT', 27 'i43_400': '7i43/*B.BIT', 28 'i22_1000': '5i22/*S.BIT', 29 'i22_1500': '5i22/*B.BIT', 30 } 31 32 # this one turns *off* all the actual firmware packages, but does not turn off the "-all" package 33 only_build_all_deb = False 34 35 # this one turns *on* the "-all" package 36 build_all_deb = True 37 38 if len(sys.argv) > 1: 39 if sys.argv[1] == '--all-only': 40 only_build_all_deb = True 41 42 if sys.argv[1] == '--no-all': 43 build_all_deb = False 44 45 all_cards = [] 46 for line in open("firmwares.txt"): 47 line = line.strip() 48 if not line or line.startswith("#"): continue 49 line = line.split() 50 card = line[0] 51 if card not in all_cards: all_cards.append(card) 52 53 if not only_build_all_deb: 54 for card in all_cards: 55 card = cards.get_card(card) 56 p = card.path 57 f = open("debian/hostmot2-firmware-%s.install" % p, "w") 58 f.write("/lib/firmware/hm2/%s/*.BIT\n" % p) 59 f.write("/lib/firmware/hm2/%s/*.xml\n" % p) 60 c = path_compat.get(card, None) 61 if c: 62 f.write("lib/firmware/hm2/%s\n" % c) 63 f = open("debian/hostmot2-firmware-%s.docs" % p, "w") 64 f.write("fw/%s/*.PIN\n" % p) 65 66 f = open("debian/control", "w") 67 f.write("""\ 68 Source: hostmot2-firmware 69 Section: misc 70 Priority: extra 71 Build-Depends: debhelper, ghdl 72 Maintainer: Jeff Epler <jepler@unpythonic.net> 73 74 """) 75 76 if build_all_deb: 77 f.write("""\ 78 Package: hostmot2-firmware-all 79 Architecture: all 80 Depends: %s 81 Description: Meta-package to install all hostmot2 firmwares 82 This is an empty package that depends on all the separately packaged 83 firmware images used by EMC2. If your configuration does not need 84 any firmware, you can safely remove this package. If you know which 85 specific hostmot2-firmware-* package you need, you can remove this package 86 and install just the one you need. 87 88 """ % ", ".join("hostmot2-firmware-%s" % cards.get_card(card).path for card in all_cards)) 89 90 if not only_build_all_deb: 91 for card in all_cards: 92 card = cards.get_card(card) 93 f.write("""\ 94 Package: hostmot2-firmware-%(card)s 95 Enhances: linuxcnc, linuxcnc-uspace 96 Architecture: all 97 Description: HostMot2 firmware images for %(cardname)s 98 This package contains HostMot2 firmware images for the %(cardname)s 99 "Anything I/O" board. If you don't use a %(cardname)s you can safely 100 remove this package. 101 102 """ % {'oldcard': card.path.split("-")[0], 'card': card.path, 'cardname': card.humanname})