summaryrefslogtreecommitdiffstats
path: root/test/test_uscan_ftp
blob: e49a9a9c8177b160506bf9735ffdf7424b7fbcde (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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
#!/bin/bash
# vim: set shiftwidth=4 tabstop=8 noexpandtab:

# Copyright (C) 2018, Osamu Aoki <osamu@debian.org>
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# On Debian systems, the complete text of the GNU General Public License
# version 3 can be found in the /usr/share/common-licenses/GPL-3 file.

set -u

TESTTYPE=FTP
. ./lib_test_uscan

DEB_HOST_OS="$(dpkg-architecture -qDEB_HOST_ARCH_OS)"
if [ "$DEB_HOST_OS" = "kfreebsd" ]; then
    # kbsd has a non-working semaphore, that is needed here.
    echo "This test is not supported on $(dpkg-architecture -qDEB_HOST_ARCH), skipping"
    exit 0
fi

COMMAND="uscan --no-conf"

# set safe defaults
WEBSCRIPT=":"
DEBUGECHO=":"
DEBUGLSLR=":"
DEBUGBASH=":"
# comment out for debug
#COMMAND="$COMMAND --debug"
#COMMAND="$COMMAND --verbose"
#DEBUGECHO=echo
#DEBUGLSLR="ls -laR"
#DEBUGLSLR="ls -la"
#DEBUGBASH="bash -i"

# Initial Debian revision value is distribution dependent
SUFFIX="1"
if which dpkg-vendor >/dev/null 2>&1; then
    VENDER="$(dpkg-vendor --query Vendor 2>/dev/null|tr 'A-Z' 'a-z')"
    case "$VENDER" in
        debian) SUFFIX="1" ;;
        *) SUFFIX="0${VENDER}1" ;;
    esac
fi

cleanup(){
    kill -9 $(cat $TMPDIR/$REPOPATH/pid)
    rm -rf $TMPDIR
    echo ""
}

spawnFtpServer(){
    (
        local USCAN_FTP_SERVER=${USCAN_FTP_SERVER:-ftpserver.py}
        mkdir -p "$TMPDIR/$REPOPATH"
        cd "$TMPDIR/$REPOPATH" || exit 1
        echo "FTP starting ... $TMPDIR/$REPOPATH"
        local pid
        python3 "$test_dir/uscan/$USCAN_FTP_SERVER" 2>log &
        pid=$!
        echo $pid > pid
        while ! [ -s port ]; do
            sleep 2s
            if ! kill -0 $pid 2> /dev/null ; then
                echo "The FTP server returned an error:"
                cat log
                exit 1
            fi
        done
    )
}

trap cleanup 1 2 3 13 15

containsName(){
  echo "$1" | grep -qF "$2"
  echo $?
}

. "${0%/*}/shunit2-helper-functions.sh"

# The following tests do the following: (1) create a minimal Debian package
# directory, containing minimal files debian/{changelog,watch,copyright},
# (2) create a minimal repository, containing a tarball (built on the fly),
# (3) start an FTP server that works offline, using the pyftpdlib
# module of Python, and (4) run uscan inside that minimal universe.

# make debian/ in `pwd`
# debian/watch contains $WATCHVER and $WATCHLINE with template URL updated
makeDebianDir() {
    DEBNAME=${1:-foo} # Debian source package name
    DEBVER=${2:-1.0}  # Debian source package version
    mkdir -p debian/source

    cat <<END > debian/rules
%:
        dh $@
END
chmod 755 debian/rules

    cat <<END > debian/changelog
$DEBNAME ($DEBVER) unstable; urgency=low

  * Release of the $DEBNAME package $DEBVER.

 -- Joe Developer <jd@debian.org>  Mon, 02 Nov 2013 22:21:31 -0100
END
    # debian/source/format
    case $DEBVER in
        *-*) # non-native package
            echo "3.0 (quilt)" > debian/source/format
             ;;
        *) # native package
            echo "3.0 (native)" > debian/source/format
             ;;
    esac
    # debian/copyright
    echo "Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/" \
        > debian/copyright
    # debian/watch
    echo "version=$WATCHVER" > debian/watch
    echo "$WATCHLINE" | sed -e "s,@@@url@@@,ftp://127.0.0.1:${PORT}/,g" - \
        >> debian/watch
    # debian/upstream/signing-key.asc
    mkdir -p debian/upstream
    cp -f $test_dir/uscan/PUBLIC_KEY.asc debian/upstream/signing-key.asc
}


