3 # 'Fix' stable to make debian-cd and dpkg -BORGiE users happy
4 # Copyright (C) 2000 James Troup <james@nocrew.org>
5 # $Id: claire.py,v 1.1 2000-12-05 04:27:48 troup Exp $
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 # "Look around... leaves are brown... and the sky's a hazy shade of winter,
22 # Look around... leaves are brown... there's a patch of snow on the ground."
23 # -- Simon & Garfunkel / 'A Hazy Shade'
25 ################################################################################
27 import pg, sys, os, string
28 import utils, db_access
31 ################################################################################
36 # Relativize an absolute symlink from 'src' -> 'dest' relative to 'root'.
38 def clean_symlink (src, dest, root):
39 src = string.replace(src, root, '', 1);
40 dest = string.replace(dest, root, '', 1);
41 dest = os.path.dirname(dest);
43 for i in xrange(len(string.split(dest, '/'))):
44 new_src = new_src + '../';
47 ################################################################################
49 def find_dislocated_stable(Cnf, projectB):
53 q = projectB.query("SELECT su.suite_name, c.name, s.id FROM suite su, src_associations sa, source s, files f, component c, location l WHERE su.suite_name = 'stable' AND sa.suite = su.id AND sa.source = s.id AND f.id = s.file AND f.location = l.id AND (l.component = c.id OR (l.component = NULL AND c.name = 'non-US/main')) AND NOT (f.filename ~ '^potato/');")
54 for i in q.getresult():
55 q = projectB.query("SELECT l.path, f.filename, f.id FROM source s, files f, location l, dsc_files df WHERE s.id = %d AND df.source = %d AND f.id = df.file AND f.location = l.id AND NOT (f.filename ~ '^potato/')" % (i[2], i[2]));
56 for j in q.getresult():
58 dest = Cnf["Dir::RootDir"]+'dists/'+i[0]+'/'+i[1]+'/source/'+os.path.basename(j[1]);
59 src = clean_symlink(src, dest, Cnf["Dir::RootDir"]);
60 if not os.path.exists(dest):
61 if Cnf.Find("Claire::Options::Verbose"):
63 os.symlink(src, dest);
64 dislocated_files[j[2]] = dest;
67 q = projectB.query("SELECT su.suite_name, c.name, a.arch_string, b.package, b.version, l.path, f.filename, f.id FROM suite su, bin_associations ba, binaries b, files f, component c, architecture a, location l WHERE ba.suite = su.id AND su.suite_name = 'stable' AND ba.bin = b.id AND f.id = b.file AND f.location = l.id AND (l.component = c.id OR (l.component = NULL and c.name = 'non-US/main')) AND b.architecture = a.id AND NOT (f.filename ~ '^potato/');");
68 for i in q.getresult():
70 dest = Cnf["Dir::RootDir"]+'dists/'+i[0]+'/'+i[1]+'/binary-'+i[2]+'/'+i[3]+'_'+utils.re_no_epoch.sub('', i[4])+'.deb'
71 src = clean_symlink(src, dest, Cnf["Dir::RootDir"]);
72 if not os.path.exists(dest):
73 if Cnf.Find("Claire::Options::Verbose"):
75 os.symlink(src, dest);
76 dislocated_files[i[7]] = dest;
78 return dislocated_files
80 ################################################################################
87 Cnf = apt_pkg.newConfiguration();
88 apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file());
90 Arguments = [('d',"debug","Claire::Options::Debug", "IntVal"),
91 ('h',"help","Claire::Options::Help"),
92 ('v',"verbose","Claire::Options::Verbose"),
93 ('V',"version","Claire::Options::Version")];
95 apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv);
97 projectB = pg.connect('projectb', 'localhost');
99 db_access.init(Cnf, projectB);
101 find_dislocated_stable(Cnf, projectB);
103 #######################################################################################
105 if __name__ == '__main__':