]> git.decadent.org.uk Git - dak.git/blob - catherine
573d57e7550af4c6a130b5d055724c52a62609ae
[dak.git] / catherine
1 #!/usr/bin/env python
2
3 # Poolify (move packages from "legacy" type locations to pool locations)
4 # Copyright (C) 2000  James Troup <james@nocrew.org>
5 # $Id: catherine,v 1.1 2000-11-24 00:20:11 troup Exp $
6
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
11
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20
21 ################################################################################
22
23 import pg
24 import utils
25 import apt_pkg;
26
27 ################################################################################
28
29 Cnf = None;
30 projectB = None;
31
32 ################################################################################
33
34 def main ():
35     global Cnf, projectB;
36
37     apt_pkg.init();
38     
39     Cnf = apt_pkg.newConfiguration();
40     apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file());
41
42     Arguments = [('d',"debug","Heidi::Options::Debug", "IntVal"),
43                  ('h',"help","Heidi::Options::Help"),
44                  ('v',"version","Heidi::Options::Version")];
45
46     amount = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv);
47
48     print amount
49     
50     return
51
52     projectB = pg.connect('projectb', 'localhost');
53
54     db_access.init(Cnf, projectB);
55
56     if (Cnf["Heidi::Options::Add"] == "" and Cnf["Heidi::Options::Remove"] == "") or (Cnf["Heidi::Options::Add"] != "" and Cnf["Heidi::Options::Remove"] != ""):
57
58         sys.stderr.write("Need either --add <suite> or --remove <suite> command line argument; not neither or both.\n");
59         sys.exit(2);
60
61     for i in ("add", "remove"):
62         suite = Cnf["Heidi::Options::%s" % (i)];
63         if suite !="":
64             if not Cnf.has_key("Suite::%s" % (suite)):
65                 sys.stderr.write("Unknown suite %s.\n" %(suite));
66                 sys.exit(2);
67             else:
68                 suite_id = db_access.get_suite_id(suite);
69                 action = i;
70
71     if file_list != []:
72         for file in file_list:
73             process_file(utils.open_file(file_list[0],'r'), suite_id, action);
74     else:
75         process_file(sys.stdin, suite_id, action);
76
77     db_access.init (Cnf, projectB);
78
79 #######################################################################################
80
81 if __name__ == '__main__':
82     main()
83