setup.sh 7.49 KB
Newer Older
1
TOPLEVEL="$(cd "$(dirname "$0")/.." && pwd)"
2

3
. "$TOPLEVEL/test/sharness.sh"
4

5
# Configure python search path.
6
PYTHONPATH="$TOPLEVEL"
7
8
export PYTHONPATH

9
# Configure paths to the Git interface scripts.
10
11
12
GIT_AUTH="$TOPLEVEL/aurweb/git/auth.py"
GIT_SERVE="$TOPLEVEL/aurweb/git/serve.py"
GIT_UPDATE="$TOPLEVEL/aurweb/git/update.py"
13
14
15
MKPKGLISTS="$TOPLEVEL/aurweb/scripts/mkpkglists.py"
TUVOTEREMINDER="$TOPLEVEL/aurweb/scripts/tuvotereminder.py"
PKGMAINT="$TOPLEVEL/aurweb/scripts/pkgmaint.py"
16
USERMAINT="$TOPLEVEL/aurweb/scripts/usermaint.py"
17
18
AURBLUP="$TOPLEVEL/aurweb/scripts/aurblup.py"
NOTIFY="$TOPLEVEL/aurweb/scripts/notify.py"
19
RENDERCOMMENT="$TOPLEVEL/aurweb/scripts/rendercomment.py"
20
21
22
23
24
25
26
27

# Create the configuration file and a dummy notification script.
cat >config <<-EOF
[database]
backend = sqlite
name = aur.db

[options]
28
aur_location = https://aur.archlinux.org
29
aur_request_ml = aur-requests@lists.archlinux.org
30
31
enable-maintenance = 0
maintenance-exceptions = 127.0.0.1
32
commit_uri = https://aur.archlinux.org/cgit/aur.git/log/?h=%s&id=%s
33
localedir = $TOPLEVEL/web/locale/
34
35

[notifications]
36
37
38
39
notify-cmd = $NOTIFY
sendmail = ./sendmail.sh
sender = notify@aur.archlinux.org
reply-to = noreply@aur.archlinux.org
40
41
42
43

[auth]
valid-keytypes = ssh-rsa ssh-dss ecdsa-sha2-nistp256 ecdsa-sha2-nistp384 ecdsa-sha2-nistp521 ssh-ed25519
username-regex = [a-zA-Z0-9]+[.\-_]?[a-zA-Z0-9]+$
44
git-serve-cmd = $GIT_SERVE
45
46
47
48
49
ssh-options = restrict

[serve]
repo-path = ./aur.git/
repo-regex = [a-z0-9][a-z0-9.+_-]*$
50
51
git-shell-cmd = ./git-shell.sh
git-update-cmd = ./update.sh
52
53
54
55
ssh-cmdline = ssh aur@aur.archlinux.org

[update]
max-blob-size = 256000
Lukas Fleischer's avatar
Lukas Fleischer committed
56

Lukas Fleischer's avatar
Lukas Fleischer committed
57
58
59
60
61
[aurblup]
db-path = $(pwd)/sync/
sync-dbs = test
server = file://$(pwd)/remote/

Lukas Fleischer's avatar
Lukas Fleischer committed
62
63
64
[mkpkglists]
packagesfile = packages.gz
pkgbasefile = pkgbase.gz
65
userfile = users.gz
66
67
EOF

68
cat >sendmail.sh <<-\EOF
69
#!/bin/sh
70
cat >>sendmail.out
71
EOF
72
chmod +x sendmail.sh
73

74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
cat >git-shell.sh <<-\EOF
#!/bin/sh
echo $AUR_USER
echo $AUR_PKGBASE
echo $GIT_NAMESPACE
EOF
chmod +x git-shell.sh

cat >update.sh <<-\EOF
#!/bin/sh
echo $AUR_USER
echo $AUR_PKGBASE
EOF
chmod +x update.sh

89
90
91
92
93
94
95
96
97
98
99
100
AUR_CONFIG=config
export AUR_CONFIG

