initial commit
This commit is contained in:
commit
7b75f18494
6 changed files with 152 additions and 0 deletions
17
Makefile
Normal file
17
Makefile
Normal file
|
@ -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
|
18
run.py
Executable file
18
run.py
Executable file
|
@ -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))
|
3
rundpkg.sh
Executable file
3
rundpkg.sh
Executable file
|
@ -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'
|
45
testapt.cc
Normal file
45
testapt.cc
Normal file
|
@ -0,0 +1,45 @@
|
|||
#include <apt-pkg/debversion.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
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);
|
||||
}
|
12
testdose.ml
Normal file
12
testdose.ml
Normal file
|
@ -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 ();;
|
57
testdpkg.c
Normal file
57
testdpkg.c
Normal file
|
@ -0,0 +1,57 @@
|
|||
#define LIBDPKG_VOLATILE_API 1
|
||||
#define _GNU_SOURCE
|
||||
#include <dpkg/dpkg.h>
|
||||
#include <dpkg/version.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
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);
|
||||
}
|
Loading…
Reference in a new issue