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
|
This guide shows how to install and configure brep on a "deployment" machine as
opposed to a "development" one (see INSTALL-DEV for the latter). Here we assume
you are using a systemd-based distribution. If not, then you will need to
replace systemctl commands with the equivalend init.d ones.
1. Create 'brep' User
This user will be used to run the brep repository loader. We will also use its
home directory to build and install the brep module, store its configuration,
etc. We create this user with a disabled password so only root will be able to
operate as brep. Because of this restriction we will allow brep to run sudo
without a password:
# adduser --disabled-password brep
# echo "brep ALL=(ALL) NOPASSWD:ALL" >/etc/sudoers.d/brep
# chmod 0440 /etc/sudoers.d/brep
In the rest of this guide commands that start with the $ shell prompt are
expected to be executed as the brep user and in its home directory.
2. Install Prerequisites
a) Install a C++ compiler using your distribution's package.
b) Install PostgreSQL 9.x and Apache2 using your distribution's packages.
Also check that the files in /home/brep are readable by "others". If they
are not, then run the following command to grant Apache2 read access:
$ setfacl -dm g:www-data:rx /home/brep
In the above command and in the rest of this guide replace www-data with
the user name under which Apache2 is running (See the "User" directive in
the Apache2 .conf file).
[Note that strictly speaking www-data in the above command is the Apache2
group, not user. However, most installations use the same name for both.]
c) Install PostgreSQL and Apache2 development files. Specifically, we need
PostgreSQL's libpq and Apache's libapr and web server development files.
Below are the names of their packages for some distributions:
Debian/Ubuntu: libpq-dev libapr1-dev apache2-dev
Fedora/RHEL: posqtgresql-devel apr-devel httpd-devel
FreeBSD: postgresql94-client apr apache24
d) Install build2-toolchain by following its INSTALL file instructions. You
can build build2-toolchain using brep's login and in its home directory.
e) Install libodb-pgsql and libstudxml
[Currently we use pre-release versions of these libraries so they have to
be built from source.]
Download source packages for the two libraries from the same location as
build2-toolchain. Then unpack, build, and install:
$ cd libXXX-X.Y.Z
$ ./configure CPPFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib \
--prefix=/usr/local
$ make
$ sudo make install
Again, you can use brep's login/home directory for this. See the INSTALL
file for each library for more information.
3. Build and Install brep
$ mkdir brep install
$ cd brep
In the following command line, replace <apr> and <apache> with directories
that contain the apr.h and httpd.h headers, respectively. Below are their
locations for some distributions:
Debian/Ubuntu: /usr/include/apr-1.0 /usr/include/apache2
Fedora/RHEL: /usr/include/apr-1 /usr/include/httpd
FreeBSD: /usr/local/include/apr-1 /usr/local/include/apache24
$ bpkg create \
cxx \
config.cxx.poptions="-I/usr/local/include -I<apr> -I<apache>" \
config.cxx.loptions=-L/usr/local/lib \
config.bin.rpath="/home/brep/install/lib /usr/local/lib" \
config.install.root=/home/brep/install
$ bpkg add http://pkg.cppget.org/1/alpha
$ bpkg fetch
$ bpkg build brep
$ bpkg install brep
$ cd .. # Back to brep home.
4. Create PostgreSQL User and Database
$ sudo sudo -u postgres psql # Note: double sudo is not a mistake.
CREATE DATABASE brep;
CREATE USER brep;
GRANT ALL PRIVILEGES ON DATABASE brep TO brep;
CREATE USER "www-data" INHERIT IN ROLE brep;
Exit psql (^D), then make sure the logins work:
$ psql
$ sudo sudo -u www-data psql -d brep
To troubleshoot, see PostgreSQL logs.
5. Create Database Schema and Load Repositories
$ mkdir config
$ edit config/brep-loader.conf # Loader configuration, see brep-loader(1).
$ psql --quiet -f install/share/brep/package.sql
$ install/bin/brep-loader config/brep-loader.conf
To verify:
$ psql -c 'SELECT name, summary FROM repository'
6. Setup Apache2 Module
$ cp install/share/brep/etc/brep-module.conf config/
$ edit config/brep-module.conf # Adjust default values if required.
Here we assume you have setup an appropriate Apache2 virtual server. Open the
corresponding Apache2 .conf file and add the following inside VirtualHost (you
can also find this fragment in install/share/brep/etc/brep-apache2.conf):
# Load the brep module.
#
LoadModule brep_module /home/brep/install/libexec/brep/mod_brep.so
SetHandler brep
# Repository root. This is the part of the URL between the host name
# and the start of the repository. For example, root value /pkg/ means
# the repository URL is http://example.org/pkg/. Specify / to use the
# web server root (e.g., http://example.org/). If using a different
# repository root, don't forget to also change Alias directives below.
#
brep-root /pkg/
# Brep module configuration. If you prefer, you can paste the contents
# of this file here. However, you will need to prefix every option with
# 'brep-'.
#
brep-conf /home/brep/config/brep-module.conf
# Static brep content (CSS files).
#
<IfModule !alias_module>
Error "mod_alias is not enabled"
</IfModule>
# Note: trailing slashes are important!
#
Alias /pkg/@/ /home/brep/install/share/brep/www/
<Directory "/home/brep/install/share/brep/www">
Require all granted
</Directory>
# You can also serve the repository files from the repository root.
# For example:
#
# http://example.org/pkg/1/... -> /path/to/repo/1/...
#
#AliasMatch ^/pkg/(\d+)/(.+) /path/to/repo/$1/$2
#
#<Directory "/path/to/repo">
# Require all granted
#</Directory>
Restart Apache2:
$ sudo systemctl restart apache2
To verify, visit the repository root. To troubleshoot, see Apache logs.
7. Setup Periodic Loader Execution
@@ TODO
8. Upgrade procedure
@@ TODO
- stop apache
- suspend periodic loader
- migrate schema
- resume loader, force a run
- start apache
- save old config, install
|