# make tarball in $REPOPATH/$POOLPATH
makeUpstreamTar() {
    UPNAME=${1:-foo} # Upstream package name
    UPVER=${2:-1.0}  # upstream package version
    COMPRESSION=${3:-gz} # archve compression type
    TYPE=${4:-non-native} # set this if native-type upstream
    OLDDIR=`pwd`
    mkdir -p $TMPDIR/$REPOPATH/$POOLPATH/$UPNAME-$UPVER
    cd $TMPDIR/$REPOPATH/$POOLPATH
    touch $UPNAME-$UPVER/FILE.$UPNAME.$UPVER
    if [ "$TYPE" = "native" ]; then
        cd $TMPDIR/$REPOPATH/$POOLPATH/$UPNAME-$UPVER
        makeDebianDir $UPNAME $UPVER
        cd $TMPDIR/$REPOPATH/$POOLPATH
    fi
    case $COMPRESSION in
        gz|gzip)
            NEWTAR=$UPNAME-$UPVER.tar
            tar -cf $NEWTAR $UPNAME-$UPVER
            NEWTAR=$UPNAME-$UPVER.tar.gz
            tar -czf $NEWTAR $UPNAME-$UPVER
            ;;
        bz2|bzip2)
            NEWTAR=$UPNAME-$UPVER.tar
            tar -cf $NEWTAR $UPNAME-$UPVER
            NEWTAR=$UPNAME-$UPVER.tar.bz2
            tar --bzip2 -cf $NEWTAR $UPNAME-$UPVER
            ;;
        xz)
            NEWTAR=$UPNAME-$UPVER.tar
            tar -cf $NEWTAR $UPNAME-$UPVER
            NEWTAR= $UPNAME-$UPVER.tar.xz
            tar --xz -cf $NEWTAR $UPNAME-$UPVER
            ;;
        zip)
            NEWTAR=$UPNAME-$UPVER.zip
            zip -r $NEWTAR $UPNAME-$UPVER
            ;;
        *)  echo "Wrong compression mode: $COMPRESSION"
            exit 1
            ;;
    esac
    # make $NEWTAR.asc
    $GPG --homedir "$GPGHOME" --no-options -q --batch --no-default-keyring \
        --secret-keyring $PRIVATE_KEYRING --default-key 72543FAF \
        --armor --detach-sign $NEWTAR
    if [ "$COMPRESSION" != "zip" ]; then
        NEWTAR=$UPNAME-$UPVER.tar
        $GPG --homedir "$GPGHOME" --no-options -q --batch --no-default-keyring \
          --secret-keyring $PRIVATE_KEYRING --default-key 72543FAF \
          --armor --detach-sign $NEWTAR

    fi
    cd $OLDDIR
}

