]> git.donarmstrong.com Git - wannabuild.git/blob - triggers/common
small fixes to allow use warnings
[wannabuild.git] / triggers / common
1 # vim:set et ts=4 sw=4 ft=bash ai:
2
3 set -eE
4
5 LANG=C
6 PATH="/bin:/usr/bin:/org/wanna-build/bin:/org/buildd.debian.org/bin:/org/wanna-build/triggers"
7 ARCHIVE_MAIN="/org/wanna-build/tmp/archive/debian"
8 ARCHIVE_BASE="/org/wanna-build/tmp/archive/${ARCHIVE}"
9 PAS_BASE="/org/buildd.debian.org/web/quinn-diff"
10 PAS_FILE="$PAS_BASE/$SUITE/Packages-arch-specific"
11 LOCKFILE="${ARCHIVE_BASE}/lock"
12 ARCHS_lenny="alpha amd64 arm armel hppa i386 ia64 mips mipsel powerpc s390 sparc"
13 ARCHS_squeeze="amd64 armel i386 ia64 mips mipsel powerpc s390 sparc kfreebsd-amd64 kfreebsd-i386"
14 ARCHS_wheezy="amd64 armel i386 ia64 mips mipsel powerpc s390 sparc kfreebsd-amd64 kfreebsd-i386"
15 ARCHS_sid="$ARCHS_squeeze alpha hppa hurd-i386"
16
17 # Creates a working environment within the corresponding archive
18 # directory and jumps there.
19 ensure_workdir() {
20     mkdir -p "${ARCHIVE_BASE}/workdir"
21     cd "${ARCHIVE_BASE}/workdir"
22 }
23
24 # Puts the list of architectures for a given suite onto stdout.
25 get_architectures() {
26     SUITE="$1"
27
28     if [ "$SUITE" = "lenny" -o "$SUITE" = "oldstable" ]; then echo $ARCHS_lenny
29     elif [ "$SUITE" = "squeeze" -o "$SUITE" = "stable" ]; then echo $ARCHS_squeeze
30     elif [ "$SUITE" = "wheezy" -o "$SUITE" = "testing" ]; then echo $ARCHS_wheezy
31     elif [ "$SUITE" = "unstable" -o "$SUITE" = "sid" ]; then echo $ARCHS_sid
32     elif [ "$SUITE" = "experimental" ]; then echo $ARCHS_sid
33     else
34         echo "Unknown suite encountered, aborting." >&2
35         exit 1
36     fi
37 }
38
39 cleanup() {
40     rm -rf "$LOCKFILE"
41 }
42
43 ensure_lock() {
44     if lockfile -! -r 10 -l 6000 "$LOCKFILE"
45     then
46         echo "Cannot lock $LOCKFILE, aborting."
47         exit 1
48     fi
49 }
50
51 trigger_wb_update() {
52     SUITE="$1"
53     ARCHS="$2"
54     SOURCES="$3"
55     PACKAGES="$4"
56     WB_SUITE="$5"
57
58     if [ -z "$WB_SUITE" ]
59     then
60         WB_SUITE="${SUITE}"
61     fi
62
63     echo "`date`: Processing ${ARCHIVE}/${SUITE} ..."
64
65     keep-latest source $(eval echo ${SOURCES}) > Sources.${SUITE}
66     for ARCH in ${ARCHS}; do
67         keep-latest ${ARCH} $(eval echo $(echo ${PACKAGES} | sed -e 's/%ARCH%/${ARCH}/g')) > Packages.${SUITE}.${ARCH}
68     done
69     [ -f Packages.${SUITE}.i386.non-free ] && PNF="Packages.${SUITE}.%ARCH%.non-free" || PNF=""
70     [ -f Sources.${SUITE}.non-free ] && SNF="Sources.${SUITE}.non-free" || SNF=""
71     parallel -l 5 -i wanna-build -v --Pas ${PAS_FILE} --merge-v3 -A "{}" --dist=$WB_SUITE Packages.${SUITE}.%ARCH% $PNF . Sources.${SUITE} $SNF . Packages.${SUITE}.%ARCH% -- ${ARCHS} || true
72
73     echo "`date`: ${ARCHIVE}/${SUITE} done"
74 }
75
76 trigger_wb_update_for_overlay() {
77     SUITE="$1"
78     ARCHS="$2"
79     SOURCES_BASE="$3"
80     PACKAGES_BASE="$4"
81     SOURCES="$5"
82     PACKAGES="$6"
83     WB_SUITE="$7"
84     WHITELIST_FILE="$8"
85
86     if [ -z "$WB_SUITE" ]
87     then
88         WB_SUITE="${SUITE}"
89     fi
90
91     echo "`date`: Processing ${ARCHIVE}/${SUITE} ..."
92
93     keep-latest source $(eval echo ${SOURCES}) > Sources.${SUITE}
94     keep-latest source $(eval echo Sources.${SUITE} ${SOURCES_BASE}) > Sources.${SUITE}-all
95     for ARCH in ${ARCHS}; do
96         keep-latest ${ARCH} $(eval echo $(echo ${PACKAGES} | sed -e 's/%ARCH%/${ARCH}/g')) > Packages.${SUITE}.${ARCH}
97         keep-latest ${ARCH} Packages.${SUITE}.${ARCH} $(eval echo $(echo ${PACKAGES_BASE} | sed -e 's/%ARCH%/${ARCH}/g')) > Packages.${SUITE}.${ARCH}-all
98     done
99     [ -f Packages.${SUITE}.i386.non-free ] && PNF="Packages.${SUITE}.%ARCH%.non-free" || PNF=""
100     [ -f Sources.${SUITE}.non-free ] && SNF="Sources.${SUITE}.non-free" || SNF=""
101     echo parallel -l 5 -i wanna-build -v --Pas ${PAS_FILE} --merge-v3 -A "{}" --dist=$WB_SUITE Packages.${SUITE}.%ARCH% $PNF . Sources.${SUITE} $SNF . \
102         Packages.${SUITE}.%ARCH%-all . Sources.${SUITE}-all $SNF -- ${ARCHS} 
103     parallel -l 5 -i wanna-build -v --Pas ${PAS_FILE} --merge-v3 -A "{}" --dist=$WB_SUITE Packages.${SUITE}.%ARCH% $PNF . Sources.${SUITE} $SNF . \
104         Packages.${SUITE}.%ARCH%-all . Sources.${SUITE}-all $SNF -- ${ARCHS} || true
105
106     echo "`date`: ${ARCHIVE}/${SUITE} done"
107 }
108
109 # This is for the case where you get also get packages from
110 # a secondary unrelated suite, the buildd's chroot also has
111 # those packages files in it.
112 # Examples are *-{volatile,backports,edu} and experimental
113 # This is not for something like stable and proposed-updates
114 trigger_wb_update_with_secondary() {
115     SUITE="$1"
116     ARCHS="$2"
117     PACKAGES_BASE="$3"
118     SOURCES="$4"
119     PACKAGES="$5"
120     WB_SUITE="$6"
121     WHITELIST_FILE="$7"
122
123     if [ -z "$WB_SUITE" ]
124     then
125         WB_SUITE="${SUITE}"
126     fi
127
128     echo "`date`: Processing ${ARCHIVE}/${SUITE} ..."
129
130     keep-latest source $(eval echo ${SOURCES}) > Sources.${SUITE}
131
132     for ARCH in ${ARCHS}; do
133         keep-latest ${ARCH} $(eval echo $(echo ${PACKAGES} | sed -e 's/%ARCH%/${ARCH}/g')) > Packages.${SUITE}.${ARCH}
134         ucat Packages.${SUITE}.${ARCH} $(eval echo $(echo ${PACKAGES_BASE} | sed -e 's/%ARCH%/${ARCH}/g')) > Packages.${SUITE}.${ARCH}-all
135     done
136     [ -f Packages.${SUITE}.i386.non-free ] && PNF="Packages.${SUITE}.%ARCH%.non-free" || PNF=""
137     [ -f Sources.${SUITE}.non-free ] && SNF="Sources.${SUITE}.non-free" || SNF=""
138     parallel -l 5 -i wanna-build -v --Pas ${PAS_FILE} --merge-v3 -A "{}" --dist=$WB_SUITE Packages.${SUITE}.%ARCH% $PNF . Sources.${SUITE} $SNF . \
139         Packages.${SUITE}.%ARCH%-all -- ${ARCHS} || true
140
141     echo "`date`: ${ARCHIVE}/${SUITE} done"
142 }
143
144 ucat() {
145     for FILE in $*; do
146       if [ -f ${FILE} ]; then
147         case $FILE in
148             *.gz)
149                 zcat $FILE
150                 ;;
151             *.bz2)
152                 bzcat $FILE
153                 ;;
154             *)
155                 cat $FILE
156                 ;;
157         esac
158       fi
159     done
160 }
161
162 filter_out_nonfree() {
163     INPUT="$1"
164     OUTPUT="$2"
165
166     gunzip -c "$INPUT" | grep-dctrl -v -r -F Section 'non-free/.*' | gzip -c > "$OUTPUT"
167 }
168