3 # Create all the Release files
5 # Copyright (C) 2001 Anthony Towns <ajt@debian.org>
6 # $Id: ziyi,v 1.4 2001-03-21 23:20:59 ajt Exp $
8 # This program 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 2 of the License, or
11 # (at your option) any later version.
13 # This program 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.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 ################################################################################
26 import pg, sys, os, stat, string, time
27 import utils, db_access
30 ################################################################################
35 ################################################################################
37 def compressnames (tree,type,file):
38 compress = AptCnf.get("%s::%s::Compress" % (tree,type), AptCnf.get("Default::%s::Compress" % (type), ". gzip"))
40 for mode in string.split(compress):
44 result.append(file + ".gz")
46 result.append(file + ".bz2")
49 def print_file (tree, name):
50 path = Cnf["Dir::RootDir"] + tree + "/"
52 file_handle = utils.open_file(path + name, "r")
53 except utils.cant_open.exc:
54 print "ALERT: Couldn't open " + path + name
56 md5 = apt_pkg.md5sum(file_handle)
59 size = os.stat(path + name)[stat.ST_SIZE]
61 out.write(" %s %8d %s\n" % (md5, size, name))
63 ################################################################################
66 global Cnf, AptCnf, projectB, out
72 Cnf = apt_pkg.newConfiguration()
73 apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file())
75 AptCnf = apt_pkg.newConfiguration()
76 apt_pkg.ReadConfigFileISC(AptCnf,utils.which_apt_conf_file())
77 print "APT.CONF IS: " + utils.which_apt_conf_file()
79 Arguments = [('d',"debug","Ziyi::Options::Debug", "IntVal"),
80 ('h',"help","Ziyi::Options::Help"),
81 ('v',"version","Ziyi::Options::Version")]
83 suites = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv)
86 suites = Cnf.SubTree("Suite").List()
89 return x != "source" and x != "all"
92 print "Processing: " + suite
93 SuiteBlock = Cnf.SubTree("Suite::" + suite)
95 if SuiteBlock.has_key("Untouchable"):
96 print "Skipping: " + suite + " (untouchable)"
99 suite = string.lower(suite)
101 origin = SuiteBlock["Origin"]
102 label = SuiteBlock.get("Label", origin)
103 version = SuiteBlock.get("Version", "")
104 codename = SuiteBlock.get("CodeName", "")
105 if SuiteBlock.has_key("Components"):
106 components = SuiteBlock.SubTree("Components").List()
113 if c[:7] != "non-US/":
118 longsuite = suite + "/non-US"
122 tree = SuiteBlock.get("Tree", "dists/%s" % (longsuite))
124 print Cnf["Dir::RootDir"] + tree + "/Release"
125 out = open(Cnf["Dir::RootDir"] + tree + "/Release", "w")
127 out.write("Origin: %s\n" % (origin))
128 out.write("Label: %s\n" % (label))
129 out.write("Suite: %s\n" % (suite))
131 out.write("Version: %s\n" % (version))
133 out.write("Codename: %s\n" % (codename))
134 out.write("Date: %s\n" % (time.strftime("%a, %d %b %Y %H:%M:%S UTC", time.gmtime(time.time()))))
135 out.write("Architectures: %s\n" % (string.join(filter(real_arch, SuiteBlock.SubTree("Architectures").List()))))
137 out.write("Components: %s\n" % (string.join(components)))
139 out.write("Description: %s\n" % (SuiteBlock["Description"]))
140 out.write("MD5Sum:\n")
141 if AptCnf.has_key("tree::%s" % (tree)):
142 for sec in string.split(AptCnf["tree::%s::Sections" % (tree)]):
143 for arch in string.split(AptCnf["tree::%s::Architectures" % (tree)]):
145 for file in compressnames("tree::%s" % (tree), "Sources", "%s/%s/Sources" % (sec, arch)):
146 print_file(tree,file)
148 rel = "%s/binary-%s/Release" % (sec, arch)
149 relpath = Cnf["Dir::RootDir"]+tree+"/"+rel
150 if os.path.exists(relpath):
152 release = open(relpath, "w")
153 #release = open(string.replace(longsuite,"/","_") + "_" + arch + "_" + sec + "_Release", "w")
155 print "Couldn't write to " + relpath
157 release.write("Archive: %s\n" % (suite))
159 release.write("Version: %s\n" % (version))
161 release.write("Component: non-US/%s\n" % (sec))
163 release.write("Component: %s\n" % (sec))
164 release.write("Origin: %s\n" % (origin))
165 release.write("Label: %s\n" % (label))
166 release.write("Architecture: %s\n" % (arch))
168 print_file(tree,"%s/binary-%s/Release" % (sec,arch))
169 for file in compressnames("tree::%s" % (tree), "Packages", "%s/binary-%s/Packages" % (sec, arch)):
170 print_file(tree,file)
171 elif AptCnf.has_key("bindirectory::%s" % (tree)):
172 for file in compressnames("bindirectory::%s" % (tree), "Packages", AptCnf["bindirectory::%s::Packages" % (tree)]):
173 print_file(tree,string.replace(file,tree+"/","",1))
174 for file in compressnames("bindirectory::%s" % (tree), "Sources", AptCnf["bindirectory::%s::Sources" % (tree)]):
175 print_file(tree,string.replace(file,tree+"/","",1))
177 print "ALERT: no tree/bindirectory for %s" % (tree)
180 if Cnf.has_key("Dinstall::SigningKeyring"):
181 dest = Cnf["Dir::RootDir"] + tree + "/Release.gpg"
182 if os.path.exists(dest):
184 os.system("gpg --secret-keyring \"%s\" --no-options --batch --no-tty --armour --detach-sign <%s --output=%s" % (Cnf["Dinstall::SigningKeyring"],
185 Cnf["Dir::RootDir"] + tree + "/Release", dest))
187 #######################################################################################
189 if __name__ == '__main__':