3 # Initial setup of an archive
4 # Copyright (C) 2002, 2004 James Troup <james@nocrew.org>
5 # $Id: rose,v 1.4 2004-03-11 00:20:51 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 ################################################################################
34 def usage(exit_code=0):
36 Creates directories for an archive based on katie.conf configuration file.
38 -h, --help show this help and exit."""
41 ################################################################################
43 def do_dir(target, config_name):
44 if os.path.exists(target):
45 if not os.path.isdir(target):
46 utils.fubar("%s (%s) is not a directory." % (target, config_name))
48 print "Creating %s ..." % (target)
51 def process_file(config, config_name):
52 if config.has_key(config_name):
53 target = os.path.dirname(config[config_name])
54 do_dir(target, config_name)
56 def process_tree(config, tree):
57 for entry in config.SubTree(tree).List():
60 if entry in [ "poolroot", "queue" , "morguereject" ]:
62 config_name = "%s::%s" % (tree, entry)
63 target = config[config_name]
64 do_dir(target, config_name)
66 def process_morguesubdir(subdir):
67 config_name = "%s::MorgueSubDir" % (subdir)
68 if Cnf.has_key(config_name):
69 target = os.path.join(Cnf["Dir::Morgue"], Cnf[config_name])
70 do_dir(target, config_name)
72 ######################################################################
74 def create_directories():
75 # Process directories from apt.conf
76 process_tree(Cnf, "Dir")
77 process_tree(Cnf, "Dir::Queue")
78 for file in [ "Dinstall::LockFile", "Melanie::LogFile", "Neve::ExportDir" ]:
79 process_file(Cnf, file)
80 for subdir in [ "Shania", "Rhona" ]:
81 process_morguesubdir(subdir)
83 # Process directories from apt.conf
84 process_tree(AptCnf, "Dir")
85 for tree in AptCnf.SubTree("Tree").List():
86 config_name = "Tree::%s" % (tree)
87 tree_dir = os.path.join(Cnf["Dir::Root"], tree)
88 do_dir(tree_dir, tree)
89 for file in [ "FileList", "SourceFileList" ]:
90 process_file(AptCnf, "%s::%s" % (config_name, file))
91 for component in AptCnf["%s::Sections" % (config_name)].split():
92 for architecture in AptCnf["%s::Architectures" % (config_name)].split():
93 if architecture != "source":
94 architecture = "binary-"+architecture
95 target = os.path.join(tree_dir,component,architecture)
96 do_dir(target, "%s, %s, %s" % (tree, component, architecture))
99 ################################################################################
102 global AptCnf, Cnf, projectB
104 Cnf = utils.get_conf()
105 Arguments = [('h',"help","Rose::Options::Help")]
107 if not Cnf.has_key("Rose::Options::%s" % (i)):
108 Cnf["Rose::Options::%s" % (i)] = ""
110 apt_pkg.ParseCommandLine(Cnf, Arguments, sys.argv)
112 Options = Cnf.SubTree("Rose::Options")
116 AptCnf = apt_pkg.newConfiguration()
117 apt_pkg.ReadConfigFileISC(AptCnf,utils.which_apt_conf_file())
121 ################################################################################
123 if __name__ == '__main__':