Bug#761149: debsources: allow redirects to package versions based on suite/codename
Hello !
As discussed on IRC, I rebase my patches for this bug.
I also fixed a few PEP8 issues found by flake8
Note: The redirects won't work until the app is updated with
bin/debsources-update (which I guess is already setup in a crontask in
production?)
Cheers
--
Jason Pleau
From d51a5d1060d6716b405b3e8880ba9ae20944af54 Mon Sep 17 00:00:00 2001
From: Jason Pleau <jason@jpleau.ca>
Date: Sun, 16 Nov 2014 11:29:55 -0500
Subject: [PATCH 2/2] update doc/db-schema from previous commit
Adds information about the new suites_aliases table
---
doc/db-schema/debsources.dia | 198 ++++++++++++++++++++++++++++++++--
doc/db-schema/debsources.dot | 3 +
doc/db-schema/debsources.html | 118 +++++++++++++++++++-
doc/db-schema/debsources.neato | 3 +
doc/db-schema/debsources.xml | 112 +++++++++++++++++++
doc/db-schema/debsources.zigzag.dia | 210 ++++++++++++++++++++++++++++++++++--
6 files changed, 620 insertions(+), 24 deletions(-)
diff --git a/doc/db-schema/debsources.dia b/doc/db-schema/debsources.dia
index 5487cb0..2cc668b 100644
--- a/doc/db-schema/debsources.dia
+++ b/doc/db-schema/debsources.dia
@@ -3178,6 +3178,156 @@
<dia:real val="6.6000000000000005"/>
</dia:attribute>
<dia:attribute name="name">
+ <dia:string>#suites_aliases#</dia:string>
+ </dia:attribute>
+
+ <dia:attribute name="comment">
+ <dia:string>##</dia:string>
+ </dia:attribute>
+ <dia:attribute name="abstract">
+ <dia:boolean val="false"/>
+ </dia:attribute>
+ <dia:attribute name="suppress_attributes">
+ <dia:boolean val="false"/>
+ </dia:attribute>
+ <dia:attribute name="suppress_operations">
+ <dia:boolean val="false"/>
+ </dia:attribute>
+ <dia:attribute name="visible_attributes">
+ <dia:boolean val="true"/>
+ </dia:attribute>
+ <dia:attribute name="visible_comments">
+ <dia:boolean val="true"/>
+ </dia:attribute>
+ <dia:attribute name="wrap_operations">
+ <dia:boolean val="false"/>
+ </dia:attribute>
+ <dia:attribute name="wrap_after_char">
+ <dia:int val="40"/>
+ </dia:attribute>
+ <dia:attribute name="line_color">
+ <dia:color val="#000000"/>
+ </dia:attribute>
+ <dia:attribute name="fill_color">
+ <dia:color val="#ffffff"/>
+ </dia:attribute>
+ <dia:attribute name="text_color">
+ <dia:color val="#000000"/>
+ </dia:attribute>
+ <dia:attribute name="normal_font">
+ <dia:font family="monospace" style="0" name="Courier"/>
+ </dia:attribute>
+ <dia:attribute name="abstract_font">
+ <dia:font family="monospace" style="88" name="Courier"/>
+ </dia:attribute>
+ <dia:attribute name="polymorphic_font">
+ <dia:font family="monospace" style="8" name="Courier"/>
+ </dia:attribute>
+ <dia:attribute name="classname_font">
+ <dia:font family="sans" style="80" name="Helvetica"/>
+ </dia:attribute>
+ <dia:attribute name="abstract_classname_font">
+ <dia:font family="sans" style="88" name="Helvetica"/>
+ </dia:attribute>
+ <dia:attribute name="comment_font">
+ <dia:font family="sans" style="8" name="Helvetica"/>
+ </dia:attribute>
+ <dia:attribute name="font_height">
+ <dia:real val="0.80000000000000004"/>
+ </dia:attribute>
+ <dia:attribute name="polymorphic_font_height">
+ <dia:real val="0.80000000000000004"/>
+ </dia:attribute>
+ <dia:attribute name="abstract_font_height">
+ <dia:real val="0.80000000000000004"/>
+ </dia:attribute>
+ <dia:attribute name="classname_font_height">
+ <dia:real val="1"/>
+ </dia:attribute>
+ <dia:attribute name="abstract_classname_font_height">
+ <dia:real val="1"/>
+ </dia:attribute>
+ <dia:attribute name="comment_font_height">
+ <dia:real val="1"/>
+ </dia:attribute>
+ <dia:attribute name="attributes">
+
+ <dia:composite type="umlattribute">
+ <dia:attribute name="name">
+ <dia:string># alias#</dia:string>
+ </dia:attribute>
+ <dia:attribute name="type">
+ <dia:string>#character varying#</dia:string>
+ </dia:attribute>
+ <dia:attribute name="value">
+
+ <dia:string/>
+
+ </dia:attribute>
+ <dia:attribute name="visibility">
+ <dia:enum val="3"/>
+ </dia:attribute>
+ <dia:attribute name="abstract">
+ <dia:boolean val="false"/>
+ </dia:attribute>
+ <dia:attribute name="class_scope">
+ <dia:boolean val="false"/>
+ </dia:attribute>
+ </dia:composite>
+
+ <dia:composite type="umlattribute">
+ <dia:attribute name="name">
+ <dia:string># suite#</dia:string>
+ </dia:attribute>
+ <dia:attribute name="type">
+ <dia:string>#character varying#</dia:string>
+ </dia:attribute>
+ <dia:attribute name="value">
+
+ <dia:string/>
+
+ </dia:attribute>
+ <dia:attribute name="visibility">
+ <dia:enum val="3"/>
+ </dia:attribute>
+ <dia:attribute name="abstract">
+ <dia:boolean val="false"/>
+ </dia:attribute>
+ <dia:attribute name="class_scope">
+ <dia:boolean val="false"/>
+ </dia:attribute>
+ </dia:composite>
+
+ </dia:attribute>
+
+ <dia:attribute name="visible_operations">
+ <dia:boolean val="false"/>
+ </dia:attribute>
+ <dia:attribute name="operations"/>
+
+ <dia:attribute name="template">
+ <dia:boolean val="false"/>
+ </dia:attribute>
+ <dia:attribute name="templates"/>
+ </dia:object>
+
+ <dia:object type="UML - Class" version="0" id="O14">
+ <dia:attribute name="obj_pos">
+ <dia:point val="0,0"/>
+ </dia:attribute>
+ <dia:attribute name="obj_bb">
+ <dia:rectangle val="-0.05,-0.05;16.4,6.65"/>
+ </dia:attribute>
+ <dia:attribute name="elem_corner">
+ <dia:point val="0,0"/>
+ </dia:attribute>
+ <dia:attribute name="elem_width">
+ <dia:real val="16.350000000000001"/>
+ </dia:attribute>
+ <dia:attribute name="elem_height">
+ <dia:real val="6.6000000000000005"/>
+ </dia:attribute>
+ <dia:attribute name="name">
<dia:string>#suites_info#</dia:string>
</dia:attribute>
@@ -3360,7 +3510,7 @@
- <dia:object type="UML - Constraint" version="0" id="O14">
+ <dia:object type="UML - Constraint" version="0" id="O15">
<dia:attribute name="obj_pos">
<dia:point val="0,3.5"/>
</dia:attribute>
@@ -3386,7 +3536,7 @@
</dia:connections>
</dia:object>
- <dia:object type="UML - Constraint" version="0" id="O15">
+ <dia:object type="UML - Constraint" version="0" id="O16">
<dia:attribute name="obj_pos">
<dia:point val="0,3.5"/>
</dia:attribute>
@@ -3412,7 +3562,7 @@
</dia:connections>
</dia:object>
- <dia:object type="UML - Constraint" version="0" id="O16">
+ <dia:object type="UML - Constraint" version="0" id="O17">
<dia:attribute name="obj_pos">
<dia:point val="0,3.5"/>
</dia:attribute>
@@ -3438,7 +3588,7 @@
</dia:connections>
</dia:object>
- <dia:object type="UML - Constraint" version="0" id="O17">
+ <dia:object type="UML - Constraint" version="0" id="O18">
<dia:attribute name="obj_pos">
<dia:point val="0,3.5"/>
</dia:attribute>
@@ -3464,7 +3614,7 @@
</dia:connections>
</dia:object>
- <dia:object type="UML - Constraint" version="0" id="O18">
+ <dia:object type="UML - Constraint" version="0" id="O19">
<dia:attribute name="obj_pos">
<dia:point val="0,3.5"/>
</dia:attribute>
@@ -3490,7 +3640,7 @@
</dia:connections>
</dia:object>
- <dia:object type="UML - Constraint" version="0" id="O19">
+ <dia:object type="UML - Constraint" version="0" id="O20">
<dia:attribute name="obj_pos">
<dia:point val="0,3.5"/>
</dia:attribute>
@@ -3516,7 +3666,7 @@
</dia:connections>
</dia:object>
- <dia:object type="UML - Constraint" version="0" id="O20">
+ <dia:object type="UML - Constraint" version="0" id="O21">
<dia:attribute name="obj_pos">
<dia:point val="0,3.5"/>
</dia:attribute>
@@ -3542,7 +3692,7 @@
</dia:connections>
</dia:object>
- <dia:object type="UML - Constraint" version="0" id="O21">
+ <dia:object type="UML - Constraint" version="0" id="O22">
<dia:attribute name="obj_pos">
<dia:point val="0,3.5"/>
</dia:attribute>
@@ -3568,7 +3718,7 @@
</dia:connections>
</dia:object>
- <dia:object type="UML - Constraint" version="0" id="O22">
+ <dia:object type="UML - Constraint" version="0" id="O23">
<dia:attribute name="obj_pos">
<dia:point val="0,3.5"/>
</dia:attribute>
@@ -3594,7 +3744,7 @@
</dia:connections>
</dia:object>
- <dia:object type="UML - Constraint" version="0" id="O23">
+ <dia:object type="UML - Constraint" version="0" id="O24">
<dia:attribute name="obj_pos">
<dia:point val="0,3.5"/>
</dia:attribute>
@@ -3620,7 +3770,7 @@
</dia:connections>
</dia:object>
- <dia:object type="UML - Constraint" version="0" id="O24">
+ <dia:object type="UML - Constraint" version="0" id="O25">
<dia:attribute name="obj_pos">
<dia:point val="0,3.5"/>
</dia:attribute>
@@ -3646,5 +3796,31 @@
</dia:connections>
</dia:object>
+ <dia:object type="UML - Constraint" version="0" id="O26">
+ <dia:attribute name="obj_pos">
+ <dia:point val="0,3.5"/>
+ </dia:attribute>
+ <dia:attribute name="obj_bb">
+ <dia:rectangle val="-0.0515705,2.29861;25.1127,3.55157"/>
+ </dia:attribute>
+ <dia:attribute name="conn_endpoints">
+ <dia:point val="0,3.5"/>
+ <dia:point val="25.05,2.7"/>
+ </dia:attribute>
+ <dia:attribute name="constraint">
+ <dia:string>#suites_aliases_suite_fkey#</dia:string>
+ </dia:attribute>
+ <dia:attribute name="text_pos">
+ <dia:point val="12.525,3.1"/>
+ </dia:attribute>
+ <dia:attribute name="line_colour">
+ <dia:color val="#000000"/>
+ </dia:attribute>
+ <dia:connections>
+ <dia:connection handle="0" to="O13" connection="10"/>
+ <dia:connection handle="1" to="O14" connection="9"/>
+ </dia:connections>
+ </dia:object>
+
</dia:layer>
</dia:diagram>
diff --git a/doc/db-schema/debsources.dot b/doc/db-schema/debsources.dot
index 43aac6c..30d5a88 100644
--- a/doc/db-schema/debsources.dot
+++ b/doc/db-schema/debsources.dot
@@ -35,6 +35,8 @@ edge [
"suites" [shape = plaintext, label = < <TABLE BORDER="1" CELLBORDER="0" CELLSPACING="0"> <TR ><TD PORT="ltcol0"> </TD> <TD bgcolor="grey90" border="1" COLSPAN="4"> \N </TD> <TD PORT="rtcol0"></TD></TR> <TR><TD PORT="ltcol1" ></TD><TD align="left" > id </TD><TD align="left" > serial </TD><TD align="left" > PK </TD><TD align="left" > </TD><TD align="left" PORT="rtcol1"> </TD></TR> <TR><TD PORT="ltcol2" ></TD><TD align="left" > package_id </TD><TD align="left" > integer </TD><TD align="left" > </TD><TD align="left" > FK </TD><TD align="left" PORT="rtcol2"> </TD></TR> <TR><TD PORT="ltcol3" ></TD><TD align="left" > suite </TD><TD align="left" > character varying </TD><TD align="left" > </TD><TD align="left" > </TD><TD align="left" PORT="rtcol3"> </TD></TR> </TABLE>> ];
+"suites_aliases" [shape = plaintext, label = < <TABLE BORDER="1" CELLBORDER="0" CELLSPACING="0"> <TR ><TD PORT="ltcol0"> </TD> <TD bgcolor="grey90" border="1" COLSPAN="4"> \N </TD> <TD PORT="rtcol0"></TD></TR> <TR><TD PORT="ltcol1" ></TD><TD align="left" > alias </TD><TD align="left" > character varying </TD><TD align="left" > PK </TD><TD align="left" > </TD><TD align="left" PORT="rtcol1"> </TD></TR> <TR><TD PORT="ltcol2" ></TD><TD align="left" > suite </TD><TD align="left" > character varying </TD><TD align="left" > PK </TD><TD align="left" > </TD><TD align="left" PORT="rtcol2"> </TD></TR> </TABLE>> ];
+
"suites_info" [shape = plaintext, label = < <TABLE BORDER="1" CELLBORDER="0" CELLSPACING="0"> <TR ><TD PORT="ltcol0"> </TD> <TD bgcolor="grey90" border="1" COLSPAN="4"> \N </TD> <TD PORT="rtcol0"></TD></TR> <TR><TD PORT="ltcol1" ></TD><TD align="left" > name </TD><TD align="left" > character varying </TD><TD align="left" > PK </TD><TD align="left" > </TD><TD align="left" PORT="rtcol1"> </TD></TR> <TR><TD PORT="ltcol2" ></TD><TD align="left" > version </TD><TD align="left" > character varying </TD><TD align="left" > </TD><TD align="left" > </TD><TD align="left" PORT="rtcol2"> </TD></TR> <TR><TD PORT="ltcol3" ></TD><TD align="left" > release_date </TD><TD align="left" > date </TD><TD align="left" > </TD><TD align="left" > </TD><TD align="left" PORT="rtcol3"> </TD></TR> <TR><TD PORT="ltcol4" ></TD><TD align="left" > sticky </TD><TD align="left" > boolean </TD><TD align="left" > </TD><TD align="left" > </TD><TD align="left" PORT="rtcol4"> </TD></TR> </TABLE>> ];
@@ -50,4 +52,5 @@ edge [
"packages":rtcol3 -> "package_names":ltcol1 [label="packages_name_id_fkey"];
"sloccounts":rtcol2 -> "packages":ltcol1 [label="sloccounts_package_id_fkey"];
"suites":rtcol2 -> "packages":ltcol1 [label="suites_package_id_fkey"];
+"suites_aliases":rtcol2 -> "suites_info":ltcol1 [label="suites_aliases_suite_fkey"];
}
diff --git a/doc/db-schema/debsources.html b/doc/db-schema/debsources.html
index 79ba33e..4214fa4 100644
--- a/doc/db-schema/debsources.html
+++ b/doc/db-schema/debsources.html
@@ -112,12 +112,12 @@
<body>
<!-- Primary Index -->
- <p><br><br>Dumped on 2014-03-11</p>
+ <p><br><br>Dumped on 2014-11-16</p>
<h1><a name="index">Index of database - debsources</a></h1>
<ul>
<li><a name="public.schema">public</a></li><ul>
- <li><a href="#public.table.binaries">binaries</a></li><li><a href="#public.table.binary-names">binary_names</a></li><li><a href="#public.table.checksums">checksums</a></li><li><a href="#public.table.ctags">ctags</a></li><li><a href="#public.table.files">files</a></li><li><a href="#public.table.history-size">history_size</a></li><li><a href="#public.table.history-sloccount">history_sloccount</a></li><li><a href="#public.table.metrics">metrics</a></li><li><a href="#public.table.package-names">package_names</a></li><li><a href="#public.table.packages">packages</a></li><li><a href="#public.table.sloccounts">sloccounts</a></li><li><a href="#public.table.suites">suites</a></li><li><a href="#public.table.suites-info">suites_info</a></li>
+ <li><a href="#public.table.binaries">binaries</a></li><li><a href="#public.table.binary-names">binary_names</a></li><li><a href="#public.table.checksums">checksums</a></li><li><a href="#public.table.ctags">ctags</a></li><li><a href="#public.table.files">files</a></li><li><a href="#public.table.history-size">history_size</a></li><li><a href="#public.table.history-sloccount">history_sloccount</a></li><li><a href="#public.table.metrics">metrics</a></li><li><a href="#public.table.package-names">package_names</a></li><li><a href="#public.table.packages">packages</a></li><li><a href="#public.table.sloccounts">sloccounts</a></li><li><a href="#public.table.suites">suites</a></li><li><a href="#public.table.suites-aliases">suites_aliases</a></li><li><a href="#public.table.suites-info">suites_info</a></li>
</ul>
@@ -2364,6 +2364,113 @@
<hr>
<h2>Table:
+ <a name="public.table.suites-aliases">suites_aliases</a>
+ </h2>
+
+
+
+ <table width="100%" cellspacing="0" cellpadding="3">
+ <caption>suites_aliases Structure</caption>
+ <tr>
+ <th>F-Key</th>
+ <th>Name</th>
+ <th>Type</th>
+ <th>Description</th>
+ </tr>
+
+ <tr class="tr0">
+ <td>
+
+
+
+
+
+ </td>
+ <td>alias</td>
+ <td>character varying</td>
+ <td><i>
+
+
+
+
+ UNIQUE
+
+
+ PRIMARY KEY
+
+
+
+
+
+
+
+ </i>
+
+ </td>
+ </tr>
+
+ <tr class="tr1">
+ <td>
+
+
+
+
+ <a href="#public.table.suites-info">suites_info.name</a>
+
+
+ </td>
+ <td>suite</td>
+ <td>character varying</td>
+ <td><i>
+
+ PRIMARY KEY
+
+
+
+
+
+
+
+
+
+
+
+ </i>
+
+ </td>
+ </tr>
+
+ </table>
+
+ <!-- Inherits -->
+
+
+
+
+
+
+ <!-- Constraint List -->
+
+
+ <!-- Foreign Key Discovery -->
+
+
+ <!-- Indexes -->
+
+
+ <!-- View Definition -->
+
+
+ <!-- List off permissions -->
+
+
+ <p>
+ <a href="#index">Index</a> -
+ <a href="#public.schema">Schema public</a>
+ </p>
+
+ <hr>
+ <h2>Table:
<a name="public.table.suites-info">suites_info</a>
</h2>
@@ -2463,6 +2570,13 @@
<!-- Foreign Key Discovery -->
+ <p>Tables referencing this one via Foreign Key Constraints:</p>
+
+ <ul>
+ <li><a href="#public.table.suites-aliases">suites_aliases</a></li>
+ </ul>
+
+
<!-- Indexes -->
diff --git a/doc/db-schema/debsources.neato b/doc/db-schema/debsources.neato
index a8fdb60..b801928 100644
--- a/doc/db-schema/debsources.neato
+++ b/doc/db-schema/debsources.neato
@@ -26,6 +26,8 @@ edge [];
"suites" [shape = record, label = "{<col0> \N| id: serial\lpackage_id: integer\lsuite: character varying\l}" ];
+"suites_aliases" [shape = record, label = "{<col0> \N| alias: character varying\lsuite: character varying\l}" ];
+
"suites_info" [shape = record, label = "{<col0> \N| name: character varying\lversion: character varying\lrelease_date: date\lsticky: boolean\l}" ];
@@ -40,6 +42,7 @@ edge [];
"packages" -> "package_names" [label="packages_name_id_fkey"];
"sloccounts" -> "packages" [label="sloccounts_package_id_fkey"];
"suites" -> "packages" [label="suites_package_id_fkey"];
+"suites_aliases" -> "suites_info" [label="suites_aliases_suite_fkey"];
}
diff --git a/doc/db-schema/debsources.xml b/doc/db-schema/debsources.xml
index 538f9ca..91e2037 100644
--- a/doc/db-schema/debsources.xml
+++ b/doc/db-schema/debsources.xml
@@ -2366,6 +2366,103 @@
</para>
</section>
+ <section id="public.table.suites-aliases"
+ xreflabel="public.suites_aliases">
+ <title id="public.table.suites-aliases-title">
+ Table:
+
+ <structname>suites_aliases</structname>
+ </title>
+
+
+
+ <para>
+ <variablelist>
+ <title>
+ Structure of <structname>suites_aliases</structname>
+ </title>
+
+
+ <varlistentry>
+ <term><structfield>alias</structfield></term>
+ <listitem><para>
+ <type>character varying</type>
+
+
+
+
+ <literal>UNIQUE</literal>
+
+
+
+ <literal>PRIMARY KEY</literal>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ </para>
+
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><structfield>suite</structfield></term>
+ <listitem><para>
+ <type>character varying</type>
+
+
+ <literal>PRIMARY KEY</literal>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <literal>REFERENCES</literal> <xref linkend="public.table.suites-info"/>
+
+
+ </para>
+
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+
+
+
+
+
+
+
+
+
+
+ </para>
+ </section>
+
<section id="public.table.suites-info"
xreflabel="public.suites_info">
<title id="public.table.suites-info-title">
@@ -2466,6 +2563,21 @@
+ <itemizedlist>
+ <title>
+ Tables referencing suites_aliases via Foreign Key Constraints
+ </title>
+
+ <listitem>
+ <para>
+ <xref linkend="public.table.suites-aliases"/>
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+
+
diff --git a/doc/db-schema/debsources.zigzag.dia b/doc/db-schema/debsources.zigzag.dia
index cd626cb..1e0485f 100644
--- a/doc/db-schema/debsources.zigzag.dia
+++ b/doc/db-schema/debsources.zigzag.dia
@@ -3178,6 +3178,156 @@
<dia:real val="6.6000000000000005"/>
</dia:attribute>
<dia:attribute name="name">
+ <dia:string>#suites_aliases#</dia:string>
+ </dia:attribute>
+
+ <dia:attribute name="comment">
+ <dia:string>##</dia:string>
+ </dia:attribute>
+ <dia:attribute name="abstract">
+ <dia:boolean val="false"/>
+ </dia:attribute>
+ <dia:attribute name="suppress_attributes">
+ <dia:boolean val="false"/>
+ </dia:attribute>
+ <dia:attribute name="suppress_operations">
+ <dia:boolean val="false"/>
+ </dia:attribute>
+ <dia:attribute name="visible_attributes">
+ <dia:boolean val="true"/>
+ </dia:attribute>
+ <dia:attribute name="visible_comments">
+ <dia:boolean val="true"/>
+ </dia:attribute>
+ <dia:attribute name="wrap_operations">
+ <dia:boolean val="false"/>
+ </dia:attribute>
+ <dia:attribute name="wrap_after_char">
+ <dia:int val="40"/>
+ </dia:attribute>
+ <dia:attribute name="line_color">
+ <dia:color val="#000000"/>
+ </dia:attribute>
+ <dia:attribute name="fill_color">
+ <dia:color val="#ffffff"/>
+ </dia:attribute>
+ <dia:attribute name="text_color">
+ <dia:color val="#000000"/>
+ </dia:attribute>
+ <dia:attribute name="normal_font">
+ <dia:font family="monospace" style="0" name="Courier"/>
+ </dia:attribute>
+ <dia:attribute name="abstract_font">
+ <dia:font family="monospace" style="88" name="Courier"/>
+ </dia:attribute>
+ <dia:attribute name="polymorphic_font">
+ <dia:font family="monospace" style="8" name="Courier"/>
+ </dia:attribute>
+ <dia:attribute name="classname_font">
+ <dia:font family="sans" style="80" name="Helvetica"/>
+ </dia:attribute>
+ <dia:attribute name="abstract_classname_font">
+ <dia:font family="sans" style="88" name="Helvetica"/>
+ </dia:attribute>
+ <dia:attribute name="comment_font">
+ <dia:font family="sans" style="8" name="Helvetica"/>
+ </dia:attribute>
+ <dia:attribute name="font_height">
+ <dia:real val="0.80000000000000004"/>
+ </dia:attribute>
+ <dia:attribute name="polymorphic_font_height">
+ <dia:real val="0.80000000000000004"/>
+ </dia:attribute>
+ <dia:attribute name="abstract_font_height">
+ <dia:real val="0.80000000000000004"/>
+ </dia:attribute>
+ <dia:attribute name="classname_font_height">
+ <dia:real val="1"/>
+ </dia:attribute>
+ <dia:attribute name="abstract_classname_font_height">
+ <dia:real val="1"/>
+ </dia:attribute>
+ <dia:attribute name="comment_font_height">
+ <dia:real val="1"/>
+ </dia:attribute>
+ <dia:attribute name="attributes">
+
+ <dia:composite type="umlattribute">
+ <dia:attribute name="name">
+ <dia:string># alias#</dia:string>
+ </dia:attribute>
+ <dia:attribute name="type">
+ <dia:string>#character varying#</dia:string>
+ </dia:attribute>
+ <dia:attribute name="value">
+
+ <dia:string/>
+
+ </dia:attribute>
+ <dia:attribute name="visibility">
+ <dia:enum val="3"/>
+ </dia:attribute>
+ <dia:attribute name="abstract">
+ <dia:boolean val="false"/>
+ </dia:attribute>
+ <dia:attribute name="class_scope">
+ <dia:boolean val="false"/>
+ </dia:attribute>
+ </dia:composite>
+
+ <dia:composite type="umlattribute">
+ <dia:attribute name="name">
+ <dia:string># suite#</dia:string>
+ </dia:attribute>
+ <dia:attribute name="type">
+ <dia:string>#character varying#</dia:string>
+ </dia:attribute>
+ <dia:attribute name="value">
+
+ <dia:string/>
+
+ </dia:attribute>
+ <dia:attribute name="visibility">
+ <dia:enum val="3"/>
+ </dia:attribute>
+ <dia:attribute name="abstract">
+ <dia:boolean val="false"/>
+ </dia:attribute>
+ <dia:attribute name="class_scope">
+ <dia:boolean val="false"/>
+ </dia:attribute>
+ </dia:composite>
+
+ </dia:attribute>
+
+ <dia:attribute name="visible_operations">
+ <dia:boolean val="false"/>
+ </dia:attribute>
+ <dia:attribute name="operations"/>
+
+ <dia:attribute name="template">
+ <dia:boolean val="false"/>
+ </dia:attribute>
+ <dia:attribute name="templates"/>
+ </dia:object>
+
+ <dia:object type="UML - Class" version="0" id="O14">
+ <dia:attribute name="obj_pos">
+ <dia:point val="0,0"/>
+ </dia:attribute>
+ <dia:attribute name="obj_bb">
+ <dia:rectangle val="-0.05,-0.05;16.4,6.65"/>
+ </dia:attribute>
+ <dia:attribute name="elem_corner">
+ <dia:point val="0,0"/>
+ </dia:attribute>
+ <dia:attribute name="elem_width">
+ <dia:real val="16.350000000000001"/>
+ </dia:attribute>
+ <dia:attribute name="elem_height">
+ <dia:real val="6.6000000000000005"/>
+ </dia:attribute>
+ <dia:attribute name="name">
<dia:string>#suites_info#</dia:string>
</dia:attribute>
@@ -3360,7 +3510,7 @@
- <dia:object type="UML - Dependency" version="0" id="O14">
+ <dia:object type="UML - Dependency" version="0" id="O15">
<dia:attribute name="obj_pos">
<dia:point val="0,3.5"/>
</dia:attribute>
@@ -3398,7 +3548,7 @@
</dia:connections>
</dia:object>
- <dia:object type="UML - Dependency" version="0" id="O15">
+ <dia:object type="UML - Dependency" version="0" id="O16">
<dia:attribute name="obj_pos">
<dia:point val="0,3.5"/>
</dia:attribute>
@@ -3436,7 +3586,7 @@
</dia:connections>
</dia:object>
- <dia:object type="UML - Dependency" version="0" id="O16">
+ <dia:object type="UML - Dependency" version="0" id="O17">
<dia:attribute name="obj_pos">
<dia:point val="0,3.5"/>
</dia:attribute>
@@ -3474,7 +3624,7 @@
</dia:connections>
</dia:object>
- <dia:object type="UML - Dependency" version="0" id="O17">
+ <dia:object type="UML - Dependency" version="0" id="O18">
<dia:attribute name="obj_pos">
<dia:point val="0,3.5"/>
</dia:attribute>
@@ -3512,7 +3662,7 @@
</dia:connections>
</dia:object>
- <dia:object type="UML - Dependency" version="0" id="O18">
+ <dia:object type="UML - Dependency" version="0" id="O19">
<dia:attribute name="obj_pos">
<dia:point val="0,3.5"/>
</dia:attribute>
@@ -3550,7 +3700,7 @@
</dia:connections>
</dia:object>
- <dia:object type="UML - Dependency" version="0" id="O19">
+ <dia:object type="UML - Dependency" version="0" id="O20">
<dia:attribute name="obj_pos">
<dia:point val="0,3.5"/>
</dia:attribute>
@@ -3588,7 +3738,7 @@
</dia:connections>
</dia:object>
- <dia:object type="UML - Dependency" version="0" id="O20">
+ <dia:object type="UML - Dependency" version="0" id="O21">
<dia:attribute name="obj_pos">
<dia:point val="0,3.5"/>
</dia:attribute>
@@ -3626,7 +3776,7 @@
</dia:connections>
</dia:object>
- <dia:object type="UML - Dependency" version="0" id="O21">
+ <dia:object type="UML - Dependency" version="0" id="O22">
<dia:attribute name="obj_pos">
<dia:point val="0,3.5"/>
</dia:attribute>
@@ -3664,7 +3814,7 @@
</dia:connections>
</dia:object>
- <dia:object type="UML - Dependency" version="0" id="O22">
+ <dia:object type="UML - Dependency" version="0" id="O23">
<dia:attribute name="obj_pos">
<dia:point val="0,3.5"/>
</dia:attribute>
@@ -3702,7 +3852,7 @@
</dia:connections>
</dia:object>
- <dia:object type="UML - Dependency" version="0" id="O23">
+ <dia:object type="UML - Dependency" version="0" id="O24">
<dia:attribute name="obj_pos">
<dia:point val="0,3.5"/>
</dia:attribute>
@@ -3740,7 +3890,7 @@
</dia:connections>
</dia:object>
- <dia:object type="UML - Dependency" version="0" id="O24">
+ <dia:object type="UML - Dependency" version="0" id="O25">
<dia:attribute name="obj_pos">
<dia:point val="0,3.5"/>
</dia:attribute>
@@ -3778,5 +3928,43 @@
</dia:connections>
</dia:object>
+ <dia:object type="UML - Dependency" version="0" id="O26">
+ <dia:attribute name="obj_pos">
+ <dia:point val="0,3.5"/>
+ </dia:attribute>
+ <dia:attribute name="obj_bb">
+ <dia:rectangle val="-0.0515705,2.29861;25.1127,3.55157"/>
+ </dia:attribute>
+ <dia:attribute name="orth_points">
+ <dia:point val="1.0,1.0"/>
+ <dia:point val="1.0,1.0"/>
+ <dia:point val="1.0,1.0"/>
+ </dia:attribute>
+ <dia:attribute name="orth_orient">
+ <dia:enum val="1"/>
+ <dia:enum val="0"/>
+ </dia:attribute>
+ <dia:attribute name="orth_autoroute">
+ <dia:boolean val="true"/>
+ </dia:attribute>
+
+ <dia:attribute name="line_colour">
+ <dia:color val="#000000"/>
+ </dia:attribute>
+ <dia:attribute name="name">
+ <dia:string>#suites_aliases_suite_fkey#</dia:string>
+ </dia:attribute>
+ <dia:attribute name="stereotype">
+ <dia:string>##</dia:string>
+ </dia:attribute>
+ <dia:attribute name="draw_arrow">
+ <dia:boolean val="true"/>
+ </dia:attribute>
+ <dia:connections>
+ <dia:connection handle="0" to="O13" connection="10"/>
+ <dia:connection handle="1" to="O14" connection="9"/>
+ </dia:connections>
+ </dia:object>
+
</dia:layer>
</dia:diagram>
--
2.1.4
>From 211d8cc7740058dca939e52ae8d65fac54865c7c Mon Sep 17 00:00:00 2001
From: Jason Pleau <jason@jpleau.ca>
Date: Sun, 16 Nov 2014 11:27:43 -0500
Subject: [PATCH 1/2] allow redirects to package versions based on
suite/codename
We now check for suite names to redirect to a specific version. If package foo
has version 1.5-1 in sid, going to /src/foo/sid will display as if we went to
/src/foo/1.5-1.
How this works: If we go to /src/foo/sid for example, we iterate through
the package's (foo) suites. If we find 'sid', we simply handle the
request as if it was /src/foo/1.5-1.
This commit also adds a "suites_aliases" table which let us setup aliases to
suites (ie: unstable->sid, testing->jessie). I have also updated the
"updater.py" script to also auto-generate those aliases, by parsing the
symlinks in the dists/ folders.
When a user requests /src/foo/unstable, it will lookup the suites_aliases
table and check if this alias is mapped to a suite. If yes, it will handle
the request as if the user requested that particular suite (in this case,
/src/foo/sid). Which in turns would handle it as if it was /src/foo1.5-1.
(taking the example above)
---
debsources/app/sources/views.py | 19 ++++++++++++++++++-
debsources/debmirror.py | 24 ++++++++++++++++++++++++
debsources/migrate/007-to-008.sql | 10 ++++++++++
debsources/models.py | 18 +++++++++++++++---
debsources/tests/test_webapp.py | 10 ++++++++++
debsources/updater.py | 14 ++++++++++----
testdata | 2 +-
7 files changed, 88 insertions(+), 9 deletions(-)
create mode 100644 debsources/migrate/007-to-008.sql
diff --git a/debsources/app/sources/views.py b/debsources/app/sources/views.py
index e6c6bf1..21b5770 100644
--- a/debsources/app/sources/views.py
+++ b/debsources/app/sources/views.py
@@ -10,7 +10,8 @@ from debsources.excepts import (
from debsources.consts import SLOCCOUNT_LANGUAGES
from debsources import statistics
from debsources.models import (
- PackageName, SourceFile, Checksum, Directory, Location, SuiteInfo)
+ PackageName, SourceFile, Checksum, Directory, Location, SuiteInfo,
+ SuiteAlias)
from ..views import GeneralView, app, session
from ..extract_stats import extract_stats
@@ -305,4 +306,20 @@ class SourceView(GeneralView):
if version == "latest": # we search the latest available version
return self._handle_latest_version(package, path)
else:
+ # Check if an alias was used. If positive, handle the request
+ # as if the suite was used instead of the alias
+ check_for_alias = session.query(SuiteAlias) \
+ .filter(SuiteAlias.alias == version).first()
+ if check_for_alias:
+ version = check_for_alias.suite
+ try:
+ versions_w_suites = PackageName.list_versions_w_suites(
+ session, package)
+ except InvalidPackageOrVersionError:
+ raise Http404Error("%s not found" % package)
+ for version_suite in versions_w_suites:
+ if version in version_suite['suites']:
+ return self._render_location(
+ package, version_suite['version'], path)
+
return self._render_location(package, version, path)
diff --git a/debsources/debmirror.py b/debsources/debmirror.py
index 0ce81ba..a8cfa1a 100644
--- a/debsources/debmirror.py
+++ b/debsources/debmirror.py
@@ -273,6 +273,30 @@ class SourceMirror(object):
return suites
+ def ls_suites_with_aliases(self):
+ """ list suites, as well as their aliases
+
+ Return value: { suite: [aliases] }
+ Example: { sid: [unstable], jessie: [testing] }
+
+ """
+ suites = {}
+
+ def add_suite(suite):
+ if suite not in suites:
+ suites[suite] = []
+
+ for f in os.listdir(self._dists_dir):
+ path = os.path.join(self._dists_dir, f)
+ if os.path.isdir(path):
+ if not os.path.islink(path):
+ add_suite(f)
+ else:
+ add_suite(os.readlink(path))
+ suites[os.readlink(path)].append(f)
+
+ return suites
+
class SourceMirrorArchive(SourceMirror):
"""Handle for a local Debian source mirror archive, i.e. a mirror of
diff --git a/debsources/migrate/007-to-008.sql b/debsources/migrate/007-to-008.sql
new file mode 100644
index 0000000..ba647c7
--- /dev/null
+++ b/debsources/migrate/007-to-008.sql
@@ -0,0 +1,10 @@
+CREATE TABLE suites_aliases (
+ alias VARCHAR NOT NULL,
+ suite VARCHAR NOT NULL,
+ CONSTRAINT suites_aliases_alias_suite_key
+ UNIQUE(alias),
+ CONSTRAINT suites_aliases_suite_fkey
+ FOREIGN KEY (suite) REFERENCES suites_info(name)
+ ON DELETE CASCADE,
+ PRIMARY KEY (alias, suite)
+);
diff --git a/debsources/models.py b/debsources/models.py
index e4d05fc..321206c 100644
--- a/debsources/models.py
+++ b/debsources/models.py
@@ -44,8 +44,8 @@ from debsources.consts import SUITES
Base = declarative_base()
-# used for migrations, see scripts under python/migrate/
-DB_SCHEMA_VERSION = 7
+# used for migrations, see scripts under debsources/migrate/
+DB_SCHEMA_VERSION = 8
class PackageName(Base):
@@ -209,14 +209,26 @@ class SuiteInfo(Base):
version = Column(String, nullable=True)
release_date = Column(Date, nullable=True)
sticky = Column(Boolean, nullable=False)
+ aliases = relationship("SuiteAlias")
- def __init__(self, name, sticky=False, version=None, release_date=None):
+ def __init__(self, name, sticky=False, version=None, release_date=None,
+ aliases=[]):
self.name = name
if version:
self.version = version
if release_date:
self.release_date = release_date
self.sticky = sticky
+ if aliases:
+ self.aliases = aliases
+
+
+class SuiteAlias(Base):
+ """ Aliases for suites (ie: unstable for sid) """
+
+ __tablename__ = "suites_aliases"
+ alias = Column(String, primary_key=True)
+ suite = Column(String, ForeignKey('suites_info.name'))
class File(Base):
diff --git a/debsources/tests/test_webapp.py b/debsources/tests/test_webapp.py
index d4eb3c8..c369581 100644
--- a/debsources/tests/test_webapp.py
+++ b/debsources/tests/test_webapp.py
@@ -384,6 +384,16 @@ class DebsourcesTestCase(unittest.TestCase, DbTestFixture):
follow_redirects=True).data)
self.assertIn("2.03-2", rv['path'])
+ def test_suite_folder(self):
+ rv = json.loads(self.app.get('/api/src/ledit/sid/',
+ follow_redirects=True).data)
+ self.assertIn("2.03-2", rv['path'])
+
+ def test_suite_folder_alias(self):
+ rv = json.loads(self.app.get('/api/src/ledit/unstable/',
+ follow_redirects=True).data)
+ self.assertIn("2.03-2", rv['path'])
+
def test_codesearch_box(self):
rv = self.app.get('/src/ledit/2.03-2/ledit.ml/')
self.assertIn('value="package:ledit "', rv.data)
diff --git a/debsources/updater.py b/debsources/updater.py
index df8f082..187bf8d 100644
--- a/debsources/updater.py
+++ b/debsources/updater.py
@@ -32,7 +32,7 @@ from debsources import statistics
from debsources.consts import DEBIAN_RELEASES, SLOCCOUNT_LANGUAGES
from debsources.debmirror import SourceMirror, SourcePackage
-from debsources.models import SuiteInfo, Suite, Package, \
+from debsources.models import SuiteInfo, Suite, SuiteAlias, Package, \
HistorySize, HistorySlocCount
from debsources.subprocess_workaround import subprocess_setup
@@ -241,7 +241,7 @@ def _rm_package(pkg, conf, session, db_package=None):
logging.exception('failed to remove %s' % pkg)
-def _add_suite(conf, session, suite, sticky=False):
+def _add_suite(conf, session, suite, sticky=False, aliases=[]):
"""add suite to the table of static suite info
"""
@@ -253,9 +253,11 @@ def _add_suite(conf, session, suite, sticky=False):
suite_reldate = suite_info['date']
if sticky:
assert suite_info['archived']
+ db_aliases = [SuiteAlias(alias=alias, suite=suite) for alias in aliases]
db_suite = SuiteInfo(suite, sticky=sticky,
version=suite_version,
- release_date=suite_reldate)
+ release_date=suite_reldate,
+ aliases=db_aliases)
if not conf['dry_run'] and 'db' in conf['backends']:
session.add(db_suite)
@@ -338,6 +340,10 @@ def update_suites(status, conf, session, mirror):
insert_q = sql.insert(Suite.__table__)
insert_params = []
+
+ # load suites aliases
+ suites_aliases = mirror.ls_suites_with_aliases()
+
for (suite, pkgs) in mirror.suites.iteritems():
if not conf['dry_run'] and 'db' in conf['backends']:
session.query(Suite).filter_by(suite=suite).delete()
@@ -368,7 +374,7 @@ def update_suites(status, conf, session, mirror):
if not conf['dry_run'] and 'db' in conf['backends']:
session.query(SuiteInfo).filter_by(name=suite).delete()
- _add_suite(conf, session, suite)
+ _add_suite(conf, session, suite, aliases=suites_aliases[suite])
if not conf['dry_run'] and 'db' in conf['backends'] \
and insert_params:
diff --git a/testdata b/testdata
index 1595214..d79b3ac 160000
--- a/testdata
+++ b/testdata
@@ -1 +1 @@
-Subproject commit 159521491a4c40d96d70a4d6ca354a6b22be3d56
+Subproject commit d79b3acbf332a92d60e4a7e0ff68c70e71e2b6a1
--
2.1.4
Reply to: