From ae15c20e53976378046fcfa6b866f537b039ffad Mon Sep 17 00:00:00 2001 From: Kubat <mael.martin31@gmail.com> Date: Mon, 21 Sep 2020 10:42:24 +0200 Subject: [PATCH] MISC: Dependencies dl update - download and build dependencies with configure - add libcurl - add zlib - add iconv - sdl2 without touchscreen - compile using -fPIC - add openssl for libcurl --- README.md | 10 +++++++ configure | 8 ++++++ configure.ac | 8 ++++++ depends/depends.txt | 4 +++ depends/rules.txt | 8 ++++-- scripts/depends.bash | 62 +++++++++++++++++++++++++++++++++------- src/module/module_repo.c | 6 ++-- 7 files changed, 90 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index dfbf6dbd..3cb2f80b 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,16 @@ configuration file: archlinux, seems to be distributed in its own package on debian: [xxd](https://packages.debian.org/sid/xxd) +If you use the configure with the `--with-depends` option (needed on debian +10), you will need the following dependencies: + +- the `curl` command line utility +- the `wget` command line utility +- the `git` command line utility + +Note that because of the use of `curl` and `get`, building behind a proxy may +be challenging. + The manual way of installing and setting up lektor: ```sh diff --git a/configure b/configure index c997750d..f3bbe3e1 100755 --- a/configure +++ b/configure @@ -13686,6 +13686,14 @@ fi CFLAGS="${CFLAGS} -I$PWD/depends_install/include -L$PWD/depends_install/lib" + + # Download and build dependencies + cd $LKT_PATH_SOURCE + ./scripts/depends.bash $LKT_PATH_BUILD + if test $? -ne 0 ; then + as_fn_error 1 "\"Failed to download and build dependencies\"" "$LINENO" 5 + fi + cd $LKT_PATH_BUILD fi ########## diff --git a/configure.ac b/configure.ac index 711dc54e..d9accc89 100644 --- a/configure.ac +++ b/configure.ac @@ -146,6 +146,14 @@ if test "x$LKT_BUILD_DEPENDS" = "xyes" ; then LKT_LIB_DIR="$PWD/depends_install/lib" AC_DISABLE_SHARED CFLAGS="${CFLAGS} -I$PWD/depends_install/include -L$PWD/depends_install/lib" + + # Download and build dependencies + cd $LKT_PATH_SOURCE + ./scripts/depends.bash $LKT_PATH_BUILD + if test $? -ne 0 ; then + AC_MSG_ERROR("Failed to download and build dependencies", [1]) + fi + cd $LKT_PATH_BUILD fi ########## diff --git a/depends/depends.txt b/depends/depends.txt index 2364b89b..1919fe6d 100644 --- a/depends/depends.txt +++ b/depends/depends.txt @@ -1,2 +1,6 @@ curl sqlite3 https://www.sqlite.org/src/tarball/sqlite.tar.gz?r=release sqlite3.tar.gz wget sdl2 https://www.libsdl.org/release/SDL2-2.0.12.tar.gz sdl2.tar.gz +wget libcurl https://curl.haxx.se/download/curl-7.72.0.tar.gz libcurl.tar.gz +wget zlib https://zlib.net/zlib-1.2.11.tar.gz zlib.tar.gz +wget iconv https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.16.tar.gz iconv.tar.gz +git openssl git://git.openssl.org/openssl.git openssl -b OpenSSL_1_1_1-stable diff --git a/depends/rules.txt b/depends/rules.txt index 21129e4c..19275750 100644 --- a/depends/rules.txt +++ b/depends/rules.txt @@ -1,2 +1,6 @@ -sqlite3 configure --disable-shared --disable-tcl -sdl2 configure --disable-shared --enable-fcitx +zlib zconfigure --static --64 +iconv configure --disable-shared +openssl sslconfigure no-shared -fPIC no-hw +sqlite3 configure --disable-shared --disable-tcl CFLAGS=-fPIC --enable-update-limit +sdl2 configure --disable-shared --enable-fcitx --enable-input-tslib=no CFLAGS=-fPIC --enable-joystick=no +libcurl configure --disable-shared --without-zlib --enable-optimize --disable-rt --disable-pop3 --disable-imap --disable-rtsp --disable-smtp --disable-smb --disable-smbs --disable-dict --disable-tftp --enable-https --enable-http --enable-mime --disable-threaded-resolver --without-zsh-functions-dir --without-fish-functions-dir --with-ssl=__BUILD_DIR__ --with-zlib=__BUILD_DIR__ diff --git a/scripts/depends.bash b/scripts/depends.bash index 2737868d..237550d8 100755 --- a/scripts/depends.bash +++ b/scripts/depends.bash @@ -25,6 +25,15 @@ function wget () [ $? -ne 0 ] && die "Failed to download $1" } +function git () +{ + local URL=$1 + local DEST=$2 + shift 2 + $GIT clone $URL $DEST $* + [ $? -ne 0 ] && die "Failed to clone $URL into folder $DEST with options $OPT" +} + function get () { local NUM=$1 @@ -54,6 +63,8 @@ WGET=`which wget 2>/dev/null` [ $? -ne 0 ] && die "Failed to find the wget binary" TAR=`which tar 2>/dev/null` [ $? -ne 0 ] && die "Failed to find the tar binary" +GIT=`which git 2>/dev/null` +[ $? -ne 0 ] && die "Failed to find the git binary" ! [ -f $DEPENDS_FILE ] && die "You must run this script from the root of the project" ! [ -f $PWD/scripts/depends.bash ] && die "You must run thus script from the root of the project" @@ -71,22 +82,26 @@ do FUNC=`get 1 $LINE` FOLD=`get 2 $LINE` URL=`get 3 $LINE` - TAR_FILE=`get 4 $LINE` + DEST=`get 4 $LINE` + OPT=`get_from 5 $LINE` - if [ -f depends/$TAR_FILE ] + if [ -f depends/$DEST ] || [ -d depends/$DEST ] then echo "Dependency $FOLD is already downloaded," \ - "remove depends/$TAR_FILE and depends/$FOLD to re-download it" + "remove depends/$DEST and depends/$DEST to re-download it" continue fi - echo "Downloading $FOLD from $URL to depends/$TAR_FILE" + echo "Downloading $FOLD from $URL to depends/$DEST" case $FUNC in wget) - wget $URL depends/$TAR_FILE + wget $URL depends/$DEST ;; curl) - curl $URL depends/$TAR_FILE + curl $URL depends/$DEST + ;; + git) + git $URL depends/$DEST $OPT ;; esac done < $DEPENDS_FILE @@ -114,6 +129,9 @@ do TYPE=`get 2 $LINE` OPT=`get_from 3 $LINE` + # Replace __VARIABLES__ from the OPT variable + OPT=`echo "$OPT" | sed -e "s+__BUILD_DIR__+$BUILD_DIR/depends_install/+g"` + ! [ -d $BUILD_DIR/depends/$FOLD ] && mkdir -p $BUILD_DIR/depends/$FOLD ! [ -d $BUILD_DIR/depends/$FOLD ] && die "Failed to create the build folder" \ "for $FOLD" @@ -125,19 +143,41 @@ do continue fi + # Go to right folder cd $BUILD_DIR/depends/$FOLD - $ROOT_DIR/depends/$FOLD/configure --prefix=$ABS_BUILD_DIR/depends_install CC=$CC CXX=$CXX $OPT - [ $? -ne 0 ] && die "Failed to configure $FOLD" + # Types of builds + case "$TYPE" in + configure) + $ROOT_DIR/depends/$FOLD/configure --prefix=$ABS_BUILD_DIR/depends_install CC=$CC CXX=$CXX $OPT + [ $? -ne 0 ] && die "Failed to configure $FOLD" + ;; + zconfigure) + # The CC= and CXX= doesn't work for zlib + # TODO pour le Kubat du futur: trouver un moyen uniforme de passer le '-fPIC' + CFLAGS="-fPIC" $ROOT_DIR/depends/$FOLD/configure --prefix=$ABS_BUILD_DIR/depends_install $OPT + [ $? -ne 0 ] && die "Failed to configure $FOLD" + ;; + sslconfigure) + # Yes, we need to call Configure and not configure here... + # TODO pour le Kubat du futur: trouver un moyen de pas ardcoder le linux-x86_64 (build FreeBSD, OSX et autres) + $ROOT_DIR/depends/$FOLD/Configure --prefix=$ABS_BUILD_DIR/depends_install $OPT linux-x86_64 + [ $? -ne 0 ] && die "Failed to configure $FOLD" + ;; + esac + + # Common part make -j$NPROC [ $? -ne 0 ] && die "Failed to make $FOLD, build folder is $BUILD_DIR/depends/$FOLD" make install - [ $? -ne 0 ] && die "Failed to install $FOLD, build folder is $BUILD_DIR/depends/$FOLD" \ - ", install folder is $ROOT_DIR/depends_install" + [ $? -ne 0 ] && die "Failed to install $FOLD, build folder is " \ + "$BUILD_DIR/depends/$FOLD, install folder " \ + "is $ROOT_DIR/depends_install" + # Exit folder and mark it as compiled touch .lektor cd $ROOT_DIR echo "Finished to build $FOLD, result is in $BUILD_DIR/depends/$FOLD" done < $RULES_FILE -# Use CC and CXX +# vim:syntax=sh ts=4 sw=4 expandtab diff --git a/src/module/module_repo.c b/src/module/module_repo.c index 53ca2975..4d2cbc29 100644 --- a/src/module/module_repo.c +++ b/src/module/module_repo.c @@ -111,8 +111,7 @@ __safe_json_get_string(struct json_object *jobj, const char *key, { const char *got; struct json_object *field; - RETURN_UNLESS(json_object_object_get_ex(jobj, key, &field), - "Key not found in json", 1); + RETURN_UNLESS(json_object_object_get_ex(jobj, key, &field), "Key not found in json", 1); got = json_object_get_string(field); RETURN_UNLESS(got, "Got a NULL for the key, may be an error", 1); strncpy(content, got, len - 1); @@ -151,7 +150,8 @@ __json_sync(struct module_repo_internal *repo, struct json_object **json) res = curl_easy_perform(curl_handle); if (res != CURLE_OK) { - LOG_ERROR("CURL", "curl_easy_perform failed: %s", curl_easy_strerror(res)); + LOG_ERROR("CURL", "curl_easy_perform failed on url %s: %s", repo->get_all_json, + curl_easy_strerror(res)); goto err; } -- GitLab