3 # Initial setup of an archive
4 # Copyright (C) 2002 James Troup <james@nocrew.org>
5 # $Id: rose,v 1.2 2002-11-22 04:07:10 troup Exp $
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.
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.
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
21 ################################################################################
27 ################################################################################
32 ################################################################################
35 def do_dir(target, config_name):
36 if os.path.exists(target):
37 if not os.path.isdir(target):
38 utils.fubar("%s (%s) is not a directory." % (target, config_name));
40 print "Creating %s ..." % (target);
43 def process_file(config, config_name):
44 if config.has_key(config_name):
45 target = os.path.dirname(config[config_name]);
46 do_dir(target, config_name);
48 def process_tree(config, tree):
49 for entry in config.SubTree(tree).List():
50 entry = entry.lower();
52 if entry == "poolroot" or entry == "queue" or entry == "morguereject":
54 config_name = "%s::%s" % (tree, entry);
55 target = config[config_name];
56 do_dir(target, config_name);
58 def process_morguesubdir(subdir):
59 config_name = "%s::MorgueSubDir" % (subdir);
60 if Cnf.has_key(config_name):
61 target = os.path.join(Cnf["Dir::Morgue"], Cnf[config_name]);
62 do_dir(target, config_name);
64 ######################################################################
66 def create_directories():
67 # Process directories from apt.conf
68 process_tree(Cnf, "Dir");
69 process_tree(Cnf, "Dir::Queue");
70 for file in [ "Dinstall::LockFile", "Melanie::LogFile", "Neve::ExportDir" ]:
71 process_file(Cnf, file);
72 for subdir in [ "Shania", "Rhona" ]:
73 process_morguesubdir(subdir);
75 # Process directories from apt.conf
76 process_tree(AptCnf, "Dir");
77 for tree in AptCnf.SubTree("Tree").List():
78 config_name = "Tree::%s" % (tree);
79 tree_dir = os.path.join(Cnf["Dir::Root"], tree);
80 do_dir(tree_dir, tree);
81 for file in [ "FileList", "SourceFileList" ]:
82 process_file(AptCnf, "%s::%s" % (config_name, file));
83 for component in AptCnf["%s::Sections" % (config_name)].split():
84 for architecture in AptCnf["%s::Architectures" % (config_name)].split():
85 if architecture != "source":
86 architecture = "binary-"+architecture;
87 target = os.path.join(tree_dir,component,architecture);
88 do_dir(target, "%s, %s, %s" % (tree, component, architecture));
91 ################################################################################
94 global AptCnf, Cnf, projectB;
96 Cnf = utils.get_conf()
97 apt_pkg.ParseCommandLine(Cnf,[],sys.argv);
99 AptCnf = apt_pkg.newConfiguration();
100 apt_pkg.ReadConfigFileISC(AptCnf,utils.which_apt_conf_file());
102 create_directories();
104 ################################################################################
106 if __name__ == '__main__':