# setup a common watch file test environment
helperWatch() {
    local SITESCRIPT=${1:-siteWebNonNative}
    local VEROLD=${2:-1.0}
    local VERNEW=${3:-2.0}
    local PREFIX="${4:-}"
    local TMPDIR=$(mktemp -d)
    ORIGDIR=`pwd`
    PKG=${PKG:-foo}
    REPOPATH=${REPOPATH:-repo}
    POOLPATH=${POOLPATH:-pool}
    GZREPACK=${GZREPACK:-gz}
    XCOMMAND=${XCOMMAND:-$COMMAND}
    WATCHVER="${WATCHVER:-3}"
    WATCHLINE0="@@@url@@@/ (?:.*)/@PACKAGE@@ANY_VERSION@@ARCHIVE_EXT@ debian uupdate"
    WATCHLINE="${WATCHLINE:-$WATCHLINE0}"
    cd $TMPDIR
    # start FTP server with its root at $TMPDIR/$REPOPATH
    spawnFtpServer || exit 1
    PORT=$(cat $TMPDIR/$REPOPATH/port)
    $DEBUGECHO " ***** ftp://localhost:$PORT started showing $TMPDIR/$REPOPATH *****"
    # make web site
    $SITESCRIPT
    # make local $VEROLD source tree
    tar -xzf $TMPDIR/$REPOPATH/$POOLPATH/${PKG}-${VEROLD}.tar.gz
    if [ -n "${PREFIX}" ]; then
        mv $TMPDIR/${PKG}-${VEROLD} $TMPDIR/${PKG}-${PREFIX}${VEROLD}
    fi
    mv $TMPDIR/${PKG}-${PREFIX}${VEROLD} $TMPDIR/${PKG}
    cd $TMPDIR/${PKG}
    if [ ! -d debian ]; then
        makeDebianDir $PKG ${PREFIX}${VEROLD}-$SUFFIX
    fi
    local UUPDATE=""
    if grep -q "uupdate" $TMPDIR/${PKG}/debian/watch ; then
        UUPDATE=uupdate
    fi
    local PGP=""
    if grep -q "pgpurlmangle" $TMPDIR/${PKG}/debian/watch ; then
        PGP=pgp
    fi
    if grep -q "pgpmode *= *auto" $TMPDIR/${PKG}/debian/watch ; then
        PGP=pgp
    fi
    if grep -q "pgpmode *= *previous" $TMPDIR/${PKG}/debian/watch ; then
        PGP=pgp
    fi
    $XCOMMAND
    assertEquals "uscan: exit_code!=0 but exit_code=0" "$?" "0"
    cd $TMPDIR
    $DEBUGLSLR
    UTARBALL=${PKG}-${VERNEW}.tar.gz
    STARBALL=${PKG}_${PREFIX}${VERNEW}.orig.tar.$GZREPACK
    assertTrue "$UTARBALL missing: $WATCHLINE" "[ -f $UTARBALL ]"
    assertTrue "$STARBALL missing: $WATCHLINE" "[ -f $STARBALL ]"
    if [ "$PGP" = "pgp" ]; then
        UTARSIG=${PKG}-${VERNEW}.tar.gz.asc
        if [ ! -f $UTARSIG ]; then
            UTARSIG=${PKG}-${VERNEW}.tar.asc
        fi
        STARSUG=${PKG}_${PREFIX}${VERNEW}.orig.tar.$GZREPACK.asc
        assertTrue "$UTARSIG and *.sig missing: $WATCHLINE" "[ -f $UTARSIG ]"
        assertTrue "$STARSIG missing: $WATCHLINE" "[ -f $STARSIG ]"
    fi
    # check uupdate
    if [ "$UUPDATE" = "uupdate" ]; then
        cd $TMPDIR/${PKG}-${PREFIX}${VERNEW}
        assertTrue 'pristine tarball is not extracted' "[ -f debian/changelog ]"
        DVERSION=`dpkg-parsechangelog -ldebian/changelog -SVersion`
        assertEquals "uscan: Version should be ${PREFIX}${VERNEW}-$SUFFIX but $DVERSION" "$DVERSION" "${PREFIX}${VERNEW}-$SUFFIX"
        cd $TMPDIR
    fi
    $DEBUGBASH
    cd $ORIGDIR
    cleanup
    unset REPOPATH
    unset POOLPATH
    unset GZREPACK
    unset XCOMMAND
    unset WATCHVER
    unset WATCHLINE
}

