Compare commits

..

18 Commits
24.03 ... main

Author SHA1 Message Date
ngn
a49f2b462f
Merge branch 'main' of https://git.matterlinux.xyz/Matter/libmp
All checks were successful
Build docker image / build (push) Successful in 1m9s
Signed-off-by: ngn <ngn@ngn.tf>
2025-01-28 10:05:33 +03:00
ngn
833503f455
new: docker image workflow
Signed-off-by: ngn <ngn@ngn.tf>
2025-01-28 10:01:39 +03:00
ngn
3c16d2c5ec update: better error handling for pool list loading 2024-08-25 14:30:50 +03:00
ngn
1160b4b6a9 update: better debug logging for __lm_ctx_resolve 2024-08-22 08:42:46 +03:00
ngn
6d4a8c9f9e update: version macro 2024-08-22 03:35:12 +03:00
ngn
a0d7e03f2e fix: list function should skip over empty pools 2024-08-22 02:54:48 +03:00
ngn
af904e1119 fix: update version macro 2024-08-22 00:22:52 +03:00
ngn
eb7e8ed2a0 fix: don't remove local packages after install
fixes #4
2024-08-22 00:14:23 +03:00
ngn
3e3c09c6bc update: version macro 2024-08-16 06:52:39 +03:00
ngn
ebc9192ae2 fix: temp directory and permission fixes 2024-08-16 06:52:05 +03:00
ngn
e41a627882 fix: make dirs readable by other users 2024-08-16 05:25:02 +03:00
ngn
2aa147b351 fix: do not check write permissions for ctx dirs 2024-08-16 04:24:09 +03:00
ngn
a641ef87ed fix: do not overwrite update package list 2024-08-16 03:08:57 +03:00
ngn
7564835b7d fix: remove error calls from threads 2024-08-16 01:04:57 +03:00
ngn
6dc139ca8c update: VERSION macro 2024-08-16 00:36:47 +03:00
ngn
7b1bee0b99 fix: prevent multi-threaded server race conditions 2024-08-16 00:22:44 +03:00
ngn
9f0665ce64 fix: add missing error format parameters 2024-08-15 23:50:27 +03:00
ngn
2786a642c4 fix: package DATA file keep key name 2024-08-15 23:44:20 +03:00
25 changed files with 464 additions and 338 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,7 @@
# libmp | MatterLinux package management library
![](https://git.matterlinux.xyz/matter/libmp/actions/workflows/docker.yml/badge.svg)
The core library for [`matt`](https://git.matterlinux.xyz/Matter/matt), it has
components for transferring, installing, updating and removing packages.

View File

@ -19,7 +19,12 @@ int main(int argc, char *argv[]) {
goto end;
}
if (lm_ctx_pool_add(&ctx, "test", "mptp://127.0.0.1:5858", "./examples/test") == NULL) {
if (lm_ctx_pool_add(&ctx, "test", "mptp://s.test.local", "./examples/test") == NULL) {
printf("failed to add pool: %s (%d)\n", lm_strerror(), lm_error());
goto end;
}
if (lm_ctx_pool_add(&ctx, "test", "mptp://n.test.local", "/tmp/test") == NULL) {
printf("failed to add pool: %s (%d)\n", lm_strerror(), lm_error());
goto end;
}

View File

@ -22,7 +22,7 @@
// clang-format on
#define LM_VERSION "24.03"
#define LM_VERSION "24.09"
#include "ctx.h"
#include "error.h"

View File

@ -93,8 +93,8 @@ bool lm_ctx_install(lm_ctx_t *ctx, lm_pkg_t *pkg, bool run_install, lm_ctx_insta
void *data); // installs/updates a single package
bool lm_ctx_check(
lm_ctx_t *ctx, lm_entry_t *entry, lm_ctx_check_callback_t callback, void *data); // checks a single package
size_t lm_ctx_sync(lm_ctx_t *ctx, bool do_update, lm_ctx_sync_callback_t callback, void *data); // syncs all the pools
void lm_ctx_ping(lm_ctx_t *ctx, lm_ctx_ping_callback_t callback, void *data); // pings all the pools
ssize_t lm_ctx_sync(lm_ctx_t *ctx, bool do_update, lm_ctx_sync_callback_t callback, void *data); // syncs all the pools
void lm_ctx_ping(lm_ctx_t *ctx, lm_ctx_ping_callback_t callback, void *data); // pings all the pools
bool lm_ctx_serve(lm_ctx_t *ctx, char *addr, uint8_t threads, __sighandler_t handler, lm_ctx_serve_callback_t callback,
void *data); // serves all the pools

View File

@ -140,7 +140,7 @@ typedef enum lm_error {
LM_ERR_InstallSaveFail = 138,
LM_ERR_FailMkdir = 139,
LM_ERR_NotDir = 140,
LM_ERR_NoWrite = 141,
LM_ERR_NoRead = 141,
LM_ERR_PoolListBadDir = 142,
LM_ERR_FileNotExist = 143,
LM_ERR_FileNotLink = 144,
@ -153,6 +153,11 @@ typedef enum lm_error {
LM_ERR_PoolInfoBadName = 151,
LM_ERR_PoolInfoUnknown = 152,
LM_ERR_MPTPBadPath = 153,
LM_ERR_UnknownThread = 154,
LM_ERR_PkgBadVersion = 155,
LM_ERR_PkgDataMissing = 156,
LM_ERR_PoolListDataFail = 157,
LM_ERR_PoolListAddFail = 158,
} lm_error_t;
typedef struct lm_error_desc {
@ -162,6 +167,7 @@ typedef struct lm_error_desc {
void lm_error_set(lm_error_t code, ...);
void lm_error_clear();
void lm_error_init();
lm_error_t lm_error();
char *lm_strerror();

View File

@ -6,7 +6,7 @@
#define PKG_DATA_DESC "desc"
#define PKG_DATA_VERSION "version"
#define PKG_DATA_DEPENDS "depends"
#define PKG_DATA_KEEPS "keeps"
#define PKG_DATA_KEEPS "keep"
#define DATA_FILE "DATA"
#define HASHES_FILE "HASHES"

View File

@ -33,8 +33,9 @@ bool rmrf(char *p);
int digits(int n);
bool package_parse(char *package, char *name, char *version);
bool package_version_valid(char *name);
bool package_name_valid(char *name);
bool __package_field_valid(char *field);
#define package_version_valid(x) __package_field_valid(x)
#define package_name_valid(x) __package_field_valid(x)
void pdebug(const char *func, const char *fmt, ...);
void pdebug_binary(char *data, size_t len);
@ -42,7 +43,7 @@ void pdebug_binary(char *data, size_t len);
bool parse_host(char *addr, char *host, uint16_t *port);
bool copy_blocks(struct archive *w, struct archive *r);
bool extract_archive(char *dst, char *src);
bool mkdir_ifnot(char *path);
bool mkdir_ifnot(char *path, int mode);
int join_multiple(char *res, const char *base, const char *pth, const char *pth2);
int join(char *res, const char *base, const char *pth);

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-08-15 02:14+0300\n"
"POT-Creation-Date: 2024-08-25 14:07+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,647 +17,667 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: src/error.c:19
#: src/error.c:31
msgid "no error"
msgstr "hata yok"
#: src/error.c:20
#: src/error.c:32
#, fuzzy
msgid "URL contains an invalid character"
msgstr "URL contains an invalid char"
#: src/error.c:21
#: src/error.c:33
msgid "URL does not have a valid protocol field"
msgstr "URL does not have a valid protocol field"
#: src/error.c:22
#: src/error.c:34
msgid "URL is too large"
msgstr "URL is too large"
#: src/error.c:23
#: src/error.c:35
msgid "URL hostname is too large"
msgstr "URL hostname is too large"
#: src/error.c:24
#: src/error.c:36
msgid "URL path is too large"
msgstr "URL path is too large"
#: src/error.c:25
#: src/error.c:37
msgid "URL does not have a valid hostname"
msgstr "URL does not have a valid hostname"
#: src/error.c:26
#: src/error.c:38
#, fuzzy
msgid "URL does not have a valid port number"
msgstr "URL does not have a valid hostname"
#: src/error.c:27
#: src/error.c:39
msgid "URL does not have a valid path"
msgstr "URL does not have a valid path"
#: src/error.c:28
#: src/error.c:40
#, fuzzy
msgid "hostname does not contain a valid port number"
msgstr "URL does not contain a hostname with a valid port number"
#: src/error.c:29
#: src/error.c:41
#, fuzzy
msgid "hostname is not valid"
msgstr "URL hostname is too large"
#: src/error.c:30
#: src/error.c:42
msgid "URL protocol port number is unknown"
msgstr "URL protocol port number is unknown"
#: src/error.c:31
#: src/error.c:43
msgid "URL is incomplete"
msgstr "URL tamamlanmamış"
#: src/error.c:32
#: src/error.c:44
msgid "pool does not support the specified protocol"
msgstr "pool does not support the specified protocol"
#: src/error.c:33
#: src/error.c:45
msgid "unsupported MPTP version"
msgstr ""
#: src/error.c:34
#: src/error.c:46
msgid "invalid MPTP request/response code"
msgstr ""
#: src/error.c:35
#: src/error.c:47
msgid "invalid MPTP URL"
msgstr ""
#: src/error.c:36
#: src/error.c:48
msgid "failed to resolve hostname for MPTP connection"
msgstr ""
#: src/error.c:37
#: src/error.c:49
msgid "failed to create a MPTP socket"
msgstr ""
#: src/error.c:38
#: src/error.c:50
msgid "failed to connect to the MPTP host"
msgstr ""
#: src/error.c:39
#: src/error.c:51
#, c-format
msgid "failed receive MPTP data from host: %s"
msgstr ""
#: src/error.c:40
#: src/error.c:52
msgid "failed send MPTP data to host"
msgstr ""
#: src/error.c:41
#: src/error.c:53
#, fuzzy
msgid "MPTP data size is invalid"
msgstr "URL path is too large"
#: src/error.c:42
#: src/error.c:54
#, fuzzy
msgid "MPTP host size is invalid"
msgstr "URL path is too large"
#: src/error.c:43
#: src/error.c:55
#, fuzzy
msgid "MPTP path size is invalid"
msgstr "URL path is too large"
#: src/error.c:44
#: src/error.c:56
msgid "failed to set MPTP socket options"
msgstr ""
#: src/error.c:45
#: src/error.c:57
msgid "MPTP connection timed out"
msgstr ""
#: src/error.c:46
#: src/error.c:58
#, c-format
msgid "failed to bind MPTP socket: %s"
msgstr ""
#: src/error.c:47
#: src/error.c:59
msgid "required argument is a NULL pointer or 0"
msgstr ""
#: src/error.c:48
#: src/error.c:60
msgid "not a MPTP request"
msgstr ""
#: src/error.c:49
#: src/error.c:61
msgid "not a MPTP response"
msgstr ""
#: src/error.c:50 src/error.c:51
#: src/error.c:62 src/error.c:63
msgid "MPTP request last flag is not set"
msgstr ""
#: src/error.c:52
#: src/error.c:64
msgid "host port not specified"
msgstr ""
#: src/error.c:53
#: src/error.c:65
msgid "pool info is badly formatted or is not complete"
msgstr ""
#: src/error.c:54
#: src/error.c:66
msgid "failed to write block from archive"
msgstr ""
#: src/error.c:55
#: src/error.c:67
msgid "failed to read block from archive"
msgstr ""
#: src/error.c:56
#: src/error.c:68
msgid "failed to open archive"
msgstr ""
#: src/error.c:57
#: src/error.c:69
msgid "failed to write archive header"
msgstr ""
#: src/error.c:58
#: src/error.c:70
msgid "failed to finish writing the archive entry"
msgstr ""
#: src/error.c:59
#: src/error.c:71
msgid "failed to create new archive reader/writer"
msgstr ""
#: src/error.c:60
#: src/error.c:72
msgid "failed to resolve full path for archive file"
msgstr ""
#: src/error.c:61
#: src/error.c:73
msgid "failed to read the next header of the archive"
msgstr ""
#: src/error.c:62
#: src/error.c:74
msgid "failed to obtain current working directory"
msgstr ""
#: src/error.c:63
#: src/error.c:75
msgid "failed to open extracted pool list directory"
msgstr ""
#: src/error.c:64
msgid "failed to read access the pool list file"
msgstr ""
#: src/error.c:65
msgid "failed to read access the pool info file"
msgstr ""
#: src/error.c:66
msgid "failed to parse package data"
msgstr ""
#: src/error.c:67
#, fuzzy
msgid "package name is invalid"
msgstr "URL hostname is too large"
#: src/error.c:68
msgid "data path is not set with in the ctx"
msgstr ""
#: src/error.c:69
msgid "temp path is not set with in the ctx"
msgstr ""
#: src/error.c:70
msgid "root path is not set with in the ctx"
msgstr ""
#: src/error.c:71
#, c-format
msgid "failed to set the ctx temp director to %s: %s"
msgstr ""
#: src/error.c:72
#, c-format
msgid "failed to set the ctx root directory to %s: %s"
msgstr ""
#: src/error.c:73
#, c-format
msgid "failed to set the ctx data directory to %s: %s"
msgstr ""
#: src/error.c:74
msgid "pool did not respond ping with pong"
msgstr ""
#: src/error.c:75
msgid "package file and directory paths are empty"
msgstr ""
#: src/error.c:76
msgid "failed to to open target file for sending"
#, c-format
msgid "failed to load \"%s\" data: %s"
msgstr ""
#: src/error.c:77
msgid "failed to to delete target file for receiving"
#, c-format
msgid "failed add \"%s\" to the pool list: %s"
msgstr ""
#: src/error.c:78
msgid "failed to to open target file for receiving"
msgid "failed to read access the pool list file"
msgstr ""
#: src/error.c:79
msgid "got a bad response code for receiving the target file"
msgid "failed to read access the pool info file"
msgstr ""
#: src/error.c:80
msgid "failed to write to the target file for receiving"
msgid "failed to parse package data"
msgstr ""
#: src/error.c:81
#, fuzzy
msgid "package not found"
msgid "package name is invalid"
msgstr "URL hostname is too large"
#: src/error.c:82
msgid "failed to access to the database file/directory"
msgstr ""
#, fuzzy
msgid "package version is invalid"
msgstr "URL hostname is too large"
#: src/error.c:83
msgid "failed to open SQLite database"
#, c-format
msgid "package data has missing field: %s"
msgstr ""
#: src/error.c:84
msgid "failed to create table in SQLite database"
msgid "data path is not set with in the ctx"
msgstr ""
#: src/error.c:85
msgid "failed to prepare statement for SQLite database"
msgid "temp path is not set with in the ctx"
msgstr ""
#: src/error.c:86
msgid "failed to insert to the table in SQLite database"
msgid "root path is not set with in the ctx"
msgstr ""
#: src/error.c:87
msgid "failed to select from the table in SQLite database"
#, c-format
msgid "failed to set the ctx temp director to %s: %s"
msgstr ""
#: src/error.c:88
msgid "failed to delete from the table in SQLite database"
#, c-format
msgid "failed to set the ctx root directory to %s: %s"
msgstr ""
#: src/error.c:89
msgid "failed to find entry in SQLite database"
#, c-format
msgid "failed to set the ctx data directory to %s: %s"
msgstr ""
#: src/error.c:90
msgid "failed to init GPG for package verification"
msgid "pool did not respond ping with pong"
msgstr ""
#: src/error.c:91
msgid "failed to import signature to GPG for package verification"
msgid "package file and directory paths are empty"
msgstr ""
#: src/error.c:92
msgid "failed to import archive to GPG for package verification"
msgid "failed to to open target file for sending"
msgstr ""
#: src/error.c:93
msgid "package signature verification failed with zero matches"
msgid "failed to to delete target file for receiving"
msgstr ""
#: src/error.c:94
msgid "package signature verification failed with zero results"
msgid "failed to to open target file for receiving"
msgstr ""
#: src/error.c:95
msgid "pool file and directory paths are empty"
msgid "got a bad response code for receiving the target file"
msgstr ""
#: src/error.c:96
msgid "pool is not avaliable for connection"
msgid "failed to write to the target file for receiving"
msgstr ""
#: src/error.c:97
msgid "pool URL is empty or invalid"
msgstr ""
#, fuzzy
msgid "package not found"
msgstr "URL hostname is too large"
#: src/error.c:98
msgid "pool directory path is not accessible"
msgid "failed to access to the database file/directory"
msgstr ""
#: src/error.c:99
msgid "pool directory sub-paths are not accessible"
msgid "failed to open SQLite database"
msgstr ""
#: src/error.c:100
msgid "file list not found for the package"
msgid "failed to create table in SQLite database"
msgstr ""
#: src/error.c:101
msgid "failed to prepare statement for SQLite database"
msgstr ""
#: src/error.c:102
msgid "failed to insert to the table in SQLite database"
msgstr ""
#: src/error.c:103
msgid "failed to select from the table in SQLite database"
msgstr ""
#: src/error.c:104
msgid "failed to delete from the table in SQLite database"
msgstr ""
#: src/error.c:105
msgid "failed to find entry in SQLite database"
msgstr ""
#: src/error.c:106
msgid "failed to init GPG for package verification"
msgstr ""
#: src/error.c:107
msgid "failed to import signature to GPG for package verification"
msgstr ""
#: src/error.c:108
msgid "failed to import archive to GPG for package verification"
msgstr ""
#: src/error.c:109
msgid "package signature verification failed with zero matches"
msgstr ""
#: src/error.c:110
msgid "package signature verification failed with zero results"
msgstr ""
#: src/error.c:111
msgid "pool file and directory paths are empty"
msgstr ""
#: src/error.c:112
msgid "pool is not avaliable for connection"
msgstr ""
#: src/error.c:113
msgid "pool URL is empty or invalid"
msgstr ""
#: src/error.c:114
msgid "pool directory path is not accessible"
msgstr ""
#: src/error.c:115
msgid "pool directory sub-paths are not accessible"
msgstr ""
#: src/error.c:116
msgid "file list not found for the package"
msgstr ""
#: src/error.c:117
#, c-format
msgid "failed to rename the file list for the package: %s"
msgstr ""
#: src/error.c:102
#: src/error.c:118
#, c-format
msgid "failed to open the package file list: %s"
msgstr ""
#: src/error.c:103
#: src/error.c:119
#, c-format
msgid "failed to open the database directory: %s"
msgstr ""
#: src/error.c:104
#: src/error.c:120
#, c-format
msgid "failed to remove package file list: %s"
msgstr ""
#: src/error.c:105
#: src/error.c:121
msgid "package keep list not found in the database"
msgstr ""
#: src/error.c:106
#: src/error.c:122
msgid "failed to open package keep list in the database"
msgstr ""
#: src/error.c:107
#: src/error.c:123
msgid "failed to access package keep list database directory"
msgstr ""
#: src/error.c:108
#: src/error.c:124
msgid "failed to remove package keep list from the database"
msgstr ""
#: src/error.c:109
#: src/error.c:125
#, c-format
msgid "failed to find %s (dependency of %s)"
msgstr ""
#: src/error.c:110
#: src/error.c:126
#, c-format
msgid "failed to download %s for installation: %s"
msgstr ""
#: src/error.c:111
#: src/error.c:127
#, fuzzy
msgid "package is not downloaded"
msgstr "URL hostname is too large"
#: src/error.c:112 src/error.c:113
#: src/error.c:128 src/error.c:129
msgid "failed to remove downloaded package"
msgstr ""
#: src/error.c:114
#: src/error.c:130
msgid "failed to open the destination file"
msgstr ""
#: src/error.c:115
#: src/error.c:131
msgid "failed to open the source file"
msgstr ""
#: src/error.c:116 src/error.c:117
#: src/error.c:132 src/error.c:133
msgid "failed to write to the destination file"
msgstr ""
#: src/error.c:118
#: src/error.c:134
msgid "package does not have associated pool"
msgstr ""
#: src/error.c:119
#: src/error.c:135
msgid "failed to create specified temp directory"
msgstr ""
#: src/error.c:120
#: src/error.c:136
msgid "package archive does not contain required files"
msgstr ""
#: src/error.c:121
msgid "package data does not match with target package"
msgstr ""
#: src/error.c:122
#, c-format
msgid "failed to update changes file for package: %s"
msgstr ""
#: src/error.c:123
msgid "failed to access package hashes file"
msgstr ""
#: src/error.c:124
msgid "failed to remove package changes file from the database"
msgstr ""
#: src/error.c:125
msgid "failed to stat target file for sending"
msgstr ""
#: src/error.c:126
msgid "failed to format target file size for sending"
msgstr ""
#: src/error.c:127
msgid "failed to read target file size for sending"
msgstr ""
#: src/error.c:128
msgid "failed to parse target file size for receiving"
msgstr ""
#: src/error.c:129
msgid "target file is not fully received"
msgstr ""
#: src/error.c:130
msgid "failed to stat for target extract archive"
msgstr ""
#: src/error.c:131
#, c-format
msgid "failed to add package file (%s) to the database: %s"
msgstr ""
#: src/error.c:132
#, c-format
msgid "failed to extract package files: %s"
msgstr ""
#: src/error.c:133
#, c-format
msgid "failed to add package to the database: %s"
msgstr ""
#: src/error.c:134
#, fuzzy
msgid "package is already installed"
msgstr "URL hostname is too large"
#: src/error.c:135
#, fuzzy
msgid "package is not installed"
msgstr "URL hostname is too large"
#: src/error.c:136
#, c-format
msgid "failed to remove package file (%s): %s"
msgstr ""
#: src/error.c:137
#, c-format
msgid "failed to remove package from the database: %s"
msgid "package data does not match with target package"
msgstr ""
#: src/error.c:138
#, c-format
msgid "failed to remove package files from the database: %s"
msgid "failed to update changes file for package: %s"
msgstr ""
#: src/error.c:139
#, c-format
msgid "failed to remove changes file for package: %s"
msgid "failed to access package hashes file"
msgstr ""
#: src/error.c:140
msgid "failed to get current directory for running install"
msgid "failed to remove package changes file from the database"
msgstr ""
#: src/error.c:141
msgid "failed change directory to root for running install"
msgid "failed to stat target file for sending"
msgstr ""
#: src/error.c:142
msgid "failed run install spawn command"
msgid "failed to format target file size for sending"
msgstr ""
#: src/error.c:143
msgid "failed to read target file size for sending"
msgstr ""
#: src/error.c:144
msgid "failed to change directory to old directory after running install"
msgid "failed to parse target file size for receiving"
msgstr ""
#: src/error.c:145
msgid "install script returned a bad status code"
msgid "target file is not fully received"
msgstr ""
#: src/error.c:146
#, c-format
msgid "failed to run the package install script: %s"
msgid "failed to stat for target extract archive"
msgstr ""
#: src/error.c:147
#, c-format
msgid "failed to save the package install script: %s"
msgid "failed to add package file (%s) to the database: %s"
msgstr ""
#: src/error.c:148
#, c-format
msgid "removing package breaks %s"
msgid "failed to extract package files: %s"
msgstr ""
#: src/error.c:149
#, fuzzy
msgid "package is already up-to-date"
msgstr "URL hostname is too large"
#, c-format
msgid "failed to add package to the database: %s"
msgstr ""
#: src/error.c:150
msgid "failed to open file for hashing"
msgstr ""
#, fuzzy
msgid "package is already installed"
msgstr "URL hostname is too large"
#: src/error.c:151
msgid "failed create digest for hashing"
msgstr ""
#, fuzzy
msgid "package is not installed"
msgstr "URL hostname is too large"
#: src/error.c:152
#, c-format
msgid "failed to get hash of %s: %s"
msgid "failed to remove package file (%s): %s"
msgstr ""
#: src/error.c:153
#, c-format
msgid "file hash does not match for %s"
msgid "failed to remove package from the database: %s"
msgstr ""
#: src/error.c:154
#, fuzzy
msgid "pool info is not loaded"
msgstr "URL hostname is too large"
#, c-format
msgid "failed to remove package files from the database: %s"
msgstr ""
#: src/error.c:155
msgid "pool list is empty"
#, c-format
msgid "failed to remove changes file for package: %s"
msgstr ""
#: src/error.c:156
msgid "package changes file not found in the database"
msgid "failed to get current directory for running install"
msgstr ""
#: src/error.c:157
msgid "failed to change mod of the changes file"
msgid "failed change directory to root for running install"
msgstr ""
#: src/error.c:158
msgid "failed to create install script save directory"
msgstr ""
#: src/error.c:159
msgid "directory does not have write permissions"
msgid "failed run install spawn command"
msgstr ""
#: src/error.c:160
msgid "specified path is not a directory"
msgid "failed to change directory to old directory after running install"
msgstr ""
#: src/error.c:161
msgid "failed to create the specified directory"
msgid "install script returned a bad status code"
msgstr ""
#: src/error.c:162
msgid "specified list extraction directory is not accessible"
#, c-format
msgid "failed to run the package install script: %s"
msgstr ""
#: src/error.c:163
#, c-format
msgid "file does not exist: %s"
msgid "failed to save the package install script: %s"
msgstr ""
#: src/error.c:164
#, c-format
msgid "file is a symbolic link: %s"
msgid "removing package breaks %s"
msgstr ""
#: src/error.c:165
msgid "failed to set the package archive"
msgstr ""
#, fuzzy
msgid "package is already up-to-date"
msgstr "URL hostname is too large"
#: src/error.c:166
#, c-format
msgid "failed change directory: %s"
msgid "failed to open file for hashing"
msgstr ""
#: src/error.c:167
msgid "failed to change directory to root during extraction"
msgid "failed create digest for hashing"
msgstr ""
#: src/error.c:168
msgid "failed to change directory back from root during extraction"
#, c-format
msgid "failed to get hash of %s: %s"
msgstr ""
#: src/error.c:169
#, c-format
msgid "failed to accept the MPTP connection: %s"
msgid "file hash does not match for %s"
msgstr ""
#: src/error.c:170
#, fuzzy
msgid "pool info is not loaded"
msgstr "URL hostname is too large"
#: src/error.c:171
msgid "pool list is empty"
msgstr ""
#: src/error.c:172
msgid "package changes file not found in the database"
msgstr ""
#: src/error.c:173
msgid "failed to change mod of the changes file"
msgstr ""
#: src/error.c:174
msgid "failed to create install script save directory"
msgstr ""
#: src/error.c:175
msgid "directory does not have read permissions"
msgstr ""
#: src/error.c:176
msgid "specified path is not a directory"
msgstr ""
#: src/error.c:177
msgid "failed to create the specified directory"
msgstr ""
#: src/error.c:178
msgid "specified list extraction directory is not accessible"
msgstr ""
#: src/error.c:179
#, c-format
msgid "file does not exist: %s"
msgstr ""
#: src/error.c:180
#, c-format
msgid "file is a symbolic link: %s"
msgstr ""
#: src/error.c:181
msgid "failed to set the package archive"
msgstr ""
#: src/error.c:182
#, c-format
msgid "failed change directory: %s"
msgstr ""
#: src/error.c:183
msgid "failed to change directory to root during extraction"
msgstr ""
#: src/error.c:184
msgid "failed to change directory back from root during extraction"
msgstr ""
#: src/error.c:185
#, c-format
msgid "failed to accept the MPTP connection: %s"
msgstr ""
#: src/error.c:186
#, c-format
msgid "failed to listen the MPTP socket: %s"
msgstr ""
#: src/error.c:171
#: src/error.c:187
#, c-format
msgid "pool name (%s) doesn't match with: %s"
msgstr ""
#: src/error.c:172
#: src/error.c:188
#, c-format
msgid "unknown key in the configuration: %s"
msgstr ""

View File

@ -3,15 +3,16 @@
#include "../../include/ctx.h"
#include <linux/limits.h>
#include <strings.h>
#include <stdbool.h>
#include <stdlib.h>
#include <locale.h>
#include <string.h>
#include <stdio.h>
#include <strings.h>
#include <errno.h>
bool __lm_ctx_init_checkdir(char *path){
if(!mkdir_ifnot(path)){
if(!mkdir_ifnot(path, 0755)){
lm_error_set(LM_ERR_FailMkdir);
return false;
}
@ -21,8 +22,8 @@ bool __lm_ctx_init_checkdir(char *path){
return false;
}
if(!can_write(path)){
lm_error_set(LM_ERR_NoWrite);
if(!can_read(path)){
lm_error_set(LM_ERR_NoRead);
return false;
}
@ -40,7 +41,7 @@ bool lm_ctx_init(lm_ctx_t *ctx) {
bzero(ctx, sizeof(lm_ctx_t));
ctx->version = LM_VERSION;
lm_error_clear();
lm_error_init();
return true;
}
@ -63,6 +64,12 @@ bool lm_ctx_new(lm_ctx_t *ctx, char *root_dir, char *temp_dir, char *data_dir) {
goto end;
}
if(root_dir != NULL && !can_write(root_dir)){
pdebug(__func__, "check failed for specified root directory: %s", lm_strerror());
lm_error_set(LM_ERR_CtxRootFail, root_dir, "directory is not writeable");
goto end;
}
if(root_dir != NULL)
ctx->root = realpath(root_dir, NULL);
@ -94,6 +101,8 @@ end:
void lm_ctx_free(lm_ctx_t *ctx) {
lm_ctx_pool_clear(ctx);
lm_ctx_temp_clear(ctx);
free(ctx->data);
free(ctx->root);
free(ctx->temp);

View File

@ -29,7 +29,7 @@ bool __lm_ctx_save_install(lm_ctx_t *ctx, lm_pkg_t *pkg, char *install_path){
sprintf(script_name, "install_%s", pkg->data.name);
join(script_dir, ctx->data, "scripts");
if(!mkdir_ifnot(script_dir)){
if(!mkdir_ifnot(script_dir, 0755)){
lm_error_set(LM_ERR_InstallDirFail);
return false;
}
@ -229,10 +229,8 @@ bool lm_ctx_install(lm_ctx_t *ctx, lm_pkg_t *pkg, bool run_install, lm_ctx_insta
return false;
}
if(!mkdir_ifnot(ctx->temp)){
lm_error_set(LM_ERR_CtxTempFailMkdir);
return false;
}
if(!lm_ctx_temp_clear(ctx))
return false; // error set by function
if(!lm_ctx_database_init(ctx))
return false; // error set by function
@ -386,7 +384,10 @@ end:
lm_database_files_del(ctx->db, &pkg->data);
}
unlink(pkg->archive);
unlink(pkg->signature);
if (pkg->pool != NULL){
unlink(pkg->archive);
unlink(pkg->signature);
}
return ret;
}

View File

@ -41,9 +41,14 @@ lm_pkg_t *lm_ctx_list_next(lm_ctx_list_t *list){
return list->pkg;
}
if((list->pkg = list->pkg->next) && NULL == list->pkg){
if((list->pool = list->pool->next) != NULL)
list->pkg = list->pool->pkg;
if((list->pkg = list->pkg->next) == NULL){
next_pool:
if((list->pool = list->pool->next) == NULL)
return list->pkg;
if((list->pkg = list->pool->pkg) == NULL)
goto next_pool;
return list->pkg;
}

View File

@ -20,18 +20,23 @@ bool __lm_ctx_resolve_contains(lm_pkg_t *pkg, lm_ctx_resolve_list_t *list){
}
bool __lm_ctx_resolve(lm_ctx_t *ctx, lm_ctx_resolve_list_t *list, lm_pkg_t *pkg, bool resolve_depends){
if(__lm_ctx_resolve_contains(pkg, list))
if(__lm_ctx_resolve_contains(pkg, list)){
pdebug(__func__, "%s is already in the list, skipping", pkg->data.name);
return true;
}
if(NULL == list->packages)
list->packages = malloc(sizeof(lm_pkg_t *)*(++list->count));
else
list->packages = realloc(list->packages, sizeof(lm_pkg_t *)*(++list->count));
pdebug(__func__, "adding %s to the list", pkg->data.name);
list->packages[list->count-1] = pkg;
if(!resolve_depends || NULL == pkg->data.depends)
if(!resolve_depends || NULL == pkg->data.depends){
pdebug(__func__, "skipping depend resolve for %s", pkg->data.name);
return true;
}
lm_pkg_t *depend = NULL;

View File

@ -29,15 +29,14 @@ void __lm_ctx_serve_thread(void *_arg) {
lm_mptp_t packet;
lm_mptp_init(&packet);
lm_error_clear();
if(!lm_mptp_server_recv(arg->sock, &packet)){
pdebug(__func__, "%x: failed to receive packet (%s)", arg->addr, lm_strerror());
pdebug(__func__, "%x: failed to receive packet", arg->addr);
return lm_mptp_close(arg->sock);
}
if (!lm_mptp_server_verify(&packet)) {
pdebug(__func__, "%x: closing connection, failed to verify (%s)", arg->addr, lm_strerror());
pdebug(__func__, "%x: closing connection, failed to verify", arg->addr);
return lm_mptp_close(arg->sock);
}
@ -45,12 +44,12 @@ void __lm_ctx_serve_thread(void *_arg) {
char path[packet.header.path_size + 1], *ppath = path;
if (!lm_mptp_get_host(&packet, hostname)) {
pdebug(__func__, "%x: closing connection, failed to get hostname (%s)", arg->addr, lm_strerror());
pdebug(__func__, "%x: closing connection, failed to get hostname", arg->addr);
goto end;
}
if (!lm_mptp_get_path(&packet, path)) {
pdebug(__func__, "%x: closing connection, failed to get path (%s)", arg->addr, lm_strerror());
pdebug(__func__, "%x: closing connection, failed to get path", arg->addr);
goto end;
}
@ -120,7 +119,7 @@ void __lm_ctx_serve_thread(void *_arg) {
if(!lm_mptp_get_path(&packet, path)){
// we should never be able to get here, if we do theres definetly a bug
pdebug(__func__, "PULL %s: skipping, failed to get path (%s)", pool->name, lm_strerror());
pdebug(__func__, "PULL %s: skipping, failed to get path", pool->name);
break;
}

View File

@ -25,7 +25,7 @@ bool __lm_ctx_sync_callback(char *path, size_t current, size_t total, void *data
return cbdata->callback(cbdata->ctx, cbdata->pool, cbdata->state, current, total, data);
}
size_t lm_ctx_sync(lm_ctx_t *ctx, bool do_update, lm_ctx_sync_callback_t callback, void *data){
ssize_t lm_ctx_sync(lm_ctx_t *ctx, bool do_update, lm_ctx_sync_callback_t callback, void *data){
if(NULL == ctx) {
lm_error_set(LM_ERR_ArgNULL);
return -1;

View File

@ -19,7 +19,7 @@ char *lm_ctx_temp_dir(lm_ctx_t *ctx, char *dir){
char td[strlen(ctx->temp)+strlen(dir)+10];
join(td, ctx->temp, dir);
if(!mkdir_ifnot(td)){
if(!mkdir_ifnot(td, 0755)){
lm_error_set(LM_ERR_CtxTempFailMkdir);
return NULL;
}
@ -35,11 +35,10 @@ bool lm_ctx_temp_clear(lm_ctx_t *ctx) {
rmrf(ctx->temp);
if(!mkdir_ifnot(ctx->temp)){
if(!mkdir_ifnot(ctx->temp, 0755)){
lm_error_set(LM_ERR_CtxTempFailMkdir);
return false;
}
return true;
}

View File

@ -32,9 +32,15 @@ lm_ctx_update_list_t *lm_ctx_update_list(lm_ctx_t *ctx){
list->entries = malloc(sizeof(lm_entry_t*)*(++list->count));
else
list->entries = realloc(list->entries, sizeof(lm_entry_t*)*(++list->count));
list->entries[list->count-1] = cur;
cur = malloc(sizeof(lm_entry_t));
lm_entry_init(cur);
}
lm_entry_free(cur);
free(cur);
lm_ctx_database_next_free(ctx, NULL);
return list;
}
@ -63,8 +69,10 @@ void lm_ctx_update_list_free(lm_ctx_update_list_t *list){
}
if(NULL != list->entries){
for(int i = 0; i < list->count; i++)
for(int i = 0; i < list->count; i++){
lm_entry_free(list->entries[i]);
free(list->entries[i]);
}
free(list->entries);
}

View File

@ -38,12 +38,12 @@ lm_database_t *lm_database_new(char *path){
char *err = NULL;
bzero(db, sizeof(lm_database_t));
if(exists(path, NULL) && (is_file(path) || !can_read(path) || !can_write(path))){
if(exists(path, NULL) && (is_file(path) || !can_read(path))){
lm_error_set(LM_ERR_DbCantAccess);
return NULL;
}
if(!exists(path, NULL) && !mkdir_ifnot(path)){
if(!exists(path, NULL) && !mkdir_ifnot(path, 0755)){
lm_error_set(LM_ERR_DbCantAccess);
return NULL;
}
@ -58,7 +58,7 @@ lm_database_t *lm_database_new(char *path){
return NULL;
}
if(sqlite3_exec(db->sql, queries[QUERY_CREATE_TABLE], NULL, 0, &err) != SQLITE_OK){
if(can_write(path) && sqlite3_exec(db->sql, queries[QUERY_CREATE_TABLE], NULL, 0, &err) != SQLITE_OK){
pdebug(__func__, "(%s) failed to create packages table: %s", packagesdb, err);
lm_error_set(LM_ERR_DbSqlCreateFail);
sqlite3_free(err);

View File

@ -252,12 +252,12 @@ bool lm_database_files_del(lm_database_t *db, lm_entry_t *entry){
join(temp_path, db->dir, temp_name);
if(NULL == (original = fopen(real_path, "r"))){
lm_error_set(LM_ERR_DbFilesOpenFail);
lm_error_set(LM_ERR_DbFilesOpenFail, real_path);
goto end;
}
if(NULL == (temp = fopen(temp_path, "a"))){
lm_error_set(LM_ERR_DbFilesOpenFail);
lm_error_set(LM_ERR_DbFilesOpenFail, temp_path);
goto end;
}

View File

@ -1,12 +1,14 @@
#include "../include/error.h"
#include "../include/util.h"
#include <pthread.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
lm_error_t lm_error_code = LM_ERR_NoError;
char *lm_error_str = NULL;
lm_error_t lm_error_code = LM_ERR_NoError; // error code
char *lm_error_str = NULL; // error string
pthread_t lm_error_thread = 0; // thread that is using the error system
void lm_error_clear() {
free(lm_error_str);
@ -14,7 +16,17 @@ void lm_error_clear() {
lm_error_str = NULL;
}
void lm_error_init() {
lm_error_clear();
lm_error_code = LM_ERR_NoError;
lm_error_str = NULL;
lm_error_thread = pthread_self();
}
void lm_error_set(lm_error_t code, ...) {
if (!pthread_equal(pthread_self(), lm_error_thread)) // ignore error_set outside the main thread
return;
lm_error_desc_t errors[] = {
{.code = LM_ERR_NoError, .desc = _("no error") },
{.code = LM_ERR_URLBadChar, .desc = _("URL contains an invalid character") },
@ -61,10 +73,14 @@ void lm_error_set(lm_error_t code, ...) {
{.code = LM_ERR_ArcNextHeaderFail, .desc = _("failed to read the next header of the archive") },
{.code = LM_ERR_GetCwdFail, .desc = _("failed to obtain current working directory") },
{.code = LM_ERR_PoolListDirFail, .desc = _("failed to open extracted pool list directory") },
{.code = LM_ERR_PoolListDataFail, .desc = _("failed to load \"%s\" data: %s") },
{.code = LM_ERR_PoolListAddFail, .desc = _("failed add \"%s\" to the pool list: %s") },
{.code = LM_ERR_PoolListCantRead, .desc = _("failed to read access the pool list file") },
{.code = LM_ERR_PoolInfoCantRead, .desc = _("failed to read access the pool info file") },
{.code = LM_ERR_PkgDataBad, .desc = _("failed to parse package data") },
{.code = LM_ERR_PkgBadName, .desc = _("package name is invalid") },
{.code = LM_ERR_PkgBadVersion, .desc = _("package version is invalid") },
{.code = LM_ERR_PkgDataMissing, .desc = _("package data has missing field: %s") },
{.code = LM_ERR_CtxDataNULL, .desc = _("data path is not set with in the ctx") },
{.code = LM_ERR_CtxTempNULL, .desc = _("temp path is not set with in the ctx") },
{.code = LM_ERR_CtxRootNULL, .desc = _("root path is not set with in the ctx") },
@ -156,7 +172,7 @@ void lm_error_set(lm_error_t code, ...) {
{.code = LM_ERR_DbChangesNotExists, .desc = _("package changes file not found in the database") },
{.code = LM_ERR_DbChangesChmodFail, .desc = _("failed to change mod of the changes file") },
{.code = LM_ERR_InstallDirFail, .desc = _("failed to create install script save directory") },
{.code = LM_ERR_NoWrite, .desc = _("directory does not have write permissions") },
{.code = LM_ERR_NoRead, .desc = _("directory does not have read permissions") },
{.code = LM_ERR_NotDir, .desc = _("specified path is not a directory") },
{.code = LM_ERR_FailMkdir, .desc = _("failed to create the specified directory") },
{.code = LM_ERR_PoolListBadDir, .desc = _("specified list extraction directory is not accessible") },
@ -203,9 +219,13 @@ void lm_error_set(lm_error_t code, ...) {
}
char *lm_strerror() {
if (!pthread_equal(pthread_self(), lm_error_thread))
return NULL;
return lm_error_str;
}
lm_error_t lm_error() {
if (!pthread_equal(pthread_self(), lm_error_thread))
return LM_ERR_UnknownThread;
return lm_error_code;
}

View File

@ -12,8 +12,10 @@ int lm_package_data_handler(void *_data, const char *_section, const char *_key,
lm_pkg_data_t *data = _data;
if(NULL == data->name){
if(!package_name_valid(section))
if(!package_name_valid(section)){
lm_error_set(LM_ERR_PkgBadName);
return 0;
}
data->name = strdup(section);
}
@ -24,8 +26,10 @@ int lm_package_data_handler(void *_data, const char *_section, const char *_key,
data->desc = strdup(value);
else if(eq(key, PKG_DATA_VERSION)){
if(!package_version_valid(value))
if(!package_version_valid(value)){
lm_error_set(LM_ERR_PkgBadVersion);
return 0;
}
data->version = strdup(value);
}
@ -47,13 +51,26 @@ int lm_package_data_handler(void *_data, const char *_section, const char *_key,
bool lm_package_data_load(lm_pkg_data_t *data, char *file){
lm_package_data_free(data);
lm_error_clear();
if (ini_parse(file, lm_package_data_handler, data) < 0) {
lm_error_set(LM_ERR_PkgDataBad);
return false;
}
return true;
if(LM_ERR_NoError != lm_error())
return false;
if(NULL == data->name)
lm_error_set(LM_ERR_PkgDataMissing, "name");
else if(NULL == data->desc)
lm_error_set(LM_ERR_PkgDataMissing, "desc");
else if(NULL == data->version)
lm_error_set(LM_ERR_PkgDataMissing, "version");
else if(0 == data->size)
lm_error_set(LM_ERR_PkgDataMissing, "size");
return LM_ERR_NoError == lm_error();
}
void lm_package_data_free(lm_pkg_data_t *data){
@ -62,5 +79,5 @@ void lm_package_data_free(lm_pkg_data_t *data){
free(data->version);
lm_package_data_depend_free(data);
lm_package_data_keep_free(data);
bzero(&data, sizeof(lm_pkg_data_t));
bzero(data, sizeof(lm_pkg_data_t));
}

View File

@ -89,7 +89,7 @@ bool lm_pool_info_download(lm_pool_t *pool, lm_mptp_transfer_callback_t callback
return false;
}
if(!mkdir_ifnot(pool->dir)){
if(!mkdir_ifnot(pool->dir, 0755)){
lm_error_set(LM_ERR_PoolBadDir);
return false;
}

View File

@ -15,7 +15,7 @@ bool lm_pool_list_load(lm_pool_t *pool, char *dir){
lm_error_set(LM_ERR_ArgNULL);
return false;
}
lm_pool_list_free(pool);
if(lm_pool_path_is_empty(pool)){
@ -30,12 +30,12 @@ bool lm_pool_list_load(lm_pool_t *pool, char *dir){
pdebug(__func__, "(%s) extracting pool to %s", pool->name, dir);
if(!mkdir_ifnot(pool->dir)){
if(!mkdir_ifnot(pool->dir, 0755)){
lm_error_set(LM_ERR_PoolBadDir);
return false;
}
if(!mkdir_ifnot(dir)){
if(!mkdir_ifnot(dir, 0755)){
lm_error_set(LM_ERR_PoolListBadDir);
return false;
}
@ -52,7 +52,7 @@ bool lm_pool_list_load(lm_pool_t *pool, char *dir){
lm_error_set(LM_ERR_PoolListDirFail);
goto end;
}
while((ent = readdir(dirfd)) != NULL){
if(eq(ent->d_name, "..") || eq(ent->d_name, "."))
continue;
@ -60,21 +60,29 @@ bool lm_pool_list_load(lm_pool_t *pool, char *dir){
ent_len = strlen(ent->d_name);
char datap[ent_len+list_dir_len+10];
join_multiple(datap, dir, ent->d_name, "DATA");
lm_pkg_t *pkg = lm_package_new();
if(!lm_package_data_load(&pkg->data, datap)){
pdebug(__func__, "(%s) failed to load new package from %s", pool->name, datap);
pdebug(__func__, "(%s) failed to load new package from %s: %s", pool->name, datap, lm_strerror());
if(NULL != pkg->data.name){
char *suberr = lm_strerror_dup();
lm_error_set(LM_ERR_PoolListDataFail, pkg->data.name, suberr);
free(suberr);
}
lm_package_free(pkg);
continue;
goto end;
}
if(!lm_pool_package_add(pool, pkg)){
pdebug(__func__, "(%s) failed to add new package: %s", pool->name, pkg->data.name);
pdebug(__func__, "(%s) failed to add package %s: %s", pool->name, pkg->data.name, lm_strerror());
char *suberr = lm_strerror_dup();
lm_error_set(LM_ERR_PoolListAddFail, pkg->data.name, suberr);
free(suberr);
lm_package_free(pkg);
continue;
goto end;
}
pdebug(__func__, "(%s) added new package: %s", pool->name, pkg->data.name);
}
@ -102,7 +110,7 @@ bool lm_pool_list_download(lm_pool_t *pool, char *dir, lm_mptp_transfer_callback
return false;
}
if(!mkdir_ifnot(pool->dir)){
if(!mkdir_ifnot(pool->dir, 0755)){
lm_error_set(LM_ERR_PoolBadDir);
return false;
}
@ -127,7 +135,7 @@ bool lm_pool_list_download(lm_pool_t *pool, char *dir, lm_mptp_transfer_callback
pdebug(__func__, "list file request failed for %s: %s", pool->name, lm_strerror());
goto end;
}
if(!lm_mptp_recvfile(sock, pool->list_file, callback, data)){
pdebug(__func__, "recvfile failed for %s: %s", pool->name, lm_strerror());
goto end;

View File

@ -17,7 +17,7 @@ bool lm_pool_path_set_dir(lm_pool_t *pool, char *dir){
if(NULL == dir)
return true;
if(exists(dir, NULL) && (is_file(dir) || !can_read(dir) || !can_write(dir))){
if(exists(dir, NULL) && (is_file(dir) || !can_read(dir))){
lm_error_set(LM_ERR_PoolBadDir);
return false;
}
@ -26,12 +26,12 @@ bool lm_pool_path_set_dir(lm_pool_t *pool, char *dir){
pool->info_file = join_alloc(dir, "INFO");
pool->list_file = join_alloc(dir, "LIST");
if(exists(pool->info_file, NULL) && (!is_file(pool->info_file) || !can_read(pool->info_file) || !can_write(pool->info_file))){
if(exists(pool->info_file, NULL) && (!is_file(pool->info_file) || !can_read(pool->info_file))){
lm_error_set(LM_ERR_PoolBadPaths);
return false;
}
if(exists(pool->list_file, NULL) && (!is_file(pool->list_file) || !can_read(pool->list_file) || !can_write(pool->list_file))){
if(exists(pool->list_file, NULL) && (!is_file(pool->list_file) || !can_read(pool->list_file))){
lm_error_set(LM_ERR_PoolBadPaths);
return false;
}

View File

@ -278,20 +278,12 @@ bool can_write(char *path) {
return access(path, W_OK) == 0;
}
bool mkdir_ifnot(char *path) {
return !(mkdir(path, 0700) < 0 && errno != EEXIST);
bool mkdir_ifnot(char *path, int mode) {
return !(mkdir(path, mode) < 0 && errno != EEXIST);
}
bool package_name_valid(char *name) {
for (char *c = name; *c != 0; c++) {
if (!is_digit(*c) && !is_letter(*c) && *c != '-' && *c != '.')
return false;
}
return true;
}
bool package_version_valid(char *version) {
for (char *c = version; *c != 0; c++) {
bool __package_field_valid(char *field) {
for (char *c = field; *c != 0; c++) {
if (!is_digit(*c) && !is_letter(*c) && *c != '-' && *c != '+' && *c != '.')
return false;
}