diff --git a/build.sh b/build.sh index e13f5b43..6ee5c9cb 100755 --- a/build.sh +++ b/build.sh @@ -78,7 +78,7 @@ configure() { return 0 else echo "--[ Listing errors in config.log ]--" - cat config.log | grep error + cat config.log | grep error | tail echo "--[ Configuration failed... ]--" return 1 fi @@ -114,7 +114,7 @@ test() { #--dump \ #./test/hello.html # more complete testing - ./test.sh + ./test.sh "$BIN_SUFFIX" "$ARCHIT" } pub() { @@ -132,11 +132,23 @@ info() { file ./src/elinks$1 ls -lh ./src/elinks$1 ls -l ./src/elinks$1 - ./src/elinks --version + if [ "$ARCHIT" = "win64" || "$ARCHIT" = "win32" ]; then + wine ./src/elinks$1 --version + else + ./src/elinks$1 --version + fi } set_arch() { - if [ "$1" = "lin64" ]; then + if [ "$1" = "lin32" ]; then + ARCHIT="$1" + CC="i686-linux-gnu-gcc" + LD="i686-linux-gnu-ld" + MAKE_HOST="i686-linux-gnu" + BIN_SUFFIX="" + LDFLAGS="" + LIBS="" + elif [ "$1" = "lin64" ]; then ARCHIT="$1" CC="x86_64-linux-gnu-gcc" LD="x86_64-linux-gnu-ld" @@ -144,6 +156,14 @@ set_arch() { BIN_SUFFIX="" LDFLAGS="" LIBS="" + elif [ "$1" = "win32" ]; then + ARCHIT="$1" + CC="i686-w64-mingw32-gcc" + LD="i686-w64-mingw32-ld" + MAKE_HOST="x86_64-w32-mingw32" + BIN_SUFFIX=".exe" + LDFLAGS="" + LIBS="" elif [ "$1" = "win64" ]; then ARCHIT="$1" CC="x86_64-w64-mingw32-gcc" @@ -181,35 +201,42 @@ set_arch() { # ARCH SELECTION MENU arch_menu() { - MENU_ARCHS="$ARCHS return" + MENU_ARCHS="$ARCHS null null null null return" echo "[=] Build architecture selection menu" select SEL in $MENU_ARCHS; do echo "[=] Build architecture selection menu" - if [ "$SEL" = "lin64" ]; then - set_arch lin64 + if [ "$SEL" = "lin32" ]; then + set_arch "$SEL" + elif [ "$SEL" = "lin64" ]; then + set_arch "$SEL" elif [ "$SEL" = "win64" ]; then - set_arch win64 + set_arch "$SEL" + elif [ "$SEL" = "win32" ]; then + set_arch "$SEL" elif [ "$SEL" = "arm32" ]; then - set_arch arm32 + set_arch "$SEL" elif [ "$SEL" = "arm64" ]; then - set_arch arm64 + set_arch "$SEL" elif [ "$SEL" = "native" ]; then set_arch native elif [ "$SEL" = "make" ]; then build + elif [ "$SEL" = "null" ]; then + echo "[.] This option is intentially left blank" elif [ "$SEL" = "return" ]; then break fi - echo "--[ Compiler: " $CC " ]--" - echo "--[ Host : " $MAKE_HOST " ]--" + echo "--[ Architecture : " $ARCHIT " ]--" + echo "--[ Compiler : " $CC " ]--" + echo "--[ Host : " $MAKE_HOST " ]--" done } # MAIN LOOP ARCHIT="" BIN_SUFFIX="" -ARCHS="lin64 win64 arm32 arm64 native" -CC_SEL="arch null null null \ +ARCHS="lin32 lin64 win32 win64 arm32 arm64 native" +CC_SEL="arch null null build \ config make test \ pub debug \ info \ @@ -219,6 +246,15 @@ set_arch native select SEL in $CC_SEL; do if [ "$SEL" = "arch" ]; then arch_menu + elif [ "$SEL" = "build" ]; then + configure "$CC" "$LD" "$MAKE_HOST" "$LDFLAGS" "$LIBS" + if [ $? -eq 1 ]; then + break + fi + build + if [ $? -eq 1 ]; then + break + fi elif [ "$SEL" = "make" ]; then build elif [ "$SEL" = "config" ]; then @@ -254,6 +290,7 @@ select SEL in $CC_SEL; do exit fi echo "--[ [=] elinks build system main menu ]--" - echo "--[ Compiler: " $CC " ]--" - echo "--[ Host : " $MAKE_HOST " ]--" + echo "--[ Architecture : " $ARCHIT " ]--" + echo "--[ Compiler : " $CC " ]--" + echo "--[ Host : " $MAKE_HOST " ]--" done diff --git a/docker/win64/Dockerfile b/docker/win64/Dockerfile new file mode 100644 index 00000000..5184d4c2 --- /dev/null +++ b/docker/win64/Dockerfile @@ -0,0 +1,9 @@ +# +# [ win64 ] elinks docker development environment +# + +FROM debian:latest + +RUN apt-get update; apt-get -y install rsync vim screen git make automake gcc-mingw-w64-x86-64 bash g++-mingw-w64-x86-64 libssl-dev +RUN cd /root; git clone https://github.com/rkd77/elinks + diff --git a/docker/win64/build.sh b/docker/win64/build.sh new file mode 100755 index 00000000..6e5aa75e --- /dev/null +++ b/docker/win64/build.sh @@ -0,0 +1,2 @@ +#!/bin/bash +docker build -t "elinks-dev:latest" . diff --git a/docker/win64/cleanup.sh b/docker/win64/cleanup.sh new file mode 100755 index 00000000..ea4af352 --- /dev/null +++ b/docker/win64/cleanup.sh @@ -0,0 +1,3 @@ +#!/bin/bash +docker container rm elinks +docker image rm elinks-dev diff --git a/docker/win64/run.sh b/docker/win64/run.sh new file mode 100755 index 00000000..04a83840 --- /dev/null +++ b/docker/win64/run.sh @@ -0,0 +1,5 @@ +#!/bin/bash +docker run -it \ + --name=elinks \ + elinks-dev:latest \ + /bin/bash diff --git a/docker/win64/shell.sh b/docker/win64/shell.sh new file mode 100755 index 00000000..c74eefb2 --- /dev/null +++ b/docker/win64/shell.sh @@ -0,0 +1,3 @@ +#!/bin/bash +docker start elinks +docker exec -it elinks bash diff --git a/test.sh b/test.sh index 205dadfc..10b80d3f 100755 --- a/test.sh +++ b/test.sh @@ -17,18 +17,60 @@ echo ' ' # RUN TEST run_test() { if [ "$1" = "hello" ]; then - ./src/elinks --dump ./test/hello.html + $ELINKS --dump ./test/hello.html elif [ "$1" = "http" ]; then - ./src/elinks http://elinks.or.cz | head + echo "[=] assumes You're running https server on port 9452" + echo "[=] see http_server option" + $ELINKS \ + --dump http://127.0.0.1:9452 | head elif [ "$1" = "https" ]; then echo "[=] assumes You're running https server on port 9453" echo "[=] see https_server option" - ./src/elinks \ + $ELINKS \ -eval 'set connection.ssl.cert_verify = 0' \ --dump https://127.0.0.1:9453 | head + elif [ "$1" = "interactive" ]; then + # set 256 colors terminal + # use: export TERM=xterm-256color + # and use compiled elinks with the tests folder + if [ "$ARCH" = "win64" ]; then + export TERM=dumb + $ELINKS \ + --config-dir `pwd`/test/etc \ + ./test + else + export TERM=xterm-256color + $ELINKS \ + --config-dir `pwd`/test/etc \ + -eval 'set terminal.xterm-256color.colors = 3' \ + ./test + fi fi } +# HTTP SERVER MENU +http_menu() { + HTTP_OPTS="start_http stop_http return" + echo "" + echo "--[ http server menu ]--" + echo "" + select SEL in $HTTP_OPTS; do + echo " [*] http server menu " + if [ "$SEL" = "start_http" ]; then + python3 ./test/server/httpf.py & + PID=`echo $!` + echo $PID > /tmp/eltmpf.pid + echo "[*} Starting http server (pid $PID)" + elif [ "$SEL" = "stop_http" ]; then + PID=`cat /tmp/eltmpf.pid` + echo "[*] Stopping http server (pid $PID)" + kill $PID + elif [ "$SEL" = "return" ]; then + break + fi + done +} + # HTTPS SERVER MENU https_menu() { HTTPS_OPTS="start_https stop_https certgen return" @@ -57,16 +99,42 @@ https_menu() { } # MAIN LOOP -SEL = "none" -OPTS="hello http https null null null null null null null https_server exit" +# +# When called from build.sh it will get first +# parameter as binary suffix and second parameter +# as architecture +# +if [ -d $1 ]; then + BIN_SUFFIX="" +else + BIN_SUFFIX=$1 +fi +if [ -d $2 ]; then + ARCHIT="lin64" +else + ARCHIT=$2 +fi +echo $ARCH $BIN_SUFFIX +if [ -f ../bin/elinks_$ARCH$BIN_SUFFIX ]; then + ELINKS=../bin/elinks_$ARCH$BIN_SUFFIX +else + ELINKS=./src/elinks$BIN_SUFFIX +fi +SEL="none" +OPTS="hello http https interactive null null null null null http_server https_server exit" select SEL in $OPTS; do - echo "--[ Current test : " $SEL" ]--" + echo "[*] Current test : " $SEL + echo "[*] Current bin : " $ELINKS if [ "$SEL" = "hello" ]; then run_test $SEL elif [ "$SEL" = "http" ]; then run_test $SEL elif [ "$SEL" = "https" ]; then run_test $SEL + elif [ "$SEL" = "interactive" ]; then + run_test $SEL + elif [ "$SEL" = "http_server" ]; then + http_menu elif [ "$SEL" = "https_server" ]; then https_menu elif [ "$SEL" = "exit" ]; then diff --git a/test/server/httpf.py b/test/server/httpf.py new file mode 100755 index 00000000..2b75cd87 --- /dev/null +++ b/test/server/httpf.py @@ -0,0 +1,15 @@ +#!/usr/bin/python3 +# +# testing server for elinks http +# + +PORT = 9452 + +import http.server +import socketserver + +handler = http.server.SimpleHTTPRequestHandler + +with socketserver.TCPServer(('127.0.0.1', PORT), handler) as httpd: + print("[*] http server started at localhost:" + str(PORT)) + httpd.serve_forever()