aboutsummaryrefslogtreecommitdiff
path: root/tests/atlocal.in
blob: e74149a621280724e938266c788cf21fc4c4f84e (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
# @configure_input@                                     -*- shell-script -*-
# Configurable variable values for Wydawca test suite.
# Copyright (C) 2009-2012, 2017, 2019-2023 Sergey Poznyakoff

PATH=@abs_builddir@:@abs_top_builddir@/src:@abs_top_srcdir@/build-aux:$top_srcdir:$srcdir:$PATH

XFAILFILE=$abs_builddir/.badversion

trap "test -r $XFAILFILE && cat $XFAILFILE; exit $?" 1 2 13 15

WY_TESTDIR=@abs_top_builddir@/tests
WY_CONFSRC=@abs_top_srcdir@/tests/etc
WY_CONFDST=$WY_TESTDIR/etc
WY_PROJECTDB=$WY_CONFSRC/project
WY_MAILUTILS=@WY_MAILUTILS@
WY_INOTIFY=@WY_INOTIFY@
WY_MODDIR=@abs_top_builddir@/modules/mailutils/.libs

GPG="@GPG@"
if [ -n "$GPG" ]; then
    GPG="$GPG --quiet --no-permission-warning --batch "
fi
GNUPGHOME=$WY_CONFDST/gnupg
export GNUPGHOME

ulimit -c unlimited

# #####################################
# Utility functions
# #####################################

# wy_project_lookup PROJECT WHAT
wy_project_lookup() {
    test $# -eq  2 || echo >&2 "wy_project_lookup: bad number of arguments"
    local n
    case $2 in
	PROJECT_NAME)  n=1;;
	REAL_NAME)     n=2;;
	EMAIL)         n=3;;
	COMMENT)       n=4;;
    esac
    grep "^$1:" $WY_PROJECTDB | cut -d: -f$n
}

# wy_create_directive [-c] [-v X.Y] [-u USER] FILENAME PROJECT [DIRECTIVE: VALUE ...]
wy_create_directive() {
    local clear version user
    while [ $# -ne 0 ]
    do
	case $1 in
	    -c) clear=1
		shift;;
	    -v) version=$2
		shift 2;;
	    -u) user=$2
		shift 2;;
	    --) shift
		break;;
	    *)  break
	esac
    done

    if test -z "$clear"; then
	: ${version:=1.2}
    fi

    local filename="$1.directive" project=$2
    shift 2
    if [ $(( $# % 2 )) -ne 0 ]; then
	echo >&2 "wy_create_directive: odd number of arguments"
	exit 1
    fi
    (if test -n "$version"; then
	 echo "version: $version"
     fi
     if test -z "$clear"; then
	 echo "directory: $project"
     fi

     while [ $# -gt 0 ]
     do
	 echo "$1 $2"
	 shift 2
     done) > $filename
    rm -f $filename.asc
    : ${user:=$(wy_project_lookup $project REAL_NAME)}
    rm -f $filename.asc
    $GPG --clearsign -u "$user" -o $filename.asc $filename
    rm $filename
}

# wy_genfile [-u USER] [-l SIZE] PROJECT NAME
wy_genfile() {
    local length user
    while [ $# -ne 0 ]
    do
	case $1 in
	    -l) length="-l $2"
		shift 2;;
	    -u) user=$2
		shift 2;;
	    --) shift
		break;;
	    *)  break
	esac
    done

    local project=$1 filename=$2
    chargen $length > $filename

    : ${user:=$(wy_project_lookup $project REAL_NAME)}
    rm -f $filename.sig
    $GPG -ba -o $filename.sig $filename
}

# wy_create_upload [-u USER] [-l SIZE] PROJECT NAME [DIRECTIVE: VALUE...]
wy_create_upload() {
    local length_option user_option
    while [ $# -ne 0 ]
    do
	case $1 in
	    -l)
		length_option="$1 $2"
		shift 2;;
	    -u)
		user_option="$1 $2"
		shift 2;;
	    --) shift
		break;;
	    *)  break
	esac
    done
    local project=$1 filename=$2
    shift 2
    wy_genfile $length_option $user_option $project $filename
    wy_create_directive $user_option $filename $project\
			filename: $(basename $filename)\
			"$@"
}

wy_config_head() {
    cat <<EOF
pidfile $PWD/wydawca.pid;
statistics all;
umask 022;
create-directories yes;
#include "$WY_CONFDST/database.cf"
EOF
}

Return to:

Send suggestions and report system problems to the System administrator.