Toggle navigation
Toggle navigation
This project
Loading...
Sign in
josch
/
debversioncomp
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Authored by
josch
2014-06-25 20:15:31 +0200
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Commit
90cd79dc69ee885e5f6d132daf1e666d06dd8d6c
90cd79dc
1 parent
86e0a8cb
add checking sort -V
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
111 additions
and
5 deletions
Makefile
inequalityfilter.cc
run.py
testapt.cc
testsort.sh
Makefile
View file @
90cd79d
testinput
:
run.py
./run.py > testinput
./run.py /var/lib/apt/lists/ftp.debian.org_debian_dists_sid_main_binary-amd64_Packages > testinput
testinput.1000
:
run.py
./run.py /var/lib/apt/lists/ftp.debian.org_debian_dists_sid_main_binary-amd64_Packages | awk
'NR % 1000 == 1'
> testinput.1000
testinput.unequal
:
testinput inequalityfilter
./inequalityfilter < testinput > testinput.unequal
testinput.unequal.1000
:
testinput inequalityfilter
./inequalityfilter < testinput | awk
'NR % 1000 == 1'
> testinput.unequal.1000
testdpkg
:
testdpkg.c
gcc testdpkg.c -ldpkg -o testdpkg
...
...
@@ -10,12 +19,31 @@ testapt: testapt.cc
testdose
:
testdose.ml
ocamlfind ocamlc -package dose3 -linkpkg testdose.ml -o testdose
inequalityfilter
:
inequalityfilter.cc
g++ inequalityfilter.cc -lapt-pkg -o inequalityfilter
.PHONY
:
test
test
:
testinput testdpkg testapt
test
:
testinput testdpkg testapt
testdose rundpkg.sh
./rundpkg.sh < testinput | md5sum
./testapt < testinput | md5sum
./testdose < testinput | md5sum
.PHONY
:
test.1000
test.1000
:
testinput.1000 testdpkg testapt testdose rundpkg.sh
./rundpkg.sh < testinput.1000 | md5sum
./testapt < testinput.1000 | md5sum
./testdose < testinput.1000 | md5sum
.PHONY
:
testsort
testsort
:
testinput.unequal testapt testsort.sh
./testapt < testinput.unequal | md5sum
./testsort.sh < testinput.unequal | md5sum
.PHONY
:
testsort.1000
testsort.1000
:
testinput.unequal.1000 testapt testsort.sh
./testapt < testinput.unequal.1000 | md5sum
./testsort.sh < testinput.unequal.1000 | md5sum
.PHONY
:
clean
clean
:
rm -f testapt testdose testdose.cmi testdose.cmo testdpkg testinput
rm -f testapt testdose testdose.cmi testdose.cmo testdpkg testinput
inequalityfilter
...
...
inequalityfilter.cc
0 → 100644
View file @
90cd79d
#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
)
{
fputs
(
orig2
,
stdout
);
}
//fputs(orig2, stdout);
free
(
orig1
);
free
(
orig2
);
}
exit
(
EXIT_SUCCESS
);
}
run.py
View file @
90cd79d
#!/usr/bin/env python
from
__future__
import
print_function
import
deb822
import
sys
versions
=
set
()
with
open
(
"/home/josch/gsoc2012/bootstrap/Packages"
)
as
f
:
for
pkg
in
deb822
.
Deb822
.
iter_paragraphs
(
f
,
use_apt_pkg
=
False
):
with
open
(
sys
.
argv
[
1
]
)
as
f
:
for
pkg
in
deb822
.
Deb822
.
iter_paragraphs
(
f
):
ver
=
pkg
.
get
(
'Version'
)
if
ver
:
versions
.
add
(
ver
)
...
...
@@ -13,6 +15,8 @@ with open("/home/josch/gsoc2012/bootstrap/Packages") as f:
# through the list of versions and comparing every version with all that come
# after it
versions
=
sorted
(
versions
)
l
=
len
(
versions
)
for
i
,
v1
in
enumerate
(
versions
):
print
(
"
%
f
%%
\r
"
%
((
i
*
100.0
)
/
l
),
file
=
sys
.
stderr
,
end
=
""
)
for
v2
in
versions
[
i
+
1
:]:
print
(
"
%
s
\t
%
s"
%
(
v1
,
v2
))
...
...
testapt.cc
View file @
90cd79d
...
...
@@ -37,6 +37,10 @@ int main()
}
else
{
fputc
(
'<'
,
stdout
);
}
/*
fputc(' ', stdout);
fputs(orig2, stdout);
*/
//fputs(orig2, stdout);
free
(
orig1
);
free
(
orig2
);
...
...
testsort.sh
0 → 100755
View file @
90cd79d
#!/bin/sh
# some examples where `sort -V` does the wrong thing:
# 0.04-1-5 0.4-3
# 0.1+20080921-2 0.1-1+b8
# 0.1+dfsg-4 000.001-4
# 0.1.0+20071012-1.2 0.1.0-1.1
# 0.3.0+20091229-1 0.3.0-7.2
# 0.6.0+git20130305-5 0.6.0-5+b1
# 0:2009.10.04-1 1.0pre11-1
# 0:2009.10.04-1 1.240-1
# 0:2009.10.04-1 1.7.2.4-4.1
# 0:2009.10.04-1 2.3-12
# 0:2009.10.04-1 8.0.184.15484+dfsg-2
# 1.0+dfsg-1 1.00-6
i
=
0
while
read
line;
do
printf
"
$i
\r
"
>&2
i
=
$((
i+1
))
set
--
$line
newest
=
$(
(
echo
"
$1
"
;
echo
"
$2
"
)
| sort -V | tail -n1
)
if
[
"
$1
"
!
=
"
$newest
"
]
;
then
printf
"<"
else
printf
">"
fi
printf
" %s
\t
%s
\n
"
$1
$2
done
Please
register
or
sign in
to post a comment