1
0
Fork 0

Merge pull request #155 from mtatton/master

[ build ] win64 docker env, http server
This commit is contained in:
rkd77 2022-04-24 14:48:08 +02:00 committed by GitHub
commit e1aa3fe517
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 164 additions and 22 deletions

View File

@ -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

9
docker/win64/Dockerfile Normal file
View File

@ -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

2
docker/win64/build.sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/bash
docker build -t "elinks-dev:latest" .

3
docker/win64/cleanup.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
docker container rm elinks
docker image rm elinks-dev

5
docker/win64/run.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash
docker run -it \
--name=elinks \
elinks-dev:latest \
/bin/bash

3
docker/win64/shell.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
docker start elinks
docker exec -it elinks bash

80
test.sh
View File

@ -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

15
test/server/httpf.py Executable file
View File

@ -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()