# setup a common watch file test environment with Zip upstream
helperWatchZip() {
    local SITESCRIPT=${1:-siteWebNonNative}
    local VEROLD=${2:-1.0}
    local VERNEW=${3:-2.0}
    local PREFIX="${4:-}"
    local TMPDIR=$(mktemp -d)
    ORIGDIR=`pwd`
    PKG=${PKG:-foo}
    REPOPATH=${REPOPATH:-repo}
    POOLPATH=${POOLPATH:-pool}
    GZREPACK=${GZREPACK:-xz}
    XCOMMAND=${XCOMMAND:-$COMMAND}
    WATCHVER="${WATCHVER:-3}"
    WATCHLINE0="@@@url@@@/ (?:.*)/@PACKAGE@@ANY_VERSION@@ARCHIVE_EXT@ debian uupdate"
    WATCHLINE="${WATCHLINE:-$WATCHLINE0}"
    cd $TMPDIR
    # start FTP server with its root at $TMPDIR/$REPOPATH
    spawnFtpServer || exit 1
    PORT=$(cat $TMPDIR/$REPOPATH/port)
    $DEBUGECHO " ***** ftp://localhost:$PORT started showing $TMPDIR/$REPOPATH *****"
    # make web site
    $SITESCRIPT
    # make local $VEROLD source tree
    unzip $TMPDIR/$REPOPATH/$POOLPATH/${PKG}-${VEROLD}.zip
    if [ -n "$PREFIX" ]; then
        mv $TMPDIR/${PKG}-${VEROLD} $TMPDIR/${PKG}-${PREFIX}${VEROLD}
    fi
    mv $TMPDIR/${PKG}-${PREFIX}${VEROLD} $TMPDIR/${PKG}
    cd $TMPDIR/${PKG}
    if [ ! -d debian ]; then
        makeDebianDir $PKG ${PREFIX}${VEROLD}-$SUFFIX
    fi
    local UUPDATE=""
    if grep -q "uupdate" $TMPDIR/${PKG}/debian/watch ; then
        UUPDATE=uupdate
    fi
    local PGP=""
    if grep -q "pgpurlmangle" $TMPDIR/${PKG}/debian/watch ; then
        PGP=pgp
    fi
    if grep -q "pgpmode *= *auto" $TMPDIR/${PKG}/debian/watch ; then
        PGP=pgp
    fi
    if grep -q "pgpmode *= *previous" $TMPDIR/${PKG}/debian/watch ; then
        PGP=pgp
    fi
    $XCOMMAND
    assertEquals "uscan: exit_code!=0 but exit_code=0" "$?" "0"
    cd $TMPDIR
    $DEBUGLSLR
    UTARBALL=${PKG}-${VERNEW}.zip
    STARBALL=${PKG}_${PREFIX}${VERNEW}.orig.tar.$GZREPACK
    assertTrue "$UTARBALL missing: $WATCHLINE" "[ -f $UTARBALL ]"
    assertTrue "$STARBALL missing: $WATCHLINE" "[ -f $STARBALL ]"
    if [ "$PGP" = "pgp" ]; then
        UTARSIG=${PKG}-${VERNEW}.zip.asc
        STARSUG=${PKG}_${PREFIX}${VERNEW}.orig.tar.$GZREPACK.asc
        assertTrue "$UTARSIG and *.sig missing: $WATCHLINE" "[ -f $UTARSIG ]"
        assertTrue "$STARSIG missing: $WATCHLINE" "[ -f $STARSIG ]"
    fi
    # check uupdate
    if [ "$UUPDATE" = "uupdate" ]; then
        cd $TMPDIR/${PKG}-${PREFIX}${VERNEW}
        assertTrue 'pristine tarball is not extracted' "[ -f debian/changelog ]"
        DVERSION=`dpkg-parsechangelog -ldebian/changelog -SVersion`
        assertEquals "uscan: Version should be ${PREFIX}${VERNEW}-$SUFFIX but $DVERSION" "$DVERSION" "${PREFIX}${VERNEW}-$SUFFIX"
        cd $TMPDIR
    fi
    $DEBUGBASH
    cd $ORIGDIR
    cleanup
    unset REPOPATH
    unset POOLPATH
    unset GZREPACK
    unset XCOMMAND
    unset WATCHVER
    unset WATCHLINE
}

siteNonNative() {
    local PKG=${1:-foo}
    local EXTRA=${2:-}
    makeUpstreamTar $PKG 0.0 gz non-native
    makeUpstreamTar $PKG 1.0 gz non-native
    makeUpstreamTar $PKG 2.0 gz non-native
    mkdir -p $TMPDIR/$REPOPATH/0.0/$PKG/ooo/
    mkdir -p $TMPDIR/$REPOPATH/1.0/$PKG/ooo/
    mkdir -p $TMPDIR/$REPOPATH/2.0/$PKG/ooo/
    if [ -n "$EXTRA" ]; then
    makeUpstreamTar $PKG 3.0 gz non-native
    mkdir -p $TMPDIR/$REPOPATH/3.0/$PKG/ooo/
    fi
    ln -sf ../../../$POOLPATH/${PKG}-0.0.tar.gz $TMPDIR/$REPOPATH/0.0/$PKG/ooo/${PKG}-0.0.tar.gz
    ln -sf ../../../$POOLPATH/${PKG}-0.0.tar.gz.asc $TMPDIR/$REPOPATH/0.0/$PKG/ooo/${PKG}-0.0.tar.gz.asc
    ln -sf ../../../$POOLPATH/${PKG}-0.0.tar.asc $TMPDIR/$REPOPATH/0.0/$PKG/ooo/${PKG}-0.0.tar.asc
    ln -sf ../../../$POOLPATH/${PKG}-1.0.tar.gz $TMPDIR/$REPOPATH/1.0/$PKG/ooo/${PKG}-1.0.tar.gz
    ln -sf ../../../$POOLPATH/${PKG}-1.0.tar.gz.asc $TMPDIR/$REPOPATH/1.0/$PKG/ooo/${PKG}-1.0.tar.gz.asc
    ln -sf ../../../$POOLPATH/${PKG}-1.0.tar.asc $TMPDIR/$REPOPATH/1.0/$PKG/ooo/${PKG}-1.0.tar.asc
    ln -sf ../../../$POOLPATH/${PKG}-2.0.tar.gz $TMPDIR/$REPOPATH/2.0/$PKG/ooo/${PKG}-2.0.tar.gz
    ln -sf ../../../$POOLPATH/${PKG}-2.0.tar.gz.asc $TMPDIR/$REPOPATH/2.0/$PKG/ooo/${PKG}-2.0.tar.gz.asc
    ln -sf ../../../$POOLPATH/${PKG}-2.0.tar.asc $TMPDIR/$REPOPATH/2.0/$PKG/ooo/${PKG}-2.0.tar.asc
    if [ -n "$EXTRA" ]; then
    ln -sf ../../../$POOLPATH/${PKG}-3.0.tar.gz $TMPDIR/$REPOPATH/3.0/$PKG/ooo/${PKG}-3.0.tar.gz
    ln -sf ../../../$POOLPATH/${PKG}-3.0.tar.gz.asc $TMPDIR/$REPOPATH/3.0/$PKG/ooo/${PKG}-3.0.tar.gz.asc
    ln -sf ../../../$POOLPATH/${PKG}-3.0.tar.asc $TMPDIR/$REPOPATH/3.0/$PKG/ooo/${PKG}-3.0.tar.asc
    fi
}

