Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
48d177965e | |||
b8243e3ee9 | |||
5ad1b09971 | |||
c8bdc795a9 | |||
88b948e186 | |||
fb9b7682e2 |
9
Makefile
9
Makefile
@ -6,7 +6,7 @@ PO_SRCS = $(wildcard locale/*/*/*.po)
|
|||||||
PO_OUTS = $(patsubst locale/%.po,locale/%.mo,$(PO_SRCS))
|
PO_OUTS = $(patsubst locale/%.po,locale/%.mo,$(PO_SRCS))
|
||||||
PO_DIRS = $(wildcard locale/*/*)
|
PO_DIRS = $(wildcard locale/*/*)
|
||||||
|
|
||||||
VERSION = 24.22
|
VERSION = 24.02
|
||||||
prefix = /usr
|
prefix = /usr
|
||||||
CC = gcc
|
CC = gcc
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ all: dist/mc $(PO_OUTS)
|
|||||||
|
|
||||||
dist/mc: $(CSRCS) $(HEADERS)
|
dist/mc: $(CSRCS) $(HEADERS)
|
||||||
mkdir -p dist
|
mkdir -p dist
|
||||||
$(CC) $(CFLAGS) $(CSRCS) -o $@ -DVERSION=\"${VERSION}\" -linih -lgit2 -lcrypto
|
$(CC) $(CFLAGS) $(CSRCS) -o $@ -DVERSION=\"${VERSION}\" -linih -lgit2 -lcurl -lcrypto
|
||||||
|
|
||||||
locale/%.mo: locale/%.po
|
locale/%.mo: locale/%.po
|
||||||
msgfmt $^ -o $@
|
msgfmt $^ -o $@
|
||||||
@ -34,8 +34,6 @@ locale/mc.pot: $(CSRCS)
|
|||||||
xgettext -k_ -c $^ -o $@
|
xgettext -k_ -c $^ -o $@
|
||||||
|
|
||||||
install:
|
install:
|
||||||
mkdir -pv $(DESTDIR)/etc/mc
|
|
||||||
mkdir -pv $(DESTDIR)/var/lib/mc
|
|
||||||
mkdir -pv $(DESTDIR)$(prefix)/bin
|
mkdir -pv $(DESTDIR)$(prefix)/bin
|
||||||
install -v -m755 dist/mc $(DESTDIR)$(prefix)/bin/mc
|
install -v -m755 dist/mc $(DESTDIR)$(prefix)/bin/mc
|
||||||
@for cmd in $(CMDS) ; do \
|
@for cmd in $(CMDS) ; do \
|
||||||
@ -47,9 +45,6 @@ install:
|
|||||||
cp $$po/mc.mo $(DESTDIR)/usr/share/$$po ; \
|
cp $$po/mc.mo $(DESTDIR)/usr/share/$$po ; \
|
||||||
done
|
done
|
||||||
|
|
||||||
defcfg:
|
|
||||||
cp -v install/cfg.default $(DESTDIR)/etc/mc/cfg
|
|
||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
rm -v $(DESTDIR)$(prefix)/bin/mc
|
rm -v $(DESTDIR)$(prefix)/bin/mc
|
||||||
@for cmd in $(CMDS) ; do \
|
@for cmd in $(CMDS) ; do \
|
||||||
|
@ -10,6 +10,7 @@ To compile `mc` and to use it, you will need the following:
|
|||||||
- make
|
- make
|
||||||
- gettext
|
- gettext
|
||||||
- libinih
|
- libinih
|
||||||
|
- curl
|
||||||
- doas (or sudo)
|
- doas (or sudo)
|
||||||
|
|
||||||
After installing these dependencies, **download the latest
|
After installing these dependencies, **download the latest
|
||||||
|
@ -7,7 +7,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-05-05 20:10+0300\n"
|
"POT-Creation-Date: 2024-05-09 23:28+0300\n"
|
||||||
"PO-Revision-Date: 2024-05-01 13:34+0300\n"
|
"PO-Revision-Date: 2024-05-01 13:34+0300\n"
|
||||||
"Last-Translator: <ngn@ngn.tf>\n"
|
"Last-Translator: <ngn@ngn.tf>\n"
|
||||||
"Language-Team: Turkish <gnome-turk@gnome.org>\n"
|
"Language-Team: Turkish <gnome-turk@gnome.org>\n"
|
||||||
@ -78,19 +78,19 @@ msgstr ""
|
|||||||
msgid "Failed to change directory to the specified directory"
|
msgid "Failed to change directory to the specified directory"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/gen.c:29 src/gen.c:36 src/pull.c:83
|
#: src/gen.c:29 src/gen.c:36 src/pull.c:95
|
||||||
msgid "Loaded repository configuration"
|
msgid "Loaded repository configuration"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/gen.c:31 src/pull.c:78
|
#: src/gen.c:31 src/pull.c:90
|
||||||
msgid "Failed to load the configuration file (mc.cfg):"
|
msgid "Failed to load the configuration file (mc.cfg):"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/gen.c:42 src/pull.c:110
|
#: src/gen.c:42 src/pull.c:122
|
||||||
msgid "Copying all the targets"
|
msgid "Copying all the targets"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/gen.c:48 src/pull.c:124
|
#: src/gen.c:48 src/pull.c:136
|
||||||
msgid "Failed to copy the target:"
|
msgid "Failed to copy the target:"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
@ -173,51 +173,51 @@ msgstr ""
|
|||||||
msgid "Please specify a config name or a URL"
|
msgid "Please specify a config name or a URL"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/pull.c:57
|
#: src/pull.c:69
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "Cloning %s"
|
msgid "Cloning %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/pull.c:62
|
#: src/pull.c:74
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "Failed to clone the %s:"
|
msgid "Failed to clone the %s:"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/pull.c:73
|
#: src/pull.c:85
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "Failed to chdir to %s"
|
msgid "Failed to chdir to %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/pull.c:86
|
#: src/pull.c:98
|
||||||
msgid "Do you want to continue?"
|
msgid "Do you want to continue?"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/pull.c:92
|
#: src/pull.c:104
|
||||||
msgid "Checking all the targets"
|
msgid "Checking all the targets"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/pull.c:98
|
#: src/pull.c:110
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "Failed to access the source for the target \"%s\""
|
msgid "Failed to access the source for the target \"%s\""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/pull.c:107
|
#: src/pull.c:119
|
||||||
msgid "All the target checks were successful"
|
msgid "All the target checks were successful"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/pull.c:118
|
#: src/pull.c:130
|
||||||
msgid "Install the target?"
|
msgid "Install the target?"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/pull.c:119
|
#: src/pull.c:131
|
||||||
msgid "Skipping target"
|
msgid "Skipping target"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/pull.c:157
|
#: src/pull.c:169
|
||||||
msgid "Installing all the requirements"
|
msgid "Installing all the requirements"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/pull.c:160
|
#: src/pull.c:172
|
||||||
msgid "Failed to run the mp-install command"
|
msgid "Failed to run the mp-install command"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
@ -253,6 +253,34 @@ msgstr ""
|
|||||||
msgid "Description"
|
msgid "Description"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/url.c:44
|
||||||
|
msgid "Failed to open /dev/null"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/url.c:51
|
||||||
|
msgid "Failed to init curl"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/url.c:63
|
||||||
|
msgid "Request failed"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/url.c:70
|
||||||
|
msgid "Failed to get the response code"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/url.c:76
|
||||||
|
msgid "Response is not a redirect"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/url.c:83
|
||||||
|
msgid "Failed to get the location header"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/url.c:89
|
||||||
|
msgid "Invalid location header"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: src/util.c:115 src/util.c:126
|
#: src/util.c:115 src/util.c:126
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "Failed to create directory: %s"
|
msgid "Failed to create directory: %s"
|
||||||
|
10
src/error.h
10
src/error.h
@ -16,6 +16,16 @@ enum ErrorCodes {
|
|||||||
RunNoRoot = 943,
|
RunNoRoot = 943,
|
||||||
RunCmdNotFound = 942,
|
RunCmdNotFound = 942,
|
||||||
RunCmdFail = 941,
|
RunCmdFail = 941,
|
||||||
|
|
||||||
|
UrlCurlFail = 940,
|
||||||
|
UrlReqFail = 939,
|
||||||
|
UrlNullFail = 938,
|
||||||
|
|
||||||
|
UrlReqCodeFail = 937,
|
||||||
|
UrlReqBadCode = 936,
|
||||||
|
|
||||||
|
UrlLocationFail = 935,
|
||||||
|
UrlLocationBad = 934
|
||||||
};
|
};
|
||||||
|
|
||||||
extern int errno;
|
extern int errno;
|
||||||
|
14
src/pull.c
14
src/pull.c
@ -4,9 +4,9 @@
|
|||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "paths.h"
|
#include "paths.h"
|
||||||
|
#include "run.h"
|
||||||
#include "url.h"
|
#include "url.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "run.h"
|
|
||||||
|
|
||||||
#include <git2.h>
|
#include <git2.h>
|
||||||
#include <git2/global.h>
|
#include <git2/global.h>
|
||||||
@ -44,6 +44,18 @@ bool pull_cmd() {
|
|||||||
else
|
else
|
||||||
repo_url = url_ensure_protocol(args.list[1]);
|
repo_url = url_ensure_protocol(args.list[1]);
|
||||||
|
|
||||||
|
if (NULL == repo_url) {
|
||||||
|
switch (errno) {
|
||||||
|
case UrlReqBadCode:
|
||||||
|
error("Specified configuration is not found");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
error("Failed to access the URL");
|
||||||
|
details(errch);
|
||||||
|
}
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
|
||||||
rmrf(mc_tmp_path);
|
rmrf(mc_tmp_path);
|
||||||
repo_root = mc_tmp_path;
|
repo_root = mc_tmp_path;
|
||||||
|
|
||||||
|
10
src/run.c
10
src/run.c
@ -1,14 +1,14 @@
|
|||||||
#include <sys/wait.h>
|
#include <spawn.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <unistd.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <spawn.h>
|
#include <sys/wait.h>
|
||||||
#include <stdio.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "util.h"
|
|
||||||
#include "run.h"
|
#include "run.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
extern char **environ;
|
extern char **environ;
|
||||||
|
|
||||||
|
72
src/url.c
72
src/url.c
@ -1,4 +1,7 @@
|
|||||||
|
#include "error.h"
|
||||||
|
#include "intl.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include <curl/curl.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -6,7 +9,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#define HUB_URL "https://matterlinux.xyz/hub/"
|
#define HUB_URL "https://matterlinux.xyz/hub"
|
||||||
|
|
||||||
bool url_is_name(char *name) {
|
bool url_is_name(char *name) {
|
||||||
for (char *c = name; *c != '\0'; c++) {
|
for (char *c = name; *c != '\0'; c++) {
|
||||||
@ -30,10 +33,71 @@ bool url_is_local(char *url) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
char *url_complete(char *name) {
|
char *url_complete(char *name) {
|
||||||
char *url = malloc(strlen(name) + strlen(HUB_URL) + 1);
|
char url[strlen(name) + strlen(HUB_URL) + 1];
|
||||||
|
|
||||||
sprintf(url, "%s/%s", HUB_URL, name);
|
sprintf(url, "%s/%s", HUB_URL, name);
|
||||||
return url;
|
|
||||||
|
FILE *devnull = fopen("/dev/null", "w");
|
||||||
|
char *location = NULL;
|
||||||
|
long code = 0;
|
||||||
|
|
||||||
|
if (NULL == devnull) {
|
||||||
|
error_set(_("Failed to open /dev/null"));
|
||||||
|
errno = UrlNullFail;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
CURL *curl = curl_easy_init();
|
||||||
|
if (NULL == curl) {
|
||||||
|
error_set(_("Failed to init curl"));
|
||||||
|
errno = UrlCurlFail;
|
||||||
|
goto CLEANUP;
|
||||||
|
}
|
||||||
|
|
||||||
|
curl_easy_setopt(curl, CURLOPT_URL, url);
|
||||||
|
curl_easy_setopt(curl, CURLOPT_USERAGENT, "libcurl/mp");
|
||||||
|
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 0L);
|
||||||
|
curl_easy_setopt(curl, CURLOPT_WRITEDATA, devnull);
|
||||||
|
CURLcode res = curl_easy_perform(curl);
|
||||||
|
|
||||||
|
if (res != CURLE_OK) {
|
||||||
|
error_set(_("Request failed"));
|
||||||
|
errno = UrlReqFail;
|
||||||
|
goto CLEANUP;
|
||||||
|
}
|
||||||
|
|
||||||
|
res = curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &code);
|
||||||
|
if (res != CURLE_OK) {
|
||||||
|
error_set(_("Failed to get the response code"));
|
||||||
|
errno = UrlReqCodeFail;
|
||||||
|
goto CLEANUP;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((code / 100) != 3) {
|
||||||
|
error_set(_("Response is not a redirect"));
|
||||||
|
errno = UrlReqBadCode;
|
||||||
|
goto CLEANUP;
|
||||||
|
}
|
||||||
|
|
||||||
|
res = curl_easy_getinfo(curl, CURLINFO_REDIRECT_URL, &location);
|
||||||
|
if (res != CURLE_OK) {
|
||||||
|
error_set(_("Failed to get the location header"));
|
||||||
|
errno = UrlLocationFail;
|
||||||
|
goto CLEANUP;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NULL == location) {
|
||||||
|
error_set(_("Invalid location header"));
|
||||||
|
errno = UrlLocationBad;
|
||||||
|
goto CLEANUP;
|
||||||
|
}
|
||||||
|
|
||||||
|
location = strdup(location);
|
||||||
|
|
||||||
|
CLEANUP:
|
||||||
|
fclose(devnull);
|
||||||
|
if (NULL != curl)
|
||||||
|
curl_easy_cleanup(curl);
|
||||||
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *url_ensure_protocol(char *url) {
|
char *url_ensure_protocol(char *url) {
|
||||||
|
Reference in New Issue
Block a user