The Assimilation Project  based on Assimilation version 1.1.7.1474836767
select-cpack.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # vim: smartindent tabstop=4 shiftwidth=4 expandtab
3 #
4 # This file is part of the Assimilation Project.
5 #
6 # Copyright (C) 2011, 2012 - Alan Robertson <alanr@unix.sh>
7 #
8 # The Assimilation software is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
12 #
13 # The Assimilation software is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with the Assimilation Project software. If not, see http://www.gnu.org/licenses/
20 #
21 #
22 import os
24  maxcount=0
25  selection='RPM'
26  names = { 'RPM': 'rpm -q -a', 'DEB': 'dpkg -l'}
27  counts = {}
28  for name in names:
29  cmd=names[name]
30  fd = os.popen('%s 2>/dev/null' % cmd, 'r')
31  packages = fd.readlines()
32  fd.close()
33  counts[name] = len(packages)
34  packages = None
35  for name in names:
36  if counts[name] > maxcount:
37  selection = name
38  print selection
39 
40 # posix, nt, dos, mac, ce, java, os2, or riscos.
41 if os.name == 'posix':
42  print_posix()
43 elif os.name == 'mac':
44  print 'PackageMaker'
45 elif os.name == 'nt' or os.name == 'dos' or os.name == 'ce':
46  print 'NSIS'
47 
def print_posix()
Definition: select-cpack.py:23