6 Commits
24.00 ... main

Author SHA1 Message Date
ngn
a394df6210 new: docker workflow
All checks were successful
Build docker image / build (push) Successful in 29s
Signed-off-by: ngn <ngn@ngn.tf>
2025-01-28 10:11:38 +03:00
ngn
7cc249aac6 fix: use the signed type for ctx_sync return 2024-08-25 14:28:43 +03:00
ngn
543e3fce31 fix: missing directory install commands 2024-08-21 07:08:45 +03:00
ngn
dc6bdefe07 fix: don't reuse section names as pool names 2024-08-18 04:12:09 +03:00
ngn
41318f3b1f update: add name option for pools with same names 2024-08-18 04:01:17 +03:00
ngn
41111ce76d fix: disable buffering for docker-compose logging 2024-08-18 03:46:44 +03:00
9 changed files with 100 additions and 54 deletions

View File

@ -0,0 +1,28 @@
name: Build docker image
on:
push:
branches: ["main"]
env:
REGISTRY: git.matterlinux.xyz
IMAGE: ${{gitea.repository}}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: "https://github.com/actions/checkout@v4"
- name: Login to container repo
uses: "https://github.com/docker/login-action@v1"
with:
registry: ${{env.REGISTRY}}
username: ${{gitea.actor}}
password: ${{secrets.PACKAGES_TOKEN}}
- name: Build image
run: |
docker build --tag ${{env.REGISTRY}}/${{env.IMAGE}}:latest .
docker push ${{env.REGISTRY}}/${{env.IMAGE}}:latest

View File

@ -1,4 +1,4 @@
FROM libmp as build
FROM git.matterlinux.xyz/matter/libmp as build
RUN apt update
RUN apt install -y make gcc gettext libinih-dev libsqlite3-dev libarchive-dev
@ -13,7 +13,7 @@ COPY ./src ./src
RUN make
RUN make install
FROM libmp as main
FROM git.matterlinux.xyz/matter/libmp as main
RUN apt update
RUN apt install -y dumb-init
@ -26,4 +26,9 @@ COPY --from=build /usr/share/locale/tr/LC_MESSAGES/pooler.mo /usr/share/locale/t
COPY --from=build /etc/pooler/config.ini /etc/pooler/config.ini
COPY --from=build /usr/bin/pooler /usr/bin/pooler
RUN useradd runner -r -u 1001
RUN chown -R runner:runner /var/lib/pooler
RUN chown -R runner:runner /etc/pooler
USER runner
ENTRYPOINT ["dumb-init", "/usr/bin/pooler", "/etc/pooler/config.ini"]

View File