siteNonNativeZip() {
    local PKG=${1:-foo}
    local EXTRA=${2:-}
    makeUpstreamTar $PKG 0.0 zip non-native
    makeUpstreamTar $PKG 1.0 zip non-native
    makeUpstreamTar $PKG 2.0 zip non-native
    mkdir -p $TMPDIR/$REPOPATH/0.0/$PKG/ooo/
    mkdir -p $TMPDIR/$REPOPATH/1.0/$PKG/ooo/
    mkdir -p $TMPDIR/$REPOPATH/2.0/$PKG/ooo/
    if [ -n "$EXTRA" ]; then
    makeUpstreamTar $PKG 3.0 gz non-native
    mkdir -p $TMPDIR/$REPOPATH/3.0/$PKG/ooo/
    fi
    ln -sf ../../../$POOLPATH/${PKG}-0.0.zip $TMPDIR/$REPOPATH/0.0/$PKG/ooo/${PKG}-0.0.zip
    ln -sf ../../../$POOLPATH/${PKG}-0.0.zip.asc $TMPDIR/$REPOPATH/0.0/$PKG/ooo/${PKG}-0.0.zip.asc
    ln -sf ../../../$POOLPATH/${PKG}-1.0.zip $TMPDIR/$REPOPATH/1.0/$PKG/ooo/${PKG}-1.0.zip
    ln -sf ../../../$POOLPATH/${PKG}-1.0.zip.asc $TMPDIR/$REPOPATH/1.0/$PKG/ooo/${PKG}-1.0.zip.asc
    ln -sf ../../../$POOLPATH/${PKG}-2.0.zip $TMPDIR/$REPOPATH/2.0/$PKG/ooo/${PKG}-2.0.zip
    ln -sf ../../../$POOLPATH/${PKG}-2.0.zip.asc $TMPDIR/$REPOPATH/2.0/$PKG/ooo/${PKG}-2.0.zip.asc
    if [ -n "$EXTRA" ]; then
    ln -sf ../../../$POOLPATH/${PKG}-3.0.zip $TMPDIR/$REPOPATH/3.0/$PKG/ooo/${PKG}-3.0.zip
    ln -sf ../../../$POOLPATH/${PKG}-3.0.zip.asc $TMPDIR/$REPOPATH/3.0/$PKG/ooo/${PKG}-3.0.zip.asc
    fi
}

