4 Do whatever is needed to get a security upload released
6 @contact: Debian FTP Master <ftpmaster@debian.org>
7 @copyright: 2010 Joerg Jaspert <joerg@debian.org>
8 @license: GNU General Public License version 2 or later
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2 of the License, or
14 # (at your option) any later version.
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 ################################################################################
28 ################################################################################
36 from daklib import queue
37 from daklib import daklog
38 from daklib import utils
39 from daklib.dbconn import *
40 from daklib.regexes import re_taint_free
41 from daklib.config import Config
49 print """Usage: dak security-install [OPTIONS] changesfiles
50 Do whatever there is to do for a security release
52 -h, --help show this help and exit
53 -n, --no-action don't commit changes
54 -s, --sudo dont bother, used internally
61 if not re_taint_free.match(command):
62 utils.fubar("Invalid character in \"%s\"." % (command))
64 if Options["No-Action"]:
65 print "[%s]" % (command)
67 (result, output) = commands.getstatusoutput(command)
69 utils.fubar("Invocation of '%s' failed:\n%s\n" % (command, output), result)
71 ##################### ! ! ! N O T E ! ! ! #####################
73 # These functions will be reinvoked by semi-priveleged users, be careful not
74 # to invoke external programs that will escalate privileges, etc.
76 ##################### ! ! ! N O T E ! ! ! #####################
78 def sudo(arg, fn, exit):
80 os.spawnl(os.P_WAIT, "/usr/bin/sudo", "/usr/bin/sudo", "-u", "dak", "-H",
81 "/usr/local/bin/dak", "new-security-install", "-"+arg)
87 def do_Approve(): sudo("A", _do_Approve, True)
89 # 1. use process-policy to go through the COMMENTS dir
90 spawn("dak process-policy embargoed")
91 spawn("dak process-policy unembargoed")
92 newstage=get_policy_queue('newstage')
94 # 2. sync the stuff to ftpmaster
95 print "Sync stuff for upload to ftpmaster"
96 spawn("rsync -a -q %s/. /srv/queued/ftpmaster/." % (newstage.path))
98 print "Locking unchecked"
99 lockfile='/srv/security-master.debian.org/lock/unchecked.lock'
100 spawn("lockfile -r8 {0}".format(lockfile))
103 # 3. Now run process-upload in the newstage dir
104 print "Now put it into the security archive"
105 spawn("dak process-upload -a -d %s" % (newstage.path))
107 # 4. Run all the steps that are needed to publish the changed archive
109 spawn("dak dominate")
110 # print "Generating filelist for apt-ftparchive"
111 # spawn("dak generate-filelist")
112 print "Updating Packages and Sources files... This may take a while, be patient"
113 spawn("/srv/security-master.debian.org/dak/config/debian-security/map.sh")
114 # spawn("apt-ftparchive generate %s" % (utils.which_apt_conf_file()))
115 spawn("dak generate-packages-sources2")
116 print "Updating Release files..."
117 spawn("dak generate-releases")
118 print "Triggering security mirrors... (this may take a while)"
119 spawn("/srv/security-master.debian.org/dak/config/debian-security/make-mirror.sh")
120 spawn("sudo -u archvsync -H /home/archvsync/signal_security")
121 print "Triggering metadata export for packages.d.o and other consumers"
122 spawn("/srv/security-master.debian.org/dak/config/debian-security/export.sh")
125 print "Lock released."
127 ########################################################################
128 ########################################################################
131 global Options, Logger, Queue, changes
134 Arguments = [('h', "Help", "Security::Options::Help"),
135 ('n', "No-Action", "Security::Options::No-Action"),
136 ('c', 'Changesfile', "Security::Options::Changesfile"),
137 ('s', "Sudo", "Security::Options::Sudo"),
138 ('A', "Approve", "Security::Options::Approve")
141 for i in ["Help", "No-Action", "Changesfile", "Sudo", "Approve"]:
142 if not cnf.has_key("Security::Options::%s" % (i)):
143 cnf["Security::Options::%s" % (i)] = ""
145 changes_files = apt_pkg.ParseCommandLine(cnf.Cnf, Arguments, sys.argv)
147 Options = cnf.SubTree("Security::Options")
152 for a in changes_files:
153 if not a.endswith(".changes"):
154 utils.fubar("not a .changes file: %s" % (a))
156 changes = changesfiles.keys()
158 username = utils.getusername()
159 if username != "dak":
160 print "Non-dak user: %s" % username
161 Options["Sudo"] = "y"
163 if Options["No-Action"]:
166 if not Options["Sudo"] and not Options["No-Action"]:
167 Logger = daklog.Logger("security-install")
169 session = DBConn().session()
171 # If we call ourselve to approve, we do just that and exit
172 if Options["Approve"]:
176 if len(changes) == 0:
177 utils.fubar("Need changes files as arguments")
179 # Yes, we could do this inside do_Approve too. But this way we see who exactly
180 # called it (ownership of the file)
183 for change in changes:
184 dbchange=get_dbchange(os.path.basename(change), session)
185 # strip epoch from version
186 version=dbchange.version
187 version=version[(version.find(':')+1):]
188 acceptfilename="%s/COMMENTS/ACCEPT.%s_%s" % (os.path.dirname(os.path.abspath(changes[0])), dbchange.source, version)
189 acceptfiles[acceptfilename]=1
191 if Options["No-Action"]:
192 print "Would create %s now and then go on to accept this package, but No-Action is set" % (acceptfiles.keys())
195 for acceptfilename in acceptfiles.keys():
196 accept_file = file(acceptfilename, "w")
197 accept_file.write("OK\n")
203 if __name__ == '__main__':