@ -11,7 +11,7 @@ HDRS = $(wildcard include/*.h)
CFLAGS = -O3 -fstack-protector-strong -fcf-protection=full -fstack-clash-protection
LIBS = -linih -lmp
VERSION = 24.00
VERSION = 24.03
all: dist dist/pooler $(PO_OUTS)
@ -43,8 +43,8 @@ locale/pooler.pot: $(SRCS)
install:
install -d -m700 $(DESTDIR)/etc/pooler
install -m755 dist/pooler $(DESTDIR)/$(PREFIX)/bin/pooler
install -m600 install/config.ini $(DESTDIR)/etc/pooler/config.ini
install -Dm755 dist/pooler $(DESTDIR)/$(PREFIX)/bin/pooler
install -Dm600 install/config.ini $(DESTDIR)/etc/pooler/config.ini
@for po in $(PO_DIRS) ; do \
echo "installing locale: $$po/pooler.mo" ; \
mkdir -pv $(DESTDIR)/$(PREFIX)/share/$$po ; \

View File

@ -1,4 +1,7 @@
# pooler | MatterLinux pool server
![](https://git.matterlinux.xyz/matter/pooler/actions/workflows/docker.yml/badge.svg)
Simple MPTP server implementation for serving MatterLinux package pools.
Built on top of [`libmp`](https://git.matterlinux.xyz/Matter/libmp).
@ -18,8 +21,7 @@ After installing these dependencies, you should download the latest release.
If you are building this program for development purposes, then you may also
build from the latest commit. However latest commit may not always be compilable.
After obtaining the source code, you can compile the program using the make
tool:
After obtaining the source code, you can compile the program using the make tool:
```bash
make
```
@ -36,13 +38,10 @@ docker build --tag pooler .
And for deployment you can use docker-compose, here is an example configuration:
```yaml
version: "3"
services:
pooler:
image: pooler
build:
context: ./
container_name: pooler
image: git.matterlinux.xyz/matter/pooler
ports:
- "5858:5858/tcp"
volumes:

View File

@ -4,6 +4,7 @@
addr = 0.0.0.0:5858
threads = 10
# [pool-name]
# [pool-config]
# name = pool-name
# host = pool.example.com
# dir = /srv/pools/pool-name

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-08-10 23:56+0300\n"
"POT-Creation-Date: 2024-08-25 14:08+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -17,27 +17,27 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: src/config.c:130
#: src/config.c:135
#, c-format
msgid "Unknown configuration option: %s"
msgstr ""
#: src/config.c:132
#: src/config.c:137
#, c-format
msgid "Unknown configuration option: %s/%s"
msgstr ""
#: src/config.c:140
#: src/config.c:145
#, fuzzy, c-format
msgid "Failed to access the configuration file: %s"
msgstr "Kayıt dosyasını açmak başarısız oldu: %s"
#: src/config.c:145
#: src/config.c:150
#, fuzzy
msgid "Failed to parse the configuration"
msgstr "Kayıt dosyasını açmak başarısız oldu: %s"
#: src/config.c:152
#: src/config.c:160
#, fuzzy, c-format
msgid "Hostname not specified for the pool: %s"
msgstr "Ana makine adı havuz konfigürasyonunda belirtilmedi, geçiliyor: %s"
@ -82,77 +82,77 @@ msgstr ""
msgid "Request from %s: PULL (%s)"
msgstr ""
#: src/main.c:109
#. disable buffering so docker-compose logs works correctly
#: src/main.c:110
#, fuzzy, c-format
msgid "Starting pooler %s (libmp %s)"
msgstr "%lu tane havuz %s adresinde sunuluyor"
#: src/main.c:112
#: src/main.c:113
msgid "Configuration file not specified"
msgstr "Konfigürasyon dosyası belirtilmedi"
#: src/main.c:125
#: src/main.c:126
msgid "Loaded the configuration"
msgstr ""
#: src/main.c:128
#: src/main.c:129
#, fuzzy
msgid "Failed to get the temp directory configuration option (tmpdir)"
msgstr "Kayıt dosyasını açmak başarısız oldu: %s"
#: src/main.c:136
#: src/main.c:137
msgid "Please specify a valid thread count (1-1000)"
msgstr "Lütfen geçerli bir işlem sayısı belirtin (1-1000)"
#: src/main.c:141
#: src/main.c:142
msgid "Please specify at least one pool in the configuration"
msgstr "Lütfen konfigürasyonda en az bir havuz belirtin"
#: src/main.c:146
#, fuzzy, c-format
msgid "%s: loading the pool"
msgstr "%s: havuz bilgisi başarıyla yüklendi"
#: src/main.c:149
#: src/main.c:148
#, fuzzy, c-format
msgid "%s: hostname not specified for pool, skipping"
msgstr "Ana makine adı havuz konfigürasyonunda belirtilmedi, geçiliyor: %s"
#: src/main.c:163
#: src/main.c:162
#, fuzzy, c-format
msgid "%s: failed access the pool directory (%s)"
msgstr "Havuz dizinine erişilemiyor: %s"
#: src/main.c:168
#: src/main.c:167
#, fuzzy, c-format
msgid "%s: failed to add pool to the list (%s)"
msgstr "Havuzu listeye eklemek başarısız oldu: %s"
#: src/main.c:176
#, c-format
msgid "Failed to sync the pools: %s"
#: src/main.c:175
#, fuzzy
msgid "Failed to sync the pools, please see the errors above"
msgstr "Havuzları sekronize etmek başarısız oldu: %s"
#: src/main.c:181
#: src/main.c:180
#, fuzzy
msgid "None of the pools is available for serving"
msgstr "Havuzların hiçbiri sunmak için müsait değil"
#: src/main.c:185
#: src/main.c:184
#, c-format
msgid "Serving %lu pool on %s"
msgstr "%lu tane havuz %s adresinde sunuluyor"
#: src/main.c:185
#: src/main.c:184
#, c-format
msgid "Serving %lu pools on %s"
msgstr "%lu tane havuz %s adresinde sunuluyor"
#: src/main.c:188
#: src/main.c:187
#, c-format
msgid "Failed to start the server: %s"
msgstr "Sunucuyu başlatmak başarısız oldu: %s"
#, fuzzy, c-format
#~ msgid "%s: loading the pool"
#~ msgstr "%s: havuz bilgisi başarıyla yüklendi"
#, fuzzy, c-format
#~ msgid "%s: loaded the pool"
#~ msgstr "%s: havuz bilgisi başarıyla yüklendi"

View File

@ -21,21 +21,21 @@ config_t config = {
.pools = NULL,
};
pool_config_t *config_pool_add(char *name) {
pool_config_t *config_pool_add(char *section) {
pool_config_t *pool = malloc(sizeof(pool_config_t));
bzero(pool, sizeof(pool_config_t));
pool->name = strdup(name);
pool->section = strdup(section);
pool->next = config.pools;
config.pools = pool;
return pool;
}
bool config_pool_contains(char *name) {
bool config_pool_contains(char *section) {
pool_config_t *cur = config.pools;
while (NULL != cur) {
if (eq(cur->name, name))
if (eq(cur->section, section))
return true;
cur = cur->next;
}
@ -105,7 +105,12 @@ int config_load_handler(void *data, const char *_section, const char *_key, cons
if (!config_pool_contains(section))
config_pool_add(section);
if (eq(key, "host")) {
if (eq(key, "name")) {
free(config.pools->name);
config.pools->name = strdup(value);
}
else if (eq(key, "host")) {
free(config.pools->host);
config.pools->host = strdup(value);
}
@ -148,10 +153,14 @@ bool config_load(char *file) {
pool_config_t *pool = config.pools;
while (NULL != pool) {
if (NULL == pool->name)
pool->name = pool->section;
if (NULL == pool->host) {
error(_("Hostname not specified for the pool: %s"), pool->name);
return false;
}
pool = pool->next;
}
@ -167,8 +176,12 @@ void config_free() {
old = cur;
cur = cur->next;
free(old->host);
free(old->section);
if (old->section != old->name)
free(old->name);
free(old->host);
free(old->path);
free(old->dir);
free(old);
}
}

View File

@ -21,6 +21,7 @@ typedef struct config_option {
typedef struct pool_config {
struct pool_config *next;
char *section;
char *name;
char *host;
char *path;

View File

@ -106,6 +106,7 @@ bool serve_callback(lm_pool_t *pool, lm_mptp_t *packet, struct sockaddr *addr, v
}
int main(int argc, char *argv[]) {
setbuf(stdout, NULL); // disable buffering so docker-compose logs works correctly
info(_("Starting pooler %s (libmp %s)"), VERSION, LM_VERSION);
if (argc != 2) {
@ -116,7 +117,7 @@ int main(int argc, char *argv[]) {
char *addr = NULL, *logfile = NULL, *tmpdir = NULL;
int ret = EXIT_FAILURE;
pool_config_t *pool = NULL;
size_t pool_count = 0;
ssize_t pool_count = 0;
lm_ctx_t ctx;
if (!config_load(argv[1]))
@ -143,8 +144,6 @@ int main(int argc, char *argv[]) {
}
while (NULL != pool) {
info(_("%s: loading the pool"), pool->name);
if (NULL == pool->host) {
error(_("%s: hostname not specified for pool, skipping"), pool->name);
goto end_ctx;
@ -173,7 +172,7 @@ int main(int argc, char *argv[]) {
}
if ((pool_count = lm_ctx_sync(&ctx, false, sync_callback, NULL)) < 0) {
error(_("Failed to sync the pools: %s"), lm_strerror());
error(_("Failed to sync the pools, please see the errors above"));
goto end_ctx;
}