3 # Initial setup of an archive
4 # Copyright (C) 2002 James Troup <james@nocrew.org>
5 # $Id: rose,v 1.1 2002-10-16 02:45:12 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 ################################################################################
31 ################################################################################
34 def do_dir(target, config_name):
35 if os.path.exists(target):
36 if not os.path.isdir(target):
37 utils.fubar("%s (%s) is not a directory." % (target, config_name));
39 print "Creating %s ..." % (target);
42 def process_file(config, config_name):
43 if config.has_key(config_name):
44 target = os.path.dirname(config[config_name]);
45 do_dir(target, config_name);
47 def process_tree(config, tree):
48 for entry in config.SubTree(tree).List():
49 entry = entry.lower();
51 if entry == "poolroot" or entry == "queue" or entry == "morguereject":
53 config_name = "%s::%s" % (tree, entry);
54 target = config[config_name];
55 do_dir(target, config_name);
57 def process_morguesubdir(subdir):
58 config_name = "%s::MorgueSubDir" % (subdir);
59 if Cnf.has_key(config_name):
60 target = os.path.join(Cnf["Dir::Morgue"], Cnf[config_name]);
61 do_dir(target, config_name);
63 ######################################################################
65 def create_directories():
66 # Process directories from apt.conf
67 process_tree(Cnf, "Dir");
68 process_tree(Cnf, "Dir::Queue");
69 for file in [ "Dinstall::LockFile", "Melanie::LogFile", "Neve::ExportDir" ]:
70 process_file(Cnf, file);
71 for subdir in [ "Shania", "Rhona" ]:
72 process_morguesubdir(subdir);
74 # Process directories from apt.conf
75 process_tree(AptCnf, "Dir");
76 for tree in AptCnf.SubTree("Tree").List():
77 config_name = "Tree::%s" % (tree);
78 tree_dir = os.path.join(Cnf["Dir::Root"], tree);
79 do_dir(tree_dir, tree);
80 for file in [ "FileList", "SourceFileList" ]:
81 process_file(AptCnf, "%s::%s" % (config_name, file));
82 for component in AptCnf["%s::Sections" % (config_name)].split():
83 for architecture in AptCnf["%s::Architectures" % (config_name)].split():
84 if architecture != "source":
85 architecture = "binary-"+architecture;
86 target = os.path.join(tree_dir,component,architecture);
87 do_dir(target, "%s, %s, %s" % (tree, component, architecture));
90 ################################################################################
95 Cnf = utils.get_conf()
96 apt_pkg.ParseCommandLine(Cnf,[],sys.argv);
98 AptCnf = apt_pkg.newConfiguration();
99 apt_pkg.ReadConfigFileISC(AptCnf,utils.which_apt_conf_file());
101 create_directories();
103 ################################################################################
105 if __name__ == '__main__':