/[gentoo]/src/packages/ebuilddb.py
Gentoo

Diff of /src/packages/ebuilddb.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.6 Revision 1.7
1#!/usr/bin/python -O 1#!/usr/bin/python -O
2 2
3__revision__ = '$Revision: 1.6 $' 3__revision__ = '$Revision: 1.7 $'
4# $Source: /var/cvsroot/gentoo/src/packages/ebuilddb.py,v $ 4# $Source: /var/cvsroot/gentoo/src/packages/ebuilddb.py,v $
5 5
6import config 6import config
7import sys 7import sys
8import os 8import os
138 return ebuild 138 return ebuild
139 139
140def get_mtime(s): 140def get_mtime(s):
141 """Get mtime of file, return in format that MySQL would like""" 141 """Get mtime of file, return in format that MySQL would like"""
142 try: 142 try:
143 t = os.path.getmtime(s) 143 mtime = os.path.getmtime(s)
144 except OSError: 144 except OSError:
145 return 'NULL' 145 return 'NULL'
146 str = time.strftime("%Y%m%d%H%M%S",time.localtime(t)) 146 strftime = time.strftime("%Y%m%d%H%M%S",time.localtime(mtime))
147 return str 147 return strftime
148 148
149def is_masked(tree, ebuild): 149def is_masked(tree, ebuild):
150 """Return true if packages is masked in tree""" 150 """Return true if packages is masked in tree"""
151 return (not tree.visible(['%(category)s/%(name)s-%(version)s' % ebuild])) 151 return (not tree.visible(['%(category)s/%(name)s-%(version)s' % ebuild]))
152 152
153def main(): 153def main(argv = []):
154 """Main program entry point""" 154 """Main program entry point"""
155 # We need to "fake" as repoman so portage will ignore local system 155 # We need to "fake" as repoman so portage will ignore local system
156 # settings 156 # settings
157 os.environ['PORTAGE_CALLER'] = 'repoman' 157 os.environ['PORTAGE_CALLER'] = 'repoman'
158 158
167 # We want to use the base profile, not any system-specific one 167 # We want to use the base profile, not any system-specific one
168 p_config = portage.config(config_profile_path = '/usr/portage/profiles/base') 168 p_config = portage.config(config_profile_path = '/usr/portage/profiles/base')
169 169
170 tree = portage.portdbapi('/usr/portage', p_config) 170 tree = portage.portdbapi('/usr/portage', p_config)
171 171
172 # are we updating the db or just rebuilding it?
173 rebuild = len(argv) == 2 and argv[1] == 'rebuild'
172 for s in ebuilds: 174 for s in ebuilds:
173 fields = parse_ebuild(s, portage.pkgsplit) 175 fields = parse_ebuild(s, portage.pkgsplit)
174 if not fields: 176 if not fields:
175 continue 177 continue
176 result = get_ebuild_record(db,fields) 178 result = get_ebuild_record(db,fields)
178 fields['changelog'] = changelogs.changelog('%s/ChangeLog' 180 fields['changelog'] = changelogs.changelog('%s/ChangeLog'
179 % os.path.dirname(s)) 181 % os.path.dirname(s))
180 fields['time'] = get_mtime(s) 182 fields['time'] = get_mtime(s)
181 fields['masked'] = int(is_masked(tree, fields)) 183 fields['masked'] = int(is_masked(tree, fields))
182 184
183 if not result: 185 if not (result or rebuild):
184 create_ebuild_record(db,fields) 186 create_ebuild_record(db,fields)
187 elif result and rebuild:
188 fields['prevarch'] = result[6]
189 fields['arch'] = [4]
190 update_ebuild_record(db, fields)
185 elif result[4] != fields['archs']: 191 elif result[4] != fields['archs']:
186 #print 'ebuild archs=',fields['archs'] 192 #print 'ebuild archs=',fields['archs']
187 #print 'db archs=',result[4] 193 #print 'db archs=',result[4]
188 #print 194 #print
189 # keywords change, update db 195 # keywords change, update db
195 fields['prevarch'] = result[4] 201 fields['prevarch'] = result[4]
196 update_ebuild_record(db,fields) 202 update_ebuild_record(db,fields)
197 203
198 db.commit() 204 db.commit()
199if __name__ == '__main__': 205if __name__ == '__main__':
200 main() 206 sys.exit(main(sys.argv))

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

  ViewVC Help
Powered by ViewVC 1.1.20