commit 7b75f18494821b985fa77abf0490b52b8abbad7d Author: josch Date: Sun Jun 1 10:31:24 2014 +0200 initial commit diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2a8ac5a --- /dev/null +++ b/Makefile @@ -0,0 +1,17 @@ +testinput: run.py + ./run.py > testinput + +testdpkg: testdpkg.c + gcc testdpkg.c -ldpkg -o testdpkg + +testapt: testapt.cc + g++ testapt.cc -lapt-pkg -o testapt + +testdose: testdose.ml + ocamlfind ocamlc -package dose3 -linkpkg testdose.ml -o testdose + +.PHONY: test +test: testinput testdpkg testapt + ./rundpkg.sh < testinput | md5sum + ./testapt < testinput | md5sum + ./testdose < testinput | md5sum diff --git a/run.py b/run.py new file mode 100755 index 0000000..2371938 --- /dev/null +++ b/run.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python + +import deb822 + +versions = set() +with open("/home/josch/gsoc2012/bootstrap/Packages") as f: + for pkg in deb822.Deb822.iter_paragraphs(f, use_apt_pkg=False): + ver = pkg.get('Version') + if ver: + versions.add(ver) + +# create a list of all possible combinations of two versions by iterating +# through the list of versions and comparing every version with all that come +# after it +versions = sorted(versions) +for i,v1 in enumerate(versions): + for v2 in versions[i+1:]: + print("%s\t%s"%(v1,v2)) diff --git a/rundpkg.sh b/rundpkg.sh new file mode 100755 index 0000000..71551cf --- /dev/null +++ b/rundpkg.sh @@ -0,0 +1,3 @@ +#!/bin/sh +# we need to do this because of bug#47214 +split --lines=1000000 --numeric-suffixes --suffix-length=4 --filter='./testdpkg' diff --git a/testapt.cc b/testapt.cc new file mode 100644 index 0000000..4f76fcf --- /dev/null +++ b/testapt.cc @@ -0,0 +1,45 @@ +#include +#include +#include +#include + +int main() +{ + char *line = NULL; + char *token; + char *orig1; + char *orig2; + char *ver1; + char *ver2; + size_t len = 0; + size_t read; + int ret; + while ((read = getline(&line, &len, stdin)) != -1) { + //fprintf(stderr, "%s", line); + orig1 = strdup(line); + orig2 = strdup(line); + token = orig1; + ver1 = strsep(&token, "\t"); + if (ver1 == NULL) { + fprintf(stderr, "cannot read token1"); + exit(EXIT_FAILURE); + } + ver2 = strsep(&token, "\n"); + if (ver2 == NULL) { + fprintf(stderr, "cannot read token2"); + exit(EXIT_FAILURE); + } + ret = debVS.CmpVersion(ver1, ver2); + if (ret == 0) { + fputc('=', stdout); + } else if (ret > 0) { + fputc('>', stdout); + } else { + fputc('<', stdout); + } + //fputs(orig2, stdout); + free(orig1); + free(orig2); + } + exit(EXIT_SUCCESS); +} diff --git a/testdose.ml b/testdose.ml new file mode 100644 index 0000000..01b66d5 --- /dev/null +++ b/testdose.ml @@ -0,0 +1,12 @@ +open Debian +open ExtLib + +let main () = + List.iter (fun line -> + let ver1, ver2 = String.split line "\t" in + let ret = Version.compare ver1 ver2 in + print_char (if ret > 0 then '>' else if ret < 0 then '<' else '=') + ) (Std.input_list stdin); +;; + +main ();; diff --git a/testdpkg.c b/testdpkg.c new file mode 100644 index 0000000..0a54824 --- /dev/null +++ b/testdpkg.c @@ -0,0 +1,57 @@ +#define LIBDPKG_VOLATILE_API 1 +#define _GNU_SOURCE +#include +#include +#include +#include +#include + +int main() +{ + char *line = NULL; + char *token; + char *orig1; + char *orig2; + char *ver1; + char *ver2; + size_t len = 0; + size_t read; + struct dpkg_version a, b; + int ret; + while ((read = getline(&line, &len, stdin)) != -1) { + //fprintf(stderr, "%s", line); + orig1 = strdup(line); + orig2 = strdup(line); + token = orig1; + ver1 = strsep(&token, "\t"); + if (ver1 == NULL) { + fprintf(stderr, "cannot read token1"); + exit(EXIT_FAILURE); + } + if(parseversion(&a, ver1, NULL)) { + fprintf(stderr, "cannot parse version1 %s\n", ver1); + exit(EXIT_FAILURE); + } + ver2 = strsep(&token, "\n"); + if (ver2 == NULL) { + fprintf(stderr, "cannot read token2"); + exit(EXIT_FAILURE); + } + if(parseversion(&b, ver2, NULL)) { + fprintf(stderr, "cannot parse version2 %s\n", ver2); + exit(EXIT_FAILURE); + } + ret = dpkg_version_compare(&a, &b); + if (ret == 0) { + fputc('=', stdout); + } else if (ret > 0) { + fputc('>', stdout); + } else { + fputc('<', stdout); + } + //fputs(orig2, stdout); + free(orig1); + free(orig2); + } + exit(EXIT_SUCCESS); +}