~launchpad-pqm/launchpad/devel

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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#! /bin/sh
#
# Copyright 2009 Canonical Ltd.  This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).

set -e
set -u

ARCHIVEROOT=${TEST_ARCHIVEROOT:-/srv/launchpad.net/ubuntu-archive/ubuntu}
MISCROOT=$ARCHIVEROOT/../ubuntu-misc
LOCKROOT=$ARCHIVEROOT/..
GERMINATEROOT=$ARCHIVEROOT/../ubuntu-germinate

LAUNCHPADROOT=${TEST_LAUNCHPADROOT:-/srv/launchpad.net/codelines/current}
MAINTAINCE_CHECK=$LAUNCHPADROOT/cronscripts/publishing/maintenance-check.py

## Check to see if another germinate run is in progress

LOCKFILE=$LOCKROOT/cron.germinate.lock
if lockfile -! -l 43200 -r 0 "${LOCKFILE}"; then
  echo Another cron.germinate appears to be running
  exit 1
fi

cleanup () {
  rm -f "$LOCKFILE"
}

trap cleanup EXIT

suite=`$LAUNCHPADROOT/scripts/ftpmaster-tools/lp-query-distro.py development`

echo -n "Running germinate... "
cd $GERMINATEROOT

# Clean up temporary files
rm -f germinate.output ALL ALL.sources UBUNTU-* KUBUNTU-* EDUBUNTU-* XUBUNTU-* MYTHBUNTU-* LUBUNTU-* UBUNTUSTUDIO-*
rm -f all_* all.sources_*
rm -rf dists

# Grab local copies of Sources and Packages files, to avoid problems in case
# the archive changes under our feet.
for component in main universe restricted multiverse; do
  base="dists/$suite/$component"
  mkdir -p "$base/source"
  zcat "$ARCHIVEROOT/$base/source/Sources.gz" > "$base/source/Sources"
  for arch in i386 amd64 powerpc armel; do
    mkdir -p "$base/binary-$arch" "$base/debian-installer/binary-$arch"
    zcat "$ARCHIVEROOT/$base/binary-$arch/Packages.gz" \
      > "$base/binary-$arch/Packages"
    zcat "$ARCHIVEROOT/$base/debian-installer/binary-$arch/Packages.gz" \
      > "$base/debian-installer/binary-$arch/Packages"
  done
done

> "$MISCROOT/more-extra.override.$suite.main.new"

germinate_components=main,universe,restricted,multiverse
for distro in ubuntu kubuntu kubuntu-mobile edubuntu xubuntu mythbuntu lubuntu ubuntustudio; do
  DISTRO="$(echo $distro | tr a-z A-Z)"
  germinate_suite="$distro.$suite"
  for arch in i386 amd64 powerpc armel; do
    # Run germinate
    echo " **************** $distro/$suite/$arch ********************* " >> germinate.output
    germinate --no-rdepends -m "file://$(pwd)/" -s "$germinate_suite" -d "$suite" -c "$germinate_components" -a $arch >> germinate.output 2>&1

    # The structure file is generally useful; keep per distro/suite/arch
    # copies for convenience
    cp structure structure_"$distro"_"$suite"_"$arch"

    # Keep per distro/suite/arch copies of 'all' and 'all.sources' for anastacia
    cp all all_"$distro"_"$suite"_"$arch"
    cp all.sources all.sources_"$distro"_"$suite"_"$arch"

    # Keep per distro/suite/arch copies of 'minimal' and 'standard' for jessica
    cp minimal minimal_"$distro"_"$suite"_"$arch"
    cp standard standard_"$distro"_"$suite"_"$arch"

    # Keep amalgamated copies of 'all' and 'all.sources', just for convenience
    cat all >> ALL; cat all.sources >> ALL.sources

    # We need to fetch a number of seeds so that we can generate Task fields
    # for them. This changes over time and differs from derivative to
    # derivative, so it's best to just fetch them all.
    taskseeds="$(cut -d: -f1 structure | xargs -n1 | sort -u)"

    for seed in $taskseeds; do
      cp "$seed" "$seed"_"$distro"_"$suite"_"$arch"
    done
    echo " ********************************************************************** " >> germinate.output
    echo "" >> germinate.output
    echo -n "."

    ## Generate apt-ftparchive 'extra' overrides for Task: fields
    for seed in $taskseeds; do
      if ! grep -iq '^Task-' "$seed.seedtext"; then
	continue
      fi
      # If the seed contains Task-Name header, override the normal behavior
      if grep -iq '^Task-Name:' "$seed.seedtext"; then
	task=$(grep '^Task-Name:' "$seed.seedtext" | cut -d: -f2)
      elif grep -iq '^Task-Per-Derivative:' "$seed.seedtext"; then
	task="$distro-$seed"
      else
	# If a seed is not per-derivative, then we only honour it for Ubuntu,
	# and its task name is archive-global.
	if [ "$distro" = ubuntu ]; then
	  task="$seed"
	else
	  continue
	fi
      fi
      if grep -iq '^Task-Seeds:' "$seed.seedtext"; then
	scanseeds="$( (grep '^Task-Seeds:' "$seed.seedtext" | cut -d: -f2 | xargs -n1; echo "$seed") | sort -u )"
      else
	scanseeds="$seed"
      fi
      for scanseed in $scanseeds; do
	egrep -v -- "^(-|Package| )" "$scanseed"_"$distro"_"$suite"_"$arch" | awk '{print $1}' | sed -e "s,$,/$arch  Task  $task," | sort -u >> "$MISCROOT/more-extra.override.$suite.main.new"
      done
    done

    # Generate apt-ftparchive 'extra' overrides for Build-Essential: fields
    if [ -e build-essential ] && [ "$distro" = ubuntu ]; then
      # Keep a copy, just for convenience
      cp build-essential build-essential_"$distro"_"$suite"_"$arch"
      egrep -v -- "^(-|Package| )" build-essential_"$distro"_"$suite"_"$arch" | awk '{print $1}' | sed -e "s,$,/$arch  Build-Essential  yes," | sort -u >> "$MISCROOT/more-extra.override.$suite.main.new"
    fi
  done
done
echo " done."

mv -f "$MISCROOT/more-extra.override.$suite.main.new" "$MISCROOT/more-extra.override.$suite.main"

# Now generate the Supported extra overrides for all supported distros.
SUITES=`$LAUNCHPADROOT/scripts/ftpmaster-tools/lp-query-distro.py supported`
for supported_suite in $SUITES; do
    echo -n "Running maintenance-check for $supported_suite... "
    # The support timeframe information is stored here
    SUPPORTED="$MISCROOT/more-extra.override.$supported_suite.main.supported"
    # This is the target override file that contains germinate plus support info
    TARGET="$MISCROOT/more-extra.override.$supported_suite.main"
    # Debug/Log information 
    LOG="_maintenance-check.$supported_suite.stderr"
    if $MAINTAINCE_CHECK $supported_suite > $SUPPORTED 2> $LOG; then
        # The target file may be missing on the server and the script should
        # not fail if that is the case.
        touch $TARGET
        # Remove old "Supported" info from extra-overrides as it may be 
        # stale now and we replace it with fresh content below.
        sed /"^.* Supported"/d $TARGET > ${TARGET}.new
        cat $SUPPORTED >> ${TARGET}.new
        mv ${TARGET}.new $TARGET
    fi
    echo " done"
done