+++ /dev/null
-This is a collection of patches and fixes/hacks. The fixes/hacks are
-very specific to Debian at the time they were written. They are
-retained here mostly for hysterical raisans and hysetiria's way of
-repeating itself, so I don't have to rewrite these disgusting hacks.
-Please don't use them, or better yet, even read them.
-
---
-James
-
+++ /dev/null
-#!/usr/bin/env python
-
-# Populate the DB
-# Copyright (C) 2000 James Troup <james@nocrew.org>
-# $Id: fix.1,v 1.1 2000-11-24 00:20:11 troup Exp $
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-# 04:36|<aj> elmo: you're making me waste 5 seconds per architecture!!!!!! YOU BASTARD!!!!!
-
-################################################################################
-
-# This code is a horrible mess for two reasons:
-
-# (o) For Debian's usage, it's doing something like 160k INSERTs,
-# even on auric, that makes the program unusable unless we get
-# involed in sorts of silly optimization games (local dicts to avoid
-# redundant SELECTS, using COPY FROM rather than INSERTS etc.)
-
-# (o) It's very site specific, because I don't expect to use this
-# script again in a hurry, and I don't want to spend any more time
-# on it than absolutely necessary.
-
-###############################################################################################################
-
-import commands, os, pg, re, sys, string, tempfile
-import apt_pkg
-import db_access, utils
-
-###############################################################################################################
-
-re_arch_from_filename = re.compile(r"binary-[^/]+")
-
-###############################################################################################################
-
-Cnf = None;
-projectB = None;
-files_id_cache = {};
-source_cache = {};
-arch_all_cache = {};
-binary_cache = {};
-#
-files_id_serial = 0;
-source_id_serial = 0;
-src_associations_id_serial = 0;
-dsc_files_id_serial = 0;
-files_query_cache = None;
-source_query_cache = None;
-src_associations_query_cache = None;
-dsc_files_query_cache = None;
-orig_tar_gz_cache = {};
-#
-binaries_id_serial = 0;
-binaries_query_cache = None;
-bin_associations_id_serial = 0;
-bin_associations_query_cache = None;
-#
-source_cache_for_binaries = {};
-
-###############################################################################################################
-
-# Prepares a filename or directory (s) to be file.filename by stripping any part of the location (sub) from it.
-def poolify (s, sub):
- for i in xrange(len(sub)):
- if sub[i:] == s[0:len(sub)-i]:
- return s[len(sub)-i:];
- return s;
-
-##############################################################################################################
-
-def get_or_set_files_id (filename, size, md5sum, location_id):
- global files_id_cache, files_id_serial, files_query_cache;
-
- cache_key = string.join((filename, size, md5sum, repr(location_id)), '~')
- if not files_id_cache.has_key(cache_key):
- files_id_serial = files_id_serial + 1
- files_query_cache.write("%d\t%s\t%s\t%s\t%d\n" % (files_id_serial, filename, size, md5sum, location_id));
- files_id_cache[cache_key] = files_id_serial
-
- return files_id_cache[cache_key]
-
-##############################################################################################################
-def process_packages (location, filename, suite, component, archive):
- global arch_all_cache, binary_cache, binaries_id_serial, binaries_query_cache, bin_associations_id_serial, bin_associations_query_cache;
-
- apt_pkg.init();
-
- Cnf = apt_pkg.newConfiguration();
- apt_pkg.ReadConfigFileISC(Cnf,'/home/troup/katie/katie.conf');
-
- projectB = pg.connect('projectb', 'localhost', -1, None, None, 'postgres')
-
- db_access.init (Cnf, projectB);
-
- count_total = 0;
- count_bad = 0;
- suite = string.lower(suite);
- suite_id = db_access.get_suite_id(suite);
- if suite == "stable":
- testing_id = db_access.get_suite_id("testing");
- suite_codename = Cnf["Suite::%s::CodeName" % (suite)];
- try:
- file = utils.open_file (filename, "r")
- except utils.cant_open_exc:
- print "WARNING: can't open '%s'" % (filename);
- return;
- Scanner = apt_pkg.ParseTagFile(file);
- while Scanner.Step() != 0:
- package = Scanner.Section["package"]
- version = Scanner.Section["version"]
- maintainer = Scanner.Section["maintainer"]
- maintainer = string.replace(maintainer, "'", "\\'")
- maintainer_id = db_access.get_or_set_maintainer_id(maintainer);
- architecture = Scanner.Section["architecture"]
- architecture_id = db_access.get_architecture_id (architecture);
- if not Scanner.Section.has_key("source"):
- source = package
- else:
- source = Scanner.Section["source"]
- source_version = ""
- if string.find(source, "(") != -1:
- m = utils.re_extract_src_version.match(source)
- source = m.group(1)
- source_version = m.group(2)
- if not source_version:
- source_version = version
- xfilename = Scanner.Section["filename"]
- filename = xfilename
- location_id = db_access.get_location_id (location, component, archive)
- filename = poolify (filename, location)
- if architecture == "all":
- filename = re_arch_from_filename.sub("binary-all", filename);
- cache_key = "%s~%s" % (source, source_version);
- source_id = source_cache_for_binaries.get(cache_key, None);
- size = Scanner.Section["size"];
- md5sum = Scanner.Section["md5sum"];
- files_id = get_or_set_files_id (filename, size, md5sum, location_id);
- cache_key = "%s~%s~%s~%d~%d~%d" % (package, version, repr(source_id), architecture_id, location_id, files_id);
- if not arch_all_cache.has_key(cache_key):
- arch_all_cache[cache_key] = 1;
- cache_key = "%s~%s~%d" % (package, version, architecture_id);
- if not binary_cache.has_key(cache_key):
- binary_cache[cache_key] = (size, md5sum);
- else:
- (oldsize, oldmd5sum) = binary_cache[cache_key];
- if oldsize != size or oldmd5sum != md5sum:
- #print "/org/ftp.debian.org/ftp/%s" % (xfilename);
- print "%s: %s vs. %s and %s vs. %s" % (xfilename, oldsize, size, oldmd5sum, md5sum);
- #count_bad = count_bad + 1;
-
- count_total = count_total +1;
-
- file.close();
- if count_bad != 0:
- print "Found %d bad." % (count_bad)
-
-##############################################################################################################
-
-def main ():
- global Cnf, projectB, query_cache, files_query_cache, source_query_cache, src_associations_query_cache, dsc_files_query_cache, bin_associations_query_cache, binaries_query_cache;
-
- apt_pkg.init();
-
- Cnf = apt_pkg.newConfiguration();
- apt_pkg.ReadConfigFileISC(Cnf,'/home/troup/katie/katie.conf');
-
- files_query_cache = utils.open_file(Cnf["Neve::ExportDir"]+"files","w");
- source_query_cache = utils.open_file(Cnf["Neve::ExportDir"]+"source","w");
- src_associations_query_cache = utils.open_file(Cnf["Neve::ExportDir"]+"src_associations","w");
- dsc_files_query_cache = utils.open_file(Cnf["Neve::ExportDir"]+"dsc_files","w");
- binaries_query_cache = utils.open_file(Cnf["Neve::ExportDir"]+"binaries","w");
- bin_associations_query_cache = utils.open_file(Cnf["Neve::ExportDir"]+"bin_associations","w");
-
- # Process Packages files to populate `binaries' and friends
-
- for location in Cnf.SubTree("Location").List():
- SubSec = Cnf.SubTree("Location::%s" % (location));
- server = SubSec["Archive"];
- if server != "ftp-master": # FIXME, don't hard code
- continue;
- type = Cnf.Find("Location::%s::Type" % (location));
- if type == "legacy-mixed":
- packages = location + 'Packages';
- suite = Cnf.Find("Location::%s::Suite" % (location));
- process_packages (location, packages, suite, "", server);
- elif type == "legacy":
- for suite in Cnf.SubTree("Location::%s::Suites" % (location)).List():
- for component in Cnf.SubTree("Component").List():
- for architecture in Cnf.SubTree("Suite::%s::Architectures" % (suite)).List():
- if architecture == "source" or architecture == "all":
- continue;
- packages = location + Cnf.Find("Suite::%s::CodeName" % (suite)) + '/' + component + '/binary-' + architecture + '/Packages'
- process_packages (location, packages, suite, component, server);
- elif type == "pool":
- continue;
-
- files_query_cache.close();
- source_query_cache.close();
- src_associations_query_cache.close();
- dsc_files_query_cache.close();
- binaries_query_cache.close();
- bin_associations_query_cache.close();
-
- return;
-
-if __name__ == '__main__':
- main()
+++ /dev/null
-#!/usr/bin/env python
-
-import commands, os, string, sys
-import apt_inst, apt_pkg
-import utils
-
-Cnf = None
-
-def main():
- global Cnf
-
- apt_pkg.init();
-
- Cnf = apt_pkg.newConfiguration();
- apt_pkg.ReadConfigFileISC(Cnf,'/home/troup/katie/katie.conf');
-
- Arguments = [];
-
- dsc_files = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv);
-
- for dsc_file in dsc_files:
- dsc = utils.parse_changes(dsc_file);
- files = utils.build_file_list(dsc, 1);
- for file in files.keys():
- if not os.path.exists(file):
- (result, output) = commands.getstatusoutput("locate %s | grep /org/ftp.debian.org/ftp/dists/potato/" % (file));
- if (result != 0):
- print "%s: can't find '%s'." % (dsc_file, file);
- continue;
- output = string.replace(output, "/org/ftp.debian.org/ftp/dists/potato/", "../potato/");
- print "symlinking '%s' to '%s'." % (output, file);
- os.symlink(output, file);
-
-if __name__ == '__main__':
- main()
-
+++ /dev/null
-#!/bin/sh
-
-# restore binary-all links
-# Copyright (C) 2000 James Troup <james@nocrew.org>
-
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
-# published by the Free Software Foundation; either version 2 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-# WARNING: this is a quick hack to fix several architectures in sid;
-# it has lots of things hardcoded when they shouldn't be etc.
-
-#######################################################################
-source `dirname $0`/vars
-
-# defaults
-
-dry_run=no
-
-#######################################################################
-
-count=0
-
-# Write usage message
-usage() {
- echo "usage: $progname [-n] architecture" 1>&2
-}
-
-# Write error message to stderr and quit.
-error() {
- echo "$progname: $@" 1>&2
- exit 1
-}
-
-# Check for at least one argument
-if [ $# -eq 0 ]; then
- usage
- exit 1
-fi
-
-# Parse options
-progname="$0"
-loop=yes
-while [ $loop = yes ]
-do
- case "$1" in
- -n|--dry-run) dry_run="yes"; shift 1;;
- --) shift; loop=no ;;
- -h|--help) usage; exit 0 ;;
- -*) error "unknown option $1" ;;
- *) loop=no ;;
- esac
-done
-
-cd $ftp/dists/potato/
-
-if [ ! -d main/binary-$1 ]; then
- echo "Can't find arch $1"
- exit 1
-fi
-
-echo "About to run this horrible script for arch $1 which will probably break things."
-echo -n "Are you sure? [Y/n]: "
-read answer
-if [ -z "$answer" ]; then answer="y"; fi
-case "$answer" in
- n|N) echo "Aborting..";exit 0;;
- y|Y) ;;
- *) echo "E: '$answer' not understood, exiting.";rm .genreport; exit 1;;
-esac
-
-for j in main non-free contrib; do
- for i in $(find $j/binary-all/ ! -type d); do
- dir=$(dirname $i | sed -e "s/binary-all/binary-$1/")
- pushd $dir >/dev/null
- if [ ! -e $(basename $i) ]; then
- if [ "$dry_run" = "no" ]; then
- echo "Linking to $i"
- ln -s ../../../$i .
- else
- echo "Would link to $i"
- fi
- count=$(expr $count + 1)
- fi
- popd > /dev/null
- done
-done
-
-echo "Added $count links."
+++ /dev/null
-#!/bin/sh
-
-dir=/org/ftp.debian.org/ftp/dists/woody/
-
-for component in main non-free contrib; do # non-free contrib
- for i in $(find $dir/$component/binary-all/ -type f); do
- new=$(find $dir/$component/binary-i386/ -type f -name $(basename $i | sed -e "s/_.*//")_\*);
- if [ ! -z "$new" ]; then
- oldver=$(dpkg-deb -f $i version)
- newver=$(dpkg-deb -f $new version)
- if dpkg --compare-versions $oldver gt $newver; then
- echo EEH???
- echo $(basename $i) dominates $(basename $new) ???;
- fi;
- if dpkg --compare-versions $oldver eq $newver; then
- #echo $(basename $i) equals $(basename $new);
- true;
- fi;
- if dpkg --compare-versions $oldver lt $newver; then
- echo \# $(basename $new) \(arch: any\) DOMINATES $(basename $i) \(arch: all\);
- echo mv -iv $i ~troup/removed-from-ftp/all/
- fi;
- fi;
- done
-done
-
-echo
-echo \# Cleanup dangling symlinks
-echo symlinks -rd $dir
+++ /dev/null
-#!/usr/bin/env python
-
-import pg, string, os, shutil
-import utils
-import apt_pkg
-
-def move(src, dest):
- if os.path.exists(dest):
- print 'overwrite `'+dest+'\'? ',
- yn = utils.our_raw_input()
- if yn != 'Y' and yn != 'y':
- return
- print src + ' -> ' + dest
- shutil.copyfile (src, dest)
- os.unlink (src)
-
-def main():
- projectB = pg.connect('projectb', 'localhost')
-
- apt_pkg.init();
-
- suite = "unstable";
- architecture = "i386";
-
-# too slow to run every time
-# "select b.package from binaries b, architecture a where a.arch_string = 'all' and b.architecture = a.id INTERSECT select b.package from binaries b, architecture a where a.arch_string = 'i386' and b.architecture = a.id;"
-
- borked = utils.open_file('broken', 'r')
- for line in borked.readlines():
- package = string.strip(line[:-1])
-
- #print "========="
- #print package
- q = projectB.query("SELECT b.version, a.arch_string, l.path, b.filename FROM bin_associations ba, binaries b, architecture a, suite s, location l WHERE b.package = '%s' AND (a.arch_string = '%s' OR a.arch_string = 'all') AND s.suite_name = '%s' AND ba.bin = b.id AND ba.suite = s.id AND b.architecture = a.id AND l.id = b .location" % (package, architecture, suite))
- entries = q.getresult()
- version = {}
- filename = ""
- for entry in entries:
- version[entry[1]] = entry[0]
- if entry[1] == "all":
- filename = entry[2] + entry[3]
- if not version.has_key(architecture) or not version.has_key("all"):
- #print "SKIPPING"
- continue
- if apt_pkg.VersionCompare(version[architecture], version["all"]) != 1:
- #print architecture+" too new... SKIPPING"
- continue
- #print " "+repr(version)
- if os.path.exists(filename):
- if os.path.islink(filename):
- print "FIXING: unlinking %s" % (filename);
- os.unlink(filename);
- else:
- print "FIXING: moving %s to /home/troup/removed-from-ftp/foad/" % (filename);
- move(filename, "/home/troup/removed-from-ftp/foad/%s" % (os.path.basename(filename)));
-
-if __name__ == '__main__':
- main()
-
+++ /dev/null
-#!/bin/sh
-
-# "I tried to understand you.. I tried to love you right"
-
-dists=/org/ftp.debian.org/ftp/dists/
-dir=$dists/woody/
-
-for i in main contrib non-free; do # main contrib non-free
- for j in arm; do # hurd-i386 hppa mips mipsel sh
- echo "Processing $j ($i)..."
- for k in $(find $dir/$i/binary-$j/ -type l); do
- dest=$(readlink $k)
- echo $dest | grep -q /binary-all/
- if [ $? -eq 0 ]; then
- file=$(basename $k)
- woody=$(find $dists/woody/$i/binary-all/ -name $file)
- if [ -z "$woody" ]; then
- echo "Killing link to $file";
- rm $k
- fi
- fi
- done
- done
-done
+++ /dev/null
-#!/bin/sh
-
-total=0
-
-for i in $(cat foo.2); do
- if [ -f $i -a ! -L $i ]; then
- dir=$(dirname $i)
- file=$(basename $i)
- size=$(du -b $i | cut -f 1)
- arch=$(echo $i | sed -e "s#.*binary-\([a-z]*\).*#\1#")
- pushd $dir > /dev/null
- destdir=/home/troup/removed-from-ftp/badmd5-$arch/
- if [ ! -d $destdir ]; then mkdir $destdir; fi
- mv -iv $file $destdir/
- ln -s ../../../../potato/$(echo $i | sed -e "s#.*woody/##") .
- popd > /dev/null
- total=$(expr $total + $size)
- fi
-done
-
-echo
-echo "Replaced $total bytes."
-
+++ /dev/null
-#!/usr/bin/env python
-
-# Fix for bug in katie where dsc_files was initialized from changes and not dsc
-# Copyright (C) 2000 James Troup <james@nocrew.org>
-# $Id: fix.9,v 1.3 2001-11-04 22:28:44 troup Exp $
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-# "Look around... leaves are brown... and the sky is hazy shade of winter,
-# Look around... leaves are brown... there's a patch of snow on the ground."
-# -- Simon & Garfunkel / 'A Hazy Shade'
-
-################################################################################
-
-import pg, sys, os, string, stat
-import utils, db_access
-import apt_pkg;
-
-################################################################################
-
-Cnf = None;
-projectB = None;
-
-################################################################################
-
-def main ():
- global Cnf, projectB;
-
- apt_pkg.init();
-
- Cnf = apt_pkg.newConfiguration();
- apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file());
-
- Arguments = [('d',"debug","Claire::Options::Debug", "IntVal"),
- ('h',"help","Claire::Options::Help"),
- ('v',"version","Claire::Options::Version")];
-
- apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv);
-
- projectB = pg.connect('projectb', 'localhost');
-
- db_access.init(Cnf, projectB);
-
- for dsc_file in sys.stdin.readlines():
- dsc_file = dsc_file[:-1];
- base_dsc_file = os.path.basename(dsc_file);
- print dsc_file
- dsc = utils.parse_changes(dsc_file);
- dsc_files = utils.build_file_list(dsc, 1);
- q = projectB.query("SELECT s.id, l.id, l.path FROM source s, location l, files f WHERE s.source = '%s' AND s.version = '%s' AND f.id = s.file AND f.location = l.id" % (dsc["source"], dsc["version"]));
- ql = q.getresult();
- if not ql or len(ql) > 1:
- print " EEEEEEEEEEEEEEK!!!"
- print " ",base_dsc_file
- source_id = ql[0][0];
- location_id = ql[0][1];
- location = ql[0][2];
- dsc_files[base_dsc_file] = {};
- dsc_files[base_dsc_file]["size"] = os.stat(dsc_file)[stat.ST_SIZE];
- dsc_files[base_dsc_file]["md5sum"] = apt_pkg.md5sum(utils.open_file(dsc_file,"r"));
- q = projectB.query("SELECT f.filename FROM dsc_files df, source s, files f WHERE s.id = '%s' AND df.source = s.id AND f.id = df.file" % (source_id));
- for i in q.getresult():
- file = os.path.basename(i[0]);
- if not dsc_files.has_key(file):
- if file != base_dsc_file:
- print " MWAAAP! MWAAP! Can't find %s!" % (file)
- else:
- del dsc_files[file];
- for i in dsc_files.keys():
- filename = os.path.dirname(dsc_file) + '/' + i;
- if not os.path.exists(filename):
- print " MWAAP!!!!!!!!!!!!!"
- print filename
- filename = string.replace(filename, location, '');
- #print " filename: ",filename
- #print " size: ", dsc_files[i]["size"]
- #print " md5sum: ",dsc_files[i]["md5sum"]
- #print " location_id: ", location_id
- files_id = db_access.get_files_id(filename, dsc_files[i]["size"], dsc_files[i]["md5sum"], location_id);
- if files_id < 0 or files_id == None:
- print " BORK!!!!!!!!!!!!"
- print " ",filename
- else:
- foo = 1
- #print "INSERT INTO dsc_files (source, file) VALUES ('%s', '%s')" % (source_id, files_id);
- projectB.query("INSERT INTO dsc_files (source, file) VALUES ('%s', '%s')" % (source_id, files_id));
- print " doh:",i
-
-#######################################################################################
-
-if __name__ == '__main__':
- main()
-
+++ /dev/null
-#!/usr/bin/env python
-
-# Fix for bug in katie where dsc_files was initialized from changes and not dsc
-# Copyright (C) 2000 James Troup <james@nocrew.org>
-# $Id: fix.b,v 1.1 2000-12-19 17:23:03 troup Exp $
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-# "Look around... leaves are brown... and the sky is hazy shade of winter,
-# Look around... leaves are brown... there's a patch of snow on the ground."
-# -- Simon & Garfunkel / 'A Hazy Shade'
-
-################################################################################
-
-import pg, sys, os, string, stat, re
-import utils, db_access
-import apt_pkg;
-
-################################################################################
-
-Cnf = None;
-projectB = None;
-
-bad_arch = re.compile(r'/binary-(hppa|mips|mipsel|sh|hurd-i386)/');
-
-################################################################################
-
-def main ():
- global Cnf, projectB;
-
- apt_pkg.init();
-
- Cnf = apt_pkg.newConfiguration();
- apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file());
-
- Arguments = [('d',"debug","Claire::Options::Debug", "IntVal"),
- ('h',"help","Claire::Options::Help"),
- ('v',"version","Claire::Options::Version")];
-
- apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv);
-
- projectB = pg.connect('projectb', 'localhost');
-
- db_access.init(Cnf, projectB);
-
- file = utils.open_file('x', 'r');
- for line in file.readlines():
- if string.find(line, '/binary-') != -1:
- if bad_arch.search(line) != None:
- new_line = string.replace(line, 'woody/', 'sid/');
- if new_line == line:
- print line;
- sys.exit(2);
- line = new_line;
- sys.stdout.write(line);
-
-#######################################################################################
-
-if __name__ == '__main__':
- main()
-
+++ /dev/null
-#!/usr/bin/env python
-
-# Quick hack to import override files
-# Copyright (C) 2000 James Troup <james@nocrew.org>
-# $Id: hack.1,v 1.2 2001-01-16 21:52:37 troup Exp $
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-import os, pg, sys, string
-import utils, db_access
-import apt_pkg;
-
-################################################################################
-
-Cnf = None;
-projectB = None;
-
-################################################################################
-
-def main ():
- global Cnf, projectB;
-
- apt_pkg.init();
-
- Cnf = apt_pkg.newConfiguration();
- apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file());
- Arguments = [('D',"debug","Alyson::Options::Debug", "IntVal"),
- ('h',"help","Alyson::Options::Help"),
- ('v',"version","Alyson::Options::Version")];
- apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv);
-
- projectB = pg.connect('projectb', 'localhost');
- db_access.init(Cnf, projectB);
-
- for filename in os.listdir('.'):
- if not os.path.isfile(filename) or filename[:9] != 'override.':
- continue;
- x = string.split(filename, '.')
- suite = x[1];
- type = "deb";
- if suite == "experimental":
- continue;
- else:
- component = x[2];
- if suite == "sid":
- suite = "unstable";
- elif suite == "potato":
- suite = "stable";
- else:
- print "say what?";
- sys.exit(3);
- if len(x) == 4:
- type = x[3];
- if type == "debian-installer":
- type = "udeb";
- elif type == "src":
- type = "dsc";
- else:
- print "say WHAT?";
- sys.exit(4);
- print "cat %s | natalie.py --set --suite=%s --component=%s --type=%s" % (filename, suite, component, type);
-
-#######################################################################################
-
-if __name__ == '__main__':
- main()
-
+++ /dev/null
-#!/usr/bin/env python
-
-import os, pg, stat, string, sys
-import utils, db_access
-import apt_pkg, apt_inst;
-
-
-def remove(file):
- dir = '/org/ftp.debian.org/morgue/shania/'
- if os.access(file,os.R_OK) == 0:
- sys.stderr.write("E: can't read '%s' to remove it.\n" % (file));
- return;
- dest = dir + os.path.basename(file);
- if os.path.exists(dest):
- sys.stderr.write("E: '%s' already exists in '%s'.\n" % (file, dir));
- return;
- print "%s -> %s" % (file, dir);
- utils.move(file, dest);
- return;
-
-def main ():
- for changes_file in sys.argv[1:]:
- try:
- changes = utils.parse_changes(changes_file, 0);
- except:
- sys.stderr.write("E: caught exception parsing '%s' [%s].\n" % (changes_file, sys.exc_type));
- continue;
- try:
- files = utils.build_file_list(changes, "");
- except:
- sys.stderr.write("E: caught exception building file list for '%s' [%s].\n" % (changes_file, sys.exc_type));
- continue;
- for file in files.keys():
- remove(file);
- remove(changes_file);
-
-#######################################################################################
-
-if __name__ == '__main__':
- main()
-
+++ /dev/null
-#!/usr/bin/env python
-
-# Whee! Fix testing fubarity
-# Copyright (C) 2000, 2001 James Troup <james@nocrew.org>
-# $Id: hack.3,v 1.1 2001-03-14 20:32:05 troup Exp $
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-# Computer games don't affect kids. I mean if Pacman affected our generation as
-# kids, we'd all run around in a darkened room munching pills and listening to
-# repetitive music.
-# -- Unknown
-
-################################################################################
-
-import pg, sys, os, string, stat
-import utils, db_access
-import apt_pkg;
-
-################################################################################
-
-Cnf = None;
-projectB = None;
-
-################################################################################
-
-def main ():
- global Cnf, projectB, db_files, waste, excluded;
-
- apt_pkg.init();
-
- Cnf = apt_pkg.newConfiguration();
- apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file());
-
- Arguments = [('d',"debug","Christina::Options::Debug", "IntVal"),
- ('h',"help","Christina::Options::Help"),
- ('v',"version","Christina::Options::Version")];
-
- apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv);
- projectB = pg.connect('projectb', 'localhost');
- christina = pg.connect('christina', 'localhost');
- db_access.init(Cnf, projectB);
-
- q = christina.query("""
-SELECT l.path, f.filename, b.package, b.version, b.architecture, a.arch_string
- FROM bin_associations ba, binaries b, files f, location l, architecture a
- WHERE ba.suite = 4 AND ba.bin = b.id AND f.id = b.file
- AND f.location = l.id AND a.id = b.architecture;""");
- ql = q.getresult();
-
- for i in ql:
- filename = i[0] + i[1]
- if not os.path.exists(filename):
- package = i[2];
- testing_version = i[3];
- architecture_id = i[4];
- architecture = i[5];
- x = projectB.query("SELECT b.id, b.version FROM bin_associations ba, binaries b WHERE ba.suite = 5 AND ba.bin = b.id AND b.package = '%s' AND b.architecture = %s" % (package, architecture_id));
- xl = x.getresult();
- new_id = xl[0][0];
- unstable_version = xl[0][1];
- #print "%s [%s]: %s ==> %s" % (package, architecture, testing_version, unstable_version);
- print "%s %s %s" % (package, unstable_version, architecture);
-
- sys.exit(0);
-
-#######################################################################################
-
-if __name__ == '__main__':
- main()
-
-
-# # And yes, I'm all too well aware of how appaling this code is;
-# # I'm so not caring right now.
-
-# # Basic plan: From a known-good backup, get a list of what should
-# # be in testing and search for every file. If it's not in the
-# # pool, check in the morgue and double check the md5sum + size.
-
-# # Binaries
-
-# q = christina.query("""
-# SELECT l.path, f.filename, f.md5sum, f.size, b.id
-# FROM bin_associations ba, binaries b, files f, location l
-# WHERE ba.suite = 4 AND ba.bin = b.id AND f.id = b.file
-# AND f.location = l.id;""");
-# ql = q.getresult();
-
-# # q = christina.query("""
-# # SELECT l.path, f.filename, f.md5sum, f.size, s.id
-# # FROM src_associations sa, source s, files f, location l, dsc_files df
-# # WHERE sa.suite = 4 AND sa.source = s.id AND f.id = df.file AND f.location = l.id
-# # AND df.source = s.id;""");
-# # ql = q.getresult();
-
-# bad_ids = {};
-# count_total = 0;
-# count_good = 0;
-# count_recoverable = 0;
-# for i in ql:
-# filename = i[0] + i[1]
-# count_total = count_total + 1;
-# if not os.path.exists(filename):
-# basename = os.path.basename(filename)
-# morgue_filename = string.join([Cnf["Dir::Morgue"],Cnf["Rhona::MorgueSubDir"],basename],'/');
-# if os.path.exists(morgue_filename):
-# db_md5sum = i[2];
-# db_size = int(i[3]);
-# try:
-# file = utils.open_file(morgue_filename, 'r');
-# except:
-# sys.stderr.write("E: can't open '%s'.\n" % (morgue_filename));
-# continue;
-# md5sum = apt_pkg.md5sum(file);
-# size = os.stat(morgue_filename)[stat.ST_SIZE];
-# if md5sum != db_md5sum:
-# #print "E: %s" % (filename);
-# #sys.stderr.write("E: **WARNING** md5sum mismatch for '%s' ('%s' [current] vs. '%s' [db]).\n" % (morgue_filename, md5sum, db_md5sum));
-# continue;
-# if size != db_size:
-# #print "E: %s" % (filename);
-# #sys.stderr.write("E: **WARNING** size mismatch for '%s' ('%s' [current] vs. '%s' [db]).\n" % (morgue_filename, size, db_size));
-# continue;
-# bad_ids[i[4]] = "";
-# print "R: %s [%s]" % (filename, morgue_filename);
-# ###utils.copy(morgue_filename, filename);
-# count_recoverable = count_recoverable + 1;
-# else:
-# #print "E: %s" % (filename);
-# baz = 0;
-# else:
-# #print "G: %s" % (filename);
-# count_good = count_good + 1;
-
-# print "Good: %d / %d (%.2f%%)" % (count_good, count_total, (float(count_good)/count_total*100));
-# print "Recoverable: %d / %d (%.2f%%)" % (count_recoverable, count_total, (float(count_recoverable)/count_total*100));
-# count_bad = count_total - count_good - count_recoverable;
-# print "Bad: %d / %d (%.2f%%)" % (count_bad, count_total, (float(count_bad)/count_total*100));
-
-# sys.exit(0);
-# projectB.query("BEGIN WORK;");
-
-# for id in bad_ids.keys():
-# q = christina.query("SELECT f.filename, f.size, f.md5sum, f.location FROM files f, binaries b WHERE b.id = %d and b.file = f.id;" % (id));
-# ql = q.getresult();
-# if len(ql) != 1:
-# sys.exit(9);
-# for i in ql:
-# filename = i[0];
-# size = i[1];
-# md5sum = i[2];
-# location_id = i[3];
-# files_id = db_access.get_files_id(filename, size, md5sum, location_id);
-# if files_id == -1:
-# sys.stderr.write("Rejected: INTERNAL ERROR, get_files_id() returned multiple matches for %s.\n" % (filename));
-# sys.exit(8);
-# elif files_id == -2:
-# sys.stderr.write("Rejected: md5sum and/or size mismatch on existing copy of %s.\n" % (filename));
-# sys.exit(8);
-# if not files_id:
-# #files_id = 42;
-# files_id = db_access.set_files_id(filename, size, md5sum, location_id);
-# print "INSERT(ed) INTO files (filename, size, md5sum, location) VALUES ('%s', %d, '%s', %d)" % (filename, long(size), md5sum, location_id);
-
-# else:
-# print "%s already exists; skipping." % (filename)
-# baz = 0;
-
-# q = christina.query("""
-# SELECT b.package, b.version, s.source, s.version, b.architecture, m.name
-# FROM binaries b, source s, maintainer m
-# WHERE b.id = %s AND s.id = b.source AND m.id = b.maintainer
-# UNION SELECT b.package, b.version, null, null, b.architecture, m.name
-# FROM binaries b, maintainer m
-# WHERE b.id = %s AND b.source is null AND b.maintainer = m.id;""" % (id, id));
-# ql = q.getresult();
-# if len(ql) != 1:
-# sys.exit(9);
-# for i in ql:
-# package = i[0];
-# version = i[1];
-# source_name = i[2];
-# source_version = i[3];
-# source_id = None;
-# architecture_id = i[4];
-# maintainer = i[5];
-# maintainer = string.replace(maintainer, "'", "\\'");
-# maintainer_id = db_access.get_or_set_maintainer_id(maintainer);
-# if source_name:
-# source_id = db_access.get_source_id (source_name, source_version);
-# if not source_id:
-# print "Say what?";
-# sys.exit(3);
-# if source_id:
-# print "INSERT INTO binaries (package, version, maintainer, source, architecture, file, type) VALUES ('%s', '%s', %d, %d, %d, %s, '%s')" % (package, version, maintainer_id, source_id, architecture_id, files_id, "deb");
-# projectB.query("INSERT INTO binaries (package, version, maintainer, source, architecture, file, type) VALUES ('%s', '%s', %d, %d, %d, %s, '%s')" % (package, version, maintainer_id, source_id, architecture_id, files_id, "deb"));
-# else:
-# print "INSERT INTO binaries (package, version, maintainer, architecture, file, type) VALUES ('%s', '%s', %d, %d, %s, '%s')" % (package, version, maintainer_id, architecture_id, files_id, "deb");
-# projectB.query("INSERT INTO binaries (package, version, maintainer, architecture, file, type) VALUES ('%s', '%s', %d, %d, %s, '%s')" % (package, version, maintainer_id, architecture_id, files_id, "deb"));
-
-# projectB.query("COMMIT WORK;");
-
-# sys.exit(0);
-
-
-
-
-# ## source .. already done
-# projectB.query("BEGIN WORK;");
-
-# for id in bad_ids.keys():
-# q = christina.query("SELECT f.filename, f.md5sum, f.size, f.location FROM files f, dsc_files df WHERE df.source = %s and f.id = df.file;""" % (id));
-# ql = q.getresult();
-# for i in ql:
-# filename = i[0];
-# md5sum = i[1];
-# size = i[2];
-# location_id = i[3];
-# files_id = db_access.get_files_id(filename, size, md5sum, location_id);
-# if files_id == -1:
-# sys.stderr.write("Rejected: INTERNAL ERROR, get_files_id() returned multiple matches for %s.\n" % (filename));
-# sys.exit(8);
-# elif files_id == -2:
-# sys.stderr.write("Rejected: md5sum and/or size mismatch on existing copy of %s.\n" % (filename));
-# sys.exit(8);
-# if not files_id:
-# #files_id = 42;
-# files_id = db_access.set_files_id(filename, size, md5sum, location_id);
-# print "INSERT(ed) INTO files (filename, size, md5sum, location) VALUES ('%s', %d, '%s', %d)" % (filename, long(size), md5sum, location_id);
-
-# else:
-# print "%s already exists; skipping." % (filename)
-# if filename[-4:] == '.dsc':
-# dsc_files_id = files_id;
-# print "--"
-
-# q = christina.query("SELECT s.source, s.version, m.name FROM source s, maintainer m WHERE s.id = %s and s.maintainer = m.id;""" % (id));
-# ql = q.getresult();
-# if len(ql) != 1:
-# sys.exit(9);
-# for i in ql:
-# source = i[0]
-# version = i[1];
-# maintainer = i[2];
-# maintainer_id = db_access.get_or_set_maintainer_id(maintainer);
-# print "INSERT INTO source (source, version, maintainer, file) VALUES ('%s', '%s', %d, %d)" % (source, version, maintainer_id, dsc_files_id);
-# projectB.query("INSERT INTO source (source, version, maintainer, file) VALUES ('%s', '%s', %d, %d)" % (source, version, maintainer_id, dsc_files_id));
-
-# projectB.query("COMMIT WORK;");
-
-
-
-
-
-# def nevermind():
-# new_bad_ids = {};
-# qx = christina.query("SELECT l.path, f.filename, f.md5sum, f.size, s.id FROM source s, files f, location l, dsc_files df WHERE f.id = df.file AND f.location = l.id AND df.source = s.id AND s.source = '%s' AND s.version = '%s';" % (source_name, source_version));
-# qxl = qx.getresult();
-# for ix in qxl:
-# filename = ix[0] + ix[1]
-# if os.path.exists(filename):
-# continue;
-# basename = os.path.basename(filename)
-# morgue_filename = string.join([Cnf["Dir::Morgue"],Cnf["Rhona::MorgueSubDir"],basename],'/');
-# if os.path.exists(morgue_filename):
-# db_md5sum = ix[2];
-# db_size = int(ix[3]);
-# try:
-# file = utils.open_file(morgue_filename, 'r');
-# except:
-# sys.stderr.write("E: can't open '%s'.\n" % (morgue_filename));
-# continue;
-# md5sum = apt_pkg.md5sum(file);
-# size = os.stat(morgue_filename)[stat.ST_SIZE];
-# if md5sum != db_md5sum:
-# sys.stderr.write("E: **WARNING** md5sum mismatch for '%s' ('%s' [current] vs. '%s' [db]).\n" % (morgue_filename, md5sum, db_md5sum));
-# continue;
-# if size != db_size:
-# sys.stderr.write("E: **WARNING** size mismatch for '%s' ('%s' [current] vs. '%s' [db]).\n" % (morgue_filename, size, db_size));
-# continue;
-# new_bad_ids[ix[4]] = "";
-# print "R: %s [%s]" % (filename, morgue_filename);
-# utils.copy(morgue_filename, filename);
-# else:
-# print "E: %s" % (filename);
-
-# projectB.query("BEGIN WORK;");
-
-# for new_id in new_bad_ids.keys():
-# qx = christina.query("SELECT f.filename, f.md5sum, f.size, f.location FROM files f, dsc_files df WHERE df.source = %s and f.id = df.file;""" % (new_id));
-# qlx = qx.getresult();
-# for ix in qlx:
-# filename = ix[0];
-# md5sum = ix[1];
-# size = ix[2];
-# location_id = ix[3];
-# files_id = db_access.get_files_id(filename, size, md5sum, location_id);
-# if files_id == -1:
-# sys.stderr.write("Rejected: INTERNAL ERROR, get_files_id() returned multiple matches for %s.\n" % (filename));
-# sys.exit(8);
-# elif files_id == -2:
-# sys.stderr.write("Rejected: md5sum and/or size mismatch on existing copy of %s.\n" % (filename));
-# sys.exit(8);
-# if not files_id:
-# #files_id = 42;
-# files_id = db_access.set_files_id(filename, size, md5sum, location_id);
-# print "INSERT(ed) INTO files (filename, size, md5sum, location) VALUES ('%s', %d, '%s', %d)" % (filename, long(size), md5sum, location_id);
-# else:
-# print "%s already exists; skipping." % (filename)
-# if filename[-4:] == '.dsc':
-# dsc_files_id = files_id;
-# print "--"
-
-# qx = christina.query("SELECT s.source, s.version, m.name FROM source s, maintainer m WHERE s.id = %s and s.maintainer = m.id;""" % (new_id));
-# qlx = qx.getresult();
-# if len(qlx) != 1:
-# sys.exit(9);
-# for ix in qlx:
-# source = ix[0];
-# version = ix[1];
-# maintainer = ix[2];
-# maintainer = string.replace(maintainer, "'", "\\'");
-# maintainer_id = db_access.get_or_set_maintainer_id(maintainer);
-# print "INSERT INTO source (source, version, maintainer, file) VALUES ('%s', '%s', %d, %d)" % (source, version, maintainer_id, dsc_files_id);
-# projectB.query("INSERT INTO source (source, version, maintainer, file) VALUES ('%s', '%s', %d, %d)" % (source, version, maintainer_id, dsc_files_id));
-# projectB.query("COMMIT WORK;");
+++ /dev/null
-#!/usr/bin/env python
-
-# Whee! Fix testing fubarity
-# Copyright (C) 2000, 2001 James Troup <james@nocrew.org>
-# $Id: hack.4,v 1.1 2001-03-14 20:32:05 troup Exp $
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-# Computer games don't affect kids. I mean if Pacman affected our generation as
-# kids, we'd all run around in a darkened room munching pills and listening to
-# repetitive music.
-# -- Unknown
-
-################################################################################
-
-import pg, sys, os, string, stat
-import utils, db_access
-import apt_pkg;
-
-################################################################################
-
-Cnf = None;
-projectB = None;
-
-################################################################################
-
-def main ():
- global Cnf, projectB, db_files, waste, excluded;
-
- apt_pkg.init();
-
- Cnf = apt_pkg.newConfiguration();
- apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file());
-
- Arguments = [('d',"debug","Christina::Options::Debug", "IntVal"),
- ('h',"help","Christina::Options::Help"),
- ('v',"version","Christina::Options::Version")];
-
- apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv);
- projectB = pg.connect('projectb', 'localhost');
- christina = pg.connect('christina', 'localhost');
- db_access.init(Cnf, projectB);
-
- # Source without dsc_file entries
- q = projectB.query("SELECT s.id, f.id, l.path, f.filename FROM source s, files f, location l WHERE NOT EXISTS (SELECT df.* FROM dsc_files df WHERE df.source = s.id) and f.id = s.file and l.id = f.location;");
- ql = q.getresult();
- projectB.query("BEGIN WORK;")
- for i in ql:
- source_id = i[0];
- dsc_file_id = i[1];
- dsc_filename = i[2] + i[3];
- dsc_dir = os.path.dirname(i[3]);
- # We get the .dsc for free
- print "INSERT INTO dsc_files (source, file) VALUES (%s, %s)" % (source_id, dsc_file_id);
- projectB.query("INSERT INTO dsc_files (source, file) VALUES (%s, %s)" % (source_id, dsc_file_id));
- # Then work out the files.id of the other files
- dsc = utils.parse_changes(dsc_filename, 0);
- dsc_files = utils.build_file_list(dsc, 1);
- for dsc_file in dsc_files.keys():
- if dsc_file[-4:] != ".dsc":
- filename = dsc_dir + '/' + dsc_file;
- x = projectB.query("SELECT id FROM files WHERE filename = '%s'" % (filename));
- xl = x.getresult();
- if len(xl) != 1:
- # No? probably s/woody/potato/ BS.. try again with ~ and only the filename
- x = projectB.query("SELECT id FROM files WHERE filename ~ '%s$'" % (utils.regex_safe(dsc_file)));
- xl = x.getresult();
- if len(xl) != 1:
- print filename
- print xl
- sys.exit(9);
- print "INSERT INTO dsc_files (source, file) VALUES (%s, %s)" % (source_id, xl[0][0]);
- projectB.query("INSERT INTO dsc_files (source, file) VALUES (%s, %s)" % (source_id, xl[0][0]));
-
- projectB.query("COMMIT WORK;");
-
- sys.exit(0);
-
-#######################################################################################
-
-if __name__ == '__main__':
- main()
-
-# source_id = i[0];
-# source_name = i[1];
-# source_version = i[2];
-# print "SELECT df.file FROM dsc_files df, source s WHERE s.source = '%s' AND s.version = '%s' AND df.source = s.id;" % (source_name, source_version);
-# x = christina.query("SELECT df.file FROM dsc_files df, source s WHERE s.source = '%s' AND s.version = '%s' AND df.source = s.id;" % (source_name, source_version));
-# xl = x.getresult();
-# if len(xl) < 2 or len(xl) > 3:
-# print xl
-# continue;
-# #sys.exit(9);
-# for j in xl:
-# df_source = source_id;
-# print "SELECT filename, location FROM files WHERE id = %s;" % (j[0]);
-# x1 = christina.query("SELECT filename, location FROM files WHERE id = %s;" % (j[0]));
-# x1l = x1.getresult();
-# if len(x1l) != 1:
-# print x1l
-# sys.exit(9);
-# filename = x1l[0][0];
-# location = x1l[0][1];
-# print "SELECT id FROM files WHERE filename = '%s' AND location = %s;" % (filename, location);
-# x2 = projectB.query("SELECT id FROM files WHERE filename = '%s' AND location = %s;" % (filename, location));
-# x2l = x2.getresult();
-# if len(x2l) != 1:
-# print x2l
-# sys.exit(9);
-# df_file = x2l[0][0];
-# projectB.query("INSERT INTO dsc_files (source, file) VALUES (%s, %s);" % (df_source, df_file));
-# print "INSERT INTO dsc_files (source, file) VALUES (%s, %s);" % (df_source, df_file);
+++ /dev/null
-#!/usr/bin/env python
-
-# ???
-# Copyright (C) 2000, 2001 James Troup <james@nocrew.org>
-# $Id: hack.5,v 1.1 2001-05-17 01:01:51 troup Exp $
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-# Computer games don't affect kids. I mean if Pacman affected our generation as
-# kids, we'd all run around in a darkened room munching pills and listening to
-# repetitive music.
-# -- Unknown
-
-################################################################################
-
-import pg, sys, os, string, re
-import utils, db_access
-import apt_pkg;
-
-################################################################################
-
-Cnf = None;
-projectB = None;
-
-re_parse_bin_filename = re.compile(r"(.+?)_(.+?)_(.+?)\.(.+?)")
-re_parse_src_filename = re.compile(r"(.+?)_(.+?)\.dsc")
-
-################################################################################
-
-def main ():
- global Cnf, projectB, db_files, waste, excluded;
-
- apt_pkg.init();
-
- Cnf = apt_pkg.newConfiguration();
- apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file());
-
- Arguments = [('d',"debug","Christina::Options::Debug", "IntVal"),
- ('h',"help","Christina::Options::Help"),
- ('v',"version","Christina::Options::Version")];
-
- changes_files = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv);
- projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]));
- db_access.init(Cnf, projectB);
-
- for changes_file in changes_files:
- #print changes_file
- changes = utils.parse_changes(changes_file, 0)
- files = utils.build_file_list(changes, "");
- for file in files.keys():
- if file[-4:] == ".deb":
- m = re_parse_bin_filename.match(file)
- package = m.group(1);
- version = m.group(2);
- architecture = m.group(3);
- type = m.group(4)
- q = projectB.query("SELECT b.id FROM binaries b, bin_associations ba, architecture a WHERE b.id = ba.bin AND ba.suite = 3 AND b.package = '%s' AND b.version = '%s' AND a.id = b.architecture AND a.arch_string = '%s'" % (package, version, architecture));
- ql = q.getresult();
- if len(ql) == 0:
- #print "[MISSING] Package: %s, version: %s, architecture: %s" % (package, version, architecture);
- foo = 0;
- elif len(ql) == 1:
- id = ql[0][0];
- print "DELETE FROM bin_associations WHERE bin = %s AND suite = 3;" % (id);
- projectB.query("DELETE FROM bin_associations WHERE bin = %s AND suite = 3;" % (id));
- #print "[%s] Package: %s, version: %s, architecture: %s" % (id, package, version, architecture);
- else:
- print "[FUBAR]"
-
- elif file[-4:] == ".dsc":
- m = re_parse_src_filename.match(file)
- package = m.group(1);
- version = m.group(2);
- q = projectB.query("SELECT s.id FROM source s, src_associations sa WHERE s.id = sa.source AND sa.suite = 3 AND s.source = '%s' AND s.version = '%s'" % (package, version));
- ql = q.getresult();
- if len(ql) == 0:
- #print "[MISSING] Package: %s, version: %s, architecture: source" % (package, version);
- foo = 0;
- elif len(ql) == 1:
- id = ql[0][0];
- print "DELETE FROM src_associations WHERE source = %s AND suite = 3;" % (id);
- projectB.query("DELETE FROM src_associations WHERE source = %s AND suite = 3;" % (id));
- #print "[%s] Package: %s, version: %s, architecture: source" % (id, package, version);
- else:
- print "[FUBAR]"
-
-#######################################################################################
-
-if __name__ == '__main__':
- main()
-
+++ /dev/null
-#!/usr/bin/env python
-
-# Fix testing
-# Copyright (C) 2000, 2001 James Troup <james@nocrew.org>
-# $Id: hack.6,v 1.1 2001-06-05 22:31:33 troup Exp $
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-# 'Too afraid to touch; too afraid you'll like too much'
-
-################################################################################
-
-import pg, sys, os, string
-import utils, db_access
-import apt_inst, apt_pkg;
-
-################################################################################
-
-Cnf = None;
-projectB = None;
-
-################################################################################
-
-def main ():
- global Cnf, projectB, db_files, waste, excluded;
-
- apt_pkg.init();
-
- Cnf = apt_pkg.newConfiguration();
- apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file());
-
- Arguments = [('d',"debug","Christina::Options::Debug", "IntVal"),
- ('h',"help","Christina::Options::Help"),
- ('v',"version","Christina::Options::Version")];
-
- apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv);
- projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]));
- christina = pg.connect('christina', Cnf["DB::Host"], int(Cnf["DB::Port"]));
- db_access.init(Cnf, projectB);
-
- total = 0; found = 0;
- morgue = Cnf["Dir::Morgue"] + '/' + Cnf["Rhona::MorgueSubDir"];
-
- xxx = utils.open_file ("xxx", 'r');
- for line in xxx.readlines():
- (package, version, arch) = string.split(line);
- eversion = utils.re_no_epoch.sub('', version);
- total = total + 1;
- if arch != "source":
- #filename = "%s/%s_%s_%s.deb" % (morgue, package, eversion, arch);
- filename = "%s/%s_%s.deb" % (morgue, package, eversion);
- else:
- continue
- if os.access(filename, os.R_OK) == 0:
- continue;
-
- control = apt_pkg.ParseSection(apt_inst.debExtractControl(utils.open_file(filename,"r")));
- deb_arch = control.Find("Architecture");
- if arch != deb_arch:
- continue;
-
- arch_id = db_access.get_architecture_id (arch);
- q = christina.query("SELECT f.*, l.path, b.* FROM binaries b, files f, location l WHERE b.package = '%s' AND b.architecture = %s AND b.version = '%s' AND b.file = f.id AND l.id = f.location" % (package, arch_id, version));
- ql = q.getresult();
- if len(ql) != 1:
- print "YOU LOSE: "+package+"~"+version+"~"+arch+"~"+repr(ql)
- continue;
- ql = ql[0];
-
- x = projectB.query("SELECT * FROM source WHERE id = %s" % (ql[11]));
- xl = x.getresult();
- if len(xl) != 1:
- old_filename = filename;
- z = christina.query("SELECT f.*, l.path, s.*, df.* FROM source s, files f, location l, dsc_files df WHERE s.id = %s AND df.source = s.id AND df.file = f.id AND l.id = f.location" % (ql[11]));
- zl = z.getresult();
- if len(zl) < 1:
- print old_filename
- print repr(ql);
- print "SELECT f.*, l.path, s.*, df.* FROM source s, files f, location l, dsc_files df WHERE s.id = %s AND df.source = s.id AND df.file = f.id AND l.id = f.location" % (ql[11]);
- print " ==> "+repr(zl);
- #sys.exit(3);
- else:
- projectB.query("BEGIN WORK");
- gack = [];
- for i in zl:
- new_filename = i[6] + i[1];
- filename = morgue + '/' + os.path.basename(new_filename);
- if os.access(filename, os.R_OK):
- print filename + " -> " + new_filename;
- if os.path.exists(new_filename):
- sys.exit(3);
- #utils.move(filename, new_filename);
- print "INSERT INTO files (id, filename, size, md5sum, location) VALUES (%s, '%s', %s, '%s', %s)" % (i[:5]);
- #projectB.query("INSERT INTO files (id, filename, size, md5sum, location) VALUES (%s, '%s', %s, '%s', %s)" % (i[:5]));
- gack.append("INSERT INTO dsc_files (id, source, file) VALUES (%s, %s, %s)" % (i[12:]));
- if new_filename[-4:] == ".dsc":
- print "INSERT INTO source (id, source, version, maintainer, file) VALUES (%s, '%s', '%s', %s, %s)" % (i[7:12]);
- #projectB.query("INSERT INTO source (id, source, version, maintainer, file) VALUES (%s, '%s', '%s', %s, %s)" % (i[7:12]));
- for i in gack:
- print i;
- #projectB.query(i);
- projectB.query("COMMIT WORK");
- filename = old_filename;
-
- projectB.query("BEGIN WORK");
- new_filename = ql[6] + ql[1];
- print filename + " -> " + new_filename;
- if os.path.exists(new_filename):
- sys.exit(3);
- utils.move(filename, new_filename);
- print "INSERT INTO files (id, filename, size, md5sum, location) VALUES (%s, '%s', %s, '%s', %s)" % (ql[:5]);
- projectB.query("INSERT INTO files (id, filename, size, md5sum, location) VALUES (%s, '%s', %s, '%s', %s)" % (ql[:5]));
- if ql[11] == 0:
- print "INSERT INTO binaries (id, package, version, maintainer, architecture, file, type) VALUES (%s, '%s', '%s', %s, %s, %s, '%s')" % (ql[7], ql[8], ql[9], ql[10], ql[12], ql[13], ql[14]);
- projectB.query("INSERT INTO binaries (id, package, version, maintainer, architecture, file, type) VALUES (%s, '%s', '%s', %s, %s, %s, '%s')" % (ql[7], ql[8], ql[9], ql[10], ql[12], ql[13], ql[14]));
- else:
- print "INSERT INTO binaries (id, package, version, maintainer, source, architecture, file, type) VALUES (%s, '%s', '%s', %s, %s, %s, %s, '%s')" % (ql[7:]);
- projectB.query("INSERT INTO binaries (id, package, version, maintainer, source, architecture, file, type) VALUES (%s, '%s', '%s', %s, %s, %s, %s, '%s')" % (ql[7:]));
- print "INSERT INTO bin_associations (suite, bin) VALUES (%s, %s)" % (4, ql[7]);
- projectB.query("INSERT INTO bin_associations (suite, bin) VALUES (%s, %s)" % (4, ql[7]));
-
- projectB.query("COMMIT WORK");
-
-#######################################################################################
-
-if __name__ == '__main__':
- main()
-
-#######################################################################################
-
-# xxx = utils.open_file ("xxx", 'r');
-# for line in xxx.readlines():
-# (package, version, arch) = string.split(line);
-# eversion = utils.re_no_epoch.sub('', version);
-# total = total + 1;
-# if arch == "source":
-# filename = "%s/%s_%s.dsc" % (morgue, package, eversion);
-# else:
-# continue
-# if os.access(filename, os.R_OK) == 0:
-# continue;
-
-# arch_id = db_access.get_architecture_id (arch);
-# q = christina.query("SELECT f.*, l.path, s.*, df.* FROM source s, files f, location l, dsc_files df WHERE s.source = '%s' AND s.version = '%s' AND df.source = s.id AND df.file = f.id AND l.id = f.location" % (package, version));
-# ql = q.getresult();
-# if len(ql) < 1:
-# print "YOU LOSE: "+package+"~"+version+"~"+arch+"~"+repr(ql)
-# continue;
-# projectB.query("BEGIN WORK");
-# gack = [];
-# for i in ql:
-# new_filename = i[6] + i[1];
-# filename = morgue + '/' + os.path.basename(new_filename);
-# if os.access(filename, os.R_OK) == 0:
-# continue;
-# print filename + " -> " + new_filename;
-# if os.path.exists(new_filename):
-# sys.exit(3);
-# utils.move(filename, new_filename);
-# print "INSERT INTO files (id, filename, size, md5sum, location) VALUES (%s, '%s', %s, '%s', %s)" % (i[:5]);
-# projectB.query("INSERT INTO files (id, filename, size, md5sum, location) VALUES (%s, '%s', %s, '%s', %s)" % (i[:5]));
-# gack.append("INSERT INTO dsc_files (id, source, file) VALUES (%s, %s, %s)" % (i[12:]));
-# if new_filename[-4:] == ".dsc":
-# print "INSERT INTO source (id, source, version, maintainer, file) VALUES (%s, '%s', '%s', %s, %s)" % (i[7:12]);
-# projectB.query("INSERT INTO source (id, source, version, maintainer, file) VALUES (%s, '%s', '%s', %s, %s)" % (i[7:12]));
-# print "INSERT INTO src_associations (suite, source) VALUES (%s, %s)" % (4, i[7]);
-# projectB.query("INSERT INTO src_associations (suite, source) VALUES (%s, %s)" % (4, i[7]));
-# #print repr(i)
-# for i in gack:
-# print i;
-# projectB.query(i);
-# projectB.query("COMMIT WORK");
-
-#######################################################################################
-
-#######################################################################################
-
-# bad = {};
-# xxx = utils.open_file ("xxx", 'r');
-# for line in xxx.readlines():
-# (package, version, arch) = string.split(line);
-# version = utils.re_no_epoch.sub('', version);
-# total = total + 1;
-# if arch != "source":
-# filename = "%s/%s_%s_%s.deb" % (morgue, package, version, arch);
-# else:
-# filename = "%s/%s_%s.dsc" % (morgue, package, version);
-# if os.access(filename, os.R_OK):
-# found = found + 1;
-# else:
-# if arch != "source":
-# filename = "%s/%s_%s.deb" % (morgue, package, version);
-# if os.access(filename, os.R_OK):
-# control = apt_pkg.ParseSection(apt_inst.debExtractControl(utils.open_file(filename,"r")));
-# deb_arch = control.Find("Architecture");
-# if arch == deb_arch:
-# found = found + 1;
-# continue;
-# if arch != "source":
-# xf = 0;
-# arch_id = db_access.get_architecture_id (arch);
-# q = projectB.query("SELECT version FROM binaries b, bin_associations ba WHERE b.package = '%s' AND b.architecture = %s AND ba.bin = b.id AND ba.suite = 5" % (package, arch_id));
-# ql = q.getresult();
-# if len(ql) != 1:
-# q = projectB.query("SELECT version FROM binaries b, bin_associations ba WHERE b.package = '%s' AND b.architecture = %s AND ba.bin = b.id AND ba.suite = 2" % (package, arch_id));
-# ql = q.getresult();
-# if len(ql) != 1:
-# #print "YOU LOSE: "+package+"~"+version+"~"+arch+"~"+repr(ql)
-# continue;
-
-# unstable_version = ql[0][0];
-# print package+" "+unstable_version+" "+arch;
-# found = found + 1;
-# else:
-# q = projectB.query("SELECT version FROM source s, src_associations sa WHERE s.source = '%s' AND sa.source = s.id AND sa.suite = 5" % (package));
-# ql = q.getresult();
-# if len(ql) != 1:
-# q = projectB.query("SELECT version FROM source s, src_associations sa WHERE s.source = '%s' AND sa.source = s.id AND sa.suite = 2" % (package));
-# ql = q.getresult();
-# if len(ql) != 1:
-# #print "YOU LOSE: "+package+"~"+version+"~"+arch+"~"+repr(ql)
-# continue;
-
-# unstable_version = ql[0][0];
-# print package+" "+unstable_version+" "+arch;
-# found = found + 1;
-
-# #print "Good: %d / %d (%.2f%%)" % (found, total, (float(found)/total*100));
-# #not_found = total - found;
-# #print "Bad: %d / %d (%.2f%%)" % (not_found, total, (float(not_found)/total*100));
-
-#######################################################################################
-
-# Pretty print bad stuff code
-
-# key = package+'~'+version;
-# if not bad.has_key(key):
-# bad[key] = [];
-# bad[key].append(arch);
-
-# keys = bad.keys();
-# keys.sort();
-# for i in keys:
-# print i+": "+repr(bad[i]);
-
-
-
-# Check if is in DB code
-
-# arch_id = db_access.get_architecture_id (arch);
-# q = projectB.query("SELECT id FROM binaries WHERE package = '%s' AND version = '%s' AND architecture = %s" % (package, version, arch_id));
-# ql = q.getresult();
-# if ql != []:
-# found = found + 1;
-
-# q = projectB.query("SELECT id FROM source WHERE source = '%s' AND version = '%s'" % (package, version));
-# ql = q.getresult();
-# if ql != []:
-# found = found + 1;