# Create SSH public keys which will be used by the test users later.
AUTH_KEYTYPE_USER=ssh-rsa
AUTH_KEYTEXT_USER=AAAAB3NzaC1yc2EAAAADAQABAAABAQCeUafDK4jqUiRHNQfwHcYjBKLZ4Rc1sNUofHApBP6j91nIvDHZe2VUqeBmFUhBz7kXK4VbXD9nlHMun2HeshL8hXnMzymZ8Wk7+IKefj61pajJkIdttw9Tnayfg7uhg5RbFy9zpEjmGjnIVjSzOXKCwppNT+CNujpKM5FD8gso/Z+l3fD+IwrPwS1SzF1Z99nqI9n2FM/JWZqluvTqnW9WdAvBDfutXxp0R5ZiLI5TAKL2Ssp5rpL70pkLXhv+9sK545zKKlXUFmw6Pi2iVBdqdRsk9ocl49dLiNIh8CYDCO3CRQn+8EnpBhTor2TKQxGJI3mzoBwWJJxoKhD/XlYJ
AUTH_FINGERPRINT_USER=SHA256:F/OFtYAy0JCytAGUi4RUZnOsThhQtFMK7fH1YvFBCpo

AUTH_KEYTYPE_TU=ssh-rsa
AUTH_KEYTEXT_TU=AAAAB3NzaC1yc2EAAAADAQABAAABAQC4Q2Beg6jf2r1LZ4vwT5y10dK8+/c5RaNyTwv77wF2OSLXh32xW0ovhE2lW2gqoakdGsxgM2fTtqMTl29WOsAxlGF7x9XbWhFXFUT88Daq1fAeuihkiRjfBbInSW/WcrFZ+biLBch67addtfkkd4PmAafDeeCtszAXqza+ltBG1oxAGiTXgI3LOhA1/GtLLxsi5sPUO3ZlhvwDn4Sy0aXYx8l9hop/PU4Cjn82hyRa9r+SRxQ3KtjKxcVMnZ8IyXOrBwXTukgSBR/6nSdEmO0JPkYUFuNwh3UGFKuNkrPguL5T+4YDym6czYmZJzQ7NNl2pLKYmYgBwBe5rORlWfN5
AUTH_FINGERPRINT_TU=SHA256:xQGC6j/U1Q3NDXLl04pm+Shr1mjYUXbGMUzlm9vby4k

101
102
103
104
AUTH_KEYTYPE_MISSING=sha-rsa
AUTH_KEYTEXT_MISSING=AAAAB3NzaC1yc2EAAAADAQABAAABAQC9UTpssBunuTBCT3KFtv+yb+cN0VmI2C9O9U7wHlkEZWxNBK8is6tnDHXBxRuvRk0LHILkTidLLFX22ZF0+TFgSz7uuEvGZVNpa2Fn2+vKJJYMvZEvb/f8VHF5/Jddt21VOyu23royTN/duiT7WIZdCtEmq5C9Y43NPfsB8FbUc+FVSYT2Lq7g1/bzvFF+CZxwCrGjC3qC7p3pshICfFR8bbWgRN33ClxIQ7MvkcDtfNu38dLotJqdfEa7NdQgba5/S586f1A4OWKc/mQJFyTaGhRBxw/cBSjqonvO0442VYLHFxlrTHoUunKyOJ8+BJfKgjWmfENC9ESY3mL/IEn5
AUTH_FINGERPRINT_MISSING=SHA256:uB0B+30r2WA1TDMUmFcaEBjosjnFGzn33XFhiyvTL9w

105
106
107
108
109
110
# Setup fake SSH environment.
SSH_CLIENT='1.2.3.4 1234 22'
SSH_CONNECTION='1.2.3.4 1234 4.3.2.1 22'
SSH_TTY=/dev/pts/0
export SSH_CLIENT SSH_CONNECTION SSH_TTY

111
# Initialize the test database.
112
python -m aurweb.initdb --no-alembic
113

Lukas Fleischer's avatar
Lukas Fleischer committed
114
115
116
117
118
119
120
121
122
echo "INSERT INTO Users (ID, UserName, Passwd, Email, LangPreference, AccountTypeID) VALUES (1, 'user', '!', 'user@localhost', 'en', 1);" | sqlite3 aur.db
echo "INSERT INTO Users (ID, UserName, Passwd, Email, LangPreference, AccountTypeID) VALUES (2, 'tu', '!', 'tu@localhost', 'en', 2);" | sqlite3 aur.db
echo "INSERT INTO Users (ID, UserName, Passwd, Email, LangPreference, AccountTypeID) VALUES (3, 'dev', '!', 'dev@localhost', 'en', 3);" | sqlite3 aur.db
echo "INSERT INTO Users (ID, UserName, Passwd, Email, LangPreference, AccountTypeID) VALUES (4, 'user2', '!', 'user2@localhost', 'en', 1);" | sqlite3 aur.db
echo "INSERT INTO Users (ID, UserName, Passwd, Email, LangPreference, AccountTypeID) VALUES (5, 'user3', '!', 'user3@localhost', 'en', 1);" | sqlite3 aur.db
echo "INSERT INTO Users (ID, UserName, Passwd, Email, LangPreference, AccountTypeID) VALUES (6, 'user4', '!', 'user4@localhost', 'en', 1);" | sqlite3 aur.db
echo "INSERT INTO Users (ID, UserName, Passwd, Email, LangPreference, AccountTypeID) VALUES (7, 'tu2', '!', 'tu2@localhost', 'en', 2);" | sqlite3 aur.db
echo "INSERT INTO Users (ID, UserName, Passwd, Email, LangPreference, AccountTypeID) VALUES (8, 'tu3', '!', 'tu3@localhost', 'en', 2);" | sqlite3 aur.db
echo "INSERT INTO Users (ID, UserName, Passwd, Email, LangPreference, AccountTypeID) VALUES (9, 'tu4', '!', 'tu4@localhost', 'en', 2);" | sqlite3 aur.db
123
124
125
126

