Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
a641ef87ed | |||
7564835b7d | |||
6dc139ca8c | |||
7b1bee0b99 | |||
9f0665ce64 | |||
2786a642c4 | |||
30915050c6 | |||
472cb9004e | |||
e0f0dec222 |
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
#define LM_VERSION "24.01"
|
#define LM_VERSION "24.04"
|
||||||
|
|
||||||
#include "ctx.h"
|
#include "ctx.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
@ -23,10 +23,9 @@ typedef struct lm_ctx_list {
|
|||||||
} lm_ctx_list_t;
|
} lm_ctx_list_t;
|
||||||
|
|
||||||
typedef struct lm_ctx_resolve_list {
|
typedef struct lm_ctx_resolve_list {
|
||||||
lm_pkg_t *resolving;
|
lm_pkg_t **packages;
|
||||||
lm_pkg_t *packages;
|
|
||||||
lm_pkg_t *cur;
|
lm_pkg_t *cur;
|
||||||
ssize_t count;
|
ssize_t count, index;
|
||||||
} lm_ctx_resolve_list_t;
|
} lm_ctx_resolve_list_t;
|
||||||
|
|
||||||
typedef struct lm_ctx_update_list {
|
typedef struct lm_ctx_update_list {
|
||||||
|
@ -4,39 +4,26 @@
|
|||||||
|
|
||||||
#include <sqlite3.h>
|
#include <sqlite3.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#define HASH_LEN 32
|
#define HASH_LEN 32
|
||||||
|
|
||||||
enum lm_query_index {
|
enum lm_query_index {
|
||||||
QUERY_CREATE_ENTRY_TABLE = 0,
|
QUERY_CREATE_TABLE = 0,
|
||||||
QUERY_INSERT_ENTRY_SINGLE = 1,
|
QUERY_INSERT_SINGLE = 1,
|
||||||
QUERY_SELECT_ENTRY_SINGLE_1 = 2,
|
QUERY_SELECT_SINGLE_1 = 2,
|
||||||
QUERY_SELECT_ENTRY_SINGLE_2 = 3,
|
QUERY_SELECT_SINGLE_2 = 3,
|
||||||
QUERY_DELETE_ENTRY_SINGLE = 4,
|
QUERY_DELETE_SINGLE = 4,
|
||||||
QUERY_SELECT_ENTRY_ALL = 5,
|
QUERY_SELECT_ALL = 5,
|
||||||
|
|
||||||
QUERY_CREATE_FILE_TABLE = 6,
|
|
||||||
QUERY_INSERT_FILE_SINGLE = 7,
|
|
||||||
QUERY_DELETE_FILE_ALL = 8,
|
|
||||||
QUERY_DELETE_FILE_SINGLE = 9,
|
|
||||||
QUERY_SELECT_FILE_ALL = 10,
|
|
||||||
QUERY_SELECT_FILE_SINGLE = 11,
|
|
||||||
QUERY_UPDATE_FILE_1 = 12,
|
|
||||||
QUERY_UPDATE_FILE_2 = 13,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum lm_columns {
|
enum lm_columns {
|
||||||
FILES_COLUMN_PATH = 1,
|
COLUMN_NAME = 1,
|
||||||
FILES_COLUMN_HASH = 2,
|
COLUMN_VERSION = 2,
|
||||||
FILES_COLUMN_KEEP = 3,
|
COLUMN_DESC = 3,
|
||||||
FILES_COLUMN_ENTRY = 4,
|
COLUMN_SIZE = 4,
|
||||||
|
COLUMN_DEPENDS = 5,
|
||||||
ENTRIES_COLUMN_NAME = 1,
|
|
||||||
ENTRIES_COLUMN_VERSION = 2,
|
|
||||||
ENTRIES_COLUMN_DESC = 3,
|
|
||||||
ENTRIES_COLUMN_SIZE = 4,
|
|
||||||
ENTRIES_COLUMN_DEPENDS = 5,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern char *queries[];
|
extern char *queries[];
|
||||||
@ -44,12 +31,9 @@ extern char *queries[];
|
|||||||
typedef lm_pkg_data_t lm_entry_t;
|
typedef lm_pkg_data_t lm_entry_t;
|
||||||
|
|
||||||
typedef struct lm_database {
|
typedef struct lm_database {
|
||||||
sqlite3 *entries_db;
|
sqlite3 *sql;
|
||||||
sqlite3_stmt *entries_st;
|
sqlite3_stmt *st;
|
||||||
|
FILE *filesp;
|
||||||
sqlite3 *files_db;
|
|
||||||
sqlite3_stmt *files_st;
|
|
||||||
|
|
||||||
char *dir;
|
char *dir;
|
||||||
} lm_database_t;
|
} lm_database_t;
|
||||||
|
|
||||||
@ -79,8 +63,9 @@ bool lm_database_files_next(
|
|||||||
lm_database_t *db, lm_entry_t *entry, char **path, char **hash, bool *keep); // gets the next file of the entry
|
lm_database_t *db, lm_entry_t *entry, char **path, char **hash, bool *keep); // gets the next file of the entry
|
||||||
bool lm_database_files_add(
|
bool lm_database_files_add(
|
||||||
lm_database_t *db, lm_entry_t *entry, char *path, char *hash); // adds a file to the files database
|
lm_database_t *db, lm_entry_t *entry, char *path, char *hash); // adds a file to the files database
|
||||||
bool lm_database_files_del(lm_database_t *db, lm_entry_t *entry); // dels all files of belonging to a entry
|
bool lm_database_files_del(
|
||||||
bool lm_database_files_del_single(lm_database_t *db, char *path);
|
lm_database_t *db, lm_entry_t *entry); // dels files belonging to an entry that is not set as KEEP
|
||||||
|
bool lm_database_files_del_all(lm_database_t *db, lm_entry_t *entry); // dels all files of belonging to an entry
|
||||||
void lm_database_files_next_free(lm_database_t *db, lm_entry_t *entry, char **path, char **hash,
|
void lm_database_files_next_free(lm_database_t *db, lm_entry_t *entry, char **path, char **hash,
|
||||||
bool *keep); // frees resources used for lm_database_files_next
|
bool *keep); // frees resources used for lm_database_files_next
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ typedef enum lm_error {
|
|||||||
LM_ERR_DbFilesOpenFail = 80,
|
LM_ERR_DbFilesOpenFail = 80,
|
||||||
LM_ERR_DbFilesDirFail = 81,
|
LM_ERR_DbFilesDirFail = 81,
|
||||||
LM_ERR_DbFilesUnlinkFail = 82,
|
LM_ERR_DbFilesUnlinkFail = 82,
|
||||||
LM_ERR_DbFilesWriteFail = 83,
|
LM_ERR_DbFilesRenameFail = 83,
|
||||||
LM_ERR_DbKeepsNotFound = 84,
|
LM_ERR_DbKeepsNotFound = 84,
|
||||||
LM_ERR_DbKeepsOpenFail = 85,
|
LM_ERR_DbKeepsOpenFail = 85,
|
||||||
LM_ERR_DbKeepsDirFail = 86,
|
LM_ERR_DbKeepsDirFail = 86,
|
||||||
@ -153,6 +153,7 @@ typedef enum lm_error {
|
|||||||
LM_ERR_PoolInfoBadName = 151,
|
LM_ERR_PoolInfoBadName = 151,
|
||||||
LM_ERR_PoolInfoUnknown = 152,
|
LM_ERR_PoolInfoUnknown = 152,
|
||||||
LM_ERR_MPTPBadPath = 153,
|
LM_ERR_MPTPBadPath = 153,
|
||||||
|
LM_ERR_UnknownThread = 154,
|
||||||
} lm_error_t;
|
} lm_error_t;
|
||||||
|
|
||||||
typedef struct lm_error_desc {
|
typedef struct lm_error_desc {
|
||||||
@ -162,6 +163,7 @@ typedef struct lm_error_desc {
|
|||||||
|
|
||||||
void lm_error_set(lm_error_t code, ...);
|
void lm_error_set(lm_error_t code, ...);
|
||||||
void lm_error_clear();
|
void lm_error_clear();
|
||||||
|
void lm_error_init();
|
||||||
lm_error_t lm_error();
|
lm_error_t lm_error();
|
||||||
char *lm_strerror();
|
char *lm_strerror();
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#define PKG_DATA_DESC "desc"
|
#define PKG_DATA_DESC "desc"
|
||||||
#define PKG_DATA_VERSION "version"
|
#define PKG_DATA_VERSION "version"
|
||||||
#define PKG_DATA_DEPENDS "depends"
|
#define PKG_DATA_DEPENDS "depends"
|
||||||
#define PKG_DATA_KEEPS "keeps"
|
#define PKG_DATA_KEEPS "keep"
|
||||||
|
|
||||||
#define DATA_FILE "DATA"
|
#define DATA_FILE "DATA"
|
||||||
#define HASHES_FILE "HASHES"
|
#define HASHES_FILE "HASHES"
|
||||||
|
@ -47,9 +47,3 @@ bool mkdir_ifnot(char *path);
|
|||||||
int join_multiple(char *res, const char *base, const char *pth, const char *pth2);
|
int join_multiple(char *res, const char *base, const char *pth, const char *pth2);
|
||||||
int join(char *res, const char *base, const char *pth);
|
int join(char *res, const char *base, const char *pth);
|
||||||
char *join_alloc(const char *base, const char *pth);
|
char *join_alloc(const char *base, const char *pth);
|
||||||
|
|
||||||
bool pkglist_contains(lm_pkg_t *list, lm_pkg_t *pkg);
|
|
||||||
lm_pkg_t *pkglist_del(lm_pkg_t *list, lm_pkg_t *pkg);
|
|
||||||
lm_pkg_t *pkglist_add_top(lm_pkg_t *list, lm_pkg_t *pkg);
|
|
||||||
lm_pkg_t *pkglist_add_end(lm_pkg_t *list, lm_pkg_t *pkg);
|
|
||||||
void pkglist_free(lm_pkg_t *list);
|
|
||||||
|
@ -8,7 +8,7 @@ msgid ""
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: PACKAGE VERSION\n"
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2024-08-10 00:05+0300\n"
|
"POT-Creation-Date: 2024-08-16 03:06+0300\n"
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
@ -17,643 +17,647 @@ msgstr ""
|
|||||||
"Content-Type: text/plain; charset=UTF-8\n"
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
|
||||||
#: src/error.c:19
|
#: src/error.c:31
|
||||||
msgid "no error"
|
msgid "no error"
|
||||||
msgstr "hata yok"
|
msgstr "hata yok"
|
||||||
|
|
||||||
#: src/error.c:20
|
#: src/error.c:32
|
||||||
#, fuzzy
|
#, fuzzy
|
||||||
msgid "URL contains an invalid character"
|
msgid "URL contains an invalid character"
|
||||||
msgstr "URL contains an invalid char"
|
msgstr "URL contains an invalid char"
|
||||||
|
|
||||||
#: src/error.c:21
|
#: src/error.c:33
|
||||||
msgid "URL does not have a valid protocol field"
|
msgid "URL does not have a valid protocol field"
|
||||||
msgstr "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"
|
msgid "URL is too large"
|
||||||
msgstr "URL is too large"
|
msgstr "URL is too large"
|
||||||
|
|
||||||
#: src/error.c:23
|
#: src/error.c:35
|
||||||
msgid "URL hostname is too large"
|
msgid "URL hostname is too large"
|
||||||
msgstr "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"
|
msgid "URL path is too large"
|
||||||
msgstr "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"
|
msgid "URL does not have a valid hostname"
|
||||||
msgstr "URL does not have a valid hostname"
|
msgstr "URL does not have a valid hostname"
|
||||||
|
|
||||||
#: src/error.c:26
|
#: src/error.c:38
|
||||||
#, fuzzy
|
#, fuzzy
|
||||||
msgid "URL does not have a valid port number"
|
msgid "URL does not have a valid port number"
|
||||||
msgstr "URL does not have a valid hostname"
|
msgstr "URL does not have a valid hostname"
|
||||||
|
|
||||||
#: src/error.c:27
|
#: src/error.c:39
|
||||||
msgid "URL does not have a valid path"
|
msgid "URL does not have a valid path"
|
||||||
msgstr "URL does not have a valid path"
|
msgstr "URL does not have a valid path"
|
||||||
|
|
||||||
#: src/error.c:28
|
#: src/error.c:40
|
||||||
#, fuzzy
|
#, fuzzy
|
||||||
msgid "hostname does not contain a valid port number"
|
msgid "hostname does not contain a valid port number"
|
||||||
msgstr "URL does not contain a hostname with 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
|
#, fuzzy
|
||||||
msgid "hostname is not valid"
|
msgid "hostname is not valid"
|
||||||
msgstr "URL hostname is too large"
|
msgstr "URL hostname is too large"
|
||||||
|
|
||||||
#: src/error.c:30
|
#: src/error.c:42
|
||||||
msgid "URL protocol port number is unknown"
|
msgid "URL protocol port number is unknown"
|
||||||
msgstr "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"
|
msgid "URL is incomplete"
|
||||||
msgstr "URL tamamlanmamış"
|
msgstr "URL tamamlanmamış"
|
||||||
|
|
||||||
#: src/error.c:32
|
#: src/error.c:44
|
||||||
msgid "pool does not support the specified protocol"
|
msgid "pool does not support the specified protocol"
|
||||||
msgstr "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"
|
msgid "unsupported MPTP version"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:34
|
#: src/error.c:46
|
||||||
msgid "invalid MPTP request/response code"
|
msgid "invalid MPTP request/response code"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:35
|
#: src/error.c:47
|
||||||
msgid "invalid MPTP URL"
|
msgid "invalid MPTP URL"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:36
|
#: src/error.c:48
|
||||||
msgid "failed to resolve hostname for MPTP connection"
|
msgid "failed to resolve hostname for MPTP connection"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:37
|
#: src/error.c:49
|
||||||
msgid "failed to create a MPTP socket"
|
msgid "failed to create a MPTP socket"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:38
|
#: src/error.c:50
|
||||||
msgid "failed to connect to the MPTP host"
|
msgid "failed to connect to the MPTP host"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:39
|
#: src/error.c:51
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "failed receive MPTP data from host: %s"
|
msgid "failed receive MPTP data from host: %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:40
|
#: src/error.c:52
|
||||||
msgid "failed send MPTP data to host"
|
msgid "failed send MPTP data to host"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:41
|
#: src/error.c:53
|
||||||
#, fuzzy
|
#, fuzzy
|
||||||
msgid "MPTP data size is invalid"
|
msgid "MPTP data size is invalid"
|
||||||
msgstr "URL path is too large"
|
msgstr "URL path is too large"
|
||||||
|
|
||||||
#: src/error.c:42
|
#: src/error.c:54
|
||||||
#, fuzzy
|
#, fuzzy
|
||||||
msgid "MPTP host size is invalid"
|
msgid "MPTP host size is invalid"
|
||||||
msgstr "URL path is too large"
|
msgstr "URL path is too large"
|
||||||
|
|
||||||
#: src/error.c:43
|
#: src/error.c:55
|
||||||
#, fuzzy
|
#, fuzzy
|
||||||
msgid "MPTP path size is invalid"
|
msgid "MPTP path size is invalid"
|
||||||
msgstr "URL path is too large"
|
msgstr "URL path is too large"
|
||||||
|
|
||||||
#: src/error.c:44
|
#: src/error.c:56
|
||||||
msgid "failed to set MPTP socket options"
|
msgid "failed to set MPTP socket options"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:45
|
#: src/error.c:57
|
||||||
msgid "MPTP connection timed out"
|
msgid "MPTP connection timed out"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:46
|
#: src/error.c:58
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "failed to bind MPTP socket: %s"
|
msgid "failed to bind MPTP socket: %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:47
|
#: src/error.c:59
|
||||||
msgid "required argument is a NULL pointer or 0"
|
msgid "required argument is a NULL pointer or 0"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:48
|
#: src/error.c:60
|
||||||
msgid "not a MPTP request"
|
msgid "not a MPTP request"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:49
|
#: src/error.c:61
|
||||||
msgid "not a MPTP response"
|
msgid "not a MPTP response"
|
||||||
msgstr ""
|
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"
|
msgid "MPTP request last flag is not set"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:52
|
#: src/error.c:64
|
||||||
msgid "host port not specified"
|
msgid "host port not specified"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:53
|
#: src/error.c:65
|
||||||
msgid "pool info is badly formatted or is not complete"
|
msgid "pool info is badly formatted or is not complete"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:54
|
#: src/error.c:66
|
||||||
msgid "failed to write block from archive"
|
msgid "failed to write block from archive"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:55
|
#: src/error.c:67
|
||||||
msgid "failed to read block from archive"
|
msgid "failed to read block from archive"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:56
|
#: src/error.c:68
|
||||||
msgid "failed to open archive"
|
msgid "failed to open archive"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:57
|
#: src/error.c:69
|
||||||
msgid "failed to write archive header"
|
msgid "failed to write archive header"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:58
|
#: src/error.c:70
|
||||||
msgid "failed to finish writing the archive entry"
|
msgid "failed to finish writing the archive entry"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:59
|
#: src/error.c:71
|
||||||
msgid "failed to create new archive reader/writer"
|
msgid "failed to create new archive reader/writer"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:60
|
#: src/error.c:72
|
||||||
msgid "failed to resolve full path for archive file"
|
msgid "failed to resolve full path for archive file"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:61
|
#: src/error.c:73
|
||||||
msgid "failed to read the next header of the archive"
|
msgid "failed to read the next header of the archive"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:62
|
#: src/error.c:74
|
||||||
msgid "failed to obtain current working directory"
|
msgid "failed to obtain current working directory"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:63
|
#: src/error.c:75
|
||||||
msgid "failed to open extracted pool list directory"
|
msgid "failed to open extracted pool list directory"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:64
|
#: src/error.c:76
|
||||||
msgid "failed to read access the pool list file"
|
msgid "failed to read access the pool list file"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:65
|
#: src/error.c:77
|
||||||
msgid "failed to read access the pool info file"
|
msgid "failed to read access the pool info file"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:66
|
#: src/error.c:78
|
||||||
msgid "failed to parse package data"
|
msgid "failed to parse package data"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:67
|
#: src/error.c:79
|
||||||
#, fuzzy
|
#, fuzzy
|
||||||
msgid "package name is invalid"
|
msgid "package name is invalid"
|
||||||
msgstr "URL hostname is too large"
|
msgstr "URL hostname is too large"
|
||||||
|
|
||||||
#: src/error.c:68
|
#: src/error.c:80
|
||||||
msgid "data path is not set with in the ctx"
|
msgid "data path is not set with in the ctx"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:69
|
#: src/error.c:81
|
||||||
msgid "temp path is not set with in the ctx"
|
msgid "temp path is not set with in the ctx"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:70
|
#: src/error.c:82
|
||||||
msgid "root path is not set with in the ctx"
|
msgid "root path is not set with in the ctx"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:71
|
#: src/error.c:83
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "failed to set the ctx temp director to %s: %s"
|
msgid "failed to set the ctx temp director to %s: %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:72
|
#: src/error.c:84
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "failed to set the ctx root directory to %s: %s"
|
msgid "failed to set the ctx root directory to %s: %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:73
|
#: src/error.c:85
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "failed to set the ctx data directory to %s: %s"
|
msgid "failed to set the ctx data directory to %s: %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:74
|
#: src/error.c:86
|
||||||
msgid "pool did not respond ping with pong"
|
msgid "pool did not respond ping with pong"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:75
|
#: src/error.c:87
|
||||||
msgid "package file and directory paths are empty"
|
msgid "package file and directory paths are empty"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:76
|
#: src/error.c:88
|
||||||
msgid "failed to to open target file for sending"
|
msgid "failed to to open target file for sending"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:77
|
#: src/error.c:89
|
||||||
msgid "failed to to delete target file for receiving"
|
msgid "failed to to delete target file for receiving"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:78
|
#: src/error.c:90
|
||||||
msgid "failed to to open target file for receiving"
|
msgid "failed to to open target file for receiving"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:79
|
#: src/error.c:91
|
||||||
msgid "got a bad response code for receiving the target file"
|
msgid "got a bad response code for receiving the target file"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:80
|
#: src/error.c:92
|
||||||
msgid "failed to write to the target file for receiving"
|
msgid "failed to write to the target file for receiving"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:81
|
#: src/error.c:93
|
||||||
#, fuzzy
|
#, fuzzy
|
||||||
msgid "package not found"
|
msgid "package not found"
|
||||||
msgstr "URL hostname is too large"
|
msgstr "URL hostname is too large"
|
||||||
|
|
||||||
#: src/error.c:82
|
#: src/error.c:94
|
||||||
msgid "failed to access to the database file/directory"
|
msgid "failed to access to the database file/directory"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:83
|
#: src/error.c:95
|
||||||
msgid "failed to open SQLite database"
|
msgid "failed to open SQLite database"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:84
|
#: src/error.c:96
|
||||||
msgid "failed to create table in SQLite database"
|
msgid "failed to create table in SQLite database"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:85
|
#: src/error.c:97
|
||||||
msgid "failed to prepare statement for SQLite database"
|
msgid "failed to prepare statement for SQLite database"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:86
|
#: src/error.c:98
|
||||||
msgid "failed to insert to the table in SQLite database"
|
msgid "failed to insert to the table in SQLite database"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:87
|
#: src/error.c:99
|
||||||
msgid "failed to select from the table in SQLite database"
|
msgid "failed to select from the table in SQLite database"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:88
|
#: src/error.c:100
|
||||||
msgid "failed to delete from the table in SQLite database"
|
msgid "failed to delete from the table in SQLite database"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:89
|
#: src/error.c:101
|
||||||
msgid "failed to find entry in SQLite database"
|
msgid "failed to find entry in SQLite database"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:90
|
#: src/error.c:102
|
||||||
msgid "failed to init GPG for package verification"
|
msgid "failed to init GPG for package verification"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:91
|
#: src/error.c:103
|
||||||
msgid "failed to import signature to GPG for package verification"
|
msgid "failed to import signature to GPG for package verification"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:92
|
#: src/error.c:104
|
||||||
msgid "failed to import archive to GPG for package verification"
|
msgid "failed to import archive to GPG for package verification"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:93
|
#: src/error.c:105
|
||||||
msgid "package signature verification failed with zero matches"
|
msgid "package signature verification failed with zero matches"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:94
|
#: src/error.c:106
|
||||||
msgid "package signature verification failed with zero results"
|
msgid "package signature verification failed with zero results"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:95
|
#: src/error.c:107
|
||||||
msgid "pool file and directory paths are empty"
|
msgid "pool file and directory paths are empty"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:96
|
#: src/error.c:108
|
||||||
msgid "pool is not avaliable for connection"
|
msgid "pool is not avaliable for connection"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:97
|
#: src/error.c:109
|
||||||
msgid "pool URL is empty or invalid"
|
msgid "pool URL is empty or invalid"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:98
|
#: src/error.c:110
|
||||||
msgid "pool directory path is not accessible"
|
msgid "pool directory path is not accessible"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:99
|
#: src/error.c:111
|
||||||
msgid "pool directory sub-paths are not accessible"
|
msgid "pool directory sub-paths are not accessible"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:100
|
#: src/error.c:112
|
||||||
msgid "package file list not found in the database"
|
msgid "file list not found for the package"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:101
|
#: src/error.c:113
|
||||||
msgid "failed to open package file list in the database"
|
#, c-format
|
||||||
|
msgid "failed to rename the file list for the package: %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:102
|
#: src/error.c:114
|
||||||
msgid "failed to access package file list database directory"
|
#, c-format
|
||||||
|
msgid "failed to open the package file list: %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:103
|
#: src/error.c:115
|
||||||
msgid "failed to remove package file list from the database"
|
#, c-format
|
||||||
|
msgid "failed to open the database directory: %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:104
|
#: src/error.c:116
|
||||||
msgid "failed to write to the file list in the database"
|
#, c-format
|
||||||
|
msgid "failed to remove package file list: %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:105
|
#: src/error.c:117
|
||||||
msgid "package keep list not found in the database"
|
msgid "package keep list not found in the database"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:106
|
#: src/error.c:118
|
||||||
msgid "failed to open package keep list in the database"
|
msgid "failed to open package keep list in the database"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:107
|
#: src/error.c:119
|
||||||
msgid "failed to access package keep list database directory"
|
msgid "failed to access package keep list database directory"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:108
|
#: src/error.c:120
|
||||||
msgid "failed to remove package keep list from the database"
|
msgid "failed to remove package keep list from the database"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:109
|
#: src/error.c:121
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "failed to find %s (dependency of %s)"
|
msgid "failed to find %s (dependency of %s)"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:110
|
#: src/error.c:122
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "failed to download %s for installation: %s"
|
msgid "failed to download %s for installation: %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:111
|
#: src/error.c:123
|
||||||
#, fuzzy
|
#, fuzzy
|
||||||
msgid "package is not downloaded"
|
msgid "package is not downloaded"
|
||||||
msgstr "URL hostname is too large"
|
msgstr "URL hostname is too large"
|
||||||
|
|
||||||
#: src/error.c:112 src/error.c:113
|
#: src/error.c:124 src/error.c:125
|
||||||
msgid "failed to remove downloaded package"
|
msgid "failed to remove downloaded package"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:114
|
#: src/error.c:126
|
||||||
msgid "failed to open the destination file"
|
msgid "failed to open the destination file"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:115
|
#: src/error.c:127
|
||||||
msgid "failed to open the source file"
|
msgid "failed to open the source file"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:116 src/error.c:117
|
#: src/error.c:128 src/error.c:129
|
||||||
msgid "failed to write to the destination file"
|
msgid "failed to write to the destination file"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:118
|
#: src/error.c:130
|
||||||
msgid "package does not have associated pool"
|
msgid "package does not have associated pool"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:119
|
#: src/error.c:131
|
||||||
msgid "failed to create specified temp directory"
|
msgid "failed to create specified temp directory"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:120
|
#: src/error.c:132
|
||||||
msgid "package archive does not contain required files"
|
msgid "package archive does not contain required files"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:121
|
#: src/error.c:133
|
||||||
msgid "package data does not match with target package"
|
msgid "package data does not match with target package"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:122
|
#: src/error.c:134
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "failed to update changes file for package: %s"
|
msgid "failed to update changes file for package: %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:123
|
#: src/error.c:135
|
||||||
msgid "failed to access package hashes file"
|
msgid "failed to access package hashes file"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:124
|
#: src/error.c:136
|
||||||
msgid "failed to remove package changes file from the database"
|
msgid "failed to remove package changes file from the database"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:125
|
#: src/error.c:137
|
||||||
msgid "failed to stat target file for sending"
|
msgid "failed to stat target file for sending"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:126
|
#: src/error.c:138
|
||||||
msgid "failed to format target file size for sending"
|
msgid "failed to format target file size for sending"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:127
|
#: src/error.c:139
|
||||||
msgid "failed to read target file size for sending"
|
msgid "failed to read target file size for sending"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:128
|
#: src/error.c:140
|
||||||
msgid "failed to parse target file size for receiving"
|
msgid "failed to parse target file size for receiving"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:129
|
#: src/error.c:141
|
||||||
msgid "target file is not fully received"
|
msgid "target file is not fully received"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:130
|
#: src/error.c:142
|
||||||
msgid "failed to stat for target extract archive"
|
msgid "failed to stat for target extract archive"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:131
|
#: src/error.c:143
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "failed to add package file (%s) to the database: %s"
|
msgid "failed to add package file (%s) to the database: %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:132
|
#: src/error.c:144
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "failed to extract package files: %s"
|
msgid "failed to extract package files: %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:133
|
#: src/error.c:145
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "failed to add package to the database: %s"
|
msgid "failed to add package to the database: %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:134
|
#: src/error.c:146
|
||||||
#, fuzzy
|
#, fuzzy
|
||||||
msgid "package is already installed"
|
msgid "package is already installed"
|
||||||
msgstr "URL hostname is too large"
|
msgstr "URL hostname is too large"
|
||||||
|
|
||||||
#: src/error.c:135
|
#: src/error.c:147
|
||||||
#, fuzzy
|
#, fuzzy
|
||||||
msgid "package is not installed"
|
msgid "package is not installed"
|
||||||
msgstr "URL hostname is too large"
|
msgstr "URL hostname is too large"
|
||||||
|
|
||||||
#: src/error.c:136
|
#: src/error.c:148
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "failed to remove package file (%s): %s"
|
msgid "failed to remove package file (%s): %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:137
|
#: src/error.c:149
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "failed to remove package from the database: %s"
|
msgid "failed to remove package from the database: %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:138
|
#: src/error.c:150
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "failed to remove package files from the database: %s"
|
msgid "failed to remove package files from the database: %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:139
|
#: src/error.c:151
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "failed to remove changes file for package: %s"
|
msgid "failed to remove changes file for package: %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:140
|
#: src/error.c:152
|
||||||
msgid "failed to get current directory for running install"
|
msgid "failed to get current directory for running install"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:141
|
#: src/error.c:153
|
||||||
msgid "failed change directory to root for running install"
|
msgid "failed change directory to root for running install"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:142
|
#: src/error.c:154
|
||||||
msgid "failed run install spawn command"
|
msgid "failed run install spawn command"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:144
|
#: src/error.c:156
|
||||||
msgid "failed to change directory to old directory after running install"
|
msgid "failed to change directory to old directory after running install"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:145
|
#: src/error.c:157
|
||||||
msgid "install script returned a bad status code"
|
msgid "install script returned a bad status code"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:146
|
#: src/error.c:158
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "failed to run the package install script: %s"
|
msgid "failed to run the package install script: %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:147
|
#: src/error.c:159
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "failed to save the package install script: %s"
|
msgid "failed to save the package install script: %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:148
|
#: src/error.c:160
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "removing package breaks %s"
|
msgid "removing package breaks %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:149
|
#: src/error.c:161
|
||||||
#, fuzzy
|
#, fuzzy
|
||||||
msgid "package is already up-to-date"
|
msgid "package is already up-to-date"
|
||||||
msgstr "URL hostname is too large"
|
msgstr "URL hostname is too large"
|
||||||
|
|
||||||
#: src/error.c:150
|
#: src/error.c:162
|
||||||
msgid "failed to open file for hashing"
|
msgid "failed to open file for hashing"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:151
|
|
||||||
msgid "failed create digest for hashing"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: src/error.c:152
|
|
||||||
#, c-format
|
|
||||||
msgid "failed to get hash of %s: %s"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: src/error.c:153
|
|
||||||
#, c-format
|
|
||||||
msgid "file hash does not match for %s"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: src/error.c:154
|
|
||||||
#, fuzzy
|
|
||||||
msgid "pool info is not loaded"
|
|
||||||
msgstr "URL hostname is too large"
|
|
||||||
|
|
||||||
#: src/error.c:155
|
|
||||||
msgid "pool list is empty"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: src/error.c:156
|
|
||||||
msgid "package changes file not found in the database"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: src/error.c:157
|
|
||||||
msgid "failed to change mod of the changes file"
|
|
||||||
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"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: src/error.c:160
|
|
||||||
msgid "specified path is not a directory"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: src/error.c:161
|
|
||||||
msgid "failed to create the specified directory"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: src/error.c:162
|
|
||||||
msgid "specified list extraction directory is not accessible"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: src/error.c:163
|
#: src/error.c:163
|
||||||
#, c-format
|
msgid "failed create digest for hashing"
|
||||||
msgid "file does not exist: %s"
|
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:164
|
#: src/error.c:164
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "file is a symbolic link: %s"
|
msgid "failed to get hash of %s: %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:165
|
#: src/error.c:165
|
||||||
msgid "failed to set the package archive"
|
#, c-format
|
||||||
|
msgid "file hash does not match for %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:166
|
#: src/error.c:166
|
||||||
|
#, fuzzy
|
||||||
|
msgid "pool info is not loaded"
|
||||||
|
msgstr "URL hostname is too large"
|
||||||
|
|
||||||
|
#: src/error.c:167
|
||||||
|
msgid "pool list is empty"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/error.c:168
|
||||||
|
msgid "package changes file not found in the database"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/error.c:169
|
||||||
|
msgid "failed to change mod of the changes file"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/error.c:170
|
||||||
|
msgid "failed to create install script save directory"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/error.c:171
|
||||||
|
msgid "directory does not have write permissions"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/error.c:172
|
||||||
|
msgid "specified path is not a directory"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/error.c:173
|
||||||
|
msgid "failed to create the specified directory"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/error.c:174
|
||||||
|
msgid "specified list extraction directory is not accessible"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/error.c:175
|
||||||
|
#, c-format
|
||||||
|
msgid "file does not exist: %s"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/error.c:176
|
||||||
|
#, c-format
|
||||||
|
msgid "file is a symbolic link: %s"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/error.c:177
|
||||||
|
msgid "failed to set the package archive"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/error.c:178
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "failed change directory: %s"
|
msgid "failed change directory: %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:167
|
#: src/error.c:179
|
||||||
msgid "failed to change directory to root during extraction"
|
msgid "failed to change directory to root during extraction"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:168
|
#: src/error.c:180
|
||||||
msgid "failed to change directory back from root during extraction"
|
msgid "failed to change directory back from root during extraction"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:169
|
#: src/error.c:181
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "failed to accept the MPTP connection: %s"
|
msgid "failed to accept the MPTP connection: %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:170
|
#: src/error.c:182
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "failed to listen the MPTP socket: %s"
|
msgid "failed to listen the MPTP socket: %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:171
|
#: src/error.c:183
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "pool name (%s) doesn't match with: %s"
|
msgid "pool name (%s) doesn't match with: %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/error.c:172
|
#: src/error.c:184
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "unknown key in the configuration: %s"
|
msgid "unknown key in the configuration: %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
@ -47,7 +47,8 @@ bool lm_ctx_check(lm_ctx_t *ctx, lm_entry_t *entry, lm_ctx_check_callback_t call
|
|||||||
if(S_ISLNK(st.st_mode)){
|
if(S_ISLNK(st.st_mode)){
|
||||||
pdebug(__func__, "%s seems to be a link, no hash verification to do", fp);
|
pdebug(__func__, "%s seems to be a link, no hash verification to do", fp);
|
||||||
|
|
||||||
if(hash[0] != '\0'){
|
// hashes for links are just "#" chars
|
||||||
|
if(hash[0] != '#'){
|
||||||
lm_error_set(LM_ERR_FileNotLink, fp);
|
lm_error_set(LM_ERR_FileNotLink, fp);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ bool lm_ctx_init(lm_ctx_t *ctx) {
|
|||||||
|
|
||||||
bzero(ctx, sizeof(lm_ctx_t));
|
bzero(ctx, sizeof(lm_ctx_t));
|
||||||
ctx->version = LM_VERSION;
|
ctx->version = LM_VERSION;
|
||||||
lm_error_clear();
|
lm_error_init();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -137,14 +137,14 @@ bool __lm_ctx_extract_files(lm_ctx_t *ctx, lm_pkg_t *pkg, char *files, lm_ctx_in
|
|||||||
current += archive_entry_size(entry);
|
current += archive_entry_size(entry);
|
||||||
type = archive_entry_filetype(entry);
|
type = archive_entry_filetype(entry);
|
||||||
|
|
||||||
if(exists(entry_path, NULL) && lm_database_files_iskeep(ctx->db, entry_path)){
|
if(exists(entry_path, NULL) && lm_package_data_keep_contains(&pkg->data, entry_path)){
|
||||||
pdebug(__func__, "not extracting %s, file is set as KEEP", entry_path);
|
pdebug(__func__, "not extracting %s, file is set as KEEP", entry_path);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case AE_IFLNK:
|
case AE_IFLNK:
|
||||||
if(!lm_database_files_add(ctx->db, &pkg->data, entry_path, "")){
|
if(!lm_database_files_add(ctx->db, &pkg->data, "################################", entry_path)){
|
||||||
char *suberr = lm_strerror_dup();
|
char *suberr = lm_strerror_dup();
|
||||||
pdebug(__func__, "failed to add link to the database for %s: %s", pkg->data.name, suberr);
|
pdebug(__func__, "failed to add link to the database for %s: %s", pkg->data.name, suberr);
|
||||||
lm_error_set(LM_ERR_PkgFilesAddFail, entry_path, suberr);
|
lm_error_set(LM_ERR_PkgFilesAddFail, entry_path, suberr);
|
||||||
@ -271,6 +271,8 @@ bool lm_ctx_install(lm_ctx_t *ctx, lm_pkg_t *pkg, bool run_install, lm_ctx_insta
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pdebug(__func__, "updating changes file for %s", pkg->data.name);
|
||||||
|
|
||||||
if(!lm_database_changes_update(ctx->db, &pkg->data, files->changes_file)){
|
if(!lm_database_changes_update(ctx->db, &pkg->data, files->changes_file)){
|
||||||
char *suberr = lm_strerror_dup();
|
char *suberr = lm_strerror_dup();
|
||||||
pdebug(__func__, "failed to update changes file for %s: %s", pkg->data.name, suberr);
|
pdebug(__func__, "failed to update changes file for %s: %s", pkg->data.name, suberr);
|
||||||
@ -284,6 +286,13 @@ bool lm_ctx_install(lm_ctx_t *ctx, lm_pkg_t *pkg, bool run_install, lm_ctx_insta
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pdebug(__func__, "deleting file list for %s", pkg->data.name);
|
||||||
|
|
||||||
|
if(!lm_database_files_del_all(ctx->db, &pkg->data)){
|
||||||
|
pdebug(__func__, "failed to remove file list for %s: %s", pkg->data.name, lm_error());
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
while((line_len = getline(&line, (size_t*)&line_len, hashes)) > 0){
|
while((line_len = getline(&line, (size_t*)&line_len, hashes)) > 0){
|
||||||
if(NULL == line)
|
if(NULL == line)
|
||||||
goto next;
|
goto next;
|
||||||
@ -306,12 +315,7 @@ bool lm_ctx_install(lm_ctx_t *ctx, lm_pkg_t *pkg, bool run_install, lm_ctx_insta
|
|||||||
|
|
||||||
pdebug(__func__, "(%lu) %s => %s", line_len, file, hash);
|
pdebug(__func__, "(%lu) %s => %s", line_len, file, hash);
|
||||||
|
|
||||||
if(!lm_database_files_del_single(ctx->db, file)){
|
if(!lm_database_files_add(ctx->db, &pkg->data, hash, file)){
|
||||||
pdebug(__func__, "failed to remove file from the database for %s: %s", pkg->data.name, lm_error());
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!lm_database_files_add(ctx->db, &pkg->data, file, hash)){
|
|
||||||
char *suberr = lm_strerror_dup();
|
char *suberr = lm_strerror_dup();
|
||||||
pdebug(__func__, "failed to add file to the database for %s: %s", pkg->data.name, suberr);
|
pdebug(__func__, "failed to add file to the database for %s: %s", pkg->data.name, suberr);
|
||||||
lm_error_set(LM_ERR_PkgFilesAddFail, file, suberr);
|
lm_error_set(LM_ERR_PkgFilesAddFail, file, suberr);
|
||||||
@ -325,6 +329,8 @@ bool lm_ctx_install(lm_ctx_t *ctx, lm_pkg_t *pkg, bool run_install, lm_ctx_insta
|
|||||||
line_len = 0;
|
line_len = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pdebug(__func__, "extracting files for %s", pkg->data.name);
|
||||||
|
|
||||||
if(!__lm_ctx_extract_files(ctx, pkg, files->files_archive, callback, data)){
|
if(!__lm_ctx_extract_files(ctx, pkg, files->files_archive, callback, data)){
|
||||||
char *suberr = lm_strerror_dup();
|
char *suberr = lm_strerror_dup();
|
||||||
pdebug(__func__, "failed to extract the files archive for %s: %s", pkg->data.name, suberr);
|
pdebug(__func__, "failed to extract the files archive for %s: %s", pkg->data.name, suberr);
|
||||||
@ -333,6 +339,8 @@ bool lm_ctx_install(lm_ctx_t *ctx, lm_pkg_t *pkg, bool run_install, lm_ctx_insta
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pdebug(__func__, "adding an entry for %s", pkg->data.name);
|
||||||
|
|
||||||
if(!lm_database_entry_add(ctx->db, &pkg->data)){
|
if(!lm_database_entry_add(ctx->db, &pkg->data)){
|
||||||
char *suberr = lm_strerror_dup();
|
char *suberr = lm_strerror_dup();
|
||||||
pdebug(__func__, "failed to add %s to the database: %s", pkg->data.name, lm_strerror());
|
pdebug(__func__, "failed to add %s to the database: %s", pkg->data.name, lm_strerror());
|
||||||
@ -341,6 +349,11 @@ bool lm_ctx_install(lm_ctx_t *ctx, lm_pkg_t *pkg, bool run_install, lm_ctx_insta
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(run_install)
|
||||||
|
pdebug(__func__, "running the install script for %s", pkg->data.name);
|
||||||
|
else
|
||||||
|
pdebug(__func__, "saving the install script for %s", pkg->data.name);
|
||||||
|
|
||||||
if(run_install && !__lm_ctx_run_install(ctx->root, files->install_file)){
|
if(run_install && !__lm_ctx_run_install(ctx->root, files->install_file)){
|
||||||
char *suberr = lm_strerror_dup();
|
char *suberr = lm_strerror_dup();
|
||||||
pdebug(__func__, "failed to run install script: %s", lm_strerror());
|
pdebug(__func__, "failed to run install script: %s", lm_strerror());
|
||||||
|
@ -55,13 +55,16 @@ bool lm_ctx_remove(lm_ctx_t *ctx, lm_entry_t *entry, lm_ctx_remove_callback_t ca
|
|||||||
size_t total = 0, current = 0;
|
size_t total = 0, current = 0;
|
||||||
|
|
||||||
total = lm_database_files_count(ctx->db, entry);
|
total = lm_database_files_count(ctx->db, entry);
|
||||||
|
pdebug(__func__, "removing %lu files", total);
|
||||||
|
|
||||||
while(lm_database_files_next(ctx->db, entry, &path, &hash, &in_keep)){
|
while(lm_database_files_next(ctx->db, entry, &path, &hash, &in_keep)){
|
||||||
if(in_keep)
|
if(in_keep){
|
||||||
|
pdebug(__func__, "not removing file because it is set as keep: %s", path);
|
||||||
goto next;
|
goto next;
|
||||||
|
}
|
||||||
|
|
||||||
fpath = join_alloc(ctx->root, path);
|
fpath = join_alloc(ctx->root, path);
|
||||||
pdebug(__func__, "removing file %s (%s)", fpath, entry->name);
|
pdebug(__func__, "removing file %s (%s)", fpath, hash);
|
||||||
|
|
||||||
if(!exists(fpath, NULL)){
|
if(!exists(fpath, NULL)){
|
||||||
pdebug(__func__, "found file in database, but its not on the file system: %s", fpath);
|
pdebug(__func__, "found file in database, but its not on the file system: %s", fpath);
|
||||||
|
@ -7,14 +7,32 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
bool __lm_ctx_resolve_contains(lm_pkg_t *pkg, lm_ctx_resolve_list_t *list){
|
||||||
|
if(NULL == list->packages)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for(int i = 0; i < list->count; i++){
|
||||||
|
if(eq(list->packages[i]->data.name, pkg->data.name))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool __lm_ctx_resolve(lm_ctx_t *ctx, lm_ctx_resolve_list_t *list, lm_pkg_t *pkg, bool resolve_depends){
|
bool __lm_ctx_resolve(lm_ctx_t *ctx, lm_ctx_resolve_list_t *list, lm_pkg_t *pkg, bool resolve_depends){
|
||||||
if(pkglist_contains(list->packages, pkg))
|
if(__lm_ctx_resolve_contains(pkg, list))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if(!resolve_depends || NULL == pkg->data.depends)
|
if(NULL == list->packages)
|
||||||
goto end;
|
list->packages = malloc(sizeof(lm_pkg_t *)*(++list->count));
|
||||||
|
else
|
||||||
|
list->packages = realloc(list->packages, sizeof(lm_pkg_t *)*(++list->count));
|
||||||
|
|
||||||
|
list->packages[list->count-1] = pkg;
|
||||||
|
|
||||||
|
if(!resolve_depends || NULL == pkg->data.depends)
|
||||||
|
return true;
|
||||||
|
|
||||||
list->resolving = pkglist_add_top(list->resolving, pkg);
|
|
||||||
lm_pkg_t *depend = NULL;
|
lm_pkg_t *depend = NULL;
|
||||||
|
|
||||||
for(int i = 0; pkg->data.depends[i] != NULL; i++){
|
for(int i = 0; pkg->data.depends[i] != NULL; i++){
|
||||||
@ -29,19 +47,10 @@ bool __lm_ctx_resolve(lm_ctx_t *ctx, lm_ctx_resolve_list_t *list, lm_pkg_t *pkg,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pkglist_contains(list->resolving, depend)){
|
|
||||||
lm_error_set(LM_ERR_DependNotFound, pkg->data.depends[i], pkg->data.name);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!__lm_ctx_resolve(ctx, list, depend, resolve_depends))
|
if(!__lm_ctx_resolve(ctx, list, depend, resolve_depends))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
list->resolving = pkglist_del(list->resolving, pkg);
|
|
||||||
end:
|
|
||||||
list->packages = pkglist_add_end(list->packages, pkg);
|
|
||||||
list->count++;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,15 +66,11 @@ lm_ctx_resolve_list_t *lm_ctx_resolve(lm_ctx_t *ctx, lm_pkg_t *pkg, bool resolve
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!__lm_ctx_resolve(ctx, list, pkg, resolve_depends)){
|
if(!__lm_ctx_resolve(ctx, list, pkg, resolve_depends)){
|
||||||
pkglist_free(list->resolving);
|
free(list->packages);
|
||||||
pkglist_free(list->packages);
|
|
||||||
free(list);
|
free(list);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pkglist_free(list->resolving);
|
|
||||||
list->resolving = NULL;
|
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,11 +81,16 @@ lm_pkg_t *lm_ctx_resolve_next(lm_ctx_resolve_list_t *list){
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(NULL == list->cur){
|
if(NULL == list->cur){
|
||||||
list->cur = list->packages;
|
list->index = 0;
|
||||||
|
list->cur = list->packages[list->index++];
|
||||||
return list->cur;
|
return list->cur;
|
||||||
}
|
}
|
||||||
|
|
||||||
list->cur = list->cur->next;
|
if(list->index >= list->count)
|
||||||
|
list->cur = NULL;
|
||||||
|
else
|
||||||
|
list->cur = list->packages[list->index++];
|
||||||
|
|
||||||
return list->cur;
|
return list->cur;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,7 +100,8 @@ void lm_ctx_resolve_free(lm_ctx_resolve_list_t *list){
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pkglist_free(list->packages);
|
free(list->packages);
|
||||||
free(list);
|
free(list);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -29,15 +29,14 @@ void __lm_ctx_serve_thread(void *_arg) {
|
|||||||
lm_mptp_t packet;
|
lm_mptp_t packet;
|
||||||
|
|
||||||
lm_mptp_init(&packet);
|
lm_mptp_init(&packet);
|
||||||
lm_error_clear();
|
|
||||||
|
|
||||||
if(!lm_mptp_server_recv(arg->sock, &packet)){
|
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);
|
return lm_mptp_close(arg->sock);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!lm_mptp_server_verify(&packet)) {
|
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);
|
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;
|
char path[packet.header.path_size + 1], *ppath = path;
|
||||||
|
|
||||||
if (!lm_mptp_get_host(&packet, hostname)) {
|
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;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!lm_mptp_get_path(&packet, path)) {
|
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;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,7 +119,7 @@ void __lm_ctx_serve_thread(void *_arg) {
|
|||||||
|
|
||||||
if(!lm_mptp_get_path(&packet, path)){
|
if(!lm_mptp_get_path(&packet, path)){
|
||||||
// we should never be able to get here, if we do theres definetly a bug
|
// 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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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));
|
list->entries = malloc(sizeof(lm_entry_t*)*(++list->count));
|
||||||
else
|
else
|
||||||
list->entries = realloc(list->entries, sizeof(lm_entry_t*)*(++list->count));
|
list->entries = realloc(list->entries, sizeof(lm_entry_t*)*(++list->count));
|
||||||
|
|
||||||
list->entries[list->count-1] = cur;
|
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);
|
lm_ctx_database_next_free(ctx, NULL);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
@ -63,8 +69,10 @@ void lm_ctx_update_list_free(lm_ctx_update_list_t *list){
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(NULL != list->entries){
|
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]);
|
lm_entry_free(list->entries[i]);
|
||||||
|
free(list->entries[i]);
|
||||||
|
}
|
||||||
free(list->entries);
|
free(list->entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,17 +8,30 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
size_t __lm_database_changes_get(lm_database_t *db, lm_entry_t *entry, char *path){
|
||||||
|
size_t changes_size = strlen(entry->name)+15;
|
||||||
|
size_t full_size = changes_size + strlen(db->dir);
|
||||||
|
|
||||||
|
if(NULL != path){
|
||||||
|
char changes_file[changes_size];
|
||||||
|
snprintf(changes_file, changes_size, "%s_changes", entry->name);
|
||||||
|
join(path, db->dir, changes_file);
|
||||||
|
}
|
||||||
|
|
||||||
|
return full_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define __lm_changes_size() __lm_database_changes_get(db, entry, NULL)
|
||||||
|
#define __lm_changes_path(p) __lm_database_changes_get(db, entry, p)
|
||||||
|
|
||||||
bool lm_database_changes_update(lm_database_t *db, lm_entry_t *entry, char *file){
|
bool lm_database_changes_update(lm_database_t *db, lm_entry_t *entry, char *file){
|
||||||
if(NULL == db || NULL == entry || NULL == file){
|
if(NULL == db || NULL == entry || NULL == file){
|
||||||
lm_error_set(LM_ERR_ArgNULL);
|
lm_error_set(LM_ERR_ArgNULL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
char changes_file[strlen(entry->name)+20];
|
char changes_path[__lm_changes_size()];
|
||||||
sprintf(changes_file, "%s_changes", entry->name);
|
__lm_changes_path(changes_path);
|
||||||
|
|
||||||
char changes_path[strlen(db->dir)+sizeof(changes_file)];
|
|
||||||
join(changes_path, db->dir, changes_file);
|
|
||||||
|
|
||||||
if(!copy_file(changes_path, file))
|
if(!copy_file(changes_path, file))
|
||||||
return false;
|
return false;
|
||||||
@ -37,11 +50,8 @@ bool lm_database_changes_del(lm_database_t *db, lm_entry_t *entry){
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
char changes_file[strlen(entry->name)+20];
|
char changes_path[__lm_changes_size()];
|
||||||
sprintf(changes_file, "%s_changes", entry->name);
|
__lm_changes_path(changes_path);
|
||||||
|
|
||||||
char changes_path[strlen(db->dir)+sizeof(changes_file)];
|
|
||||||
join(changes_path, db->dir, changes_file);
|
|
||||||
|
|
||||||
if(unlink(changes_path) < 0 && errno != ENOENT){
|
if(unlink(changes_path) < 0 && errno != ENOENT){
|
||||||
lm_error_set(LM_ERR_DbChangesUnlinkFail);
|
lm_error_set(LM_ERR_DbChangesUnlinkFail);
|
||||||
@ -52,15 +62,16 @@ bool lm_database_changes_del(lm_database_t *db, lm_entry_t *entry){
|
|||||||
}
|
}
|
||||||
|
|
||||||
char *lm_database_changes_get(lm_database_t *db, lm_entry_t *entry){
|
char *lm_database_changes_get(lm_database_t *db, lm_entry_t *entry){
|
||||||
char changes_file[strlen(entry->name)+20];
|
if(NULL == db || NULL == entry){
|
||||||
sprintf(changes_file, "%s_changes", entry->name);
|
lm_error_set(LM_ERR_ArgNULL);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
char *changes_path = malloc(strlen(db->dir)+sizeof(changes_file));
|
char* changes_path = malloc(__lm_changes_size());
|
||||||
join(changes_path, db->dir, changes_file);
|
__lm_changes_path(changes_path);
|
||||||
|
|
||||||
if(!exists(changes_path, NULL)){
|
if(!exists(changes_path, NULL)){
|
||||||
lm_error_set(LM_ERR_DbChangesNotExists);
|
lm_error_set(LM_ERR_DbChangesNotExists);
|
||||||
free(changes_path);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,34 +31,6 @@ char *queries[] = {
|
|||||||
|
|
||||||
// QUERY_SELECT_PACKAGE_ALL
|
// QUERY_SELECT_PACKAGE_ALL
|
||||||
"SELECT * FROM packages",
|
"SELECT * FROM packages",
|
||||||
|
|
||||||
// QUERY_CREATE_FILE_TABLE
|
|
||||||
"CREATE TABLE IF NOT EXISTS files (" \
|
|
||||||
" path TEXT PRIMARY KEY NOT NULL," \
|
|
||||||
" hash TEXT NOT NULL," \
|
|
||||||
" keep INT NOT NULL," \
|
|
||||||
" package TEXT NOT NULL);",
|
|
||||||
|
|
||||||
// QUERY_INSERT_FILE_SINGLE
|
|
||||||
"INSERT INTO files VALUES (?, ?, ?, ?)",
|
|
||||||
|
|
||||||
// QUERY_DELETE_FILE_ALL
|
|
||||||
"DELETE FROM files WHERE package = ? AND keep = 0",
|
|
||||||
|
|
||||||
// QUERY_DELETE_FILE_SINGLE
|
|
||||||
"DELETE FROM files WHERE path = ?",
|
|
||||||
|
|
||||||
// QUERY_SELECT_FILE_ALL
|
|
||||||
"SELECT * FROM files WHERE package = ?",
|
|
||||||
|
|
||||||
// QUERY_SELECT_FILE_SINGLE
|
|
||||||
"SELECT * FROM files WHERE path = ?",
|
|
||||||
|
|
||||||
// QUERY_UPDATE_FILE_1
|
|
||||||
"UPDATE files SET keep = 1 WHERE path = ?",
|
|
||||||
|
|
||||||
// QUERY_UPDATE_FILE_2
|
|
||||||
"UPDATE files SET keep = 0 WHERE path = ?",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
lm_database_t *lm_database_new(char *path){
|
lm_database_t *lm_database_new(char *path){
|
||||||
@ -77,35 +49,20 @@ lm_database_t *lm_database_new(char *path){
|
|||||||
}
|
}
|
||||||
|
|
||||||
size_t pathlen = strlen(path);
|
size_t pathlen = strlen(path);
|
||||||
char packagesdb[pathlen+20], filesdb[pathlen+20];
|
char packagesdb[pathlen+15];
|
||||||
|
|
||||||
join(packagesdb, path, "packages.db");
|
join(packagesdb, path, "packages.db");
|
||||||
join(filesdb, path, "files.db");
|
|
||||||
|
|
||||||
if(sqlite3_open(packagesdb, &db->entries_db)){
|
if(sqlite3_open(packagesdb, &db->sql)){
|
||||||
pdebug(__func__, "(%s) failed to open databse: %s", packagesdb, sqlite3_errmsg(db->entries_db));
|
pdebug(__func__, "(%s) failed to open databse: %s", packagesdb, sqlite3_errmsg(db->sql));
|
||||||
lm_error_set(LM_ERR_DbSqlOpenFail);
|
lm_error_set(LM_ERR_DbSqlOpenFail);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(sqlite3_open(filesdb, &db->files_db)){
|
if(sqlite3_exec(db->sql, queries[QUERY_CREATE_TABLE], NULL, 0, &err) != SQLITE_OK){
|
||||||
pdebug(__func__, "(%s) failed to open databse: %s", filesdb, sqlite3_errmsg(db->files_db));
|
|
||||||
lm_error_set(LM_ERR_DbSqlOpenFail);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(sqlite3_exec(db->entries_db, queries[QUERY_CREATE_ENTRY_TABLE], NULL, 0, &err) != SQLITE_OK){
|
|
||||||
pdebug(__func__, "(%s) failed to create packages table: %s", packagesdb, err);
|
pdebug(__func__, "(%s) failed to create packages table: %s", packagesdb, err);
|
||||||
lm_error_set(LM_ERR_DbSqlCreateFail);
|
lm_error_set(LM_ERR_DbSqlCreateFail);
|
||||||
sqlite3_free(err);
|
sqlite3_free(err);
|
||||||
db->entries_db = NULL;
|
db->sql = NULL;
|
||||||
}
|
|
||||||
|
|
||||||
if(sqlite3_exec(db->files_db, queries[QUERY_CREATE_FILE_TABLE], NULL, 0, &err) != SQLITE_OK){
|
|
||||||
pdebug(__func__, "(%s) failed to create files table: %s", filesdb, err);
|
|
||||||
lm_error_set(LM_ERR_DbSqlCreateFail);
|
|
||||||
sqlite3_free(err);
|
|
||||||
db->files_db = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
db->dir = strdup(path);
|
db->dir = strdup(path);
|
||||||
@ -113,15 +70,13 @@ lm_database_t *lm_database_new(char *path){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void lm_database_free(lm_database_t *db){
|
void lm_database_free(lm_database_t *db){
|
||||||
if(NULL != db->entries_st)
|
if(NULL != db->st)
|
||||||
sqlite3_finalize(db->entries_st);
|
sqlite3_finalize(db->st);
|
||||||
|
|
||||||
if(NULL != db->files_st)
|
if(NULL != db->filesp)
|
||||||
sqlite3_finalize(db->files_st);
|
fclose(db->filesp);
|
||||||
|
|
||||||
sqlite3_close(db->entries_db);
|
|
||||||
sqlite3_close(db->files_db);
|
|
||||||
|
|
||||||
|
sqlite3_close(db->sql);
|
||||||
free(db->dir);
|
free(db->dir);
|
||||||
free(db);
|
free(db);
|
||||||
}
|
}
|
||||||
|
@ -28,35 +28,35 @@ bool lm_database_entry_add(lm_database_t *db, lm_entry_t *entry){
|
|||||||
char depends[lm_package_data_depend_strlen(entry)];
|
char depends[lm_package_data_depend_strlen(entry)];
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
if(sqlite3_prepare(db->entries_db, queries[QUERY_INSERT_ENTRY_SINGLE], strlen(queries[QUERY_INSERT_ENTRY_SINGLE]), &db->entries_st, NULL) != SQLITE_OK){
|
if(sqlite3_prepare(db->sql, queries[QUERY_INSERT_SINGLE], strlen(queries[QUERY_INSERT_SINGLE]), &db->st, NULL) != SQLITE_OK){
|
||||||
pdebug(__func__, "failed to prepare statement for inserting %s: %s", entry->name, sqlite3_errmsg(db->entries_db));
|
pdebug(__func__, "failed to prepare statement for inserting %s: %s", entry->name, sqlite3_errmsg(db->sql));
|
||||||
lm_error_set(LM_ERR_DbSqlPrepareFail);
|
lm_error_set(LM_ERR_DbSqlPrepareFail);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
sqlite3_bind_text(db->entries_st, ENTRIES_COLUMN_NAME, entry->name, strlen(entry->name), SQLITE_STATIC);
|
sqlite3_bind_text(db->st, COLUMN_NAME, entry->name, strlen(entry->name), SQLITE_STATIC);
|
||||||
sqlite3_bind_text(db->entries_st, ENTRIES_COLUMN_DESC, entry->desc, strlen(entry->desc), SQLITE_STATIC);
|
sqlite3_bind_text(db->st, COLUMN_DESC, entry->desc, strlen(entry->desc), SQLITE_STATIC);
|
||||||
sqlite3_bind_text(db->entries_st, ENTRIES_COLUMN_VERSION, entry->version, strlen(entry->version), SQLITE_STATIC);
|
sqlite3_bind_text(db->st, COLUMN_VERSION, entry->version, strlen(entry->version), SQLITE_STATIC);
|
||||||
sqlite3_bind_int64(db->entries_st, ENTRIES_COLUMN_SIZE, entry->size);
|
sqlite3_bind_int64(db->st, COLUMN_SIZE, entry->size);
|
||||||
|
|
||||||
if(!lm_package_data_depend_tostr(entry, depends)){
|
if(!lm_package_data_depend_tostr(entry, depends)){
|
||||||
pdebug(__func__, "failed to convert depends to string for inserting %s: %s", entry->name, lm_strerror());
|
pdebug(__func__, "failed to convert depends to string for inserting %s: %s", entry->name, lm_strerror());
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
pdebug(__func__, "depend list for %s: %s", entry->name, depends);
|
pdebug(__func__, "depend list for %s: %s", entry->name, depends);
|
||||||
sqlite3_bind_text(db->entries_st, ENTRIES_COLUMN_DEPENDS, depends, strlen(depends), SQLITE_STATIC);
|
sqlite3_bind_text(db->st, COLUMN_DEPENDS, depends, strlen(depends), SQLITE_STATIC);
|
||||||
|
|
||||||
if(!lm_database_step_all(db->entries_st)){
|
if(!lm_database_step_all(db->st)){
|
||||||
pdebug(__func__, "failed to execute insert statement for inserting %s: %s", entry->name, sqlite3_errmsg(db->entries_db));
|
pdebug(__func__, "failed to execute insert statement for inserting %s: %s", entry->name, sqlite3_errmsg(db->sql));
|
||||||
lm_error_set(LM_ERR_DbSqlInsertFail);
|
lm_error_set(LM_ERR_DbSqlInsertFail);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = true;
|
ret = true;
|
||||||
end:
|
end:
|
||||||
if(NULL != db->entries_st){
|
if(NULL != db->st){
|
||||||
sqlite3_finalize(db->entries_st);
|
sqlite3_finalize(db->st);
|
||||||
db->entries_st = NULL;
|
db->st = NULL;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -71,26 +71,26 @@ bool lm_database_entry_find(lm_database_t *db, lm_entry_t *entry, char *name, ch
|
|||||||
char *query = NULL;
|
char *query = NULL;
|
||||||
|
|
||||||
if(NULL == version)
|
if(NULL == version)
|
||||||
query = queries[QUERY_SELECT_ENTRY_SINGLE_1];
|
query = queries[QUERY_SELECT_SINGLE_1];
|
||||||
else
|
else
|
||||||
query = queries[QUERY_SELECT_ENTRY_SINGLE_2];
|
query = queries[QUERY_SELECT_SINGLE_2];
|
||||||
|
|
||||||
// package pointer should already be free'd
|
// package pointer should already be free'd
|
||||||
// we are initing it just in case the caller didn't
|
// we are initing it just in case the caller didn't
|
||||||
if(NULL != entry)
|
if(NULL != entry)
|
||||||
lm_entry_init(entry);
|
lm_entry_init(entry);
|
||||||
|
|
||||||
if(sqlite3_prepare(db->entries_db, query, strlen(query), &db->entries_st, NULL) != SQLITE_OK){
|
if(sqlite3_prepare(db->sql, query, strlen(query), &db->st, NULL) != SQLITE_OK){
|
||||||
pdebug(__func__, "failed to prepare statement for finding %s: %s", name, sqlite3_errmsg(db->entries_db));
|
pdebug(__func__, "failed to prepare statement for finding %s: %s", name, sqlite3_errmsg(db->sql));
|
||||||
lm_error_set(LM_ERR_DbSqlPrepareFail);
|
lm_error_set(LM_ERR_DbSqlPrepareFail);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
sqlite3_bind_text(db->entries_st, ENTRIES_COLUMN_NAME, name, strlen(name), SQLITE_STATIC);
|
sqlite3_bind_text(db->st, COLUMN_NAME, name, strlen(name), SQLITE_STATIC);
|
||||||
if(NULL != version)
|
if(NULL != version)
|
||||||
sqlite3_bind_text(db->entries_st, ENTRIES_COLUMN_VERSION, version, strlen(version), SQLITE_STATIC);
|
sqlite3_bind_text(db->st, COLUMN_VERSION, version, strlen(version), SQLITE_STATIC);
|
||||||
|
|
||||||
if(sqlite3_step(db->entries_st) != SQLITE_ROW){
|
if(sqlite3_step(db->st) != SQLITE_ROW){
|
||||||
pdebug(__func__, "got no rows for %s", name);
|
pdebug(__func__, "got no rows for %s", name);
|
||||||
lm_error_set(LM_ERR_DbSqlNotFound);
|
lm_error_set(LM_ERR_DbSqlNotFound);
|
||||||
goto end;
|
goto end;
|
||||||
@ -101,12 +101,12 @@ bool lm_database_entry_find(lm_database_t *db, lm_entry_t *entry, char *name, ch
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
entry->name = strdup((char*)sqlite3_column_text(db->entries_st, ENTRIES_COLUMN_NAME-1));
|
entry->name = strdup((char*)sqlite3_column_text(db->st, COLUMN_NAME-1));
|
||||||
entry->desc = strdup((char*)sqlite3_column_text(db->entries_st, ENTRIES_COLUMN_DESC-1));
|
entry->desc = strdup((char*)sqlite3_column_text(db->st, COLUMN_DESC-1));
|
||||||
entry->version = strdup((char*)sqlite3_column_text(db->entries_st, ENTRIES_COLUMN_VERSION-1));
|
entry->version = strdup((char*)sqlite3_column_text(db->st, COLUMN_VERSION-1));
|
||||||
entry->size = sqlite3_column_int64(db->entries_st, ENTRIES_COLUMN_SIZE-1);
|
entry->size = sqlite3_column_int64(db->st, COLUMN_SIZE-1);
|
||||||
|
|
||||||
char *depends = (char*)sqlite3_column_text(db->entries_st, ENTRIES_COLUMN_DEPENDS-1);
|
char *depends = (char*)sqlite3_column_text(db->st, COLUMN_DEPENDS-1);
|
||||||
if(!lm_package_data_depend_fromstr(entry, depends)){
|
if(!lm_package_data_depend_fromstr(entry, depends)){
|
||||||
pdebug(__func__, "failed to load depends for finding %s: %s", entry->name, lm_strerror());
|
pdebug(__func__, "failed to load depends for finding %s: %s", entry->name, lm_strerror());
|
||||||
// error is set by the function
|
// error is set by the function
|
||||||
@ -115,9 +115,9 @@ bool lm_database_entry_find(lm_database_t *db, lm_entry_t *entry, char *name, ch
|
|||||||
|
|
||||||
ret = true;
|
ret = true;
|
||||||
end:
|
end:
|
||||||
if(NULL != db->entries_st){
|
if(NULL != db->st){
|
||||||
sqlite3_finalize(db->entries_st);
|
sqlite3_finalize(db->st);
|
||||||
db->entries_st = NULL;
|
db->st = NULL;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -130,25 +130,25 @@ bool lm_database_entry_del(lm_database_t *db, lm_entry_t *entry){
|
|||||||
|
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
if(sqlite3_prepare(db->entries_db, queries[QUERY_DELETE_ENTRY_SINGLE], strlen(queries[QUERY_DELETE_ENTRY_SINGLE]), &db->entries_st, NULL) != SQLITE_OK){
|
if(sqlite3_prepare(db->sql, queries[QUERY_DELETE_SINGLE], strlen(queries[QUERY_DELETE_SINGLE]), &db->st, NULL) != SQLITE_OK){
|
||||||
pdebug(__func__, "failed to prepare statement for deleting %s: %s", entry->name, sqlite3_errmsg(db->entries_db));
|
pdebug(__func__, "failed to prepare statement for deleting %s: %s", entry->name, sqlite3_errmsg(db->sql));
|
||||||
lm_error_set(LM_ERR_DbSqlPrepareFail);
|
lm_error_set(LM_ERR_DbSqlPrepareFail);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
sqlite3_bind_text(db->entries_st, ENTRIES_COLUMN_NAME, entry->name, strlen(entry->name), SQLITE_STATIC);
|
sqlite3_bind_text(db->st, COLUMN_NAME, entry->name, strlen(entry->name), SQLITE_STATIC);
|
||||||
|
|
||||||
if(sqlite3_step(db->entries_st) != SQLITE_DONE){
|
if(sqlite3_step(db->st) != SQLITE_DONE){
|
||||||
pdebug(__func__, "failed to execute delete statement for deleting %s: %s", entry->name, sqlite3_errmsg(db->entries_db));
|
pdebug(__func__, "failed to execute delete statement for deleting %s: %s", entry->name, sqlite3_errmsg(db->sql));
|
||||||
lm_error_set(LM_ERR_DbSqlDeleteFail);
|
lm_error_set(LM_ERR_DbSqlDeleteFail);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = true;
|
ret = true;
|
||||||
end:
|
end:
|
||||||
if(NULL != db->entries_st){
|
if(NULL != db->st){
|
||||||
sqlite3_finalize(db->entries_st);
|
sqlite3_finalize(db->st);
|
||||||
db->entries_st = NULL;
|
db->st = NULL;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -159,33 +159,33 @@ bool lm_database_entry_next(lm_database_t *db, lm_entry_t *entry){
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(NULL != db->entries_st)
|
if(NULL != db->st)
|
||||||
lm_entry_free(entry);
|
lm_entry_free(entry);
|
||||||
|
|
||||||
else if(NULL == db->entries_st &&
|
else if(NULL == db->st &&
|
||||||
sqlite3_prepare(db->entries_db, queries[QUERY_SELECT_ENTRY_ALL], strlen(queries[QUERY_SELECT_ENTRY_ALL]), &db->entries_st, NULL) != SQLITE_OK){
|
sqlite3_prepare(db->sql, queries[QUERY_SELECT_ALL], strlen(queries[QUERY_SELECT_ALL]), &db->st, NULL) != SQLITE_OK){
|
||||||
pdebug(__func__, "failed to prepare statement for selecting all: %s", sqlite3_errmsg(db->entries_db));
|
pdebug(__func__, "failed to prepare statement for selecting all: %s", sqlite3_errmsg(db->sql));
|
||||||
lm_error_set(LM_ERR_DbSqlPrepareFail);
|
lm_error_set(LM_ERR_DbSqlPrepareFail);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
lm_entry_init(entry);
|
lm_entry_init(entry);
|
||||||
|
|
||||||
if(sqlite3_step(db->entries_st) != SQLITE_ROW){
|
if(sqlite3_step(db->st) != SQLITE_ROW){
|
||||||
sqlite3_finalize(db->entries_st);
|
sqlite3_finalize(db->st);
|
||||||
db->entries_st = NULL;
|
db->st = NULL;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
entry->name = strdup((char*)sqlite3_column_text(db->entries_st, ENTRIES_COLUMN_NAME-1));
|
entry->name = strdup((char*)sqlite3_column_text(db->st, COLUMN_NAME-1));
|
||||||
entry->desc = strdup((char*)sqlite3_column_text(db->entries_st, ENTRIES_COLUMN_DESC-1));
|
entry->desc = strdup((char*)sqlite3_column_text(db->st, COLUMN_DESC-1));
|
||||||
entry->version = strdup((char*)sqlite3_column_text(db->entries_st, ENTRIES_COLUMN_VERSION-1));
|
entry->version = strdup((char*)sqlite3_column_text(db->st, COLUMN_VERSION-1));
|
||||||
entry->size = sqlite3_column_int64(db->entries_st, ENTRIES_COLUMN_SIZE-1);
|
entry->size = sqlite3_column_int64(db->st, COLUMN_SIZE-1);
|
||||||
|
|
||||||
char *depends = (char*)sqlite3_column_text(db->entries_st, ENTRIES_COLUMN_DEPENDS-1);
|
char *depends = (char*)sqlite3_column_text(db->st, COLUMN_DEPENDS-1);
|
||||||
if(!lm_package_data_depend_fromstr(entry, depends)){
|
if(!lm_package_data_depend_fromstr(entry, depends)){
|
||||||
pdebug(__func__, "failed to load depends for finding %s: %s", entry->name, lm_strerror());
|
pdebug(__func__, "failed to load depends for finding %s: %s", entry->name, lm_strerror());
|
||||||
sqlite3_finalize(db->entries_st);
|
sqlite3_finalize(db->st);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,9 +198,9 @@ void lm_database_entry_next_free(lm_database_t *db, lm_entry_t *entry){
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(NULL != db->entries_st){
|
if(NULL != db->st){
|
||||||
sqlite3_finalize(db->entries_st);
|
sqlite3_finalize(db->st);
|
||||||
db->entries_st = NULL;
|
db->st = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(NULL != entry)
|
if(NULL != entry)
|
||||||
|
@ -4,238 +4,316 @@
|
|||||||
#include "../../include/util.h"
|
#include "../../include/util.h"
|
||||||
|
|
||||||
#include <sqlite3.h>
|
#include <sqlite3.h>
|
||||||
#include <stdio.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <dirent.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
ssize_t lm_database_files_count(lm_database_t *db, lm_entry_t *entry){
|
#define LINE_MIN 36 // keep (1) + colon (1) + MD5 hash (32) + colon (1) + path (min 1)
|
||||||
ssize_t count = 0;
|
#define KEEP_INDEX 0
|
||||||
|
#define HASH_INDEX 2
|
||||||
|
#define PATH_INDEX 35
|
||||||
|
|
||||||
if(NULL == db || NULL == entry){
|
size_t __lm_database_files_get(lm_database_t *db, lm_entry_t *entry, char *path){
|
||||||
lm_error_set(LM_ERR_ArgNULL);
|
size_t name_size = strlen(entry->name)+20;
|
||||||
goto end;
|
size_t full_size = name_size + strlen(db->dir);
|
||||||
|
|
||||||
|
if(NULL != path){
|
||||||
|
char files_name[name_size];
|
||||||
|
snprintf(files_name, name_size, "%s_files", entry->name);
|
||||||
|
join(path, db->dir, files_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(sqlite3_prepare(db->files_db, queries[QUERY_SELECT_FILE_ALL], strlen(queries[QUERY_SELECT_FILE_ALL]), &db->files_st, NULL) != SQLITE_OK){
|
return full_size;
|
||||||
pdebug(__func__, "failed to prepare statement for selecting all: %s", sqlite3_errmsg(db->files_db));
|
}
|
||||||
lm_error_set(LM_ERR_DbSqlPrepareFail);
|
|
||||||
|
#define __lm_files_size() __lm_database_files_get(db, entry, NULL)
|
||||||
|
#define __lm_files_path(p) __lm_database_files_get(db, entry, p)
|
||||||
|
|
||||||
|
FILE *__lm_database_files_open(lm_database_t *db, lm_entry_t *entry, char *perms){
|
||||||
|
if(NULL == db || NULL == entry){
|
||||||
|
lm_error_set(LM_ERR_ArgNULL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
sqlite3_bind_text(db->files_st, 1, entry->name, strlen(entry->name), SQLITE_STATIC);
|
char files_path[__lm_files_size()];
|
||||||
|
FILE *filesp = NULL;
|
||||||
|
|
||||||
while(sqlite3_step(db->files_st) == SQLITE_ROW)
|
__lm_files_path(files_path);
|
||||||
count++;
|
|
||||||
end:
|
if(!exists(files_path, NULL)){
|
||||||
if(NULL != db->files_st){
|
lm_error_set(LM_ERR_DbFilesNotFound);
|
||||||
sqlite3_finalize(db->files_st);
|
return NULL;
|
||||||
db->files_st = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(NULL == (filesp = fopen(files_path, perms))){
|
||||||
|
lm_error_set(LM_ERR_DbFilesOpenFail, files_path);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return filesp;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *__lm_database_files_line_single(FILE *filesp, char *path) {
|
||||||
|
ssize_t line_len = 0;
|
||||||
|
char *line = NULL;
|
||||||
|
|
||||||
|
while ((line_len = getline(&line, (size_t*)&line_len, filesp)) >= LINE_MIN) {
|
||||||
|
// keep : hash : path
|
||||||
|
// 1 : 32 : ?
|
||||||
|
|
||||||
|
// ignore empty line
|
||||||
|
if(line[0] == 0)
|
||||||
|
goto next;
|
||||||
|
|
||||||
|
// remove newline
|
||||||
|
else if (line[line_len-1] == '\n')
|
||||||
|
line[line_len-1] = 0;
|
||||||
|
|
||||||
|
if(eq((line + PATH_INDEX), path))
|
||||||
|
return line;
|
||||||
|
|
||||||
|
next:
|
||||||
|
free(line);
|
||||||
|
line = NULL;
|
||||||
|
line_len = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return line;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *__lm_database_files_line_all(lm_database_t *db, char *path) {
|
||||||
|
size_t dirlen = strlen(db->dir);
|
||||||
|
struct dirent *ent = NULL;
|
||||||
|
FILE* filesp = NULL;
|
||||||
|
DIR *ddir = NULL;
|
||||||
|
char *ret = NULL;
|
||||||
|
|
||||||
|
if(NULL == (ddir = opendir(db->dir))){
|
||||||
|
lm_error_set(LM_ERR_DbFilesDirFail, db->dir);
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
while(NULL != (ent = readdir(ddir))){
|
||||||
|
size_t entlen = strlen(ent->d_name);
|
||||||
|
char entpath[entlen+dirlen+10];
|
||||||
|
|
||||||
|
join(entpath, db->dir, ent->d_name);
|
||||||
|
|
||||||
|
if(NULL == (filesp = fopen(entpath, "r"))){
|
||||||
|
lm_error_set(LM_ERR_DbFilesOpenFail, entpath);
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(NULL == (ret = __lm_database_files_line_single(filesp, path)))
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
end:
|
||||||
|
if(NULL != ddir)
|
||||||
|
closedir(ddir);
|
||||||
|
|
||||||
|
if(NULL != filesp)
|
||||||
|
fclose(filesp);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
ssize_t lm_database_files_count(lm_database_t *db, lm_entry_t *entry){
|
||||||
|
if(NULL == db || NULL == entry){
|
||||||
|
lm_error_set(LM_ERR_ArgNULL);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
FILE *filesp = NULL;
|
||||||
|
ssize_t count = 0;
|
||||||
|
char c = 0;
|
||||||
|
|
||||||
|
if((filesp = __lm_database_files_open(db, entry, "r")) == NULL)
|
||||||
|
return 0; // error set by function
|
||||||
|
|
||||||
|
while((c = fgetc(filesp)) != EOF)
|
||||||
|
if(c == '\n')
|
||||||
|
count ++;
|
||||||
|
|
||||||
|
fclose(filesp);
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool lm_database_files_contains(lm_database_t *db, lm_entry_t *entry, char *path){
|
bool lm_database_files_contains(lm_database_t *db, lm_entry_t *entry, char *path){
|
||||||
char *package = NULL;
|
if(NULL == db || NULL == entry || NULL == path){
|
||||||
|
lm_error_set(LM_ERR_ArgNULL);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
FILE *filesp = NULL;
|
||||||
|
char *line = NULL;
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
if(NULL == db || NULL == path){
|
if((filesp = __lm_database_files_open(db, entry, "r")) == NULL)
|
||||||
lm_error_set(LM_ERR_ArgNULL);
|
return false; // error set by function
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(sqlite3_prepare(db->files_db, queries[QUERY_SELECT_FILE_SINGLE], strlen(queries[QUERY_SELECT_FILE_SINGLE]), &db->files_st, NULL) != SQLITE_OK){
|
if((line = __lm_database_files_line_single(filesp, path)) != NULL)
|
||||||
pdebug(__func__, "failed to prepare statement for selecting %s: %s", path, sqlite3_errmsg(db->files_db));
|
ret = true;
|
||||||
lm_error_set(LM_ERR_DbSqlPrepareFail);
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
sqlite3_bind_text(db->files_st, FILES_COLUMN_PATH, path, strlen(path), SQLITE_STATIC);
|
free(line);
|
||||||
|
|
||||||
if(sqlite3_step(db->files_st) != SQLITE_ROW){
|
if(NULL != filesp)
|
||||||
pdebug(__func__, "failed to execute select statement for selecting %s: %s", path, sqlite3_errmsg(db->files_db));
|
fclose(filesp);
|
||||||
lm_error_set(LM_ERR_DbSqlSelectFail);
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
package = (char*)sqlite3_column_text(db->files_st, FILES_COLUMN_ENTRY-1);
|
|
||||||
ret = eq(package, entry->name);
|
|
||||||
end:
|
|
||||||
if(NULL != db->files_st){
|
|
||||||
sqlite3_finalize(db->files_st);
|
|
||||||
db->files_st = NULL;
|
|
||||||
}
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool lm_database_files_matches(lm_database_t *db, char *path, char *hash){
|
bool lm_database_files_matches(lm_database_t *db, char *path, char *hash){
|
||||||
char *hashdb = NULL;
|
|
||||||
bool ret = false;
|
|
||||||
|
|
||||||
if(NULL == db || NULL == path || NULL == hash){
|
if(NULL == db || NULL == path || NULL == hash){
|
||||||
lm_error_set(LM_ERR_ArgNULL);
|
lm_error_set(LM_ERR_ArgNULL);
|
||||||
goto end;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(sqlite3_prepare(db->files_db, queries[QUERY_SELECT_FILE_SINGLE], strlen(queries[QUERY_SELECT_FILE_SINGLE]), &db->files_st, NULL) != SQLITE_OK){
|
char *line = NULL, *line_hash = NULL;
|
||||||
pdebug(__func__, "failed to prepare statement for selecting %s: %s", path, sqlite3_errmsg(db->files_db));
|
bool ret = false;
|
||||||
lm_error_set(LM_ERR_DbSqlPrepareFail);
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
sqlite3_bind_text(db->files_st, 1, path, strlen(path), SQLITE_STATIC);
|
if(NULL == (line = __lm_database_files_line_all(db, path)))
|
||||||
|
return false;
|
||||||
|
|
||||||
if(sqlite3_step(db->files_st) != SQLITE_ROW){
|
line_hash = line+2;
|
||||||
pdebug(__func__, "failed to execute select statement for selecting %s: %s", path, sqlite3_errmsg(db->files_db));
|
line[35] = 0;
|
||||||
lm_error_set(LM_ERR_DbSqlSelectFail);
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
hashdb = (char*)sqlite3_column_text(db->files_st, FILES_COLUMN_HASH-1);
|
if(eq(line_hash, hash))
|
||||||
ret = eq(hashdb, hash);
|
ret = true;
|
||||||
|
|
||||||
end:
|
free(line);
|
||||||
if(NULL != db->files_st){
|
|
||||||
sqlite3_finalize(db->files_st);
|
|
||||||
db->files_st = NULL;
|
|
||||||
}
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool lm_database_files_iskeep(lm_database_t *db, char *path){
|
bool lm_database_files_iskeep(lm_database_t *db, char *path){
|
||||||
bool ret = false;
|
|
||||||
int iskeep = 0;
|
|
||||||
|
|
||||||
if(NULL == db || NULL == path){
|
if(NULL == db || NULL == path){
|
||||||
lm_error_set(LM_ERR_ArgNULL);
|
lm_error_set(LM_ERR_ArgNULL);
|
||||||
goto end;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(sqlite3_prepare(db->files_db, queries[QUERY_SELECT_FILE_SINGLE], strlen(queries[QUERY_SELECT_FILE_SINGLE]), &db->files_st, NULL) != SQLITE_OK){
|
char *line = NULL;
|
||||||
pdebug(__func__, "failed to prepare statement for selecting %s: %s", path, sqlite3_errmsg(db->files_db));
|
|
||||||
lm_error_set(LM_ERR_DbSqlPrepareFail);
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
sqlite3_bind_text(db->files_st, 1, path, strlen(path), SQLITE_STATIC);
|
|
||||||
|
|
||||||
if(!lm_database_step_all(db->files_st)){
|
|
||||||
pdebug(__func__, "failed to execute select statement for selecting %s: %s", path, sqlite3_errmsg(db->files_db));
|
|
||||||
lm_error_set(LM_ERR_DbSqlSelectFail);
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
iskeep = sqlite3_column_int64(db->files_st, FILES_COLUMN_KEEP-1);
|
|
||||||
ret = iskeep == 1;
|
|
||||||
|
|
||||||
end:
|
|
||||||
if(NULL != db->files_st){
|
|
||||||
sqlite3_finalize(db->files_st);
|
|
||||||
db->files_st = NULL;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
bool lm_database_files_add(lm_database_t *db, lm_entry_t *entry, char *path, char *hash){
|
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
if(NULL == db || NULL == entry || NULL == path || NULL == hash){
|
if(NULL == (line = __lm_database_files_line_all(db, path)))
|
||||||
lm_error_set(LM_ERR_ArgNULL);
|
return false;
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(sqlite3_prepare(db->files_db, queries[QUERY_INSERT_FILE_SINGLE], strlen(queries[QUERY_INSERT_FILE_SINGLE]), &db->files_st, NULL) != SQLITE_OK){
|
|
||||||
pdebug(__func__, "failed to prepare statement for inserting %s: %s", path, sqlite3_errmsg(db->files_db));
|
|
||||||
lm_error_set(LM_ERR_DbSqlPrepareFail);
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
sqlite3_bind_text(db->files_st, FILES_COLUMN_PATH, path, strlen(path), SQLITE_STATIC);
|
|
||||||
sqlite3_bind_text(db->files_st, FILES_COLUMN_HASH, hash, strlen(hash), SQLITE_STATIC);
|
|
||||||
if(lm_package_data_keep_contains(entry, path))
|
|
||||||
sqlite3_bind_int(db->files_st, FILES_COLUMN_KEEP, 1);
|
|
||||||
else
|
|
||||||
sqlite3_bind_int(db->files_st, FILES_COLUMN_KEEP, 0);
|
|
||||||
sqlite3_bind_text(db->files_st, FILES_COLUMN_ENTRY, entry->name, strlen(entry->name), SQLITE_STATIC);
|
|
||||||
|
|
||||||
if(!lm_database_step_all(db->files_st)){
|
|
||||||
pdebug(__func__, "failed to execute insert statement for inserting %s: %s", entry->name, sqlite3_errmsg(db->files_db));
|
|
||||||
lm_error_set(LM_ERR_DbSqlInsertFail);
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if(line[0] == '1')
|
||||||
ret = true;
|
ret = true;
|
||||||
end:
|
|
||||||
if(NULL != db->files_st){
|
free(line);
|
||||||
sqlite3_finalize(db->files_st);
|
|
||||||
db->files_st = NULL;
|
|
||||||
}
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool lm_database_files_add(lm_database_t *db, lm_entry_t *entry, char *hash, char *path){
|
||||||
|
if(NULL == db || NULL == entry || NULL == hash || NULL == path){
|
||||||
|
lm_error_set(LM_ERR_ArgNULL);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
char files_path[__lm_files_size()];
|
||||||
|
FILE *filesp = NULL;
|
||||||
|
|
||||||
|
__lm_files_path(files_path);
|
||||||
|
|
||||||
|
if(NULL == (filesp = fopen(files_path, "a"))){
|
||||||
|
lm_error_set(LM_ERR_DbFilesOpenFail, files_path);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
fwrite(lm_package_data_keep_contains(entry, path) ? "1:" : "0:", 1, 2, filesp);
|
||||||
|
fwrite(hash, 1, strlen(hash), filesp);
|
||||||
|
fwrite(":", 1, 1, filesp);
|
||||||
|
fwrite(path, 1, strlen(path), filesp);
|
||||||
|
fwrite("\n", 1, 1, filesp);
|
||||||
|
|
||||||
|
fclose(filesp);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool lm_database_files_del(lm_database_t *db, lm_entry_t *entry){
|
bool lm_database_files_del(lm_database_t *db, lm_entry_t *entry){
|
||||||
if(NULL == db || NULL == entry){
|
if(NULL == db || NULL == entry){
|
||||||
lm_error_set(LM_ERR_ArgNULL);
|
lm_error_set(LM_ERR_ArgNULL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ret = false;
|
FILE *original = NULL, *temp = NULL;
|
||||||
|
char temp_name[strlen(entry->name)+15];
|
||||||
|
char temp_path[__lm_files_size()+10];
|
||||||
|
char real_path[__lm_files_size()], *line = NULL;
|
||||||
|
bool ret = false, empty = true;
|
||||||
|
ssize_t line_len = 0;
|
||||||
|
|
||||||
if(sqlite3_prepare(db->files_db, queries[QUERY_DELETE_FILE_ALL], strlen(queries[QUERY_DELETE_FILE_ALL]), &db->files_st, NULL) != SQLITE_OK){
|
__lm_files_path(real_path);
|
||||||
pdebug(__func__, "failed to prepare statement for deleting %s: %s", entry->name, sqlite3_errmsg(db->files_db));
|
sprintf(temp_name, "%s_files.temp", entry->name);
|
||||||
lm_error_set(LM_ERR_DbSqlPrepareFail);
|
join(temp_path, db->dir, temp_name);
|
||||||
|
|
||||||
|
if(NULL == (original = fopen(real_path, "r"))){
|
||||||
|
lm_error_set(LM_ERR_DbFilesOpenFail, real_path);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
sqlite3_bind_text(db->files_st, 1, entry->name, strlen(entry->name), SQLITE_STATIC);
|
if(NULL == (temp = fopen(temp_path, "a"))){
|
||||||
|
lm_error_set(LM_ERR_DbFilesOpenFail, temp_path);
|
||||||
if(!lm_database_step_all(db->files_st)){
|
|
||||||
pdebug(__func__, "failed to execute delete statement for deleting %s: %s", entry->name, sqlite3_errmsg(db->files_db));
|
|
||||||
lm_error_set(LM_ERR_DbSqlDeleteFail);
|
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while ((line_len = getline(&line, (size_t*)&line_len, original)) >= LINE_MIN){
|
||||||
|
if(line[0] == '1'){
|
||||||
|
fwrite(line, 1, line_len, temp);
|
||||||
|
empty = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
free(line);
|
||||||
|
line = NULL;
|
||||||
|
line_len = 0;
|
||||||
|
}
|
||||||
|
|
||||||
ret = true;
|
ret = true;
|
||||||
end:
|
end:
|
||||||
if(NULL != db->files_st){
|
if(NULL != original)
|
||||||
sqlite3_finalize(db->files_st);
|
fclose(original);
|
||||||
db->files_st = NULL;
|
|
||||||
|
if(NULL != temp)
|
||||||
|
fclose(temp);
|
||||||
|
|
||||||
|
free(line);
|
||||||
|
|
||||||
|
if(ret && unlink(real_path) != 0){
|
||||||
|
lm_error_set(LM_ERR_DbFilesUnlinkFail, real_path);
|
||||||
|
ret = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(empty || !ret){
|
||||||
|
unlink(temp_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if(ret && rename(temp_path, real_path) != 0){
|
||||||
|
lm_error_set(LM_ERR_DbFilesRenameFail, real_path);
|
||||||
|
ret = false;
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool lm_database_files_del_single(lm_database_t *db, char *path){
|
bool lm_database_files_del_all(lm_database_t *db, lm_entry_t *entry){
|
||||||
if(NULL == db || NULL == path){
|
if(NULL == db || NULL == entry){
|
||||||
lm_error_set(LM_ERR_ArgNULL);
|
lm_error_set(LM_ERR_ArgNULL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ret = false;
|
char files_path[__lm_files_size()];
|
||||||
|
__lm_files_path(files_path);
|
||||||
|
|
||||||
if(sqlite3_prepare(db->files_db, queries[QUERY_DELETE_FILE_SINGLE], strlen(queries[QUERY_DELETE_FILE_SINGLE]), &db->files_st, NULL) != SQLITE_OK){
|
if(exists(files_path, NULL) && unlink(files_path) != 0){
|
||||||
pdebug(__func__, "failed to prepare statement for deleting %s: %s", path, sqlite3_errmsg(db->files_db));
|
lm_error_set(LM_ERR_DbFilesUnlinkFail, files_path);
|
||||||
lm_error_set(LM_ERR_DbSqlPrepareFail);
|
return false;
|
||||||
goto end;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sqlite3_bind_text(db->files_st, 1, path, strlen(path), SQLITE_STATIC);
|
return true;
|
||||||
|
|
||||||
if(!lm_database_step_all(db->files_st)){
|
|
||||||
pdebug(__func__, "failed to execute delete statement for deleting %s: %s", path, sqlite3_errmsg(db->files_db));
|
|
||||||
lm_error_set(LM_ERR_DbSqlDeleteFail);
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = true;
|
|
||||||
end:
|
|
||||||
if(NULL != db->files_st){
|
|
||||||
sqlite3_finalize(db->files_st);
|
|
||||||
db->files_st = NULL;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool lm_database_files_next(lm_database_t *db, lm_entry_t *entry, char **path, char **hash, bool *keep){
|
bool lm_database_files_next(lm_database_t *db, lm_entry_t *entry, char **path, char **hash, bool *keep){
|
||||||
@ -244,51 +322,54 @@ bool lm_database_files_next(lm_database_t *db, lm_entry_t *entry, char **path, c
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(NULL == db->files_st){
|
if(NULL == db->filesp && NULL == (db->filesp = __lm_database_files_open(db, entry, "r")))
|
||||||
if(sqlite3_prepare(db->files_db, queries[QUERY_SELECT_FILE_ALL], strlen(queries[QUERY_SELECT_FILE_ALL]), &db->files_st, NULL) != SQLITE_OK){
|
return false; // error set by function
|
||||||
pdebug(__func__, "failed to prepare statement for selecting all: %s", sqlite3_errmsg(db->files_db));
|
|
||||||
lm_error_set(LM_ERR_DbSqlPrepareFail);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
sqlite3_bind_text(db->files_st, 1, entry->name, strlen(entry->name), SQLITE_STATIC);
|
|
||||||
}
|
|
||||||
|
|
||||||
else if(NULL != db->files_st){
|
ssize_t line_len = 0;
|
||||||
free(*path);
|
char *line = NULL;
|
||||||
free(*hash);
|
|
||||||
|
if(NULL != *hash)
|
||||||
|
free(*hash-HASH_INDEX);
|
||||||
|
|
||||||
|
if((line_len = getline(&line, (size_t*)&line_len, db->filesp)) <= LINE_MIN)
|
||||||
|
goto eof;
|
||||||
|
|
||||||
|
if(line[line_len-1] == '\n')
|
||||||
|
line[line_len-1] = 0; // replace newline with null terminator
|
||||||
|
line[PATH_INDEX-1] = 0; // replace colon with null terminator
|
||||||
|
|
||||||
|
*keep = line[0] == '1';
|
||||||
|
*hash = line + HASH_INDEX;
|
||||||
|
*path = line + PATH_INDEX;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
eof:
|
||||||
|
fclose(db->filesp);
|
||||||
|
free(line);
|
||||||
|
|
||||||
|
db->filesp = NULL;
|
||||||
|
*keep = false;
|
||||||
*path = NULL;
|
*path = NULL;
|
||||||
*hash = NULL;
|
*hash = NULL;
|
||||||
*keep = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(sqlite3_step(db->files_st) != SQLITE_ROW){
|
|
||||||
sqlite3_finalize(db->files_st);
|
|
||||||
db->files_st = NULL;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
*path = strdup((char*)sqlite3_column_text(db->files_st, FILES_COLUMN_PATH-1));
|
|
||||||
*hash = strdup((char*)sqlite3_column_text(db->files_st, FILES_COLUMN_HASH-1));
|
|
||||||
*keep = sqlite3_column_int(db->files_st, FILES_COLUMN_KEEP-1) == 1;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void lm_database_files_next_free(lm_database_t *db, lm_entry_t *entry, char **path, char **hash, bool *keep){
|
void lm_database_files_next_free(lm_database_t *db, lm_entry_t *entry, char **path, char **hash, bool *keep){
|
||||||
if(NULL == db || NULL == entry || NULL == path || NULL == hash || NULL == keep){
|
if(NULL == db || NULL == entry || NULL == path || NULL == hash || NULL == keep){
|
||||||
lm_error_set(LM_ERR_ArgNULL);
|
lm_error_set(LM_ERR_ArgNULL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(NULL != db->files_st){
|
if(NULL != db->filesp)
|
||||||
sqlite3_finalize(db->files_st);
|
fclose(db->filesp);
|
||||||
db->files_st = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(NULL != path)
|
if(NULL != *hash)
|
||||||
free(*path);
|
free(*hash-HASH_INDEX);
|
||||||
|
|
||||||
if(NULL != hash)
|
|
||||||
free(*hash);
|
|
||||||
|
|
||||||
|
db->filesp = NULL;
|
||||||
*keep = false;
|
*keep = false;
|
||||||
|
*path = NULL;
|
||||||
|
*hash = NULL;
|
||||||
}
|
}
|
||||||
|
30
src/error.c
30
src/error.c
@ -1,12 +1,14 @@
|
|||||||
#include "../include/error.h"
|
#include "../include/error.h"
|
||||||
#include "../include/util.h"
|
#include "../include/util.h"
|
||||||
|
|
||||||
|
#include <pthread.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
lm_error_t lm_error_code = LM_ERR_NoError;
|
lm_error_t lm_error_code = LM_ERR_NoError; // error code
|
||||||
char *lm_error_str = NULL;
|
char *lm_error_str = NULL; // error string
|
||||||
|
pthread_t lm_error_thread = 0; // thread that is using the error system
|
||||||
|
|
||||||
void lm_error_clear() {
|
void lm_error_clear() {
|
||||||
free(lm_error_str);
|
free(lm_error_str);
|
||||||
@ -14,7 +16,17 @@ void lm_error_clear() {
|
|||||||
lm_error_str = NULL;
|
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, ...) {
|
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[] = {
|
lm_error_desc_t errors[] = {
|
||||||
{.code = LM_ERR_NoError, .desc = _("no error") },
|
{.code = LM_ERR_NoError, .desc = _("no error") },
|
||||||
{.code = LM_ERR_URLBadChar, .desc = _("URL contains an invalid character") },
|
{.code = LM_ERR_URLBadChar, .desc = _("URL contains an invalid character") },
|
||||||
@ -97,11 +109,11 @@ void lm_error_set(lm_error_t code, ...) {
|
|||||||
{.code = LM_ERR_PoolUrlEmpty, .desc = _("pool URL is empty or invalid") },
|
{.code = LM_ERR_PoolUrlEmpty, .desc = _("pool URL is empty or invalid") },
|
||||||
{.code = LM_ERR_PoolBadDir, .desc = _("pool directory path is not accessible") },
|
{.code = LM_ERR_PoolBadDir, .desc = _("pool directory path is not accessible") },
|
||||||
{.code = LM_ERR_PoolBadPaths, .desc = _("pool directory sub-paths are not accessible") },
|
{.code = LM_ERR_PoolBadPaths, .desc = _("pool directory sub-paths are not accessible") },
|
||||||
{.code = LM_ERR_DbFilesNotFound, .desc = _("package file list not found in the database") },
|
{.code = LM_ERR_DbFilesNotFound, .desc = _("file list not found for the package") },
|
||||||
{.code = LM_ERR_DbFilesOpenFail, .desc = _("failed to open package file list in the database") },
|
{.code = LM_ERR_DbFilesRenameFail, .desc = _("failed to rename the file list for the package: %s") },
|
||||||
{.code = LM_ERR_DbFilesDirFail, .desc = _("failed to access package file list database directory") },
|
{.code = LM_ERR_DbFilesOpenFail, .desc = _("failed to open the package file list: %s") },
|
||||||
{.code = LM_ERR_DbFilesUnlinkFail, .desc = _("failed to remove package file list from the database") },
|
{.code = LM_ERR_DbFilesDirFail, .desc = _("failed to open the database directory: %s") },
|
||||||
{.code = LM_ERR_DbFilesWriteFail, .desc = _("failed to write to the file list in the database") },
|
{.code = LM_ERR_DbFilesUnlinkFail, .desc = _("failed to remove package file list: %s") },
|
||||||
{.code = LM_ERR_DbKeepsNotFound, .desc = _("package keep list not found in the database") },
|
{.code = LM_ERR_DbKeepsNotFound, .desc = _("package keep list not found in the database") },
|
||||||
{.code = LM_ERR_DbKeepsOpenFail, .desc = _("failed to open package keep list in the database") },
|
{.code = LM_ERR_DbKeepsOpenFail, .desc = _("failed to open package keep list in the database") },
|
||||||
{.code = LM_ERR_DbKeepsDirFail, .desc = _("failed to access package keep list database directory") },
|
{.code = LM_ERR_DbKeepsDirFail, .desc = _("failed to access package keep list database directory") },
|
||||||
@ -203,9 +215,13 @@ void lm_error_set(lm_error_t code, ...) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
char *lm_strerror() {
|
char *lm_strerror() {
|
||||||
|
if (!pthread_equal(pthread_self(), lm_error_thread))
|
||||||
|
return NULL;
|
||||||
return lm_error_str;
|
return lm_error_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
lm_error_t lm_error() {
|
lm_error_t lm_error() {
|
||||||
|
if (!pthread_equal(pthread_self(), lm_error_thread))
|
||||||
|
return LM_ERR_UnknownThread;
|
||||||
return lm_error_code;
|
return lm_error_code;
|
||||||
}
|
}
|
||||||
|
75
src/util.c
75
src/util.c
@ -354,81 +354,6 @@ char *join_alloc(const char *base, const char *pth) {
|
|||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pkglist_contains(lm_pkg_t *list, lm_pkg_t *pkg) {
|
|
||||||
lm_pkg_t *cur = list;
|
|
||||||
while (cur) {
|
|
||||||
if (eq(pkg->data.name, cur->data.name))
|
|
||||||
return true;
|
|
||||||
cur = cur->next;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
lm_pkg_t *pkglist_del(lm_pkg_t *list, lm_pkg_t *pkg) {
|
|
||||||
if (NULL == pkg) {
|
|
||||||
lm_error_set(LM_ERR_ArgNULL);
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NULL == list)
|
|
||||||
return list;
|
|
||||||
|
|
||||||
if (eq(list->data.name, pkg->data.name)) {
|
|
||||||
list = NULL;
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
lm_pkg_t *cur = list;
|
|
||||||
lm_pkg_t *found = NULL;
|
|
||||||
|
|
||||||
while (NULL != cur->next) {
|
|
||||||
if (eq(cur->next->data.name, pkg->data.name)) {
|
|
||||||
found = cur->next;
|
|
||||||
cur->next = cur->next->next;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
cur = cur->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
free(found);
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
lm_pkg_t *pkglist_add_top(lm_pkg_t *list, lm_pkg_t *pkg) {
|
|
||||||
lm_pkg_t *new = malloc(sizeof(lm_pkg_t));
|
|
||||||
memcpy(new, pkg, sizeof(lm_pkg_t));
|
|
||||||
new->next = list;
|
|
||||||
list = new;
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
lm_pkg_t *pkglist_add_end(lm_pkg_t *list, lm_pkg_t *pkg) {
|
|
||||||
lm_pkg_t *new = malloc(sizeof(lm_pkg_t)), *cur = list;
|
|
||||||
memcpy(new, pkg, sizeof(lm_pkg_t));
|
|
||||||
|
|
||||||
new->next = NULL;
|
|
||||||
|
|
||||||
if (NULL == cur) {
|
|
||||||
list = new;
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (cur->next != NULL)
|
|
||||||
cur = cur->next;
|
|
||||||
cur->next = new;
|
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
void pkglist_free(lm_pkg_t *list) {
|
|
||||||
lm_pkg_t *cur = list, *old = NULL;
|
|
||||||
while (cur != NULL) {
|
|
||||||
old = cur;
|
|
||||||
cur = cur->next;
|
|
||||||
free(old);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool copy_file(char *dst, char *src) {
|
bool copy_file(char *dst, char *src) {
|
||||||
FILE *dstp = NULL, *srcp = NULL;
|
FILE *dstp = NULL, *srcp = NULL;
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
Reference in New Issue
Block a user