summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile5
-rw-r--r--contrib/build-env-setup/README.md39
-rw-r--r--src/gateleen_resclone/gateleen_resclone.c14
3 files changed, 48 insertions, 10 deletions
diff --git a/Makefile b/Makefile
index 5ce9593..4235867 100644
--- a/Makefile
+++ b/Makefile
@@ -68,12 +68,13 @@ build/bin/gateleen-resclone$(BINEXT): \
@echo "\n[\033[34mINFO \033[0m] Linking '$@'"
@mkdir -p $(shell dirname $@)
$(CC) -o $@ $(LDFLAGS) $^ $(LIBSDIR) \
+ -Wl,-Bstatic \
-larchive -lcurl -lcJSON $(LPCREPOSIX) $(LPCRE) \
+ -Wl,-Bdynamic \
build/lib/libGateleenResclone$(LIBSEXT): \
build/obj/array/array.o \
build/obj/gateleen_resclone/gateleen_resclone.o \
- build/obj/log/log.o \
build/obj/mime/mime.o \
build/obj/util_term/util_term.o
@echo "\n[\033[34mINFO \033[0m] Archive '$@'"
@@ -103,7 +104,7 @@ dist: clean link
rm -rf build/dist-bin && mkdir -p build/dist-bin
mv -t build/dist-bin \
build/dist-src/README* \
- build/dist-src/LICENCE* \
+ build/dist-src/LICENSE* \
build/dist-src/MANIFEST.INI
mkdir build/dist-bin/bin
mv -t build/dist-bin/bin \
diff --git a/contrib/build-env-setup/README.md b/contrib/build-env-setup/README.md
index 14ac679..89fcb01 100644
--- a/contrib/build-env-setup/README.md
+++ b/contrib/build-env-setup/README.md
@@ -80,9 +80,13 @@ true \
&& GIT_TAG="master" \
&& LIBARCHIVE_VERSION="3.6.2" \
&& CURL_VERSION="8.3.0" \
+ && CJSON_VERSION="1.7.15" \
\
&& WORKDIR="/home/${USER}/work" \
&& INSTALL_ROOT="/usr/${HOST:-local}" \
+ && CJSON_URL="https://github.com/DaveGamble/cJSON/archive/refs/tags/v${CJSON_VERSION:?}.tar.gz" \
+ && CJSON_SRCTGZ="/var/tmp/cJSON-${CJSON_VERSION:?}.tgz" \
+ && CJSON_BINTGZ="${CJSON_SRCTGZ%.*}-bin.tgz" \
&& CURL_VERSION_UGLY="$(echo "$CURL_VERSION"|sed 's;\.;_;g')" \
&& CURL_URL="https://github.com/curl/curl/archive/refs/tags/curl-${CURL_VERSION_UGLY:?}.tar.gz" \
&& CURL_SRCTGZ="/var/tmp/curl-${CURL_VERSION:?}.tgz" \
@@ -92,6 +96,11 @@ true \
&& LIBARCHIVE_BINTGZ="${LIBARCHIVE_SRCTGZ%.*}-bin.tgz" \
\
&& ${PKGINIT:?} && ${PKGADD:?} $PKGS_TO_ADD \
+ && printf '\n Download Dependency Sources\n\n'
+ && if test ! -e "${CJSON_SRCTGZ:?}"; then true \
+ && echo "Download ${CJSON_URL:?}" \
+ && curl -sSLo "${CJSON_SRCTGZ:?}" "${CJSON_URL:?}" \
+ ;fi \
&& if test ! -e "${LIBARCHIVE_SRCTGZ:?}"; then true \
&& echo "Download ${LIBARCHIVE_URL:?}" \
&& curl -sSLo "${LIBARCHIVE_SRCTGZ:?}" "${LIBARCHIVE_URL:?}" \
@@ -100,7 +109,32 @@ true \
&& echo "Download ${CURL_URL:?}" \
&& curl -sSLo "${CURL_SRCTGZ:?}" "${CURL_URL:?}" \
;fi \
+ && if test ! -e "${CJSON_BINTGZ:?}"; then (true \
+ && printf '\n Build cJSON\n\n' \
+ && cd /tmp \
+ && tar xf "${CJSON_SRCTGZ:?}" \
+ && cd "cJSON-${CJSON_VERSION:?}" \
+ && mkdir build build/obj build/lib build/include \
+ && CFLAGS="-Wall -pedantic -fPIC" \
+ && ${HOST_}cc $CFLAGS -c -o build/obj/cJSON.o cJSON.c \
+ && ${HOST_}cc $CFLAGS -shared -o build/lib/libcJSON.so.${CJSON_VERSION:?} build/obj/cJSON.o \
+ && unset CFLAGS \
+ && (cd build/lib \
+ && MIN=${CJSON_VERSION%.*} && MAJ=${MIN%.*} \
+ && ln -s libcJSON.so.${CJSON_VERSION:?} libcJSON.so.${MIN:?} \
+ && ln -s libcJSON.so.${MIN:?} libcJSON.so.${MAJ} \
+ ) \
+ && ar rcs build/lib/libcJSON.a build/obj/cJSON.o \
+ && cp -t build/. LICENSE README.md \
+ && cp -t build/include/. cJSON.h \
+ && rm -rf build/obj \
+ && (cd build && tar --owner=0 --group=0 -czf "${CJSON_BINTGZ:?}" *) \
+ && cd /tmp \
+ && rm -rf "cJSON-${CJSON_VERSION:?}" \
+ && $SUDO tar -C /usr/local -xzf "${CJSON_BINTGZ:?}" \
+ );fi \
&& if test ! -e "${LIBARCHIVE_BINTGZ}"; then (true \
+ && printf '\n Build libarchive\n\n' \
&& cd /tmp \
&& tar xf "${LIBARCHIVE_SRCTGZ:?}" \
&& cd "libarchive-${LIBARCHIVE_VERSION:?}" \
@@ -109,10 +143,10 @@ true \
&& rm -rf build/usr_local/lib/pkgconfig \
&& (cd build/usr_local && tar --owner=0 --group=0 -czf "${LIBARCHIVE_BINTGZ:?}" *) \
&& cd /tmp && rm -rf "libarchive-${LIBARCHIVE_VERSION:?}" \
- && $SUDO tar -C /usr/local -xzf "${LIBARCHIVE_BINTGZ}" \
+ && $SUDO tar -C /usr/local -xzf "${LIBARCHIVE_BINTGZ:?}" \
);fi \
&& if test ! -e "${CURL_BINTGZ:?}"; then (true
-
+ && printf '\n Build curl\n\n' \
&& cd /tmp \
&& tar xf "${CURL_SRCTGZ:?}" \
&& cd "curl-curl-${CURL_VERSION_UGLY:?}" \
@@ -123,6 +157,7 @@ true \
&& (cd build/usr_local && tar --owner=0 --group=0 -czf "${CURL_BINTGZ:?}" *) \
&& cd /tmp \
&& rm -rf "curl-curl-${CURL_VERSION_UGLY:?}" \
+ && $SUDO tar -C /usr/local -xzf "${CURL_BINTGZ:?}" \
);fi \
&& printf '\n Build project itself\n\n' \
diff --git a/src/gateleen_resclone/gateleen_resclone.c b/src/gateleen_resclone/gateleen_resclone.c
index f97373b..7f8c65f 100644
--- a/src/gateleen_resclone/gateleen_resclone.c
+++ b/src/gateleen_resclone/gateleen_resclone.c
@@ -114,7 +114,7 @@ TPL_ARRAY(str, char*, 16);
static void printHelp( void ){
printf("%s%s%s",
" \n"
- " ", strrchr(filename,'/')+1, " - " STR_QUOT(PROJECT_VERSION) "\n"
+ " ", strrchr(__FILE__,'/')+1, " - " STR_QUOT(PROJECT_VERSION) "\n"
" \n"
" Options:\n"
" \n"
@@ -123,6 +123,7 @@ static void printHelp( void ){
" \n"
" --url <url>\n"
" Root node of remote tre\n"
+ " \n"
" --filter-part <path-filter>\n"
" Regex pattern applied as predicate to the path starting after\n"
" the path specified in '--url'. Each path segment will be\n"
@@ -254,14 +255,14 @@ static int parseArgs( int argc, char**argv, OpMode*mode, char**url, regex_t**fil
//fprintf(stderr, "%s%u%s%p\n",
// "[DEBUG] realloc(NULL, ", filter_cap*sizeof**filter," ) -> ", tmp);
if( tmp == NULL ){
- fprintf(stderr, "%s%d%s\n", "[ERROR] realloc(", filter_cap*sizeof**filter, ")");
+ fprintf(stderr, "%s%lu%s\n", "[ERROR] realloc(", filter_cap*sizeof**filter, ")");
err = -ENOMEM; goto fail; }
*filter = tmp;
}
//fprintf(stderr, "%s%d%s%s%s\n", "[DEBUG] filter[", iSegm, "] -> '", beg-1, "'");
err = regcomp((*filter)+iSegm, beg-1, REG_EXTENDED);
if( err ){
- fprintf(stderr, "%s%s%s%d\n", "[ERROR] regcomp(", beg, ") -> ", err);
+ fprintf(stderr, "%s%s%s%ld\n", "[ERROR] regcomp(", beg, ") -> ", err);
err = -1; goto fail; }
/* Restore surrounding stuff. */
beg[-1] = origBeg;
@@ -295,6 +296,7 @@ fail:
static size_t onCurlDirRsp( char*buf, size_t size, size_t nmemb, void*ResourceDir_ ){
+ int err;
fprintf(stderr, "%s%s%s%p%s%ld%s%ld%s%p%s\n", "[TRACE] ", __func__, "( buf=", buf,
", size=", size, ", nmemb=", nmemb, ", cls=", ResourceDir_, " )");
ResourceDir *resourceDir = ResourceDir_;
@@ -460,7 +462,7 @@ static ssize_t pathFilterAcceptsEntry( ClsDload*dload, ResourceDir*resourceDir,
//fprintf(stderr, "%s\n", "[DEBUG] Segment rejected by filter.");
err = 0; /* fall to restoreEndSlash */
}else{
- fprintf(stderr, "%s%.*s%s%d\n", "[ERROR] regexec(rgx, '", (int)name_len, name, "') -> ", err);
+ fprintf(stderr, "%s%.*s%s%ld\n", "[ERROR] regexec(rgx, '", (int)name_len, name, "') -> ", err);
err = -1; /* fall to restoreEndSlash */
}
if( restoreEndSlash ){
@@ -716,7 +718,7 @@ static ssize_t addContentTypeHeader( Put*put, struct curl_slist *reqHdrs ){
reqHdrs = curl_slist_append(reqHdrs, contentTypeHdr);
err = curl_easy_setopt(upload->curl, CURLOPT_HTTPHEADER, reqHdrs);
if( err ){
- fprintf(stderr, "%s\n", "[ERROR] curl_easy_setopt(_, HTTPHEADER, _)", err);
+ fprintf(stderr, "%s%ld\n", "[ERROR] curl_easy_setopt(_, HTTPHEADER, _): ", err);
assert(!err); err = -1; goto endFn; }
err = 0;
@@ -738,7 +740,7 @@ static ssize_t httpPutEntry( Put*put ){
}
int url_len = strlen(upload->rootUrl) + strlen(put->name);
url = malloc(url_len +2);
- if( url = NULL ){
+ if( url == NULL ){
err = -ENOMEM; goto endFn; }
sprintf(url, "%.*s/%s", rootUrl_len,upload->rootUrl, put->name);
err = CURLE_OK != curl_easy_setopt(upload->curl, CURLOPT_URL, url)