blob: 4bd1c41605048ff7ecb0912e56732c1816ac4461 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
#!/bin/bash
# Copyright 2014 Holger Levsen <holger@layer-acht.org>
# released under the GPLv=2
. /srv/jenkins/bin/common-functions.sh
common_init "$@"
# define db
PACKAGES_DB=/var/lib/jenkins/reproducible.db
INIT=/var/lib/jenkins/reproducible.init
if [ ! -f $PACKAGES_DB ] ; then
echo "$PACKAGES_DB doesn't exist, no builds possible."
exit 1
fi
# this needs sid entries in sources.list:
grep deb-src /etc/apt/sources.list | grep sid
# try apt-get update twice, else fail gracefully, aka not.
sudo apt-get update || ( sleep $(( $RANDOM % 70 + 30 )) ; sudo apt-get update || true )
# update sources table in db
update_sources_table() {
TMPFILE=$(mktemp)
curl $MIRROR/dists/sid/main/source/Sources.xz > $TMPFILE
CSVFILE=$(mktemp)
(xzcat $TMPFILE | egrep "(^Package:|^Version:)" | sed -s "s#^Version: ##g; s#Package: ##g; s#\n# #g"| while read PKG ; do read VERSION ; echo "$PKG,$VERSION" ; done) > $CSVFILE
sqlite3 -csv -init $INIT ${PACKAGES_DB} "DELETE from sources"
echo ".import $CSVFILE sources" | sqlite3 -csv -init $INIT ${PACKAGES_DB}
# update amount of available packages (for doing statistics later)
P_IN_SOURCES=$(xzcat $TMPFILE | grep "^Package" | grep -v "^Package-List:" | cut -d " " -f2 | sort -u | wc -l)
sqlite3 -init $INIT ${PACKAGES_DB} "REPLACE INTO source_stats VALUES (\"sid\", \"${P_IN_SOURCES}\")"
rm $CSVFILE # $TMPFILE is still being used
}
set +x
if [ $1 = "unknown" ] ; then
update_sources_table
AMOUNT=$2
REAL_AMOUNT=0
GUESSES=$(echo "${AMOUNT}*3" | bc)
PACKAGES=""
# FIXME: blacklisted is a valid status in the db which should be used...
CANDIDATES=$(xzcat $TMPFILE | grep "^Package" | grep -v "^Package-List:" | cut -d " " -f2 | egrep -v "^(linux|cups|zurl|openclipart)$" | sort -R | head -$GUESSES | xargs echo)
for PKG in $CANDIDATES ; do
if [ $REAL_AMOUNT -eq $AMOUNT ] ; then
continue
fi
RESULT=$(sqlite3 ${PACKAGES_DB} "SELECT name FROM source_packages WHERE name = \"${PKG}\"")
if [ "$RESULT" = "" ] ; then
PACKAGES="${PACKAGES} $PKG"
fi
done
elif [ $1 = "known" ] ; then
update_sources_table
AMOUNT=$2
PACKAGES=$(sqlite3 -init $INIT ${PACKAGES_DB} "SELECT DISTINCT source_packages.name FROM source_packages,sources WHERE sources.version IN (SELECT version FROM sources WHERE name=source_packages.name ORDER by sources.version DESC LIMIT 1) AND (( source_packages.status = 'unreproducible' OR source_packages.status = 'FTBFS') AND source_packages.name = sources.name AND source_packages.version < sources.version) ORDER BY source_packages.build_date LIMIT $AMOUNT" | xargs -r echo)
else
# CANDIDATES is defined in that file
. /srv/jenkins/bin/reproducible_candidates.sh
PACKAGES=""
AMOUNT=$2
REAL_AMOUNT=0
for i in $(seq 0 ${#CANDIDATES[@]}) ; do
if [ $REAL_AMOUNT -eq $AMOUNT ] ; then
continue
fi
PKG=${CANDIDATES[$i]}
RESULT=$(sqlite3 ${PACKAGES_DB} "SELECT name FROM source_packages WHERE name = \"${PKG}\"")
if [ "$RESULT" = "" ] ; then
PACKAGES="${PACKAGES} $PKG"
let "REAL_AMOUNT=REAL_AMOUNT+1"
fi
done
fi
AMOUNT=0
for PKG in $PACKAGES ; do
let "AMOUNT=AMOUNT+1"
done
echo "============================================================================="
echo "The following $AMOUNT source packages will be scheduled: ${PACKAGES}"
echo "============================================================================="
echo
rm -f $TMPFILE
|