echo "INSERT INTO SSHPubKeys (UserID, Fingerprint, PubKey) VALUES (1, '$AUTH_FINGERPRINT_USER', '$AUTH_KEYTYPE_USER $AUTH_KEYTEXT_USER');" | sqlite3 aur.db
echo "INSERT INTO SSHPubKeys (UserID, Fingerprint, PubKey) VALUES (2, '$AUTH_FINGERPRINT_TU', '$AUTH_KEYTYPE_TU $AUTH_KEYTEXT_TU');" | sqlite3 aur.db

127
128
echo "INSERT INTO Bans (IPAddress, BanTS) VALUES ('1.3.3.7', 0);" | sqlite3 aur.db

129
130
131
132
133
134
135
136
137
138
echo "INSERT INTO PackageBlacklist (Name) VALUES ('forbidden');" | sqlite3 aur.db
echo "INSERT INTO OfficialProviders (Name, Repo, Provides) VALUES ('official', 'core', 'official');" | sqlite3 aur.db

# Initialize a Git repository and test packages.
GIT_AUTHOR_EMAIL=author@example.com
GIT_AUTHOR_NAME='A U Thor'
GIT_COMMITTER_EMAIL=committer@example.com
GIT_COMMITTER_NAME='C O Mitter'
export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME
export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME
139

140
(
141
142
143
	mkdir aur.git
	cd aur.git
	git init -q
144
	git config --local commit.gpgsign false
145
146

	git checkout -q --orphan refs/namespaces/foobar/refs/heads/master
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

	cat >PKGBUILD <<-EOF
	pkgname=foobar
	pkgver=1
	pkgrel=1
	pkgdesc='aurweb test package.'
	url='https://aur.archlinux.org/'
	license=('GPL')
	arch=('any')
	depends=('python-pygit2')
	source=()
	md5sums=()

	package() {
		echo 'Hello world!'
	}
	EOF

	cat >.SRCINFO <<-EOF
	pkgbase = foobar
		pkgdesc = aurweb test package.
		pkgver = 1
		pkgrel = 1
		url = https://aur.archlinux.org/
		arch = any
		license = GPL
		depends = python-pygit2

	pkgname = foobar
	EOF

	git add PKGBUILD .SRCINFO
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
	git commit -q -m 'Initial import'

	sed 's/\(pkgrel.*\)1/\12/' PKGBUILD >PKGBUILD.new
	sed 's/\(pkgrel.*\)1/\12/' .SRCINFO >.SRCINFO.new
	mv PKGBUILD.new PKGBUILD
	mv .SRCINFO.new .SRCINFO
	git commit -q -am 'Bump pkgrel'

	git checkout -q --orphan refs/namespaces/foobar2/refs/heads/master

	cat >PKGBUILD <<-EOF
	pkgname=foobar2
	pkgver=1
	pkgrel=1
	pkgdesc='aurweb test package.'
	url='https://aur.archlinux.org/'
	license=('MIT')
	arch=('any')
	depends=('python-pygit2')
	source=()
	md5sums=()

	package() {
		echo 'Hello world!'
	}
	EOF

	cat >.SRCINFO <<-EOF
	pkgbase = foobar2
		pkgdesc = aurweb test package.
		pkgver = 1
		pkgrel = 1
		url = https://aur.archlinux.org/
		arch = any
		license = MIT
		depends = python-pygit2

	pkgname = foobar2
	EOF

	git add PKGBUILD .SRCINFO
	git commit -q -m 'Initial import'

	git checkout -q refs/namespaces/foobar/refs/heads/master
223
)