summaryrefslogtreecommitdiff
path: root/jenkins/builddebcheck-pgapt
blob: 16ee88f632299e99ea2accd069274184f54f3afd (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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/bin/bash

# expected parameters:
#   distribution (without -pgdg, default "sid")
#   architecture (default "amd64")
#   stage (testing or production, default "testing")
# expected directories: chroots in /home/chroot
# needs dose3 >= 4

set -eu

error () {
  echo "Error: $@" >&2
  exit 2
}

# read pgapt config
for dir in . .. $HOME/apt.postgresql.org; do
  test -f $dir/pgapt.conf || continue
  . $dir/pgapt.conf
  PGAPTDIR="$dir"
  break
done

: ${distribution:=sid} ${architecture:=amd64} ${stage:=testing}
set_dist_vars $distribution

LISTSDIR="/home/chroot/$distribution-$architecture/var/lib/apt/lists"
[ -d "$LISTSDIR" ] || error "$LISTSDIR not found"
BPODIR="/home/chroot/$distribution-$architecture/var/lib/apt/backports"
DISTSDIR="$REPO_HOST$REPO_URL_PATH/dists"

trap 'rm -f ${BPOSRC:-} ${TMP:-}' EXIT

remove_packages ()
{
  FILE="$1"
  shift
  for pkg in "$@"; do
    TMP="$FILE.$$"
    grep-dctrl --not -S --eregex "$pkg" $FILE > $TMP
    mv $TMP $FILE
  done
}

# include all Packages files for "distribution" (main, universe, security) and "distribution-updates" (main, universe)
for FILE in $LISTSDIR/*_dists_${distribution}{,-updates}_*_binary-${architecture}_Packages; do
  [ -f "$FILE" ] || continue
  PKG="${PKG:-} $FILE"
done

# include pgdg dists
case $stage in
  production) DIST="$distribution$REPO_DIST_SUFFIX" ;;
  testing)    DIST="$distribution$REPO_DIST_SUFFIX-testing" ;;
  *) error "Bad stage $stage" ;;
esac

# download apt.pg.o packages files
wget --no-verbose --mirror $(for component in $COMPONENTS; do echo http://$DISTSDIR/$DIST/$component/binary-$architecture/Packages.bz2 http://$DISTSDIR/$DIST/$component/source/Sources.bz2; done)
bunzip2 -fk $(for component in $COMPONENTS; do echo $DISTSDIR/$DIST/$component/binary-$architecture/Packages.bz2 $DISTSDIR/$DIST/$component/source/Sources.bz2; done)
echo

# packages not depending on backports
PKG="$PKG $DISTSDIR/$DIST/main/binary-${architecture}/Packages"
MAINSRC=$DISTSDIR/$DIST/main/source/Sources

if [ "$HAS_BACKPORTS" ]; then
    [ -f $PGAPTDIR/jenkins/packages.backports ] || error "$PGAPTDIR/jenkins/packages.backports not found"
    remove_packages $MAINSRC $(cat $PGAPTDIR/jenkins/packages.backports*)

    # packages depending on backports
    BPOSRC=$(mktemp ${DIST}_bpo_source_Sources.XXXXXX)
    for pkg in $(cat $PGAPTDIR/jenkins/packages.backports*); do
      grep-dctrl -S $pkg < $MAINSRC >> $BPOSRC || :
    done

    # include backports packages file
    [ -d "$BPODIR" ] || error "$BPODIR not found"
    for FILE in $BPODIR/*_dists_${distribution}-backports_main_binary-${architecture}_Packages ; do
      [ -f "$FILE" ] || error "$FILE not found"
      BPO="$FILE"
    done
fi

# packages not tested on specific architectures
case $architecture in
  ppc64el)
    remove_packages $MAINSRC buildapp cffi cl-unicode pgloader sbcl plv8
    ;;
  s390x)
    remove_packages $MAINSRC buildapp cffi cl-unicode pgloader sbcl plv8 \
        mobilitydb pgfaceting pg-roaringbitmap timescaledb
    ;;
esac

# packages not tested on certain dists
# postgresql-11 needs llvm-15 (disabled via pkg.postgresql.nollvm, but let's not set that globally here)
case $distribution in sid|trixie) remove_packages $MAINSRC postgresql-11 ;; esac
# vip-manager needs newer Go version to compile, but .debs are copied to older dists
case $distribution in
  buster|groovy|focal)
    remove_packages $MAINSRC vip-manager ;;
esac
# zstd is too old on stretch, buster and bionic
#case $distribution in stretch|buster|bionic) PROFILES="pkg.postgresql.nozstd" ;; esac

# run builddebcheck
BUILDDEBCHECK="dose-builddebcheck -v -f -e --deb-native-arch=$architecture ${PROFILES:+--deb-profiles=$PROFILES}"

echo "### Running builddebcheck: main, packages not needing backports"
( set -x; $BUILDDEBCHECK $PKG $MAINSRC ) || EXIT=1
echo

if test -s "${BPO:-}"; then
  echo "### Running builddebcheck: main, packages needing backports"
  grep '^Package:' $BPOSRC || :
  ( set -x; $BUILDDEBCHECK $PKG $BPO $BPOSRC ) || EXIT=1
  echo
fi

for component in $COMPONENTS; do
  [ "$component" = "main" ] && continue
  sources="$DISTSDIR/$DIST/$component/source/Sources"
  [ -s $sources ] || continue # skip empty file
  echo "### Running builddebcheck: $sources"
  grep '^Package:' $sources
  ( set -x; $BUILDDEBCHECK $PKG $sources ) || EXIT=1
  echo
done

exit ${EXIT:-0}