~ubuntu-branches/ubuntu/karmic/net-retriever/karmic

« back to all changes in this revision

Viewing changes to vergt.c

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2008-05-30 12:44:30 UTC
  • Revision ID: james.westby@ubuntu.com-20080530124430-85f6qn45bw8h9xo3
Tags: 1.21ubuntu2
* Deduplicate Packages files before passing them to anna (LP: #234486).
  Circumstances conspire to make this excessively difficult, including
  requiring net-retriever to become Architecture: any; this should really
  be done in libdebian-installer, but for the meantime that's even harder.
* Fetch packages from security host if trying to fetch them from the main
  host fails (LP: #94398).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdio.h>
 
2
#include <debian-installer.h>
 
3
 
 
4
/* This program is a nasty hack around udpkg not having --compare-versions.
 
5
 * Furthermore, doing this in net-retriever at all is a nasty hack around
 
6
 * libdebian-installer not deduplicating Packages files. Don't even think
 
7
 * about relying on this program ANYWHERE else.
 
8
 */
 
9
int main(int argc, char **argv)
 
10
{
 
11
        di_package dummyleft, dummyright;
 
12
        di_package_version *left, *right;
 
13
 
 
14
        if (argc != 3) {
 
15
                fprintf(stderr, "usage: vergt VER1 VER2\n");
 
16
                return 2;
 
17
        }
 
18
 
 
19
        /* libdebian-installer has a crazy interface that won't let me parse
 
20
         * raw strings, so I need this dance.
 
21
         */
 
22
        dummyleft.version = argv[1];
 
23
        dummyright.version = argv[2];
 
24
 
 
25
        left = di_package_version_parse(&dummyleft);
 
26
        if (!left) {
 
27
                fprintf(stderr, "failed to parse version %s\n", argv[1]);
 
28
                return 2;
 
29
        }
 
30
        right = di_package_version_parse(&dummyright);
 
31
        if (!right) {
 
32
                fprintf(stderr, "failed to parse version %s\n", argv[2]);
 
33
                return 2;
 
34
        }
 
35
 
 
36
        if (di_package_version_compare(left, right) > 0)
 
37
                return 0;
 
38
        else
 
39
                return 1;
 
40
}