3 # Create all the Release files
5 # Copyright (C) 2001 Anthony Towns <ajt@debian.org>
6 # $Id: ziyi,v 1.7 2001-08-21 15:40:10 troup 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_md5_files (tree, files):
50 path = Cnf["Dir::RootDir"] + tree + "/"
53 file_handle = utils.open_file(path + name, "r")
54 except utils.cant_open_exc:
55 print "ALERT: Couldn't open " + path + name
57 md5 = apt_pkg.md5sum(file_handle)
60 size = os.stat(path + name)[stat.ST_SIZE]
61 out.write(" %s %8d %s\n" % (md5, size, name))
63 def print_sha1_files (tree, files):
64 path = Cnf["Dir::RootDir"] + tree + "/"
67 file_handle = utils.open_file(path + name, "r")
68 except utils.cant_open_exc:
69 print "ALERT: Couldn't open " + path + name
71 sha1 = apt_pkg.sha1sum(file_handle)
74 size = os.stat(path + name)[stat.ST_SIZE]
75 out.write(" %s %8d %s\n" % (sha1, size, name))
77 ################################################################################
80 global Cnf, AptCnf, projectB, out
86 Cnf = apt_pkg.newConfiguration()
87 apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file())
89 AptCnf = apt_pkg.newConfiguration()
90 apt_pkg.ReadConfigFileISC(AptCnf,utils.which_apt_conf_file())
92 Arguments = [('d',"debug","Ziyi::Options::Debug", "IntVal"),
93 ('h',"help","Ziyi::Options::Help"),
94 ('v',"version","Ziyi::Options::Version")]
96 suites = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv)
99 suites = Cnf.SubTree("Suite").List()
102 return x != "source" and x != "all"
105 print "Processing: " + suite
106 SuiteBlock = Cnf.SubTree("Suite::" + suite)
108 if SuiteBlock.has_key("Untouchable"):
109 print "Skipping: " + suite + " (untouchable)"
112 suite = string.lower(suite)
114 origin = SuiteBlock["Origin"]
115 label = SuiteBlock.get("Label", origin)
116 version = SuiteBlock.get("Version", "")
117 codename = SuiteBlock.get("CodeName", "")
119 if SuiteBlock.has_key("NotAutomatic"):
124 if SuiteBlock.has_key("Components"):
125 components = SuiteBlock.SubTree("Components").List()
132 if c[:7] != "non-US/":
137 longsuite = suite + "/non-US"
141 tree = SuiteBlock.get("Tree", "dists/%s" % (longsuite))
143 print Cnf["Dir::RootDir"] + tree + "/Release"
144 out = open(Cnf["Dir::RootDir"] + tree + "/Release", "w")
146 out.write("Origin: %s\n" % (origin))
147 out.write("Label: %s\n" % (label))
148 out.write("Suite: %s\n" % (suite))
150 out.write("Version: %s\n" % (version))
152 out.write("Codename: %s\n" % (codename))
153 out.write("Date: %s\n" % (time.strftime("%a, %d %b %Y %H:%M:%S UTC", time.gmtime(time.time()))))
154 if notautomatic != "":
155 out.write("NotAutomatic: %s\n" % (notautomatic))
156 out.write("Architectures: %s\n" % (string.join(filter(real_arch, SuiteBlock.SubTree("Architectures").List()))))
158 out.write("Components: %s\n" % (string.join(components)))
160 out.write("Description: %s\n" % (SuiteBlock["Description"]))
164 if AptCnf.has_key("tree::%s" % (tree)):
165 for sec in string.split(AptCnf["tree::%s::Sections" % (tree)]):
166 for arch in string.split(AptCnf["tree::%s::Architectures" % (tree)]):
168 for file in compressnames("tree::%s" % (tree), "Sources", "%s/%s/Sources" % (sec, arch)):
171 rel = "%s/binary-%s/Release" % (sec, arch)
172 relpath = Cnf["Dir::RootDir"]+tree+"/"+rel
173 if os.path.exists(relpath):
175 release = open(relpath, "w")
176 #release = open(string.replace(longsuite,"/","_") + "_" + arch + "_" + sec + "_Release", "w")
178 print "Couldn't write to " + relpath
180 release.write("Archive: %s\n" % (suite))
182 release.write("Version: %s\n" % (version))
184 release.write("Component: non-US/%s\n" % (sec))
186 release.write("Component: %s\n" % (sec))
187 release.write("Origin: %s\n" % (origin))
188 release.write("Label: %s\n" % (label))
189 if notautomatic != "":
190 release.write("NotAutomatic: %s\n" % (notautomatic))
191 release.write("Architecture: %s\n" % (arch))
193 files.append("%s/binary-%s/Release" % (sec,arch))
195 disks = "%s/disks-%s" % (sec, arch)
196 diskspath = Cnf["Dir::RootDir"]+tree+"/"+disks
197 if os.path.exists(diskspath):
198 for dir in os.listdir(diskspath):
199 if os.path.exists("%s/%s/md5sum.txt" % (diskspath, dir)):
200 files.append("%s/%s/md5sum.txt" % (disks, dir))
202 for file in compressnames("tree::%s" % (tree), "Packages", "%s/binary-%s/Packages" % (sec, arch)):
205 if AptCnf.has_key("tree::%s/main" % (tree)):
206 sec = string.split(AptCnf["tree::%s/main::Sections" % (tree)])[0]
207 if sec != "debian-installer":
208 print "ALERT: weird non debian-installer section in %s" % (tree)
210 for arch in string.split(AptCnf["tree::%s/main::Architectures" % (tree)]):
211 if arch != "source": # always true
212 for file in compressnames("tree::%s/main" % (tree), "Packages", "main/%s/binary-%s/Packages" % (sec, arch)):
215 elif AptCnf.has_key("bindirectory::%s" % (tree)):
216 for file in compressnames("bindirectory::%s" % (tree), "Packages", AptCnf["bindirectory::%s::Packages" % (tree)]):
217 files.append(string.replace(file,tree+"/","",1))
218 for file in compressnames("bindirectory::%s" % (tree), "Sources", AptCnf["bindirectory::%s::Sources" % (tree)]):
219 files.append(string.replace(file,tree+"/","",1))
221 print "ALERT: no tree/bindirectory for %s" % (tree)
223 out.write("MD5Sum:\n")
224 print_md5_files(tree, files)
226 print_sha1_files(tree, files)
229 if Cnf.has_key("Dinstall::SigningKeyring"):
230 dest = Cnf["Dir::RootDir"] + tree + "/Release.gpg"
231 if os.path.exists(dest):
233 os.system("gpg --secret-keyring \"%s\" --no-options --batch --no-tty --armour --detach-sign <%s --output=%s" % (Cnf["Dinstall::SigningKeyring"],
234 Cnf["Dir::RootDir"] + tree + "/Release", dest))
236 #######################################################################################
238 if __name__ == '__main__':