if [ ! -z "$changes" ]; then
echo "$timestamp": "$changes" >> $report
- dak process-unchecked -a $changes >> $report
+ dak process-unchecked -a -d "$unchecked" >> $report
echo "--" >> $report
# sync with debbugs
# Cleanup actions
function cleanup() {
- savelog -c ${LOGROTATE} -j "$LOGFILE"
+ rm -f ${LOCK_DAILY}
+ rm -f ${LOCK_ACCEPTED}
}
# Setup the notice file to tell bad mirrors they used the wrong time
# Process the accepted queue
function accepted() {
log "Processing queue/accepted"
- cd "$accepted"
- rm -f REPORT
- dak process-accepted -pa *.changes | tee REPORT | \
- mail -s "Install for $(date +"%D - %R")" ftpmaster@ftp-master.debian.org
+ rm -f "$accepted/REPORT"
+ dak process-accepted -pa -d "$accepted" > "$accepted/REPORT"
+ cat REPORT | mail -s "Install for $(date +"%D - %R")" ftpmaster@ftp-master.debian.org
chgrp debadmin REPORT
chmod 664 REPORT
}
dak generate-releases
}
-function cleanup() {
+function dakcleanup() {
log "Cleanup old packages/files"
dak clean-suites
dak clean-queues
# it has to cd first!
cd ${configdir}
- if [ "${ERR}" = "false"]; then
+ if [ "${ERR}" = "false" ]; then
set +e
fi
${FUNC} ${ARGS}
# We need logs.
LOGFILE="$logdir/dinstall.log"
-exec > "$LOGFILE" 2>&1
+exec >> "$LOGFILE" 2>&1
# usually we are not using debug logs. Set to 1 if you want them.
DEBUG=0
FUNC="updates"
TIME="External Updates"
ARGS=""
- ERR=""
+ ERR="false"
)
stage $GO
)
stage $GO
-rm -f $LOCKAC
+rm -f "$LOCK_ACCEPTED"
GO=(
FUNC="msfl"
stage $GO
GO=(
- FUNC="cleanup"
+ FUNC="dakcleanup"
TIME="cleanup"
ARGS=""
ERR=""
cat "$LOGFILE" | mail -s "Log for dinstall run of ${NOW}" cron@ftp-master.debian.org
+savelog -c ${LOGROTATE} -j "$LOGFILE"
+
# Now, at the very (successful) end of dinstall, make sure we remove
# our stage files, so the next dinstall run will do it all again.
rm -f "${stagedir}/*"
except InvalidDscError, line:
utils.warn("syntax error in .dsc file '%s', line %s." % (f, line))
count += 1
+ except ChangesUnicodeError:
+ utils.warn("found invalid changes file, not properly utf-8 encoded")
+ count += 1
if count:
utils.warn("Found %s invalid .dsc files." % (count))
try:
changes = utils.parse_changes(filename)
files = utils.build_file_list(changes)
+ except ChangesUnicodeError:
+ utils.warn("Improperly encoded changes file, not utf-8")
+ return
except:
utils.warn("Error parsing changes file '%s'" % (filename))
return
foldable_output(changes_filename, "changes", changes, norow=True)
def check_changes (changes_filename):
- changes = utils.parse_changes (changes_filename)
+ try:
+ changes = utils.parse_changes (changes_filename)
+ except ChangesUnicodeError:
+ utils.warn("Encoding problem with changes file %s" % (changes_filename))
display_changes(changes['distribution'], changes_filename)
files = utils.build_file_list(changes)
('h',"help","Dinstall::Options::Help"),
('n',"no-action","Dinstall::Options::No-Action"),
('p',"no-lock", "Dinstall::Options::No-Lock"),
- ('s',"no-mail", "Dinstall::Options::No-Mail")]
+ ('s',"no-mail", "Dinstall::Options::No-Mail"),
+ ('d',"directory", "Dinstall::Options::Directory")]
- for i in ["automatic", "help", "no-action", "no-lock", "no-mail", "version"]:
+ for i in ["automatic", "help", "no-action", "no-lock", "no-mail",
+ "version", "directory"]:
if not Cnf.has_key("Dinstall::Options::%s" % (i)):
Cnf["Dinstall::Options::%s" % (i)] = ""
if Options["Help"]:
usage()
+ # If we have a directory flag, use it to find our files
+ if Cnf["Dinstall::Options::Directory"] != "":
+ # Note that we clobber the list of files we were given in this case
+ # so warn if the user has done both
+ if len(changes_files) > 0:
+ utils.warn("Directory provided so ignoring files given on command line")
+
+ changes_files = utils.get_changes_files(Cnf["Dinstall::Options::Directory"])
+
Upload = queue.Upload(Cnf)
projectB = Upload.projectB
suite_id = database.get_suite_id(suite)
projectB.query("INSERT INTO bin_associations (suite, bin) VALUES (%d, currval('binaries_id_seq'))" % (suite_id))
+ orig_tar_id = Upload.pkg.orig_tar_id
+ orig_tar_location = Upload.pkg.orig_tar_location
+
# If this is a sourceful diff only upload that is moving
# cross-component we need to copy the .orig.tar.gz into the new
# component too for the same reasons as above.
('h',"help","Dinstall::Options::Help"),
('n',"no-action","Dinstall::Options::No-Action"),
('p',"no-lock", "Dinstall::Options::No-Lock"),
- ('s',"no-mail", "Dinstall::Options::No-Mail")]
+ ('s',"no-mail", "Dinstall::Options::No-Mail"),
+ ('d',"directory", "Dinstall::Options::Directory")]
for i in ["automatic", "help", "no-action", "no-lock", "no-mail",
- "override-distribution", "version"]:
+ "override-distribution", "version", "directory"]:
Cnf["Dinstall::Options::%s" % (i)] = ""
changes_files = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv)
if Options["Help"]:
usage()
+ # If we have a directory flag, use it to find our files
+ if Cnf["Dinstall::Options::Directory"] != "":
+ # Note that we clobber the list of files we were given in this case
+ # so warn if the user has done both
+ if len(changes_files) > 0:
+ utils.warn("Directory provided so ignoring files given on command line")
+
+ changes_files = utils.get_changes_files(Cnf["Dinstall::Options::Directory"])
+
Upload = queue.Upload(Cnf)
changes = Upload.pkg.changes
except ParseChangesError, line:
reject("%s: parse error, can't grok: %s." % (filename, line))
return 0
+ except ChangesUnicodeError:
+ reject("%s: changes file not proper utf-8" % (filename))
+ return 0
# Parse the Files field from the .changes into another dictionary
try:
reject("%s: parse error, can't grok: %s." % (dsc_filename, line))
except InvalidDscError, line:
reject("%s: syntax error on line %s." % (dsc_filename, line))
+ except ChangesUnicodeError:
+ reject("%s: dsc file not proper utf-8." % (dsc_filename))
+
# Build up the file list of files mentioned by the .dsc
try:
dsc_files.update(utils.build_file_list(dsc, is_a_dsc=1))
"NoFreeFilenameError": """Exception raised when no alternate filename was found.""",
"TransitionsError": """Exception raised when transitions file can't be parsed.""",
"NoSourceFieldError": """Exception raised - we cant find the source - wtf?""",
- "DBUpdateError": """Exception raised - could not update the database"""
+ "DBUpdateError": """Exception raised - could not update the database""",
+ "ChangesUnicodeError": """Exception raised - changes file not properly utf-8 encoded"""
} #: All dak exceptions
def construct_dak_exception(name, description):
changes_in = open_file(filename)
content = changes_in.read()
changes_in.close()
+ try:
+ unicode(content, 'utf-8')
+ except UnicodeError:
+ raise ChangesUnicodeError, "Changes file not proper utf-8"
return parse_deb822(content, signing_rules)
################################################################################
################################################################################
+def get_changes_files(dir):
+ """
+ Takes a directory and lists all .changes files in it (as well as chdir'ing
+ to the directory; this is due to broken behaviour on the part of p-u/p-a
+ when you're not in the right place)
+
+ Returns a list of filenames
+ """
+ try:
+ # Much of the rest of p-u/p-a depends on being in the right place
+ os.chdir(dir)
+ changes_files = [x for x in os.listdir(dir) if x.endswith('.changes')]
+ except OSError, e:
+ fubar("Failed to read list from directory %s (%s)" % (dir, e))
+
+ return changes_files
+
+################################################################################
+
apt_pkg.init()
Cnf = apt_pkg.newConfiguration()