update: finish up the pull command
This commit is contained in:
parent
d7e347175f
commit
9e8f57c175
@ -7,7 +7,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2024-05-02 23:10+0300\n"
|
||||
"POT-Creation-Date: 2024-05-02 23:20+0300\n"
|
||||
"PO-Revision-Date: 2024-05-01 13:34+0300\n"
|
||||
"Last-Translator: <ngn@ngn.tf>\n"
|
||||
"Language-Team: Turkish <gnome-turk@gnome.org>\n"
|
||||
@ -50,7 +50,7 @@ msgstr ""
|
||||
msgid "Configuration details:\n"
|
||||
msgstr ""
|
||||
|
||||
#: src/config.c:178
|
||||
#: src/config.c:178 src/target.c:119
|
||||
msgid "Name"
|
||||
msgstr ""
|
||||
|
||||
@ -82,11 +82,11 @@ msgstr ""
|
||||
msgid "Failed to load the configuration file (mc.cfg):"
|
||||
msgstr ""
|
||||
|
||||
#: src/gen.c:42
|
||||
#: src/gen.c:42 src/pull.c:109
|
||||
msgid "Copying all the targets"
|
||||
msgstr ""
|
||||
|
||||
#: src/gen.c:48
|
||||
#: src/gen.c:48 src/pull.c:121
|
||||
msgid "Failed to copy the target:"
|
||||
msgstr ""
|
||||
|
||||
@ -184,43 +184,59 @@ msgstr ""
|
||||
msgid "Do you want to continue?"
|
||||
msgstr ""
|
||||
|
||||
#: src/pull.c:88
|
||||
#: src/pull.c:91
|
||||
msgid "Checking all the targets"
|
||||
msgstr ""
|
||||
|
||||
#: src/pull.c:92
|
||||
#: src/pull.c:97
|
||||
#, c-format
|
||||
msgid "Failed to access the source for the target \"%s\""
|
||||
msgstr ""
|
||||
|
||||
#: src/pull.c:98
|
||||
msgid "All the targets are OK"
|
||||
#: src/pull.c:106
|
||||
msgid "All the target checks were successful"
|
||||
msgstr ""
|
||||
|
||||
#: src/target.c:13
|
||||
#: src/pull.c:114
|
||||
msgid "Install the target?"
|
||||
msgstr ""
|
||||
|
||||
#: src/pull.c:115
|
||||
msgid "Skipping target"
|
||||
msgstr ""
|
||||
|
||||
#: src/target.c:15
|
||||
msgid "Configuration target is missing a name"
|
||||
msgstr ""
|
||||
|
||||
#: src/target.c:18
|
||||
#: src/target.c:20
|
||||
#, c-format
|
||||
msgid "Configuration target \"%s\" does not have \"dst\" field"
|
||||
msgstr ""
|
||||
|
||||
#: src/target.c:23
|
||||
#: src/target.c:25
|
||||
#, c-format
|
||||
msgid "Configuration target \"%s\" does not have \"src\" field"
|
||||
msgstr ""
|
||||
|
||||
#: src/target.c:38
|
||||
#: src/target.c:40
|
||||
#, c-format
|
||||
msgid "Failed to open the directory: %s"
|
||||
msgstr ""
|
||||
|
||||
#: src/target.c:79
|
||||
#: src/target.c:81
|
||||
#, c-format
|
||||
msgid "Source directory \"%s\" does not exist"
|
||||
msgstr ""
|
||||
|
||||
#: src/target.c:118
|
||||
msgid "Target details:\n"
|
||||
msgstr ""
|
||||
|
||||
#: src/target.c:120
|
||||
msgid "Description"
|
||||
msgstr ""
|
||||
|
||||
#: src/util.c:115 src/util.c:126
|
||||
#, c-format
|
||||
msgid "Failed to create directory: %s"
|
||||
|
@ -2,11 +2,11 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "paths.h"
|
||||
#include "config.h"
|
||||
#include "error.h"
|
||||
#include "intl.h"
|
||||
#include "log.h"
|
||||
#include "paths.h"
|
||||
#include "util.h"
|
||||
|
||||
bool config_contains_target(config_t *config, char *name) {
|
||||
@ -100,7 +100,7 @@ int config_handler(void *data, const char *section, const char *key, const char
|
||||
config->t_last->desc = strdup(value);
|
||||
return 1;
|
||||
} else if (MATCHKEY("dst")) {
|
||||
int len = strlen(value)+strlen(mc_root)+2;
|
||||
int len = strlen(value) + strlen(mc_root) + 2;
|
||||
config->t_last->dst = malloc(len);
|
||||
join(config->t_last->dst, mc_root, value);
|
||||
return 1;
|
||||
|
@ -43,7 +43,7 @@ bool gen_cmd() {
|
||||
bar_init();
|
||||
|
||||
while (cur && ++counter > 0) {
|
||||
if(!target_copy(cur, true)){
|
||||
if (!target_copy(cur, true)) {
|
||||
bar_free();
|
||||
error(_("Failed to copy the target:"));
|
||||
details(errch);
|
||||
|
37
src/pull.c
37
src/pull.c
@ -85,17 +85,48 @@ COPY:
|
||||
if (!yesno(_("Do you want to continue?")))
|
||||
goto END;
|
||||
|
||||
info(_("Checking all the targets"));
|
||||
target_t *cur = repo_cfg.t_first;
|
||||
while (NULL != cur) {
|
||||
int counter = 0;
|
||||
|
||||
info(_("Checking all the targets"));
|
||||
bar_init();
|
||||
|
||||
while (NULL != cur && ++counter > 0) {
|
||||
if (!exists(cur->src)) {
|
||||
bar_free();
|
||||
error(_("Failed to access the source for the target \"%s\""), cur->name);
|
||||
goto END;
|
||||
}
|
||||
|
||||
cur = cur->next;
|
||||
bar(counter, repo_cfg.t_len);
|
||||
}
|
||||
|
||||
bar_free();
|
||||
success(_("All the target checks were successful"));
|
||||
|
||||
cur = repo_cfg.t_first;
|
||||
info(_("Copying all the targets"));
|
||||
|
||||
while (cur && ++counter > 0) {
|
||||
target_print(cur);
|
||||
|
||||
if (!yesno(_("Install the target?"))) {
|
||||
info(_("Skipping target"));
|
||||
cur = cur->next;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!target_copy(cur, false)) {
|
||||
error(_("Failed to copy the target:"));
|
||||
details(errch);
|
||||
goto END;
|
||||
}
|
||||
|
||||
cur = cur->next;
|
||||
}
|
||||
|
||||
success(_("All the targets are OK"));
|
||||
ret = true;
|
||||
|
||||
END:
|
||||
if (repo_cfg.name != NULL)
|
||||
|
15
src/target.c
15
src/target.c
@ -1,10 +1,12 @@
|
||||
#include "target.h"
|
||||
#include "error.h"
|
||||
#include "intl.h"
|
||||
#include "log.h"
|
||||
#include "util.h"
|
||||
|
||||
#include <libgen.h>
|
||||
#include <dirent.h>
|
||||
#include <libgen.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
@ -44,7 +46,7 @@ bool target_copy_dir(char *src, char *dst) {
|
||||
size_t dst_len = strlen(dst);
|
||||
|
||||
while ((ent = readdir(dir)) != NULL) {
|
||||
if(eq(ent->d_name, ".") || eq(ent->d_name, ".."))
|
||||
if (eq(ent->d_name, ".") || eq(ent->d_name, ".."))
|
||||
continue;
|
||||
|
||||
size_t len = strlen(ent->d_name);
|
||||
@ -87,7 +89,7 @@ bool target_copy(target_t *t, bool fromdst) {
|
||||
char *dstcp = strdup(dst);
|
||||
char *dstdir = dirname(dst);
|
||||
|
||||
if(!mksubdirsp(dstdir, 0755))
|
||||
if (!mksubdirsp(dstdir, 0755))
|
||||
return ret;
|
||||
|
||||
ret = copyfile(src, dstcp);
|
||||
@ -111,3 +113,10 @@ void target_free(target_t *t) {
|
||||
free(t->src);
|
||||
clist_free(&t->requires);
|
||||
}
|
||||
|
||||
void target_print(target_t *t) {
|
||||
info(_("Target details:\n"));
|
||||
printf(COLOR_BOLD " %s " COLOR_RESET "=> %s\n", _("Name"), t->name);
|
||||
printf(COLOR_BOLD " %s " COLOR_RESET "=> %s\n", _("Description"), t->desc);
|
||||
printf("\n");
|
||||
}
|
||||
|
@ -15,3 +15,4 @@ bool target_is_valid(target_t *);
|
||||
void target_init(target_t *);
|
||||
void target_free(target_t *);
|
||||
bool target_copy(target_t *, bool);
|
||||
void target_print(target_t *);
|
||||
|
12
src/util.c
12
src/util.c
@ -111,7 +111,7 @@ bool mksubdirsp(char *path, int perms) {
|
||||
for (char *c = path; *c != '\0'; c++) {
|
||||
if (*c == '/' && indx != 0) {
|
||||
cur[indx] = '\0';
|
||||
if (!exists(cur) && mkdir(cur, perms) < 0){
|
||||
if (!exists(cur) && mkdir(cur, perms) < 0) {
|
||||
error_set(_("Failed to create directory: %s"), cur);
|
||||
errno = MkdirFail;
|
||||
return false;
|
||||
@ -122,7 +122,7 @@ bool mksubdirsp(char *path, int perms) {
|
||||
indx++;
|
||||
}
|
||||
|
||||
if (!exists(cur) && mkdir(cur, perms) < 0){
|
||||
if (!exists(cur) && mkdir(cur, perms) < 0) {
|
||||
error_set(_("Failed to create directory: %s"), cur);
|
||||
errno = MkdirFail;
|
||||
return false;
|
||||
@ -196,12 +196,12 @@ void clist_add(clist_t *l, char *en) {
|
||||
l->s++;
|
||||
}
|
||||
|
||||
bool copyfile(char *src, char *dst){
|
||||
bool copyfile(char *src, char *dst) {
|
||||
FILE *srcf = fopen(src, "r");
|
||||
FILE *dstf = fopen(dst, "w");
|
||||
|
||||
if(NULL == srcf || NULL == dstf){
|
||||
if(NULL == srcf)
|
||||
if (NULL == srcf || NULL == dstf) {
|
||||
if (NULL == srcf)
|
||||
error_set(_("Failed to open \"%s\" for reading"), srcf);
|
||||
else
|
||||
error_set(_("Failed to open \"%s\" for writing"), dstf);
|
||||
@ -214,7 +214,7 @@ bool copyfile(char *src, char *dst){
|
||||
|
||||
bzero(buffer, 32);
|
||||
|
||||
while((read = fread(buffer, 1, 32, srcf)) > 0)
|
||||
while ((read = fread(buffer, 1, 32, srcf)) > 0)
|
||||
fwrite(buffer, 1, read, dstf);
|
||||
|
||||
fclose(srcf);
|
||||
|
Loading…
Reference in New Issue
Block a user