siteNonNativeR() {
    local PKG=${1:-foo}
    local EXTRA=${2:-}
    makeUpstreamTar $PKG 0.0 gz non-native
    makeUpstreamTar $PKG 1.0 gz non-native
    makeUpstreamTar $PKG 2.0 gz non-native
    mkdir -p $TMPDIR/$REPOPATH/0.0/$PKG/ooo/
    mkdir -p $TMPDIR/$REPOPATH/1.0/$PKG/ooo/
    mkdir -p $TMPDIR/$REPOPATH/2.0/$PKG/ooo/
    if [ -n "$EXTRA" ]; then
    makeUpstreamTar $PKG 3.0 gz non-native
    mkdir -p $TMPDIR/$REPOPATH/3.0/$PKG/ooo/
    fi
    ln -sf ../../../$POOLPATH/${PKG}-0.0.tar.gz $TMPDIR/$REPOPATH/3.0/$PKG/ooo/${PKG}-0.0.tar.gz
    ln -sf ../../../$POOLPATH/${PKG}-0.0.tar.gz.asc $TMPDIR/$REPOPATH/3.0/$PKG/ooo/${PKG}-0.0.tar.gz.asc
    ln -sf ../../../$POOLPATH/${PKG}-1.0.tar.gz $TMPDIR/$REPOPATH/2.0/$PKG/ooo/${PKG}-1.0.tar.gz
    ln -sf ../../../$POOLPATH/${PKG}-1.0.tar.gz.asc $TMPDIR/$REPOPATH/2.0/$PKG/ooo/${PKG}-1.0.tar.gz.asc
    ln -sf ../../../$POOLPATH/${PKG}-2.0.tar.gz $TMPDIR/$REPOPATH/1.0/$PKG/ooo/${PKG}-2.0.tar.gz
    ln -sf ../../../$POOLPATH/${PKG}-2.0.tar.gz.asc $TMPDIR/$REPOPATH/1.0/$PKG/ooo/${PKG}-2.0.tar.gz.asc
    if [ -n "$EXTRA" ]; then
    ln -sf ../../../$POOLPATH/${PKG}-3.0.tar.gz $TMPDIR/$REPOPATH/0.0/$PKG/ooo/${PKG}-3.0.tar.gz
    ln -sf ../../../$POOLPATH/${PKG}-3.0.tar.gz.asc $TMPDIR/$REPOPATH/0.0/$PKG/ooo/${PKG}-3.0.tar.gz.asc
    fi
}

# test a watch files

### VERSION 4 ###
# standard tests

# test non-native package with uupdate, bare FTP server in normal order
testWatch4NonNative() {
    WATCHVER=4
    WATCHLINE='opts=pgpsigurlmangle=s/$/.asc/ @@@url@@@([\.\d]+)/(.+)/(.+)/ @PACKAGE@@ANY_VERSION@@ARCHIVE_EXT@ debian uupdate'
    helperWatch siteNonNative
}

# test --download-current-version, bare FTP server in normal order
testWatch4NonNativeDlCurrent() {
    WATCHVER=4
    XCOMMAND="$COMMAND --download-current-version"
    WATCHLINE='opts=pgpsigurlmangle=s/$/.asc/ @@@url@@@([\.\d]+)/(.+)/(.+)/ @PACKAGE@@ANY_VERSION@@ARCHIVE_EXT@ debian uupdate'
    helperWatch siteNonNative 1.0 1.0
}

# test --download-version, bare FTP server in normal order
testWatch4NonNativeDlUversion() {
    WATCHVER=4
    XCOMMAND="$COMMAND --download-version 0.0"
    WATCHLINE='opts=pgpsigurlmangle=s/$/.asc/ @@@url@@@([\.\d]+)/(.+)/(.+)/ @PACKAGE@@ANY_VERSION@@ARCHIVE_EXT@ debian uupdate'
    helperWatch siteNonNative 1.0 0.0
}

# test non-native package with uupdate, bare FTP server in normal order with upstream ZIP
testWatch4NonNativeZip() {
    WATCHVER=4
    COMPRESSION='zip'
    WATCHLINE='opts=pgpsigurlmangle=s/$/.asc/ @@@url@@@([\.\d]+)/(.+)/(.+)/ @PACKAGE@@ANY_VERSION@@ARCHIVE_EXT@ debian uupdate'
    helperWatchZip siteNonNativeZip
}

# test non-native package with uupdate, bare FTP server in normal order with repack to xz
testWatch4NonNativeXz() {
    WATCHVER=4
    GZREPACK='xz'
    WATCHLINE='opts=pgpsigurlmangle=s/$/.asc/,compression=xz,repack @@@url@@@([\.\d]+)/(.+)/(.+)/ @PACKAGE@@ANY_VERSION@@ARCHIVE_EXT@ debian uupdate'
    helperWatch siteNonNative
}

# test non-native package with uupdate, bare FTP server in normal order with ungzsig
testWatch4NonNativeUngzsig() {
    WATCHVER=4
    WATCHLINE='opts=pgpsigurlmangle=s/.gz$/.asc/,decompress @@@url@@@([\.\d]+)/(.+)/(.+)/ @PACKAGE@@ANY_VERSION@@ARCHIVE_EXT@ debian uupdate'
    helperWatch siteNonNative
}

. shunit2