3 # Create all the Release files
5 # Copyright (C) 2001 Anthony Towns <ajt@debian.org>
6 # $Id: ziyi,v 1.10 2001-11-18 19:57:58 rmurray 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 usage (exit_code=0):
38 print """Usage: ziyi [OPTION]
39 Generate Release files.
41 -h, --help show this help and exit"""
45 ################################################################################
47 def compressnames (tree,type,file):
48 compress = AptCnf.get("%s::%s::Compress" % (tree,type), AptCnf.get("Default::%s::Compress" % (type), ". gzip"))
50 for mode in string.split(compress):
54 result.append(file + ".gz")
56 result.append(file + ".bz2")
59 def print_md5_files (tree, files):
60 path = Cnf["Dir::RootDir"] + tree + "/"
63 file_handle = utils.open_file(path + name)
64 except utils.cant_open_exc:
65 print "ALERT: Couldn't open " + path + name
67 md5 = apt_pkg.md5sum(file_handle)
70 size = os.stat(path + name)[stat.ST_SIZE]
71 out.write(" %s %8d %s\n" % (md5, size, name))
73 def print_sha1_files (tree, files):
74 path = Cnf["Dir::RootDir"] + tree + "/"
77 file_handle = utils.open_file(path + name)
78 except utils.cant_open_exc:
79 print "ALERT: Couldn't open " + path + name
81 sha1 = apt_pkg.sha1sum(file_handle)
84 size = os.stat(path + name)[stat.ST_SIZE]
85 out.write(" %s %8d %s\n" % (sha1, size, name))
87 ################################################################################
90 global Cnf, AptCnf, projectB, out
93 Cnf = utils.get_conf()
95 AptCnf = apt_pkg.newConfiguration()
96 apt_pkg.ReadConfigFileISC(AptCnf,utils.which_apt_conf_file())
98 Arguments = [('h',"help","Ziyi::Options::Help")];
100 if not Cnf.has_key("Ziyi::Options::%s" % (i)):
101 Cnf["Ziyi::Options::%s" % (i)] = "";
103 suites = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv)
104 Options = Cnf.SubTree("Ziyi::Options")
110 suites = Cnf.SubTree("Suite").List()
113 return x != "source" and x != "all"
116 print "Processing: " + suite
117 SuiteBlock = Cnf.SubTree("Suite::" + suite)
119 if SuiteBlock.has_key("Untouchable"):
120 print "Skipping: " + suite + " (untouchable)"
123 suite = string.lower(suite)
125 origin = SuiteBlock["Origin"]
126 label = SuiteBlock.get("Label", origin)
127 version = SuiteBlock.get("Version", "")
128 codename = SuiteBlock.get("CodeName", "")
130 if SuiteBlock.has_key("NotAutomatic"):
135 if SuiteBlock.has_key("Components"):
136 components = SuiteBlock.SubTree("Components").List()
143 if string.find(c, "non-US/") != 0:
148 longsuite = suite + "/non-US"
152 tree = SuiteBlock.get("Tree", "dists/%s" % (longsuite))
154 print Cnf["Dir::RootDir"] + tree + "/Release"
155 out = open(Cnf["Dir::RootDir"] + tree + "/Release", "w")
157 out.write("Origin: %s\n" % (origin))
158 out.write("Label: %s\n" % (label))
159 out.write("Suite: %s\n" % (suite))
161 out.write("Version: %s\n" % (version))
163 out.write("Codename: %s\n" % (codename))
164 out.write("Date: %s\n" % (time.strftime("%a, %d %b %Y %H:%M:%S UTC", time.gmtime(time.time()))))
165 if notautomatic != "":
166 out.write("NotAutomatic: %s\n" % (notautomatic))
167 out.write("Architectures: %s\n" % (string.join(filter(real_arch, SuiteBlock.SubTree("Architectures").List()))))
169 out.write("Components: %s\n" % (string.join(components)))
171 out.write("Description: %s\n" % (SuiteBlock["Description"]))
175 if AptCnf.has_key("tree::%s" % (tree)):
176 for sec in string.split(AptCnf["tree::%s::Sections" % (tree)]):
177 for arch in string.split(AptCnf["tree::%s::Architectures" % (tree)]):
179 for file in compressnames("tree::%s" % (tree), "Sources", "%s/%s/Sources" % (sec, arch)):
182 rel = "%s/binary-%s/Release" % (sec, arch)
183 relpath = Cnf["Dir::RootDir"]+tree+"/"+rel
184 if os.path.exists(relpath):
186 release = open(relpath, "w")
187 #release = open(string.replace(longsuite,"/","_") + "_" + arch + "_" + sec + "_Release", "w")
189 print "Couldn't write to " + relpath
191 release.write("Archive: %s\n" % (suite))
193 release.write("Version: %s\n" % (version))
195 release.write("Component: non-US/%s\n" % (sec))
197 release.write("Component: %s\n" % (sec))
198 release.write("Origin: %s\n" % (origin))
199 release.write("Label: %s\n" % (label))
200 if notautomatic != "":
201 release.write("NotAutomatic: %s\n" % (notautomatic))
202 release.write("Architecture: %s\n" % (arch))
204 files.append("%s/binary-%s/Release" % (sec,arch))
206 disks = "%s/disks-%s" % (sec, arch)
207 diskspath = Cnf["Dir::RootDir"]+tree+"/"+disks
208 if os.path.exists(diskspath):
209 for dir in os.listdir(diskspath):
210 if os.path.exists("%s/%s/md5sum.txt" % (diskspath, dir)):
211 files.append("%s/%s/md5sum.txt" % (disks, dir))
213 for file in compressnames("tree::%s" % (tree), "Packages", "%s/binary-%s/Packages" % (sec, arch)):
216 if AptCnf.has_key("tree::%s/main" % (tree)):
217 sec = string.split(AptCnf["tree::%s/main::Sections" % (tree)])[0]
218 if sec != "debian-installer":
219 print "ALERT: weird non debian-installer section in %s" % (tree)
221 for arch in string.split(AptCnf["tree::%s/main::Architectures" % (tree)]):
222 if arch != "source": # always true
223 for file in compressnames("tree::%s/main" % (tree), "Packages", "main/%s/binary-%s/Packages" % (sec, arch)):
226 elif AptCnf.has_key("bindirectory::%s" % (tree)):
227 for file in compressnames("bindirectory::%s" % (tree), "Packages", AptCnf["bindirectory::%s::Packages" % (tree)]):
228 files.append(string.replace(file,tree+"/","",1))
229 for file in compressnames("bindirectory::%s" % (tree), "Sources", AptCnf["bindirectory::%s::Sources" % (tree)]):
230 files.append(string.replace(file,tree+"/","",1))
232 print "ALERT: no tree/bindirectory for %s" % (tree)
234 out.write("MD5Sum:\n")
235 print_md5_files(tree, files)
237 print_sha1_files(tree, files)
240 if Cnf.has_key("Dinstall::SigningKeyring"):
241 dest = Cnf["Dir::RootDir"] + tree + "/Release.gpg"
242 if os.path.exists(dest):
244 os.system("gpg --secret-keyring \"%s\" --no-options --batch --no-tty --armour --detach-sign <%s --output=%s" % (Cnf["Dinstall::SigningKeyring"],
245 Cnf["Dir::RootDir"] + tree + "/Release", dest))
247 #######################################################################################
249 if __name__ == '__main__':